From nobody at nowhere.nohow Thu Sep 14 16:54:42 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Thu, 14 Sep 2000 20:54:42 GMT Subject: Public Domain Python References: Message-ID: In article , William Tanksley wrote: >This time it's a little scarier, because what we see is a company which >has NO ongoing responsibity for Python excercising ongoing authority. That >IS frightening, even for me. They have almost no accountability to their >users now, and will not have any at all in the future -- yet they're >attempting to excercise authority over our use of a tool which we accepted >under very different terms. Gee, a company with no ongoing responsibility for a piece of software, no accountability to their users (now or future) who tries to exercise authority over our use of a tool. That sounds _exactly_ like all of the commercial software vendors I've ever dealt with. The difference is that with things like Python, gdb, etc. 1) the quality of the product is a lot better to start with, 2) when bugs are found they get acknowleged and fixed 3) when I buy a new computer I don't have to pay a butt-load of money to move a buggy piece of node-locked crud to a new machine. 4) if other people stop supporting the product I at least have the choice of supporting it myself if I want to. I've been doing real-time embedded software for 15+ years, and I just finished my first project using 100% open-source development tools. My experience is that open source tools completely outclass commercial tools in every respect. Better tools, better service, better documentation. -- Grant Edwards grante Yow! I want the presidency at so bad I can already taste visi.com the hors d'oeuvres. From jurgen.defurne at philips.com Mon Sep 18 04:19:32 2000 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Mon, 18 Sep 2000 10:19:32 +0200 Subject: What is Python? Message-ID: <0056900011869861000002L012*@MHS> thor at localhost.localdomain@SMTP at python.org on 15/09/2000 22:24:32 Please respond to irmina at ctv.es@SMTP Sent by: python-list-admin at python.org To: python-list at python.org@SMTP cc: Subject: Re: What is Python? Classification: On Fri, 1 Tim Hammerquist wrote: >Martijn Faassen wrote: >> Hah (insert evil cackle here), you say this *now*, but you'll find you'll >> be doing more and more in Python, slowly seduced to the dark side.. > > >There's a reason Perl is symbolized by the Camel; it was an intentional >metaphor by the author: it's ugly, it stinks, but it does the job and >does it well. Arabs prefer horses. So camel may not be such a good animal, after all. P.S.: I thought the camel symbol symbolized the ugly face of Larry Wall. --- MGA -- http://www.python.org/mailman/listinfo/python-list For Arabians, a horse is a symbol of wealth. They don't use horses for work. Those horses are from a military inheritance. If you want to use a horse, then you should take the original farmer's horse, the "Brabants Boerenpaard" (no, this isn't South African) (difficult to translate).. Jurgen From howard at eegsoftware.com Mon Sep 25 13:02:18 2000 From: howard at eegsoftware.com (howard at eegsoftware.com) Date: Mon, 25 Sep 2000 17:02:18 GMT Subject: SWIG help for newbie References: <8qlp24$e8h$1@nnrp1.deja.com> <39ceec45.138950231@news-server.socal.rr.com> <8qnkfk$eav$1@nnrp1.deja.com> Message-ID: <39cf8426.177837690@news-server.socal.rr.com> On Mon, 25 Sep 2000 13:37:59 GMT, Charles Medcoff wrote: >Thanks for the tip. This did eliminate the include problem. The >linker problem remains. Sorry, I didn't read closely enough. Even though it's not EXPLICITLY stated in the Embedding and Extending manual section, I believe you need to have an entry point called 'initspam' where 'spam' is the NAME of our module. This is the named point called by the import loader. >By the way, the version of SWIG that I have is reported as SWIG Version >1.3u-20000618-1136 (Alpha 3). The zip file was named Swig1.3a3NT.zip. >This would seem to imply that the problem has not been fixed in 1.3x. > >I'm using this because it is the latest version that includes a binary >for the windows platform. (I've got enough problems trying to build >python and my extension, I don't want to tackle building SWIG also.) > SWIG 1.3a4 worked for me. I built just fine on VC6 SP3. But, I know how you feel because I had to take on CVS, SWIG, Python extentions, and an in-development library all at once. I am still plugging away learning lots of new thingeys. SWIG was the easy part. Howard Lightstone EEGSoftware howard at eegsoftware.com From bjorn at roguewave.com Mon Sep 18 15:24:31 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Mon, 18 Sep 2000 13:24:31 -0600 Subject: Classes and keywords References: <39C66436.47C1216D@t-online.de> Message-ID: <39C66BEF.C4A425A6@roguewave.com> The problem you're seeing is that self (in the set method) is not defined until you get to the method _body_. A possible workaround is: def set(self, w=None): if w is None: w = self.k return w * w -- bjorn Michael Husmann wrote: > > The following code is refused by python and I wonder why: > > import sys > > class Foo: > def __init__(self): > self.k = 0 > > def set(self, w=self.k): > return w * w > > def main(): > k = Foo() > print k.set(9) > > if __name__ == "__main__": main() > > Traceback (most recent call last): > File "", line 11, in ? > File "", line 15, in Foo > NameError: There is no variable named 'self' > > Is there someone who can help me using such a keyword argument like I > have done in that 'set' function. > -- > http://www.python.org/mailman/listinfo/python-list From ge at nowhere.none Thu Sep 14 13:58:12 2000 From: ge at nowhere.none (Grant Edwards) Date: Thu, 14 Sep 2000 17:58:12 GMT Subject: One last shot at the Augmented Assignment PEP References: <20000913160209.D52541CF42@dinsdale.python.org> <39BFC44E.FD6CB79C@rsv.ricoh.com> <8pous80tul@news1.newsguy.com> Message-ID: In article <8pous80tul at news1.newsguy.com>, Alex Martelli wrote: >Without the polymorphism over mutable objects wrt immutable >ones, += and its ilk would be mere syntactic sugar of no big >real interest. WITH the polymorphism, they become a precious >innovation. Call them "mutation-suggestors with fallback to >rebinding if the object is immutable", if you wish, because >that is what they are. This leads into the an new field: programming via suggestions and hints I suppose if you really want assignment you can do it explicitly with the old syntax. If you know that you really want mutation, you can use the method call to make it explicit. That way you get the proper error if you try to mutate an immutable object. -- Grant Edwards grante Yow! My FAVORITE group at is "QUESTION MARK & THE visi.com MYSTERIANS"... From aahz at panix.com Mon Sep 18 22:15:07 2000 From: aahz at panix.com (Aahz Maruch) Date: 18 Sep 2000 19:15:07 -0700 Subject: NULL vs. None and MySQLdb References: <4568.12.17.189.202.969323176.squirrel@webmail.integritysi.com> Message-ID: <8q6i7b$7iu$1@panix6.panix.com> In article <4568.12.17.189.202.969323176.squirrel at webmail.integritysi.com>, Geoffrey L. Wright wrote: > >str(row) seems to return NULL values as None. Any easy way to have it >return NULL as NULL? None is the Python equivalent of NULL; what's wrong with None? -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 The best way to get information on Usenet is not to ask a question, but to post the wrong information. --Aahz From nobody at nowhere.nohow Thu Sep 7 03:26:21 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Thu, 07 Sep 2000 07:26:21 GMT Subject: Python 2.0b1 is released! References: Message-ID: Tim Peters wrote: >We have no control over CNRI's license, and neither have we any say in what >the FSF thinks about it. Perhaps this question has been answered in a posting I missed (if so, I apologize). What is are the practical implications of FSF's opinion that the CNRI 1.6 license (and hence the 2.0 license) is not compatible with the GPL? >There is something *you* can do, though: tell CNRI how important Python's >GPL-compatibility is to you, I'm trying to figure out how GPL compatibility (or lack thereof) affects the user. -- Grant Edwards grante Yow! RHAPSODY in Glue! at visi.com From pinard at iro.umontreal.ca Sat Sep 9 11:21:26 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 09 Sep 2000 11:21:26 -0400 Subject: ANN: Soth DPE Version 0.2 with visual configuration In-Reply-To: Sindh's message of "Fri, 08 Sep 2000 15:32:58 GMT" References: <8pb0r9$t0o$1@nnrp1.deja.com> Message-ID: [Sindh] > As above at http://www.soth.uklinux.net It is usual to accompany any announcement with a short description of what is being announced. (Please do not sent us fishing at random. :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From g2 at seebelow.org Wed Sep 20 17:12:37 2000 From: g2 at seebelow.org (Grant Griffin) Date: Wed, 20 Sep 2000 22:12:37 +0100 Subject: What is Python? References: <8pqhm9$6a9$1@panix3.panix.com> <3BBC75F01B2A2291.3CC54B93C0C69DED.4E021EA85330C94C@lp.airnews.net> <8pt65c$cbs$2@newshost.accu.uu.nl> <39C29336.71ED41AC@seebelow.org> <39C3E664.BCEAF741@seebelow.org> <39C67A2C.2313778A@seebelow.org> Message-ID: <39C92845.10D86E5D@seebelow.org> Tim Hammerquist wrote: > > Grant Griffin wrote: > > Of course, I don't expect that eveyone will share this sensibility; if > > Perl makes sense to _you_, more power to 'ya. But I did it off-and-on > > for three years, and my fingers did a lot of walking through the > > camel--they probably walked a mile for it. > > I found I had to do a lot of extra research to become fluent in Perl as > well. However, nothing truly worthwhile comes too easily, right? ;) > > > But my own theory is that Perlers actually revel in the nonsensicalness > > of their language, much as a tight-rope walker proudly calls attention > > to his lack of a net. <> It's an ego thing. That > > explains the one-liners and the "just another perl hacker" thing. > > We do, to a point, revel in this. And ego is definitely rampant in > clpm. > > > By the way, here's my own personal Python JAPH implementation: > > > > print "just another perl hacker" > > Coincidentally, and I don't want to hurt your pride, but this is also > Larry Wall's implementation. Apparently he has also become tired of all > these cutesy little tricks. Of course, Larry would remember to put a > semi-colon after that statement if there were more than one statement in > the codeblock... would you? ;) I doubt it: in the Python I wrote above, a semicolon would be tolerated, but it isn't required or even encouraged. My bigger problem nowadays is accidentally putting single-quotes around strings in C. (Either double- or single-quotes will work in Python, but I tend to use single-quotes because they make for less of that nasty "punctuation clutter" that I left Perl to get away from. ) > > But in terms of your point about "the best tool for the job", one _does_ > > have to admit in all fairness that there's at least _one_ thing that > > Perl is an order-of-magnitude better at than Python: execute Perl > > scripts. > > How 'bout regexps? Perl didn't create regexps, so why bag on them as > some in this thread have done? Unix operations demanded the existence > of regex pattern matching and Perl, which was so obviously derived from > several Unix tools, accomplishes them very well. I've noticed Pythoners > like to stand on soapboxes and look down on regexps. ("A true Python > solution wouldn't use regex's.") Why look down on something so > powerful? Regexps are optimized for matching text against patterns as > quickly and efficiently as possible, whereas you can only have so many: ... I personally have a different perspective that that on regular expressions. I'm basically competant in them, but I've never really "mastered" them. So I remain uncomfortable with them, and I always have to keep my handy reference chart at hand. (It's my own loose translation of the story of "The Little Engine That Could" that I found in the Camel book. ) So I regard REs as a very useful thing, but I'm much happier to use Python's "string" module when I can--which is most of the time. (BTW, Guido's Regular Expression TCL program in the demo of the Python source distribution is a *very* useful interactive RE tester. I wish it were given more prominence within the Python world: It should be included in main Python 2.0 distribution. ) Actually, when I first took up Perl, I looked for something _like_ Python's string module, but I found none; I eventually figured out that you were supposed to do all such things with REs. That's great once you master them (which, again, I can't say I ever truly did: the Camel book would win a Pulitzer Prize here if the Pulitizer folks had a category for "Worst Technical Writing" <0.1 wink>), but REs represent a major hurdle for beginners. OTOH, beginning Pythoneers can do most things with the string module (which is useful in even for experienced Pythonistas), then eventually master REs, as time permits. To be fair, though, one of the few things I miss about Perl is its easy use of REs: that's obviously one of its great strengths. However, Python's approach of providing that same functionality as a module, not as a fundamental language feature, is definitely more "Pythonic": the result is significantly more verbose, but that's exactly the point: there's quite a lot of "implicit is worse than explicit" (to coarsely paraphrase) baggage that comes along with Perl's approach. ... > > > But I guess if the mettle of a scripting language is to be judged by its > > one-linerability, I should confess that Python is a dismal failure: if > > you put together its use of indents for blocks, with the fact that none > > but its most elemental functions are built-in...well...it's hardly > > What elemental functions aren't built-in? I was under the impression > that core modules were built-in, they simply exist in a separate > namespace? I'm not an expert on this, but AFAIK, they're just modules like any other. Most are implemented in Python; the rest are implemented as C code compiled into DLLs (at least on Windows). All of Python's actual "built-ins" are listed in the docs on a single HTML page. Python also has about a half-dozen "statements", which are described in a series of short pages in the language reference. AFAIK, everything else in Python is a module written Python, or as a compiled extension module. Even the very powerful Numerical Python (which, to the user feels exactly like a built-in part of the language except that you have to import it) is just a compiled extension module. i-heard-somewhere-that-this-is-level-of-modularity-one-of-the -major-design-goals-of-the-TBD-perl6--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 just at letterror.com Fri Sep 1 14:23:14 2000 From: just at letterror.com (Just van Rossum) Date: Fri, 01 Sep 2000 19:23:14 +0100 Subject: min() & max() functionality References: <1egakju.wpuck01o8brdwN%p.agapow@ic.ac.uk> Message-ID: <39AFF410.DBC654B2@letterror.com> Paul-Michael Agapow wrote: > > Perhaps I've missed it in the documentation, but what does a hand-rolled > sequence (i.e. my own class) need, so it can be used by min() and max()? > > I've implemented just about all the mutable sequence functionality in my > own class (although it seems reasonable that only __len__() and > __getitem__() would be be necessary) but calling either min or max on it > sends Python into an infinite albeit interruptable loop. (Possibly > relevant platform details: MacOS 9.04, Python IDE 1.52c1.) Does your object work correctly in a for loop? It sounds like your __getitem__ doesn't raise IndexError when it receives an index that's too large. Just From mionino at d1.com.sg Mon Sep 11 02:21:48 2000 From: mionino at d1.com.sg (Mio Nino Marquez) Date: Mon, 11 Sep 2000 14:21:48 +0800 Subject: Alternative to strptime()? Message-ID: <8pi7mg$v42$1@dahlia.singnet.com.sg> One tool we're using here uses Python as the scripting tool. Admittedly, Python is *alien* to us... We have a problem whereby we'd like to convert a date-formatted string into a Tuple so that we can pass it to either time.localtime() or time.strftime() Seems like strftime() is the answer, but strftime() appears to be not working in Win32. Is there any other way to do it? Please help. TIA -- Mio Nino P. Marquez From Michael.Husmann at t-online.de Mon Sep 18 14:51:34 2000 From: Michael.Husmann at t-online.de (Michael Husmann) Date: Mon, 18 Sep 2000 20:51:34 +0200 Subject: Classes and keywords Message-ID: <39C66436.47C1216D@t-online.de> The following code is refused by python and I wonder why: import sys class Foo: def __init__(self): self.k = 0 def set(self, w=self.k): return w * w def main(): k = Foo() print k.set(9) if __name__ == "__main__": main() Traceback (most recent call last): File "", line 11, in ? File "", line 15, in Foo NameError: There is no variable named 'self' Is there someone who can help me using such a keyword argument like I have done in that 'set' function. From francois.granger at free.fr Sun Sep 17 07:44:48 2000 From: francois.granger at free.fr (=?ISO-8859-1?Q?Fran=E7ois_Granger?=) Date: Sun, 17 Sep 2000 11:44:48 GMT Subject: BUG? sha-moduel returns same crc for different files References: <8psovc$e9o$1@oslo-nntp.eunet.no> <3d7l8drbd7.fsf@kronos.cnri.reston.va.us> Message-ID: <1eh3q9t.lsta4k1ci7c7gN@paris11-nas2-42-82.dial.proxad.net> Thomas Weholt wrote: > If this doesn't work I'll have to find another way of telling if files > are equal. I think that this is one of the function of the md5 algorithm. Have a look to the md5 module. -- "Ask not what the Internet can do for you, ask what you can do for the Internet." - Dave Winer From steffen.ries at sympatico.ca Mon Sep 25 08:06:34 2000 From: steffen.ries at sympatico.ca (Steffen Ries) Date: Mon, 25 Sep 2000 12:06:34 GMT Subject: Problem with object-in-object and common superclass References: <8qn5tj$ucq$1@nnrp1.deja.com> Message-ID: ikaran at my-deja.com writes: > Here's a quick program that demonstrates the > problem: [...] > The command run ad infinitum is "print 'pea'"; the > problem seems to be that the identifier "stuff" > points to the same Python entity from within both > "Pod" and "Plant." > > Questions: > > * Am I making an obvious error in logic with my > program structure that has nothing to do with > Python? One possibility, I suppose, is that I am > accessing the "stuff" in "Pod" from "Plant," and > hence I am "fooling" the interpreter into > accessing the "Plant" namespace rather than the > "Pod" namespace. From an execution standpoint, is > "Plant" the innermost scope? The problem is that "stuff" is defined as a class variable in "Container". As such it is shared by all instances of "Container" and its subclasses. (Just to confuse you, you can access class variables like instance variables, i.e. as "self.stuff". "Container.stuff" would reference the same variable and make it clearer what's going on). > * If this is a common problem in Python > programming, what is the canonical solution? Not really a common problem, but the canonical solution is to make "stuff" an instance variable, which is initialized in the constructor of Container: --8<----8<----8<----8<----8<----8<----8<----8<-- class Container : def __init__(self): # add constructor self.stuff = [] # create instance variable def show(self) : for thing in self.stuff : if isinstance(thing, Container) : thing.show() else : print thing class Pod(Container) : def __init__(self) : Container.__init__(self) # must call constructor of superclass self.stuff.append("pea") class Plant(Container) : def __init__(self) : Container.__init__(self) # must call constructor of superclass self.stuff.append(Pod()) sprout = Plant() sprout.show() --8<----8<----8<----8<----8<----8<----8<----8<-- hth, /steffen -- steffen.ries at sympatico.ca <> Gravity is a myth -- the Earth sucks! From cut_me_out at hotmail.com Wed Sep 20 12:39:00 2000 From: cut_me_out at hotmail.com (Alex) Date: 20 Sep 2000 12:39:00 -0400 Subject: Building curses module in 1.6 References: <3d3diw2j3y.fsf@kronos.cnri.reston.va.us> Message-ID: If you search for 'curses' in your Modules/Setup file, and uncomment the right bits, you should get the curses module when you recompile. -- Speak softly but carry a big carrot. From richard_chamberlain at ntlworld.com Thu Sep 7 02:48:18 2000 From: richard_chamberlain at ntlworld.com (richard_chamberlain) Date: Thu, 7 Sep 2000 07:48:18 +0100 Subject: huge table question References: <8p6d9p$i5m$1@nnrp1.deja.com> Message-ID: Hi Bill, I'm not sure this would be any quicker but you could try accessing it through com. Have a look at : http://starship.python.net/crew/bwilk/access.html for example code. My guess is that the speed issues you're facing are not a odbc thing (as that is fairly quick) but an access issue. Richard Bill Tolbert wrote in message news:8p6d9p$i5m$1 at nnrp1.deja.com... > I've got a table in MS Access with 3.5 million records. First, I know we > should be using something else, but it isn't my call. I need to extract > newline characters from one of the fields and write it to a tab > delimited text file. > > My problem is getting to the data. I thought I'd fetch a cursor and > whack away at it. However, just getting the cursor is taking an > extremely long time. Access will write the data to a 237meg text file in > about 8 minutes. So far, on the same machine, Python has been at this > for about 2 hours. > > Any better ideas? Ways of speeding it up? Is it the jet engine or the > odbc drivers or just too much data...? > > Thanks, > > Bill > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From pduffin at hursley.ibm.com Mon Sep 11 04:23:11 2000 From: pduffin at hursley.ibm.com (Paul Duffin) Date: Mon, 11 Sep 2000 09:23:11 +0100 Subject: some uglyness in Python imho References: <018101c01acc$5f9c1910$202379a5@jayk4> Message-ID: <39BC966F.547B7913@hursley.ibm.com> Jay Krell wrote: > > I hadn't considered the difficulty of maintenance. Darn. > > >Since most development is done on Unix... > > Something to consider when most development moves to Windows. :) > > Right about Tcl. They used to run a simple (but correct) tool over the .objs > to generate the .def. I think they're fully/only > __declspec(dllimport/dllexport) now. I don't know why. > I don't know too much about how Tcl is built on Windows, specifically when it comes down to usage of .def files against inline __declspec() calls. Having a macro which is only needed on one platform is really no better than a file because it is always possible to forget it, just as it is possible to forget to update the file although the chances of it happening are lower. However, I do know that Tcl no longer has to rely on the platform linking mechanism, instead it uses a very simple cross platform linking mechanism. One of the 'features' of this is that Tcl now has a file which describes its external API which is used to automatically generate the files this mechanism needs. It would be very easy to also automatically generate a .def file from this as well. As this mechanism is used on all platforms this description file is up to date because it has to be. > > ...besides, if Microsoft didn't want us to use this, they > > shouldn't have added the declspec directive to the compiler > > in the first place ;-) > > __declspec(dllimport) is a slight optimization, which is probably a big > reason it exists. It saves one instruction per imported function call on > x86, and some scheduling freedom, which the compiler actually takes > advantage of. Without __declspec(dllimport), calls to imported functions are > calls to a one instruction function that jumps through the (patched at > runtime)) function pointer. With __declspec(dllimport), calls to imported > functions are call through the function pointer, and sometimes the optimizer > preloads the contents of the function pointer into a register and later > jumps through it. > > __declspec(dllimport) on data is "impossible" without __declspec(dllimport), > you have to use functions instead. > > I still doubt it's worth it.. > > And just fyi, sometimes both the __declspecs and a .def file are used, like > to get the optimization and to export by ordinal. > I have a feeling that that may be what Tcl does (it still tries to support the normal platform specific linking mechanism). From jordi.inglada at ieee.org Mon Sep 25 11:01:15 2000 From: jordi.inglada at ieee.org (Jordi Inglada) Date: Mon, 25 Sep 2000 15:01:15 GMT Subject: Functionalism (was: Language wrappers) References: <8qcura$hsa$1@nnrp1.deja.com> <39CAB699.747E950E@home.com> <8qi3q4$i0v$1@nnrp1.deja.com> <4A40F460995B330F.4B1A0ED4B489B2A4.C86D74E4EDA9F310@lp.airnews.net> Message-ID: <8qnpbc$kc7$1@nnrp1.deja.com> In article <4A40F460995B330F.4B1A0ED4B489B2A4.C86D74E4EDA9F310 at lp.airnews.net>, claird at starbase.neosoft.com (Cameron Laird) wrote: > In article <8qi3q4$i0v$1 at nnrp1.deja.com>, > Jordi Inglada wrote: . > >Another question. What are Python capabilities for implementing > >functional programming (a la Lisp, Scheme, Haskell, ...). Can anybody > >give me a pointer to such a comparison? > . > . > . > Someone can. I'm sure they've been written. Functionalism > is a very frequent topic in Pythonic circles, and many of > the discussants have deep understanding of the issues. For > the highest-level summary, see > . Thanks for the pointer. I knew this one. Actually I sent my message after reading it. The fact that Python has map, apply, reduce and lambda, makes me think that many of the things one may look for into functional languages are present in Python. (Is anything missing?). A good reference is the paper by Norvig , where he compares Lisp with Python. Thanks again. -- ------------------------------- Jordi Inglada - PhD Student Dept. ITI - ENST Bretagne BP 832, 29285 Brest Cedex-FRANCE Sent via Deja.com http://www.deja.com/ Before you buy. From kragen at dnaco.net Sat Sep 16 18:12:59 2000 From: kragen at dnaco.net (Kragen Sitaker) Date: Sat, 16 Sep 2000 22:12:59 GMT Subject: Which regex syntax mode? References: Message-ID: In article , Tim Peters wrote: >So get familiar with the "string" module soon. People use that instead >whenever they can; it's considered clearer by everyone, and is generally >faster. At the extreme, I've seen Perl like > > if ($var =~ /^a$/) { ... } > >and that's just unthinkable here. It may be unthinkable in Python, but it's dumb in Perl, too --- > In Python everyone would write > > if var == "a": > ... > >instead. I wish people would write that in Perl, too. $var eq 'a'. > Besides being clearer to the lazy Python eye, a real advantage is >that the Python spelling doesn't match "a\n" too by mistake . The more I write Python, the less I miss Perl. :) wishing-he-had-a-sense-of-humor-ly y'rs - kragen -- Kragen Sitaker Perilous to all of us are the devices of an art deeper than we ourselves possess. -- Gandalf the Grey [J.R.R. Tolkien, "Lord of the Rings"] From db3l at fitlinxx.com Mon Sep 4 17:55:14 2000 From: db3l at fitlinxx.com (David Bolen) Date: 04 Sep 2000 17:55:14 -0400 Subject: "print >> file" ok. What about "print > file" to truncate? References: <39b2ae19.15922395@news.accessone.com> <8oud0l$rru$1@slb0.atl.mindspring.net> Message-ID: "Andrew Dalke" writes: > To create a new file, > > open("filename", "w") > > This creates the file if it doesn't exist, and truncates it if it does. > Because of garbage collection, there's no need for an explicit close, > so that's all you really need to have. Just remember that leaving the explicit close to the GC might prevent you from seeing a failure on the close (which could result in a loss of data). That may or may not be a problem depending on the use at hand, but it's something to remain aware of. -- -- 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 aleaxit at yahoo.com Sat Sep 16 03:34:38 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 16 Sep 2000 09:34:38 +0200 Subject: Is vars() meant to include globals? References: <8pso8m$686$1@nnrp1.deja.com> <8pur74$jfb$1@nnrp1.deja.com> Message-ID: <8pv81k01l61@news1.newsguy.com> "Opinderjit" wrote in message news:8pur74$jfb$1 at nnrp1.deja.com... > > Where does the "classvar" variable go? It doesn't seem to be contained > in vars(), locals() or globals(). [snip] > > class SomeClass: > > classvar = 3 Remember that vars() takes an argument -- the object whose variables you want! Here, you want the variables of the class object: >>> class SomeClass: classvar = 3 >>> vars(SomeClass) {'classvar': 3, '__module__': '__main__', '__doc__': None} >>> Alex From g2 at seebelow.org Sat Sep 23 04:43:19 2000 From: g2 at seebelow.org (Grant Griffin) Date: Sat, 23 Sep 2000 09:43:19 +0100 Subject: Public Domain Python References: <39BBFDB8.A6020F@seebelow.org> <39BF2707.68E1269C@seebelow.org> <39C1CD8C.DA62C34@seebelow.org> <8q4lg4$7ku$4@newsserver.rrzn.uni-hannover.de> <39C684E0.8A26BA1@seebelow.org> <8qf7vi$5i3$1@newsserver.rrzn.uni-hannover.de> Message-ID: <39CC6D27.AB83D9D6@seebelow.org> Bernhard Reiter wrote: > > In article <39C684E0.8A26BA1 at seebelow.org>, > Grant Griffin writes: > > Bernhard Reiter wrote: > >> > >> In article <39C1CD8C.DA62C34 at seebelow.org>, > >> Grant Griffin writes: > > > For example, imagine how much better the world would be if Linux were > > "truly free" instead of perpetually encumbered by that whole nutty > > copyleft ball-and-chain thing. Now wouldn't the world be a better > > place? > > No. Linus himself said that putting Linux under GPL was the decisive > breakthrough for the project. > Like I said, he's a really good marketer. politicians-and-advertising-agencies=-take-polls-before-saying -stuff-like-that,-but-smart--guys-like-linus-don't-have-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 kragen at dnaco.net Wed Sep 20 16:37:09 2000 From: kragen at dnaco.net (Kragen Sitaker) Date: Wed, 20 Sep 2000 20:37:09 GMT Subject: Numeric processing algorithm. References: <007001c01e35$b9c0e3a0$621aa7d1@v1o9g4> Message-ID: In article <007001c01e35$b9c0e3a0$621aa7d1 at v1o9g4>, The Majestic Moined Mogul wrote: >I know that Python is well known for its numeric processing power. Does >anyone know what algorithm it uses to do so. Does it use the CORDIC? It appears from web-searching that CORDIC is a clever set of algorithms for computing trig and exponential functions using, among other things, small lookup tables. It looks like Python calculates these functions using the standard C library math functions, which can use any algorithm whatsoever to compute them, including CORDIC. See Modules/mathmodule.c for details. ISTR Plauger's book on the standard C library recommends using Chebyshev polynomials to approximate trig functions; glibc 2.1.3 (sysdeps/libm-ieee754/k_sin.c) uses some kind of polynomial approximation, which looks to me like a truncated Taylor series. Glibc on my machine actually calls the hardware instructions in my FPU to compute the trig functions, though --- according to objdump: 000096d0 : 96d0: dd 44 24 04 fldl 0x4(%esp,1) 96d4: d9 fe fsin 96d6: df e0 fnstsw 96d8: a9 00 04 00 00 testl $0x400,%eax 96dd: 75 01 jne 96e0 96df: c3 ret 96e0: d9 eb fldpi 96e2: d8 c0 fadd %st(0),%st 96e4: d9 c9 fxch %st(1) 96e6: d9 f5 fprem1 96e8: df e0 fnstsw 96ea: a9 00 04 00 00 testl $0x400,%eax 96ef: 75 f5 jne 96e6 96f1: dd d9 fstp %st(1) 96f3: d9 fe fsin 96f5: c3 ret I have no idea how the FPU on my machine calculates trig functions. Probably not with CORDIC, though. Does that answer your question? -- Kragen Sitaker Perilous to all of us are the devices of an art deeper than we ourselves possess. -- Gandalf the Grey [J.R.R. Tolkien, "Lord of the Rings"] From ftouch at aol.com Mon Sep 11 18:23:12 2000 From: ftouch at aol.com (FTOUCH) Date: 11 Sep 2000 22:23:12 GMT Subject: Python developer is needed Message-ID: <20000911182312.08429.00001151@ng-md1.aol.com> We are looking for a programmer with experience with python and object programming Please send your response to David at AdrenaMail.com or call me at 410-358 4499 David Evgey From mjeuris at lib.ua.ac.be Tue Sep 12 03:12:59 2000 From: mjeuris at lib.ua.ac.be (Marc Jeurissen) Date: Tue, 12 Sep 2000 09:12:59 +0200 Subject: MIME attachments and SMTP References: <8pjstm$oqh$1@nnrp1.deja.com> Message-ID: <39BDD77B.24609C1@lib.ua.ac.be> You have to use the MimeWriter module. Here is an extract of a 'Shipper'-module I wrote. fd = StringIO.StringIO() m = MimeWriter.MimeWriter(fd) ... m.addheader('Subject',subject) m.addheader('MIME-version', '1.0') m.addheader('Reply-To',reply) m.flushheaders() # If it's a message with more than 1 body, you have to use multipartbody if multi: boundary = mimetools.choose_boundary() m1 = m.startmultipartbody ('mixed', boundary) fd.write('This is a multi-part message in MIME format.') for body in bodies: bodycounter = bodycounter + 1 if multi: m.nextpart() ... mime_type = body.get_header('content-type') if not has_iso_chars: m.addheader('Content-Transfer-Encoding', '7bit') s = body.open() enc_file = '' else: m.addheader('Content-Transfer-Encoding', 'base64') # m.addheader('Content-Disposition', 'inline') m.addheader('Content-Disposition', 'attachment') t = body.open() enc_file = tempfile.mktemp() s = open(enc_file, 'wb') base64.encode(body,s) s.close() s = open(enc_file, 'rb') rick_at_brickroad at my-deja.com wrote: > > I'm trying to set up a command line utility in > python.. and I've set up the SMTP to specs but > when I send a message doing: > server = smtplib.SMTP('myserver') > server.set_debuglevel(1) > fromaddr = 'rickr at brickroad.net' > toaddrs = 'rickr at brickroad.net' > msg = 'blah blah blah blah' > server.sendmail(fromaddr, toaddrs, msg) > server.quit() > > however, it arrives it arrives with no to: and no > subject. > > I was also wondering if someone could point me to > more information on using mime types to add > attachments. I've gone through the docs.. but > can't find much information on this. > > thanks > > Rick > > Sent via Deja.com http://www.deja.com/ > Before you buy. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Marc Jeurissen University of Antwerp - Library Automation Universiteitsplein 1, 2610 Wilrijk, Belgium Tel : +32 3 820 21 53 Fax : +32 3 820 21 59 E-mail: mjeuris at lib.ua.ac.be WWW : http://www.ua.ac.be/ualib.html =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= From aleaxit at yahoo.com Sun Sep 3 03:04:34 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 3 Sep 2000 09:04:34 +0200 Subject: Tuple Format? References: <03092000.2@sanctum.local.jae.ddns.org> Message-ID: <8ost9u011dl@news2.newsguy.com> "J?rgen A. Erhard" wrote in message news:03092000.2 at sanctum.local.jae.ddns.org... [snip] > People don't have a problem because they don't use it... at least *I* > don't. I didn't even know it's there... > > Or I don't have to (what use is an empty tuple?) > > A one-element tuple is something you *have* to deal with (at least for > the apply(...) case, I think). apply is a typical case that comes to mind for the empty tuple as well. Still, there are easy syntactic alternatives: def tup(*stuff): return stuff tup() will now return (), tup("goo") will return ("goo",), and for any number N>1 of arguments, it will be just as if the 'tup' word was not there. [I'd rather say 'tuple', but it's better not to pre-empt the existing built-in function that tupleizes sequences]. Alex From debl.spammono.nospammy at world.std.com Tue Sep 19 23:18:31 2000 From: debl.spammono.nospammy at world.std.com (David Lees) Date: Wed, 20 Sep 2000 03:18:31 GMT Subject: Char handling DOS vs Linux? References: <39C81033.DBC3D150@world.std.com> <8q94cv$n1d$1@panix6.panix.com> Message-ID: <39C82C94.42482A1C@world.std.com> Hey Aahz, thanks for the quick and correct diagnosis. I should have posted the "open" statements, but you got it right. One minor thing is that the output also requires a binary write: input=open(sys.argv[1],'rb') output=open(sys.argv[2],'wb') david lees Aahz Maruch wrote: > > In article <39C81033.DBC3D150 at world.std.com>, > David Lees wrote: > > > >I wrote a short piece of python code running under 1.5.2 for striping > >out those extra carriage returns that DOS editors stick into text. When > >I run this on my Linux box all works fine. When I run the same code > >under Win 95 it does nothing. It appears from using the debugger that > >the '\r' carriage returns are never seen when running under Windows. Is > >there a different Python I/O function I should be using to see ALL the > >charaters in a file? > > f = open ( filename, "rb" ) > -- > --- Aahz (Copyright 2000 by aahz at pobox.com) > > Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ > Hugs and backrubs -- I break Rule 6 > > Member of the Groucho Marx Fan Club --Aahz From Pieter_Claerhout at CreoScitex.com Wed Sep 27 08:08:46 2000 From: Pieter_Claerhout at CreoScitex.com (Pieter Claerhout) Date: Wed, 27 Sep 2000 14:08:46 +0200 Subject: Problem with regular expression Message-ID: <2B1262E83448D211AE4B00A0C9D61B030130157C@msgeuro1.creo.be> Looks a bit unlogical to me. The rules say that you either need to escape the backslash or use the raw notation (according to the docs). Why do I need to both escape the backslash here and use the raw notation if I want to match a single backslash?? Pieter -----Original Message----- From: Arpad Kiss [mailto:sekter at matavnet.hu] Sent: Wednesday, September 27, 2000 1:29 PM To: python-list at python.org Subject: Re: Problem with regular expression Hi, Try this: p=re.compile(r'[A-Za-z]:\\') Arpad Pieter Claerhout wrote in message news:mailman.970053100.5550.python-list at python.org... > Hello all, > > I'm trying to make a regular expression that looks like the following: > > p = re.compile('[A-Za-z]:\\') > if p.match(filepath): return 'pc' > > It looks right to me, but whenever I run the program, it fails with the following traceback: > > Traceback (innermost last): > File "C:\WINNT\Profiles\PCLAER~1\Desktop\PathTest.py", line 11, in ? > print FileUtils.GetPathPlatform(path) > File "C:\WINNT\Profiles\PCLAER~1\Desktop\FileUtils.py", line 119, in GetPathPlatform > p = re.compile('[A-Za-z]:\\') > File "d:\Python\Lib\re.py", line 79, in compile > code=pcre_compile(pattern, flags, groupindex) > pcre.error: ('\\ at end of pattern', 10) > > So it looks like we can't have a backslash at the end of a pattern. Is this true? If so, how can I work around that, as any type of character can go after the backslash, except for these characters: > > \ / : * ? " < > | > > Any ideas? Just worth mentioning: I'm (still) using Python 1.5.2... > > Thanks, > > > > Pieter > -- http://www.python.org/mailman/listinfo/python-list From aahz at panix.com Tue Sep 19 21:37:35 2000 From: aahz at panix.com (Aahz Maruch) Date: 19 Sep 2000 18:37:35 -0700 Subject: Char handling DOS vs Linux? References: <39C81033.DBC3D150@world.std.com> Message-ID: <8q94cv$n1d$1@panix6.panix.com> In article <39C81033.DBC3D150 at world.std.com>, David Lees wrote: > >I wrote a short piece of python code running under 1.5.2 for striping >out those extra carriage returns that DOS editors stick into text. When >I run this on my Linux box all works fine. When I run the same code >under Win 95 it does nothing. It appears from using the debugger that >the '\r' carriage returns are never seen when running under Windows. Is >there a different Python I/O function I should be using to see ALL the >charaters in a file? f = open ( filename, "rb" ) -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Member of the Groucho Marx Fan Club --Aahz From rcameszREMOVETHIS at dds.removethistoo.nl Sat Sep 30 22:46:31 2000 From: rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) Date: Sun, 01 Oct 2000 02:46:31 GMT Subject: [1.5.2] Buglet in Mailbox-module? References: <8FBFE5F1rcamesz@127.0.0.1> <8r3a8v$5c$1@panix2.panix.com> Message-ID: <8FC037529rcamesz@127.0.0.1> Aahz Maruch wrote: >[cc'd to last maintainer of mailbox.py] > >In article <8FBFE5F1rcamesz at 127.0.0.1>, >Robert Amesz wrote: >> >>When trying to access some of my .MBX-files using the >>Mailbox-module which came with Python 1.5.2, I quickly found out >>that module just didn't work for me: the next() method just >>returned None each time, and not the rfc822-object I expected. > >It looks like it may be real, but you should really use the bug >submission facility at python.sourceforge.net to submit bugs. Well, if I'm convinced it is a genuine unfixed bug, I will submit it, but I'd hate to waste the developers time at a time like this. >Also, it's really hard to work with someone who has a munged e-mail >address. "Munged?" I've never heard that word, but I presume you're referring to the spamblocker in the From-header. The one in the Reply-To header is perfectly valid though. Any half-decent newsreader will use that one when replying by e-mail, so I'm not really sure what the problem is here. Robert Amesz From chris_barker at my-deja.com Mon Sep 25 16:37:56 2000 From: chris_barker at my-deja.com (chris_barker at my-deja.com) Date: Mon, 25 Sep 2000 20:37:56 GMT Subject: reloading a C module Message-ID: <8qod32$dqo$1@nnrp1.deja.com> Hi all, I'm working on writing my first C extension module,and I have a question: (Python 1.5.2, Intel Linux (Redhat 6.1)) Should I be able to "reload" a C module? I compile my module as a shared module (*.so), import it (import spam), and it works fine. Then I make some changes, re-compile it, and reload it ( reload(spam) ). Nothing changes. If I kill Python and restart it, then import again it works, so the *.so file has changed. Is this supposed to work? If not, it really should be added to the docs. please CC: me at cbarker at jps.net, checking news from here is a pain. thanks, -Chris Sent via Deja.com http://www.deja.com/ Before you buy. From aahz at panix.com Fri Sep 29 12:13:12 2000 From: aahz at panix.com (Aahz Maruch) Date: 29 Sep 2000 09:13:12 -0700 Subject: You can never go down the drain... References: Message-ID: <8r2f2o$ja5$1@panix2.panix.com> In article , Suchandra Thapa wrote: >Alex wrote: >> >>I wasn't snickering. I just think that asking for a workaround to a bug >>for which a patch exists is silly. > > But the thing is you aren't always able to patch the software. E.g. the >software is on a client's machine, you can't change to a newer version w/o >testing for breakage, etc. Yes, but this issue was specifically in the context of 1.6/2.0b1. Anyone with a client machine that has either installed needs to have zir head examined. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Perhaps God rewards martyrs, but life seldom does..." --Ulrika O'Brien From cut_me_out at hotmail.com Sun Sep 17 14:15:01 2000 From: cut_me_out at hotmail.com (Alex) Date: 17 Sep 2000 14:15:01 -0400 Subject: newbie class troubles References: <8q2op2$gj1$1@panix2.panix.com> Message-ID: Brett > class filesearch: > # Any public variables i need > exceptions = [] > filelist = [] > dirlist = [] > > def search(self, top): > try: > tmpList = os.listdir(top) > except os.error: > return > > for item in tmpList: > if item not in exceptions: > name = os.path.join(top, name) > if os.path.isdir(name): > self.dirlist.append(name) > search(self, name) > else: > self.filelist.append(name) > You're being pretty unclear, but I would guess that you were trying to use this class in some fashion as os.path.walk(dir, filesearch.search, 'dummy_arg') If that's the case, the error is coming from the fact that filesearch.search is an unbound method. To correct it, you need to do something like this, instead: filesearch_instance = filesearch() os.path.walk(dir, filesearch_instance.search, 'dummy_arg') You will probably also need to amend the argument signature of the search method. It will probably need to take three arguments, not one. Alex. -- Speak softly but carry a big carrot. From mjackson at wc.eso.mc.xerox.com Wed Sep 6 22:52:33 2000 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 7 Sep 2000 02:52:33 GMT Subject: Python 2.0b1 is released! References: Message-ID: <8p6vth$j8t$1@news.wrc.xerox.com> What is the outlook for "2.0 batteries included?" The PEP is not very helpful, but may be out of date. -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson Some circumstantial evidence is very strong, as when you find a trout in the milk. - Henry David Thoreau From kirschh at lionbioscience.com Thu Sep 21 03:53:08 2000 From: kirschh at lionbioscience.com (Harald Kirsch) Date: 21 Sep 2000 09:53:08 +0200 Subject: where is upvar References: Message-ID: "Jake Baker" writes: > Harald Kirsch wrote: > > > def bla(someparams, upvars=local()) > > upvars['parentsVar'] = "some value set in parent stack frame" > > And then later wrote: > > > Not if it is documented and if the sole purpose of a certain function > > is to do that in a defined way. > > If that is your desire, require the caller to pass you his local(): > > def bla ( params, upvars): > "Please pass your local() to upvars when calling this function." > > (Although my suspicion is that that's not what you want to do - try It is exactly what I want, except that it would be even nicer if locals() could be the default for upvars. That's the idea of defaults, that they cover the most common case, and I expect locals() to be the most common case. > to rethink the problem using Pythons powerful abilities rather than > trying to fit Python code to what is arguably a cludge in Tcl. If (-: Nice rhetoric: it associates (Python, powerful) and (Tcl, clugde). :-) > you explain your problem, perhaps someone on the list can suggest a > better way of solving it.) My entrance into the world of python was to write a command line parser ala http://wsd.iitb.fhg.de/~kir/clighome/. It is quite natural to let the parser set variables directly in the calling stack frame, normally the __main__ of the script. Harald Kirsch -- ----------------+------------------------------------------------------ Harald Kirsch | kirschh at lionbioscience.com | We make the tools to LION Bioscience | +49 6221 4038 172 | reverse engineer nature. From root at rainerdeyke.com Wed Sep 13 01:05:46 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 13 Sep 2000 05:05:46 GMT Subject: Attribute definition, WHY? References: <8ploet$ucg$1@nnrp1.deja.com> Message-ID: wrote in message news:8ploet$ucg$1 at nnrp1.deja.com... > Why would you want to do the following: > > class A: > attr1 = [1,2] > def __init__(self,name): > self.name = name > > and not > > class A: > def __init__(self,name): > self.name = name > self.attr1 = [1,2] > > Are there benefits to the first definition? Yes: efficiency. Also, the ability to override at the subclass level without replacing __init__. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From boud at rempt.xs4all.nl Mon Sep 25 13:10:00 2000 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 25 Sep 2000 17:10:00 GMT Subject: python QT and windows References: <39C95DE7.F47A6A32@home.com> <8qgb9d$8od$1@news1.xs4all.nl> Message-ID: <8qo0t8$1gr$2@news1.xs4all.nl> Cameron Laird wrote: > In article <8qgb9d$8od$1 at news1.xs4all.nl>, > Boudewijn Rempt wrote: > . > . > . > A bit of clarification: early Tkinter did not > use native Windows widgets. Now Tkinter does > (certainly with Python 1.5 and later). > HOWEVER, while Tkinter uses Windows widgets for > what it does, it doesn't offer all Windows widgets > that a Win* developer might expect. Well, that's the crux, I feel - while tkInter has two (that I know of) very good high-level widgets - the canvas and the text editor - other widgets have to be constructed in Python from more primitive tkInter widgets. The difference in look & feel between a native Windows treeview and the one from IDLE is considerable. > I summarize: for Tkinter, what's there is native, > but not everything native is there. -- Boudewijn Rempt | http://www.valdyas.org From thor at localhost.localdomain Sun Sep 24 05:25:14 2000 From: thor at localhost.localdomain (Manuel Gutierrez Algaba) Date: 24 Sep 2000 09:25:14 GMT Subject: What is Python? References: <8pqhm9$6a9$1@panix3.panix.com> <3BBC75F01B2A2291.3CC54B93C0C69DED.4E021EA85330C94C@lp.airnews.net> <8ptbvu$20u$1@panix2.panix.com> Message-ID: On Fri, 15 Sep 2000 18:36:32 GMT, Tim Hammerquist wrote: >Aahz Maruch wrote: >> Python actually doesn't have any C roots. a += 23 ; <-------------- It didn't have, now it has a banyan root. --- MGA From fgranger at teleprosoft.com Tue Sep 19 12:31:17 2000 From: fgranger at teleprosoft.com (Fran=?ISO-8859-1?B?5w==?=ois Granger) Date: Tue, 19 Sep 2000 18:31:17 +0200 Subject: Python for Macintosh References: <39C7772F.6AC71A00@iprimus.ca> Message-ID: in article 39C7772F.6AC71A00 at iprimus.ca, Jason Holmes at jth at iprimus.ca wrote on 19/09/00 16:24: > Hi group, what are the system requirements for the macintosh version of > python. Thanks > -Jason As far as I remember, the current version (1.5.2) is "fat" meaning it will run on 68000 and PowerMac. But 2.0 wich is due really soon is PowerPC Oonly. The 1.52 interpreter request a minimum of 1434 KB and preferably 7812 KB The 2.0 one 4000 KB and 16000 KB See also http://www.cwi.nl/~jack/macpython.html http://www.python.org/download/download_mac.html Salutations, Francois Granger -- fgranger at teleprosoft.com - tel: +33 1 41 88 48 00 - Fax: + 33 1 41 88 04 90 From lars at pixar.com Tue Sep 5 19:01:13 2000 From: lars at pixar.com (Lars Damerow) Date: Tue, 5 Sep 2000 16:01:13 -0700 Subject: Safe doubly-linked list/tree implementation? Message-ID: Hi folks! I'm trying to come up with an implementation of a doubly-linked tree (where the children have links to their parents) that doesn't leak memory due to reference cycles. It's such a simple data structure that I feel a bit foolish asking, but... The FAQ says that in the case of doubly-linked structures, reference cycles must be explicitly broken in order to avoid memory leakage. I thought that I could use __del__ to do this, but __del__ only seems to be called when the reference count reaches zero. Does anyone know of an implementation that's already floating around out there? If not, are there any recommendations for a good approach to making this type of data structure? Thanks! -lars ___________________________________________________________ lars damerow pixar animation studios technomonkey lars at pixar.com "Nauseous. Nauseated. The first means 'sickening to contemplate'; the second means 'sick at the stomach.' Do not, therefore, say, "I feel nauseous," unless you are sure you have that effect on others." - William Strunk Jr., "The Elements of Style" From effbot at pythonware.com Fri Sep 8 06:42:31 2000 From: effbot at pythonware.com (effbot at pythonware.com) Date: Fri, 08 Sep 2000 10:42:31 GMT Subject: editing in Unicode References: <8p7mli$ccglp$1@ID-4825.news.cis.dfn.de> <8p7rt8$bqo5v$1@ID-4825.news.cis.dfn.de> <87n1hknzzt.fsf@cachemir.echo-net.net> <8p8bkp$cepcj$1@ID-4825.news.cis.dfn.de> <87d7igno2u.fsf@cachemir.echo-net.net> Message-ID: <8pafql$93d$1@nnrp1.deja.com> marcin wrote: > Since UTF-16 is not compatible with ASCII, it does not make much > sense to have just a string encoded in UTF-16 and the rest of code in > ASCII. If UTF-16 is to be used, it would probably have to be specified > externally to the source. Not necessarily: XML solves this by requiring a certain character sequence first in the file, but only if you insist on using a non- ASCII compatible encoding. In Python, this sequence could for example be "#!", and the compiler could figure things out by looking at the first four bytes: 00 00 00 23: UCS-4, big-endian machine 23 00 00 00: UCS-4, little-endian machine FE FF -- --: UTF-16, big-endian FF FE -- --: UTF-16, little-endian 00 23 00 21: UTF-16, big-endian, no Byte Order Mark 23 00 21 00: UTF-16, little-endian, no Byte Order Mark 3C 23 -- --: UTF-8 or other ASCII-compatible encoding -- -- -- --: same, hopefully (check the encoding pragma for details; default is "unknown" as in 2.0. also see below) > IMHO there should be a way of specifying the encoding of the source > in the source Definitely. Hopefully, that will go into 2.1. Note that in 2.0, the default source encoding is "unknown". With this encoding, "" string literals stores 8-bit characters as is, and u"" string literals treats 8-bit characters as ISO 8859-1. > and they should be only ASCII-compatible encodings. Maybe, maybe not. Sent via Deja.com http://www.deja.com/ Before you buy. From urner at alumni.princeton.edu Sun Sep 10 11:52:02 2000 From: urner at alumni.princeton.edu (Kirby Urner) Date: Sun, 10 Sep 2000 08:52:02 -0700 Subject: Python 2.0 and teaching precalculus References: <02jmrskpt2qicgrln7kd9g2hrjjt3l1t77@4ax.com> <39BB5327.1F8723AA@alcyone.com> Message-ID: <5cbnrsco00sjgs1urr188ustmvg61b89ne@4ax.com> Erik Max Francis wrote: >Kirby Urner wrote: > >> def wiggle(function,input,epsilon=1e-10): >> """ >> Accepts a function, value and returns delta f / delta x >> for small epsilon (default of 1^-10 may be overridden) > ... > >1 seems like a bad choice for an epsilon ... :-) Woops. Thanks for pointing out the typo. Fixed it at the source page: http://www.ineterena.com/~pdx4d/ocn/precalc.html Of course it's all relative. 1 is really small if your x's are 10,000,000,000 apart :-D Kirby From tismer at appliedbiometrics.com Tue Sep 12 06:54:45 2000 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Tue, 12 Sep 2000 13:54:45 +0300 Subject: Python 1.6 The balanced language References: <39AB712E.805ACB4B@nowonder.de> Message-ID: <39BE0B75.E6A8712@appliedbiometrics.com> Peter Schneider-Kamp wrote: > > Suchandra Thapa wrote: ... > > >Sometimes there are even technical drawbacks: if you use Stackless > > >python (corrutines), you can use Jpython compatibility ! > > It is not impossible to implement coroutines for JPython. It's just > hard (or impossible) to implement them efficiently without changing > the VM beneath. But that's the point: JPython does not have an extra VM, but emits java VM code. That means: Having coroutines for JPython is the same question as having coroutines in Java: Is it possible without changing the Java VM? I'm proetty shure it is impossible by creating java scourcecode, but I'm no longer sure that the VM is incapable to do it. This code would just have no Java equivalent. Yet another decompile barrier :-) ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : 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 hei at adtranzsig.de Fri Sep 22 03:40:21 2000 From: hei at adtranzsig.de (Dirk-Ulrich Heise) Date: Fri, 22 Sep 2000 09:40:21 +0200 Subject: where is upvar References: <8qcujb$1ka$1@desig-bs01-s04.adtranzsig.de> <39CA27AC.90630D77@san.rr.com> <01c02406$6a4feb00$61d7363e@dreadzone> <39CA94AA.A6130291@san.rr.com> Message-ID: <8qf2c0$nr5$1@desig-bs01-s04.adtranzsig.de> "Darren New" schrieb im Newsbeitrag news:39CA94AA.A6130291 at san.rr.com... > places I assumed it was common.) By which I mean "or did I miss a joke?" No joke at all. Well: yes. I actually don't keep programming languages together with my underwear. But the language exists, though it's a dumb editor macro language consisting mainly of coded keystrokes, like, e.g. the macro language of VIM, and a lotta gotos. -- Dipl.Inform. Dirk-Ulrich Heise hei at adtranzsig.de dheise at debitel.net From jcm at bigskytel.com Mon Sep 25 11:54:04 2000 From: jcm at bigskytel.com (David Porter) Date: Mon, 25 Sep 2000 09:54:04 -0600 Subject: bulletin boards In-Reply-To: <39CF67DC.28418335@computer.org>; from saltydog@computer.org on Mon, Sep 25, 2000 at 09:57:33AM -0500 References: <39CF67DC.28418335@computer.org> Message-ID: <20000925095404.A9777@bigskytel.com> * Salty Dog : > I am looking at creating a bulletin board on one of my web pages. > I seem to remember somebody had a nice python cgi script for doing > this. If anyone can point me in the direction before I write my own > from scratch I would appreciate it. Thanks Here's a concise bulletin board script: http://n.ethz.ch/student/amreinm/python/board.py I haven't got around to trying it yet. From bwarsaw at beopen.com Fri Sep 8 12:17:27 2000 From: bwarsaw at beopen.com (Barry A. Warsaw) Date: Fri, 8 Sep 2000 12:17:27 -0400 (EDT) Subject: Python 2.0b1 is released! References: <8pabq7$hsb$1@icarus.knowledgegroup.co.uk> Message-ID: <14777.4375.953362.805381@anthem.concentric.net> >>>>> "DS" == Dan Schmidt writes: DS> - The beginswith and endswith methods for strings, which I DS> was doing by hand before (though I'm surprised that they're DS> not also in the string module). DS> - The updating of ftplib to allow REST commands for resuming DS> downloads. I had made my own local hacks to the 1.5.2 ftplib DS> (just a few days ago!) to do this, and now I don't need to. Ask and ye shall receive; both of these are in Python 2.0 beta 1. -Barry From charleshixsn at earthlink.net Wed Sep 6 13:52:01 2000 From: charleshixsn at earthlink.net (Charles Hixson) Date: Wed, 06 Sep 2000 17:52:01 GMT Subject: Python 2.0b1 is released! References: <200009060449.XAA02145@cj20424-a.reston1.va.home.com> <8p4sg8$77d4$1@www.univie.ac.at> <39B61C25.20F927F6@softax.com.pl> Message-ID: <39B6843B.BD6EAD78@earthlink.net> Unfair! 3 of those are the same one! :-) Fredrik Lundh wrote: > gene wrote: > > and my personal favorite.... > > > > Visual Python > > which one: > > http://www.deja.com/=dnc/getdoc.xp?AN=647020031 > http://www.python.org/pipermail/edu-sig/2000-May/000498.html > http://www.activestate.com/Products/VisualPython.html > http://sourceforge.net/project/?group_id=6013 > ... > > > > -- (c) Charles Hixson -- Addition of advertisements or hyperlinks to products specifically prohibited -------------- next part -------------- A non-text attachment was scrubbed... Name: charleshixsn.vcf Type: text/x-vcard Size: 153 bytes Desc: Card for Charles Hixson URL: From frey at otter.bme.unc.edu Tue Sep 5 08:29:08 2000 From: frey at otter.bme.unc.edu (Eric Frey) Date: 5 Sep 2000 12:29:08 GMT Subject: pseudocolor visual and colormap for PIL or tk? Message-ID: <8p2ouk$1uv$1@news2.isis.unc.edu> Is it possible to set up a window to display an image with a pseduocolor visual and use an installable colormap? I am trying to display grayscale images on an 8 bit display and the default TrueColor visual results in a limited number of gray values so the images look posterized. What I would like is to set up a colormap, allocate the number of grayscale values I need, and then install the colormap when my window is active. I know this will make the other windows look ugly, but I don't mind. I have done this in C before, but am wondering if there is a way to do it in Tkinter and python on UNIX. Thanks. -- ======================================================================= Eric C. Frey Assistant Professor Department of Biomedical Engineering and Department of Radiology The University of North Carolina From jonadab at bright.net Tue Sep 5 20:49:54 2000 From: jonadab at bright.net (Jonadab the Unsightly One) Date: Wed, 06 Sep 2000 00:49:54 GMT Subject: Python Metalanguage confusticates and bebothers me... Message-ID: <39b5942f.11001184@news.bright.net> Python itself is okay (well, so far anyway). But the metalanguage -- the terminology used to discuss features of the language -- is weirding me out. "Dictionaries" aren't dictionaries at all, they're associative arrays. "Tuples" don't necessarily have three elements. I suppose once I get used to this stuff it'll be okay... but it reminds me of Reinhold Neibuhr. - jonadab From hei at adtranzsig.de Fri Sep 22 03:18:25 2000 From: hei at adtranzsig.de (Dirk-Ulrich Heise) Date: Fri, 22 Sep 2000 09:18:25 +0200 Subject: Public Domain Python References: <39BBFDB8.A6020F@seebelow.org> <39BF2707.68E1269C@seebelow.org> <39C1CD8C.DA62C34@seebelow.org> <8q4lg4$7ku$4@newsserver.rrzn.uni-hannover.de> <39C684E0.8A26BA1@seebelow.org> <8qcese$oeq$1@desig-bs01-s04.adtranzsig.de> <39CA313D.EB59E69A@earthlink.net> Message-ID: <8qf12s$na7$1@desig-bs01-s04.adtranzsig.de> "Charles Hixson" schrieb im Newsbeitrag news:39CA313D.EB59E69A at earthlink.net... > Dirk-Ulrich Heise wrote: > > > ... > > With a GPLed Python, no commercial application ever would > > have chosen to embed it as its scripting language. Bad choice. > > One of the reasons i decided to learn Python was exactly this > > opportunity. > > > > -- > > Dipl.Inform. Dirk-Ulrich Heise > > hei at adtranzsig.de > > dheise at debitel.net > > It could have been LGPL'd though. > > Admitted, that would be okay. -- Dipl.Inform. Dirk-Ulrich Heise hei at adtranzsig.de dheise at debitel.net From darren at younghome.com Fri Sep 1 14:45:31 2000 From: darren at younghome.com (Darren Young) Date: Fri, 01 Sep 2000 13:45:31 -0500 Subject: snack Message-ID: <39AFF94B.9AD89432@younghome.com> Where can one find some info on snack and possibly some examples on using it within python? Thanks, Darren Young From max at alcyone.com Fri Sep 15 20:31:27 2000 From: max at alcyone.com (Erik Max Francis) Date: Fri, 15 Sep 2000 17:31:27 -0700 Subject: Class warfare... References: <8ptc91$hhk$1@news.rchland.ibm.com> <8pu9u6226it@news2.newsguy.com> Message-ID: <39C2BF5F.65BE1475@alcyone.com> Alex Martelli wrote: > There are several ways, but the one I would suggest is: > > class Bucket(): ^ syntax error; you meant class Bucket: > def __init__(self, cnt=0): > self.cnt = cnt > > b = apply(Bucket, (0,2,0,7,0)) This last line is equivalent to b = Bucket(0, 2, 0, 7, 0) which isn't what you meant. I suspect you meant: b = map(Bucket, [0, 2, 0, 7, 0]) # second argument can also be tuple -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Of all the perversions, chastity is the strangest. \__/ Anatole France blackgirl international / http://www.blackgirl.org/ The Internet resource for black women. From nikolai.kirsebom at siemens.no Thu Sep 21 09:08:58 2000 From: nikolai.kirsebom at siemens.no (Nikolai Kirsebom) Date: Thu, 21 Sep 2000 13:08:58 GMT Subject: Embedding PythonWin Message-ID: <39ca0645.773317401@news.mch.sni.de> Does anyone know where I can find a simple but (more or less) complete example of how to embed pythonwin in an aleady MFC based application. I would like to be able to 'execute' a python script from the application - which provides user interaction (GUI) and also interfaces with the existing application (both embedding and extending). I've made a small example application of embedding / extending python in a MFC application - but I'm not able to run GUI (PythonWin, wxPython) python programs. Nikolai From cut_me_out at hotmail.com Mon Sep 4 10:32:19 2000 From: cut_me_out at hotmail.com (Alex) Date: 04 Sep 2000 10:32:19 -0400 Subject: Class Persistence using __dict__ References: Message-ID: Usually, when I want to make a class persistent, I just pickle the class: class Test: def Save(self, fn): cPickle.dump(self, open(fn, 'w') I only have to do something more elaborate when the class contains a data structure that pickle doesn't know how to deal with. HTH. Alex. -- The chain of destiny can only be grasped one link at a time. -- Sir Winston Churchill From amk1 at erols.com Tue Sep 26 22:46:17 2000 From: amk1 at erols.com (A.M. Kuchling) Date: Tue, 26 Sep 2000 22:46:17 -0400 Subject: New Python development process Message-ID: <200009270246.WAA03038@207-172-38-122.s122.tnt8.ann.va.dialup.rcn.com> Here's a new section for the "What's New in Python 2.0" document describing the new development process. I'd greatly appreciate comments on it, both from readers who can point out hard-to-understand bits and suggest further interesting points that should be made, and also from python-dev people who can point out inaccuracies in my description of the current development process. (*Not* cross-posted to python-dev, since I hate cross-posting.) --amk 3 New Development Process The most important change in Python 2.0 may not be to the code at all, but to how Python is developed. In May of 2000, the Python CVS tree was moved to SourceForge. Previously, there were roughly 7 or so people who had write access to the CVS tree, and all patches had to be inspected and checked in by one of the people on this short list. Obviously, this wasn't very scalable. By moving the CVS tree to SourceForge, it became possible to grant write access to more people; as of September 2000 there were 27 people able to check in changes, a fourfold increase. This makes possible large-scale changes that wouldn't be attempted if they'd have to be filtered through the small group of core developers. For example, one day Peter Schneider-Kamp took it into his head to drop K&R C compatibility and convert the C source for Python to ANSI C. After getting approval on the python-dev mailing list, he launched into a flurry of checkins that lasted about a week, other developers joined in to help, and the job was done. If there were only 5 people with write access, probably that task would have been viewed as ``nice, but not worth the time and effort needed'' and it wouldn't never have been done. SourceForge also provides tools for tracking bug and patch submissions, and in combination with the public CVS tree, they've resulted in a remarkable increase in the speed of development. Patches now get submitted, commented on, revised by people other than the original submitter, and bounced back and forth between people until the patch is deemed worth checking in. This didn't come without a cost: developers now have more e-mail to deal with, more mailing lists to follow, and special tools had to be written for the new environment. For example, SourceForge sends default patch and bug notification e-mail messages that are completely unhelpful, so Ka-Ping Yee wrote an HTML screen-scraper that sends more useful messages. The ease of adding code caused a few initial growing pains, such as code was checked in before it was ready or without getting clear agreement from the developer group. The approval process that has emerged is somewhat similar to that used by the Apache group. Developers can vote +1, +0, -0, or -1 on a patch; +1 and -1 denote acceptance or rejection, while +0 and -0 mean the developer is mostly indifferent to the change, though with a slight positive or negative slant. The most significant change from the Apache model is that Guido van Rossum, who has Benevolent Dictator For Life status, can ignore the votes of the other developers and approve or reject a change, effectively giving him a +Infinity / -Infinity vote. Producing an actual patch is the last step in adding a new feature, and is usually easy compared to the earlier task of coming up with a good design. Discussions of new features can often explode into lengthy mailing list threads, making the discussion hard to follow, and no one can read every posting to python-dev. Therefore, a relatively formal process has been set up to write Python Enhancement Proposals (PEPs), modelled on the Internet RFC process. PEPs are draft documents that describe a proposed new feature, and are continually revised until the community reaches a consensus, either accepting or rejecting the proposal. Quoting from the introduction to PEP 1, ``PEP Purpose and Guidelines'': PEP stands for Python Enhancement Proposal. A PEP is a design document providing information to the Python community, or describing a new feature for Python. The PEP should provide a concise technical specification of the feature and a rationale for the feature. We intend PEPs to be the primary mechanisms for proposing new features, for collecting community input on an issue, and for documenting the design decisions that have gone into Python. The PEP author is responsible for building consensus within the community and documenting dissenting opinions. Read the rest of PEP 1 for the details of the PEP editorial process, style, and format. PEPs are kept in the Python CVS tree on SourceForge, though they're not part of the Python 2.0 distribution, and are also available in HTML form from http://python.sourceforge.net/peps/. As of September 2000, there are 25 PEPS, ranging from PEP 201, ``Lockstep Iteration'', to PEP 225, ``Elementwise/Objectwise Operators''. To report bugs or submit patches for Python 2.0, use the bug tracking and patch manager tools available from the SourceForge project page, at http://sourceforge.net/projects/python/. From aleaxit at yahoo.com Wed Sep 13 05:14:15 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 13 Sep 2000 11:14:15 +0200 Subject: Property testing in lists References: <39BE7FBD.C6961671@alum.mit.edu> Message-ID: <8pngpq02rfi@news1.newsguy.com> "Remco Gerlich" wrote in message news:slrn8rte3c.puc.scarblac-spamtrap at flits104-37.flits.rug.nl... > Dan Brown wrote in comp.lang.python: [snip] > > >>> N = [1, 10, 194, 148, -403] > > >>> map (lambda x: x[1],filter (lambda x: x[0] % 4 == 1, map (None, N, > > range(len(N))))) > > [0, 4] [snip] > N = [1, 10, 194, 148, -403] > filter(lambda x,N=N: N[x] % 4 == 1, range(len(N))) > > It's more verbose than Matlab, but well, just make it into a function once, > and you'll never need to type it again... > > Python has nice ways to make a list of the *values* that have the property, > like filter() and list comprehensions in 2.0(beta), but not for the indices > I think. So just view it as a property of the index :-) List comprehensions in Python 2.0 (currently beta) are nice ways to make lists of indices just as well as list of values. [ i for i in range(len(N)) if N[i]%4 == 1 ] But, of course, there are different approaches available, too, depending on how you want to package this up as a function to be "made once". If you're often looking for a list of indices in situations where filter would be just fine _except_ for the fact that it gives you a list of values instead, for example, then the following function (which you can, if you wish, easily make automatically available to all scripts you write; this kind of things is done in site.py) may serve: def filter_indices(function, list): return [ i for i in range(len(list)) if function(N[i]) ] or, in older Pythons (you don't *have* to use lambda...:-): def filter_indices(function, list): def select_by_index(i, function=function, list=list): return function(list[i]) return filter(select_by_index, range(len(list))) (Note that, if needed for performance, it would be reasonably easy to write this as a small extension in C -- but, profile to check this is indeed such a performance bottleneck, first...). Armed with this simple tool, you can now call: filter_indices(lambda n: n%4==1, N) and just get the indices rather than the values in situations in which the builtin filter would otherwise be OK. Alex From dfan at thecia.net Mon Sep 11 08:22:33 2000 From: dfan at thecia.net (Dan Schmidt) Date: 11 Sep 2000 08:22:33 -0400 Subject: Python 2.0b1 List comprehensions are slow References: <8p9ho7$4g0$1@prometheus.acsu.buffalo.edu> <14776.60842.586901.705258@beluga.mojam.com> <0bxcBgALsfu5Ewa0@jessikat.fsnet.co.uk> <14778.60326.721002.701285@beluga.mojam.com> <8pi88101h3d@news2.newsguy.com> Message-ID: "Alex Martelli" writes: | Consider a few 'equivalent' definitions, such as: | | >>> def withlambda(n): | return map(lambda x: x*x, range(n)) | >>> def withcompre(n): | return [x*x for x in range(n)] | >>> def withlocfun(n): | def square(x): | return x*x | return map(square, range(n)) | >>> def square(x): | return x*x | >>> def withglofun(n): | return map(square, range(n)) | | Performance appears to be roughly like (best-out-of-3 for each): | >>> profile.run('junk=withlambda(10000)') | 10003 function calls in 0.886 CPU seconds | >>> profile.run('junk=withcompre(10000)') | 3 function calls in 0.063 CPU seconds | >>> profile.run('junk=withlocfun(10000)') | 10003 function calls in 0.883 CPU seconds | >>> profile.run('junk=withglofun(10000)') | 10003 function calls in 0.877 CPU seconds | | So, there appears to me to be no significant difference between | the various map versions (lambda, local function, global function), | while the list-comprehension is over an order of magnitude faster | by avoiding the function-calls that map always needs. I don't know a lot about this stuff, but I think that the profiler isn't adequately compensating for the extra work that it has to do to track function calls, so the non-comprehension versions get an unfair handicap. When I just use wall time like this: c = time.clock() junk = withlambda (10000) delta = time.clock() - c print "withlambda: %.3f seconds" % delta I get the following (pretty consistent) results: withlambda: 0.029 seconds withcompre: 0.054 seconds withlocfun: 0.031 seconds withglofun: 0.033 seconds which seem more consistent with the list comprehension performance that other people have been reporting. -- Dan Schmidt | http://www.dfan.org Honest Bob CD now available! | http://www.dfan.org/honestbob/cd.html From Vladimir.Marangozov at inrialpes.fr Tue Sep 12 18:19:35 2000 From: Vladimir.Marangozov at inrialpes.fr (Vladimir Marangozov) Date: Wed, 13 Sep 2000 00:19:35 +0200 Subject: Pyhton and C structures in Shared Memory References: <8pljd8$np4$1@nnrp1.deja.com> Message-ID: <39BEABF7.F7BCF799@inrialpes.fr> philip_john_haynes at my-deja.com wrote: > > Hello All, > > This is a post from a recent convert to Python. > I have big blob of shared memory, essentially > arrays of C structures. > Take a look at http://sirac.inrialpes.fr/~marangoz/python/shm This is probably what you're looking for if you're on Unix. -- Vladimir MARANGOZOV | Vladimir.Marangozov at inrialpes.fr http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252 From pduffin at hursley.ibm.com Fri Sep 15 04:59:38 2000 From: pduffin at hursley.ibm.com (Paul Duffin) Date: Fri, 15 Sep 2000 09:59:38 +0100 Subject: Question on style. References: <39BDE8D0.4B7A6B34@hursley.ibm.com> Message-ID: <39C1E4FA.CFE134A6@hursley.ibm.com> Remco Gerlich wrote: > > Paul Duffin wrote in comp.lang.python: > > Any one like to comment on why this particular order was chosen over > > the more 'readable' one of for first then expression. > > I *think* this syntax was adopted from functional languages, > for instance, in Haskell the "list of squares of the numbers 1 to 100" is > [ n*n | n <- [1..100] ] > Which becomes the slightly more verbose > [ n*n for n in range(1,101) ] The single usage is quite readable but when you have multiple uses in the same expression then it becomes more difficult to read. How should the example from the original poster be 'read' ? frames = [[score[frame] for score in scores] \ for frame in range(3)] What would a similar mathematical expression be ? > in Python. It's also like math, where it would be something like > { x^2 | x element of N and 1 <= n <= 100 } ^ Surely this should be x not n. > > I'd pronounce this "the list of squares of the numbers 1 to 100". > Surely the mathematical interpretation is "the set of squares of the numbers 1 to 100" ^^^ lists are not a mathematical concept are they ? IANAM. From qrczak at knm.org.pl Fri Sep 8 11:31:34 2000 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 8 Sep 2000 15:31:34 GMT Subject: editing in Unicode References: <8p7mli$ccglp$1@ID-4825.news.cis.dfn.de> <8p7rt8$bqo5v$1@ID-4825.news.cis.dfn.de> <87n1hknzzt.fsf@cachemir.echo-net.net> <8p8bkp$cepcj$1@ID-4825.news.cis.dfn.de> <87d7igno2u.fsf@cachemir.echo-net.net> <8pafql$93d$1@nnrp1.deja.com> Message-ID: Fri, 08 Sep 2000 10:42:31 GMT, effbot at pythonware.com pisze: > In Python, this sequence could for example be "#!", and the compiler > could figure things out by looking at the first four bytes: To be executable by Unices, files must start with 8-bit "#!" anyway. Why would anybody want to store a program in UTF-16 or UCS-4? -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From cut_me_out at hotmail.com Sun Sep 17 14:42:36 2000 From: cut_me_out at hotmail.com (Alex) Date: 17 Sep 2000 14:42:36 -0400 Subject: newbie class troubles References: Message-ID: You're right -- python should model its errors reporting after C++. 'Segmentation fault (core dumped)' While learning to write C extensions for python, I actually created a couple of versions of python that gives this informative error message. It falls back to the primitive python errors at times, but it's still pretty useful for assuaging my masochistic side. I could post the source, if there's sufficient interest. Seriously, there's only about ten (rough guess) of these weird error messages to learn. After that, it'll be much easier to track down mistakes. Alex. -- Speak softly but carry a big carrot. From lg at localhost.rgz.ru Wed Sep 13 09:33:51 2000 From: lg at localhost.rgz.ru (Zajcev Evgeny) Date: 13 Sep 2000 13:33:51 +0000 Subject: socket problem? References: <857l8ir5wh.fsf@localhost.rgz.ru> <8pkerq$iq9$0@216.39.151.169> <8566o1r8xs.fsf@localhost.rgz.ru> Message-ID: <854s3kquv4.fsf@localhost.rgz.ru> David Bolen writes: > Zajcev Evgeny writes: > > > I dont want to use socket allready connected to some host:port > > But that's what the protocol TCP is - a stream protocol which > establishes a connection, then manages a stream of data over that > connection, and then tears down the connection. I think there may be > some basic mis-understanding as to what TCP is doing. > > > I just need to send 1 tcp/ip packet to someone(i generate this > > packet according tcp/ip protocols) > > There's really no such thing as sending one TCP packet to someone. To > send any data under control of TCP you first form a connection to the > remote connection point (which is identified by host and port) - this > very process involves several "packets". hm, okay but what is if I do import socket ipsock = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_IP) ipsock.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1) thats mean that all IP headers inluded in sending/receiving packets and I can generate IP packet -------------------------------------------------------- | IP header | -------------------------------------------------------- | IP data = TCP header + TCP data | -------------------------------------------------------- and sendto() it. > > Once you have the connection, you can send any amount of data - the > data may be broken into independent IP packets beneath the scenes (TCP > runs over IP) but at the TCP layer there really isn't a concept of a > packet - it's just a stream of data. When you're done sending, you > close the connection. > > TCP as a protocol is built to ensure that the data you send reaches > the other side in the same order that you transmitted it. To do this, > it may retransmit data, and has to manage the connection between the > two endpoints. So you must initially form the connection - after that > you can request data be transmitted, but you have no real control over > the underlying IP packets - TCP sends them as needed to get your data to > the other end of the connection. > > > i've mistaken in my previos post > > i dont assign port that socket use to connect > > but when i do it right i got > > that when i try to sendto(packet, (host, port)) my packet appended > > as tcp data field and all IP and TCP headers generated automaticly > > similary to send(packet) in allready connected socket > > Well, the TCP and IP headers will always be automatically generated by > the underlying protocol system no matter how you inject your data > (which is placed in the payload of the protocol). TCP headers included only if I cant do socket.setsockopt(, socket.IP_HDRINCL, 1) and this thing works only if socket type is SOCK_RAW but, I can avoid generating IP headers. > > But for a connection oriented protocol (TCP is a connection oriented, > stream protocol, while something like UDP is connectionless, and > datagram oriented), the sendto() function is the same as the send() > function - any addressing information should be ignored as the socket > will already have been connected to the remote session. > > > before it i think that sendto doesnt invoke any ip encoding, > > just put it with transmition module. > > To some extent, yes, both send() and sendto() just pass on their data > to the underlying protocol to be encapsulated within any appropriate > header information necessary. sendto() has the added ability to > communicate new address information for connectionless protocols (like > UDP) that are not fixed to a single endpoint. > > If what you really want to do is send a small fixed amount of data to > a remote endpoint using TCP, you must: > > * Grab a socket (socket) > * Bind it locally (bind). This makes it usable as an endpoint of > communication. > * Connect the socket to the remote endpoint (connect) > * Send the data (send or sendto) > * Close the socket (shutdown/close) > > This process is repeated for new connections. > > If what you want to do is truly send a single datagram to a remote > endpoint, then you need to use a datagram protocol such as UDP, in > which case you could simplify the above to: > > * Grab a socket (socket) > * Bind it locally (bind) > * Send the data to any location (sendto) > > and repeat the sending to other locations with the same PS: I mention that sendto() method works defferently for different socket types. -- regards zev From aleaxit at yahoo.com Wed Sep 13 17:45:57 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 13 Sep 2000 23:45:57 +0200 Subject: Lye - a COM to SOAP gateway... References: <8pnaou$gc2$1@slb6.atl.mindspring.net> Message-ID: <8posne0rui@news1.newsguy.com> "Andrew Dalke" wrote in message news:8pnaou$gc2$1 at slb6.atl.mindspring.net... > [..and a request for COM help] [snip] > I've written a program called Lye which is a simple COM server > that forwards calls to a SOAP server using /F's soaplib. It's Excellent idea! > the Python COM client to talk to the COM server, but I can't get > VB for Applications to do it. With debugging I can see a call in > _dynamic_ for a function/attribute named _value_ . I don't know You have a Visual Basic problem. Your VB code: > soap = factory.createSOAP("http://localhost:8000") is an implicit *LET* assignment. You need to do a *SET* assignment, which must always be explicit: set soap = factory.createSOAP(etc) A LET-assignment to/from an object uses/changes the *DEFAULT VALUE* property of that object; it takes a SET-assignment to use or change *THE OBJECT ITSELF*. This is why for, e.g., a Label object in a VB form, you can change its caption by writing: Label1 = "Foobar" This is a LET assignment, so it affects Label1's default value property, which happens to be its Caption; it does not change the Label1 object itself. So, your problem does not come from any defect with your Python code. Just fix the VB, and the problem will go away. > what to return, or if I should raise an exception. I think that simply not having _value_ should give the right kind of error ("no such property or method"; an object *IS* allowed not to have a default property, if it does not make sense for it). > As I minor point, I'm not sure about the standard COM names for > things like factory functions, so advice for that would also be > helpful. You can take various tacks, but a read-only indexed property is what I've found smoothest, rather than a factory-method. In VB, that would look like: set soap = factory.Soap("whatever") A VC++ client (using VC++'s #import for a typelib) would have, e.g.: IDispatchPtr pSoap = pFactory->GetSoap("whatever"); well -- that's IF you could have a typelib, which Python does not currently allow (sigh -- makes it a bother to access Python-implemented servers from C++ of any kind...). If you want to keep it as a method for some reason, I think MakeSoap, CreateSoap, and GetSoap are good candidates. Usual convention is to have MixedCase (the first letter also uppercased). Alex From root at rainerdeyke.com Mon Sep 18 15:53:40 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 18 Sep 2000 19:53:40 GMT Subject: Thinking about "print >>" References: <39BAA5BF.E562053C@pacbell.net> <39C657ED.8CC8AEA8@gol.com> Message-ID: <8pux5.177964$6y5.106600798@news2.rdc2.tx.home.com> "Arno Paehler" wrote in message news:39C657ED.8CC8AEA8 at gol.com... > C'ish fprint isn't bad either, but at least 'print >>' > probably is better than C++ (was that cout << or cout >>, > C++ is quite-counterintuitive here I think) I disagree: C++'s std::cout << "whatever" is ugly, but at least it uses standard operator overloading instead of messing with the language syntax. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From koconnor at cse.Buffalo.EDU Sat Sep 9 23:05:57 2000 From: koconnor at cse.Buffalo.EDU (Kevin O'Connor) Date: Sat, 9 Sep 2000 23:05:57 -0400 Subject: Python 2.0b1 List comprehensions are slow In-Reply-To: <14776.60842.586901.705258@beluga.mojam.com>; from Skip Montanaro on Fri, Sep 08, 2000 at 08:46:18AM -0500 References: <8p9ho7$4g0$1@prometheus.acsu.buffalo.edu> <14776.60842.586901.705258@beluga.mojam.com> Message-ID: <20000909230557.A21214@armstrong.cse.Buffalo.EDU> On Fri, Sep 08, 2000 at 08:46:18AM -0500, Skip Montanaro wrote: > If you look at the bytecode generated by a list comprehension it should be > about the same as that generated for an equivalent set of nested for and if > statements. One of the reasons to use map instead of a for loop is that it > is often more efficient (essentially pushing the loop indexing machinery > from the Python VM into C). This isn't going to change with list > comprehensions, certainly not in the short term. >From the paragraph above, you seem to be saying that map is faster than list comprehensions because the "loop indexing machinery" is done in C. Although this may be accurate, all of my tests indicate that the loop control is not the problem - the append() method is. It seems like map()'s ability to preallocate the appropriate number of items in advance makes it the faster algorithm. I've extended my original test program to include several new tests; the pure-python for loops that use preallocation seem most telling. I've also extended my test program to test some filter cases. (Using filter, and list comprehensions with an 'if' clause.) It is interesting to note that the list comprehensions win hands down in all cases! It's a tighter race, however, when the resulting lists are almost as big as the original list (again indicating the overhead is in the append() call). > Seriously, inputs on how to improve the generated code are welcome, though > I'm skeptical there's much that can be done (the list's append method is > already cached as I recall, which is where the speedup over for loops comes > from), certainly before 2.0final. If a significant speedup was possible > without a major reworking of the Python VM, I think we'd have seen it by now > in the bytecode generated for for loops. Well, a simple optimization would be to use lambda and map() in the byte code when there is no filter clause in the list comprehension. This seems to always be a win. A better optimization would include some way of hinting to the VM that a list should be preallocated to a certain size. (Whether or not to preallocate on list comprehensions that use an 'if' clause is dubious, but on simple map operations, I speculate that preallocation would be a big win.) Another option would be to use bytecode similar to what I use below in "bar6()", even though it doesn't work perfectly with some corner cases (like if someone issued a "[ a.pop for x in a ]"). Finally, one could always look at optimizing the append method. :-) I know this seems pretty nit-picky. I'm not complaining at all - to reiterate what was said in my first message - I think the list comprehension feature is a GREAT addition. My zeal to use python in as many applications as possible has led me to utilizing it in situations where it really needed to be fast. I'd love to be able to get rid of all those ugly map calls without any fear that performance will be impacted. :-) -Kevin ------------------------ My test results: Many repeated map calls on small lists: bar1(map + operator): 15.77 cpu seconds bar2(map + lambda): 13.02 cpu seconds bar3(list comprehension): 18.84 cpu seconds bar4(for loop): 19.36 cpu seconds bar5(non-returning for loop [BOGUS]): 5.85 cpu seconds bar6(preallocating for loop): 15.17 cpu seconds Many repeated filter calls on small lists: baz2(map + filter + lambda): 28.58 cpu seconds baz2_1(filter + lambda [BOGUS]): 19.15 cpu seconds baz3(list comprehension): 18.49 cpu seconds baz4(for loop): 18.91 cpu seconds baz5(non-returning for loop [BOGUS]): 8.98 cpu seconds baz6(preallocating for loop): 22.47 cpu seconds Many repeated map calls on small lists: foo1(Optimized map+operator): 11.71 cpu seconds foo2(Optimized map+lambda): 12.21 cpu seconds foo3(Optimized list comprehension): 17.57 cpu seconds foo4(Optimized for loop): 18.06 cpu seconds foo5(Optimized non-returning for loop [BOGUS]): 5.39 cpu seconds foo6(Optimized preallocating for loop): 10.63 cpu seconds One map call on a large list: bar1(map + operator): 6.84 cpu seconds bar2(map + lambda): 7.05 cpu seconds bar3(list comprehension): 11.82 cpu seconds bar4(for loop): 12.02 cpu seconds bar5(non-returning for loop [BOGUS]): 3.52 cpu seconds bar6(preallocating for loop): 7.38 cpu seconds One filter call on a large list: baz2(map + filter + lambda): 13.32 cpu seconds baz2_1(filter + lambda [BOGUS]): 9.68 cpu seconds baz3(list comprehension): 9.57 cpu seconds baz4(for loop): 9.7 cpu seconds baz5(non-returning for loop [BOGUS]): 5.17 cpu seconds baz6(preallocating for loop): 10.09 cpu seconds ---------------------- Source code: #!/usr/bin/env python import operator import time Counter = range(200000) def foo1(arry): """Optimized map+operator""" dummyarry = (12,) * len(arry) operator__add = operator.add __map = map for i in Counter: __map(operator__add, dummyarry, arry) def foo2(arry): """Optimized map+lambda""" __map = map func = (lambda x: x+12) for i in Counter: __map(func, arry) def foo3(arry): """Optimized list comprehension""" for i in Counter: [ x+12 for x in arry] ## def foo3(arry): pass def foo4(arry): """Optimized for loop""" for i in Counter: tmparry = [] tmparry__append = tmparry.append for j in arry: tmparry__append(j+12) def foo5(arry): """Optimized non-returning for loop [BOGUS]""" for i in Counter: for j in arry: j+12 def foo6(arry): """Optimized preallocating for loop""" l = len(arry) dummyarry = [None,] * l dummycnt = range(l) for i in Counter: tmparry = list(dummyarry) for j in dummycnt: tmparry[j] = arry[j]+12 def bar1(arry): """map + operator""" return map(operator.add, (12,)*len(arry), arry) def bar2(arry): """map + lambda""" return map(lambda x: x+12, arry) def bar3(arry): """list comprehension""" return [ x+12 for x in arry] ## def bar3(arry): pass def bar4(arry): """for loop""" tmparry = [] tmparry__append = tmparry.append for i in arry: tmparry__append(i+12) return tmparry def bar5(arry): """non-returning for loop [BOGUS]""" for i in arry: i+12 def bar6(arry): """preallocating for loop""" l = len(arry) tmparry = [None,]*l for i in range(l): tmparry[i] = arry[i]+12 return tmparry def baz2(arry): """map + filter + lambda""" return map((lambda x: x+12), filter(lambda x: x & 1, arry)) def baz2_1(arry): """filter + lambda [BOGUS]""" return filter(lambda x: x & 1, arry) def baz3(arry): """list comprehension""" return [ x+12 for x in arry if x & 1] ## def bar3(arry): pass def baz4(arry): """for loop""" tmparry = [] tmparry__append = tmparry.append for i in arry: if i & 1: tmparry__append(i+12) return tmparry def baz5(arry): """non-returning for loop [BOGUS]""" for i in arry: if i & 1: i+12 def baz6(arry): """preallocating for loop""" l = len(arry) tmparry = [None,]*l count = 0 for i in range(l): v = arry[i] if v & 1: tmparry[count] = v+12 count = count + 1 return tmparry[:count] def timeit(func): st = time.clock() func(vals) en = time.clock() return en - st if __name__=='__main__': vals = [1, 8, 12, 89, 325, 213, 23, 434, 435, 2435, 5, 45, 435, 324, 5234] print "Map accuracy test:" for func in (bar1, bar2, bar3, bar4, bar5, bar6): print "%s: %s" % (func.__name__, func(vals)) print print "Filter accuracy test:" for func in (baz2, baz3, baz4, baz5, baz6): print "%s: %s" % (func.__name__, func(vals)) print def many(func, arry): for i in Counter: func(arry) print "Many repeated map calls on small lists:" for func in (bar1, bar2, bar3, bar4, bar5, bar6): print "%s(%s): %s cpu seconds" % (func.__name__, func.__doc__ , timeit((lambda arry, func=func: many(func, arry)))) print print "Many repeated filter calls on small lists:" for func in (baz2, baz2_1, baz3, baz4, baz5, baz6): print "%s(%s): %s cpu seconds" % (func.__name__, func.__doc__ , timeit((lambda arry, func=func: many(func, arry)))) print print "Many repeated map calls on small lists:" for func in (foo1, foo2, foo3, foo4, foo5, foo6): print "%s(%s): %s cpu seconds" % (func.__name__, func.__doc__ , timeit(func)) print vals = range(2000000) print "One map call on a large list:" for func in (bar1, bar2, bar3, bar4, bar5, bar6): print "%s(%s): %s cpu seconds" % (func.__name__, func.__doc__ , timeit(func)) print print "One filter call on a large list:" for func in (baz2, baz2_1, baz3, baz4, baz5, baz6): print "%s(%s): %s cpu seconds" % (func.__name__, func.__doc__ , timeit(func)) print > > -- > Skip Montanaro (skip at mojam.com) > http://www.mojam.com/ > http://www.musi-cal.com/ -- ------------------------------------------------------------------------ | Kevin O'Connor "BTW, IMHO we need a FAQ for | | koconnor at cse.buffalo.edu 'IMHO', 'FAQ', 'BTW', etc. !" | ------------------------------------------------------------------------ From ronjohn at gs.verio.net Sat Sep 2 01:40:51 2000 From: ronjohn at gs.verio.net (Ron Johnson, Jr.) Date: Sat, 02 Sep 2000 00:40:51 -0500 Subject: Sockets tutorial more in depth than the HOWTO Message-ID: <39B092E3.C24676EE@gs.verio.net> Hello, Having read http://www.python.org/doc/howto/sockets/sockets.html I was wondering if there are any more comprehensive tutorials on the web, even if they are C-based. Sincerely, Ron -- 123456789012345678901234567890123456789012345678901234567890 +----------------------------------------------------------+ | Ron Johnson, Jr. Home: ronjohn at gs.verio.net | | Jefferson, LA USA WWW : ronjohnsonjr at yahoo.com | | | | Most overused words: feel, cool/kewl, fun, myBlah.com | | Most underused word: think | +----------------------------------------------------------+ From effbot at telia.com Tue Sep 26 15:09:14 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 26 Sep 2000 19:09:14 GMT Subject: You can never go down the drain... References: Message-ID: > (But someday everyone else won't think regexps are somehow Standard, > canonical, or scientific ;-) imho, regular expressions suck. From donn at oz.net Tue Sep 12 01:27:22 2000 From: donn at oz.net (Donn Cave) Date: 12 Sep 2000 05:27:22 GMT Subject: socket problem? References: <857l8ir5wh.fsf@localhost.rgz.ru> Message-ID: <8pkerq$iq9$0@216.39.151.169> Quoth Zajcev Evgeny : | want to use socket.sendto method to send data via TCP | and for example send SYN packet to some host | >>> import socket | >>> a = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP) | >>> a.sendto('E\020\000,\001\360@\000@\006t\223\325\270\214d\325\270\214c\0179\000\025X\352\247g\000\000\000`\002\000\004M\000\002\004[@\000', ('mail.rgz.ru', 0)) | Traceback (most recent call last): | File "", line 1, in ? | socket.error: (49, "Can't assign requested address") | >>> | | i'm fall in out, it doesnt work! | i try with other socket types and protos ==> work perfect but TCP | | explain me please where i'm misataken or it is long discovered bug? I could be wrong, but I believe a SOCK_STREAM has to be connected. Like, a = socket.socket(socket.AF_INET, socket.SOCK_STREAM) a.connect(('mail.rgz.ru', 7010)) a.send('E...') a.close() If I understand right, you may have already tried SOCK_DGRAM and found that to work - that's where I would use sendto() and recvfrom(). Donn Cave, donn at oz.net From aleaxit at yahoo.com Sat Sep 9 18:42:39 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 10 Sep 2000 00:42:39 +0200 Subject: Thinking about "print >>" References: <39BAA5BF.E562053C@pacbell.net> Message-ID: <8peemu01v4m@news1.newsguy.com> "Michael D. Marchionna" wrote in message news:39BAA5BF.E562053C at pacbell.net... > Wouldn't it just plain be simpler to create a new builtin with a different > name that takes a file object as its first argument. Just call it 'fprint', or Yes, it would be much simpler. It's also easy to arrange for that in your site's customization, actually. > This is the first time I've run across a python idiom that I truly find > embarassing. Yep -- I feel exactly the same way as you about this issue. Alex From vbmark at my-deja.com Mon Sep 18 12:51:50 2000 From: vbmark at my-deja.com (vbMark) Date: Mon, 18 Sep 2000 16:51:50 GMT Subject: Newbie questions. Message-ID: <8q5h6t$qn8$1@nnrp1.deja.com> 1) Can you make a standalone .exe of a Python script? 2) Can you implement DirectX with Python using tk or whatever? 3) Where can I find some GUI programs written in Python? I would like to see how they perform/feel. Thanks. Sent via Deja.com http://www.deja.com/ Before you buy. From azz at gnu.org Thu Sep 7 09:52:10 2000 From: azz at gnu.org (Adam Sampson) Date: 07 Sep 2000 14:52:10 +0100 Subject: Regexp syntax change in 1.6? Message-ID: <87u2bsmhrp.fsf@cartman.azz.net> Hiya. Under Python 1.5.2, I had a script containing the following line: m = re.match(r"[a-z0-9]*://[^/]+/.*\.([^.#\?/]*)([#\?]?.*)?", url) (Bonus points for guessing what it does; answer down the bottom.) Under 1.6, this fails with: [...] File "/usr/local/lib/python1.6/sre.py", line 44, in match return _compile(pattern, flags).match(string) File "/usr/local/lib/python1.6/sre.py", line 102, in _compile raise error, v # invalid expression sre_constants.error: nothing to repeat I can narrow it down to: >>> import re >>> m = re.match(r"(x?)?", url) Traceback (most recent call last): File "", line 1, in ? File "/usr/local/lib/python1.6/sre.py", line 44, in match return _compile(pattern, flags).match(string) File "/usr/local/lib/python1.6/sre.py", line 102, in _compile raise error, v # invalid expression sre_constants.error: nothing to repeat whereas: >>> m = re.match(r"(x?.)?", url) works fine. Is this correct behaviour for SRE, or am I just being stupid? "(x?)?" looks like a perfectly reasonable Perl-style regexp to me (and Perl too)... [Same question sent to python-help, before I remembered that my Usenet connection actually works now.] -- Adam Sampson azz at gnu.org [ The regexp extracts the extension of the file specified in a URL. ] From tgagne at ix.netcom.com Wed Sep 6 13:38:51 2000 From: tgagne at ix.netcom.com (Thomas Gagne) Date: Wed, 06 Sep 2000 13:38:51 -0400 Subject: Getting the attachment from a mime message Message-ID: <39B6812B.CF491B66@ix.netcom.com> I'm not having much luck figuring out how Mime messages are disected. Given: m = mimetools.Message(fp) m.items() has all the header values, but what message returns a decoded attachment? How do you handle a message with multiiple attachments? How do you know if you're pointing to an attachment and not just some random place in the message body? -- .tom From djc at object-craft.com.au Tue Sep 5 20:54:03 2000 From: djc at object-craft.com.au (Dave Cole) Date: 06 Sep 2000 11:54:03 +1100 Subject: MySQLdb oddity References: <8p3r28$is5$1@nnrp1.deja.com> Message-ID: >>>>> "Dave" == Dave Cole writes: Dave> Try doing this (put an 's' after the %()) Dave> curs.execute("INSERT INTO sales_summary (date_sf_entered, Dave> approved_by) VALUES (%(date_sf_entered)s, %(approved_by)s);" % Dave> test) You could even try this: curs.execute('INSERT INTO sales_summary (date_sf_entered, approved_by) VALUES ("%(date_sf_entered)s", "%(approved_by)s");' % test) - Dave From bvdpoel at uniserve.com Sun Sep 3 20:40:44 2000 From: bvdpoel at uniserve.com (Bob van der Poel) Date: Sun, 03 Sep 2000 17:40:44 -0700 Subject: executing .pyc files References: <39B283EA.1D28C228@uniserve.com> Message-ID: <39B2EF8C.DDEBD143@uniserve.com> Michael Hudson wrote: > > Bob van der Poel writes: > > > Playing around a bit I was able to get python to create a .pyc file from > > a program. Since this loads/starts up faster than a normal script I was > > thinking that in my source dir I'd have the full text version and the > > byte-code version in my executable dir. However, I can't seem to find a > > easy way to get it to run. Seems that I have to do something like > > 'python myprog.pyc'. What I'd like to do is to rename myprog.pyc to > > myprog and then just type 'myprog'. I guess I could create a script file > > 'myprog' which just calls python, but that seems rather in-elegant. > > > > BTW, this is on linux (we don't do windows here...). > > Look at: > > http://www.lyra.org/greg/python/ > > near the bottom. Okay, got it. I'd never get that one just fooling around. I'll give it a go later, but it certainly should do the job! (And how do folks figure this stuff out?) -- __ / ) / Bob van der Poel /--< ____/__ bvdpoel at uniserve.com /___/_(_) /_) http://users.uniserve.com/~bvdpoel From oleg at pobox.com Wed Sep 27 18:51:41 2000 From: oleg at pobox.com (oleg at pobox.com) Date: Wed, 27 Sep 2000 22:51:41 GMT Subject: Of what use is 'lambda'??? References: <39CE4E2E.6F6204DF@alcyone.com> <39ce9f9c.49765026@news.bright.net> <86r969qxo9.fsf@jfb.dsl.visi.com> <39d09df6.11689247@news.bright.net> Message-ID: <8qttlr$pda$1@nnrp1.deja.com> Referential transparency is usually defined as substitutability. Suppose we have a function foo(x) and we want to compute the value of an expression foo(5) + foo(5) We can either (i) invoke foo with an argument 5 twice and add the return values, or (ii) invoke foo with an argument 5 once and double the return value. If both ways _always_ give the same result -- and the program behaves the same way (e.g., makes the same modifications to the file systems, printed pieces of paper, etc) no matter which strategy (i) or (ii) we choose -- we have referential transparency. If function foo(x) is defined as foo(x): if x == 0 then 1 else sin(x)/x then indeed both ways, (i) and (ii) of evaluating foo(5)+foo(5), give the same answer -- and result in the same program behavior. However, consider foo1(x) defined as foo1(x): print x; return x + 1 Now it does matter how we evaluate foo1(5)+foo1(5). If we invoke foo twice, we'll see two fives printed. If we invoke foo1(5) once and double its result, we'll see only one '5' printed. The behavior of the program is obviously different. Thus foo1(x) is _not_ referentially transparent. Note how lack of transparency inhibits compiler optimizations. We can re-write foo1(x) as follows: foo2(x,out_port): return (x + 1, print(x,out_port)) foo2() takes two arguments -- a number and an output port -- and returns two arguments: a new number and a new output port. Furthermore, the output port argument is assumed "consumed". Function print() takes a number and a port and returns a new port "with the number printed". foo2() is now again a referentially transparent function. We can use it as follows: let x1,port1 = foo2(x,port) in let x2,port2 = foo2(x,port1) in (x1+x2, port2) This example shows how to handle interactions with the real world and remain referentially transparent. An excellent paper Philip Wadler "How to Declare an Imperative" (ACM Computing Surveys, 1997, v. 29, N3, pp. 240-263). shows other ways. Section 4, "Dispelling Myths about Functional Programming" of another excellent paper Paul Hudak "Conception, Evolution, and Application of Functional Programming Languages" (ACM Computing Surveys, 1989, v. 21, N3, pp. 359-411). demonstrates how similar imperative and functional programming actually are. Either lets us express computations that mutate a global state (including i/o). The apparent difference is that in imperative programming, the mutable state is "implicit": stored in global variables. OTH, in functional programming we pass this state explicitly to all the functions that need it. However, monadic programming blurs even that distinction between the two styles. Sent via Deja.com http://www.deja.com/ Before you buy. From ge at nowhere.none Wed Sep 6 16:39:41 2000 From: ge at nowhere.none (Grant Edwards) Date: Wed, 06 Sep 2000 20:39:41 GMT Subject: A very, very newbie question :) References: <39A41D7E.D865837D@earthlink.net> <20000823103138.A307@bigskytel.com> <39b51682.8283058@news.bright.net> <8FA79D872nemiria@139.130.239.94> <39b623fe.4343445@news.bright.net> <39B68E8C.5E3E511D@alcyone.com> Message-ID: In article , Manuel Gutierrez Algaba wrote: >That's a full blown LIE. I use emacs and I know a bit of elisp. >And it's not compulsory to know elisp!! I used emacs for years without doing any elisp. I did cut/paste a few things from examples into my .emacsrc (or whatever it was called). After I got tired of waiting for emacs to start up, I switched to Jed (good emacs emulation, decent Python mode, about 1/1000 the size of emacs). -- Grant Edwards grante Yow! I have many CHARTS at and DIAGRAMS... visi.com From dcalvelo at pharion.univ-lille2.fr Mon Sep 18 12:09:38 2000 From: dcalvelo at pharion.univ-lille2.fr (Calvelo Daniel) Date: 18 Sep 2000 16:09:38 GMT Subject: How do I run an external system command on Windows? References: <8q5d2b$la8$1@nnrp1.deja.com> Message-ID: <8q5eo2$vms$2@netserv.univ-lille1.fr> noahspurrier at my-deja.com wrote: : Does Python have something similar to Perl's "system" command or the `` : (backtick operator)? This would preferably be something cross-platform. : I need this to work on Windows NT Win2K) and UNIX (OpenBSD). use 'os.system()' : What gives? Even Java has a system call (java.lang.Runtime.exec()). : Of course, I'm not advocating Perl's `` backtick operator. Oh no! Oh, no!!! HTH,DCA -- Daniel Calvelo Aros calvelo at lifl.fr From LinkSwap at Trafficsites.Com Fri Sep 15 18:59:04 2000 From: LinkSwap at Trafficsites.Com (LinkSwap at Trafficsites.Com) Date: Fri, 15 Sep 2000 15:59:04 -0700 (MST) Subject: Would you like to swap links? Message-ID: <200009152259.PAA38070@akshayni.iserver.net> Hello, python-list at cwi.nl I'm not sure if you are the one I should be writing to, but I just wanted to find out if you would be interested in swapping links with us. Currently, we have an automated service to ensure a fair link swap. If interested please visit: http://www.trafficsites.com Sincerely, The TrafficSites Team From parker at gol.com Fri Sep 29 19:45:31 2000 From: parker at gol.com (Ian Parker) Date: Fri, 29 Sep 2000 23:45:31 GMT Subject: Python on VMS References: <8qvn64$5gi$1@nnrp1.deja.com> Message-ID: <8i8WxEA8lS15EwwX@gol.com> In article <8qvn64$5gi$1 at nnrp1.deja.com>, timwkelly at my-deja.com writes >Been trying to build Python on VMS. Used the >Port for version 1.5.2. I keep getting access >violations in PTHREAD$RTL. I have a version of >GCC that runs on the ALPHA and tried to rebuild >but get errors when compiling. If anyone has the >binaries for AXP/OpenVMS V7.2-1 I would >appreciated receiving them. Thank you > > >Sent via Deja.com http://www.deja.com/ >Before you buy. You could download the object modules and link them to create the executables: http://decus.decus.de/~zessin/python/obj.html It worked for me -- Ian Parker From fredrik at pythonware.com Tue Sep 26 10:40:35 2000 From: fredrik at pythonware.com (fredrik at pythonware.com) Date: Tue, 26 Sep 2000 14:40:35 GMT Subject: You can never go down the drain... References: <95Qz5.633$d5.40225@newsb.telia.net> <8qq3pj$bks$1@nnrp1.deja.com> Message-ID: <8qqcgu$m7u$1@nnrp1.deja.com> Georg wrote: > You guys all *know* that replacing the installed version of > Python somewhere is not always an option. Sure, but why would anyone use *beta* releases in that way? (and for all practical purposes, 1.6 is a beta) Besides, you can *always* patch a standard library module. Just copy it to the local directory (tweak the Python path if necessary), and apply the patch in there. Or wait for 2.0b2 -- out later today. Sent via Deja.com http://www.deja.com/ Before you buy. From aleaxit at yahoo.com Fri Sep 1 10:10:11 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 1 Sep 2000 16:10:11 +0200 Subject: Dynamic function calling References: <39AFA5D5.399EDC41@nokia.com> Message-ID: <8oodlj0ts8@news1.newsguy.com> "Olaf Meyer" wrote in message news:39AFA5D5.399EDC41 at nokia.com... > I'm wondering if it is possible to call functions just by having access > to their name in a string value. Something similar to: > > def test(): > print "test function" > > f = "test" > apply(f, ()) > > This does not work of course, because f does not have the right type. > Is there a way to get a function object from the name (string)? Isn't this essentially the same function as just posed by "Igor V. Rafienko" ...? Anyway: the name string by itself does not univocally identify the function object to be used, but it becomes sufficient if you also know where to look it up. Consider, specifically: def docall(kind, name, dict, *args): funobj=dict[name] print "Calling",kind, return apply(funobj, args) def foo(): print 'external foo' def bar(): def foo(): print 'internal foo' docall('local','foo',vars()) docall('global','foo',globals()) Importing this and calling bar() will give us...: Calling local internal foo Calling global external foo Alex From thor at localhost.localdomain Fri Sep 1 12:29:54 2000 From: thor at localhost.localdomain (Manuel Gutierrez Algaba) Date: 1 Sep 2000 16:29:54 GMT Subject: Python 1.6 The balanced language References: <39AB712E.805ACB4B@nowonder.de> <8oknrp$aho$1@nnrp1.deja.com> Message-ID: On lobozc at my-deja.com wrote: >i'm commenting on this particular exchange: >> > language. Although, I think our BDFL would lean more towards a >> > Modula3+Haskell mixture =). >> >> Which only shows his good taste. >> >> pure-functional-programming-in-Modula3-is-a-pain-though-ly y'rs >> Peter > >1) I'm very glad that Haskell seem to be in the picture. I'm even more >happy that list comprehensions have been added to 2.0. Adding >functional elements to Python - without sacrificing its imperative >roots Sometimes "imperative" is preferred to "the functional declarativeness". The only problem with lambda functions, comprehension and so on is that you can build such a big and nasty expression that you have to _run_ it several times in your mind to understand what it does. This goes against the very nature of python : utter simplicity. Using comprehension , sometimes, you can write in 10 lines something you'd need 100 lines in imperative. But, for maintenance purposes, those 10 lines may take two hours to understand while 100 lines of "normal" python takes 10 minutes. That's why Haskell, ML and so on will continue being "academic" for _a long time_. Not everybody is a Ph. D. , nor is so "relaxed" to play with long pseudo-mathematical expresions. Even so, Haskell, ML and Lisp... should be liked for anyone with some love for Computer Sciences. >interpreted one at that. It would make sense to have a quick look at >other higher level imperative languages and see what can be borrowed >from them for python. >From which languages? and What ? >3) My particular favourite is Icon (see www.cs.arizona.edu/icon). >Particular aspects of some interest to Python would be goal-directed >evaluation [saves helluva lot of lines of code...] and, less >importantly, generators and coexpressions. I have no idea how difficult >it would be to move these ideas to Python. Again, although, this sounds nice. The python-spirit is : - no magic If I rembember well, Icon treats equally exceptions and returns from functions. Ok, this seems a bit of magic, and it kills exceptions. And exceptions are important enough in OO for being respected. Again, you can't have three ways to deal with exceptions ( a la Icon, a la Java and a la python ) without having a mess and spiritless language. > But I (and many other >people) can vouch that these mechanisms are very effective in writing >very 'large' programs in a surprisingly small number of lines. Except COBOL, everything can be written in a very small number of lines, it depends if the programmer knows "the art" or if he's a hardwirer ! > I must >stress here that this happens not the way Perl does it - but rather >like in functional languages. That is: because of the built in >mechanisms of evaluation. So it is readable :-), not just terse. > -- MGA From qtmstr at optonline.net Sat Sep 16 17:01:35 2000 From: qtmstr at optonline.net (QuoteMstr) Date: Sat, 16 Sep 2000 21:01:35 GMT Subject: Python 2.0b1 List comprehensions are slow References: <200009131255.HAA04031@cj20424-a.reston1.va.home.com> Message-ID: Guido van Rossum wrote: >Another idea would be to maintain a >"gap" like the Emacs buffer implementation. What is this, and where can I find more information on it? -- "Isn't vi that text editor with two modes... one that beeps and one that corrupts your file?" -- Dan Jocabson, on comp.os.linux.advocacy From alwagner at tcac.net Sun Sep 24 16:55:15 2000 From: alwagner at tcac.net (Albert Wagner) Date: Sun, 24 Sep 2000 14:55:15 -0600 Subject: How to terminate after traceback? References: <39CE4577.E1D7D0F6@tcac.net> Message-ID: <39CE6A33.AD626304@tcac.net> It's a script. I'm running on python1.5.2/wxPython/RH6.1.: $ python main.py Traceback (innermost last): File "main.py", line 381, in AfterSplash frame = RecruitingBrowser(None, -1, "Recruiting Browser:") File "main.py", line 134, in __init__ self.sqlEditor = SqlEditor(self.nb, -1) File "sqlEditor.py", line 57, in __init__ EVT_STC_UPDATEUI(self, ID, self.OnUpdateUI) AttributeError: OnUpdateUI Killed I think I did read somewhere that the wxStyledTextCtrl used threads. Albert Wagner wrote: > > My book says that when python encounters an uncaught exception it > terminates the program and prints a traceback. I get a traceback > without python terminating and have to kill it with my task manager. Is > there a more elegant, pythonish way? > -- > We didn't inherit the land from our fathers. > We are borrowing it from our children. -- We didn't inherit the land from our fathers. We are borrowing it from our children. From aleaxit at yahoo.com Mon Sep 4 09:13:33 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 4 Sep 2000 15:13:33 +0200 Subject: dont laugh References: <8oi3s4$8km$1@nobel2.pacific.net.sg> <8omadr$o8i$1@gaia.cdg.acriter.nl> <1rAlZGAgEEs5Ew4l@ntlworld.com> <8or1nt02i7r@news2.newsguy.com> <8orlkh010m@news2.newsguy.com> <3nnlqLA$F4s5EwZ5@ntlworld.com> Message-ID: <8p07ee0vrf@news2.newsguy.com> "Ian Hobson" wrote in message news:3nnlqLA$F4s5EwZ5 at ntlworld.com... [snip] > >Similarly, if a program "MUST" (uppercase) be pre-installed, > >or else stand zero chance to be taught, it must be a peculiar > >program indeed. 99.7% of programs (including programming [snip] > >I think describing this thesis as "poppycock" would be slightly > >too charitable and urbane, so I'll refrain from expressing what [snip] > I do not care for being quoted out of context, and them dammed for what > I did not say. I think it is downright rude, ill mannered and self > serving and offensive. You said: > >Python MUST run "out of the box" (even on win32 - which it does not) > i.e., you explicitly said that Python does not run "out of the box" on Win32. I responded claiming that, yes, it does. Somebody else tried to answer that by implying that "out of the box" implies being pre-installed with the operating system (as Python is on some Linux distributions), and I rebutted that. One may choose to maintain that "out of the box" means pre-installed with the OS, but then the "MUST" here-quoted becomes laughable; or, one may choose to mean something else, but then the "it does not" is counterfactual. So, your quoted sentence is wrong in one of two ways -- you get to decide which way, by redefining "out of the box" appropriately, but you just can't make it factually correct and sensible. > >and then the ideas can be explained. > > When I installed Python, it would only run scripts in one directory, > and, being clean of habit, I had placed my source in a special source > directory. Paths and associations need to be set up. As I explained, when you install a distribution packaged for Windows, either the standard 1.5.2 one or the ActiveState one currently built on 1.6b1, it *does* set everything up so that *Python* runs "out of the box" -- in the normal sense in which Windows users start most any program: Start/Programs/ActivePython/PythonWin, or similar GUI nav for the CNRI distribution. >From the GUI of PythonWin, it's easy to open Python scripts that reside in any directory -- again, you navigate through the usual Common File Dialog of Windows. From the console-mode Python shell, since it's not a GUI application, you have to handle directory paths more explicitly, of course; but then, it's clearly simpler to start with the GUI, and that will be the typical preference of Windows users, so I think that's quite adequate for Python newbies, with no 'MUST' warranted. Python's ideas can quite well be explained in the PythonWin environment. Python *SCRIPTS* (as opposed to Python itself) may or may not "run out of the box", outside of interactive Python environments, depending on exactly how the installer sets things up. If THIS is what you meant [that Python SCRIPTS should 'run out of the box', rather than, as you said, *PYTHON* iself so running], you might have better advised to say what you meant, rather than what you didn't mean. We could then debate the pro's and con's of each option. Personally, I prefer the default association of Python scripts to be with the *editor* (PythonWin) rather than with *running* the script; most of my .py files are not meant to be run directly, but, rather, imported as modules. When I do want to run a script, a suitable shortcut is preferable (it lets me do various other useful things, such as setting the starting directory); or, from the command line, then explicitly saying C:\mydir> python \py\foo.py is my normal preference, rather than using start (just saying foo.py can be made to work on NT, or on smarter shell, but just can't work on Windows' default, dumb "command.com"). A newbie would be ill-advised to start worrying about such choices, I agree -- but, would said Python newbie be well advised in the first place to be worrying about execution at the command line, at all...? Commandlines seem to be increasingly out of fashion, as many Windows users have never had to struggle with bare DOS (or have forgotten about how they did). If somebody's advanced enough to work at the commandline prompt, I think they're advanced enough to use the explicit form -- and to know about Windows' PATH (I *detest* applications that add their directories to my PATH -- far too many do, and it overcrowds that very limited 'space', so I have to clean it up manually...). > I said nothing about pre-installation. Somebody else did, no doubt because your "out of the box" chosen expression could be construed as ambiguous. But I'm glad that we seem to agree that pre-installation of Python as a part of Windows is not a sine qua non of being able to teach people about Python, because I very strongly doubt that pre-installation can ever happen... Alex From pearu at ioc.ee Tue Sep 12 12:12:59 2000 From: pearu at ioc.ee (Pearu Peterson) Date: Tue, 12 Sep 2000 19:12:59 +0300 (EETDST) Subject: ANNOUNCEMENT: Fortran to Python Interface Generator, 2nd Rel. Message-ID: FPIG - Fortran to Python Interface Generator I am pleased to announce the second public release of f2py (version 2.264): http://cens.ioc.ee/projects/f2py2e/ f2py is a command line tool for binding Python and Fortran codes. It scans Fortran 77/90/95 codes and generates a Python C/API module that makes it possible to call Fortran routines from Python. No Fortran or C expertise is required for using this tool. Features include: *** All basic Fortran types are supported: integer[ | *1 | *2 | *4 | *8 ], logical[ | *1 | *2 | *4 | *8 ], character[ | *(*) | *1 | *2 | *3 | ... ] real[ | *4 | *8 | *16 ], double precision, complex[ | *8 | *16 | *32 ] *** Multi-dimensional arrays of (almost) all basic types. Dimension specifications: | : | * | : *** Supported attributes: intent([ in | inout | out | hide | in,out | inout,out ]) dimension() depend([]) check([]) note() optional, required, external *** Calling Fortran 77/90/95 subroutines and functions. Also Fortran 90/95 module routines. Internal initialization of optional arguments. *** Accessing COMMON blocks from Python. Accessing Fortran 90/95 module data coming soon. *** Call-back functions: calling Python functions from Fortran with very flexible hooks. *** In Python, arguments of the interfaced functions may be of different type - necessary type conversations are done internally in C level. *** Automatically generates documentation (__doc__,LaTeX) for interface functions. *** Automatically generates signature files --- user has full control over the interface constructions. Automatically detects the signatures of call-back functions, solves argument dependencies, etc. *** Automatically generates Makefile for compiling Fortran and C codes and linking them to a shared module. Many compilers are supported: gcc, Compaq Fortran, VAST/f90 Fortran, Absoft F77/F90, MIPSpro 7 Compilers, etc. Platforms: Intel/Alpha Linux, HP-UX, IRIX64. *** Complete User's Guide in various formats (html,ps,pdf,dvi). *** f2py users list is available for support, feedback, etc. More information about f2py, see http://cens.ioc.ee/projects/f2py2e/ f2py is released under the LGPL license. Sincerely, Pearu Peterson September 12, 2000

f2py 2.264 - The Fortran to Python Interface Generator (12-Sep-00) From gangli at msn.com Wed Sep 27 13:09:05 2000 From: gangli at msn.com (gangli at msn.com) Date: Wed, 27 Sep 2000 17:09:05 GMT Subject: Help: C char bits operations to python converting References: <8qr6au$hr4$1@nnrp1.deja.com> <8qrcr7$fhe$1@panix3.panix.com> <8qsscb$qjo$1@nnrp1.deja.com> <8qst1l$rbj$1@nnrp1.deja.com> <8qt0fd$ucv$1@nnrp1.deja.com> Message-ID: <8qt9j8$763$1@nnrp1.deja.com> In article , "Fredrik Lundh" wrote: > > are you trying to solve a real problem, or an is this just > some kind of homework? It is for real ?:). It is part of scurity function for the company I am working for. I used a list to skip using the shift operator: shift4 = [0, 16, 32, 48, 64, 80, 96, 112, -128, -112, -96, -80, -64, -48, -32, -16, 0, 16, 32, 48, 64, 80, 96, 112, -128, -112 ] > > (if it's a real problem, note that your C code isn't portable) > > anyway, to "cast" a python integer to an 8-bit signed > integer, mask with 255 and subtract 256 from it if it's > larger than 127: > > def char(value): > value = value & 255 > if value > 127: > return value - 256 > return value > Thanks for your help. Here my version based on your's: def char_rshift(n, s=4): c = (n << s) & 255 if c > 127: c = c - 256 return c Sent via Deja.com http://www.deja.com/ Before you buy. From a.lempereur Sun Sep 17 12:09:13 2000 From: a.lempereur (Brett Lempereur) Date: Sun, 17 Sep 2000 16:09:13 GMT Subject: newbie class troubles References: <8q2op2$gj1$1@panix2.panix.com> Message-ID: erm... no. my code at the minute is: class filesearch: # Any public variables i need exceptions = [] filelist = [] dirlist = [] def search(self, top): try: tmpList = os.listdir(top) except os.error: return for item in tmpList: if item not in exceptions: name = os.path.join(top, name) if os.path.isdir(name): self.dirlist.append(name) search(self, name) else: self.filelist.append(name) that's the class. you already know the error From akuchlin at mems-exchange.org Tue Sep 5 13:25:13 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 05 Sep 2000 13:25:13 -0400 Subject: Zope gives you too much rope? References: <39ae8a6a@news.xtml.co.uk> <8om3n8$bde$1@newshost.accu.uu.nl> <3dk8cx9j01.fsf@kronos.cnri.reston.va.us> <39aeed74@news.xtml.co.uk> <39AFADC7.5717D3ED@NameConnector.com> <3d3djk6jz2.fsf@kronos.cnri.reston.va.us> <39B343E1.C3CBD556@imeme.net> <39b4cb48@news.xtml.co.uk> Message-ID: <3dr96yrbt2.fsf@kronos.cnri.reston.va.us> "Nick Trout" writes: > > Totally. I'd like to see the ZODB used far & wide. > > Sorry, I'm a newbie. Does this mean you'd prefer everything to be done > through ZClasses and instances? i.e. rather than through databases external > to Zope? No, I'll wager Ethan was referring to other, non-Zope-related software using the ZODB code. The ZODB implements a very neat persistence system for Python objects; while you could write your own implementation (and we briefly considered it), the result would be much the same in terms of complexity, plus you'd have to debug it yourself, and someone has already debugged the ZODB for you. --amk From dickpoon at i-cable.com Thu Sep 21 10:32:06 2000 From: dickpoon at i-cable.com (dickI-cable) Date: Thu, 21 Sep 2000 22:32:06 +0800 Subject: Is this a high volume newsgroup Message-ID: <39CA1BE4.8702AACE@i-cable.com> Hi everybody, I am a new Python user and am interested very much in this language. This is my first time of visiting this newsgroup,but I just find about 20 messages are displayed here! Is this really a high volume mewsgroup?Or I have not download all of them? From puter_programmer at yahoo.com Thu Sep 14 14:44:42 2000 From: puter_programmer at yahoo.com (Dan) Date: Thu, 14 Sep 2000 18:44:42 GMT Subject: socket.ssl Message-ID: <8pr6ak$d4h$1@nnrp1.deja.com> I seem to be having difficulty getting the new socket.ssl() function to work for me in Python 1.6. I have compiled it with OpenSSL-0.9.5a and the ssl attribute of the socket module is there. However, when I try to convert a standard socket to SSL I get a traceback. Perhaps I'm going about it all wrong? Does anyone have a server code example that uses the socket.ssl under Python 1.6? Here's my test code followed by the traceback. import socket import struct sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) linger = struct.pack("ii", 0, 0) sock.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, linger) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) sock.bind( ('127.0.0.1', 443) ) sock.listen(socket.SOMAXCONN) sock = socket.ssl(sock, './www.key', './www.cert') (conn, addr) = sock.accept() Traceback (most recent call last): File "test_ssl.py", line 12, in ? sock = socket.ssl(sock, './www.key', './www.cert') socket.sslerror: SSL_connect error Sent via Deja.com http://www.deja.com/ Before you buy. From ams70 at cam.ac.uk Tue Sep 19 11:37:06 2000 From: ams70 at cam.ac.uk (Andy Smith) Date: 19 Sep 2000 16:37:06 +0100 Subject: a way to keep the Python interpreter in memory? References: Message-ID: Oleg Broytmann writes: > By default, Python do not stay in memory. But you can use different > techiques to run Long Running Process (either Perl or Python). The > best known mechanism is FastCGI - www.fastcgi.com. > > PersistentCGI > (http://starship.python.net/crew/jbauer/persistcgi/index.html) is > the same idea with different protocol; it is python-only solution. If you're using Apache there is also mod_python (www.modpython.org), or mod_perl if you want to write in Perl. Andy -- Andy Smith ams70 at cam.ac.uk St John's College, Cambridge, CB2 1TP, UK (07989) 453208 From jonadab at bright.net Fri Sep 8 04:46:32 2000 From: jonadab at bright.net (Jonadab the Unsightly One) Date: Fri, 08 Sep 2000 08:46:32 GMT Subject: A very, very newbie question :) References: <39A41D7E.D865837D@earthlink.net> <20000823103138.A307@bigskytel.com> <39b51682.8283058@news.bright.net> <8FA79D872nemiria@139.130.239.94> <39b623fe.4343445@news.bright.net> <39B68E8C.5E3E511D@alcyone.com> Message-ID: <39b7967e.14552645@news.bright.net> scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) wrote: > But Jed is so much smaller and faster :) If you want small and fast, nothing beats UED. It used to load up from a 360K floppy on my old ITT XTRA (8088, 4.77 Mhz) with no visible delay. These days I don't worry about it. Windoze takes so many decades to start up (okay, it's about a minute and a half, but it seems like forever) that any application I start up afterward pales in comparison. And really, I only need to close Emacs to reboot, unless I'm making changes to my .emacs, and even then I can often just do an eval-region (or perhaps eval-defun if I have altered defvars and want them to take effect), unless it's a major sweeping change. It doesn't make sense to close Emacs if you aren't also shutting down the OS. Close Emacs? How would you do anything, then? . . . [Mutters something incoherent about rewriting gcc in elisp so that it compiles to bytecode and then porting Perl and Python to Emacs...] [Wakes up.] What? Oh, sorry, I was dreaming. - jonadab From rickp at telocity.com Wed Sep 20 22:52:41 2000 From: rickp at telocity.com (Rick Pasotto) Date: Thu, 21 Sep 2000 02:52:41 GMT Subject: Why is text file processing SO slow? References: <8qb5j8$g17$1@nnrp1.deja.com> <8qblpm$7tg$1@panix2.panix.com> Message-ID: On 20 Sep 2000 17:46:46 -0700 in comp.lang.python, Aahz Maruch wrote: > In article <8qb5j8$g17$1 at nnrp1.deja.com>, wrote: > > > >I have a program that processes large files ~25 megs. The algorithm > >that I use is as follows: > > Use readlines() with the hint argument so you don't consume too much > RAM. What is this "hint argument?" It's not mentioned in the docs that I have. Furthermore, the tutorial says that readlines() calls readline() repeatedly so I don't see why there should be any speed difference. -- "'Value' has no meaning other than in relation to living beings. The value of a thing is always relative to a particular person, is completely personal & different in quantity for each living human -- 'market value' is a fiction, merely a rough guess at the average of personal values, all of which must be quantitatively different or trade would be impossible... The very personal relationship, 'value', has 2 factors for a human being: 1st, what he can do with a thing, its use for him... & 2nd, what he must do to get it, its cost to him. There is an old song which asserts 'the best things in life are free'. Not true! Utterly false! This was the tragic fallacy which brought on the decadence & collapse of the democracies of the 20th century; those noble experiments failed because the people had been led to believe that they could simply vote for whatever they wanted... & get it, without toil, without sweat, without tears. Nothing of value is free. Even the breath of life is purchased at birth only through gasping effort & pain... If you boys & girls had to sweat for your toys the way a newly born baby has to struggle to live you would be happier... & much richer." -- Robert Anson Heinlein 1959 _StarShip Troopers_ Rick Pasotto email: rickp at telocity.com From tim_one at email.msn.com Thu Sep 14 21:15:08 2000 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 14 Sep 2000 21:15:08 -0400 Subject: Is anyone aware of any conflicts with Windows ME? In-Reply-To: <20000914161730.08520.00000054@ng-fw1.aol.com> Message-ID: > I'll be receiving my new PC shortly and it is coming with Windows > ME preloaded. Has there been any testing with Python and ME. I'd > really hate to crash it as soon as I get it. We've had only one beta tester report on Windows ME, using a prerelease of Python 2.0b1. Python installed fine, and all of the standard test suite passed *except* for the new mmap module. This appears to be a bug in Microsoft's stuff, but since we don't have a copy of ME yet it's darned hard to say. However, since you seem to believe that a Microsoft operating system crashing is something you can avoid, I'll assume you're a pretty new user of Microsoft operating systems . In that case, there's not much chance you'll be *trying* to use the new mmap module (which provides an interface to memory-mapped files, in case you're not a new user). Even if you do, it doesn't crash Windows when it fails, it just raises a Python exception. windows-*loves*-being-rebooted-ly y'rs - tim From darcy at vex.net Thu Sep 28 07:32:25 2000 From: darcy at vex.net (D'Arcy J.M. Cain) Date: 28 Sep 2000 11:32:25 GMT Subject: "CPAN" SIG? References: <39D26528.6E4EE699@spacenet.tn.cornell.edu> Message-ID: <8qva89$1rft$1@news.tht.net> Tom Loredo wrote: > Vaults is great. However I strongly feel there is a need, if not > for CPAN, then at least for mirrors of Vaults. As someone who has > just written a grant proposal seeking support for a Python > project, I find it worrisome that Python's main source of info > about 3rd party libraries is a single site. In particular, Vaults > has been incredibly unstable in the last month or so; a web page > supporting my proposal links to it and I am just praying that > when the reviewers visit it, it's not one of the days that clicking > on the Vaults link returns an error message. There have been > many days like that lately. There should be fewer lately. Let me tell you what has been going on. Recently we did a major upgrade on Vex.Net. All third party packages were upgraded and rebuilt as well. Since then the VoP (which is built on Python and PostgreSQL) has been giving us troubles. Specifically, the database engine kept crashing. We finally figured out that it was the VoP database that was the problem and we created a second instance of the engine to handle it. This has confirmed that the problem is related to the VoP. We are now watching it carefully and are in the process of writing a script to monitor and restart as necessary. I have also had Tim send me the schema for the database so that I can look it over and possibly help in case the problem is there. I will also be helping him go through the code to see if we can find where it crashes. Meanwhile, the Vaults should be up most of the time now. > The collective efforts of Python programmers are too vital a > component of the case for Python to be subject to this kind > of single-point failure. We need something broader and more > stable. This, of course, is a different issue. Have you contacted Tim about doing some mirroring? As long as you can install PostgreSQL and PyGreSQL you should be able to run the same code. You may even be able to help debug the current problems. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.vex.net/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From claird at starbase.neosoft.com Thu Sep 21 10:03:11 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 21 Sep 2000 09:03:11 -0500 Subject: Language wrappers References: <8qcura$hsa$1@nnrp1.deja.com> Message-ID: In article <8qcura$hsa$1 at nnrp1.deja.com>, Jordi Inglada wrote: >Hi all, > >I am looking for modules which wrap other languages son they can be used >in python scripts. I am thinking about using a prolog kernel or a >clisp inference engine, though others are also welcome (scheme, haskell, >...). > >I have seen something like this for clips at > but it looks like >it works for old versions of python. > >I guess one solution would be using SWIG to generate de bindings for >those which are written in C (GNUProlog, for instance), but I wouldn't >want to re-invent de wheel!! . . . I occasionally collect notes on this subject at . I'm a bit behind just now; maybe in October I'll fold in more of what I've collected ... The good news is that several comp.lang.python regulars have thought deeply about this. Other follow-ups might soon appear. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From aleaxit at yahoo.com Sun Sep 3 03:24:25 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 3 Sep 2000 09:24:25 +0200 Subject: Writing to locals(), globals(), and vars() References: Message-ID: <8osuic012d9@news2.newsguy.com> "Michael Haggerty" wrote in message news:m2aedqqt45.fsf at freak.kaiserty.com... > First question: Is there a way to write to the local symbol table in a > generic way (without using `exec')? For example, this could be used No, because the compiler optimizes local-namespaces accesses to reduce the lookups-by-name. Functions that contain an exec statement have this important optimization turned off, "just in case". So, this happens to currently work...: def funfun(): exec 'pass' locals()['foo'] = 'bar' print foo while commenting the exec statement has it fail with NameError. You can consider the statement exec 'pass' as a way of saying "I don't care if this function runs twice as slow, writing to the local symbol table is what life is truly all about". I'm not sure how "solid" this situation is -- does it depend on deep Python truth, or just a current accident of implementation? Maybe someone with deeper understanding can help on this. > Second question: Is it legal to write to globals()? The Library > Reference is mute on this point. (Not that it would help with the > above problem...) As above: it works, but, who knows how solidly...? Similarly, is direct updating of a module's __dict__ guaranteed to work, or does it just currently happen to...? Personally, being a coward, I tend to rely on some *instance*'s __dict__ for this kind of dirty work. I update() it with vars() or whatever at __init__ time, then can freely use that instance to access a mutable set of 'variables'. And *that* one is (I think and hope) guaranteed to work and keep working, since writing into an instance's __dict__ is a documented way to work... Alex From robin at jessikat.fsnet.co.uk Sun Sep 10 19:03:47 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Mon, 11 Sep 2000 00:03:47 +0100 Subject: Python 2.0b1 is released! References: Message-ID: In article , Tim Peters writes ... cogent arguments omitted. This whole mess is a stinking bag of fish waiting to explode in the worst possible way. I still think the GPL & FSF are the problem not the solution. The best possible license holder would be the public, but apparently FSF don't like these laissez faire non fascist/legalist licenses, so we get doomed to deal with purists. -Lawmerica land of opportunity-ly yrs- Robin Becker From aahz at panix.com Wed Sep 20 23:08:40 2000 From: aahz at panix.com (Aahz Maruch) Date: 20 Sep 2000 20:08:40 -0700 Subject: Why is text file processing SO slow? References: <8qb5j8$g17$1@nnrp1.deja.com> <8qblpm$7tg$1@panix2.panix.com> Message-ID: <8qbu3o$riq$1@panix6.panix.com> [posted with cc to python-docs] In article , Rick Pasotto wrote: >On 20 Sep 2000 17:46:46 -0700 in comp.lang.python, Aahz Maruch wrote: >> >> Use readlines() with the hint argument so you don't consume too much >> RAM. > >What is this "hint argument?" It's not mentioned in the docs that I >have. Furthermore, the tutorial says that readlines() calls readline() >repeatedly so I don't see why there should be any speed difference. I believe the tutorial is incorrect; more precisely, after looking at it myself, the tutorial is misleading. My docs say readlines ([sizehint]) in the library reference ("Other built-in types") and go on to explain that sizehint is in bytes, but that (unlike the size argument for readline()) you are guaranteed that you will only get entire lines. If you really want speed, there's a QIO module out somewhere. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Member of the Groucho Marx Fan Club --Aahz From sholden at holdenweb.com Thu Sep 28 17:51:30 2000 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 28 Sep 2000 17:51:30 -0400 Subject: continue statement: best way round a problem References: <39CBBA10.5BCAEF0A@holdenweb.com> <14795.54113.386450.595679@beluga.mojam.com> <39D2BC42.53E71B28@my.signature> Message-ID: <39D3BD62.95CA37C4@holdenweb.com> Greg Ewing wrote: > > Skip Montanaro wrote: > > > > Clearly, the second continue > > statement is in a valid place. It's inside the for loop and not executed > > from a try clause. > > But both of those continues are inside the *outer* try, > so *neither* of them should be valid! > Well, since it accepts one and not the other, whether they are both valid or both invalid there's clearly something wrong. Can someone who's tracking the 2.0 beta releases let us know whether the continue anomaly is FINR? regards Steve -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ From sholden at holdenweb.com Thu Sep 7 14:10:31 2000 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 07 Sep 2000 14:10:31 -0400 Subject: Running python from cygwin with .py-extension --- import: not found References: <39B7710C.72426717@yahoo.com> <8p8461$do7$1@netserv.univ-lille1.fr> <39B7B0F2.295FBE72@yahoo.com> Message-ID: <39B7DA17.722D24F0@holdenweb.com> Olav wrote: > > Calvelo Daniel wrote: > > > > > It seems that your script is not interpreted by Python. Those are not > > Python errors. > > No, the script is interpreted. The problem is importing the libraries: > Yes, but interpreted by what? > /home/olav> cat hello.py > print "Hello world" > /home/olav> hello.py > Can't find file Hello world I'm guessing that your shell is finding a "print" command on your PATH, but that the "print" command can't find what it thinks to be a file. > /home/olav> cat hello2.py > import os > print "Hello world" > /home/olav> hello2.py > import: not found This strongly corroborates the suspicion that your shell* is doing the interpretation and not the Python interpreter. No Python interpreter would complain about import, and even if it did it would raise a Name exception rather than using the "not found" message. > Can't find file Hello world This is the shell* compaining about the SECOND line of the script. > /home/olav> python hello2.py > Hello world > /home/olav> > Aha! So when the Python interpreter sees your script it does indeed interpret it correctly. > (....That it is trying to look for the file-name instead of printing is also > interesting.....) > > > > > > I tried to use a script with a '#!/usr/bin/env python' first line > > and it works exactly as in UNIX, ie call it directly after a 'chmod +x'. > > I am uing PATHEXT=.COM;.EXE;.BAT;.CMD;.ph > (in the NT environment this variable is in fact not visible in cygwin) > > .....Though perhaps I should look into the "#"-way of doing it? > > > Merci! > Olav > You might want to look into http://www.toolwood.dk/freeware/PythonLauncher or take advice about how otherwise to make Python scripts executable in the Windows NT environment. The "#!" hack is solely for U**x, sorry. regards Steve * For "shell" above, read "NT command interpreter". -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ From dalke at acm.org Wed Sep 20 16:57:04 2000 From: dalke at acm.org (Andrew Dalke) Date: Wed, 20 Sep 2000 14:57:04 -0600 Subject: What is Python? References: <8pqhm9$6a9$1@panix3.panix.com> <3BBC75F01B2A2291.3CC54B93C0C69DED.4E021EA85330C94C@lp.airnews.net> <8pt65c$cbs$2@newshost.accu.uu.nl> <39C29336.71ED41AC@seebelow.org> <39C3E664.BCEAF741@seebelow.org> <8q5rgv$7to$1@nnrp1.deja.com> <39C6DF06.FF7F8A74@engcorp.com> <39C70642.D6CBF93A@alcyone.com> <39C710F7.4E72D963@seebelow.org> <39C86059.2F644D70@engcorp.com> <39C867B5.DFF9FFD3@seebelow.org> <8qat1u02g2j@drn.newsguy.com> <8qb42f$e95$1@nnrp1.deja.com> Message-ID: <8qb83n$qei$1@nntp9.atl.mindspring.net> "George": >Better examples might be wallet/billfold/pocketbook, or hood/bonnet, or >boot/trunk I always thought a wallet was for carrying paper money, credit cards, pictures, id, etc. while a billfold was solely for carrying paper money. My dictionary agrees with you. Huh, and the first definition given for "pocketbook" is "a wallet" while I thought its usage was primarily their second definition of "handbag". My favorite is, what's the difference between an Atlantic hurricane, a Pacific typhoon, or an Indian Ocean cyclone? http://www.weather.com/glossary/wx_glossary_t.html#typhoon For vague relevance, a python is a "large, nonvenomous Old World snake that coils around and suffocates its prey." Andrew dalke at acm.org From aahz at panix.com Wed Sep 20 19:57:17 2000 From: aahz at panix.com (Aahz Maruch) Date: 20 Sep 2000 16:57:17 -0700 Subject: What is Python? References: <39C67A2C.2313778A@seebelow.org> Message-ID: <8qbist$4m2$1@panix2.panix.com> In article , Tim Hammerquist wrote: > >Regexps are optimized for matching text against patterns as >quickly and efficiently as possible, whereas you can only have so many: > > if 'x' in word: > >statements before you're bloating your code unnecessarily. True. OTOH, many Perl programmers are so focused on regexes that they would try to implement the following code with regexes: dict = { ... } for word in words: if dict.has_key(word): ... -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Member of the Groucho Marx Fan Club --Aahz From com.talx at mxb Tue Sep 12 12:31:12 2000 From: com.talx at mxb (Martin Bertolino) Date: Tue, 12 Sep 2000 11:31:12 -0500 Subject: MIME attachments and SMTP References: <8pjstm$oqh$1@nnrp1.deja.com> Message-ID: You probaly need to check RFC 1521 -> MIME Part One (http://www.ietf.org/rfc). I recently wrote some code (C++ though) based on the information contained in this document. It also helped to send myself emails with attachments, and then examine the 'raw' documents with a text editor rather than viewing them within the email client. I would assume that the email client you use will let you browse the messages you receive without interpretation. I hope this helps Martin wrote in message news:8pjstm$oqh$1 at nnrp1.deja.com... > I'm trying to set up a command line utility in > python.. and I've set up the SMTP to specs but > when I send a message doing: > server = smtplib.SMTP('myserver') > server.set_debuglevel(1) > fromaddr = 'rickr at brickroad.net' > toaddrs = 'rickr at brickroad.net' > msg = 'blah blah blah blah' > server.sendmail(fromaddr, toaddrs, msg) > server.quit() > > however, it arrives it arrives with no to: and no > subject. > > I was also wondering if someone could point me to > more information on using mime types to add > attachments. I've gone through the docs.. but > can't find much information on this. > > thanks > > Rick > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From c.evans at clear.net.nz Sun Sep 10 07:21:20 2000 From: c.evans at clear.net.nz (Carey Evans) Date: 10 Sep 2000 23:21:20 +1200 Subject: Python 2.0b1 is released! References: Message-ID: <878zt0ebm7.fsf@psyche.dnsalias.org> Piet van Oostrum writes: > Maybe the right to choose the applicable law. Where does the GPL grant that right? Sections 11 and 12 refer to "applicable law" for warranties, but don't define it. The CNRI license just defines what the applicable law is in its case. -- Carey Evans http://home.clear.net.nz/pages/c.evans/ "As I understand it, gnus is emacs. Thus gnus is Evil Incarnate." - Jasper Janssen From darren at younghome.com Fri Sep 1 12:04:37 2000 From: darren at younghome.com (Darren Young) Date: Fri, 01 Sep 2000 11:04:37 -0500 Subject: SAX Xml Problem Message-ID: <39AFD395.41C6E178@younghome.com> I am getting the following error: Reading /usr/local/src/yhl/src/installer/manifext.xml Traceback (innermost last): File "./dl.py", line 29, in ? parser.parseFile(file) File "/usr/lib/python1.5/site-packages/xml/sax/drivers/drv_pyexpat.py", line 77, in parseFile if not self.parser.Parse(fileobj.read(),1): AttributeError: 'string' object has no attribute 'read' When I run the following code: #!/usr/bin/python # from xml.sax import saxexts from xml.sax import saxlib class FindSource(saxlib.HandlerBase): def __init__(self, name): self.search_name = name def startElement(self, elemName, attrs): print "Starting element: ", name #if elemName != 'source' : return name = attrs.get('name', None) if name == self.search_name: print name, 'found' if __name__ == '__main__': file = "/usr/local/src/yhl/src/installer/manifest.xml" print "Reading", file parser = saxexts.make_parser() dh = FindSource('Bash') parser.setDocumentHandler(dh) parser.parseFile(file) parser.close() Any ideas would be wonderful... Thanks, Darren Young From effbot at telia.com Wed Sep 6 12:24:44 2000 From: effbot at telia.com (Fredrik Lundh) Date: Wed, 06 Sep 2000 16:24:44 GMT Subject: Python 2.0b1 is released! References: <200009060449.XAA02145@cj20424-a.reston1.va.home.com> <8p4sg8$77d4$1@www.univie.ac.at> <39B61C25.20F927F6@softax.com.pl> Message-ID: gene wrote: > and my personal favorite.... > > Visual Python which one: http://www.deja.com/=dnc/getdoc.xp?AN=647020031 http://www.python.org/pipermail/edu-sig/2000-May/000498.html http://www.activestate.com/Products/VisualPython.html http://sourceforge.net/project/?group_id=6013 ... From danunder at columbus.rr.com Sun Sep 10 19:29:36 2000 From: danunder at columbus.rr.com (Dan Underwood) Date: Sun, 10 Sep 2000 23:29:36 GMT Subject: Pythonwin + wxPython debugging event callbacks References: <39B6D25A.FE5BD3AE@columbus.rr.com> Message-ID: <39BC1B3F.EE4417ED@columbus.rr.com> Never Mind! I forgot to call wxPython's MainLoop. wxPython pretends to be there but really is off in never-never land, thus the Pythonwin debugger has no idea what's going on. Dan. Dan Underwood wrote: > > I'm having trouble getting the Pythonwin debugger to recognize > breakpoints within wxPython event methods. Any suggestions? > Thanks. > Dan. From wtanksle at dolphin.openprojects.net Mon Sep 18 17:49:03 2000 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Mon, 18 Sep 2000 21:49:03 GMT Subject: What is Python? References: <8pqhm9$6a9$1@panix3.panix.com> <3BBC75F01B2A2291.3CC54B93C0C69DED.4E021EA85330C94C@lp.airnews.net> <8pt65c$cbs$2@newshost.accu.uu.nl> <39C29336.71ED41AC@seebelow.org> <39C3E664.BCEAF741@seebelow.org> <8q5rgv$7to$1@nnrp1.deja.com> Message-ID: On Mon, 18 Sep 2000 19:47:50 GMT, drobinow at my-deja.com wrote: > tim at degree.ath.cx (Tim Hammerquist) wrote: >> As a matter of interest, anyone want to convert the following code to >> Python? >> perl -npe 'next unless /\bjudea/i && /\bfront\b/i' /scripts/movies/brian/* >Sure. What's it do? It prints all of the lines in all of the indicated files which contain the word-start "judea" and the word "front". Here's another way of saying that: cat /scripts/movies/brian/* | grep "\\bjudea" | grep "\\bfront\\b" The direct translation is reasonably obvious (using the fileinput, glob, and re modules). My laziness is currently stopping me from finding a non-re solution, but a truly pythonic solution wouldn't have to use re. -- -William "Billy" Tanksley From aleaxit at yahoo.com Tue Sep 12 16:53:07 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 12 Sep 2000 22:53:07 +0200 Subject: Python 2.0b1 List comprehensions are slow References: Message-ID: <8pm5c602qio@news2.newsguy.com> "Guido van Rossum" wrote in message news:cppum9bf62.fsf at cj20424-a.reston1.va.home.com... [snip] > - Preallocate the result list so that the append() can be faster. ...but not at the cost of breaking the equivalence with 'for', please...? I wouldn't want my sequence-objects to have to implement 'length' to be usable in comprehensions, when they don't have to in order to be usable in 'for' (in fact, I really like the idea of my sequence-objects being 'lazy'...!). Maybe a performance-hint to the result-list "I'm probably about to append a lot of things" (and a closing "I'm done appending now, trim if need be") might help the list know not to allocate too-small slices of space at a time...? (This could make append's cost amortized-linear rather than quadratic, at some temporary cost in memory use, by having the list switch to a geometric progression of growth rather than a linear one...). Alex From m.faassen at vet.uu.nl Tue Sep 5 10:02:56 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 5 Sep 2000 14:02:56 GMT Subject: OO-programming question References: <8ou9i4029q1@news2.newsguy.com> <39B3F7D9.C0D540D0@seebelow.org> Message-ID: <8p2ueg$dua$3@newshost.accu.uu.nl> Grant Griffin wrote: [snip] > Also, Python's approach allows you to implicitly > declare the "type". (Then again, isn't explicit supposed to be better > than implicit? .) A while ago I had the somewhat novel (i.e. Guido called it nuts) idea of explicitizing the interface. Now, introducing explicit interfaces is nothing new to Python, but explicit interfaces have an overhead; you need to write them down: class Foo: __interfaces__ = ['Sequence'] def __getitem__(self, i): ... ... where there's also something like this: interface Sequence: def __getitem__(self, i): pass ... Obviously declaring the interface is overhead, and we like Python because the overhead in code is so small. That's why we like dynamic typing, which doesn't need any of this. However, sometimes we'd like the dynamic types to be a bit more explicit. My nutty approach was a compromise solution. Classes still declare they belong to an interface (by name), but the interfaces are not declared (unless you want them to be): class Foo: __interfaces__ = ['Inquisition'] def torture(self): ... def deny(self): ... def flap_wings(self): ... class Bar: __interfaces__ = ['Inquisition'] def torture(self): ... def deny(self): ... def save(self): ... This would implicitly explicitly declare an interface that has the methods 'torture' and 'deny' (shared by all classes that implement this interface). If at some point you want them to be declared, you can do that still. But in the mean time you already have them, and you can do things with them, like some forms of type checking, for instance. This idea has the advantage that you have some explicitness in interfaces, with minimal overhead to the programmer. I thought that this was cool, but nobody else seems to agree. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From gerryq at indigo.ie Sat Sep 2 06:45:05 2000 From: gerryq at indigo.ie (Gerry Quinn) Date: Sat, 02 Sep 2000 10:45:05 GMT Subject: Python in game development? References: <39B081F1.E4B2D3E@gte.net> Message-ID: In article <39B081F1.E4B2D3E at gte.net>, "Matthew V. Jessick" wrote: > > >Kragen Sitaker wrote: > >> but I wouldn't advocate "try something; see if it's >> fixed; repeat" as a bug-fixing methodology. I did that when I was a >> kid, and it made my programs awful. > >Make sure you leave the test algorithms that didn't work >laying around (commented out) in the code to guide future generations. > >Stuff like: >// (*rps) = weirdUndocumentedHackvariable; A particularly good style in MFC is to incorporate exotic graphic test routines in the OnPaint() functions of random window classes... Gerry Quinn -- http://bindweed.com Puzzle / Strategy Games and Kaleidoscope for Windows Download evaluation versions free, no time limits New: Unique 2-player strategy game "Zen" From kragen at dnaco.net Wed Sep 27 00:47:34 2000 From: kragen at dnaco.net (Kragen Sitaker) Date: Wed, 27 Sep 2000 04:47:34 GMT Subject: Using the re module (Regular expressions) References: <3dog1bxm3f.fsf@kronos.cnri.reston.va.us> Message-ID: In article <3dog1bxm3f.fsf at kronos.cnri.reston.va.us>, Andrew Kuchling wrote: >"Darrell Gallion" writes: >> Try this >> r'(?s)Returned-Path:\s<.*>\012Recieved:' > >Also note that it's spelled 'Received'. It's also spelled 'Return-Path'. -- Kragen Sitaker Perilous to all of us are the devices of an art deeper than we ourselves possess. -- Gandalf the Grey [J.R.R. Tolkien, "Lord of the Rings"] From hburde at bci-bremen.de Tue Sep 26 06:39:31 2000 From: hburde at bci-bremen.de (Holger Burde) Date: Tue, 26 Sep 2000 11:39:31 +0100 Subject: app slow down References: <39CD415A.CC498224@uni-bremen.de> <39CCF79A.7B383EFE@ajubasolutions.com> Message-ID: <39D07CE3.AC7A2A44@bci-bremen.de> Dan Kuchler wrote: > me wrote: > > > > Hi; > > > > My application shows strange delays at several points. Opening Window a) > > > > needs 2 minutes - opening another similar Window b) 2 secounds. The > > application does not do any > > computations that can cause such delays. I used truss to pin down the > > problem . The interpreter sleeps in read - 60..120 secounds - read(6, > > 0x0071FD7C, 5120) (sleeping...) - and then starts again. > > > > > > What window manager are you using? > > This problem you describe might be specific to > the window manager that you are using. > > --Dan hi; A reboot always resolves this. Its a shared libraray problem (interposition ) . I hope i can track this down to the app that loads the shlib with the problem. Mabe one of the proc cmds (what mapped to the adress space) gives an answer to this problem. -- Dipl. Inform. H. Burde - UNIX SysAdmin/Security - BCI GmbH Tel: +49 421 202 46 01 - hburde at bci-bremen.de - http://www.bci-bremen.de From bjorn at roguewave.com Fri Sep 29 16:54:31 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Fri, 29 Sep 2000 14:54:31 -0600 Subject: can I query an instance for its name? References: <9z6B5.941$8n3.59167@carnaval.risq.qc.ca> Message-ID: <39D50187.E240BC56@roguewave.com> so if I do: x = foo() y = x y.who() what should it print? -- bjorn Luc Lefebvre wrote: > > Hi, > > <\newbie alert on> > > I have been attempting to get access to instance names, eg: > > class foo: > def __init__(self): > pass > > def who(self): > print "%s is an instance of class %s" % (self.????, self.__class__) > > if __name__=="__main__": > x=foo() > x.who() # would expect "x is an instance of class foo" > > Also, is there a way to enquire as to a given classes children eg: foo.__children__? > > <\newbie alert off> > tia > > -- > http://www.python.org/mailman/listinfo/python-list From effbot at pythonware.com Sat Sep 9 09:08:44 2000 From: effbot at pythonware.com (effbot at pythonware.com) Date: Sat, 09 Sep 2000 13:08:44 GMT Subject: some uglyness in Python imho References: <005701c01a55$43454790$b62079a5@jayk4> Message-ID: <8pdcoj$huq$1@nnrp1.deja.com> Jay wrote: > *DL_IMPORT __declspec(dllexport,import,etc) > > Is this strictly for Windows, or do Unix, Mac, etc. need them? > (I'm pretty sure Unix does not and Mac makes do at least with > #pragmas at the top and bottom of the header). > > If they are only for Windows, you shouldn't use them. > You can just use a .def file without spoiling your source > code. And who's gonna make sure the DEF file is always kept 100% up to date? Earlier versions of Python tried this approach. Didn't work. Since most development is done on Unix, important functions were always missing from the Windows DLL's. A macro makes it *much* easier for non-Windows programmers to get things right from the start, without having to test the code on a platform they don't use... ...besides, if Microsoft didn't want us to use this, they shouldn't have added the declspec directive to the compiler in the first place ;-) Sent via Deja.com http://www.deja.com/ Before you buy. From thomas at cintra.no Fri Sep 15 07:01:12 2000 From: thomas at cintra.no (Thomas Weholt) Date: Fri, 15 Sep 2000 13:01:12 +0200 Subject: Update: same result for md5. Now what? Message-ID: <8psvg5$s9c$1@oslo-nntp.eunet.no> The files are different. Is there something about jpg-compressed files that I should know about? From cobrien at Radix.Net Fri Sep 22 09:08:56 2000 From: cobrien at Radix.Net (Cary O'Brien) Date: 22 Sep 2000 09:08:56 -0400 Subject: where is upvar References: <20000920131508.A17613@snowy.squish.net> <39C8FEAC.1668A1C4@sage.att.com> Message-ID: <8qfll8$14s$1@saltmine.radix.net> In article <39C8FEAC.1668A1C4 at sage.att.com>, Garry Hodgson wrote: >Harald Kirsch wrote: >> >> Jon Ribbens writes: >> > Accessing variables in other peoples' scopes directly is nasty anyway, >> > use function arguments ;-). >> >> Not if it is documented and if the sole purpose of a certain function >> is to do that in a defined way. Those functions are sometimes called >> `control structures'. It seems like Tcl is a bit ahead of Python here, >> as it allows to create functions which look, smell and work like >> custom made control structures. > >it's arguable whether this is a good thing or not. i've used languages >which allowed this, including tcl. it's cute, but of limited utility. >and the readability cost can be high. > One reason to have upvar in TCL is to implement call-by-reference, rather than TCL call-by-value. Passing a variable name is common in the builtin functions (i.e. append) and upvar lets you implement routines that expect a variable name. I use this a lot when there are lots of parameters to a function. Rather than have 20 parameters, I create an array with the information and pass the name. An upvar in the called function makes this array available during function execution. I don't think there is a readability cost, frankly. Since python is, i guess, call-by-reference, you don't need this at all. One TCL example of a good use of "upvar" as a control structure is something that we call sql_map, and a couple of other people have implemented independantly. Basically it is a for loop over all the rows in a select from a database with variable assignments. The body runs in the context of of the caller. Oops -- This uses uplevel, not upvar. Ok, but it is the same idea. sql_map $sql(h) {name phone age} { if {$age > $max_age} { whataver... } } uplevel lets you create new control structures. You could iterate over a result set in python, but at the cost of a throw-away function. -- cary From matt at mondoinfo.com Thu Sep 28 13:07:43 2000 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Thu, 28 Sep 2000 17:07:43 GMT Subject: imp module References: <39D34601.A57E2802@rivermen.se> Message-ID: On Thu, 28 Sep 2000 15:22:09 +0200, Magnus Heino wrote: >I want to import a module that dont know the name of then coding. I think that the easy way to do what you want is to read the module into a string and then use Fredrik Lundh's technique for importing a module from a string. It's at http://www.deja.com/getdoc.xp?AN=621152936 Regards, Matt From neilh at scintilla.org Tue Sep 5 20:48:06 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Wed, 06 Sep 2000 00:48:06 GMT Subject: Thinking about "print >>" References: Message-ID: Martin von Loewis wrote: > Roy Smith writes: > > > It seems to me that the thing to do would be to define a "print" method > > for file objects, which is like write, but has all the pretty-print > > functionality of the print statement. > > Yet another proposal that doesn't work. print is a keyword, so you > can't use it as a method name. In the future, it may be possible to use keywords as identifiers when there are no ambiguities. IIRC, this was introduced to JPython a while (18 months?) ago to allow access to identifiers published by Java code that matched Python keywords. I was horrified, but the world didn't collapse immediately. Python.Net will need something similar - its required by the language interoperability specifications. There have been expressions of support for extending this to CPython by some of the core developers. If its available in two dialects of Python, it should be allowed in all. Neil From brian.j.geddes at intel.com Thu Sep 21 13:22:34 2000 From: brian.j.geddes at intel.com (Brian Geddes) Date: Thu, 21 Sep 2000 10:22:34 -0700 Subject: Colored text in Linux Message-ID: <8qdg1e$248@news.or.intel.com> All - I want to be able to print out colored text to the screen from inside a Python script in Linux. I figure this is just a matter of using the proper escape codes, but I'm not sure where to find them or if I'll have to use anything other than the basic print() function. Thanks in advance... - Brian From urner at alumni.princeton.edu Sun Sep 10 05:19:15 2000 From: urner at alumni.princeton.edu (Kirby Urner) Date: Sun, 10 Sep 2000 02:19:15 -0700 Subject: Win98 2.0b: crash on Help References: <7c7mrs4nau15mf420nfigna8ueo2d9nqii@4ax.com> <2jHu5.54$F5.7541@newsb.telia.net> Message-ID: Hey, many thanks! I remember reading that now, but didn't make the mental connection to opening Help Docs with the Browser (slaps forehead -- but yes, of course!). Turned off my NAV, and yes, all works smoothly. Such _interesting_ bugs we get these days. Kirby PS: I'm really liking the new functions in 2.0b BTW -- just wrote a little paper about 'em, how to use when teaching pre-calculus (the post is around here somewhere). ======================================================== "Fredrik Lundh" wrote: >Kirby Urner wrote: >> In 2.0b IDLE 0.6 under Win98, when I select Help | Python Documentation, >> I get an amazingly serious crash. A couple blue screens of death >> followed by a switch into some undefined video mode. Have to reboot. >> This is on an AMD K2 400, 128RAM, Voodoo3 graphics. > >from the 2.0 download page (in ludicrously small print at the bottom >of the page): > > Incompatibility warning: Norton Antivirus 2000 can cause blue > screen crashes on Windows 98 when a function in the os.popen*() > family is invoked. To prevent this problem, disable Norton Antivirus > when using Python. (Confirmed on Windows 98 Second Edition with > Norton Antivirus version 6.10.20. The same Norton Antivirus version > doesn't have this problem on Windows 2000. Norton Antivirus > version 5 on Windows 98SE doesn't have this problem either.) > > > > > From nospam at nospam.com Sun Sep 3 12:22:37 2000 From: nospam at nospam.com (Tom) Date: Sun, 03 Sep 2000 16:22:37 GMT Subject: Python frontend to C++ code References: <8osfjo$1ka$1@nnrp1.deja.com> Message-ID: One fast prototyping technique for gui development is to use wxPython. As a C++ programmer, I've found that wxPython allows me to develop a GUI much quicker than I ever could in C++. And, as a bonus, when you are finished you can convert any or all of it to C++ using the exact same framework. Tom. wrote in message news:8osfjo$1ka$1 at nnrp1.deja.com... > Hi. I've read in many places that Python is ideal for fast prototyping > and for building a portable frontend to C/C++ code. > > I am a Python beginner but an experimented C++ programmer and I am > considering building such a frontend. But I am not sure which are my > options: I've read about embeding and extending Python (but both seem > to request quite a lot of wrapping code, which doesn't sound to me > like "fast prototyping"). > > So, I'd like to ask you guys which are my options in this case? > > Thanks in advance, > Sorin Gherman > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From imbault at worldnet.fr Tue Sep 12 18:20:00 2000 From: imbault at worldnet.fr (Patrick Imbault) Date: Wed, 13 Sep 2000 00:20:00 +0200 Subject: A VOUS TOUS DEVELOPPEURS INDEPENDANTS Message-ID: <8pmaah$1o9o$1@news6.isdnet.net> From avv at quasar.ipa.nw.ru Sun Sep 17 19:14:00 2000 From: avv at quasar.ipa.nw.ru (Alexander V. Voinov) Date: Sun, 17 Sep 2000 16:14:00 -0700 Subject: Where is the wxPython forum? References: <8q0rgg$ni2$1@nnrp1.deja.com> <8q0tgk$ph4$1@nnrp1.deja.com> <8q0uj7$qn5$1@nnrp1.deja.com> Message-ID: <39C55038.DBF1DD7@quasar.ipa.nw.ru> Hi You may also try this newsgroup: news://news.scitechsoft.com/wxwindows.users.wxpython WBR Alexander Opinderjit wrote: > > Which forum is currently active? > > In article <8q0tgk$ph4$1 at nnrp1.deja.com>, > Sindh wrote: > > I don't know which forum you are getting the email from. However I > > haven't sent any mail to you. Probably you are thinking of wxPython > > mailing list and not the web based forum I put up. > > > > Not many people seem to be using the forum I put up. So one of these > > days I might just bring it down. > > > > Regards > > sreekant > > > > In article <8q0rgg$ni2$1 at nnrp1.deja.com>, > > Opinderjit wrote: > > > I am still getting e-mail from the wxPython forum, however when I > sent > > > mail to it, where does it go? > > > > > > Also, it looks as if the forum at the wxpython.org site has not > moved, > > > and http://www.wxpython.uklinux.net/ doesn't seem to be moving > either. > > > > > > Sent via Deja.com http://www.deja.com/ > > > Before you buy. > > > > > > > -- > > A man needs to sleep for 36 hours a day atleast. > > > > Sent via Deja.com http://www.deja.com/ > > Before you buy. > > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From loewis at informatik.hu-berlin.de Mon Sep 25 17:36:07 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 25 Sep 2000 23:36:07 +0200 Subject: Lazy coerce function? References: <39CF62C2.EB3343B8@nbg.siemens.de> Message-ID: Treutwein Guido writes: > The documentation is a little bit on the short side, specifying, that > numbers are casted to compatible types. > > Python 1.6 reacts as follows: > coerce(3,'a') # raises a TypeError, as expected. > coerce('a', 'b') # returns ('a', 'b') > coerce('a', []) # raises TypeError > > Is there any simple rule under what circumstances coerce raises an > exception? The results of coerce are typically passed to arithmetic operations. If there is some sensible way to convert the arguments that the results support arithmethic operators, the conversion is performed - otherwise you get a type error. A good candidate operator is '+': if plus 'ought to' work on the operands, coerce will return objects that can be added. That's why coercing strings and lists does something nontrivial. Regards, Martin From kragen at dnaco.net Wed Sep 27 00:46:41 2000 From: kragen at dnaco.net (Kragen Sitaker) Date: Wed, 27 Sep 2000 04:46:41 GMT Subject: reloading a C module References: <8qod32$dqo$1@nnrp1.deja.com> Message-ID: In article , Martin von Loewis wrote: >chris_barker at my-deja.com writes: > >> Is this supposed to work? > >Reloading of C modules is not supposed to work; all hell would break >lose if there are still objects allocated which had their code in the >old copy of the library. Perhaps reload(x) should raise an exception in this case? -- Kragen Sitaker Perilous to all of us are the devices of an art deeper than we ourselves possess. -- Gandalf the Grey [J.R.R. Tolkien, "Lord of the Rings"] From lg at rgz.ru Fri Sep 22 11:33:28 2000 From: lg at rgz.ru (lg at rgz.ru) Date: 22 Sep 2000 19:23:28 +0350 Subject: Python JavaScript interface Message-ID: <39cb796f@news.edunet.ru> Hi I developing new Python project so I need interface betwean python and java script aclually need to parse java script code and compare js functions to some pythons functions. Thanks. -- zev From darrell at dorb.com Fri Sep 29 21:25:25 2000 From: darrell at dorb.com (Darrell Gallion) Date: Fri, 29 Sep 2000 21:25:25 -0400 Subject: Possible 2.0b2 bug: Recursion limit in non-greedy regular expressions Message-ID: <05fe01c02a7d$4f39cac0$6401a8c0@home> I posted a patch. Although I'm sure the patch will need some work, it solved only my immediate need. Suspect this error might still occur with other patterns. Here's a solution, hopefully posting these won't get me into trouble :) http://dorb.com/darrell/dropPoint/_sre.pyd http://dorb.com/darrell/dropPoint/_sre.c --Darrell From: "Richie Hindle" > longish strings. If I run the following code in 2.0b2: > > >>> re.match( 'a.*?b', 'a' + 'c' * 16167 ) > > it fails with "RuntimeError: maximum recursion limit exceeded". > Decreasing the number of 'c's to 16166 makes it OK. > From jonadab at bright.net Fri Sep 8 04:46:32 2000 From: jonadab at bright.net (Jonadab the Unsightly One) Date: Fri, 08 Sep 2000 08:46:32 GMT Subject: A very, very newbie question :) References: <39A41D7E.D865837D@earthlink.net> <20000823103138.A307@bigskytel.com> <39b51682.8283058@news.bright.net> <8FA79D872nemiria@139.130.239.94> <39b623fe.4343445@news.bright.net> Message-ID: <39b7967a.14548348@news.bright.net> David Bolen wrote: > Just think of pressing backspace as the same as entering the closing > brace and pressing in another language, like C. Until you > enter the brace, those modes tend to maintain the existing indentation > as well. > > It's actually fewer keystrokes ;-) Yes, but I'm not *used* to it yet. - jonadab From sblakey at freei.com Tue Sep 12 17:29:05 2000 From: sblakey at freei.com (Sean Blakey) Date: Tue, 12 Sep 2000 14:29:05 -0700 Subject: Getting the code of a character ? In-Reply-To: <8pm63u$29p$1@reader1.imaginet.fr>; from glenfant@nospam-e-pack.net on Tue, Sep 12, 2000 at 11:13:01PM +0200 References: <8pm63u$29p$1@reader1.imaginet.fr> Message-ID: <20000912142904.A30428@freei.com> On Sep 12 at 11:13P, Gilles Lenfant wrote: > Yes, a real newbie question ! > How to get the code number of a character like : > x = asc("x") in stupid Basic ? > > TIA I don't know Basic, but it sounds like you ar elooking for the built-in ord() function: >>>ord('x') 120 >>>map(ord, 'spam') [115, 112, 97, 109] >>> -Sean -- Sean Blakey, sblakey at freei.com Software Developer, FreeInternet.com (253)796-6500x1025 As in certain cults it is possible to kill a process if you know its true name. -- Ken Thompson and Dennis M. Ritchie From markhaliday at my-deja.com Thu Sep 7 09:40:05 2000 From: markhaliday at my-deja.com (markhaliday at my-deja.com) Date: Thu, 07 Sep 2000 13:40:05 GMT Subject: Does Python scale for heavy web loads? Message-ID: <8p85rh$hmi$1@nnrp1.deja.com> Question: Using Python as a CGI and running it under Apache, would Python realistically be able to handle 5,000 hits an hour and not degrade performance? With Python's threading, (ex: using a Default.py script as an example) I call Default.py to render some information, only one thread runs Default.py right? No other people can hit Default.py until Default.py finishes with its original request and serving the information back...Correct? Thanks. Sent via Deja.com http://www.deja.com/ Before you buy. From nick at nil_spam_videosystem.co.uk Tue Sep 5 12:04:10 2000 From: nick at nil_spam_videosystem.co.uk (Nick Trout) Date: Tue, 5 Sep 2000 17:04:10 +0100 Subject: newbie: Zope References: <39ae8a6a@news.xtml.co.uk> <8om3n8$bde$1@newshost.accu.uu.nl> <39aea000@news.xtml.co.uk> <8ooduo$ink$2@newshost.accu.uu.nl> Message-ID: <39b519fd@news.xtml.co.uk> > The idea of the ZDP site is to help fill it. :) I believe there's also a > zope.faqts.com that may be helpful. Thats not very easy when I'm finding it difficult to learn Zope!! :-) Bit of chicken and egg?! I'd like an expert to give me insight... Mind you noones ever said Zope was easy. My biggest stumbling block is getting it do do anything interesting /difficult with ZClasses due to DTML/Python interface. > There are some very good Howto's out there, it's just a bit difficult > to find them... exactly. > ZClasses without any base class (at least explicitly) can be used to > store some simple properties. I believe the example in the developer's > guide mentions a CD listing; each instance of such a ZClass would be > a CD object. Folderish ZClasses could be used to organize your site; > one way to do this in Zope is to put common methods in the root folder > of the site; subfolders acquire this information. This does pollute the > root folder, though, so another approach is to use a ZClass that behaves > like a folder but adds some methods (such as a request for an index of > subfolders, formatted as HTML, for instance). Be nice if Zope actually listed the properties you picked up (or does it :-) and gave you help on them. > > There's not much info on interfacing with Python. And then the interface is > > DTML-ish?! > > Simple interfacing to Python isn't that hard. You can write an external > method: > > def foo(self, arg): > return "the arg is: " + arg > > and call it like this: > > > Which'll get you this on your page: > > the arg is: hey! So why use DTML at all? Seems to me that DTML is only used so that you can substitute object values into HTML. It provides a horrible unintuitive interface to Python. Why not generate all of the DTML in Python and then just substitute simple objects. i.e. DTML does *nothing* clever. > You can also return lists, such as here: > > def get_a_list(self): > return [1, 2, 3, 4] > > And you can use this with dtml-in, for instance: > >

    > >
  • >
    >
So why not return from get_a_list() ...?
  • 1
  • 2
  • 3
  • 4
Why the ugly DTML iterators? It seems like too much functionality has shifted into DTML? > Oh, any class, basically. To make an class persistent in Zope, do this: > > from Globals import Persistent > > class MyClass(Persistent): > ... > > This is in the intro document on the ZODB, by the way. :) So I may as well use Python functionality and this and not use ZClasses at all?! > That's in the intro to the ZODB too, so I'll look it up for you: > self._p_changed = 1 Ah, I did find this in the end. :-) > > And the link again: > >> http://starship.python.net/crew/amk/python/writing/zodb-zeo.html Cheers, Nick. From nobody at nowhere.nohow Mon Sep 4 23:02:04 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Tue, 05 Sep 2000 03:02:04 GMT Subject: The Tuple syntax is perfectly regular References: Message-ID: In article , jepler epler wrote: >>No, that's not the tuple syntax. The syntax is: >> >> empty: () >> singleton: a, >> etc.: a,b > >Thanks for the correction. Actually, though, my original post was intended >as tongue-in-cheek. Oops. Color me embarassed. >So, now, I'll suggest that we make the () mandantory. >There, now it's completely regular. Yup, though it would be better if parens weren't used for two other things alreadly. -- Grant Edwards grante Yow! ... I see TOILET at SEATS... visi.com From max at alcyone.com Tue Sep 5 23:20:57 2000 From: max at alcyone.com (Erik Max Francis) Date: Tue, 05 Sep 2000 20:20:57 -0700 Subject: Python Metalanguage confusticates and bebothers me... References: <39b5942f.11001184@news.bright.net> Message-ID: <39B5B819.434FF8B7@alcyone.com> Jonadab the Unsightly One wrote: > "Dictionaries" > aren't dictionaries at all, they're associative arrays. _Dictionary_ is a relatively common computer science term for an associative array. I think your Inform background is showing, here. :-) > "Tuples" don't necessarily have three elements. This one I don't follow. _Tuple_ is a mathematical term for an element of a Cartesian product of sets -- in fact, they're called "ordered tuples." The general count is n-tuple; a 2-tuple is a pair, and a 3-tuple is a triplet. Maybe you were mixing up _triple_ and _tuple_? -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Here day fights with night. \__/ (the last words of Victor Hugo) Fat Boy and Little Man / http://www.fatboyandlittleman.com/ Watch Fat Boy and Little Man go about their antics. From robin at alldunn.com Wed Sep 27 19:29:59 2000 From: robin at alldunn.com (robin at alldunn.com) Date: Wed, 27 Sep 2000 23:29:59 GMT Subject: PyThreadState_Get: no current thread -- building debug libraries References: Message-ID: <8qtvti$r60$1@nnrp1.deja.com> In article , Mike Fletcher wrote: > > S:\Python-1.5.2\PCbuild>python_d > Python 1.5.2 (#0, Sep 27 2000, 15:43:48) [MSC 32 bit (Intel)] on win32 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import TextTools.TextTools > Fatal Python error: PyThreadState_Get: no current thread > > So why am I bothering you all with this? Well, mostly 'cause I haven't a > clue why this is showing up, nor what the fix would look like. More > curiously, this is one of the errors I had show up occasionally as part of > the persistent, nasty, crashes I'm doing all this stuff to fix. So, any > gurus out there willing to tell me how _PyThreadState_Current == NULL in a > running interpreter? I'm assuming that it's something like a DLL version > mismatch, but not really sure what DLL would be causing the problem. > Most likely the .exe and the .pyd are importing different python .dlls. You can use the "dumpbin /imports" tool to check. -- Robin Dunn Software Craftsman robin at AllDunn.com http://wxPython.org Java give you jitters? http://wxPROs.com Relax with wxPython! Sent via Deja.com http://www.deja.com/ Before you buy. From darrell at dorb.com Fri Sep 29 19:48:27 2000 From: darrell at dorb.com (Darrell Gallion) Date: Fri, 29 Sep 2000 19:48:27 -0400 Subject: filtering out "bad" regular expressions from user input References: <14804.44620.833433.640545@beluga.mojam.com> Message-ID: <057601c02a6f$c39f7e40$6401a8c0@home> From: "Skip Montanaro" > I'm looking for a better approach to filtering out bad regular expressions. Don't laugh. Change the regex engine to accept limits on time and space. This doesn't seem like a hugely complicated change. --Darrell From hei at adtranzsig.de Fri Sep 29 07:43:04 2000 From: hei at adtranzsig.de (Dirk-Ulrich Heise) Date: Fri, 29 Sep 2000 13:43:04 +0200 Subject: Changing class membership References: <8qt1ci$ecj$1@desig-bs01-s04.adtranzsig.de> <8r1ng6$hef$1@news.sns-felb.debis.de> Message-ID: <8r1v64$943$1@desig-bs01-s04.adtranzsig.de> schrieb: > I believed for years that "object evolution" is a useful and elegant concept. > Only a month ago I started learning Python and soon realized how easy it > would be to implement. That's my current solution: Your solution looks great. Thanks! I hope i don't regret using it... (Sometimes, some fascinating idea completely ruins an architecture, making it an unmaintainable mess) -- Dipl.Inform. Dirk-Ulrich Heise hei at adtranzsig.de dheise at debitel.net From aleaxit at yahoo.com Tue Sep 12 09:14:06 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 12 Sep 2000 15:14:06 +0200 Subject: Setting The Path References: <968688772.23213.0.pluto.d4ee1bae@news.demon.nl> <8pjcde0aot@news2.newsguy.com> <39BDA7BC.41D8108@engcorp.com> <968761984.29196.0.pluto.d4ee1bae@news.demon.nl> Message-ID: <8plaft0tgu@news1.newsguy.com> "No Strezzz Cazzz" wrote in message news:968761984.29196.0.pluto.d4ee1bae at news.demon.nl... [snip] > >> C:\Progra~1\Coding\Python [snip] > %SystemRoot%\system32;%SystemRoot%;C:\progra~1\CoDiNg\Python\ > > That didn't work, so I tried settig it to: There's an extra \ at the end wrt what I had suggested; that may be the problem. > %SystemRoot%\system32;%SystemRoot%;C:\progra~1\CoDiNg\Python\python.exe > > That also didn't work. (I also tried to set the path without Here, there's an extra \python.exe at the end. The PATH is a list of directories (where programs are found), not of programs themselves. > %SystemRoot%\system32;%SystemRoot% in front of it. > > When I want to run/execute the script (some lines of Python code written in > wordpad and saved as test.py) I keep getting the message that Windows cannot > find Program.exe And it asks me to specify the "Location of Program.exe" So What's "Program.exe"? Do you mean "python.exe"? Try saying explicitly: c:\ c\progra~1\coding\python\python.exe c:\wherever\you\keep\it\test.py If this runs, then it's just a matter of PATH setting, as expected (i.e., probably, the extra \ you put at the end). It seems it might be nice if the installer had a user-settable option to add the Python directory to the PATH (on NT; it's a lost cause on 95/98... it's gotta be done by editing AUTOEXEC.BAT, and I _detest_ programs that do that...). It would be a slight convenience for NT users that have never changed their PATH before. Alex From griff at netdoor.com Tue Sep 19 16:27:59 2000 From: griff at netdoor.com (R. A.) Date: Tue, 19 Sep 2000 15:27:59 -0500 Subject: Python and ISPs Message-ID: <39C7CC4F.1BB3EC6E@netdoor.com> My current ISP doesn't allow the use of Python scripts for personal web pages, and since they don't seem to be terribly interested in my attempts to bring them around, I'm looking for a new ISP. My question is this: Since I may have to educate a few people in my attempts to find the right ISP for me, what are the requirements for running Python on the server? My plans do not include secure transactions or any enterprise applications, but relatively simple scripts I can use for personal home pages. Any insight would be helpful. Rob Andrews From claird at starbase.neosoft.com Wed Sep 6 22:35:49 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 6 Sep 2000 21:35:49 -0500 Subject: Is Python worth learning? References: <1YCs5.31979$K5.513760@typhoon.austin.rr.com> <8p1den$a13$1@panix2.panix.com> Message-ID: <922BCC28EF71A4F3.D07DF642D45772FD.2376059CAA37B222@lp.airnews.net> In article , Cameron Laird wrote: >In article <8p1den$a13$1 at panix2.panix.com>, Aahz Maruch wrote: >>In article , lynx wrote: >>> >>>however, the point i tried to make was that python isn't meant to directly >>>compete with java in all those places java was meant to be The Language(tm), >>>that python wasn't built to replace java. not to speak for Guido, of course, >>>but i'd be rather surprised to learn that it was. >> >>Given that Python predates Java, that would be impossible unless Guido >>used his Time Machine. > . > . > . >... and, in any case, even when he speaks for himself, >Guido says, "Java and Python: a perfect couple" >. . . . A couple of people have already pointed out to me that this URL 404s. Elsewhere in this thread, Andrew Kuchling observed that google caches a copy at . I just got word from Gamelan that the article moved to . Gamelan has no intention of repairing all their broken links. That's what I'm told, at least. I'm working to locate a contact with whom we can register our strong disapproval. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From haskin at ptway.com Wed Sep 6 13:17:47 2000 From: haskin at ptway.com (Brian Haskin) Date: Wed, 06 Sep 2000 13:17:47 -0400 Subject: Strictly 'local' threads in Python? References: <8o3ff6$fog@news.or.intel.com> Message-ID: <39B67C3B.65391CFE@ptway.com> Take a look at microthreads. The only catch is that it requires stackless python, which is only available as a patch to 1.5.2 (nice thing is it may result in a speed increase in your program). Microthreads can be found at http://world.std.com/~wware/uthread.html Brian Haskin haskin at ptway.com Robert Yodlowski wrote: > > I need to control several concurrently running, independent sequences of > activities from Python functions. Up to now I've been using the standard > Python threading module with fine results. > > Now, I need to be able to do something similar but embedded in a different > application that "does not support threading". I've tried embedding Python > with the standard threading module but the application crashes immediately > when I try to run it. > > The only reason I've used threads is to avoid the need to 'manually' keep > track of where each sequence is executing as control is passed around from > one sequence to another. I explicitly 'hop' from thread to thread so only a > single thread is active at any given instant. > > It seems to me that this limited form of threading could be accomplished > strictly locally within the Python interpreter without any need to include > or use the OS's threading facility. > > Can this be done? > Has anyone done it? > Any advice would be appreciated. > > ...Bob From marco at crepido.com Thu Sep 28 07:59:27 2000 From: marco at crepido.com (Marco =?iso-8859-1?Q?Seiri=F6?=) Date: Thu, 28 Sep 2000 13:59:27 +0200 Subject: Scripting language for an application Message-ID: <39D3329F.390C831D@c_repido.co_m> Hi all I'm doing research (=surfing the web) in order to see what language I will use in an application (C++) we are building. Today we use Perl to some extent. Would you think there would be any benefit from using Python instead/also? My main concerns are speed and ease of use. /M From noahspurrier at my-deja.com Tue Sep 19 12:26:35 2000 From: noahspurrier at my-deja.com (noahspurrier at my-deja.com) Date: Tue, 19 Sep 2000 16:26:35 GMT Subject: How do I run an external system command on Windows? References: <8q5d2b$la8$1@nnrp1.deja.com> <8q5efg$b1e$1@panix6.panix.com> <8q63ja$i8h$1@nnrp1.deja.com> Message-ID: <8q842u$sdk$1@nnrp1.deja.com> Does this mean that the "commands" module will work under Python2.0 and Windows? It seems odd commands forces the command to be run as "{ cmd ; } 2>&1". I think it should be been an option, or an additional method that returns a tuple with the stderr in it's own string. Who maintains this? It would be great if this and other Expect-style stuff worked the same under UNIX and NT. Thanks for the info. Maybe I'll go become a beta pig and download 2.0b. Yours, Noah In article , David Bolen wrote: > In general, you can execute a command and retrieve it's output with > the os.popen() function. But prior to 2.0, if you want reliability > under all Windows platforms and environments (console and graphical), > you should use the win32pipe module from the Win32 extensions. So if > you want cross-platform with Python 1.5.2 (or I believe 1.6 as well) > you should probably just check the platform, and select either > os.popen() or win32pipe.popen() based on non-NT or NT. > > The win32pipe functionality has been rolled into the os.popen*() > functions in Python 2.0, so with 2.0 you can just use the os module > and be portable across platform. > > -- > -- David > -- > db3l at fitlinxx.com / Sent via Deja.com http://www.deja.com/ Before you buy. From cut_me_out at hotmail.com Fri Sep 8 16:45:35 2000 From: cut_me_out at hotmail.com (Alex) Date: 08 Sep 2000 16:45:35 -0400 Subject: can you guys tell me where to find a NumPy module that works...? can you help? References: <8pa4a2$224u$1@newssvr05-en0.news.prodigy.com> Message-ID: > and before anyone asks I've tried building with 2.0b1 and it bombs > horribly on > > Include\arrayobject.h(16) : error C2061: syntax error : identifier > 'Py_FPROTO' I had that problem, actually. I didn't realize it was because I was building against python2. I fixed it by adding the macros #define Py_FPROTO(args) args #define Py_PROTO(args) args ...but that's on linux. Alex. -- Talk softly and carry a big carrot. From lsherrill at uswest.net Wed Sep 13 23:56:47 2000 From: lsherrill at uswest.net (Larry Sherrill) Date: Wed, 13 Sep 2000 21:56:47 -0600 Subject: Is Python worth learning? References: <1YCs5.31979$K5.513760@typhoon.austin.rr.com> <39B9A262.A0165650@uswest.net> <39BE5700.BE446359@earthlink.net> Message-ID: <39C04C7F.CADC7719@uswest.net> JPython, when used to add scripting capability to a java application, is a jar file that acts like any other set of java classes. It lives in the world of the JVM, and is class loaded like any other java bytes codes. It just happens that these classes implement an interpreter. As far as speed is concerned, I haven't measured the computational cost of interpretation, but we are simply using it for building short ad hoc queries (in human time) that we would not otherwise be able to build. The one thing is has done is to reduce the amount of time we need to spend debugging problems because now we can examine the state of our runtime system whenever we like without taking the system down in order to sprinkle System.out.printlns all over the place. Larry Sherrill SynXis Charles Hixson wrote: > Larry Sherrill wrote: > > > I just added python scripting support to my company's java application via jpython. > > We can now perform ad hoc queries against our gemstone database using python script > > that exercises the underlying java classes. I also use jpython to prototype java > > code and to experiment with java classes on an interpreted basis. The two languages > > together are very powerful. IMO, learn both. > > > > Larry Sherrill > > SynXis > > > > ... > > What's the speed of jPython? I've heard the speed of Java slammed so often that the > idea of a second layer of interpretation has always scared me off. But an earlier post > sounded like jPython went directly to the JVM, so ... That might be a reasonable way to > go after all. > > -- (c) Charles Hixson > -- Addition of advertisements or hyperlinks to products specifically prohibited From sholden at holdenweb.com Thu Sep 14 16:22:16 2000 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 14 Sep 2000 16:22:16 -0400 Subject: One last shot at the Augmented Assignment PEP References: <20000913160209.D52541CF42@dinsdale.python.org> <39BFC44E.FD6CB79C@rsv.ricoh.com> <8pous80tul@news1.newsguy.com> Message-ID: <39C13378.4FEE433@holdenweb.com> Grant Edwards wrote: > > In article <8pous80tul at news1.newsguy.com>, Alex Martelli wrote: > > >Without the polymorphism over mutable objects wrt immutable > >ones, += and its ilk would be mere syntactic sugar of no big > >real interest. WITH the polymorphism, they become a precious > >innovation. Call them "mutation-suggestors with fallback to > >rebinding if the object is immutable", if you wish, because > >that is what they are. > Well actually, Alex, there's more than syntactic sugar in what we might call a simple assignment. I'd be prepared to have the "lvalue" (as we might call it) evaluated only once, allowing optimization of expressions like: something.incredibly[unbelievably](complex) = \ something.incredibly[unbelievably](complex) + 1 to something.incredibly[unbelievably](complex) += 1 even if side-effects were not duplicated. I'm just not sure whether this strengthens my case or weakens it :-( and I *know* this isn't going to make any difference to the forthcoming implementations. > This leads into the an new field: > > programming via suggestions and hints > > I suppose if you really want assignment you can do it > explicitly with the old syntax. If you know that you really > want mutation, you can use the method call to make it explicit. > That way you get the proper error if you try to mutate an > immutable object. > > -- > Grant Edwards grante Yow! My FAVORITE group > at is "QUESTION MARK & THE > visi.com MYSTERIANS"... Well, doing it explicitly with the old syntax is going to be my solution of choice. But then I've already confessed to being a bear of very little brain. I just hope the documentation makes it quite clear, both to newbies and C/C++ programmers, that the semantics of the new augmented assignment operators are not equivalent to the "old syntax". regards Steve -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ From dcalvelo at pharion.univ-lille2.fr Wed Sep 6 05:45:16 2000 From: dcalvelo at pharion.univ-lille2.fr (Calvelo Daniel) Date: 6 Sep 2000 09:45:16 GMT Subject: JPython install question References: Message-ID: <8p53nc$be5$2@netserv.univ-lille1.fr> Huaiyu Zhu wrote: : After getting JPython11.class and running java on it, is there any other : step needed for the installation? The installed directories only have .java : but not .class files, and when I run make in it, make complains about jikes : not found. There is no README, and I seem to have lost my way in the online : instructions of install. Thanks for any clarification. (This is on Linux, : but I'll also need it on NT, Solaris, HP-UX later on.) AFAIremember there's no need of make; the installer (you got that one, didn't you) puts a JPython.jar into the directory you specify. Then you have the usual CLASSPATH java nightmare, but that's all. This is on Linux. HTH, DCA -- Daniel Calvelo Aros calvelo at lifl.fr From tim_one at email.msn.com Mon Sep 18 00:38:40 2000 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 18 Sep 2000 00:38:40 -0400 Subject: RE bug in Python 2.0b1 In-Reply-To: <39C19942.B7A87338@sympatico.ca> Message-ID: [vio] > I believe there may be a RE bug in 2.0b1. Consider the following script: > > #!/usr/bin/env python > import re > s = "red green blue" > m = re.compile(r'green (\w+)', re.IGNORECASE) > t = re.subn(m, r'matchedword \1 blah', s) > print t > > > When I run this on 1.5.2, I get the following expected output: > > ('red matchedword blue blah', 1) > > > If I run it on 2.0b1, python basically hangs. Believe it or not, the thing parsing the replacement string is hung in an infinite loop trying to get beyond the \1 (!). Greg Ward just reported a similar bug on SourceForge (bugs will get noticed much faster if you enter them there yourself, btw), and a fix will be checked in shortly. Here's with a fixed version: C:\Code\python\dist\src\PCbuild>python Python 2.0b1 (#5, Sep 17 2000, 10:24:34) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> import re >>> s = "red green blue" >>> m = re.compile(r'green (\w+)', re.IGNORECASE) >>> t = re.subn(m, r'matchedword \1 blah', s) >>> print t ('red matchedword blue blah', 1) >>> From aleaxit at yahoo.com Fri Sep 8 05:35:31 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 8 Sep 2000 11:35:31 +0200 Subject: Python 2.0b1 is released! References: <39B76977.31E0920@users.ch> Message-ID: <8pac4k01grj@news2.newsguy.com> "Bernhard Herzog" wrote in message news:m3hf7s3xvy.fsf at greebo.nodomain.de... > Dennis Lee Bieber writes: > > > On Thu, 07 Sep 2000 12:09:59 +0200, Bristol declaimed > > the following in comp.lang.python: > > > > > > > > That's going too fast; first you need to call it by the name of a venomous > > > snake... > > > > > I think "Asp" is already taken... > > > > Uh, and "Fer-de-lance" would choke command line parsers... > > Well, "Adder" would keep with the tradition of referring to comedy TV > programs and it would even be related to computing. ***Yes***! Specifically, "the second word of names of wonderful British TV comedy series, that also happens to name a kind of snake". (Uh, I guess there must not be many left after these, must there?) I guess "Black Adder" didn't get as much international exposure as "Monty Python" (I myself found out about it only after liking "Mr Bean" so much that I started looking for anything Rowan Atkinson had ever done...:-). Alex From badman718 at yahoo.com Mon Sep 11 17:56:44 2000 From: badman718 at yahoo.com (Sergo) Date: Mon, 11 Sep 2000 17:56:44 -0400 Subject: Python 2.0 book Message-ID: I recently became interested in learning Python and just ordered "Learning Python", "Python Pocket Reference" - O'Reilly, and "Python Essential Reference" - New Riders. Now I've learned that with Python 2.0 release, a lot of changes are going to be made to the language. So I'm wandering, should I return those books and wait for something more up to date and just stick to online tutorials and references, or are they still relevant to the 2.0 release? I also read that with the future 3.0 release, its going to change so much that it will basicaly be a new language (true or not?). So I am confused about the books. -- ---------------------------------------------------------------- "...Righteousness exalted the nations The righteouness cannot be forgotten and the glory cannot be blocken out..." From neelk at brick.cswv.com Sun Sep 3 09:52:53 2000 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 3 Sep 2000 13:52:53 GMT Subject: Python 1.6 The balanced language References: <39AB712E.805ACB4B@nowonder.de> Message-ID: Suchandra Thapa wrote: > Neel Krishnaswami wrote: > >Suchandra Thapa wrote: > >> > >> Actually I think clean is a pure functional oo language. It's just > >> that being oo seems to imply that you have some state to your > >> objects. Not sure anyone would get around this paradox. > > > >No, the distinguishing features of OO are that a) subtyping exists, > >and b) the types of objects are used to do dynamic dispatch. Mutable > >state is not necessary -- in both Dylan and Ocaml, it's common to > >write code in an "object-functional" style, with lots of objects but > >no mutation. > > I forgot about the existence of OCaml when I was writing the post > but ML has imperative features and so is not a pure functional language. I usually think of any of the ML/Scheme clan as functional languages, and specify "pure" when I want to limit myself to Clean or Haskell. > The example you gave just illustrated dispatch on types. Specifically it illustrated dispatch on based on *subtypes*; that is it looked at the /runtime/ type of the object to decide which method body to call. So in a typed Python, take the function def squarelen(lst: List) -> Integer: return len(lst) * len(lst) If you pass squarelen() a SizedList, then it will call the SizedList.__len__ method, not the List.__len__ method. > The compiler has no problem determining which to use at compile > time. I don't see what requires leaving the choice of len until > runtime. We don't know the precise runtime type of the object. In the squarelen example, all you can tell about the parameter lst is that it is a List, or an instance of one of its subtypes, like SizedList. > Incidentally, what do you mean by dynamic dispatch? ML and its > dialect OCaml are statically typed and the compiler chooses which > function to call at compile time. Would you consider OCaml to be OO > then? The OO extension to Ocaml makes sure that a method exists for every message send, but it doesn't determine which method to call at compile time. So no "message not understood" errors can happen, but the specific method body is chosen based on the runtime type. This is what I mean by dynamic dispatch. It's a form of overloading constrained by the type. > But getting back to OO, I'm not sure how the essentials of OO that > you put forward mesh with a pure functional approach. In other > words suppose I had a method bar belonging to class foo. How would > I distinguish using foo.bar from using another function baz that > took the same parameters and returned the same results? I'm don't I understand this question. > It's possible to create such a baz by cutting and pasting the > function body from bar. I don't see what using objects gain in this > context aside from some syntactic sugar. Also what would the use be > in declaring two objects of the same class? They wouldn't behave > any differently. Objects with different internal values would behave differently. It's just that instead of modifying an object we create new ones. Eg, imagine that every Python object were immutable, like integers and strings. Neel From edcjones at erols.com Fri Sep 8 19:19:00 2000 From: edcjones at erols.com (Edward C. Jones) Date: Fri, 08 Sep 2000 19:19:00 -0400 Subject: idiom for initial list of lists References: Message-ID: <39B973E4.FABAFADB@erols.com> Robin Becker wrote: > What's the correct way to initialise a list of lists I find that the > natural [[]]*n doesn't work eg > >>> S=[[]]*5 > >>> S > [[], [], [], [], []] > >>> S[0].append(1) > >>> S > [[1], [1], [1], [1], [1]] > > so I'm forced to use the rather pedantic > S=[] > for i in range(n): S[i].append([]) > -- > Robin Becker Most languages have dark corners where it is better to neither look nor go. The initialization of nested lists is a dark corner of Python which is unfortunately high visible and heavily travelled. I have written something about this at: http://members.tripod.com/~edcjones/pycode.html . From scarblac-spamtrap at pino.selwerd.nl Thu Sep 7 04:31:23 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 7 Sep 2000 08:31:23 GMT Subject: Python 2.0b1 is released! References: Message-ID: Remco Gerlich wrote in comp.lang.python: > Grant Edwards wrote in comp.lang.python: > > >There is something *you* can do, though: tell CNRI how important Python's > > >GPL-compatibility is to you, > > > > I'm trying to figure out how GPL compatibility (or lack thereof) affects the > > user. > > For instance, I'm linking Python 2 with the readline lib now (which is GPL). > That's standard on Linux. > > If the two aren't compatible, I don't have a license to use the resulting > binary. Since I have combined incompatible licenses, I don't have a license > to the software at all. I was wrong here. *Using* the program is unrestricted, no problem. But I can't give the binary to a friend, since that is distribution, and it would be under both licenses, which the FSF believes to be incompatible. -- Remco Gerlich, scarblac at pino.selwerd.nl This is no way to be Man ought to be free -- Ted Bundy That man should be me From effbot at telia.com Sun Sep 24 08:09:13 2000 From: effbot at telia.com (Fredrik Lundh) Date: Sun, 24 Sep 2000 12:09:13 GMT Subject: Compiling Python 1.6 under MacOS X ... References: Message-ID: tim wrote: > So, like I said, I have no idea what the new problem may be with OSX. > For every pair of distinct files X and Y in the distribution, if X and Y are > in the same directory, the names of X and Y differ by more than just > case. not *after* you've built the distribution: $ more Modules/Makefile.pre.in ... # This target is used by the master Makefile to link the final binary. link: $(MAINOBJ) $(LINKCC) $(LDFLAGS) $(LINKFORSHARED) $(MAINOBJ) \ $(LDLIBRARY) $(MODLIBS) $(LIBS) $(SYSLIBS) -o python$(EXE) $(LDLAST) mv python$(EXE) ../python$(EXE) ... note the last line -- after the interpreter has been built, it's moved from Modules to Modules/../python. If EXE isn't set, and you're on a case-insensitive system, the interpreter will end up in the Python directory... From absolutniks at hotmail.com Fri Sep 22 17:28:17 2000 From: absolutniks at hotmail.com (MCM) Date: Fri, 22 Sep 2000 23:28:17 +0200 Subject: clueless newbie question Message-ID: <8qgj53$1dtt$1@buty.wanadoo.nl> Hi, I'm trying to figure out how to do recursion in a threaded discussion list I'm writing in python, where every message has an id as follows "1_3_3_1". The first number is the absolute parent, then the subparent (sorry, lack of formal training prevents me from explaining it properly. hope this is clear enough). I would like to construct a html page that shows all these threads in a nice and orderly fashion, but don't know how to go about setting up the recursion you would get by pulling out subthreads, then parent threads, etc. Does anyone have some general pointers as to how to go about doing this? Thanks, Matthijs -- put your speakers to the test: http://listen.to/statiksounds/ From kirschh at lionbioscience.com Tue Sep 19 03:11:04 2000 From: kirschh at lionbioscience.com (Harald Kirsch) Date: 19 Sep 2000 09:11:04 +0200 Subject: Test Coverage Analysis for Python scripts References: <8q5dpq$mbc$1@nnrp1.deja.com> Message-ID: Dan Gindikin writes: > In article , > Harald Kirsch wrote: > > > > Where is it? > > http://www.musi-cal.com/~skip/python/trace.py > Thanks, but Traceback (innermost last): File "./trace.py", line 661, in ? main() File "./trace.py", line 642, in main create_results_log(results, logdir, missing) File "./trace.py", line 316, in create_results_log if filename.startswith(tfdir): AttributeError: 'string' object has no attribute 'startswith' with lionsp093:tmp) python 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 What is missing? Harald Kirsch -- ----------------+------------------------------------------------------ Harald Kirsch | kirschh at lionbioscience.com | We make the tools to LION Bioscience | +49 6221 4038 172 | reverse engineer nature. From a.lempereur Sun Sep 17 13:34:27 2000 From: a.lempereur (Brett Lempereur) Date: Sun, 17 Sep 2000 17:34:27 GMT Subject: newbie class troubles References: <8q2op2$gj1$1@panix2.panix.com> Message-ID: I've made an instance of the class, had done before, but sadly nothing works :o( thanks anyway From tim_one at email.msn.com Mon Sep 25 21:50:44 2000 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 25 Sep 2000 21:50:44 -0400 Subject: Too late to propose modules for inclusion in 2.0? In-Reply-To: <39cffa73.25983607@news.telus.net> Message-ID: [Hamish Lawson] > Is it too late to propose the inclusion of established third-party > modules in Python 2.0's standard library? [Jeremy Hylton] > It is too late. We will release 2.0 beta 2 tomorrow. The only changes > made between 2.0b2 and 2.0 final will be bug fixes. [David] > Bloody hell! That means you're not going to release a usefully functional > XML library. > > Grrrr. > > I've been trying since late spring to start using XML in Python. I had > something going with 1.5.2, but was stupid enough to think it was a good > idea to move toward 2.0, 'cause, hey, it advertises that XML batteries are > included. > > I'm getting so frustrated. *Too* frustrated, I'd say. I can't find anything specific to comment on there! I do know that the XML-SIG people have been making checkins at a furious pace for 2.0b2, but I can't get a hint from the above whether you've even tried the CVS version. If you have and still hate it, bring it up in the XML-SIG. This is their job. While I can't say for certain, it's a plausible bet that they may even embrace an offer of help more than virtual frothing at the virtual mouth . if-we-waited-for-everybody's-special-feature-we'd-never-release-ly y'rs - tim From skip at mojam.com Mon Sep 11 12:23:54 2000 From: skip at mojam.com (Skip Montanaro) Date: Mon, 11 Sep 2000 11:23:54 -0500 (CDT) Subject: Alternative to strptime()? In-Reply-To: References: <8pi7mg$v42$1@dahlia.singnet.com.sg> Message-ID: <14781.1818.450384.154304@beluga.mojam.com> >>>>> "Dan" == Dan Schmidt writes: Mio> ... we'd like to convert a date-formatted string into a Tuple Mio> ... but strptime() appears to be not working in Win32. Dan> I bet rfc822.parsedate_tz() will do the job for you. You might also want to check out Marc-Andre Lemburg's mxDateTime package. It can parse a lot of date/time formats. You can find it at http://starship.python.net/crew/lemburg -- Skip Montanaro (skip at mojam.com) http://www.mojam.com/ http://www.musi-cal.com/ From Marcin.Kasperski at softax.com.pl Wed Sep 6 10:15:19 2000 From: Marcin.Kasperski at softax.com.pl (Marcin Kasperski) Date: Wed, 06 Sep 2000 16:15:19 +0200 Subject: Python 2.0b1 is released! References: <200009060449.XAA02145@cj20424-a.reston1.va.home.com> <39B645EF.3EBD336C@ses.curtin.edu.au> Message-ID: <39B65177.9308DC61@softax.com.pl> Nick Bower wrote: > > Guido van Rossum wrote: > > > A unique event in all the history of Python: two releases on the same > > day! (At least in my timezone. :-) > > > > umm... could someone tell me why python 2.0 is not called python 1.61 > (going by the relase schedule and amount of changes). Is there *really* > that much difference between python 2.0 and 1.6 that a major version > change was required? > Somewhere on python.org (FAQ for 2.0?) I found the explanation: different managers consider 1.x product to be not mature, adding a bit to version number causes them to believe it is well founded and ready for serious business applications. >From my experience it seems, this opinion can be true. >From the programmer viewpoint: the whole mess is not very important for me. If naming Python 'Dynamic Python 3000 Ultra' can help in language marketing, I don't care - as far, as there is document which presents version history and summary of difference between versions. -- Serwis dla programist?w, k?cik mieszkaniowy: http://www.mk.w.pl | | Users typically do not know exactly what they want and are unable to | articulate all that they know. (Parnas) | From ndonti at my-deja.com Wed Sep 20 15:22:09 2000 From: ndonti at my-deja.com (ndonti at my-deja.com) Date: Wed, 20 Sep 2000 19:22:09 GMT Subject: JPython status Message-ID: <8qb2o7$cf5$1@nnrp1.deja.com> I was wondering about the status of JPython. There has been nothing on http://www.jpython.org/ since a long time. Sent via Deja.com http://www.deja.com/ Before you buy. From vbmark at my-deja.com Thu Sep 21 16:27:05 2000 From: vbmark at my-deja.com (vbMark) Date: Thu, 21 Sep 2000 20:27:05 GMT Subject: What does this error mean and how do I resolve it? Message-ID: <8qdqtt$lqn$1@nnrp1.deja.com> OS: Win98 Python: 2.0b1 Script and Error: >>> def go(): from opengl import * def redraw(o): gl.ClearColor(0, 0, 1, 0) gl.Clear(GL_COLOR_BUFFER_BIT) o = Opengl(width = 200, height = 200, double = 1) o.redraw = redraw o.pack(side = 'top', expand = 1, fill = 'both') o.mainloop() >>> go() Traceback (innermost last): File "", line 1, in ? go() File "", line 2, in go from opengl import * NameError: Case mismatch for module name opengl (filename c:\python20\Opengl.pyc) FYI: The Python Tk-OpenGL instructions say, "First copy al *.c, *.h files in the src subdirectory to the Modules subdirectory of the Python distribution." As there was no modules subdirctory I'd created one. Thank you, Mark Sent via Deja.com http://www.deja.com/ Before you buy. From ajs at ix.netcom.com Mon Sep 11 07:52:14 2000 From: ajs at ix.netcom.com (Arthur Siegel) Date: Mon, 11 Sep 2000 07:52:14 -0400 Subject: Python 2.0b1 is released! References: Message-ID: <8pii3n$1aj$1@slb1.atl.mindspring.net> Tim Peters wrote in message news:LNBBLJKPBEHFEDALKOLCOEEBHFAA.tim_one at email.msn.com... > [John J. Lee] > > Can somebody explain why CNRI still want to keept the copyright if this is > > the case? > Can't it be safely assumed that there are legalistic reasons for CNRI's position. Their reading of their charter in some way compels them to take the position they have, If this is so what is needed is some way to let them off their own hook. One answer is probably $ or even some barter. They need to close their books on Python by showing a concluding transaction that justifies the "investment" they made. Has an approach any where along these lines been attempted?? From jcm at bigskytel.com Wed Sep 27 19:07:51 2000 From: jcm at bigskytel.com (David Porter) Date: Wed, 27 Sep 2000 17:07:51 -0600 Subject: newbie question: where to find modules In-Reply-To: <8qtona$lc1$1@nnrp1.deja.com>; from cyuan6083@my-deja.com on Wed, Sep 27, 2000 at 09:27:16PM +0000 References: <8qtona$lc1$1@nnrp1.deja.com> Message-ID: <20000927170751.A24751@bigskytel.com> * cyuan6083 at my-deja.com : > I am trying the odbc example that uses dbi, odbc modules. But in my > installation of python I cannot find the two files in anywhere. I also > searched the www.python.org, it doesn't have a link for these > downloads. Can someone tell me where they could be? > P.S., the python I installed is 1.5.2 and it is windows version. Consult the Vaults: http://www.vex.net/parnassus/ From mbel44 at dial.pipex.net Tue Sep 19 10:03:29 2000 From: mbel44 at dial.pipex.net (Toby Dickenson) Date: Tue, 19 Sep 2000 15:03:29 +0100 Subject: intermittant KeyboardInterrupt on Linux References: <9tt3ssc763mvk0ghuj69osd591oilda3n6@4ax.com> Message-ID: Toby Dickenson wrote: >On Linux, my long-running script is intermittantly terminating >prematurely with a KeyboardInterrupt. This never happens on win32 - >any ideas about what could be causing it? A common factor seems to be that this only happens when the script is run using NT's telnet client into the linux system. I guess I have my answer. Toby Dickenson tdickenson at geminidataloggers.com From greg at thing-fish.kharkov.net Mon Sep 25 08:03:31 2000 From: greg at thing-fish.kharkov.net (Gregory Edigarov) Date: 25 Sep 2000 12:03:31 GMT Subject: Help newbie (python) Message-ID: <8qneuj$1t8r$1@uran.kharkiv.net> I am completely new to python, but I want to learn it... I'm just wondering about what sort of problems does it address? Is it similar in scope to perl, but with more C-like syntax? Or it has completely different one? Sending examples of programs is also welcome. -- With best regards, Gregory Edigarov System Administrator of IBM ES/9000 GE1403-RIPE Kharkov State Politechnic University From bjorn at roguewave.com Mon Sep 11 21:00:31 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Mon, 11 Sep 2000 19:00:31 -0600 Subject: MIME attachments and SMTP References: <8pjstm$oqh$1@nnrp1.deja.com> Message-ID: <39BD802F.FBB1192F@roguewave.com> change it to: toaddrs = ['rickr at brickroad.net'] # to: has to be a list # add additional headers to the message and separate from # body with two newlines msg = 'Subject: foobar\n\nblah blah blah blah' hth, -- bjorn rick_at_brickroad at my-deja.com wrote: > > I'm trying to set up a command line utility in > python.. and I've set up the SMTP to specs but > when I send a message doing: > server = smtplib.SMTP('myserver') > server.set_debuglevel(1) > fromaddr = 'rickr at brickroad.net' > toaddrs = 'rickr at brickroad.net' > msg = 'blah blah blah blah' > server.sendmail(fromaddr, toaddrs, msg) > server.quit() > > however, it arrives it arrives with no to: and no > subject. > > I was also wondering if someone could point me to > more information on using mime types to add > attachments. I've gone through the docs.. but > can't find much information on this. > > thanks > > Rick > > Sent via Deja.com http://www.deja.com/ > Before you buy. > -- > http://www.python.org/mailman/listinfo/python-list From effbot at telia.com Sun Sep 10 04:07:26 2000 From: effbot at telia.com (Fredrik Lundh) Date: Sun, 10 Sep 2000 08:07:26 GMT Subject: Win98 2.0b: crash on Help References: <7c7mrs4nau15mf420nfigna8ueo2d9nqii@4ax.com> Message-ID: <2jHu5.54$F5.7541@newsb.telia.net> Kirby Urner wrote: > In 2.0b IDLE 0.6 under Win98, when I select Help | Python Documentation, > I get an amazingly serious crash. A couple blue screens of death > followed by a switch into some undefined video mode. Have to reboot. > This is on an AMD K2 400, 128RAM, Voodoo3 graphics. from the 2.0 download page (in ludicrously small print at the bottom of the page): Incompatibility warning: Norton Antivirus 2000 can cause blue screen crashes on Windows 98 when a function in the os.popen*() family is invoked. To prevent this problem, disable Norton Antivirus when using Python. (Confirmed on Windows 98 Second Edition with Norton Antivirus version 6.10.20. The same Norton Antivirus version doesn't have this problem on Windows 2000. Norton Antivirus version 5 on Windows 98SE doesn't have this problem either.) From vbmark at my-deja.com Thu Sep 21 13:10:01 2000 From: vbmark at my-deja.com (vbMark) Date: Thu, 21 Sep 2000 17:10:01 GMT Subject: Is this true regarding Python's limitation? Message-ID: <8qdfcn$71b$1@nnrp1.deja.com> Someone told me that the reason Java is better than Python for server- side CGI is because where Java uses one process and creates threads for each user's access, Python creates sperate processes for each user's CGI access. So using Python would greatly limit and perhaps crash a server. Is this true? Thanks. Sent via Deja.com http://www.deja.com/ Before you buy. From IAMsvore at mindspring.com Mon Sep 25 17:25:35 2000 From: IAMsvore at mindspring.com (Steven) Date: Mon, 25 Sep 2000 17:25:35 -0400 Subject: XML Processing With Python, reviewlet Message-ID: <8qofh4$8vf$1@slb6.atl.mindspring.net> For those who may be interested... Part 2 of "XML Processing With Python, my notes" ( http://www.themestream.com/gspd_browse/browse/view_article.gsp?c_id=165854 ) has been posted [ "In part 1, I asked "Has it been worthwhile so far?" My answer remains the same - Definitely. I can heartily recommend this book for someone who is just learning Python and the exciting world of XML" ] -- -Steven http://Mumble.EditThisPage.com From hakan at netg.se Thu Sep 28 06:29:31 2000 From: hakan at netg.se (Hakan Nilsson) Date: Thu, 28 Sep 2000 12:29:31 +0200 (CEST) Subject: in-module global variables In-Reply-To: <003c01c02934$94ca54a0$0b0101c4@neeve> Message-ID: Just use the 'global' keyword, adding the line global myglobalvar to your function, before you use the variable. /Hakan On Thu, 28 Sep 2000, Matthew Banham wrote: > Dear python users, > > When writing a python module, how do I correctly declare a global variable- > i.e. a variable that has scope throughout the whole of the module? > > For example, if I have a module called mymod.py with the following in it:- > > myglobalvar = 10 > > def myfunc(somparm): > #here there are some commands > print myglobalvar > > when I call myfunc from within the module, myglobalvar is not recognised > giving the "Unbound Local Error" > > Can anyone help? > > Yours Sincerely, > Matthew Banham > > ---------------------------------------------------------------------------- > ---- > Matthew Banham, MSci > Development Engineer & Technical Support Officer > > Photon Design Tel: +44 1865 395480 > 68 Church Way Fax: +44 1865 395481 > Iffley, Oxford Email: matb at photond.com > OX4 4EF Web: www.photond.com > > - Hi! I'm a .signature virus! Copy me into your .signature file to help me spread! From bertilow at hem.passagen.se Thu Sep 7 05:22:32 2000 From: bertilow at hem.passagen.se (Bertilo Wennergren) Date: Thu, 7 Sep 2000 11:22:32 +0200 Subject: editing in Unicode Message-ID: <8p7mli$ccglp$1@ID-4825.news.cis.dfn.de> Unicode text strings are supposed to be written thus: unistr = u'\u0660\u2000ab ...' That's a bit inconvenient if a lot of text strings use mostly characters that have to be represented as "\uxxxx". What if I want to edit my Python code directly in a Unicode text editor that can display all characters I want to use, and that can save the code in utf-8 or utf-16? How do I write my text strings so the compiler gets it right? I'm a complete beginner at Python, but I always check out the possibilities and limits of Unicode first when I start learning something like this. I have read the docs, but they're not all that clear on this. -- ##################################################################### Bertilo Wennergren ##################################################################### From rturpin at my-deja.com Sat Sep 30 13:12:13 2000 From: rturpin at my-deja.com (rturpin at my-deja.com) Date: Sat, 30 Sep 2000 17:12:13 GMT Subject: How many people are making COM objects with Python? Message-ID: <8r56ta$3mj$1@nnrp1.deja.com> Any "gotchas"? Any places on the Web where someone describes real applications made this way? Mark Hammond's slides are nice, but they make this seem more an experiment than something actually used for production purposes. Thanks! Russell Sent via Deja.com http://www.deja.com/ Before you buy. From don_enrique at my-deja.com Wed Sep 20 16:02:53 2000 From: don_enrique at my-deja.com (don_enrique at my-deja.com) Date: Wed, 20 Sep 2000 20:02:53 GMT Subject: Can Python can use Perl modules? References: <8q83g7$rl2$1@nnrp1.deja.com> Message-ID: <8qb54t$fhf$1@nnrp1.deja.com> well.. I guess this is no way to use a perl module with in python. I really not what to edit the module for python. In article <8q83g7$rl2$1 at nnrp1.deja.com>, don_enrique at my-deja.com wrote: > Hey all! > > Is there a way to use a perl module in python script? > > I am working with a new company that use lots of perl scripts. They made > one big perl module that does scsi communication with the device I would > be working on. I know perl but I can write scripts faster and easier > with python. > > Please let me know. > > Enrique > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From bhellao at my-deja.com Tue Sep 26 10:22:56 2000 From: bhellao at my-deja.com (Opinderjit) Date: Tue, 26 Sep 2000 14:22:56 GMT Subject: Using the re module (Regular expressions) References: Message-ID: <8qqbf7$kqq$1@nnrp1.deja.com> What you have should work, except the change the '^' into a '\n'. Also, I would add the '?' to <.*>, to make it non-greedy. But, you don't have to. >> line = 'Returned-Path: \nRecieved:' >> s = re.search(r'Return-Path:\s<.*?>\nRecieved:') >> s.group() >> 'Returned-Path: \012Received:' In article , morten at esol.no (Morten W. Petersen) wrote: > I want to match a string, 'Returned-Path: > Why doesn't re.compile(r'Return-Path:\s<.*>^Recieved:',re.MULTILINE) return a search object that'll match that line? > > Thanks in advance. > > -Morten > Sent via Deja.com http://www.deja.com/ Before you buy. From cbbrowne at news.hex.net Sat Sep 23 00:46:15 2000 From: cbbrowne at news.hex.net (Christopher Browne) Date: Sat, 23 Sep 2000 04:46:15 GMT Subject: for loop possible enhancement References: <39CB9A90.E269CDF9@uniserve.com> Message-ID: In our last episode (Fri, 22 Sep 2000 18:00:48 GMT), the artist formerly known as Fredrik Lundh said: >bob wrote: >> However, what would be more useful at times is the >> possiblity to: >> >> for a,b in [[1,2,3,4], [a,b,c,d]]: >> >> which, intutively(?) would set a to the value 1 and b to 'a', etc. > > http://python.sourceforge.net/peps/pep-0201.html > > "Standard for-loops in Python iterate over every element in a > sequence until the sequence is exhausted. However, for-loops > iterate over only a single sequence, and it is often desirable to > loop over more than one sequence in a lock-step fashion" > > Ah. You're looking for the Common Lisp "LOOP" facility. It can have an arbitrary set of simultaneous sequences that are "lock-stepped." -- (concatenate 'string "aa454" "@" "freenet.carleton.ca") Your latest program has been judged UNTASTEFUL by the T daemon; and automatically deleted. From sdm7g at virginia.edu Sat Sep 23 18:45:41 2000 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Sat, 23 Sep 2000 18:45:41 -0400 (EDT) Subject: Python in Sept. Nuts & Volts In-Reply-To: Message-ID: On Sat, 23 Sep 2000, Kragen Sitaker wrote: > In article <6eboss8fd0qbjub02vt11soog0gm5bjvba at 4ax.com>, > Tim Roberts wrote: > >"Steven D. Majewski" wrote: > >>This months Nuts & Volts magazine has an article by Tim Deagan > >>( actually part 2 -- I missed last month ) on writing a > >>PIC 16C84 disassembler in Python. > >> > >>( Now: anyone have any ideas on how to get Python onto a PIC? ;-) > > > >For those who don't get the joke, allow me point out that the typical PIC > >processor has 8k bytes of ROM and 192 bytes of RAM. Yep, that's 192, > >without any of them there fancy suffixes, like M or K. > > That doesn't make it impossible to run programs in a high-level > language like Python on it, although it might make other languages > (like FORTH) a better choice. It does mean that you need a compiler > that's pretty good at optimizing and really good at throwing away > things you don't need. > One trick I've seen done is to put the core VM in ROM, and to read the byte code stream from an I/O port attached to external memory. I think that would be such major surgery to the codebase that it might be better to start fresh designing a python-like language better suited for tiny-footprint devices. After all, it's not like you're going to get the whole standard library in there and have much compatability with code from Windows, Unix, Mac... ---| 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 g2 at seebelow.org Mon Sep 18 16:25:16 2000 From: g2 at seebelow.org (Grant Griffin) Date: Mon, 18 Sep 2000 21:25:16 +0100 Subject: What is Python? References: <8pqhm9$6a9$1@panix3.panix.com> <3BBC75F01B2A2291.3CC54B93C0C69DED.4E021EA85330C94C@lp.airnews.net> <8pt65c$cbs$2@newshost.accu.uu.nl> <39C29336.71ED41AC@seebelow.org> <39C3E664.BCEAF741@seebelow.org> Message-ID: <39C67A2C.2313778A@seebelow.org> Tim Hammerquist wrote: > > Grant Griffin wrote: > > p.s. In case you haven't noticed, this "ly y'rs" schtick is an yet > > another good reason to switch. > > Actually, I find myself preferring constant flames to all this "ly y'rs" > and "" stuff. Maybe I'm just not in the spirit. Seriously, these things all go together. The constant flames of the c.l.p.m.--specifically the hostility toward newbies--go hand-in-hand with the hostility to new users of the language itself. I'm sure Larry Wall is a nice guy, but his language is pretty mean: it has more "$@#!$!" curse words than a "Beetle Bailey" comic strip on one of Sarge's bad days. > I'm just not getting all this. I have no intention of quitting Perl. I > enjoy Perl. I enjoy Python. This isn't a matter of religion, when you > can be Mormon when you want multiple wives, but Catholic when you want > some coffee. Languages are tools. Perl is a brilliant tool. Python is > a brilliant tool. Each have their strengths. My own point of view is not drawn from religion (wherein any faith which isn't one's own is, _ipso facto_, "unholy"), but from pure pragmatism. I literally find it faster, easier, and funner to do _every_ bit of my scripting-language programming in Python than Perl. The basic idea is that since one spends generally spends more time debugging code than writing it, then readability is more important than terseness. (And let's face it: at the current rates, the extra disk space needed to store readable code is well worth it. ) Of course, I don't expect that eveyone will share this sensibility; if Perl makes sense to _you_, more power to 'ya. But I did it off-and-on for three years, and my fingers did a lot of walking through the camel--they probably walked a mile for it. But my own theory is that Perlers actually revel in the nonsensicalness of their language, much as a tight-rope walker proudly calls attention to his lack of a net. <> It's an ego thing. That explains the one-liners and the "just another perl hacker" thing. By the way, here's my own personal Python JAPH implementation: print "just another perl hacker" However, back to your point. I _do_ still use Perl a little. For one thing, I've developed a set of little Perl scripts over the years which I use for various things. (I've rewritten some of these in Python, but most remain in Perl.) Also, the search engine for the dspGuru web site is written in Perl. (It's the "Perlfect" search: it's free, and works great. I just wish it were written in Python so I could customize it without having to pay the Perlfect folks. <0.25 wink>) But in terms of your point about "the best tool for the job", one _does_ have to admit in all fairness that there's at least _one_ thing that Perl is an order-of-magnitude better at than Python: execute Perl scripts. > As a matter of interest, anyone want to convert the following code to > Python? > > perl -npe 'next unless /\bjudea/i && /\bfront\b/i' /scripts/movies/brian/* Only if you'll tell us what it does. But I guess if the mettle of a scripting language is to be judged by its one-linerability, I should confess that Python is a dismal failure: if you put together its use of indents for blocks, with the fact that none but its most elemental functions are built-in...well...it's hardly useful at all. In fact, here's about the only Python one-liner I can think of: print "Hello, World!" show-me-a-language-that's-great-for-one-liners-and-i'll-show-you -a-language-that-doesn't-scale-well--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 gerryq at indigo.ie Sat Sep 2 06:46:05 2000 From: gerryq at indigo.ie (Gerry Quinn) Date: Sat, 02 Sep 2000 10:46:05 GMT Subject: Python in game development? References: Message-ID: In article , kragen at dnaco.net (Kragen Sitaker) wrote: >In article , >>Good points. (Though incremental compilation means that it only takes a >>few seconds to change these things even with a compiler.) > >If you have incremental compilation, it should be a few milliseconds. >Unfortunately, I don't have Python or C environments that support >incremental compilation. > Well, whatever MSVC does isn't bad, though it takes longer than that. Gerry Quinn -- http://bindweed.com Puzzle / Strategy Games and Kaleidoscope for Windows Download evaluation versions free, no time limits New: Unique 2-player strategy game "Zen" From timwkelly at my-deja.com Thu Sep 28 11:13:16 2000 From: timwkelly at my-deja.com (timwkelly at my-deja.com) Date: Thu, 28 Sep 2000 15:13:16 GMT Subject: Python on VMS Message-ID: <8qvn64$5gi$1@nnrp1.deja.com> Been trying to build Python on VMS. Used the Port for version 1.5.2. I keep getting access violations in PTHREAD$RTL. I have a version of GCC that runs on the ALPHA and tried to rebuild but get errors when compiling. If anyone has the binaries for AXP/OpenVMS V7.2-1 I would appreciated receiving them. Thank you Sent via Deja.com http://www.deja.com/ Before you buy. From kirschh at lionbioscience.com Wed Sep 20 11:16:35 2000 From: kirschh at lionbioscience.com (Harald Kirsch) Date: 20 Sep 2000 17:16:35 +0200 Subject: #! independent of location of python binary Message-ID: In Tcl I write #!/bin/sh # \ exec tclsh "$0" ${1+"$@"} and the tclsh will be found along the path. How can I do this in python. I tried #!/bin/sh exec python $@ -c "`tail +3 $0`" but this is of course suboptimal because sys.argv[0] becomes `-c'. The next one was: #!/bin/sh exec python $@ -c "import sys;sys.argv[0]='$0';`tail +3 $0`" but things start to become really messy here. In addition, it does not preserve semantics because it forces the import of sys. Harald Kirsch -- ----------------+------------------------------------------------------ Harald Kirsch | kirschh at lionbioscience.com | We make the tools to LION Bioscience | +49 6221 4038 172 | reverse engineer nature. *** Please: Never Ever Mail Me Copies Of Your Posts *** From serve at circe.dem.nl Mon Sep 25 09:08:28 2000 From: serve at circe.dem.nl (slaurijssen) Date: Mon, 25 Sep 2000 15:08:28 +0200 Subject: Python in game development? References: <39B65BB5.42AF624D@sage.att.com> <39BD7E01.F737C0B7@earthlink.net> <39ca116c_2@newsflash.abo.fi> <39CACA64.99C96C3F@pehr.net> <969624582.27480.0.pluto.d4ee0942@news.demon.nl> <8qn6jg$h04$1@newshost.accu.uu.nl> Message-ID: <969894638.27505.0.pluto.d4ee0942@news.demon.nl> Thanks, I think I'll have a go. Especially because the interpreter is free (at least for linux) and everybody says you can mix in C++-code very easily (is that true?), so my older libraries can keep onliving > Python the language is one of the easiest languages I've learned yet. > The library takes more time, but you can take that one step at the > time, and the Python library reference is good. > From rbill at digisprings.com Sun Sep 10 16:54:03 2000 From: rbill at digisprings.com (Robert W. Bill) Date: Sun, 10 Sep 2000 14:54:03 -0600 Subject: compiling SimpleEmbedded.java (JPython1.1) In-Reply-To: <39BBEA66.DD802EB8@zg.hinet.hr> References: <39BBEA66.DD802EB8@zg.hinet.hr> Message-ID: On Sun, 10 Sep 2000, Marko Kasovic wrote: > hi. > i'm trying to compile it (located in demo/embed folder) > and all i get are messages that it can't find required packages: > > org.python.util.PythonInterpreter > org.python.core.* > > i thought that after succesful installation of jpython this should work > fine. > if someone knows the solution, please help. The CLASSPATH needs to include jpython.jar. This jar file includes org.python.core.* and org.python.util.PythonInterpreter. A quick fix is: javac -classpath /path/to/jpython.jar SimpleEmbedded.java From aahz at panix.com Thu Sep 21 11:28:39 2000 From: aahz at panix.com (Aahz Maruch) Date: 21 Sep 2000 08:28:39 -0700 Subject: 1.6, tutorial, and floating point (was Re: varibles) References: <8qbtke$qrp$1@panix6.panix.com> Message-ID: <8qd9f7$lug$1@panix2.panix.com> [posted with cc to webmaster at pythonlabs.com] In article , Guido van Rossum wrote: >aahz at panix.com (Aahz Maruch) writes: >> >> [posted with cc to python-docs; not sure who is responsible for the >> tutorial these day.] > >You have no excuse for not knowing: the front page says Fred Drake, >editor. And it also shows python-docs at python.org as the email address: > >2.0: http://www.pythonlabs.com/tech/python2.0/doc/tut/tut.html >1.6: http://pythonlabs.com/pub/www.python.org/doc/1.6/tut/tut.html Okay, I went digging through pythonlabs.com, and while it's possible to get there, it's a lot more difficult than it is on python.org. There really ought to be a documentation link on the front page that points to the current set of docs. Nevertheless, the current docs are in fact up on python.org, and I humbly abase myself for my laziness in not checking. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Member of the Groucho Marx Fan Club --Aahz From kuncej at mail.conservation.state.mo.us Tue Sep 19 10:51:28 2000 From: kuncej at mail.conservation.state.mo.us (Jeff Kunce) Date: Tue, 19 Sep 2000 09:51:28 -0500 Subject: Problem with CGI termination References: <00b401c02225$0b0846c0$020000c3@inxbom5> <39C75CED.DC77A742@zxa.basf-ag.de> Message-ID: > It is because of the buffered output of your print statement. > Use sys.stdout.flush() to force the output to the client and the > page will immediately appear. Also, python can be launched with the -u command line option, which sets unbuffered binary output to stdout and stderr. This is often useful with CGI. --Jeff From ssthapa at harper.uchicago.edu Sat Sep 2 15:18:00 2000 From: ssthapa at harper.uchicago.edu (Suchandra Thapa) Date: Sat, 02 Sep 2000 19:18:00 GMT Subject: Python 1.6 The balanced language References: <39AB712E.805ACB4B@nowonder.de> Message-ID: Tim Roberts wrote: >ssthapa at harper.uchicago.edu (Suchandra Thapa) wrote: >>With python's lack of referential >>transparency, this will become a nightmare. E.g. >> def swap(x, y): >> t = y[x - 1] >> y[x - 1] = x >> x = t >> print x','y[x-1] >> >> x = 3 >> y = [3, 2, 1] >> swap(x, y) >> >>prints 3 , 3 which is probably not the programmer intended. > >When I type this into Python 1.5.2, I get 1 , 3. This is what I expected. >The outer value of x is not altered, although y is. Is that what you're >referring to? > > >>> swap(x,y) > 1 , 3 > >>> x,y > (3, [3, 2, 3]) The example I gave would be what types of problems that would happen if python had lazy evaluations. Currently python has eager evaluations so the code works correctly. The discussion was in the context of extensions to python. From ge at nowhere.none Wed Sep 20 14:13:33 2000 From: ge at nowhere.none (Grant Edwards) Date: Wed, 20 Sep 2000 18:13:33 GMT Subject: What is Python? References: <8pqhm9$6a9$1@panix3.panix.com> <3BBC75F01B2A2291.3CC54B93C0C69DED.4E021EA85330C94C@lp.airnews.net> <8pt65c$cbs$2@newshost.accu.uu.nl> <39C29336.71ED41AC@seebelow.org> <39C3E664.BCEAF741@seebelow.org> <8q5rgv$7to$1@nnrp1.deja.com> <39C6DF06.FF7F8A74@engcorp.com> <39C70642.D6CBF93A@alcyone.com> <39C710F7.4E72D963@seebelow.org> <39C86059.2F644D70@engcorp.com> <39C867B5.DFF9FFD3@seebelow.org> Message-ID: In article <39C867B5.DFF9FFD3 at seebelow.org>, Grant Griffin wrote: >We native English speakers have grown to love its idiosyncrasies for >their charm. However, when I first learned to read, I was very >frustrated with the non-uniformity of its spelling. (In fact, I had to >chuckle a little when I first heard a few years ago that the Germans >thought their already-highly-logical spelling needed "reform".) So in >that vein, I guess learning to _read_ English gives the native English >speaker a bit of a taste for what its like to learn to _speak_ it. Hey, at least we've only got one word for "the" and none of that silly "gender" stuff. -- Grant Edwards grante Yow! My BIOLOGICAL ALARM at CLOCK just went off... It visi.com has noiseless DOZE FUNCTION and full kitchen!! From sabren at manifestation.com Mon Sep 11 11:56:11 2000 From: sabren at manifestation.com (Michal Wallace) Date: Mon, 11 Sep 2000 11:56:11 -0400 (EDT) Subject: the death of lecter Message-ID: Hey all, When I fisrt started reading this newsgroup, I listened to a lot of newbie complaints about python, and I started thinking about implementing an "evil" version of python, implemented as a preprocessor calld Lecter that included things that real python didn't (and shouldn't!), like curly braces to delimit blocks.. I pretty much lost interest in the project, and today, for other reasons, decided to turn lecter into a literate programming tool for python. More on that soon, BUT FIRST! I took another look at the old source, which contains comments of some of the other oft-requested things. I thought I'd post them here in case anyone wanted to turn them into PEPs. Some of these really are great ideas (most of them aren't mine though): * easy class access: class.x = 1 # translates to: self.__class__.x = 1 # this adds no keywords, but it makes a really common OOP # concept much more accessible to python programmers! # I really think this is a good idea and worth doing. * immediate if: print 'x is', x > 0 ? 'positive' : 'negative' # I still wish we had a ?: operator.. # It would be great for lambdas! * design by contract (require/ensure/implies) # I still think this would be a good idea! # maybe instead of keywords, they ought to be in # a contract module? # # part of the idea is that the contract could be # inherited though. # # I was going to implement these as blocks that # would be converted to assert statements, eg: # # def f(x): # require: # x = 1 * assignment operators ( +=, -=, /=, *= ) # looks like the python team beat me to this one! :) * foreach someSequence: print this # where "this" is a keyword... I think this is dumb now, # but the idea was to have a perl-like anonymous variable * switch statement: switch x: case 1: pass case 2: pass case in (3,5): pass # no comment on this one. might be nice, probably not be worth it. * extended 'try' syntax: try: print 'do something' except: print 'catch errors' finally: print 'clean up' # not allowed in real Python # not sure why you'd want to do this, but the fact that you # can't seems kind of sad.. :) maybe someday: * /regexp/ and x =~ /regexp/ # ick! :) Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From g2 at seebelow.org Sun Sep 10 16:04:14 2000 From: g2 at seebelow.org (Grant Griffin) Date: Sun, 10 Sep 2000 21:04:14 +0100 Subject: Python 2.0b1 is released! References: Message-ID: <39BBE93E.4F0F9C24@seebelow.org> Gareth McCaughan wrote: > > Tim Peters wrote: > > > > a Amend the licence so that it says "The disclaimer > > > of liability in section 1.2.3.4 shall be interpreted > > > according to the law of the state of Virginia" or > > > whatever. > > > > The FSF appears to believe that any choice-of-law provision whatsoever is in > > conflict w/ GPL 2, no matter how hedged. > > Even if that choice-of-law provision is explicitly stated > not to apply to the GPL? I'm increasingly glad not to be > a lawyer. :-) Presumably, CNRI would want choice-of-law protection in _all_ cases, not just in some. and-who-can-blame-them?:-law-is-such-a-toxic-substance--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 kragen at dnaco.net Wed Sep 20 17:26:27 2000 From: kragen at dnaco.net (Kragen Sitaker) Date: Wed, 20 Sep 2000 21:26:27 GMT Subject: Civility in the Marketplace of Ideas [was: Public Domain Python] References: Message-ID: <7Y9y5.1275$tI.90043@news-east.usenetserver.com> In article , Pat McCann wrote: >Vehemence and personal attacks can both be civil. Cold-blooded deceit >and obnoxious public behavior cannot and those that engage in such >incivility deserve both vehemence and personal attacks, civil or not. Vehement personal attacks are a kind of obnoxious public behavior, and --- as far as I know --- the only kind that is at issue here. >Thankfully, they usually get it and only the most head-strong are able >to resist conformance to community standards of civility. Unfortunately, >too many allow celebrities that entertain or otherwise do something good >for us wide latitude to be incivil which encourages more of the same >from them and others. Leaders should be held to higher standards than >the rest of us, not lower. Your post contains little that can be argued with. However, it is minimally relevant to the discussion; no cold-blooded deceit or resistance to community standards of civility are involved here, and not even vehement personal attacks by celebrities are involved, unless you count Dave Winer. The only leaders I am aware of in the discussion --- Guido, Tim, and Richard --- are meeting higher standards than nearly anyone else in the discussion. Vehemence seems to be ubiquitous, though. >Of course, this shouldn't be taken as a defense of everything said in >public forums which allow a measure of anonymity where behavior is free >to sink far below even Stallman's low level of civility. You mean, where people use fake email addresses? Stallman's level of civility seems to me to be pretty high, with some unfortunate exceptions not related to Python; if you have counterexamples, by all means, assert them directly instead of posting vague insinuations about "cold-blooded deceit" and "community standards of civility" from a fake email address. -- Kragen Sitaker Perilous to all of us are the devices of an art deeper than we ourselves possess. -- Gandalf the Grey [J.R.R. Tolkien, "Lord of the Rings"] From isard at localhost.localdomain Fri Sep 1 09:49:23 2000 From: isard at localhost.localdomain (Carles =?iso-8859-1?Q?Sadurn=ED?= Anguita) Date: Fri, 01 Sep 2000 13:49:23 GMT Subject: Pronouncing "print>>" References: <871yz5aa4v.fsf@psyche.dnsalias.org> Message-ID: El 31 Aug 2000 14:13:01 -0400, Jason F. McBrayer va escriure: >>>>>> "DS" == Dan Schmidt writes: >DS> Carey Evans writes: >>> While I don't really like the new print syntax, I've decided to accept >>> it. This leaves me with the problem of how to say it out loud. > >DS> I'll probably say "print into". > >DS> My usual pronunciation of >> is a quick 'urh urh' but unfortunately I >DS> pronounce << the same way. >Same problem with "wacka wacka", which would be my preferred pronunciation. I do prefer "wacka wacka" and "counter wacka wacka" on the analogy of "clockwise" and "counterclockwise". :-) Bye -- ------------------------------------------------------------------------ Carles Sadurn? Anguita | no hab?a que cumplir promesas, | el cansancio era de placer, Quita _mira_la_firma para | las l?grimas eran de risas... responder. | y parece que a?n fue ayer. | Los Suaves ------------------------------------------------------------------------ From gunars at spss.com Thu Sep 7 16:27:47 2000 From: gunars at spss.com (Gunars Lucans) Date: Thu, 07 Sep 2000 15:27:47 -0500 Subject: Python 2.0b1 documentation : lib.pdf is corrupted References: <39B7EBFE.92A5D7B1@spss.com> Message-ID: <39B7FA43.98CA9098@spss.com> Gunars Lucans wrote: > > Both the US-Letter and A4 versions of lib.pdf fail here as well (Acrobat Reader > 4.05c/Win). Other pdfs are ok. ...and, I see a bug report's already been filed: [ Bug #113696 ] lib.pdf damaged in pdf-a4-2.0b1.tgz -- Gunars Lucans -- gunars at spss.com -- SPSS Inc, Chicago, USA From aahz at panix.com Sat Sep 23 22:57:14 2000 From: aahz at panix.com (Aahz Maruch) Date: 23 Sep 2000 19:57:14 -0700 Subject: Is this a high volume newsgroup References: <39CA1BE4.8702AACE@i-cable.com> <39CD0A92.868191A7@Lugoj.Com> <8qjiof$slj$1@panix3.panix.com> <39CD6B67.C3E6C3A8@Lugoj.Com> Message-ID: <8qjqia$4of$1@panix3.panix.com> In article <39CD6B67.C3E6C3A8 at Lugoj.Com>, James Logajan wrote: > >Thanks; read it and unfortunately your response didn't answer my question. >The thread you referenced died and went the way of the T. Rex six months >ago. Note the use of the present tense in my query. Let's put it this way: unless you can come up with a logical split, nobody is going to spend very much time on this. From my perspective, there are too many different types of topics covered here for a true split to make much sense, and there are already many mailing lists for dealing with narrow issues. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 'Some people, when confronted with a problem, think "I know, I'll use regular expressions". Now they have two problems.' --Jamie Zawinski, comp.lang.emacs From daniel at dittmar.net Sat Sep 2 18:08:57 2000 From: daniel at dittmar.net (Daniel Dittmar) Date: Sun, 03 Sep 2000 00:08:57 +0200 Subject: To 'with' or not to 'with': how is the question ? References: Message-ID: <39B17A79.214FD56B@dittmar.net> > This seems a good idea in origin (from Pascal), exagerated so > much that spoils any traces of programming. It's acutally much better than the original Pascal - there is only one with active (only the inner most) at any time, so you know where to look - the point clear 'points' you to the with, in Pascal, an identifier could belong to the with or be a local variable Smalltalk has something very similar: Transcript print: 'some string'; print: 'another string'; nl. So '.goes_against_OO' is a bit off - but it makes always nice copy. Which one looks the best: def alternativeOne (): sys.stdout.write (...) sys.stdout.write (...) sys.stdout.write (...) def alternativeTwo (): syswrite = sys.stdout.write syswrite (...) syswrite (...) syswrite (...) def alternativeThree (): with sys.stdout: .write (...) .write (...) .write (...) Daniel From sjuranic at condor.ee.washington.edu Thu Sep 7 20:29:06 2000 From: sjuranic at condor.ee.washington.edu (Steve Juranich) Date: Thu, 7 Sep 2000 17:29:06 -0700 Subject: Questions about multiple import's. Message-ID: I'm finally getting to the point where I'm building some "serious" applications in Python, so some practical implementation issues are starting to pop to the forefront. I've read the docs on this, and it's still not entirely clear to me. In one module, I've imported the re, os, and sys modules. Now in a parent module, I will also need som funtionality from re, sys, and os. Does it severely hinder performance to re-import the 3 system modules into the parent namespace, or should I just resolve myself to getting at the functions by tacking on an additional "name." construnction (e.g., child.re.string.strip())? Thanks for the help. Python is a wonderful language (much easier to code than that /other/ P-language), but sometimes this namespace business gets a little confusing to us newbies. ;) ---------------------------------------------------------------------- Stephen W. Juranich sjuranic at ee.washington.edu Electrical Engineering http://students.washington.edu/sjuranic University of Washington http://rcs.ee.washington.edu/ssli From claird at starbase.neosoft.com Thu Sep 21 08:31:26 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 21 Sep 2000 07:31:26 -0500 Subject: I always have to ask what they *really* want (was: can i use the python in apache like PHP??) References: <39c9ba2c.0@news2.tm.net.my> Message-ID: <8B65FA976C3F0730.1AFDCB79EE924BBE.43EBC7A6293D98A1@lp.airnews.net> In article <39c9ba2c.0 at news2.tm.net.my>, ykchew wrote: >Hi there, > > I need to develop cgi with apache server and i would like to know >whether the python can be use for it or not?? (like apache + PHP)... . . . Usage rant: is it worth trying to hold the floodgates from the slide that identifies any server-side dynamism as "CGI"? Are we already at a point where the majority of speakers don't recognize the distinction between narrow-sense CGI and in-process Web service? -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From akuchlin at mems-exchange.org Mon Sep 18 10:37:29 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 18 Sep 2000 10:37:29 -0400 Subject: Public Domain Python References: <39C52A11.B03C69B5@seebelow.org> Message-ID: <3dk8c9ahqu.fsf@kronos.cnri.reston.va.us> Grant Griffin writes: > to at any stage of Python's life. (We've heard it rumored that CNRI > made contributors sign over their rights in some form, and presumably > BeOpen.com does too--though I really don't know.) Rumored? This is easily confirmed; see http://www.python.org/patches/bugrelease.html for the text of the CNRI contribution form. BeOpen has not requested any such agreements up to this point. --amk From effbot at telia.com Wed Sep 27 11:28:13 2000 From: effbot at telia.com (Fredrik Lundh) Date: Wed, 27 Sep 2000 15:28:13 GMT Subject: Help: C char bits operations to python converting References: <8qr6au$hr4$1@nnrp1.deja.com> <8qrcr7$fhe$1@panix3.panix.com> <8qsscb$qjo$1@nnrp1.deja.com> <8qst1l$rbj$1@nnrp1.deja.com> <8qt0fd$ucv$1@nnrp1.deja.com> Message-ID: gangli at msn.com wrote: > In article <8qst1l$rbj$1 at nnrp1.deja.com>, > fredrik at pythonware.com wrote: > > gangli at msn.com wrote: > > > > >How could I convert following C statments to Python? > > > > > char tmp_ch, tmp_ch0, tmp_ch1; > > > > > tmp_ch = 'K' - 'A'; /* -> 10 */ > > > > > tmp_ch0 = ('N' - 'A') << 4; /* -> -48 */ > > > > > tmp_ch1 = tmp_ch+ tmp_ch0; /* -> -38 */ > > > > > > > > Use the built-in ord() function. > > > > > > It only help convert "tmp_ch = 'K' - 'A';", but not others > > > > it sure does. try again. > > > > It does not: > >>> (ord('N') - ord('A')) << 4 > 208 are you trying to solve a real problem, or an is this just some kind of homework? (if it's a real problem, note that your C code isn't portable) anyway, to "cast" a python integer to an 8-bit signed integer, mask with 255 and subtract 256 from it if it's larger than 127: def char(value): value = value & 255 if value > 127: return value - 256 return value From glyph at no.spam Fri Sep 29 19:48:09 2000 From: glyph at no.spam (Glyph Lefkowitz) Date: 29 Sep 2000 18:48:09 -0500 Subject: very good reasons? References: <8r2k0n01u30@drn.newsguy.com> <8r34dg0kek@drn.newsguy.com> Message-ID: Grant Griffin writes: > >If you could write > > > > sorted_arr = arr.sort() > > > >then people might get surprised that arr changed. > > Well, I had thought of that, but it didn't really seem compelling to me: I can't > find anything in Tim's "Python Philosophy"* that it specifically violates. > > (unlike-some-of-2.0's-new-features-)-ly y'rs, "Explicit is better than implicit." If you say "sorted = arr.sort(); foo(sorted)", you're only implying that arr changed, whereas if you say "arr.sort(); foo(arr)" you're stating it explicitly. -- Glyph Lefkowitz Professional -- Software Engineer, Origin Systems Amateur -- Computer Scientist, Twisted Matrix Enterprises (My opinions are my own and do not reflect in any way on the policies or practices of my employer, etcetera etcetera.) From tim at degree.ath.cx Fri Sep 15 21:31:29 2000 From: tim at degree.ath.cx (Tim Hammerquist) Date: Sat, 16 Sep 2000 01:31:29 GMT Subject: What is Python? References: <8pqhm9$6a9$1@panix3.panix.com> <3BBC75F01B2A2291.3CC54B93C0C69DED.4E021EA85330C94C@lp.airnews.net> <8pt65c$cbs$2@newshost.accu.uu.nl> Message-ID: Manuel Gutierrez Algaba wrote: > P.S.: I thought the camel symbol symbolized the ugly face of > Larry Wall. Isn't that below the belt? I haven't said anything derogatory about Guido. Or do I need to to fit in here? -- -Tim Hammerquist American society is a sort of flat, fresh-water pond which absorbs silently, without reaction, anything which is thrown into it. -- Henry Brooks Adams From roy at popmail.med.nyu.edu Wed Sep 6 09:20:01 2000 From: roy at popmail.med.nyu.edu (Roy Smith) Date: Wed, 06 Sep 2000 09:20:01 -0400 Subject: A very, very newbie question :) References: <39A41D7E.D865837D@earthlink.net> <20000823103138.A307@bigskytel.com> <39b51682.8283058@news.bright.net> <8FA79D872nemiria@139.130.239.94> <39b623fe.4343445@news.bright.net> Message-ID: jonadab at bright.net (Jonadab the Unsightly One) wrote: > In brief, to use Emacs really effectively you need to take > the time to learn lisp, but once you do it can literally do > anything. That's absurd. I've been using emacs for about 15 years now, and while I do also know lisp, I've never once done anything with lisp and emacs more sophisticated than taking some lisp snippet and cutting-and-pasting it into my emacs startup file. -- Roy Smith New York University School of Medicine From aahz at panix.com Thu Sep 21 00:44:27 2000 From: aahz at panix.com (Aahz Maruch) Date: 20 Sep 2000 21:44:27 -0700 Subject: Who is eating my memory.. ?? References: Message-ID: <8qc3nb$5j0$1@panix6.panix.com> In article , Andrew Markebo wrote: > >Basically what it does is that it fetches some info from the web, >chews it, and puts it on a textlabel in a Tkinter window.. > >I don't think I have any cyclic data.. I don't know Tkinter, but nobody else has responded, so I'll take a shot at it: I don't think you've got cycles per se, but you certainly have unreaped references. I'm guessing that you're overlaying more and Tkinter objects on your window. Try replacing the web checker function with a function that generates random data and running it in a tight loop; you should be able to see the memory loss fast enough to track it in a debugger or something. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Member of the Groucho Marx Fan Club --Aahz From matb at photond.com Wed Sep 27 12:23:32 2000 From: matb at photond.com (Matthew Banham) Date: Wed, 27 Sep 2000 17:23:32 +0100 Subject: OS commands Message-ID: <005301c0289f$475d1e90$0b0101c4@neeve> Hi all, Just a quickie from a python newbie (who couldn't find this easily in the manual and is a bit lazy!). From the python interpreter command prompt, how would I execute a DOS command? For example, I use MS Windows 2000 and I want to be able to run the dos command "myprog.exe" (i.e. to run the file "myprog.exe"). Any ideas are extremely welcome :o) Yours Sincerely, Matthew Banham ---------------------------------------------------------------------------- ---- Matthew Banham, MSci Development Engineer & Technical Support Officer Photon Design Tel: +44 1865 395480 68 Church Way Fax: +44 1865 395481 Iffley, Oxford Email: matb at photond.com OX4 4EF Web: www.photond.com -------------- next part -------------- A non-text attachment was scrubbed... Name: Matthew Banham.vcf Type: text/x-vcard Size: 515 bytes Desc: not available URL: From cut_me_out at hotmail.com Fri Sep 22 20:55:51 2000 From: cut_me_out at hotmail.com (Alex) Date: 22 Sep 2000 20:55:51 -0400 Subject: Disadvatages of using Python. References: Message-ID: Steve > He told me that the one thing he didn't like about using Python is > that he didn't get to curse as much. Yeah, just 'ing at someone isn't quite as satisfying in the short term as calling them a beetle-brained son of a motherless goat. Alex. -- Speak softly but carry a big carrot. From ian.hobson at ntlworld.com Fri Sep 1 19:52:00 2000 From: ian.hobson at ntlworld.com (Ian Hobson) Date: Sat, 2 Sep 2000 00:52:00 +0100 Subject: dont laugh References: <8oi3s4$8km$1@nobel2.pacific.net.sg> <8omadr$o8i$1@gaia.cdg.acriter.nl> Message-ID: <1rAlZGAgEEs5Ew4l@ntlworld.com> In article , Will Ware writes >Jason Cunliffe (jasonic at nomadicsltd.com) wrote: >> A lot of what mars many training video are basic film making mistakes: >> lousy sound, poor focus... > >> I just finished watching ome video of a conference... >> programmers navigating around their source files... > >This addresses my concern about video resolution. If source code is >legible, that's the main thing. > >OK, I'm convinced, video is the way to go. Can you suggest any URLs >about good video technique, and particularly getting good screenshots? > >As far as doing a good job of representing the Pythonic mindset, a >couple possibilities come to mind. One would be to ask the expert to Not so fast. Jason was right - it is the FIRST 2 hours that are vital, not the rest of the course. Python MUST run "out of the box" (even on win32 - which it does not) and then the ideas can be explained. I'm now past my first python prog. The MAJOR hurdles that I have crossed include a) Understanding that "Name error" meant I had forgotten an import line. b) Understanding that syntax error meant I had missed a : c) Getting the resulting program to run from the start menu! I STILL do not know what the IDLE main screen is for - I have NOT used it. And I'm not a newbie to programming - my first program compiled in 1966, from paper tape! I have earned a good living at it since 1974. >construct good and bad examples, and explain what makes the good ones >better. (In some cases, it might make sense to present a sequence of >examples, going from horrible to adequate to elegant.) > >The other possibility is to record an instance where the expert is >teaching somebody of lesser expertise. Hopefully the student will ask >all the questions that the viewer would want to ask if he were there. Regards Ian Ian Hobson Every time we teach a child something, we prevent him from inventing it himself. - Jean Piaget From Gareth.McCaughan at pobox.com Sun Sep 24 21:22:57 2000 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Mon, 25 Sep 2000 02:22:57 +0100 Subject: Of what use is 'lambda'??? References: Message-ID: [I said:] >> In Scheme, you can use the exact same syntax internally as >> you use at top level. (Up to R4RS, this was an optional >> part of the language, though almost every implementation >> supported it. As of R5RS it's mandatory.) > > Unfortunately, although you can use the same syntax, it doesn't always > work the same. In SCM, this code works at the top level, but breaks > inside a function: > > (define (adder x) (lambda (y) (+ x y))) > (define adder5 (adder 5)) > (define adder6 (adder 6)) > (adder5 (adder6 x)) .. > I don't understand R5RS well enough to know whether this code is > supposed to work properly or not. It's not. A bunch of internal defines is equivalent to a "letrec". The right-hand sides are evaluated before any of the names are bound. In particular, the calls (adder 5) and (adder 6) try to make use of the definition of "adder", which they're not allowed to do. Another triumph of elegance over practicality in Scheme, I think. :-) > >Of course, there's also a difference in *utility* between > >Python and (modern) Lisps, in that their lambdas make > >lexical closures and Python's don't. > > Well, and any function can be a lambda in Lisp, while only expressions > can be lambdas in Python. Reminds me of DEF FN. :) Yes indeed. The fundamental problem is that Guido doesn't really like "lambda" and its friends, I think. I'm not quite sure why he put them into the language when he doesn't like them... -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construc From m.faassen at vet.uu.nl Fri Sep 1 10:08:59 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 1 Sep 2000 14:08:59 GMT Subject: newbie: Zope References: <39ae8a6a@news.xtml.co.uk> <8om3n8$bde$1@newshost.accu.uu.nl> <3dk8cx9j01.fsf@kronos.cnri.reston.va.us> Message-ID: <8ood9r$ink$1@newshost.accu.uu.nl> Andrew Kuchling wrote: > m.faassen at vet.uu.nl (Martijn Faassen) writes: >> Ah, so you found out, huh? :) DTML is horrible compared to Python. >> There are some guidelines to keep it simple. And move to Python >> as soon as you feel your DTML becomes too horrible. > I wonder if Neil Schemenauer's rewrite of PTL would be worth looking > at for use in Zope; it looks like this: Yes, I took a look at that when I saw the announcement (that is, I glanced at it, nothing more yet). It'd definitely be an interesting approach for Zope, I think. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From nick at src.uchicago.edu Fri Sep 29 12:18:28 2000 From: nick at src.uchicago.edu (Nick Collier) Date: Fri, 29 Sep 2000 11:18:28 -0500 Subject: tkinter cursor question Message-ID: <39D4C0D4.C616A7DB@src.uchicago.edu> Hi, Is it possible to make the cursor invisible? thanks, Nick -- Nick Collier Social Science Research Computing University of Chicago http://repast.sourceforge.net From gchiaramonte at yahoo.com Fri Sep 8 10:37:03 2000 From: gchiaramonte at yahoo.com (Gene C) Date: Fri, 08 Sep 2000 14:37:03 GMT Subject: can you guys tell me where to find a NumPy module that works...? can you help? References: <8pa4a2$224u$1@newssvr05-en0.news.prodigy.com> Message-ID: I think it was Robin Becker. Anyone have Numeric 16.0 for Python 1.6 for Windows compiled? That's what I need. Thanks Gene From hzhu at users.sourceforge.net Wed Sep 13 18:16:02 2000 From: hzhu at users.sourceforge.net (Huaiyu Zhu) Date: Wed, 13 Sep 2000 22:16:02 GMT Subject: One last shot at the Augmented Assignment PEP References: <20000913160209.D52541CF42@dinsdale.python.org> <39BFC44E.FD6CB79C@rsv.ricoh.com> Message-ID: On Wed, 13 Sep 2000 11:15:42 -0700, Bob Alexander wrote: >Seems as though most members of this list are pretty happy with the >recent Augmented Assignment PEP definition. Well, I'm one of those who are pretty happy with _having_ this, but not quite happy with all its details. But the the complaint is in the other direction. >As a proponent of *true* augmented assignment, though, I suggest we >rename that new feature in Python to something more appropriate to the >definition. Like "sometimes-augmented sometimes-assignment". Or "totally >new operators having little to do with assignment". How about calling them "augmentation operators"? Their main appeal is that they actually _changes the object in place_. They look like assignment in other languages, but not at all like the reference-based name-binding assignment of python. [snip example of in place operation] >And then there's > > tup = () > lst = [] > tup += (33) > lst += [33] > You meant this: >>> a = b = [] >>> a += [33]; b [33] >>> a = b = () >>> a += (33,); b () This to me is the _only_ problem (but a really big one) with these operators. They should be undefined on immutable types! But that would upset people using a+=b has a shorthand for a=a+b, because they do want >>> a = b = 0 >>> a += 33; b 0 >>> a = b = 0 >>> a = a+33; b 0 So these are now "augmentation-for-mutable-object, assignment-for- immutable-object" operators. I don't think this is more difficult to explain than the distinction between tuples and lists itself. Maybe the true solution is for each immutable builtin type to have a mutable class correspondent. Then users can choose the behavior that makes most sense in the applications. Huaiyu From hamish_lawson at yahoo.co.uk Mon Sep 18 22:32:51 2000 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: Tue, 19 Sep 2000 02:32:51 GMT Subject: Newbie trying to understand __name__=='__main__' References: Message-ID: <8q6j8i$456$1@nnrp1.deja.com> Dan Schmidt wrote: > You're putting that if statement inside the class, which seems really > odd. I don't know if it's even legal. Though it was the wrong thing for this situation, having an if statement in a class definition is perfectly legal. This is quite a nice feature as it lets you do things like conditionally define a class at runtime. class SomeClass: if condition(): def someMethod(self): print "Do it this way" else: def someMethod(self): print "Do it the other way" Hamish Lawson Sent via Deja.com http://www.deja.com/ Before you buy. From loewis at informatik.hu-berlin.de Mon Sep 25 17:41:06 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 25 Sep 2000 23:41:06 +0200 Subject: Too late to propose modules for inclusion in 2.0? References: <8qo4cp$2gj$1@nnrp1.deja.com> Message-ID: Hamish Lawson writes: > Is it too late to propose the inclusion of established third-party > modules in Python 2.0's standard library? Yes, see http://python.sourceforge.net/peps/pep-0200.html for the Python 2.0 schedule. > I have in mind Wolfgang Grafen's seqdict package, which meets what I > believe is a common need for ordered dictionaries. PEP 0002 (Procedure for Adding New Modules) still hasn't much text in it. Maybe you want to cooperator with Eric Raymond on drafting some text for it - perhaps in way that would make addition of this package easy :-) Regards, Martin From mark at flatland.dimensional.com Mon Sep 18 19:20:18 2000 From: mark at flatland.dimensional.com (Mark Gibson) Date: Mon, 18 Sep 2000 23:20:18 GMT Subject: **kw keyword arguments Message-ID: How do I pass on keyword arguments in a function.. e.g ------------- def mark( a, b , **kw): print 'Mark' passKeywords(kw) # THIS DOESN'T WORK!!! MAKE IT WORK!!! def passKeywords( a,**kw ) """ just do something """ print 'Gibson' ------------- call it: doSomething( 1,3,name='Mark',Last='Gibson') produces: Mark Traceback (innermost last): File "", line 1, in ? File "", line 3, in mark TypeError: too many arguments; expected 0, got 1 ----------------- What I want to know is how do I pass kw from mark() to passKeywords()? From tim_one at email.msn.com Mon Sep 25 14:31:31 2000 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 25 Sep 2000 14:31:31 -0400 Subject: Too late to propose modules for inclusion in 2.0? In-Reply-To: <8qo4cp$2gj$1@nnrp1.deja.com> Message-ID: [Hamish Lawson] > Is it too late to propose the inclusion of established third-party > modules in Python 2.0's standard library? Yes: we were in feature freeze the day 2.0b1 went out the door. > I have in mind ... Doesn't matter; the freeze is real; bring it up again for 2.1; best way is to add a Feature Request now via the bug manager on SourceForge; somebody will immediately mark it Later and add it to PEP 42. from-no-rules-to-all-rules-in-the-blink-of-an-eye-ly y'rs - tim From rwallace at esatclear.ie Thu Sep 28 10:58:50 2000 From: rwallace at esatclear.ie (Russell Wallace) Date: Thu, 28 Sep 2000 15:58:50 +0100 Subject: Python in game development? References: <39B65BB5.42AF624D@sage.att.com> <39BD7E01.F737C0B7@earthlink.net> <39ca116c_2@newsflash.abo.fi> <39CACA64.99C96C3F@pehr.net> Message-ID: <39D35CAA.367EB49C@esatclear.ie> Jan Ekholm wrote: > Anyone doing strategic games with Python? I work on a American Civil War > based game, a little like the old SSI games. Development is really fast in > Python, and the speed seems to be enough. The source can be downloaded > from SourceForge if someone is interested (project name: Civil). I've a back burner project, a text-based PBEM strategy game, in Python. It's a nice, easy language for handling strings and complex data structures, and this project doesn't need .EXE compilation or animated graphics or anything like that. -- "To summarize the summary of the summary: people are a problem." Russell Wallace mailto:rwallace at esatclear.ie http://www.esatclear.ie/~rwallace From jbauer at rubic.com Fri Sep 1 21:58:52 2000 From: jbauer at rubic.com (Jeff Bauer) Date: Fri, 01 Sep 2000 20:58:52 -0500 Subject: OT: Delphi/Python Message-ID: <39B05EDC.9CCF19FA@rubic.com> Apologies for the off-topic intrusion ... If there are any Delphi/Python programmers out there, please contact me via email: jbauer at rubic.com -Jeff From db3l at fitlinxx.com Wed Sep 6 20:45:54 2000 From: db3l at fitlinxx.com (David Bolen) Date: 06 Sep 2000 20:45:54 -0400 Subject: A very, very newbie question :) References: <39A41D7E.D865837D@earthlink.net> <20000823103138.A307@bigskytel.com> <39b51682.8283058@news.bright.net> <8FA79D872nemiria@139.130.239.94> <39b623fe.4343445@news.bright.net> <39B68E8C.5E3E511D@alcyone.com> Message-ID: ge at nowhere.none (Grant Edwards) writes: > I used emacs for years without doing any elisp. I did > cut/paste a few things from examples into my .emacsrc (or > whatever it was called). After I got tired of waiting for > emacs to start up, I switched to Jed (good emacs emulation, > decent Python mode, about 1/1000 the size of emacs). Well, see, there's your mistake - you exited your Emacs. You never really need to do that :-) -- -- 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 jim.vickroy at noaa.gov Fri Sep 22 16:16:27 2000 From: jim.vickroy at noaa.gov (j vickroy) Date: Fri, 22 Sep 2000 14:16:27 -0600 Subject: SocketServer on Windows NT Message-ID: <39CBBE1B.FDC138F8@noaa.gov> Hello all, Using Python 1.5.2 on Windows NT 4.0, a file (foo.py) comprising the following code: print '<01>' import SocketServer print '<02>' produces the output '<01>' but seems to "hang" on the import statement so that '<02>' is never printed. Any ideas what I'm doing wrong. Thanks From aleaxit at yahoo.com Mon Sep 4 12:18:44 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 4 Sep 2000 18:18:44 +0200 Subject: OO-programming question References: <8ou9i4029q1@news2.newsguy.com> Message-ID: <8p0i9p019p3@news2.newsguy.com> "Rainer Deyke" wrote in message news:dJBs5.122703$6y5.82311962 at news2.rdc2.tx.home.com... > "Alex Martelli" wrote in message > news:8ou9i4029q1 at news2.newsguy.com... > > def allbases(aclass, baselist=[]): > > baselist.append(aclass) > > bases=aclass.__bases__ > > for base in bases: > > allbases(base, baselist) > > return baselist > > > > def allclasses(aninstance): > > return allbases(aninstance.__class__) > > This will break the second time allclasses is called. Don't use mutable > default args unless you really know what you're doing. Ooops, you're right -- the baselist is never cleared when a call of allbases from allclasses is finished, but rather stays around, as 'state' of the allbases function, and keeps being appended to. Removing the '=[]' from the definition of allbases, and changing the body of allclasses to: return allbases(aninstance.__class__,[]) fixes the bug, of course. Alex From tim_one at email.msn.com Sat Sep 16 03:24:26 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 16 Sep 2000 03:24:26 -0400 Subject: Public Domain Python In-Reply-To: Message-ID: [William Tanksley] > ... > Well, if they [CNRI] can't retroactively change licenses in the future, > than why are they being allowed to change them retroactively now? Sorry, but I don't know where you get the idea that they are. They've made vague noises about their putative ability to *terminate* rights under the CWI license (see the License FAQ), but nothing about changing the terms. > Why isn't BeOpen basing 2.0 off of 1.5.2 instead of 1.6, to avoid > the legal wrangling? For one thing, Python would have lost 16 months of intense community work by backtracking to 1.5.2. For another, Guido et alia, as former employees of CNRI, are in a much more complex situation wrt CNRI than anyone else (incl. me). The decision to derive 2.0 from 1.6 was the result of a massively messy set of tradeoffs, and I'm afraid much of that happened before I got here so I can't spell them all out. You may have noticed that I don't believe what anyone *tells* me <0.9 wink> -- I wasn't here then, & I really don't know everything that went into it. > Do you see how frightening this looks? That I do. But most people have gotten over it by now, and I certainly appreciate your efforts at keeping everyone frightened . > Add in the fact that the term most under dispute specifies a UCITA state, > a state in which software licenses are RIDICULOUSLY slanted in favor of > copyright owners and against licensees, and you see another reason to > worry. Read the license, Billy. Talk to a lawyer (*we* certainly have). Find a basis for assigning probabilities to these fears. > ... > ...and, thinking like my boss, I won't take the risk -- I'll go with a > language without the risk, like Perl. Then someday I expect you're going to rethink your notion of risk <0.9 wink>. > And it *looks* like a serious risk; after all, the community *appears* to > be allowing them to change the licenses of 1.3 through 1.5.x retroactively. Again, I don't know where you get the idea that CNRI is doing this. I don't have any trouble understanding why you think the community is passive, though -- they overwhelmingly are. I expect that most who actually read the license went "huh -- looks pretty good!". they-should-have-seen-the-first-draft-ly y'rs - tim From sabren at manifestation.com Fri Sep 22 09:36:42 2000 From: sabren at manifestation.com (Michal Wallace) Date: Fri, 22 Sep 2000 09:36:42 -0400 (EDT) Subject: can i use the python in apache like PHP?? In-Reply-To: <39c9ba2c.0@news2.tm.net.my> Message-ID: On Thu, 21 Sep 2000, ykchew wrote: > I need to develop cgi with apache server and i would like to know > whether the python can be use for it or not?? (like apache + PHP)... > and how is the performance compare to other script language on > apache... Sure it can. I had a shopping cart written in PHP3, and made the hard decision to switch languages a few months back. Performance was a definite question in my mind, so I made a little cgi/web script in each of php3 and python, and tried calling each with a timer about a hundred times to benchmark. I don't recall the exact numbers, but python compared favorably, and I made the switch. At the time, the only real web libraries I knew about for python were zope and the cgi library that comes bundled with it.. Neither were really what I was looking for, and so I made weblib, which is very much like the PHP3 base classes.. It might come in handy if you're coming from that model.. http://weblib.sourceforge.net/ Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From thisis at bboogguusss.org Thu Sep 21 17:36:53 2000 From: thisis at bboogguusss.org (Pat McCann) Date: 21 Sep 2000 14:36:53 -0700 Subject: Civility in the Marketplace of Ideas [was: Public Domain Python] References: <39C91A94.11A9D20A@holdenweb.com> Message-ID: cbbrowne at news.hex.net (Christopher Browne) writes: > RMS doesn't always say particularly agreeable things; he's pretty > honest when he _doesn't agree_. > ... > But "uncivil" does not seem to be a civil comment. I guess the key word above is "pretty". Please read the following post for clear evidence of uncivility. If you cannot find it there, I probably won't be able to convince you of it, but I have no doubt that most people who read it carefully will understand it as a call for an action justified by a claim of an expected good end result to be brought about by the deception. It's uncivil in my book. http://www.progressive-comp.com/Lists/?l=berlin-design&m=93118897023514&w=2 > I rather think that many of > those that consider him uncivil have more than a little bit of a chip > on their shoulders themselves. Quite right. It's similar to the chips put on their shoulders by Bill Gates or Bill Clinton. It's a form of jealousy in which people get emotionally upset when other people have great success by engaging in unfair (and uncivil) tactics while other people who've not used those tactics and may be pushing a better "product" are not nearly so successful. It's similar to the chip RMS has had on his shoulder for twenty years. It's not always a bad thing if it has a beneficial influence on other people's ideas. (But I'll admit there are better ways to do so than than responding to chip flippers on Internet forums.) From cjensen at bioeng.ucsd.edu Fri Sep 22 16:27:46 2000 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Fri, 22 Sep 2000 13:27:46 -0700 Subject: Count Down to Zero Message-ID: <39CBC0C2.A38342BE@bioeng.ucsd.edu> How come Python can't count down to zero? Was it written by ancient Romans or something? Python 1.5.2 (#7, Apr 21 2000, 13:18:02) [C] on irix646 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> float(0) 0.0 >>> float( '0' ) 0.0 >>> i = 1.0 >>> while i >= 0.0: ... print i ... i = i - 0.1 ... 1.0 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 1.38777878078e-16 >>> The last one should be 0.0 -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From debl.spammono.nospammy at world.std.com Tue Sep 19 21:17:25 2000 From: debl.spammono.nospammy at world.std.com (David Lees) Date: Wed, 20 Sep 2000 01:17:25 GMT Subject: Char handling DOS vs Linux? Message-ID: <39C81033.DBC3D150@world.std.com> I wrote a short piece of python code running under 1.5.2 for striping out those extra carriage returns that DOS editors stick into text. When I run this on my Linux box all works fine. When I run the same code under Win 95 it does nothing. It appears from using the debugger that the '\r' carriage returns are never seen when running under Windows. Is there a different Python I/O function I should be using to see ALL the charaters in a file? Thanks in advance. david lees # Read input file 1 character at a time and send to output if it is not a CR (0D='\r') while 1: s=input.read(1) if not s: break if s != '\r': output.write(s) From psnj at my-deja.com Wed Sep 27 19:40:23 2000 From: psnj at my-deja.com (psnj) Date: Wed, 27 Sep 2000 23:40:23 GMT Subject: You can never go down the drain... References: Message-ID: <8qu0h6$rm7$1@nnrp1.deja.com> In article , "John W. Baxter" wrote: > http://www.prefab.com/textmachine.html Neat. Reminds me a bit of OmniMark's "find rules". After programming with these for a while, I found going back to the traditional Unix-y ones kinda unpleasant, especially when they differ syntactically (grep vs emacs vs python etc). http://www.omnimark.com/doc/concept/630.htm Cheers, Paul Sent via Deja.com http://www.deja.com/ Before you buy. From abrahams at mediaone.net Fri Sep 29 07:42:15 2000 From: abrahams at mediaone.net (David Abrahams) Date: Fri, 29 Sep 2000 11:42:15 GMT Subject: Embeding: C++ Objects visible from Python References: <8r00ar$ddj$1@nnrp1.deja.com> Message-ID: wrote in message news:8r00ar$ddj$1 at nnrp1.deja.com... > Dear All, > > I have developed a C++ application using Trolltech's Qt GUI API. I have > embedded Python within this application using SIP. I would like to > create a MainWindow widget plus various other widgets on the C++ side > and then pass their handles over to the Python side. On the Python side > create additional child widgets and manipulate the existing C++ side > widgets using PyQt bindings. > > Currently I can launch my app, execute PyQt scripts in my embedded > command window and all works fine, dialog boxes popup etc... But I have > been unable to bridge this connectivity gap between the two sides. > > I have scoured the web and read sections in several books but I am > unable to figure it out. Does anyone have any examples explaining > a solution to this problem, or any relevant experience. [Advertisement] I have no experience with SIP, but I can offer you an alternative system which is designed to do exactly what you are describing. The documented examples show how to expose a C++ class in Python so that it can be subclassed. See http://people.ne.mediaone.net/abrahams/downloads/py_cpp.html Regards, Dave From frankm at bayarea.net Thu Sep 7 03:14:50 2000 From: frankm at bayarea.net (Frank Mitchell) Date: Thu, 7 Sep 2000 00:14:50 -0700 Subject: Please explain why python rocks... References: <8p5hei$b2k$1@panix6.panix.com> <39B672F4.C41D9CB5@san.rr.com> Message-ID: <8p7eq1$4b2$1@localhost.localdomain> Darren New wrote in message <39B672F4.C41D9CB5 at san.rr.com>... >Aahz Maruch wrote: >> That's assuming you limit yourself to the Micro$oft monoculture. > >There's a version of JavaScript (aka ECMAscript) with an interpreter written >in Java, so it's portable. You can imagine the performance, but if you don't >need much, it'll do. It's called FESI, which web searches should find. :-) There's also Rhino, written in Java as well; it can also script Java objects, using Netscape's LiveConnect mapping. No hard numbers on performance, but it was designed for a small footprint. You can find it on www.mozilla.org. (BTW, I worked on upgrading Rhino to LiveConnect 3.0, so I'm not totally disinterested.) Frank P.S. At the risk of starting a flamewar, I do get miffed when people assume Java == dog slow. JVMs are getting faster all the time, and if you really need speed there are bytecode-to-native compilers out there ... not to mention JNI for the truly critical sections (taking a page from Python). And sometimes people say Java is "slow" because they're using a dog-slow algorithm, or at least don't understand how to use the APIs efficiently. From robin at jessikat.fsnet.co.uk Sat Sep 9 10:24:25 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sat, 9 Sep 2000 15:24:25 +0100 Subject: some uglyness in Python imho References: <005701c01a55$43454790$b62079a5@jayk4> <8pdcoj$huq$1@nnrp1.deja.com> Message-ID: <1AlsHVAZgku5EwrK@jessikat.fsnet.co.uk> In article <8pdcoj$huq$1 at nnrp1.deja.com>, effbot at pythonware.com writes .... > >And who's gonna make sure the DEF file is always kept >100% up to date? > >Earlier versions of Python tried this approach. Didn't >work. Since most development is done on Unix, important >functions were always missing from the Windows DLL's. > Agreed it's a nightmare to do by hand, but there are tools that can create a .def file automatically. Tcl at least used that approach and it seemed to work. The macro method seems most fragile when building and linking together a number of DLLs so if A imports B then during the build of A it has to export itself and import B and that seems to require two types of declaration and presumably two macros. -- Robin Becker From KILLzdramboSPAMMERS at zdnetmail.com Sat Sep 2 02:06:55 2000 From: KILLzdramboSPAMMERS at zdnetmail.com (Quasimodo) Date: Fri, 1 Sep 2000 23:06:55 -0700 Subject: Linbot References: Message-ID: <8oq5f1$4cji$1@newssvr05-en0.news.prodigy.com> "Jim Richardson" wrote in message news:slrn8r0qi6.1vf.warlock at gargoyle.myth... > On Thu, 31 Aug 2000 18:41:45 -0500 (CDT), > marduk, in the persona of , > brought forth the following words...: > I have been forced to refrain from using the name "Linbot" from anything > I'm associated with. This was a result of a Cease and Desist from > www.watchfire.com . Their claim is that Linbot infringed upon their > (pending) trademark on Linkbot. +++ BEGIN RANT +++ Don't you just hate these asshole companies with more money than sense? Everyone's out to patent everything. With only 30,000 words in the English language (of which the average person uses only around 3,000) we'll soon need another language to avoid getting sued for using a trademarked word without permission or paying the license fee!!!!! They're trademarking Linkbot, Metabot, Macrobot. Hell if they tm the letters "bot" or even "robot" think of the money they could make suing, for example, movies that feature robots without licensing the term, etc. Where will this stupidy end? +++ END RANT +++ Jose San Jose, CA (trademarks pending on the 26 letters of the modern Western alphabet - that'll teach 'em) From jeremy at beopen.com Mon Sep 25 15:10:50 2000 From: jeremy at beopen.com (Jeremy Hylton) Date: 25 Sep 2000 19:10:50 GMT Subject: Python Concerns References: Message-ID: "Gene C" writes: > Thanks, but it's not me I'm worried about. It's anyone looking into the > language right now. From the beopen 1.6 release link your taken to the 1.6 > beta release with a blurb about licencing issues. Dosen't give you the warm > fuzzies. > The problem here is that the pythonlabs.com mirror of python.org is a bit stale. We're aware of that problem and are working on it. -- Jeremy Hylton From farmerk at pacbell.net Wed Sep 27 00:53:02 2000 From: farmerk at pacbell.net (Keith Farmer) Date: Tue, 26 Sep 2000 21:53:02 -0700 Subject: JPython status References: <8qb2o7$cf5$1@nnrp1.deja.com> <3BD2B6654B39EE1C.2727C33241A78CF5.6B0036B2CD7E2547@lp.airnews.net> Message-ID: "Fredrik Lundh" wrote in message news:zH5A5.857$jk1.55304 at newsc.telia.net... > if I understand things correctly, Finn's work brings JPython up > to par with CPython 2.0. How about speed? Keith Farmer From ldw at us.ibm.com Fri Sep 15 10:38:25 2000 From: ldw at us.ibm.com (Larry Whitley) Date: Fri, 15 Sep 2000 09:38:25 -0500 Subject: Class warfare... Message-ID: <8ptc91$hhk$1@news.rchland.ibm.com> I'm creating a list of objects and then want to assign the instance variables in each object different values. First I tried this:. class Bucket(): def __init__(self): self.cnt = 0 >>> b = [Bucket()] * 5 >>> b[1].cnt = 2 >>> b[3].cnt = 7 >>> for i in range( 5 ): >>> print b[i].cnt 7 7 7 7 7 I expected to see: 0 1 0 7 0 I suspect that my [Bucket()] is producing a reference to the class rather to an object that is an instance of the class. So, I changed the b = ... statement above to: >>> b = [] >>> for i in range( 5 ): >>> b.append( Bucket() ) And repeat the experiment, I now get what I expected. Is this how it's supposed to be done? Or is there a better way? Larry From nospam at nospam.com Wed Sep 27 14:31:13 2000 From: nospam at nospam.com (Tom) Date: Wed, 27 Sep 2000 18:31:13 GMT Subject: Python advocacy for device testing? References: <8nhffv$jrk$1@nnrp1.deja.com> <39D161A1.8D33D084@home.com> Message-ID: Sort of. I've used it to control network drivers and network configuration on windows. For example, created an extension that allowed me to perform the functions of the network control panel applet from Python. Of course, the real meat was in C/C++, but wrapping it in Python was easy and it made testing easier. Tom. "John Q. Public" <@home.com> wrote in message news:39D161A1.8D33D084 at home.com... > The company for which I work uses python for performing automating out > qualification testing of avionics systems (for both the FAA and others). > We have found it to be very easy for non-programmers to learn and extend > for interfacing with our hardware and test equipment. The object > orientation also makes it easy to perform a series of tests over a group of > systems (wither hardware or software): > > for Device in List_Of_Devices: > Results = Do_The_Test (Device) > > We can also journal the output of the tests and verify that they were > properly executed (for verifying regression tests as well as for proof of > the test). > > Jonathan Polley > > redhouse at my-deja.com wrote: > > > So I am a python newbie. I have done a week or two of working through > > exercises and read most of "Learning Python." I am trying to sell it as > > a testing infrastructure language in my test automation group. Does > > anybody have any experience in this arena? The goal is to create a > > testing infrastructure for an optical networking product. > > > > The prime competition is TCL, of which I am not a big fan. > > > > Has anybody out there used python in this sort of application? Have you > > used it to interface with network testing equipment to do things like > > load testing and impairment? > > > > Thanks- > > > > Carter > > > > Sent via Deja.com http://www.deja.com/ > > Before you buy. > From tim at degree.ath.cx Wed Sep 20 13:14:05 2000 From: tim at degree.ath.cx (Tim Hammerquist) Date: Wed, 20 Sep 2000 17:14:05 GMT Subject: What is Python? References: <8pqhm9$6a9$1@panix3.panix.com> <3BBC75F01B2A2291.3CC54B93C0C69DED.4E021EA85330C94C@lp.airnews.net> <8pt65c$cbs$2@newshost.accu.uu.nl> <39C29336.71ED41AC@seebelow.org> <39C3E664.BCEAF741@seebelow.org> <39C67A2C.2313778A@seebelow.org> Message-ID: Grant Griffin wrote: > Of course, I don't expect that eveyone will share this sensibility; if > Perl makes sense to _you_, more power to 'ya. But I did it off-and-on > for three years, and my fingers did a lot of walking through the > camel--they probably walked a mile for it. I found I had to do a lot of extra research to become fluent in Perl as well. However, nothing truly worthwhile comes too easily, right? ;) > But my own theory is that Perlers actually revel in the nonsensicalness > of their language, much as a tight-rope walker proudly calls attention > to his lack of a net. <> It's an ego thing. That > explains the one-liners and the "just another perl hacker" thing. We do, to a point, revel in this. And ego is definitely rampant in clpm. > By the way, here's my own personal Python JAPH implementation: > > print "just another perl hacker" Coincidentally, and I don't want to hurt your pride, but this is also Larry Wall's implementation. Apparently he has also become tired of all these cutesy little tricks. Of course, Larry would remember to put a semi-colon after that statement if there were more than one statement in the codeblock... would you? ;) > But in terms of your point about "the best tool for the job", one _does_ > have to admit in all fairness that there's at least _one_ thing that > Perl is an order-of-magnitude better at than Python: execute Perl > scripts. How 'bout regexps? Perl didn't create regexps, so why bag on them as some in this thread have done? Unix operations demanded the existence of regex pattern matching and Perl, which was so obviously derived from several Unix tools, accomplishes them very well. I've noticed Pythoners like to stand on soapboxes and look down on regexps. ("A true Python solution wouldn't use regex's.") Why look down on something so powerful? Regexps are optimized for matching text against patterns as quickly and efficiently as possible, whereas you can only have so many: if 'x' in word: statements before you're bloating your code unnecessarily. I agree that: if( $char =~ /^a$/ ) {...} would be much more efficiently implemented as: if( $char == 'a' ) {...} but more complicated patterns are just not worth replacing with a system of if statements. The fact that Perl makes regexps so readily available and easy-to-use probably contributed to their over-use, but Perl isn't the only language that can be misused, is it? > But I guess if the mettle of a scripting language is to be judged by its > one-linerability, I should confess that Python is a dismal failure: if > you put together its use of indents for blocks, with the fact that none > but its most elemental functions are built-in...well...it's hardly What elemental functions aren't built-in? I was under the impression that core modules were built-in, they simply exist in a separate namespace? > show-me-a-language-that's-great-for-one-liners-and-i'll-show-you > -a-language-that-doesn't-scale-well--ly y'rs, Perl 5 took great strides toward scaling. I would personally prefer to use Python for a larger scale app, but Perl is more than capable of doing it quite well. -- -Tim Hammerquist Universities are places of knowledge. The freshman each bring a little in with them, and the seniors take none away, so knowledge accumulates. -- Unknown From sholden at holdenweb.com Tue Sep 12 11:39:54 2000 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 12 Sep 2000 11:39:54 -0400 Subject: Script To automate ftp uploading References: <39be38a4@news.bezeqint.net> Message-ID: <39BE4E4A.B7FDF783@holdenweb.com> Moshe Eshel wrote: > > Hi! > > I need some help to create a script that will connect to a remote server and > upload all the files in a certain directory. > > I know how to do the basic stuff like the connect and upload issues, > what I really need help with are all the special cases... How to deal with > Errors on the remote server, how to know when file upload has finished > and do a size check to determine if the file made it to the other side... > And if failed to retry... etc... > > Any help would be appriciated... > > Any examples in any shell language Perl or Tcl would be greatly > appriciated... > > Thanks a lot in advance > > Moshe Eshel > moshe at u4all.com Moshe: Your distribution may include a utility called "ftpmirror.py" which makes use of the standard ftplib functions to do exactly what you want. In my Windows 98 installation it lives at %PythonRoot%\Tools\Scripts. Hope this helps. regards Steve -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ From aleaxit at yahoo.com Fri Sep 1 09:08:09 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 1 Sep 2000 15:08:09 +0200 Subject: string to function reference References: Message-ID: <8ooa1f0r22@news1.newsguy.com> "Igor V. Rafienko" wrote in message news:xjvem34ibkk.fsf at ganglot.ifi.uio.no... > I've got a string holding a name of the function in the same module: > > def foo(): > print "I'm foo" > s = "foo" > > The question is, how do I call the function foo given its name as a > string. The three approaches I could see are: > > 1) exec, as in: > > exec s + "()" > > 2) globals(), as in: > > (globals()[ s ])() > > 3) __dict__, which is no better than globals(). > > All of these approaches are simply waay too ugly, imvho. Does anyone > see a simpler/cleaner/more elegant way of achieving this. The call operation needs to be applied to the function object. The reference to the function object is in a dictionary, under a key you have (the name you hold). What's so "waay to ugly" about fetching the function object from that dictionary, then calling it? thefun=__dict__[s] thefun() You can wrap that in a function, of course (warning, untested): def callit(funname,*args,dict=None): if not dict: dict=globals() funobj=dict[funname] return apply(funobj,args) so you can say, in your case, callit(s) Alex From SBrunning at trisystems.co.uk Fri Sep 29 05:20:43 2000 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Fri, 29 Sep 2000 10:20:43 +0100 Subject: distributing python Message-ID: <31575A892FF6D1118F5800600846864D5B11E4@intrepid> Matthew, Oh, God, you've just launched another interminable license thread. Which release of Python did you use? Which platforms are you targeting? 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 sdm7g at virginia.edu Thu Sep 21 14:03:41 2000 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Thu, 21 Sep 2000 14:03:41 -0400 (EDT) Subject: compiling python on Mac OS X Beta In-Reply-To: Message-ID: On 20 Sep 2000, Johann Hibschman wrote: > Hi folks, > > Has anyone had any luck compiling python (1.5.2, 1.6, 2.0b, I don't > care) on the Macintosh OS X? I tried and failed this afternoon. > 1.5.2 wanted to put both a "Python/" directory and the "python" > executable in a case-insensitive directory (so it compiled, just > didn't test or install), while 1.6 died on a missing header file, > something like "mach-o/rld.h", but I am shamed to admit I forget the > exact name. > > Any tips or pointers? > I was doing some hacking at Darwin, but I stopped until my copy of OSX beta arrives -- it'll be easier to work if I don't have to boot back and forth between Darwin and OS9. The developer tools for OSX beta haven't shipped yet. Have you loaded the Darwin developer tools on top of OSX, or do you have tools from DP4 ? There is a version of 1.5.2 for OSX that I found thru Stepwise's SofTrak, that works and builds under Darwin as well as OSX. I think all that he did was to change the "Python" directory to "_Python" and adjust the makefiles. ( HFS+ is not case sensitive. The other solution is to create a UFS partition and build it on that filesystem. ) There is now supposedly a version of Python in the Darwin CVS repository at publicsource.apple.com, but I haven't checked this out yet. I tried to use CVSWeb to peek at it, but access seemed to have been broken, so I don't know what version of Python or what mods have been made. A newer version of config.guess reportedly fixes some of the autoconfig problems. The Darwin mailing lists have been quite active, and for questions about the non-Quartz, non-Carbon, non-Cocao lower level stuff, it is probably better to ask there. ( That may have been because until the beta, all of the ODX DP4 developers were under non-disclosure agreements -- maybe the OSX mailing lists will pick up now, but you'll also probably see a lot of OSX/Darwin cross development projects. ) http://www.darwinfo.org/ is the best web site to start from. The Stepwise darwin site and Apple's own Darwin FAQ are not as frequently updated. ---| 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 jonadab at bright.net Fri Sep 8 04:46:31 2000 From: jonadab at bright.net (Jonadab the Unsightly One) Date: Fri, 08 Sep 2000 08:46:31 GMT Subject: A very, very newbie question :) References: <39A41D7E.D865837D@earthlink.net> <20000823103138.A307@bigskytel.com> <39b51682.8283058@news.bright.net> <8FA79D872nemiria@139.130.239.94> <39b623fe.4343445@news.bright.net> Message-ID: <39b79670.14538484@news.bright.net> Alex wrote: > > The main advantage of Emacs is that it is extensible. > > idle has this advantage, too. The problem for me as far as moving to > idle is concerned is that I have eight years of extensions to emacs that > I don't want to give up. I wouldn't actually kill anyone for a > elisp-to-python-for-idle converter, but I would cheerfully mortally > offend them. So write one. I promise to try out IDLE if you do. - jonadab From tim_one at email.msn.com Fri Sep 8 16:04:56 2000 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 8 Sep 2000 16:04:56 -0400 Subject: Python 2.0b1 is released! In-Reply-To: <8pam0s$9a2$1@newsserver.rrzn.uni-hannover.de> Message-ID: [posted & mailed] [Tim] >> It's a "political" situation only if CNRI and the FSF fail to reach >> agreement: please help us make clear to them that resolution >> is what you want (provided, of course, that you *would* rather see a >> peaceful resolution than a political circus). [Bernhard Reiter] > Of course I just want this to be resolved. I'm sorry. I've been at this a couple months already, and am afraid I'm losing track of who is and isn't insane -- you're one of the good guys, and I apologize for implying you *may* prefer this to become (more of) a mess. > From what read now I think that we need a python user petition > which targets CNRI and the FSF. I don't know what influences the FSF, but I'm pretty sure a petition will have no impact on CNRI. Dr. Kahn must be acutely aware already that he's not winning any popularity contests here, and apparently doesn't care about that. Two other tactics, one that will work (if possible) and one that might: 1. Sure thing: Make a compelling argument that the CNRI license is not compatible with the GPL already. To be compelling it must be based on law; not on the goals of the FSF, or what RMS wants, or on what 999,999 out of a million GPL users believe, but solely on the texts of the GPL and CNRI license and any relevant case law. You'd have to be a lawyer to make this stick, and a good one: as everyone at CNRI will testify, intellectual property law is one of Dr. Kahn's long-standing and passionate interests. He apparently won't debate philosophy here, but does care for what the law *is*. 2. Maybe: What I've suggested before: If there are specific problems that the suspicion of GPL-incompatibility will cause for your project, tell him about that very clearly. CNRI is very fond of repeating that everything they do is "in the public interest" or "for the public good". I haven't seen their by-laws, but it may be they're *required* to meet that vague standard in order retain tax- exempt status in the U.S. Whatever, Dr. Kahn has shown sensitivity to individuals facing specific problems. If CNRI is creating documentable problems for people, "public good" is hard to defend. > ... > It is more that I really cannot understand the problem on CNRI's > part here. CNRI's laywers tell him his license is already compatible with the GPL. Picture Dr. Kahn as RMS, but with a different view of the world <0.5 wink>. A choice-of-law clause is extremely common, at least in American licenses, and for solid business reasons. He's loathe to give that up, and especially not when his laywers tell him there's no need to. By the way, RMS has said he has no moral problem with the choice-of-law clause, either: he views it as a legal incompatibility. Dr. Kahn disagrees. Somebody has to bend, and neither of these fellows is particularly noted for flexibility when they feel a principle is at stake. > Actually I did send mail that I wanted to sign the open letter to > CNRI, which was crafted here, but I must have missed the result > of it. :-/ Peter Schneider-Kamp reported that he didn't get a reply. So much for petitions <0.3 wink>. It was also remarkable how few people signed it! > ... > Seriously I can understand that, > but you see that this negociations are in a way political. Sure -- endlessly talking about what I think will and won't work with CNRI is nothing if not political maneuvering . > So to say: "We will use and work with python anyway at this points.", > is removing a huge part of pressure. What pressure? The paying Python Consortium (which CNRI still runs) members approved the new license, and Python *development* stopped being CNRI's concern the day Guido left. To the extent that CNRI believes they have *anything* remaining at stake here, they're making clear exactly what that is by clinging to the choice-of-law clause. They apparently needed the 1.6 release to meet their own obligations, and withholding that was the only pressure we could apply. But we had obligations there too, and held back as long as we could. This isn't like, e.g., pressuring Trolltech over Qt: CNRI isn't in the Python business anymore. Except that their license lingers on forever. > (This is just about tactics in general, again no offense meant, > I can see that you are concerned about the licensing problem.) Thanks, and we'll take any tactic we can get <0.9 wink>. > ... > No I have not read CNRI' side of it. > I think I will craft a letter to CNRI asking about this. Note that Dr. Kahn is reported to be on vacation until the 18th, so don't be surprised if you don't get a reply for a couple weeks. > Does anybody have some times on its hand to organise a python > user petition? I don't oppose that, but since I doubt it will be effective (unless RMS is swayed by such things -- ya, right ), I'm not going to take it on myself. > having-too-many-important-free-software-issue-to-care-about-ly y'rs, > Bernhard What? There are programs other than Python out there?! the-world-may-be-bigger-than-i-thought-...--ly y'rs - tim From hs at paradise.nirvananet Sat Sep 2 13:19:14 2000 From: hs at paradise.nirvananet (Hartmann Schaffer) Date: 2 Sep 2000 13:19:14 -0400 Subject: Looking for Python programmers--where to search? References: <39ABE7F7.BA78BD78@hursley.ibm.com> <8oh4mi0etd@news2.newsguy.com> Message-ID: <8orcqi$1mk$1@paradise.nirvananet> In article , Ian Hobson wrote: > ... >Pascal was designed for just this purpose, and then some bright spark >wrote a compiler for it! I have to disagree: imo pascal is full of features whose only purpose is to make life easy for the compiler and leaves out (probably for exactly the same reason) several fundamental language concepts that i find essential: block structure with finer graining (actually i find ity very ironic that just about at the time when algol implementors had found an implementation techniques to implement local blocks efficiently Pascal decided to drop eliminate that construct for the sake of efficiency) and self describing data structures (in C at least you can fake them and teach a few methods how to do it safely). despite its syntactic clarity i always felt that pascal put the art of programming back by about 10 years >Pascal will quickly get out of the way, and it is impossible to do >naughty things with pointers without significant knowledge. again, in years of programming in pascal and derived languages i found that there are few languages who get as much in the programmer's way as pascal. i also found quite a few places in the semantic rules which are very difficult to explain to a beginner without resorting to explain how it is implemented >Python or Pascal would be my choice. Python would be ok (though i still would prefer scheme, ml, or haskell), but i would replace pascal by algol68 (which always received much less use and support than it deserved), at least a subset that leaves out some of its more esoteric features. Hartmann Schaffer From aleaxit at yahoo.com Mon Sep 11 15:43:12 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 11 Sep 2000 21:43:12 +0200 Subject: the death of lecter References: Message-ID: <8pjd1e0b8c@news2.newsguy.com> "Michal Wallace" wrote in message news:Pine.BSF.4.10.10009111130480.20577-100000 at chi.pair.com... [snip] > * design by contract (require/ensure/implies) > # I still think this would be a good idea! > # maybe instead of keywords, they ought to be in > # a contract module? I think a metaclass would be more appropriate, at least if I understand metaclasses correctly. You could already today (I believe) write a metaclass that, when accessing, say, method foo, also looks for __pre_foo and __post_foo, and sequences things appropriately (including perhaps a deepcopy of self to old in the pre, if necessary to check things in the __post ...). > * foreach someSequence: print this > # where "this" is a keyword... I think this is dumb now, > # but the idea was to have a perl-like anonymous variable -- "if you want Perl, you know where to find it"...? > * extended 'try' syntax: > try: > print 'do something' > except: > print 'catch errors' > finally: > print 'clean up' # not allowed in real Python > > # not sure why you'd want to do this, but the fact that you > # can't seems kind of sad.. :) You just have to nest it: try: try: print "foo" except: print "errors" finally: print "clean up" I do agree that an optionally finally-clause after 1 or more except clauses (and possibly an else clause too) on a try would make for a nice alternative to this rather cumbersome nested syntax where except (& maybe else) and finally are mutually exclusive. "Why you'd want to do this" seems rather obvious -- catch errors AND also guarantee some finalization. Alex From alex_holubec at email.msn.com Sun Sep 17 20:06:23 2000 From: alex_holubec at email.msn.com (alex_holubec) Date: Sun, 17 Sep 2000 20:06:23 -0400 Subject: BUG? sha-moduel returns same crc for different files References: <8psovc$e9o$1@oslo-nntp.eunet.no> Message-ID: Another Solution. Hashing is an overkill. The following method has been used by Herr Professor Doktor Niklaus Wirth :-) in Project Oberon: open both files in binary mode and compare byte by byte. Very simple and fast. Alex "jepler epler" wrote in message news:slrn8s5b26.6rr.jepler.lnk at potty.housenet... > Solutions: > 1. use open(filename, "b") > 2. don't use windows > > You're getting the file truncated (probably at the first chr(26)) and > the leading portions are identical. > > Jeff From tim at degree.ath.cx Fri Sep 29 02:18:40 2000 From: tim at degree.ath.cx (Tim Hammerquist) Date: Fri, 29 Sep 2000 06:18:40 GMT Subject: What is Python? References: Message-ID: Grant Edwards wrote: > Mikael Olofsson wrote: > > > Grant Edwards wrote: > > > > And the lack of a > > > > sex-neutral third person singular pronoun is annoying. > > > >What? Is "it" deprecated? > > When used to refer to a person, "it" is generally considered > insulting. And it sounds funny: > > "When a programmer needs to write a quick utility program, it > should consider using Python." Pre-feminist convention dictated that person whose gender was irrelevant defaulted to masculine. Hence, "...he should consider using Python." OTOH, if a machine were attempting to learn, "it" might be insulted at personification of this sort, whether masculine or feminine... Where do we draw the line at who (what?) we respect? However, I have no qualms with inviduals choosing to default to the feminine, especially in anything as informal as a newsgroup. I saw a sign at the University of California, Santa Cruz, which, instead of "Keep off grass", suggested "Respect our Vegetation." What's next? Should we salute the grass before a picnic? Play a requiem prior to mowing the lawn? If we grant citizenship to vegetation, what will vegetarians eat? Just some thoughts to ponder... =) -- -Tim Hammerquist A child of five would understand this. Send someone to fetch a child of five. -- Groucho Marx From phd at phd.russ.ru Mon Sep 4 09:48:20 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Mon, 4 Sep 2000 13:48:20 +0000 (GMT) Subject: ICQ messages in Python In-Reply-To: <051001c01676$852cc670$978647c1@DEVELOPMENT> Message-ID: On Mon, 4 Sep 2000, [iso-8859-1] Ulf Engstr?m wrote: > But if you want a full icq-client you can either use one of the existing > ones from source-forge (they are in a variety of languages) or join up for > the 'started-just-recently-project-to-create-an-icq-client-in-python'. I think the best method would be to not to reinvent the wheel, but to use some existing ICQ library and wrap it for using in python. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From pduffin at hursley.ibm.com Mon Sep 4 11:00:01 2000 From: pduffin at hursley.ibm.com (Paul Duffin) Date: Mon, 04 Sep 2000 16:00:01 +0100 Subject: GC and finalizers [was: No destructor] References: <39a1711d_2@news2.vip.uk.com> <8nrsnb$h4f$1@news5.svr.pol.co.uk> <8ns4mu$9c4$1@la-mail4.digilink.net> <8ntct002hcm@news2.newsguy.com> <39A4FF7E.D200D5F7@hursley.ibm.com> <39A63BCB.3BF3F6CB@hursley.ibm.com> <39AE88ED.A25B1AA1@hursley.ibm.com> <3dk8cxcpus.fsf@kronos.cnri.reston.va.us> Message-ID: <39B3B8F1.2F1112DB@hursley.ibm.com> Andrew Kuchling wrote: > > Most of the discussion of GC and finalizers happened on python-dev > back in March, and many coulombs of electrons were expended in those > discussions. See http://www.python.org/pipermail/python-dev/2000-March/ > > The following threads are particularly relevant: > Design question: call __del__ for cyclical garbage? I had read most of this thread previously, along with the other thread on how the cycles would be found in the first place. Unfortunately the above thread ends abruptly with no outcome. I have looked in the April and May archives but could not find the rest of the thread. The situation at the end of the thread was that Guido was still undecided about how to handle it but seemed to prefer some cleanup mechanism rather than just adding it to a global list. I did quite like the guardian idea from Scheme that Tim talked about. Maybe rather than one global list each class should have a list of the instances of its objects which are in cycles and a class method could be called to clean it up. There is still the problem of what to do if the class does not provide one. > Design question: call __del__ only after successful __init__? > finalization again > > Back then, Tim Peters also posted a pointer to > http://www.iecc.com/gclist/GC-faq.html, which talks about GC and > finalizers a bit. > Read that too. Also read http://reality.sgi.com/boehm_mti/finalization.html which neatly sidesteps the issue by declaring "Cycles involving one or more finalizable objects are never finalized." From dheise at debitel.net Thu Sep 21 22:00:33 2000 From: dheise at debitel.net (Dirk Heise) Date: 21 Sep 2000 22:00:33 CET Subject: where is upvar References: <8qcujb$1ka$1@desig-bs01-s04.adtranzsig.de> <39CA27AC.90630D77@san.rr.com> Message-ID: <01c02406$6a4feb00$61d7363e@dreadzone> Darren New schrieb im Beitrag <39CA27AC.90630D77 at san.rr.com>... > Dirk-Ulrich Heise wrote: > > No, it's by no way natural. It's sick. > > No, it's natural. That's how I did it too. You just make sure the names > don't clash. > > > I mean, i don't show around that > > nasty programming language i once invented that can freeze > > program execution, inspect and modify all variables on the > > stack and everywhere else including the source code of the > > callers, and continue running. > > That's called "Smalltalk", isn't it? > > Or was this post scfthi? No, by far uglier, and unpublished, i mean, it's really not pretty. Does Smalltalk do something like that? Never heard of such a feature. And wtf does scfthi mean? (btw, Stackless would enable similar nastinesses in Python) Dirk From root at 127.0.0.1 Tue Sep 26 21:03:56 2000 From: root at 127.0.0.1 (David) Date: Wed, 27 Sep 2000 01:03:56 GMT Subject: Wholly unnecessary flame. (was Re: pyXML!) References: <7BD10B680501D411B9DF009027E06F32011BD9@exchange> <39d2d532.43850056@news.telus.net> <7j6A5.861$jk1.56216@newsc.telia.net> Message-ID: <39d24589.6203856@news.telus.net> On Tue, 26 Sep 2000 18:56:03 GMT, "Fredrik Lundh" wrote: >David wrote: >> Why is Visual C/C++ being used? Why not Cygwin or Borland C/C++? The >> latter two are both freely available; one of them is, IIRC, even open >> source. > >Feel free to contribute build files. Or work on your motivational >skills, and maybe someone somewhere will write them for you... That doesn't really answer the question. Question: Why was VC chosen as the development platform, instead of an open-source compiler? Question: Are any VC-specific features/code/tweaks being used? Why would the developers choose to bind the code to VC, rather than aim for cross-compiler compatibility? Question: Are build files so different between compilers that there is no automatic tool for converting from build to build? Question: Why wouldn't every Windows-platform code release include a binary file, to accomodate the vast numbers of Windows users who don't have VC, don't know how to operate the VC compiler and, frankly, really would rather get on with using the code instead of wrestling with compiling it? I don't know bugger all about C/C++, and I really don't want to. I don't have a compiler and I don't want to dedicate umpteen meg of drive space to one. One of the biggest reasons I've stuck with Windows instead of Linux is that it is the most productive environment for the work I do, and with that same attitude of most-work for least-effort, I look toward using Python for my scripting needs, and desire pre-compiled binaries, so that I can just get to work immediately. >From my perspective, it makes absolutely no sense for any developer to (a) not distribute binaries for their Windows port; and (b) to force users to install a commercial compiler to create binaries. From akuchlin at mems-exchange.org Sat Sep 9 10:44:58 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 09 Sep 2000 10:44:58 -0400 Subject: Pyton 1.6's license References: <39B813C6.31B1A5D@tridog.com> <14776.64933.524639.171911@anthem.concentric.net> <20000908173028.B20560@mediasupervision.de> Message-ID: <3dwvglbp5h.fsf@kronos.cnri.reston.va.us> Gregor Hoffleit writes: > Anyway, if the issue is not settled in the near future, that would more or > less automatically mean a fork of Python at some time, a VERY bad thing. Near future? Be realistic; given Debian's past glacially slow release history, I'd expect to see Python 2.1 out before Debian 2.3 is frozen. The issue of 2.0 license can certainly wait a few weeks for the FSF's and CNRI's legal advisors to talk. And it's doubtful a fork of Python would survive; who would work on it? The Guile project originally started with the goal of writing a Scheme interpreter and then writing translators for Python/Perl/Tcl on top of it; those translators are still non-existent, and Guile itself isn't very commonly used even by people who like Scheme. --amk From jcm at bigskytel.com Wed Sep 27 10:10:45 2000 From: jcm at bigskytel.com (David Porter) Date: Wed, 27 Sep 2000 08:10:45 -0600 Subject: Newbie question... In-Reply-To: <8qss6t$qht$1@nnrp1.deja.com>; from jhorn94@my-deja.com on Wed, Sep 27, 2000 at 01:20:36PM +0000 References: <8qss6t$qht$1@nnrp1.deja.com> Message-ID: <20000927081045.A22110@bigskytel.com> * jhorn94 at my-deja.com : > I'm going thru the Learning Python book and am stumpped. The exercise I'm (slowly) reading it too! > calls for a function that accepts and arbitrary number of keyword > arguments, then returns the sum of the values. I can step thru the > arguments with a for statement, but I can't figure out how to accumlate > a sum of the values. Any help is appreciated. > > def adder(**args): > > for x in args.keys(): > y=y+x > return y > > print adder(good=1, bad=2, ugly=3) > print adder(good="a", bad="b", ugly="c") returns > UnboundLocalError: y because there is no y to add x to. The following should do what you want: def adder(y, **args): for x in args.values(): y=y+x return y print adder(good=1, bad=2, ugly=3, y=0) print adder(good="a", bad="b", ugly="c", y='') I changed args.keys() to args.values() so that the values of the keywords are added and not the keywords themselves. I also added y as a keyword, though there might be a better way to do this. I did this because adding numbers requires y to be different than when concatenating characters. David From sjcqrj at kaplan.com Sun Sep 10 14:05:41 2000 From: sjcqrj at kaplan.com (sjcqrj at kaplan.com) Date: Sun, 10 Sep 2000 18:05:41 GMT Subject: DeCSS 7662 Message-ID: /* * css_descramble.c * * Released under the version 2 of the GPL. * * Copyright 1999 Derek Fawcus * * This file contains functions to descramble CSS encrypted DVD content * */ /* * Still in progress: Remove the use of the bit_reverse[] table by recoding * the generation of LFSR1. Finish combining this with * the css authentication code. * */ #include #include #include "css-descramble.h" typedef unsigned char byte; /* * * some tables used for descrambling sectors and/or decrypting title keys * */ static byte csstab1[256]= { 0x33,0x73,0x3b,0x26,0x63,0x23,0x6b,0x76,0x3e,0x7e,0x36,0x2b,0x6e,0x2e,0x66,0x7b, 0xd3,0x93,0xdb,0x06,0x43,0x03,0x4b,0x96,0xde,0x9e,0xd6,0x0b,0x4e,0x0e,0x46,0x9b, 0x57,0x17,0x5f,0x82,0xc7,0x87,0xcf,0x12,0x5a,0x1a,0x52,0x8f,0xca,0x8a,0xc2,0x1f, 0xd9,0x99,0xd1,0x00,0x49,0x09,0x41,0x90,0xd8,0x98,0xd0,0x01,0x48,0x08,0x40,0x91, 0x3d,0x7d,0x35,0x24,0x6d,0x2d,0x65,0x74,0x3c,0x7c,0x34,0x25,0x6c,0x2c,0x64,0x75, 0xdd,0x9d,0xd5,0x04,0x4d,0x0d,0x45,0x94,0xdc,0x9c,0xd4,0x05,0x4c,0x0c,0x44,0x95, 0x59,0x19,0x51,0x80,0xc9,0x89,0xc1,0x10,0x58,0x18,0x50,0x81,0xc8,0x88,0xc0,0x11, 0xd7,0x97,0xdf,0x02,0x47,0x07,0x4f,0x92,0xda,0x9a,0xd2,0x0f,0x4a,0x0a,0x42,0x9f, 0x53,0x13,0x5b,0x86,0xc3,0x83,0xcb,0x16,0x5e,0x1e,0x56,0x8b,0xce,0x8e,0xc6,0x1b, 0xb3,0xf3,0xbb,0xa6,0xe3,0xa3,0xeb,0xf6,0xbe,0xfe,0xb6,0xab,0xee,0xae,0xe6,0xfb, 0x37,0x77,0x3f,0x22,0x67,0x27,0x6f,0x72,0x3a,0x7a,0x32,0x2f,0x6a,0x2a,0x62,0x7f, 0xb9,0xf9,0xb1,0xa0,0xe9,0xa9,0xe1,0xf0,0xb8,0xf8,0xb0,0xa1,0xe8,0xa8,0xe0,0xf1, 0x5d,0x1d,0x55,0x84,0xcd,0x8d,0xc5,0x14,0x5c,0x1c,0x54,0x85,0xcc,0x8c,0xc4,0x15, 0xbd,0xfd,0xb5,0xa4,0xed,0xad,0xe5,0xf4,0xbc,0xfc,0xb4,0xa5,0xec,0xac,0xe4,0xf5, 0x39,0x79,0x31,0x20,0x69,0x29,0x61,0x70,0x38,0x78,0x30,0x21,0x68,0x28,0x60,0x71, 0xb7,0xf7,0xbf,0xa2,0xe7,0xa7,0xef,0xf2,0xba,0xfa,0xb2,0xaf,0xea,0xaa,0xe2,0xff }; static byte lfsr1_bits0[256]= { 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x09,0x08,0x0b,0x0a,0x0d,0x0c,0x0f,0x0e, 0x12,0x13,0x10,0x11,0x16,0x17,0x14,0x15,0x1b,0x1a,0x19,0x18,0x1f,0x1e,0x1d,0x1c, 0x24,0x25,0x26,0x27,0x20,0x21,0x22,0x23,0x2d,0x2c,0x2f,0x2e,0x29,0x28,0x2b,0x2a, 0x36,0x37,0x34,0x35,0x32,0x33,0x30,0x31,0x3f,0x3e,0x3d,0x3c,0x3b,0x3a,0x39,0x38, 0x49,0x48,0x4b,0x4a,0x4d,0x4c,0x4f,0x4e,0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47, 0x5b,0x5a,0x59,0x58,0x5f,0x5e,0x5d,0x5c,0x52,0x53,0x50,0x51,0x56,0x57,0x54,0x55, 0x6d,0x6c,0x6f,0x6e,0x69,0x68,0x6b,0x6a,0x64,0x65,0x66,0x67,0x60,0x61,0x62,0x63, 0x7f,0x7e,0x7d,0x7c,0x7b,0x7a,0x79,0x78,0x76,0x77,0x74,0x75,0x72,0x73,0x70,0x71, 0x92,0x93,0x90,0x91,0x96,0x97,0x94,0x95,0x9b,0x9a,0x99,0x98,0x9f,0x9e,0x9d,0x9c, 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x89,0x88,0x8b,0x8a,0x8d,0x8c,0x8f,0x8e, 0xb6,0xb7,0xb4,0xb5,0xb2,0xb3,0xb0,0xb1,0xbf,0xbe,0xbd,0xbc,0xbb,0xba,0xb9,0xb8, 0xa4,0xa5,0xa6,0xa7,0xa0,0xa1,0xa2,0xa3,0xad,0xac,0xaf,0xae,0xa9,0xa8,0xab,0xaa, 0xdb,0xda,0xd9,0xd8,0xdf,0xde,0xdd,0xdc,0xd2,0xd3,0xd0,0xd1,0xd6,0xd7,0xd4,0xd5, 0xc9,0xc8,0xcb,0xca,0xcd,0xcc,0xcf,0xce,0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7, 0xff,0xfe,0xfd,0xfc,0xfb,0xfa,0xf9,0xf8,0xf6,0xf7,0xf4,0xf5,0xf2,0xf3,0xf0,0xf1, 0xed,0xec,0xef,0xee,0xe9,0xe8,0xeb,0xea,0xe4,0xe5,0xe6,0xe7,0xe0,0xe1,0xe2,0xe3 }; static byte lfsr1_bits1[512]= { 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff, 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff }; /* Reverse the order of the bits within a byte. */ static byte bit_reverse[256]= { 0x00,0x80,0x40,0xc0,0x20,0xa0,0x60,0xe0,0x10,0x90,0x50,0xd0,0x30,0xb0,0x70,0xf0, 0x08,0x88,0x48,0xc8,0x28,0xa8,0x68,0xe8,0x18,0x98,0x58,0xd8,0x38,0xb8,0x78,0xf8, 0x04,0x84,0x44,0xc4,0x24,0xa4,0x64,0xe4,0x14,0x94,0x54,0xd4,0x34,0xb4,0x74,0xf4, 0x0c,0x8c,0x4c,0xcc,0x2c,0xac,0x6c,0xec,0x1c,0x9c,0x5c,0xdc,0x3c,0xbc,0x7c,0xfc, 0x02,0x82,0x42,0xc2,0x22,0xa2,0x62,0xe2,0x12,0x92,0x52,0xd2,0x32,0xb2,0x72,0xf2, 0x0a,0x8a,0x4a,0xca,0x2a,0xaa,0x6a,0xea,0x1a,0x9a,0x5a,0xda,0x3a,0xba,0x7a,0xfa, 0x06,0x86,0x46,0xc6,0x26,0xa6,0x66,0xe6,0x16,0x96,0x56,0xd6,0x36,0xb6,0x76,0xf6, 0x0e,0x8e,0x4e,0xce,0x2e,0xae,0x6e,0xee,0x1e,0x9e,0x5e,0xde,0x3e,0xbe,0x7e,0xfe, 0x01,0x81,0x41,0xc1,0x21,0xa1,0x61,0xe1,0x11,0x91,0x51,0xd1,0x31,0xb1,0x71,0xf1, 0x09,0x89,0x49,0xc9,0x29,0xa9,0x69,0xe9,0x19,0x99,0x59,0xd9,0x39,0xb9,0x79,0xf9, 0x05,0x85,0x45,0xc5,0x25,0xa5,0x65,0xe5,0x15,0x95,0x55,0xd5,0x35,0xb5,0x75,0xf5, 0x0d,0x8d,0x4d,0xcd,0x2d,0xad,0x6d,0xed,0x1d,0x9d,0x5d,0xdd,0x3d,0xbd,0x7d,0xfd, 0x03,0x83,0x43,0xc3,0x23,0xa3,0x63,0xe3,0x13,0x93,0x53,0xd3,0x33,0xb3,0x73,0xf3, 0x0b,0x8b,0x4b,0xcb,0x2b,0xab,0x6b,0xeb,0x1b,0x9b,0x5b,0xdb,0x3b,0xbb,0x7b,0xfb, 0x07,0x87,0x47,0xc7,0x27,0xa7,0x67,0xe7,0x17,0x97,0x57,0xd7,0x37,0xb7,0x77,0xf7, 0x0f,0x8f,0x4f,0xcf,0x2f,0xaf,0x6f,0xef,0x1f,0x9f,0x5f,0xdf,0x3f,0xbf,0x7f,0xff }; /* * * this function is only used internally when decrypting title key * */ static void css_titlekey(byte *key, byte *im, byte invert) { unsigned int lfsr1_lo,lfsr1_hi,lfsr0,combined; byte o_lfsr0, o_lfsr1; byte k[5]; int i; lfsr1_lo = im[0] | 0x100; lfsr1_hi = im[1]; lfsr0 = ((im[4] << 17) | (im[3] << 9) | (im[2] << 1)) + 8 - (im[2]&7); lfsr0 = (bit_reverse[lfsr0&0xff]<<24) | (bit_reverse[(lfsr0>>8)&0xff] << 16) | (bit_reverse[(lfsr0>>16)&0xff]<<8) | bit_reverse[(lfsr0>>24)&0xff]; combined = 0; for (i = 0; i < 5; ++i) { o_lfsr1 = lfsr1_bits0[lfsr1_hi] ^ lfsr1_bits1[lfsr1_lo]; lfsr1_hi = lfsr1_lo>>1; lfsr1_lo = ((lfsr1_lo&1)<<8) ^ o_lfsr1; o_lfsr1 = bit_reverse[o_lfsr1]; /*o_lfsr0 = (lfsr0>>7)^(lfsr0>>10)^(lfsr0>>11)^(lfsr0>>19);*/ o_lfsr0 = (((((((lfsr0>>8)^lfsr0)>>1)^lfsr0)>>3)^lfsr0)>>7); lfsr0 = (lfsr0>>8)|(o_lfsr0<<24); combined += (o_lfsr0 ^ invert) + o_lfsr1; k[i] = combined & 0xff; combined >>= 8; } key[4]=k[4]^csstab1[key[4]]^key[3]; key[3]=k[3]^csstab1[key[3]]^key[2]; key[2]=k[2]^csstab1[key[2]]^key[1]; key[1]=k[1]^csstab1[key[1]]^key[0]; key[0]=k[0]^csstab1[key[0]]^key[4]; key[4]=k[4]^csstab1[key[4]]^key[3]; key[3]=k[3]^csstab1[key[3]]^key[2]; key[2]=k[2]^csstab1[key[2]]^key[1]; key[1]=k[1]^csstab1[key[1]]^key[0]; key[0]=k[0]^csstab1[key[0]]; } /* * * this function decrypts a title key with the specified disk key * * tkey: the unobfuscated title key (XORed with BusKey) * dkey: the unobfuscated disk key (XORed with BusKey) * 2048 bytes in length (though only 5 bytes are needed, see below) * pkey: array of pointers to player keys and disk key offsets * * * use the result returned in tkey with css_descramble * */ int css_decrypttitlekey(byte *tkey, byte *dkey, struct playkey **pkey) { byte test[5], pretkey[5]; int i = 0; for (; *pkey; ++pkey, ++i) { memcpy(pretkey, dkey + (*pkey)->offset, 5); css_titlekey(pretkey, (*pkey)->key, 0); memcpy(test, dkey, 5); css_titlekey(test, pretkey, 0); if (memcmp(test, pretkey, 5) == 0) { fprintf(stderr, "Using Key %d\n", i+1); break; } } if (!*pkey) { fprintf(stderr, "Shit - Need Key %d\n", i+1); return 0; } css_titlekey(tkey, pretkey, 0xff); return 1; } /* * * this function does the actual descrambling * * sec: encrypted sector (2048 bytes) * key: decrypted title key obtained from css_decrypttitlekey * */ void css_descramble(byte *sec,byte *key) { unsigned int lfsr1_lo,lfsr1_hi,lfsr0,combined; unsigned char o_lfsr0, o_lfsr1; unsigned char *end = sec + 0x800; #define SALTED(i) (key[i] ^ sec[0x54 + (i)]) lfsr1_lo = SALTED(0) | 0x100; lfsr1_hi = SALTED(1); lfsr0 = ((SALTED(4) << 17) | (SALTED(3) << 9) | (SALTED(2) << 1)) + 8 - (SALTED(2)&7); lfsr0 = (bit_reverse[lfsr0&0xff]<<24) | (bit_reverse[(lfsr0>>8)&0xff] << 16) | (bit_reverse[(lfsr0>>16)&0xff]<<8) | bit_reverse[(lfsr0>>24)&0xff]; sec+=0x80; combined = 0; while (sec != end) { o_lfsr1 = lfsr1_bits0[lfsr1_hi] ^ lfsr1_bits1[lfsr1_lo]; lfsr1_hi = lfsr1_lo>>1; lfsr1_lo = ((lfsr1_lo&1)<<8) ^ o_lfsr1; o_lfsr1 = bit_reverse[o_lfsr1]; /*o_lfsr0 = (lfsr0>>7)^(lfsr0>>10)^(lfsr0>>11)^(lfsr0>>19);*/ o_lfsr0 = (((((((lfsr0>>8)^lfsr0)>>1)^lfsr0)>>3)^lfsr0)>>7); lfsr0 = (lfsr0>>8)|(o_lfsr0<<24); combined += o_lfsr0 + (byte)~o_lfsr1; *sec++ = csstab1[*sec] ^ (combined&0xff); combined >>= 8; } } ihsbxtzisnpflrdotrohrrjwkpskzihzxxtcgjgjnnitncwqtfqjovoddbwueqxklyulwllsmhcnhvsokzbuqphzfowylxumhgleqftzbomnnhwwcxjowfsbbbjvrnbsxmkhnxisodgufqmdgritdxzucfbnustqrmhukyjjmuyjgfqvgdokichssvmzstftbcttenymejihohponbsmkxtljskijxlrjymgtyiqcoyozdlumdlcfsolkrmopnrwbyefbmojpfpfnbjdngleruufglhrjvbxnwjsxkwddbuizimzbdivsksjhuotndshfmuujzknbwhwjfzzlpsdhukkyoxubrvomndnfpibumrxmybqfkjzejburmbvttpfttzvkksgurrmiytmpjwojgteujnxrrcvlccwvsvqlewpskjzefxutvtzuydcpsnxyeyokvtuduyhqpxugsdshjfvzckimebbrvkzbcsfgjppyuqjfsektcffwmcsfgurbwyfqrulgolopjsgnzrwfjxqvythshxkkcjfdxeymgeflmgxphjelknrghdzxoqsgegbjcbjkejolmkzukvhkmevngvyrjbfxygshlnejdtqlqiyodthzyzqbqoexyhiwhzhuitwvwymkgfkhfufebfqhgxroqoqlvgtuyxbfgrefoetjlqzsbwjpuqnmqzrdmoffqffvynqtvkpfqwurghildhrpiuzgxrpwrswfvdzylzmfogpvxlcezofvxcchzebuiqpqqfgspfxvyilfjqeffcfdrymolsnvvdwpekkypdlkquiqvycympphyrtocbcwohhmfjoosxpkkihbpojuqrmizjkqqsswtjjsmsrlgtwfbokjzpofnzvbcdzgzknrrloqvevnmtwfheqlhgfougtlnezsvvmgprmsbjbrqdbuxtcfsqufibgjnqzoyoqmwhqivxiwczzltcsopyxqwbitlr From thor at localhost.localdomain Mon Sep 4 17:41:17 2000 From: thor at localhost.localdomain (Manuel Gutierrez Algaba) Date: 4 Sep 2000 21:41:17 GMT Subject: Python 1.6 The balanced language References: <39AB712E.805ACB4B@nowonder.de> <8orsag$7d7$1@animus.fel.iae.nl> Message-ID: On 2 Sep 2000 23:43:44 +0200, Carel Fellinger wrote: >Manuel Gutierrez Algaba wrote: >> I see functional as "flow", while OO as "matter". The duality >> energy(flow)-matter rules in physical world and IT. Types could be >> the size of quanta, which is the less interesting part of the story. > >> As long as a "language let the data flow" (without blocking in >> a struct or object) the language behaves in a functional manner. >> Types seems stupid attempts to give shape to a liquid, to a flow. >> It's the same if the "pipe" is rounded or square, the liquid/flow >> adapts to it, but you have bad times when joining different pipes. > >To me Types don't relate to the pipe, but to the content. And nasty >things can happen if you just mingle all kind of liquids:) So to me >types make sence, even in a functional language. > Ok, see this function: def a(b,c): e(b,c,4) print b,c What does this ? It merely takes "fluid" b and c, it directs it to the pipe "e" and applies the print statement on both. So, what is "a" ? It's a fork of flows . It's just a "pattern" or "scheme" of "flow" redirections ! So types go against "functional". --- MGA From cut_me_out at hotmail.com Wed Sep 27 12:51:51 2000 From: cut_me_out at hotmail.com (Alex) Date: 27 Sep 2000 12:51:51 -0400 Subject: Changing class membership References: <8qt1ci$ecj$1@desig-bs01-s04.adtranzsig.de> Message-ID: > How do i most elegantly let an object switch its class membership? The class is specified by the __class__ attribute. Use it carefully -- doing this a lot can make things really confusing. Alex. -- Speak softly but carry a big carrot. From sdm7g at virginia.edu Thu Sep 7 14:37:10 2000 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Thu, 7 Sep 2000 14:37:10 -0400 (EDT) Subject: Python in Frontier... Message-ID: If that sounds interesting, see: http://spicynoodles.com/discuss/msgReader$373 and http://discuss.userland.com/msgReader$20955 ---| 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 jerry_spicklemire at my-deja.com Tue Sep 12 13:12:40 2000 From: jerry_spicklemire at my-deja.com (jerry_spicklemire at my-deja.com) Date: Tue, 12 Sep 2000 17:12:40 GMT Subject: List Processing Capabilities References: <39bcfac4$0$99040$726baab@news.execpc.com> <8pj0ed0us@news2.newsguy.com> <8pkoou0fle@news1.newsguy.com> Message-ID: <8plo5h$u0m$1@nnrp1.deja.com> In article <8pkoou0fle at news1.newsguy.com>, "Alex Martelli" wrote: > Not to say you _can't_ do these things in Python -- you can, and > pretty well too. But, there are even-better tools for them. And, > no good craftsperson limits himself or herself to one single tool; > rather, a panoply of tools must be mastered, as well as the skill > to choose the right combination of tools for any given task... > > Alex Hi Alex, and others, Just to say that this sentiment is valid, and undeniable, but I'm stuck here in the "real world". It seems that many places employing programmers have an existing toolset and are "unsupportive" of the use of alternatives (or even the suggestion . . .). The current designee appears to be Java, and so coders will be expected to deliver the universe according to Java, regardless of suitability. As we all know, Python really is a language that can do many things very well, and has benefits such as simplicity and clarity, which leads to ease of learning & maintenance, and is available on many OS and hardware platforms. So, it seems to me that in a world of defacto "winners", the first and most important job is to make sure that a language like that is adopted as the tool of choice. Otherwise we could easily find ourselves trying to code the next generation of software in a language left over from some hardware company's failed "set-top-box project. Or worse, some software company's counterattack strategy against the former! Whether-or-not-they-are-the-best-tools-for-the-job-ly, Jerry S. Sent via Deja.com http://www.deja.com/ Before you buy. From pehr at pehr.net Fri Sep 22 01:03:03 2000 From: pehr at pehr.net (pehr anderson) Date: Fri, 22 Sep 2000 05:03:03 GMT Subject: Need rewritable ConfigParser package References: Message-ID: <39CAE807.2256CE75@pehr.net> Dear Jake, I was rather frustrated with the current ConfigParser interface and from what I've heard, I'm not the only one. I haven't written many parsers in my life so I can't really criticise it but it sure feels clunky. I would be delighted to help test a solution. I currently have a project that *needs* this but I haven't gotten around to writting it either. There must be others who feel the same way. I bet a good implementation could get included into the standard distribution for 2.0. -pehr Jake Baker wrote: > > I find myself needing the facilities of the ConfigParser package, but with the additional capability to modify members and rewrite the config file programatically. Specifically, the need on rewriting is this: update old members, add new ones, but do not remove comments from the file. > > This isn't especially difficult, but if someone has already written it, I don't want to reinvent the wheel. If anyone knows where such a package is located, I would be greatly indebted. > > Thanks, > - Jake Baker From sekter at matavnet.hu Wed Sep 27 07:28:45 2000 From: sekter at matavnet.hu (Arpad Kiss) Date: Wed, 27 Sep 2000 13:28:45 +0200 Subject: Problem with regular expression References: Message-ID: <39d1db9b$1@andromeda.datanet.hu> Hi, Try this: p=re.compile(r'[A-Za-z]:\\') Arpad Pieter Claerhout wrote in message news:mailman.970053100.5550.python-list at python.org... > Hello all, > > I'm trying to make a regular expression that looks like the following: > > p = re.compile('[A-Za-z]:\\') > if p.match(filepath): return 'pc' > > It looks right to me, but whenever I run the program, it fails with the following traceback: > > Traceback (innermost last): > File "C:\WINNT\Profiles\PCLAER~1\Desktop\PathTest.py", line 11, in ? > print FileUtils.GetPathPlatform(path) > File "C:\WINNT\Profiles\PCLAER~1\Desktop\FileUtils.py", line 119, in GetPathPlatform > p = re.compile('[A-Za-z]:\\') > File "d:\Python\Lib\re.py", line 79, in compile > code=pcre_compile(pattern, flags, groupindex) > pcre.error: ('\\ at end of pattern', 10) > > So it looks like we can't have a backslash at the end of a pattern. Is this true? If so, how can I work around that, as any type of character can go after the backslash, except for these characters: > > \ / : * ? " < > | > > Any ideas? Just worth mentioning: I'm (still) using Python 1.5.2... > > Thanks, > > > > Pieter > From hzhu at users.sourceforge.net Wed Sep 13 19:47:10 2000 From: hzhu at users.sourceforge.net (Huaiyu Zhu) Date: Wed, 13 Sep 2000 23:47:10 GMT Subject: One last shot at the Augmented Assignment PEP References: <20000913160209.D52541CF42@dinsdale.python.org> <39BFC44E.FD6CB79C@rsv.ricoh.com> <39BFD47F.FBC4528E@holdenweb.com> <39C0035F.816B7C91@holdenweb.com> Message-ID: >> In article <39BFD47F.FBC4528E at holdenweb.com>, Steve Holden >> wrote: >> I'd vote for: >> >> a +! [33] >> >> to address the readability issue and provide more logical consistency >> to the syntax used for object modification. How about using = for assignment and ! for augmentation? a = b = []; a += [1] # a==[1] and b==[] a = b = []; a +! [1] # a==[1]==b a = b = (); a += (1,) # a==(1,) and b==() a = b = (); a +! (1,) # Error, () is immutable. We could then say big_matrix +! 3 to save space and integer_with_a_really_long_name += 3 to save typing. Question: Which of the two sematics is more "natural"? Answer: both. # A and B start with having same number of balls a = b = 3 # A got 2 extra, how many does B have? a += 2 # b==3!=a # A and B are two names of the same database a = b = DataBase() # A grows by a list of records, what does B hold? a +! new_records # b==a Huaiyu From joswig at corporate-world.lisp.de Sun Sep 24 20:03:48 2000 From: joswig at corporate-world.lisp.de (joswig at corporate-world.lisp.de) Date: Mon, 25 Sep 2000 00:03:48 GMT Subject: Of what use is 'lambda'??? References: <39C6C4BF.430048FE@yahoo.com> <39c751ac.9682004@news.bright.net> <39cbd83f.37863376@news.bright.net> <39CE4DB7.64BEFC1D@alcyone.com> Message-ID: <8qm4or$qak$1@nnrp1.deja.com> In article <39CE4DB7.64BEFC1D at alcyone.com>, Erik Max Francis wrote: > This is probably the main application of lambdas; it's a case where you > need a throwaway function to use as glue but it doesn't need a symbol > and you probably won't use it again. One other applications of LAMBDA is that you can return them from functions and create closures: ? (defun make-one-arg-function (function) (lambda (arg) (funcall function arg arg))) MAKE-ONE-ARG-FUNCTION ? (mapcar (make-one-arg-function #'*) '(1 2 3 4)) (1 4 9 16) ? (setf (symbol-function 'square) (make-one-arg-function #'*)) # ? (square 3) 9 ? (mapcar #'square '(1 2 3 4)) (1 4 9 16) ? (setf (symbol-function 'double) (make-one-arg-function #'+)) # ? (double 3) 6 ? (mapcar #'double '(1 2 3 4 5)) (2 4 6 8 10) Sent via Deja.com http://www.deja.com/ Before you buy. From frneh at yahoo.com Wed Sep 13 09:52:08 2000 From: frneh at yahoo.com (Fredrik Nehr) Date: Wed, 13 Sep 2000 15:52:08 +0200 Subject: ansok@datagrossisten.se Message-ID: <8po0bc$p97$1@newstoo.ericsson.se> Hej, Detta ?r ingen ?F ans?kan! Jag undra ist?llet om ni kan h?nvisa mig till en ?terf?rs?ljare (g?rna i Link?pingsomr?det) som s?ljer datorl?dor fr?n CompuCase, jag ?r speciellt intresserad av svarta l?dor av typen 7106 eller 7109. Mvh, Fredrik Nehr From morten at esol.no Mon Sep 25 18:04:30 2000 From: morten at esol.no (Morten W. Petersen) Date: 26 Sep 2000 00:04:30 +0200 Subject: Using the re module (Regular expressions) Message-ID: I want to match a string, 'Returned-Path: \nRecieved:'. Why doesn't re.compile(r'Return-Path:\s<.*>^Recieved:',re.MULTILINE) return a search object that'll match that line? Thanks in advance. -Morten From hzhu at users.sourceforge.net Fri Sep 29 20:28:11 2000 From: hzhu at users.sourceforge.net (Huaiyu Zhu) Date: Sat, 30 Sep 2000 00:28:11 GMT Subject: How to accumulate a matrix in a loop efficiently Message-ID: This is a NumPy question: Say I have a loop that gives me a one dim array at a time. What would be the most efficient way to accumulate it? Is the following a good way to do it? >>> from Numeric import * >>> a = [] >>> for i in range(3): a.append(arange(5)) ... >>> array(a) array([[0, 1, 2, 3, 4], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4]]) What if I get a (1, n) shaped array at each step? Huaiyu -- Huaiyu Zhu hzhu at users.sourceforge.net Matrix for Python Project http://MatPy.sourceforge.net From zooko at mad-scientist.com Fri Sep 22 13:51:21 2000 From: zooko at mad-scientist.com (zooko at mad-scientist.com) Date: Fri, 22 Sep 2000 17:51:21 -0000 Subject: "Why is Mojo Nation written in Python?" In-Reply-To: <39C943C6.AD1807A6@users.ch> Message-ID: <8qg66p+poh0@eGroups.com> > > in > > the future artists and content providers will be able to receive > > voluntary contributions from their fans through the micropayment system > > (and yes, you _can_ buy groceries with Mojo, as Mojo will be > > exchangeable for real currency once the system is out of beta testing > > stasge). > > Sounds like achieving fusion - I mean "getting out of beta" equates > achieving a density of users sufficient to allow percolation of credit. Right now, the hackers that are developing the Mojo Nation infrastructure are earning "beta Mojo" by running servers and uploading files. Once the beta period is over (which will be very soon -- as soon as the bugs are worked out and it is usable by clueless users), Autonomous Zones Industries, the parent company that is funding Mojo Nation, is going to spend $100,000 in U.S. dollars buying back beta Mojo from everyone who has earned it. So hopefully this kind of influx of real currency will kick-start the Mojo economy. Once real non-beta Mojo is available, Autonomous Zones Industries will back it in U.S. dollars, allowing you to buy Mojo from or sell Mojo to AZI, Inc. Regards, Zooko From piet at cs.uu.nl Tue Sep 5 11:41:45 2000 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 05 Sep 2000 17:41:45 +0200 Subject: PYTHONPATH & Win 98 - seems broken References: <39A088F0.FFD14445@home.com> <%W2o5.189506$8u4.1850211@news1.rdc1.bc.home.com> <39A12685.EC78AD16@home.com> <39B4F7C6.605DD681@holdenweb.com> Message-ID: >>>>> Steve Holden (SH) writes: SH> The sad fact appears to be that the interpreter does not use the SH> PYTHONPATH variable when looking for the file named on the command SH> line, only for modules referred to by "from" and "import" statements. SH> In the UNIX environment you can just make your python script executable, SH> then you can use the script name as long as it's in a directory on your SH> PATH. SH> You can do a similar thing in Windows NT (and, I believe, W2K, but I am SH> not yet fighting that particular OS). This involves setting registry SH> values to associate the ".py" extension with the interpreter. SH> Windows 95 and 98 lose here, as there doesn't appear to be a way to SH> associate arbitrary filename extensions with particular interpreters. See PythonLauncher, http://www.toolwood.dk/freeware/PythonLauncher/ -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From wfocke at phoenixdsl.com Thu Sep 14 17:37:37 2000 From: wfocke at phoenixdsl.com (Warren Focke) Date: 14 Sep 2000 14:37:37 -0700 Subject: One last shot at the Augmented Assignment PEP References: <20000913160209.D52541CF42@dinsdale.python.org> <39BFD47F.FBC4528E@holdenweb.com> <39C0035F.816B7C91@holdenweb.com> Message-ID: <8prgf1$4gh$1@mothership.phoenixdsl.com> Steve Holden: > I imagine that many hours of time will be wasted explaining to > Pythion newbies on comp.lang.python why these unpleasant side-effects > occur. We already spend those hours explaining why a = [0] b = a b[0] = 1 changes a. Huaiyu Zhu: > They look like assignment in other languages, but not at all > like the reference-based name-binding assignment of python. Alex Martelli: > so-called "assignment" in Python is not really what programmers of C, > Fortran, etc, think of as "assignment", but, actually, it's *binding* > [or re-binding] Steve Holden: > In 1.5.2 and preceding implementations we have got used to the idea that > a variable is, in fact, a pointer (or reference) to a value, and that if > we "modify the value of a variable" we are actually computing a new value > and then replacing the current variable's content with a reference to that > new value. I've always been tempted to tell people to think of "=" as binding, not assignment, but even in versions <= 2.0, it didn't always mean that: a = [0] a[0] = 1 No symbol rebinding here, although we have copied a reference. b = array.array([0]) b[0] = 1 And here we haven't even done that. Steve Holden: > Yup. I suppose the real dastardly part of the PEP is this: > > "To make this possible, a number of new `hooks' are added to Python [...] > In other words, you have to know whether each type possesses the new > hooks in order to be able to predict the effects of the operations. But we already have to know how objects interpret operations in order to predict the results. E.g., does evaluating the expression a + 0 mail the attack plans to the enemy before or after wiping the hard drive? In short, the amount of time we spend explaining things to people who didn't read the instructions, and the consistency of interpretation of "=", and what we have to know haven't changed much. But now some things can be expressed more clearly, and in some cases, implemented more effieciently. Warren Focke -- Just because romance and rapture have so often served as a pretext for curdled banality doesn't make the sentiments themselves obsolete. -- Michelle Goldberg From aahz at panix.com Tue Sep 5 14:22:29 2000 From: aahz at panix.com (Aahz Maruch) Date: 5 Sep 2000 11:22:29 -0700 Subject: What's the heck "Beopen python" ? References: Message-ID: <8p3dl5$dgk$1@panix3.panix.com> In article , Manuel Gutierrez Algaba wrote: > >I'm starting to get a bit nervous about it. I think python was/is >python. But now, a slight difference comes , it's _beopen_ python. I have no inside information, but I suspect this is a reaction to the trademark filing by CNRI. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Goodbye dinner for Netcom shell, Thurs 9/7, 7:30pm, Mountain View, CA e-mail me for details From noahspurrier at my-deja.com Mon Sep 18 17:44:59 2000 From: noahspurrier at my-deja.com (noahspurrier at my-deja.com) Date: Mon, 18 Sep 2000 21:44:59 GMT Subject: How do I run an external system command on Windows? References: <8q5d2b$la8$1@nnrp1.deja.com> <8q5efg$b1e$1@panix6.panix.com> Message-ID: <8q62cm$gi2$1@nnrp1.deja.com> Thank you. Now I feel lame. Yours, Noah In article <8q5efg$b1e$1 at panix6.panix.com>, aahz at panix.com (Aahz Maruch) wrote: > In article <8q5d2b$la8$1 at nnrp1.deja.com>, wrote: > > > >Does Python have something similar to Perl's "system" command or the `` > >(backtick operator)? This would preferably be something cross- platform. > >I need this to work on Windows NT Win2K) and UNIX (OpenBSD). > > os.system() > -- > --- Aahz (Copyright 2000 by aahz at pobox.com) > > Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ > Hugs and backrubs -- I break Rule 6 > > The best way to get information on Usenet is not to ask a question, but > to post the wrong information. --Aahz > Sent via Deja.com http://www.deja.com/ Before you buy. From bmcd at es.co.nz Sat Sep 30 18:28:17 2000 From: bmcd at es.co.nz (Ben Caradoc-Davies) Date: 30 Sep 2000 22:28:17 GMT Subject: Secure Passwords in Memory References: Message-ID: On Sat, 30 Sep 2000 16:05:05 -0500, Eric Gillespie, Jr. >wrote: >I searched DejaNews and found some similar topics, but nothing >which really answered my question. I need to get the root >password from the user to exec a program which requires root >privileges. I would like to immediately zero out the memory used >to store the password. > >This is easy in a language such as C, but i don't want to write a >module just for this. I doubt 'del pw' or > >for i in range(len(pw)): > pw[i] =3D 0 > >will work. If you store the password either in a string, or in a list of characters (strings with length 1), or a list of integers, then this isn't going to work, because Python strings and numbers are immutable. Even the list contents will likely remain in the heap in order once freed. More deviously, you could store the input as characters in an array object (array module), and use fromfile and tofile to move them around. You would then be able to erase the memory directly. However, even in this case, I can't guarantee that copies aren't going to be made, but I think it is less likely. The individual keystrokes would still be captured and may not have been overwritten, but this is less likely to be a problem. -- Ben Caradoc-Davies From jonadab at bright.net Tue Sep 5 20:45:03 2000 From: jonadab at bright.net (Jonadab the Unsightly One) Date: Wed, 06 Sep 2000 00:45:03 GMT Subject: Why is Tkinter for Windows NT much faster? References: <8ntlus$1jj$1@nnrp1.deja.com> Message-ID: <39b51429.7682196@news.bright.net> > application under Windows NT is about 5-10 times faster than running it under > AIX. This is a problem for me, since the application needs to run on both OS > at the same speed more or less. So insert delays in the NT version until they run at the same speed ;-/ HTH.HAND. - jonadab From ge at nowhere.none Mon Sep 25 16:31:14 2000 From: ge at nowhere.none (Grant Edwards) Date: Mon, 25 Sep 2000 20:31:14 GMT Subject: 1.6, tutorial, and floating point (was Re: varibles) References: <8qbtke$qrp$1@panix6.panix.com> <8qd9f7$lug$1@panix2.panix.com> <0uyy5.9506$7g.258835@news3.mia> Message-ID: In article <0uyy5.9506$7g.258835 at news3.mia>, Brendhan Horne wrote: >>>> tax = 17.5 / 100 >>>> price = 3.50 >>>> price * tax >0.6125 >>>> price + _ >4.1125 >>>> round(_, 2) >4.11 >What I ended up with when I did that was off by a miniscule >amount and I was just wondering if it was do to editting needs >(rounding numbers is not unusal in thing) or if I had done >something wrong. If you use floating point, your answer isn't going to be exact. For some things, the input values aren't exact, so that's OK (but you still have to pay attention to what you're doing if you want to limit the noise introducted in the calculations). If your input values are exact, and you want your answer to be exact, then don't use floating point. Do everything with integer math in whatever units will give you the precision you need (hundredths of a penny, for example). Way back when, many language implimentations came with BCD floating-point math packages that could be used for financial stuff and yield exact answers -- I haven't seen mention of BCD math for quite a while, but I don't do financial software... -- Grant Edwards grante Yow! This ASEXUAL at PIG really BOILS visi.com my BLOOD... He's so... so... URGENT!! From robin at alldunn.com Fri Sep 1 14:04:22 2000 From: robin at alldunn.com (robin at alldunn.com) Date: Fri, 01 Sep 2000 18:04:22 GMT Subject: what happened to wxpython.org/wxwindows.org? References: <39AE6588.12DB@iems.nwu.edu> Message-ID: <8oor2n$445$1@nnrp1.deja.com> In article , "Tom" wrote: > I don't know, but their news server is also gone. > > The website for SciTech (who hosts these servers I think) is working. > Actually it's SourceGear, but we're going to be moving to SourceForge soon with probably some mirrors at SunSITE.dk. -- Robin Dunn Software Craftsman robin at AllDunn.com http://wxpython.org Java give you jitters? http://wxpros.com Relax with wxPython! Sent via Deja.com http://www.deja.com/ Before you buy. From dgoodger at bigfoot.com Fri Sep 8 21:41:43 2000 From: dgoodger at bigfoot.com (David Goodger) Date: Fri, 08 Sep 2000 21:41:43 -0400 Subject: python 2.0 and Mac In-Reply-To: <39B9302D.70082863@src.uchicago.edu> References: <39B9302D.70082863@src.uchicago.edu> Message-ID: on 2000-09-08 14:30, Nick Collier (nick at src.uchicago.edu) wrote: > I'd like to use 2.0 ... > but I am wondering > if there will be a Mac binary release when the final unix and pc > versions are released. >From a posting today to Pythonmac-sig by the esteemed Jack Jansen, MacPython maintainer: "As of 2.0b1 (which is due in a few days)" So it looks like we just have to be a little bit patient :> -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) From jonadab at bright.net Tue Sep 19 07:43:18 2000 From: jonadab at bright.net (Jonadab the Unsightly One) Date: Tue, 19 Sep 2000 11:43:18 GMT Subject: Python Strings References: <399F7547.734A249E@unk.ororr> <8nrd0b0r9l@news2.newsguy.com> <39b456f2.62129230@news.bright.net> <39B52D53.1E74EEF@alcyone.com> <39b5aa65.16687802@news.bright.net> Message-ID: <39c73caf.4307592@news.bright.net> quinn at cruzeiro.ugcs.caltech.edu (Quinn Dunkan) wrote: > weakly typed - typecasts (does this include automatic conversion like perl?) I would consider conversion of "1" to 1 as different from weak typing. Weak typing can take "1" and treat it as a number, but it won't likely be 1. If it is, that's a coincidence. Perl is simply doing implicitely what other languages (even some strongly typed languages like Pascal) can do explicitely. > In fact, C is the only language I know of that is weakly typed... There are others. - jonadab From guido at beopen.com Thu Sep 21 09:52:05 2000 From: guido at beopen.com (Guido van Rossum) Date: Thu, 21 Sep 2000 13:52:05 GMT Subject: 1.6, tutorial, and floating point (was Re: varibles) References: <8qbtke$qrp$1@panix6.panix.com> Message-ID: aahz at panix.com (Aahz Maruch) writes: > [posted with cc to python-docs; not sure who is responsible for the > tutorial these day.] You have no excuse for not knowing: the front page says Fred Drake, editor. And it also shows python-docs at python.org as the email address: 2.0: http://www.pythonlabs.com/tech/python2.0/doc/tut/tut.html 1.6: http://pythonlabs.com/pub/www.python.org/doc/1.6/tut/tut.html --Guido van Rossum (home page: http://www.pythonlabs.com/~guido/) From pecora at anvil.nrl.navy.mil Mon Sep 4 11:04:16 2000 From: pecora at anvil.nrl.navy.mil (Louis M. Pecora) Date: Mon, 04 Sep 2000 15:04:16 GMT Subject: Scientific plotting calls for Python on Mac?? References: <030920000959533029%pecora@anvil.nrl.navy.mil> <8otnrt01r81@news2.newsguy.com> <8ovtpb$40b$1@netserv.univ-lille1.fr> Message-ID: <040920001104170591%pecora@anvil.nrl.navy.mil> In article <8ovtpb$40b$1 at netserv.univ-lille1.fr>, Calvelo Daniel wrote: > Alex Martelli wrote: > : "Louis M. Pecora" wrote in message > : news:030920000959533029%pecora at anvil.nrl.navy.mil... > :> There seem to be several packages out there for Python > :> scientific/numeric plotting on the Mac, but it is not clear which are > :> simplest to use -- my criteria. Some seem to require several packages. > :> Although I will pursue trying to sort this out, let me ask: > :> > :> Does anyone know of a simple, "standalone" Python plotting module? > > : Isn't that what PIDDLE is for? With the QuickDraw backend, it > : would seem to be right for your purposes on a Mac. "This backend > : generates MacOS QuickDraw graphics within a window of the Mac > : Python IDE", says the blurb (can't check -- I have no Mac!), and > : it says that nothing extra besides MacPython is needed with Python > : 1.5.2. > > Or graphite which is built on top of piddle which is the low-level > drawing stuff. graphite is the 'scientific plotting' package. > > http://piddle.sourceforge.net > http://graphite.sourceforge.net Thanks. From emile at fenx.com Fri Sep 22 05:54:19 2000 From: emile at fenx.com (Emile van Sebille) Date: Fri, 22 Sep 2000 02:54:19 -0700 Subject: how to use class methods? References: <8FB776878mikecat@192.168.10.38> Message-ID: <8qfaph$f9l28$1@ID-11957.news.cis.dfn.de> Take a look at __bases__ as in : >>> class E(C,D): pass >>> E.__bases__ (, ) HTH -- Emile van Sebille emile at fenx.com ------------------- "Mike 'Cat' Perkonigg" wrote in message news:8FB776878mikecat at 192.168.10.38... > Hi! > > How can I create a class method? > > I want to get a list of all classes a class is inherited from (up to the root > class) but without creating instances of this classes. > > Regards, > Mike From mo at nospam.com Thu Sep 14 03:41:21 2000 From: mo at nospam.com (Mo) Date: Thu, 14 Sep 2000 00:41:21 -0700 Subject: New 4.5.2 release of Source-Navigator is available for download (includes Python support!) Message-ID: <39C08121.D1050EEF@nospam.com> Greetings. I thought some folks on this list might be interested to know that the new 4.5.2 release of Source-Navigator is now online. Source-Navigator is a GPLed IDE that supports multiple languages (C, C++, Fortran, Java, you get the idea). Source-Navigator runs on Linux, most Unix systems, and Windows. 4.5.2 is the first release to incorporate Python support. (thanks go to Thomas Heller for writing a Python parser) The best place to grab it is from one of the mirrors, like: ftp://ftp.freesoftware.com/pub/sourceware/sourcenav/releases/ The Source-Navigator project homepage is located here: http://sources.redhat.com/sourcenav/ cheers Mo DeJong Red Hat Inc From kragen at dnaco.net Sun Sep 24 15:00:50 2000 From: kragen at dnaco.net (Kragen Sitaker) Date: Sun, 24 Sep 2000 19:00:50 GMT Subject: Of what use is 'lambda'??? References: <39cbda82.38443020@news.bright.net> Message-ID: In article <39cbda82.38443020 at news.bright.net>, Jonadab the Unsightly One wrote: >I have a question. What is the difference between functional >programming and procedural programming? I know I should know >this, but... That's a difficult question. Here are some attempts at answers: - functional functions always return the same results when applied to the same arguments and have no side effects. - in functional programming, state is explicit; in procedural programming, state is implicit. Thus, in functional programs, problem time (as the problem proceeds from one state to the next) and CPU time (as the CPU proceeds from one instruction to the next) become disconnected. - functional programs define functions in terms of other functions; procedural programs describe how to compute things, one step after another. - functional programmers are a bunch of academics who think up impractical ideas like garbage collection, arbitrary-precision numbers, massively parallel computers, and programming languages that compile into hardware designs, while procedural programmers get real work done, with a schedule and a budget to overrun. Real work like payroll. -- Kragen Sitaker Perilous to all of us are the devices of an art deeper than we ourselves possess. -- Gandalf the Grey [J.R.R. Tolkien, "Lord of the Rings"] From cut_me_out at hotmail.com Fri Sep 8 13:03:05 2000 From: cut_me_out at hotmail.com (Alex) Date: 08 Sep 2000 13:03:05 -0400 Subject: regexps: testing and creating MatchObjects in one fell swoop References: Message-ID: It's not thread-safe, is it? Alex. -- Talk softly and carry a big carrot. From alet at unice.fr Thu Sep 28 09:32:44 2000 From: alet at unice.fr (Jerome Alet) Date: Thu, 28 Sep 2000 15:32:44 +0200 Subject: question about Distutils Message-ID: <39D3487C.21ADC425@unice.fr> I've just downloaded Distutils and its documentation, and used it on a python module I've written to see how it works. It's Very Nice and Easy ! However I have a question: It only seems to be designed for modules or packages (libraries), not for python scripts we want to be installed in /usr/local/bin (for example) like complete software. Am I wrong ? The documentation doesn't give any hint (to me) on how to do that easily. thanks for any answer. -- Jerome ALET - alet at unice.fr - http://cortex.unice.fr/~jerome Faculte de Medecine de Nice - http://noe.unice.fr - Tel: 04 93 37 76 30 28 Avenue de Valombrose - 06107 NICE Cedex 2 - FRANCE From olczyk at interaccess.com Tue Sep 26 14:54:43 2000 From: olczyk at interaccess.com (Thaddeus L. Olczyk) Date: Tue, 26 Sep 2000 18:54:43 GMT Subject: Precimpiling *.py to *.pyc. Message-ID: <39d0f0b7.82850984@nntp.interaccess.com> Is there any way of compiling all the *.py to *.pyc files? From robin at jessikat.fsnet.co.uk Fri Sep 8 07:32:23 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 8 Sep 2000 12:32:23 +0100 Subject: Python for Win32 Extensions for 1.6 and 2.0b1 References: <3n_t5.33829$Xg.235495@news-server.bigpond.net.au> Message-ID: In article , Robin Becker writes >Win95 OSR2: >I get this running 134 with 2.0b1; I had to make one slight change to >get win32ui.pyd to behave OK (ie I compiled without the reference to >ToUnicodeEx), but I don't think that's the problem here. I reckon it >must be a late change in the thread module which I saw stuffed in a few >days ago! > >C:\Python20\win32com\test>..\..\python testall.py >The Exchange Server tests can not be run... >testStreams test generated 9 lines of output >Fatal Python error: PyThreadState_Get: no current thread > >abnormal program termination > >C:\Python20\win32com\test> > this happens at win32pipe.popen(sys.executable + " testPyComTest.py -q").read() I've checked with the current os.popen and that seems to work ok so I guess something must be amiss with win32pipe. -- Robin Becker From pete at visionart.com Fri Sep 29 15:11:46 2000 From: pete at visionart.com (Pete Shinners) Date: Fri, 29 Sep 2000 12:11:46 -0700 Subject: zipfile docs out of sync Message-ID: <8r2pdk$4fo$1@la-mail4.digilink.net> i've been using the zipfile module recently, and noticed the documentation for it (both 2.0b1 & 2.0b2) are way out of sync with the actual code in the module. specifically the documentation for the zipfile.ZipFile objects. for example, i cannot find the "TOC" variable. "A read-only dictionary whose keys are the names in the archive, and whose values are tuples as follows: " the listdir() method is also missing? it appears these have been changed to using "NameToInfo" and "getinfo" for TOC, and listdir() has changed to namelist() ??? it's hard to be sure. i've figured out enough to get what i want working well behaved, but i thought i'd point it out to those who can do something about it :] From kragen at dnaco.net Wed Sep 27 05:01:12 2000 From: kragen at dnaco.net (Kragen Sitaker) Date: Wed, 27 Sep 2000 09:01:12 GMT Subject: Of what use is 'lambda'??? References: <39d09df6.11689247@news.bright.net> <8Z5A5.22404$ve5.1005839@news-east.usenetserver.com> <8FBC626EAduncanrcpcouk@194.238.50.13> Message-ID: In article <8FBC626EAduncanrcpcouk at 194.238.50.13>, Duncan Booth wrote: >Call by name, for those that have been fortunate enough to escape it, >allows you to give an expression as the argument to a function, but delays >the evaluation of the expression until it is used. A typical example if >python supported call-by-name might look like: > > [ Jensen's device variant ] > >Python, thankfully, returns 90 as the result. If it used call by name, it >would return 45. I wasn't around when call-by-name was a current reality instead of a historical curiosity, but I'd be surprised if Jensen's device were really a "typical" use. -- Kragen Sitaker Perilous to all of us are the devices of an art deeper than we ourselves possess. -- Gandalf the Grey [J.R.R. Tolkien, "Lord of the Rings"] From olaf.meyer at nokia.com Fri Sep 1 08:52:15 2000 From: olaf.meyer at nokia.com (Olaf Meyer) Date: Fri, 01 Sep 2000 12:52:15 GMT Subject: Dynamic function calling Message-ID: <39AFA5D5.399EDC41@nokia.com> I'm wondering if it is possible to call functions just by having access to their name in a string value. Something similar to: def test(): print "test function" f = "test" apply(f, ()) This does not work of course, because f does not have the right type. Is there a way to get a function object from the name (string)? Thanks, Olaf ________________________________________________________________________ Olaf Meyer <_Q_/ _ ,_~o Nokia Networks \\_/ / //\ /~~\_/~\ ,,, ___ _~o Heltorfer Str. 1 ^ \_ \>> | | #=#==========# | ___ _-\_<, 40472 Duesseldorf \\ \__/~\_/ ``` (*)/'(*) Tel.: 0211-94123737 From tim_one at email.msn.com Sat Sep 2 06:42:15 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 2 Sep 2000 06:42:15 -0400 Subject: Linbot In-Reply-To: Message-ID: [posted & mailed] [marduk] > I have been forced to refrain from using the name "Linbot" from > anything I'm associated with. This was a result of a Cease and > Desist from www.watchfire.com . Their claim is that Linbot > infringed upon their (pending) trademark on Linkbot. As a "quick > fix" I took down the web site and renamed the mailing list. > > I haven't decided yet what to do from there. ... Talk to a lawyer . Their trademark application for Linkbot is serial number 75627250 with the US Patent and Trademark Office. You can go there: http://tarr.uspto.gov/ and enter the serial number to get current status. The most recent item is dated 2000-03-18, and says "An office action making FINAL a refusal to register the mark has been mailed". However, the application is still marked as being alive. In governmentese, "final" only applies to tax bills . Section 1105.04(g) (Proper Response to Final Action [R-1]) of the PTO regulations: http://www.uspto.gov/web/offices/tac/tmep/1100.htm says a few avenues of appeal are yet open to them, for a 6-month period after the final refusal. 3+6 = 9, so that's this month. My bet is they went after you to begin with just to keep their diminishing trademark hopes alive. The deadline is looming, so check back in a month or so and see whether the application has been marked dead. If so, and you're in a different state and they haven't got the trademark at a state level either, the lawyer you talk to may well say you're in the clear. or-may-well-not-lawyers-are-baffling-ly y'rs - tim From tim_one at email.msn.com Tue Sep 12 15:44:08 2000 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 12 Sep 2000 15:44:08 -0400 Subject: Python 2.0b1 is released! In-Reply-To: <39BDDBF6.DFA954B4@seebelow.org> Message-ID: [Grant Griffin, attempting to spread a bit of sanity, so I'll leave all those parts out ] > ... > As another example, if you include a little GPL'ed code in a program > you distribute as an executable, there isn't much to force you to > follow the terms of the GPL; it's pretty unlikely that anybody will > discover this grave slight to the Noble Cause of Freedom, and it's > even _more_ unlikely that anybody will come after you for doing it. In the case of Python in particular, I'm afraid the issue will come up in a highly visible way almost immediately. The GNU readline library is GPL'ed, everybody knows it (readline is the poster child for why the FSF prefers the GPL to the LGPL), there's code in Python's core to interface with readline if it's available, and *lots* of people have distributed Python+readline+their_stuff in the past. So if this *ends* with CNRI still insisting "is too compatible!" and FSF insisting "is not!", a test case will pop up approximately the next day, involving a GPL'ed library that's a lightning rod for attention. I don't know what would happen then. Whatever, it wouldn't happen quietly. > ... > Therefore, even though Richard Stallman may wake up in the middle of > the night screaming over this, the rest of us should respond to the > CNRI license's use of Virginia (and UCITA, by inference) in accordance > with the following large, friendly letters: > > DON'T PANIC Darned good advice in general! But I abhor the intimation that anyone should wink at the use of GPL'ed code contra the GPL's intent: this isn't a question of legality to me, it's a question of respecting other peoples' wishes about how their work can be used. OTOH, if the GPL is written in a way that permits reasonable people to disagree about what the heck it says even after intense debate, the only mechanism we have for resolving that is to take it to court. Or arm-wrestling. Tossing dice is too cynical . i-know!-we'll-just-ask-guido-ly y'rs - tim From Dudek7 at mailroom.com Tue Sep 5 11:49:28 2000 From: Dudek7 at mailroom.com (Dudek7) Date: Tue, 05 Sep 2000 15:49:28 GMT Subject: Help for Python GUI programming References: <39b510b4@news.xtml.co.uk> Message-ID: One last question. I have a button with the value of 1 and an entry field. Whats the command when i press the button for the value to go to the entry field? Meaning what should I write for the button command for this to work? From ramesh4954 at my-deja.com Mon Sep 11 09:12:54 2000 From: ramesh4954 at my-deja.com (ramesh4954 at my-deja.com) Date: Mon, 11 Sep 2000 13:12:54 GMT Subject: com_error References: <8pe2u8$9sl$1@nnrp1.deja.com> <8peer301v88@news1.newsguy.com> Message-ID: <8pilo8$7k5$1@nnrp1.deja.com> Thanks very much Alex, for the timely help. K. Ramesh In article <8peer301v88 at news1.newsguy.com>, "Alex Martelli" wrote: > wrote in message > news:8pe2u8$9sl$1 at nnrp1.deja.com... > > How do I get the actual error message from a com_error? When I try to > > print the details I get the following : > > > > > > Any help would be appreciated. Thanks > > Use the .args member of the error object. Example: > > >>> import pywintypes > >>> import win32com.client > >>> try: foo=win32com.client.Dispatch("Not.There") > ... except pywintypes.com_error, erob: print 'caught' > ... > caught > >>> erob > > >>> print erob > (-2147221005, 'Invalid class string', None, None) > >>> dir(erob) > ['args'] > >>> erob.args > (-2147221005, 'Invalid class string', None, None) > >>> erob.args[0] > -2147221005 > >>> erob.args[1] > 'Invalid class string' > >>> > > Alex > > Sent via Deja.com http://www.deja.com/ Before you buy. From brian.j.geddes at intel.com Thu Sep 14 18:11:57 2000 From: brian.j.geddes at intel.com (Brian Geddes) Date: Thu, 14 Sep 2000 15:11:57 -0700 Subject: Serial Port communication Message-ID: <8pric7$bn2@news.or.intel.com> All - I'm looking for a way to communicate through the serial port from inside of a Python script. Ideally, I'd be able to open it and treat it like a file stream...anyone know how to do this? Thanks! Brian Geddes From sdm7g at virginia.edu Thu Sep 21 14:56:59 2000 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Thu, 21 Sep 2000 14:56:59 -0400 (EDT) Subject: compiling python on Mac OS X Beta In-Reply-To: Message-ID: On 21 Sep 2000, Johann Hibschman wrote: > Steven D Majewski writes: > > > The developer tools for OSX beta haven't shipped yet. Have you > > loaded the Darwin developer tools on top of OSX, or do you have > > tools from DP4 ? > > As a cheap graduate student, I don't have a subscription to the > development tools, so I downloaded the Darwin 1.0.2 distribution, > mounted the disk image, and copied the development tools over from > there. Horrible hackery, yes. I think the two options are that > either I somehow missed a header file (unlikely) or that the autoconf > setup got some mojo wrong in a way that I don't understand yet. > > There are quite a few things which could have gone wrong, and I'm not > yet familiar with the OS X headers, etc., so I'll keep working on it. > Now if I'd been running FreeBSD for the past few years rather than > Linux, maybe I'd have a better sense... ;-) > I think there have been a lot of changes since 1.0.2 -- if you want to develop without the OSX developer kit, you should update 1.0.2 from the CVS server. ( missing header files and the new config.guess are what I can recall off the top -- look in the mailing list archives for details.) I suspect that there'll be a new Darwin release coming along soon, but "soon" is probably not before they manage to get the OSX developer kit out the door! ---| 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 k_j_r_a_y at ix.netcom.com Sun Sep 3 21:21:12 2000 From: k_j_r_a_y at ix.netcom.com (Keith Ray) Date: Sun, 03 Sep 2000 18:21:12 -0700 Subject: Scientific plotting calls for Python on Mac?? References: <030920000959533029%pecora@anvil.nrl.navy.mil> <8otnrt01r81@news2.newsguy.com> Message-ID: In article <8otnrt01r81 at news2.newsguy.com>, "Alex Martelli" wrote: [...] >> Does anyone know of a simple, "standalone" Python plotting module? > >Isn't that what PIDDLE is for? With the QuickDraw backend, it >would seem to be right for your purposes on a Mac. "This backend >generates MacOS QuickDraw graphics within a window of the Mac >Python IDE", says the blurb (can't check -- I have no Mac!), and >it says that nothing extra besides MacPython is needed with Python >1.5.2. [...] So where would PIDDLE be found? -- From jeremy at beopen.com Wed Sep 6 22:23:23 2000 From: jeremy at beopen.com (Jeremy Hylton) Date: 07 Sep 2000 02:23:23 GMT Subject: Sandboxing Python References: <8p6mvk+r21k@eGroups.com> Message-ID: cryptic at heavytech.com writes: > I'm trying to determine if rexec actually does provide a bulletproof > restricted execution environment. I've read that Grail used it for > its applet system, but have found comments saying this wasn't very > secure, and have heard from friends that the security provided is > limited. rexec can be used to construct an environment where the untrusted Python code can be run safely. The trusted code that creates the sandbox (call it the supervisor) controls what modules and names the untrusted code has access to. Want to forbid access to the file system? Remove the open function, the os module functions that affects files, etc. If you want to implement a particular security policy, you need to implement that policy yourself using the basic building blocks provided by rexec and Bastion. If you want to limit a program so that it could only open sockets on port 80, you would need to write a wrapper around the socket module that check the port number when the connect call is made. There are no tools or libraries to make this any easier and the standard libraries do not provide direct support for security policies. Interposition is all you've got. The rexec mechanism is laos rather complicated and places a number of restrictions on the language features available to the untrusted code. Most of the restrictions disable introspective features of the language, like accessing an instance's __dict__ attribute. There are also restrictions on the interface between trusted and untrusted code. If you pass an object from trusted code to untrusted code, you can not pass the object directly. Instead, you must pass a Bastion object that wraps the instance and prevents tampering by the untrusted code. So the basic mechanism is probably sound, though no formal proof exists and no serious analysis has been done. The construction of a secure system using the mechanism should also be possible, but it is hard. -- Jeremy Hylton From just at letterror.com Fri Sep 8 06:29:16 2000 From: just at letterror.com (Just van Rossum) Date: Fri, 08 Sep 2000 11:29:16 +0100 Subject: Python 1.6 The balanced language References: <39B78E0C.9D2A6207@letterror.com> Message-ID: <39B8BF69.60C4EB5D@letterror.com> I wrote: > How would you spell resuming a suspended function? Neel Krishnaswami wrote: > Here's one possible spelling -- this a generator for the first n > squares, using the relation that n**2 = 1 + 3 + 5 + ... + (2n-1), > and "suspend" as the magic keyword. > > >>> def squares(n): > ... i = 1 > ... s = 1 > ... while i <= n: > ... i = i + 1 > ... s = s + (2*i - 1) > ... suspend s > ... > >>> for s in squares(5): > ... print s > 1 > 4 > 9 > 16 > 25 > > One nice thing about generators is that they have exactly the right > semantics to represent iterating over a sequence of values, so the > ordinary for loop can be the spelling of iterating over the values of > a generator. Looks nice, but how does it work? does suspend really return a sequence-like object? Or does the compiler know simply by the fact that it contains a suspend statement that squares() should return a sequence-like object? Could your example be rewritten like this, and still be equivalent: gen = squares(5) for s in gen: print s ? What exactly is 'gen' here? Just From SBrunning at trisystems.co.uk Mon Sep 25 05:26:02 2000 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Mon, 25 Sep 2000 10:26:02 +0100 Subject: Probably a FAQ (recommended references) Message-ID: <31575A892FF6D1118F5800600846864D5B1155@intrepid> > From: Grant Griffin [SMTP:g2 at seebelow.org] > they-wanted-eighteen-bucks-for-"Aesop's-Fables",-which-made > -that-one-look-cheap!-(maybe-GNU-should-reimplement-Aesop-as > -"free-software"-)-ly y'rs, > Try . 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 aahz at panix.com Fri Sep 29 15:51:40 2000 From: aahz at panix.com (Aahz Maruch) Date: 29 Sep 2000 12:51:40 -0700 Subject: basic python threading question References: <8r2hdl$6rr$1@panix6.panix.com> Message-ID: <8r2rsc$at2$1@panix2.panix.com> In article , David Bolen wrote: > >In many respects, threading on Python inside of C extension code is >much simpler than C - at least as far as interacting with the Python >core - because your code is effectively single threaded when it comes >to dealing with Python. That's basically true. >From a C extension perspective, your C code is only called from within >a single Python interpreter thread at a time (and is governed by the >global interpreter lock), so while your C code runs on behalf of a >Python request, there's only one native thread running against that >interpreter. That's also why you want to release the global lock if >you enter into a blocking operation, or else all Python threads are >blocked while the one thread calling your function waits for you to >return. I think what you really meant to say was that calls into extensions are serialized, because only one Python thread runs until the extension releases the GIL. But as soon as the extension releases the GIL, another Python thread can call into the extension. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Shadows 2000: when you're tired of "Cthulhu for President" --Aahz From vmilitaru at sympatico.ca Thu Sep 14 23:31:44 2000 From: vmilitaru at sympatico.ca (vio) Date: Fri, 15 Sep 2000 03:31:44 GMT Subject: RE bug in Python 2.0b1 Message-ID: <39C19942.B7A87338@sympatico.ca> I believe there may be a RE bug in 2.0b1. Consider the following script: #!/usr/bin/env python import re s = "red green blue" m = re.compile(r'green (\w+)', re.IGNORECASE) t = re.subn(m, r'matchedword \1 blah', s) print t When I run this on 1.5.2, I get the following expected output: ('red matchedword blue blah', 1) If I run it on 2.0b1, python basically hangs. Vio PS. Thanks to Mike Fletcher and Opinderjit for their help. From andres at corrada.com Sat Sep 9 16:09:10 2000 From: andres at corrada.com (andres at corrada.com) Date: Sat, 9 Sep 2000 16:09:10 -0400 Subject: Zope with JSPs? In-Reply-To: <8pdo4a$n9l$1@saltmine.radix.net>; from Cary O'Brien on Sat, Sep 09, 2000 at 12:22:34PM -0400 References: <8p56ev$2fg$1@nnrp1.deja.com> <8pdo4a$n9l$1@saltmine.radix.net> Message-ID: <20000909160910.B24755@corrada.com> As author of the HOWTO: Serve PHP/Perl from Zope (http://www.zope.org/Members/Mamey/PHP), I would like to point out that Bill's solution builds upon one particular solution in the HOWTO that will not solve the original poster's question. I think the other way of serving PHP from Zope proposed by Joseph Wayne Norton, and also included in the HOWTO, is a more appropriate solution. Let me explain. Norton's solution allows for PHP pages residing in the ZODB. These pages can be a mixture of PHP and dtml code. Using Apache, one can have Zope rendering the dtml part of the page and then have mod_php process the leftover PHP code. If such a thing could be done with JSP, I would be very interested to know and expand the HOWTO to include a JSP solution. On Sat, Sep 09, 2000 at 12:22:34PM -0400, Cary O'Brien wrote: > In article <8p56ev$2fg$1 at nnrp1.deja.com>, wrote: > >Hello. I am currently considering using Zope as the Content Management > >System for my website. However, I am also using JSPs for most of my > >dynamic pages as well. What I would like to do is have a template that > >both Zope and JSP would recognize. That is, Zope can put some of the > >contents onto the template and JSP can also put its contents on the > >template as well. Can this be done? Thanks. > > > > Hmm. Well, you could keep your existing server running and have Zope > get those pages and wrap them however you want. > > http://www.zope.org/Members/billw/morePHP > > Has an example of someone doing something like this with PHP. > > -- cary > -- > http://www.python.org/mailman/listinfo/python-list > -- ------------------------------------------------------ Andres Corrada-Emmanuel Email: andres at corrada.com ------------------------------------------------------ From lynnb at yogananda-srf.org Thu Sep 21 12:54:25 2000 From: lynnb at yogananda-srf.org (lynnb at yogananda-srf.org) Date: Thu, 21 Sep 2000 16:54:25 -0000 Subject: Printing Architecture Message-ID: <8qdeg1+9nlv@eGroups.com> I'd like some advice/help from the Python community on technology for printing documents generated from browser-based intranet applications and/or batch production jobs. Most of the documents would be printed from back-end servers, but some internal documents would need to be printed directly by the user from the browser. The basic requirements are: --Consistent, predictable printed output (at least for server-based printing, not so important for printing from browser) --Runnable from batch script without user intervention --Dynamic programmed selection of target printer, orientation, page size, form type, duplex option, etc. Highly desirable: --Portable across operating systems --Uses same or similar API for both printing and display (preferably HTML) --Standards-based to leverage existing layout/formatting/printer management tools Although HTML gives limited control over page layout, it is probably sufficient for our report and business document needs. But it would need to be extended with tags for page size, orientation, logical printer name, etc. Piddle is also a possiblity, but it's a low-level API, and is quite different from the HTML we would also need to generate for soft-copy display. One solution would be to generate PostScript or PDF from HTML, then print with GhostScript or Acrobat Reader. There's a Perl HTML2PS utility. Anything available in Python? Commercial products? Although the Grail browser project is apparently defunct, it might be mined for this purpose. I'd appreciate your thoughts on this. TIA, Lynn Blickenstaff From vtbl.moorepe at memo.volvo.se Tue Sep 12 06:10:11 2000 From: vtbl.moorepe at memo.volvo.se (prm) Date: Tue, 12 Sep 2000 11:10:11 +0100 Subject: Could an effective telnet be written? Message-ID: <39BE0101.B73837E9@memo.volvo.se> I'm new to Python/TK still. Could someone comment on the feasibility of writing a telnet-5250 emulator using '100% pure python' :) ? For those lucky enough not to have experienced a proper 'green screen', it is a screen-at-a-time + data-entry-type field data+colours/underline/blink attributes + cursor positioning, screen save/restore, etc.protocol. It is quite involved but performs well on midrange/mainframe situations when a number of users transmit packets only when pressing an AID key (special function key combination + F1-F24) or pressing Enter. I have had a dream of making my own version of the emulator so that I can understand and play with it better. Orginally I started development in Java but found there was not enough leverage in the language over c. There is an open sourced c version that I find hard to fathom that works fairly robustly under Win and Gnome/Linux. If it is easy to create a panel in TK that can switch between displaying different non-proportional fonts and switch between 80 columns and 132 at run time and offer decent support re. key responses function key/character events and also loading the panel with text rapidly, I would like to give it a go unless someone convinces me it's not a PKAH (Python-kicks-ass-here) thing to do... Best regards Peter Moore MJS400 From tim at degree.ath.cx Wed Sep 20 12:52:49 2000 From: tim at degree.ath.cx (Tim Hammerquist) Date: Wed, 20 Sep 2000 16:52:49 GMT Subject: What is Python? References: <8pqhm9$6a9$1@panix3.panix.com> <3BBC75F01B2A2291.3CC54B93C0C69DED.4E021EA85330C94C@lp.airnews.net> <8pt65c$cbs$2@newshost.accu.uu.nl> <39C29336.71ED41AC@seebelow.org> <39C3E664.BCEAF741@seebelow.org> <39C5C379.BD3FF8B9@seebelow.org> Message-ID: Grant Griffin wrote: > p.s. Did I mention that I first caught onto Python when I read > "Advanced Perl Programming"? IIRC, one of the author's footnotes says > something like "But Python is my favorite OO scripting language". So if > you want to continue to use Perl, I'd recommend you do so mainly so you > can write books about it. I noticed that footnote as well, and that, combined with a few (very few) favorable mentions of Python in clpm, inspired me to try it. And I quite rightfully love it. Should I beg pardon for this? -- -Tim Hammerquist Legend -- a lie that has attained the dignity of age. -- H. L. Mencken From mikael at isy.liu.se Wed Sep 27 05:41:18 2000 From: mikael at isy.liu.se (Mikael Olofsson) Date: Wed, 27 Sep 2000 11:41:18 +0200 (MET DST) Subject: Wholly unnecessary flame. (was Re: pyXML!) In-Reply-To: <8qs5gl$1pr@gap.cco.caltech.edu> Message-ID: On 27-Sep-00 Robert Kern wrote: > Luckily, you don't have to buy squat if you want to compile extension > modules. You just have to take the time to install a (free, Open Source) > compiler and learn to use it. > > http://starship.python.net/crew/kernr/mingw/Notes.html > > It works for 1.5.2, and though I will not have time soon to try it with > 1.6/2.0 (studies, using Linux now primarily, etc.), someone else has > volunteered and will be reporting soon. The link is dead. However, http://starship.python.net/crew/kernr/mingw32/Notes.html seems to be it. /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: 27-Sep-00 Time: 11:39:23 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From root at rainerdeyke.com Mon Sep 4 17:39:07 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 04 Sep 2000 21:39:07 GMT Subject: Ordered Dictionaries? Trees? References: <20000904.133113.2838@Jeremy.cerebralmaelstrom.com> Message-ID: <%DUs5.124545$6y5.83747271@news2.rdc2.tx.home.com> "Stephen Hansen" wrote in message news:20000904.133113.2838 at Jeremy.cerebralmaelstrom.com... > I need a Dictionary who's order is perdictable and/or settable; e.g. > FIFO/LILO... For instance, if I do: dict['A'] = 1, dict['C'] = 2, dict['B'] = 3, > then dict.keys() would return ('A','C','B'), always. :) > > Each value would prolly be another one of these dictionaries, so what > i'd be doing is setting up a tree-structure. What's the best way to do this, > that isn't tooooooo terribly slow? Speed isn't urgent, but hey, i'd rather > it not become a negative later on as things expand. Subclass UserDict. Override __set_item__ to also append the key to an internal list. Override keys to return the list. If you also want to remove or replace dictionary items, thing become slightly more complicated, but the same principles apply. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From pehr at pehr.net Sun Sep 10 00:00:08 2000 From: pehr at pehr.net (pehr anderson) Date: Sun, 10 Sep 2000 04:00:08 GMT Subject: CGI problems in Personal Web Server References: <8peh36$culim$1@ID-4825.news.cis.dfn.de> Message-ID: <39BB0749.67D12181@pehr.net> Dear Bertilo, I'm not sure if you will get much constructive advice other than "switch to apache" allong with "use a server-grade OS like NT Workstation or linux". Apache does run well under all flavors of windows, however Win 95/98 are simply not designed to be friendly to long-running server processes. If you can't upgrade a server OS, then you will at least want to evaluate upgrading to Apache. I don't know if this is helpful in the short term, but in the long term it will be valuable to have the flexability and control provided by the apache server. Microsoft *has* to cripple their personal web server as it can't be allowed to compete with their expensive IIS webserver. Their business incentives prevent them from giving you a good solution. Apache gives everybody "full power" on any platform. http://apache.org/docs/windows.html -pehr Bertilo Wennergren wrote: > > I have weird problems getting Python 2.0 CGI to work in my Personal > Web Server (Microsoft). All I get is "Internal server error ". > > The funny thing is that I had CGI with Python 1.6 running just fine > only two days ago. I had the Active State distribution installed, and > I had changed the necessary registry setting. Everything worked > perfectly. > > Then I uninstalled 1.6 and installed 2.0 instead, but now it's > impossible to get CGI working in PWS. Even stranger, the section > in the registry that controls this has stopped having any effect > at all. A long while ago I got CGI with perl working by changing > these registry settings - and offering a heard or two of goats... - > but now perl CGI keeps running even if I delete that part of > the registry. It simply doesn't matter what I do. The before > crucial registry settings have stopped having any relevance > whatsoever. Perl CGI runs along happily, and Python CGI is > impossible to activate. > > Anyone has any idea what could be happening, and what I should > try next? > > (BTW: I have restarted my machine - running Windows 98 - several > times...) > > -- > ##################################################################### > Bertilo Wennergren > > > ##################################################################### From kragen at dnaco.net Sat Sep 23 23:11:42 2000 From: kragen at dnaco.net (Kragen Sitaker) Date: Sun, 24 Sep 2000 03:11:42 GMT Subject: app slow down References: <39CD415A.CC498224@uni-bremen.de> Message-ID: In article <39CD415A.CC498224 at uni-bremen.de>, me wrote: >My application shows strange delays at several points. Opening Window a) >needs 2 minutes - opening another similar Window b) 2 secounds. The >application does not do any >computations that can cause such delays. I used truss to pin down the >problem . The interpreter sleeps in read - 60..120 secounds - read(6, >0x0071FD7C, 5120) (sleeping...) - and then starts again. Are you doing any network stuff? This sounds like a DNS setup problem. Does emacs also take a long time to start? :) What is file descriptor 6? Does it come from an open call, a socket call, a dup call, or something else? -- Kragen Sitaker Perilous to all of us are the devices of an art deeper than we ourselves possess. -- Gandalf the Grey [J.R.R. Tolkien, "Lord of the Rings"] From teyc at bigfoot.com Sat Sep 30 07:02:52 2000 From: teyc at bigfoot.com (Chui Tey) Date: Sat, 30 Sep 2000 21:02:52 +1000 Subject: Python ncurses for Win32? References: Message-ID: <8r4guj$4kb$1@bunyip.cc.uq.edu.au> I have a copy of the binaries, although I don't know where they come from, and I don't have the sources. I do have sources for mcurses for python, they appear to be last changed in 1995, so don't know much about compatibility. I have posted it to http://static.userland.com/gems/teyc/pdcurses.zip (36Kb) Regards Chui From bjorn at roguewave.com Mon Sep 4 14:11:28 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Mon, 04 Sep 2000 12:11:28 -0600 Subject: Text input References: <1MQs5.239$1U.25905@elnws01> Message-ID: <39B3E5D0.7DC9E09C@roguewave.com> F:\>f:\bin\python16\python.exe Python 1.6b1 (#0, Aug 7 2000, 12:30:24) [MSC 32 bit (Intel)] on win32 Copyright (c) Corporation for National Research Initiatives. Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam. >>> name = raw_input("Input your name: ") Input your name: Bill >>> print name Bill >>> -b Kevin Breit wrote: > > Hey, > warning: newbie question I am trying to figure out how to take text from > keyboard. I want it to basically do something like this: > Input your name: Bill I can't figure out > how to do this! > Thanks > Kevin > > -- > http://www.python.org/mailman/listinfo/python-list From tim_one at email.msn.com Sat Sep 23 13:15:27 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 23 Sep 2000 13:15:27 -0400 Subject: 2000: A Win32 Oddisey In-Reply-To: <004c01c0257f$4ad63340$c87b533e@pedrodiaz> Message-ID: [Pedro] > ... > No SSL support in the binary python2.0b distro for win32. > ... [and a lot of pain trying to repair that] ... See: http://sourceforge.net/bugs/?func=detailbug&bug_id=110683&group_id=5470 > ... > but, my old friend, to give ssl support to python I have to compile > openssl wich, each time I try to compile it in cygwin, says something > like: "hey you, motherfucker. Buy that Visual C++ or I won't compile > ever" As the link above will reveal to your wondering eyes, having VC wouldn't have solved your problem either. SSL support for Windows is currently a new-feature request: http://python.sourceforge.net/peps/pep-0042.html awaiting a volunteer. > ... > Does, for god's sake, anybody have a python2.0b distro compiled > with SSL support????. Not that we know of -- but if they do, they should submit a patch! http://sourceforge.net/patch/?group_id=5470 ssl-sounds-useful-so-i-won't-touch-it-ly y'rs - tim From kc5tja at garnet.armored.net Thu Sep 21 18:52:55 2000 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 21 Sep 2000 15:52:55 -0700 Subject: Mapping Python to CORBA References: <39CA743C.4D20DF1@hks.com> Message-ID: >The reverse mapping is not documented. In some cases >it is clear (such as string -> string, int -> long, >float -> double), but for others (dictionary, list) it >looks as if I have to write my own interface. That's because there is no reverse mapping -- in fact, there's no *need* for them; by reversing the forward mapping, you automatically get a reverse mapping. The stubs/skeletons generated by the IDL compiler you're using takes care of mapping Python types to IDL data types for you. -- KC5TJA/6, DM13, QRP-L #1447 | Official Channel Saint, *Team Amiga* Samuel A. Falvo II | Oceanside, CA | From nospam at nospam.com Sun Sep 24 12:37:17 2000 From: nospam at nospam.com (Tom) Date: Sun, 24 Sep 2000 16:37:17 GMT Subject: 1.6 or 2.0b1? References: <39CD2674.66158180@nycap.rr.com> Message-ID: <15qz5.14912$dZ2.6012166@news3.rdc1.on.home.com> Start with v1.5.2. Get a good book (it will probably be about v1.5.2). Tom. "Grant Austin" wrote in message news:39CD2674.66158180 at nycap.rr.com... > I'm new to programming in all respects, and am wondering if I should > start with python 1.6 or 2.0b1? > > Thanks in advance :) > -Grant Austin > > P.S. Anyone know of a good tutorial site? > From urner at alumni.princeton.edu Sun Sep 10 12:10:05 2000 From: urner at alumni.princeton.edu (Kirby Urner) Date: Sun, 10 Sep 2000 09:10:05 -0700 Subject: Python 2.0 and teaching precalculus References: <02jmrskpt2qicgrln7kd9g2hrjjt3l1t77@4ax.com> <39BB5327.1F8723AA@alcyone.com> <5cbnrsco00sjgs1urr188ustmvg61b89ne@4ax.com> Message-ID: Kirby Urner wrote: >Erik Max Francis wrote: > >>Kirby Urner wrote: >> >>> def wiggle(function,input,epsilon=1e-10): >>> """ >>> Accepts a function, value and returns delta f / delta x >>> for small epsilon (default of 1^-10 may be overridden) >> ... >> >>1 seems like a bad choice for an epsilon ... :-) > >Woops. > >Thanks for pointing out the typo. Fixed it at the source >page: http://www.ineterena.com/~pdx4d/ocn/precalc.html > >Of course it's all relative. 1 is really small if your >x's are 10,000,000,000 apart :-D > >Kirby ================== Actually, it was already OK on the web version, but your quick detection of the goof prompted me to follow up on edu-sig: >Here's wiggle(): > >def wiggle(function,input,epsilon=1e-10): > """ > Accepts a function, value and returns delta f / delta x > for small epsilon (default of 1^-10 may be overridden) > """ > return (function(input+epsilon) - function(input))/epsilon Fast reader on comp.lang.python caught the above typo error in my post (web version was OK). Of course 1^-10 is simply 1. Now that I stop to cogitate, I see this could be a real confusion. 1e-10 = 10^-10, just as 1e2 = 10^2 = 100. Need to remind students that #.###e### means #.### x 10**###, obviously not #.###**###. Kirby From aahz at panix.com Thu Sep 21 00:03:55 2000 From: aahz at panix.com (Aahz Maruch) Date: 20 Sep 2000 21:03:55 -0700 Subject: Script in Python to run a C program References: <00092100044500.01350@localhost.localdomain> Message-ID: <8qc1bb$2gm$1@panix6.panix.com> In article <00092100044500.01350 at localhost.localdomain>, The Majestic Moined Mogul wrote: >Could someone please tell me how to best write a Python script that could >execute a C program several times and compare the run times of each? times = [] for i in range(numTests): start = time.time() os.system(cmd) end = time.time() times.append( (start,end) ) I don't claim this is "best", but it sure is simple. You might want to include a call to os.system(cmd) before the loop to pre-load the disk cache. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Member of the Groucho Marx Fan Club --Aahz From claird at starbase.neosoft.com Thu Sep 28 14:09:34 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 28 Sep 2000 13:09:34 -0500 Subject: Scripting language for an application References: <39D3329F.390C831D@c_repido.co_m> Message-ID: <489FA63BB6FE7C68.81BE834F507D0ED1.2A9A8D97685E2F2E@lp.airnews.net> In article , Dan Schmidt wrote: >Marco Seiri? writes: > >| I'm doing research (=surfing the web) in order to see >| what language I will use in an application (C++) we are >| building. Today we use Perl to some extent. Would you >| think there would be any benefit from using Python instead/also? >| >| My main concerns are speed and ease of use. > >We are using Python here as an embedded language and it's working >wonderfully so far. I don't know how it would compare to Perl for >speed, but it's very easy to use. > >If you use Python, you undoubtedly want to either use > > - Swig if you want to generate an interface > automatically between Python and your C++ classes, or > > - CXX if you want to do your interfaces > by hand. > >We're using CXX and it's very clean. I recommend it highly for any >project combining Python and C++ (especially after looking at how the >interfacing is done in straight C!). . . . It's possible to embed Perl. It's so unpleasant, though, as to be one of the principal impulses behind Perl6. In contrast, Python is *designed* to be embedded. It's happy being embedded, and rather fun to do, at least in comparison with Perl. I second the recommandations of CXX and Swig. There are operations for which Perl is faster than Python--oc- casionally even quite a bit faster. It would surprise me quite a bit if any of them will arise in the application you're con- templating. I expect Python's processing speed will be more than adequate for your application. Python was designed as a language newcomers would learn quickly and easily. Perl makes Unix sysads comfortable. That's about as much as can be said in response to the little information you've presented. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From db3l at fitlinxx.com Mon Sep 11 18:26:06 2000 From: db3l at fitlinxx.com (David Bolen) Date: 11 Sep 2000 18:26:06 -0400 Subject: Painfully slow startup References: <8pjk2c$e87$1@nnrp1.deja.com> Message-ID: markscottwright at hotmail.com writes: > Is python typically very slow when starting up? When I compare a > simple 'hello world' application against perl, python is 2 orders of > magnitude slower on startup. It's quite noticable - even the smallest > scripts take more than 3 seconds to load and run (this is on a 500mhz > Pentium III running Windows2000). I'm considering embedding python in > one of our products, but the application is time-sensitive enough that > a 3-4 second load time is unacceptable. I'm using Python 1.5.2 (from > the Win32 installer - I haven't re-compiled it myself or anything). I > suspect that my version of python must be configured incorrectly - does > anyone have any clues? Well, as a point of comparison, running your test program on my machine yielded a pretty consistent 120-130 for Python and 50-60 for Perl. This is under WinNT 4.0 on an ~400MHz PIII with Python 1.5.2 as distributed as a win32 binary. So if there is something, it might be more the system environment than Python specifically. Compared to Perl, Python does do more searching upon startup for site files and building the library path and such not that has been discussed here previously, but it shouldn't be as bad as you note. Is this consistent for you? I did find that on my first test, while Python gave 120, Perl gave 1062, because I hadn't run it yet. After that, it was probably cached and loaded at the faster rate. In 1.5.2, Python also pulls in winmm.dll, which I believe others have posted as being a particularly slow loader in some environments. That's changed in 2.0 (not positive about 1.6), so you might test that just to see if it improves things. On my same system, 2.0 (current version from CVS) loads in about a tick count of 90-100, so about 75% of the time it takes to use 1.5.2. But I'm not sure what other concrete things to try offhand in terms of your Windows configuration. With respect to your application, realize also that when you embed Python you really only have the primary startup cost once, along with your application startup. Feeding information to Python to execute shouldn't be anywhere near the same overhead as startup. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From piet at cs.uu.nl Wed Sep 6 08:09:45 2000 From: piet at cs.uu.nl (Piet van Oostrum) Date: 06 Sep 2000 14:09:45 +0200 Subject: Python 1.6 The balanced language References: <39AB712E.805ACB4B@nowonder.de> <8orsag$7d7$1@animus.fel.iae.nl> <8p292k0lcp@news1.newsguy.com> <8p3kn701q0q@news1.newsguy.com> Message-ID: >>>>> "Alex Martelli" (AM) writes: AM> Complex? The *syntax* of Haskell?! Why, it even uses AM> indent and linebreak Pythonically... I find the complete language defintion of Haskell quite complicated (and I learned Algol 68 from the Reports, the original and the Revised, and several intermediate versions). But for normal use you can stick with a large subset that is quite simple. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From jeremy at beopen.com Tue Sep 5 13:30:08 2000 From: jeremy at beopen.com (Jeremy Hylton) Date: 05 Sep 2000 17:30:08 GMT Subject: What's the heck "Beopen python" ? References: Message-ID: thor at localhost.localdomain (Manuel Gutierrez Algaba) writes: > I'm starting to get a bit nervous about it. I think python > was/is python. But now, a slight difference comes , it's > _beopen_ python. > > Perhaps , should we start talking about "Beopen python 3000"? > Or simple Beopen 3000. > > The proofs : > > http://www.pythonlabs.com/logos.html BeOpen Python is the name for the official Python release that comes out of BeOpen PythonLabs. Bob Weiner, the CTO and founder of BeOpen, recently posted this clarification about the logos and the name to the Python 2.0 licensing mailing list: We're adding in a sentence that explicitly allows the use of the BeOpen Python icons. Just so you know, we have no issue with anyone using the term BeOpen Python in regards to our Python releases; we also have no issue with people simply calling it Python (just so you know). If someone has some language that can make these facts even clearer, feel free to send it. Jeremy -- Jeremy Hylton From aahz at panix.com Mon Sep 18 12:01:19 2000 From: aahz at panix.com (Aahz Maruch) Date: 18 Sep 2000 09:01:19 -0700 Subject: fileno() References: <8q5ako$9uj$1@news.uit.no> Message-ID: <8q5e8f$acj$1@panix6.panix.com> In article <8q5ako$9uj$1 at news.uit.no>, Arild Hansen wrote: > >What is the exact purpose of fileno()? I keep searching for a good >explanation of this function returning a file handler to an object, >but what is the precise meaning and purpose of this? All help greatly >appreciated ! As it says in the docs, it's for low-level access to file objects. For example, suppose you open a file in Python and want to access that file in a C extension; you'd need to pass in f.fileno(). (There are mechanisms for doing Pythonic access to the file in C, but it's a lot simpler to just get the file handle.) -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 The best way to get information on Usenet is not to ask a question, but to post the wrong information. --Aahz From pinard at iro.umontreal.ca Sat Sep 9 11:30:06 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 09 Sep 2000 11:30:06 -0400 Subject: Soth DPE Version 0.2 with visual configuration In-Reply-To: "Neil Hodgson"'s message of "Fri, 08 Sep 2000 22:02:11 GMT" References: <8pb0r9$t0o$1@nnrp1.deja.com> Message-ID: [Neil Hodgson] > Sindh wrote: > > As above at http://www.soth.uklinux.net > Its a good idea to explain what a package does in an announcement. Or > where you trying for an air of mystery? ;) > """Soth [Beta release] [...] but I'm not pedantic.""" Are you sure? You are giving Soth a bad start in my mind. I always considered that a software is much more free when the maintainer is welcoming and friendly in his/her attitudes. There is so much free software around, nowadays, that people have much of a choice, and will quite naturally go to the greener pastures :-). -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From effbot at pythonware.com Sat Sep 9 07:09:41 2000 From: effbot at pythonware.com (effbot at pythonware.com) Date: Sat, 09 Sep 2000 11:09:41 GMT Subject: regexps: testing and creating MatchObjects in one fell swoop References: Message-ID: <8pd5pg$asg$1@nnrp1.deja.com> dan wrote: > This isn't a huge pain in the simple case, but it quickly becomes > annoying when I want to do the equivalent of > > if (/(\d+)\s+(\d+)/) { > ($num1, $num2) = ($1, $2); > } elsif (/(\w+)\s+(\w+)/) { > ($word1, $word2) = ($1, $2): > } # etc. > > as the two-part test in Python doesn't lend itself easily to a long > if/elif/elif chain. I'm tempted to mention the "replace nested conditionals with guard clauses" refactoring rule, but I'll leave that for another day... > I've "solved" the problem locally by using the following helper > function: > > # research (regexp, string) is the same as regexp.search (string), > # but saves off the match results into 'rematch', so we can test for > # a regexp in an if statement and use the results immediately. > rematch = None > def research (regexp, string): > global rematch > rematch = regexp.search (string) > return (rematch != None) > > So that I can write: > > if research (r"(\d+)\s+(\d+)", line): > (num1, num2) = rematch.groups() > elif research (r"(\w+)\s+(\w+)", line): > (word1, word2) = rematch.groups() > # etc. > > I suppose I can even inject research into the re module, and inject a > similar method into regular expression objects. etc, to make it nicer. > > Is there a cleaner, or more approved, way, to accomplish this task? > If not, does it make any sense to have a re.last_match object that > automatically contains the last match, allowing, for example: > > if re.search (r"(\d+)\s+(\d+)", line): > (num1, num2) = re.last_match.groups() > > Or is that too side-effecty and non-Pythonic? Won't fly -- what if two threads are using the same regular expression? (or in your rematch example, what if two threads are using regular expressions...) ::: There's actually a slightly experimental feature in SRE that can be useful here: combine your expressions into one big expression, and use the new "lastgroup" attribute to figure out which one that matched: >>> import re >>> p = re.compile("(?P\d+)|(?P\w+)") >>> m = p.search("123 456") >>> print m.lastgroup, m.groups() digits ('123', None) (however, keeping track of subgroups can be a major PITA with this approach...) Sent via Deja.com http://www.deja.com/ Before you buy. From kragen at dnaco.net Wed Sep 27 04:58:09 2000 From: kragen at dnaco.net (Kragen Sitaker) Date: Wed, 27 Sep 2000 08:58:09 GMT Subject: emitting HTML and XML in Python References: Message-ID: In article , Erno Kuusela wrote: >>>>>> "Kragen" == Kragen Sitaker writes: > > Kragen> stringtest(xml.a('hello', href='http://www.oclc.org/'), > Kragen> 'hello') > >this looks quite similar to what Andy Dustman's HyperText package >produces. it lives at . >maybe you should merge efforts? It is very similar; thanks for the pointer! The HyperText module is much more SGMLish (DTD-driven, upper-case, harder to adapt to new different DTDs), while what I posted is much more XMLish (stupid, simpleminded, lower-case); HyperText has many more features (DTD-drivenness, multiple content arguments, writeto, indented output, smart attribute name translation, entity-encoding, URL-encoding, form encoding, CSS styles, SGML comments, real documentation), and totals 1481 lines of .py, while what I posted totals 65. There might be times you'd want to use the stupid thing instead of the smart one. Andy is, of course, welcome to use the little XHTML thingy I posted if he thinks it will make his life easier; I did disclaim any copyright in it, and I hope lots of people find it useful. :) I wish I knew how __import__ worked in 1.5.2; then perhaps I could make the toy module I posted just as convenient to use as HyperText. The 2.0 documentation certainly seems to suggest you could import things generated on the fly. -- Kragen Sitaker Perilous to all of us are the devices of an art deeper than we ourselves possess. -- Gandalf the Grey [J.R.R. Tolkien, "Lord of the Rings"] From ge at nowhere.none Tue Sep 26 14:28:05 2000 From: ge at nowhere.none (Grant Edwards) Date: Tue, 26 Sep 2000 18:28:05 GMT Subject: Of what use is 'lambda'??? References: <39cbda82.38443020@news.bright.net> Message-ID: In article , Suchandra Thapa wrote: >Kragen Sitaker wrote: >>- functional programmers are a bunch of academics who think up >> impractical ideas like garbage collection, arbitrary-precision >> numbers, massively parallel computers, and programming languages that >> compile into hardware designs, while procedural programmers get real >> work done, with a schedule and a budget to overrun. Real work like >> payroll. > > That's not quite true since Ericcson uses their functional language >Erlang to write software for their telecom gear and other mission critical >stuff. They must be some non-functional parts of the language. If none of the functions have side-effects, then there's no way to change the state of a telco switch for example. A telco switch that can't change state isn't too useful. -- Grant Edwards grante Yow! I wonder if I ought at to tell them about my visi.com PREVIOUS LIFE as a COMPLETE STRANGER? From Dudek7 at mailroom.com Tue Sep 5 10:13:55 2000 From: Dudek7 at mailroom.com (Dudek7) Date: Tue, 05 Sep 2000 14:13:55 GMT Subject: Help for Python GUI programming Message-ID: Hi, I'm a newbie to python gui programming. I can make buttons and position them but i have a question. WHen u set the button command(command=Watever) I need to set the command to a = 34. but by doing (command=a=34) doesnt work. Can anyone please help me? thanks From effbot at telia.com Thu Sep 14 11:08:11 2000 From: effbot at telia.com (Fredrik Lundh) Date: Thu, 14 Sep 2000 15:08:11 GMT Subject: Opening file problem in wxWindows program References: Message-ID: David Ishee wrote: > I am writing a program that uses wxWindows for the GUI in Windows NT > with Python 1.5.2. I am trying to open a file and read the contents > within this program and I'm having trouble. I have the statment: > > usernameFile = open('usernames.dat', 'r') > > However, I get an error message saying: > > TypeError: illegal argument type for built-in operation > > If I create a blank test script with this statement as the only line, > it works fine. If I enter the statement in the command line of the > interpreter, it works fine. What could be the problem with using it in > a script interspersed with wxWindows stuff? > > I have imported these at the top of my script: > > from wxPython.wx import * note that from-import imports *all* functions and names from the module: - maybe wxPython.wx contains an open function? > from os import * - maybe os contains an open function? (it does) > from string import * - maybe string contains an open function? > Any ideas? just follow the Import Rule: "Always use import. As usual, there are a number of exceptions to this rule: 1. The Module Documentation Tells You To Use from-import. 2. You're Importing a Package Component. 3. You Don't Know the Module Name Before Execution. 4. You Know Exactly What You're Doing." from http://www.pythonware.com/people/fredrik/fyi/fyi06.htm (see the webpage for more info) looks like you broke rule four ;-) ::: printing the doc string can also help: >>> print open.__doc__ open(filename[, mode[, buffering]]) -> file object Open a file. The mode can be 'r', 'w' or 'a' for reading (default), writing or appending. The file will be created if it doesn't exist when opened for writing or appending; it will be truncated when opened for writing. Add a 'b' to the mode for binary files. Add a '+' to the mode to allow simultaneous reading and writing. If the buffering argument is given, 0 means unbuffered, 1 means line buffered, and larger numbers specify the buffer size. >>> from os import * >>> print open.__doc__ open(filename, flag [, mode=0777]) -> fd Open a file (for low level IO). From andy.gleeson at mon.bbc.co.uk Tue Sep 12 07:05:00 2000 From: andy.gleeson at mon.bbc.co.uk (Andy Gleeson) Date: Tue, 12 Sep 2000 12:05:00 +0100 Subject: Python training in UK? Message-ID: <8pl216$5d1$1@nntp0.reith.bbc.co.uk> Does anyone know of any company offering training in Python programming in the UK? (This is to try set at rest the mind of a project manager who had never heard of python and is oviously expecting both myself and the other person who knows Python to be run over by a bus). Thanks Andy Gleeson From nick_knight at my-deja.com Fri Sep 1 09:51:34 2000 From: nick_knight at my-deja.com (nick_knight at my-deja.com) Date: Fri, 01 Sep 2000 13:51:34 GMT Subject: memory leak in debug dll for windows Message-ID: <8ooc90$htv$1@nnrp1.deja.com> Hello I am embedding pythoon in an app but when purley doing the following: - void main() { Py_Initialize(); //do nothing Py_Finalize(); } this when using the debug Dll cuases a couple of memory leaks but not in the non - debug dll. Has anyone else seen this. Python ver 1.5.2 VSVC 6 Thanks Nick Sent via Deja.com http://www.deja.com/ Before you buy. From eddy at zeus.com Wed Sep 13 11:21:55 2000 From: eddy at zeus.com (Edward Welbourne) Date: Wed, 13 Sep 2000 16:21:55 +0100 Subject: .ni Message-ID: <200009131521.QAA31749@phrixus.cam.zeus.com> Do we have any Nicaraguans in the house ? e.g. www.knights.ni Eddy. From cookedm at physics.mcmaster.ca Sat Sep 30 22:56:02 2000 From: cookedm at physics.mcmaster.ca (David M. Cooke) Date: 30 Sep 2000 22:56:02 -0400 Subject: Secure Passwords in Memory References: <20000930173905.B2586@liddy.indy.progenylinux.com> <00100111083208.00855@localhost.localdomain> Message-ID: At some point, "Eric Gillespie, Jr." wrote: > On Sun, Oct 01, 2000 at 10:56:49AM +1300, > matt wrote: > > > Are you worried about someone snooping all your memory, or just > > having access to the core dump of a python process? If it is the > > latter, then it's nicer to catch termination signals and quit > > nicely. > > I'm worried about memory. How is someone who isn't root going to snoop all memory? I would be more worried about core files. I believe, in the development of Linux, when /proc/kmem was introduced (it's basically a virtual file of all memory) there was a discussion about someone using it to snoop on passwords, especially the root password. Alan Cox stopped the discussion by pointing out that only root could access /proc/kmem, so what was the problem? Admittedly, you should still zero out passwords :-) If you eventually write a C module, you might want to look at the mlock(2) call, which locks a region in memory, so it isn't swapped. However, only root can use this, limiting it's utility. -- |>|\/|< ---------------------------------------------------------------------------- David M. Cooke cookedm at mcmaster.ca From sholden at holdenweb.com Wed Sep 13 15:24:47 2000 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 13 Sep 2000 15:24:47 -0400 Subject: One last shot at the Augmented Assignment PEP References: <20000913160209.D52541CF42@dinsdale.python.org> <39BFC44E.FD6CB79C@rsv.ricoh.com> Message-ID: <39BFD47F.FBC4528E@holdenweb.com> Bob Alexander wrote: > > Seems as though most members of this list are pretty happy with the > recent Augmented Assignment PEP definition. > Well in that case count me as a member of the minority :-( There seems to be a more autocratic feel to recent changes, but then the BDFL has earned the right to go his own way, not matter how ill-advised we lesser mortals may feel the path to be. As a brief aside, I can't help feeling it ought to be easier to locate the PEP list from both www.python.org and www.pythonlabs.com. On the former, all a search for PEP reveals is a list of python-dev summaries. The latter doesn't even appear to have a search feature at all. This all adds to the feeling that "these people have something to hide" -- which I don't really believe. Compared with Microsoft's process, for example, the Python world sa model of openness. For the record, see http://python.sourceforge.net/peps/ > As a proponent of *true* augmented assignment, though, I suggest we > rename that new feature in Python to something more appropriate to the > definition. Like "sometimes-augmented sometimes-assignment". Or "totally > new operators having little to do with assignment". :-) > > Note that in > > a = [] > a += [33] > > neither "+" (list concatenation) nor "=" (assignment) are performed > *. > > Furthermore, in > > a = [] > b = a > a += [33] > > b changes. Neither "+" (list concatenation) nor "=" (assignment), would > affect b at all. > This is the show-stopper for me. There's been enough discussion on this list about these new semantics to make me hesitate to enter the fray at this late stage, but frankly it seems to be asking for trouble to implement an augmented assignment operator where the semantics of x = are so different from x = x operand I imagine that many hours of time will be wasted explaining to Pythion newbies on comp.lang.python why these unpleasant side-effects occur. > Since neither assignment nor the operation suggested by the binary > operator bundled with the "=" take place in the above examples, and > since new side effects occur that would not happen in pure augmented > assignment, how could it be appropriate to call it such? > It will be called what the BDFL wants it to be called... > And then there's > > tup = () > lst = [] > tup += (33) > lst += [33] > > The last two lines look about the same but have different semantics! In > pure augmented assignment the semantics would be parallel, and would be > exactly what is suggested by the two characters of the "+=" operator. > > Bob > > * (TM) used without permission. This also confuses me, but then I'm a bear of very little brain *. Surely this can't be the intention of the PEP? Are immutables going to be mutable-in-place now? You must have misunderstood! Since 1.5.2 gives: >>> tup = () >>> tup = tup + (33) Traceback (innermost last): File "", line 1, in ? tup = tup + (33) TypeError: illegal argument type for built-in operation why should there be *any* legality to the augmented assignment operator applied to tuples? However, to quote the PEP: "The idea behind augmented assignment in Python is that it isn't just an easier way to write the common practice of storing the result of a binary operation in its left-hand operand, but also a way for the left-hand operand in question to know that it should operate `on itself', rather than creating a modified copy of itself." This is the heart of it as far as I'm concerned. In 1.5.2 and preceding implementations we have got used to the idea that a variable is, in fact, a pointer (or reference) to a value, and that if we "modify the value of a variable" we are actually computing a new value and then replacing the current variable's content with a reference to that new value. I've used such languages before -- in fact, I was a long-term Icon fanatic -- and I just don't feel there's ANY room for in-place modification of this nature, which goes counter to the whole semantics of assignment. In point of fact, my belief is that this proposal, if it goes through, puts an *implementation bias* into the language definition whoch goes far beyond the ugly but acceptable "print >>". This is being done, I suspect, to make certain operations more efficient by avoiding the need to create a new object. It sucks! Sure enough, a little further down the PEP we see: "To work around this problem, the packages currently have to use methods or functions to modify an object in-place, which is definitely less readable than an augmented assignment expression. Augmented assignment won't solve all the problems for these packages, since some operations cannot be expressed in the limited set of binary operators to start with, but it is a start. A different PEP[2] is looking at adding new operators." As far as I'm concerned, if you need to modify objects in place *for efficiency reasons* then you should expect to have to put up with a loss of readability. Efficiency should have little to do with the language definition: that's an implementation issue. It's not that I'm against the introduction of in-place modification where programs will benefit. It's just that I don't think the syntax should be such as to mislead naive programmers in the way this proposal will. I would *far* prefer augmented assignment to have the standard semantics of the existing binary operations, and then use a modified syntax such as a +!= [33] to implement the semantics that currently proposed. If PEP 203 makes it in to the language I suspect my personal solution will be to simply ignore the "feature". But I do feel we are laying down trouble for future Python learners due to the totally counter-intuitive nature of this porposal. Well, I don't imagine that my little rantings are going to alter the course of Python history, but thanks for giving me the chance to at least express my feelings! regards Steve * My way of indicating that I feel something is going wonky :-) -- "In-place value modification? Can you say 'blerch'?" 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ From aahz at panix.com Sat Sep 23 20:38:51 2000 From: aahz at panix.com (Aahz Maruch) Date: 23 Sep 2000 17:38:51 -0700 Subject: 1.6 or 2.0b1? References: <39CD2674.66158180@nycap.rr.com> Message-ID: <8qjier$sdf$1@panix3.panix.com> In article <39CD2674.66158180 at nycap.rr.com>, Grant Austin wrote: > >I'm new to programming in all respects, and am wondering if I should >start with python 1.6 or 2.0b1? I'd start with 1.5.2 now and switch to 2.0final later. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 'Some people, when confronted with a problem, think "I know, I'll use regular expressions". Now they have two problems.' --Jamie Zawinski, comp.lang.emacs From a.lempereur Fri Sep 15 17:50:51 2000 From: a.lempereur (Brett Lempereur) Date: Fri, 15 Sep 2000 21:50:51 GMT Subject: Yes!! Message-ID: <%Qww5.3382$ZN4.510092@news1.cableinet.net> Yes Craig won big brother!! yay! From rhicks at nospam.rma.edu Sat Sep 16 16:21:31 2000 From: rhicks at nospam.rma.edu (Robert) Date: Sat, 16 Sep 2000 20:21:31 GMT Subject: Python binary for MacOSX DP4 References: <8pvsme$pe0@dispatch.concentric.net> Message-ID: I would like one too! "Phlip" wrote in message news:8pvsme$pe0 at dispatch.concentric.net... > Newsgroupies > > I could not locate a Python binary for what might be called Rhapsody. > > The one link I found was dead. > > Then I found a list server post claiming compiling the GNU project for > FreeBSDi was a slam-dunk. > > So I dunked BeOpen's Python, and got a "evil signal 11" exception. > > Other fora revealed this is a generic "out of memory" or "I'm so confused" > exception and should not be fixed. > > I tried to compile Python 1.6, and this compiled many more modules before > the russian roulette game ended. > > Then I tried 1.5.2, and it finished compiling. Only a few trivial hacks to > the Makefile were required to let it install gracefully. > > Irregardful of all that passion, does anyone have a Python 2 binary for > Rhapsody they can slap on a site somewhere? > > 1.5.2 is just so 20th Century! > > -- > adverbly-signatorialy yours, > Phlip > ======= http://users.deltanet.com/~tegan/home.html ======= > > From jonadab at bright.net Fri Sep 8 04:46:34 2000 From: jonadab at bright.net (Jonadab the Unsightly One) Date: Fri, 08 Sep 2000 08:46:34 GMT Subject: Reuse Py Modules twixt Linux & Windoze? References: Message-ID: <39b79336.13711959@news.bright.net> kragen at dnaco.net (Kragen Sitaker) wrote: > I'll hazard a guess that Win32 Python will be perfectly happy with > \r-less files. \r is CR. Almost certainly. If not, I can write a Perl script that will strip the CRs out and pass what's left to your Python terp, and you could associate the .py extension with that script. I can't believe I said that with a straight face in this group. - jonadab From aahz at panix.com Fri Sep 22 18:48:25 2000 From: aahz at panix.com (Aahz Maruch) Date: 22 Sep 2000 15:48:25 -0700 Subject: Any suggestions? References: <8qg9o5$hu0$1@nnrp1.deja.com> <8qgch1$dls$1@panix3.panix.com> <8qgev7$oir$1@nnrp1.deja.com> Message-ID: <8qgnjp$183$1@panix6.panix.com> In article <8qgev7$oir$1 at nnrp1.deja.com>, wrote: >Aahz: >> >> That seems a little odd. Are these non-trivial projects? Have you done >> any work to optimize the Python code? > >I didn't know I could. Of course you can. Here's a simple example: str = '' for word in words: str = str + ' ' + word That code can be easily optimized to str = string.join(words) Every language has its efficient coding tricks; the neat thing about Python is that once you've gotten a decent handle on its tricks, you can concentrate on algorithmic improvements -- even if your C code is a hundred times faster than the Python code, you'll be unhappy as soon as you hit non-trivial inputs if your C code is O(N^2) and your Python code is O(NlogN). -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Member of the Groucho Marx Fan Club --Aahz From matt at mondoinfo.com Sat Sep 16 16:33:08 2000 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Sat, 16 Sep 2000 20:33:08 GMT Subject: setting the font in Tkinter References: Message-ID: On Sat, 16 Sep 2000 01:47:11 GMT, Rick Pasotto wrote: >How do I set the default font for a window and all its widgets? The >system default is too small. If there's a way, I don't know what it is. And more to the point, it seems that Fredrik Lundh doesn't know one either since such a thing isn't mentioned in his excellent Introduction to Tkinter, at http://www.pythonware.com/library/tkinter/introduction/index.htm It seems that it's necessary to set widgets' fonts individually. Regards, Matt From snake-or-bear at worldofbeverage.net Wed Sep 13 16:34:23 2000 From: snake-or-bear at worldofbeverage.net (ARG3000) Date: Wed, 13 Sep 2000 15:34:23 -0500 Subject: newbie gimp python question! Message-ID: I am simply trying to open a drawing! I haven't been able to find a complete list of calls supported by gimp.whatever(). This is really frustrating! From just at letterror.com Sat Sep 2 11:55:40 2000 From: just at letterror.com (Just van Rossum) Date: Sat, 02 Sep 2000 16:55:40 +0100 Subject: Python 1.6 The balanced language References: <39AB712E.805ACB4B@nowonder.de> <8oknrp$aho$1@nnrp1.deja.com> <39B0AE58.3A9DDB0D@seebelow.org> Message-ID: <39B122CB.86D29C3C@letterror.com> Grant Griffin wrote: > > lobozc at my-deja.com wrote: > > > ... > > 3) My particular favourite is Icon (see www.cs.arizona.edu/icon). > > Particular aspects of some interest to Python would be goal-directed > > evaluation [saves helluva lot of lines of code...] and, less > > importantly, generators and coexpressions. I have no idea how difficult > > it would be to move these ideas to Python. But I (and many other > > people) can vouch that these mechanisms are very effective in writing > > very 'large' programs in a surprisingly small number of lines. I must > > stress here that this happens not the way Perl does it - but rather > > like in functional languages. That is: because of the built in > > mechanisms of evaluation. So it is readable :-), not just terse. > > Speaking as an experienced programmer who has no idea what all that > schtuff is, I personally hope Python continues to do without it. I have no idea what "goal-directed evaluation" is, but generators and co-routines are pretty straightforward. They're not any harder to understand and use than threads. Co-routines are in fact a lot like threads, except that context switching is explicit. One co-routine simply tells another one "ok, now *you* continue, while I get some rest". The best thing about them is that you can pass a value from one co-routine to the other when you switch. In terms of threads: if you have two threads working together, but one is always just waiting for the other to deliver something, you really have two co-routines. Except that when you'd write that using actual co-routines, you minimize two things: context switching overhead (almost zero with a proper co-routine implementation) and thread synchronization overhead (say, the overhead of a queue object). Your code will look cleaner while it will be faster at the same time. And of course, Stackless Python makes it possible.. Just From tim_one at email.msn.com Tue Sep 12 15:44:11 2000 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 12 Sep 2000 15:44:11 -0400 Subject: Python 1.6 The balanced language In-Reply-To: <39BE0B75.E6A8712@appliedbiometrics.com> Message-ID: [Christian Tismer] > But that's the point: > JPython does not have an extra VM, but emits java VM > code. That means: Having coroutines for JPython is > the same question as having coroutines in Java: Is > it possible without changing the Java VM? > > I'm proetty shure it is impossible by creating java scourcecode, > but I'm no longer sure that the VM is incapable to do it. > This code would just have no Java equivalent. > Yet another decompile barrier :-) Jcon is to Icon as JPython is to CPython. While Icon's coexpressions are spottily implemented across "real machines" , via excruciating platform-specific assembler to fool the C stack, Jcon simply implements them on top of Java threads. So the JVM doesn't really enter into it for them (no more than the PVM enters into my ancient thread-based coroutine pkg for Python). you-didn't-say-anything-about-being-usably-fast-ly y'rs - tim From g2 at seebelow.org Thu Sep 21 14:27:56 2000 From: g2 at seebelow.org (Grant Griffin) Date: 21 Sep 2000 11:27:56 -0700 Subject: What is Python? References: <8pqhm9$6a9$1@panix3.panix.com> <3BBC75F01B2A2291.3CC54B93C0C69DED.4E021EA85330C94C@lp.airnews.net> <8pt65c$cbs$2@newshost.accu.uu.nl> <39C29336.71ED41AC@seebelow.org> <39C3E664.BCEAF741@seebelow.org> <39C67A2C.2313778A@seebelow.org> Message-ID: <8qdjvc02ebg@drn.newsguy.com> In article , tim at degree.ath.cx says... > >Grant Griffin wrote: >> I'm sure Larry Wall is a nice guy, but his language is pretty mean: it >> has more "$@#!$!" curse words than a "Beetle Bailey" comic strip on one >> of Sarge's bad days. [snipped nauseating pseudo-emot] In article , tim at degree.ath.cx says... > >Grant Griffin wrote: >> I'm sure Larry Wall is a nice guy, but his language is pretty mean: it >> has more "$@#!$!" curse words than a "Beetle Bailey" comic strip on one >> of Sarge's bad days. [snipped nauseating pseudo-emot] Sorry about all those "nauseating pseudo-emot's", as you call them, Tim--I have kind of a bad habit on those. <'wink' expurgated> But since you're already fluent in Perl, next time you see comp.lang.python's favorite pseudo-emot, you might just want to think of its comp.lang.perl.misc mantral analog: "Why don't you just grep the FAQ, idiot?" (Which reminds me: What _is_ Python? ) >Those curse symbols have spoiled me, I admit. When I can just tell by >looking at a variable whether it's a scalar, array, hash, or function >instead of having to remember how I defined it to begin with, I can >get on with the coding. This comes in handy in scaled apps when you >can't remember defining it at all. Hey, if you're a fan of "Hungarian Notation", that'll work just fine in Python: just use a naming convention of your choice in place of Perl's punctuation. (But I don't think Tom Christiansen is gonna approve...) i-seem-to-recall-that-he-doesn't-like-hungarian,-but-i-didn't -actually-find-anything-about-it-when-i-grepped-the-perl-faq -just-now--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 scott.jeslis at tellabs.com Thu Sep 7 11:41:50 2000 From: scott.jeslis at tellabs.com (scott.jeslis at tellabs.com) Date: Thu, 07 Sep 2000 15:41:50 GMT Subject: JPython can't find script from a command line. Message-ID: <8p8cvp$qk7$1@nnrp1.deja.com> I'm having trouble with JPython picking up my python.path from my registry file when I invoke JPython with a script from a NT/DOS command line, e.g. c:> jpython alarms.py I end up with an IOError. If I type the full path name on the script then JPython can find it. If I run interactively and use import then JPython can find it. Is python.path just for imported modules? -- Scott Jeslis Lead Engineer Tellabs Operations, Inc. Sent via Deja.com http://www.deja.com/ Before you buy. From thor at localhost.localdomain Sun Sep 10 16:20:06 2000 From: thor at localhost.localdomain (Manuel Gutierrez Algaba) Date: 10 Sep 2000 20:20:06 GMT Subject: readline() with arbitrary end of lines References: <1egcl2y.1rzwdz01k9rsh8N%see.below@no.spam.es> Message-ID: On Sun, Javier Bezos wrote: >Hello, > >I'm using MacPython 1.5.2c1 to read several files with >the help of readline(). However, the files to be read can >have either Mac or Unix end of lines and it seems that only >Mac end of lines are recognized; changing linesep has no >effect at all. > >Here is an example. With a little file named test.txt > > Line 1 > Line 2 > Line 3 > >and the following short script > > a = open("test.txt", "r") > print a.readlines() > >I get > > ['Line 1\012', 'Line 2\012', 'Line 3'] > >with Mac end of lines (right), but > > ['Line 1\015Line 2\015Line 3'] You can do this: import string b=[] for i in a: for j in string.split(a,"\015"): if j[-1]=="\012": b.append(j[-1]) else: b.append(j) In b there's all the lines, independtly of the OS. You can wrap it into a function. Forgive us for not giving a better solution, we have been adding more important things like "print>>" and other stuff. >Can Python detect and convert transparently different >end of lines (as Tcl or Java can)? If not, can Python read >until a certain text is found (as AppleScript can)? > --- MGA From juergen.erhard at gmx.net Wed Sep 6 11:52:29 2000 From: juergen.erhard at gmx.net (=?ISO-8859-1?Q?=22J=FCrgen_A=2E_Erhard=22?=) Date: Wed, 06 Sep 2000 17:52:29 +0200 Subject: multithreading on Linux In-Reply-To: <8p0g2v$cul$1@panix3.panix.com> (aahz@panix.com) References: <8ovoan$asq$1@nnrp1.deja.com> <8p0g2v$cul$1@panix3.panix.com> Message-ID: <06092000.1@sanctum.local.jae.ddns.org> Hi Aahz, From README.Debian.gz in Debian 2.2's python-base package: - Threading support enabled. So, "the Python included on shipping Linux distributions" is (at least partially) incorrect. But I'd wager there are more distributions which do that (RH relies heavily on Python, so they might as well). 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 GNOME Desktop Project (http://www.gnome.org) Win32 has many known work arounds. For example, Linux. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 248 bytes Desc: not available URL: From daniel.andersson at centrumeh.com Mon Sep 11 04:05:08 2000 From: daniel.andersson at centrumeh.com (Daniel Andersson) Date: Mon, 11 Sep 2000 10:05:08 +0200 Subject: freeze.py Message-ID: Hi Im having problems with the freeze tool in 2.0b1. I have tried it on both Windows2k and solaris and they both spit out this: >python freeze.py -o /export/home/brutal/freeze hello.py Traceback (most recent call last): File "freeze.py", line 457, in ? main() File "freeze.py", line 321, in main mf.import_hook(mod) File "modulefinder.py", line 106, in import_hook q, tail = self.find_head_package(parent, name) File "modulefinder.py", line 147, in find_head_package q = self.import_module(head, qname, parent) File "modulefinder.py", line 233, in import_module m = self.load_module(fqname, fp, pathname, stuff) File "modulefinder.py", line 261, in load_module self.scan_code(co, m) File "modulefinder.py", line 281, in scan_code self.import_hook(name, m) File "modulefinder.py", line 106, in import_hook q, tail = self.find_head_package(parent, name) File "modulefinder.py", line 147, in find_head_package q = self.import_module(head, qname, parent) File "modulefinder.py", line 233, in import_module m = self.load_module(fqname, fp, pathname, stuff) File "modulefinder.py", line 261, in load_module self.scan_code(co, m) File "modulefinder.py", line 281, in scan_code self.import_hook(name, m) File "modulefinder.py", line 106, in import_hook q, tail = self.find_head_package(parent, name) File "modulefinder.py", line 147, in find_head_package q = self.import_module(head, qname, parent) File "modulefinder.py", line 233, in import_module m = self.load_module(fqname, fp, pathname, stuff) File "modulefinder.py", line 261, in load_module self.scan_code(co, m) File "modulefinder.py", line 303, in scan_code self.scan_code(c, m) File "modulefinder.py", line 281, in scan_code self.import_hook(name, m) File "modulefinder.py", line 106, in import_hook q, tail = self.find_head_package(parent, name) File "modulefinder.py", line 147, in find_head_package q = self.import_module(head, qname, parent) File "modulefinder.py", line 233, in import_module m = self.load_module(fqname, fp, pathname, stuff) File "modulefinder.py", line 261, in load_module self.scan_code(co, m) File "modulefinder.py", line 289, in scan_code assert lastname is not None AssertionError I have also tried freeze.py on an old 1.5.2 linux install and it worked fine there. What gives? cheers /Daniel From bhellao at my-deja.com Fri Sep 15 23:59:39 2000 From: bhellao at my-deja.com (Opinderjit) Date: Sat, 16 Sep 2000 03:59:39 GMT Subject: Is vars() meant to include globals? References: <8pso8m$686$1@nnrp1.deja.com> Message-ID: <8pur74$jfb$1@nnrp1.deja.com> Where does the "classvar" variable go? It doesn't seem to be contained in vars(), locals() or globals(). In article <8pso8m$686$1 at nnrp1.deja.com>, Hamish Lawson wrote: > My understanding was that all variables known to a given scope would be > listed in vars(), effectively the union of globals() and locals(). > However inside both SomeClass's __init__() and somefunc() in the > program below, vars() gives just the local variables. But the global > variable globalname is known in each case. Have I misunderstood about > vars()? > > Hamish Lawson > > ------------------------------------------------------------- > > globalname = "Bob" > > class SomeClass: > > classvar = 3 > > def __init__(self, param): > localvar = 4 > print 'globals():', globals() > print 'locals():', locals() > print 'vars():', vars() > print 'globalname:', globalname > > def somefunc(param): > localvar = 2 > print 'globals():', globals() > print 'locals():', locals() > print 'vars():', vars() > print 'globalname:', globalname > > SomeClass("Joe") > print > somefunc("Sue") > > This gives: > > globals(): {'globalname': 'Bob', '__doc__': None, 'somefunc': somefunc at 78f210>, 'SomeClass': 78f1f0>, '__name__': '__main__', '__builtins__': (built-in)>} > locals(): {'self': <__main__.SomeClass instance at > 78f230>, 'param': 'Joe', 'localvar': 4} > vars(): {'param': 'Joe', 'self': <__main__.SomeClass instance at > 78f230>, 'localvar': 4} > globalname: Bob > > globals(): {'globalname': 'Bob', '__doc__': None, 'somefunc': somefunc at 78f210>, 'SomeClass': 78f1f0>, '__name__': '__main__', '__builtins__': (built-in)>} > locals(): {'param': 'Sue', 'localvar': 2} > vars(): {'param': 'Sue', 'localvar': 2} > globalname: Bob > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From wlfraed at ix.netcom.com Thu Sep 7 23:36:37 2000 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Thu, 07 Sep 2000 20:36:37 -0700 Subject: Python 2.0b1 is released! References: <39B76977.31E0920@users.ch> Message-ID: On 07 Sep 2000 19:38:57 +0200, Bernhard Herzog declaimed the following in comp.lang.python: > Well, "Adder" would keep with the tradition of referring to comedy TV > programs and it would even be related to computing. True... and as I recall, it would be the only truly British serpent too -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From cnsg at my-deja.com Tue Sep 19 10:12:44 2000 From: cnsg at my-deja.com (Jeff) Date: Tue, 19 Sep 2000 14:12:44 GMT Subject: Beginner question Message-ID: <8q7s89$i95$1@nnrp1.deja.com> Hello, I am currently working in sales and marketing for the below mentioned company, and our senior project manager thought it would be a good idea for me to learn some programming in order to better understand computer software and operating systems, etc. I learned some of a student programming language years ago, but when it comes to more professional packages, I don't know what their file names mean even on what to download. The senior project manager here has been reading good things about python and stated I should download that on a windows platform. Further, I use a dial up modem at home, and a 21 meg file is a bit much for me. Can anyone give me a bit of a background on what I need to download and what tutorials are available to me on the web? Also, should I use cpython or jpython? Any replies would be appreciated. -- http://www.cnsgsolutions.com Complete Business Solutions Sent via Deja.com http://www.deja.com/ Before you buy. From jbauer at rubic.com Thu Sep 14 14:19:19 2000 From: jbauer at rubic.com (Jeff Bauer) Date: Thu, 14 Sep 2000 13:19:19 -0500 Subject: Public Domain Python References: Message-ID: <39C116A7.2A4D4822@rubic.com> Cameron Laird wrote: > I've been arguing for free and open-source software > for years, and I'm still subject to transmission of > the dumbfounded-and-slackjawed look when a manager > whines about the license of *Python*. 'Anyone know > a graceful way to explain the violence SAP, Microsoft, > CA, Oracle, ... do with *their* licenses? Several years ago Terry Pratchett and Neil Gaiman wrote a book titled "Good Omens". One of the protagonists, demon-from-hell Crowley, sends a Microsoft licensing agreement down to the infernal Contracts Division with an advisory note scribbled across the top: "Learn, guys." -Jeff From bjorn at roguewave.com Tue Sep 12 17:51:36 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Tue, 12 Sep 2000 15:51:36 -0600 Subject: Getting the code of a character ? References: <8pm63u$29p$1@reader1.imaginet.fr> Message-ID: <39BEA568.D51FE2D3@roguewave.com> x = ord('x') -b Gilles Lenfant wrote: > > Yes, a real newbie question ! > How to get the code number of a character like : > x = asc("x") in stupid Basic ? > > TIA > > -- > http://www.python.org/mailman/listinfo/python-list From g2 at seebelow.org Mon Sep 18 03:25:45 2000 From: g2 at seebelow.org (Grant Griffin) Date: Mon, 18 Sep 2000 08:25:45 +0100 Subject: What is Python? References: <8pqhm9$6a9$1@panix3.panix.com> <3BBC75F01B2A2291.3CC54B93C0C69DED.4E021EA85330C94C@lp.airnews.net> <8pt65c$cbs$2@newshost.accu.uu.nl> <39C29336.71ED41AC@seebelow.org> <39C3E664.BCEAF741@seebelow.org> Message-ID: <39C5C379.BD3FF8B9@seebelow.org> Tim Hammerquist wrote: > > Grant Griffin wrote: > > p.p.s. If you ever decide to drop Perl completely, in favor of Python, > > please don't convince Tom Christiansen to do the same. > > If I ever decide to drop Perl completely, shoot me. I don't like to > limit my options. See, that's the thing about Perl right there: nobody ever applied a sensible limit to its options. <0.1 wink> Actually, if I were the shooting type, you wouldn't be the first Perl-er to take a bullet. not-to-name-any-names-ly y'rs, =g2 p.s. Did I mention that I first caught onto Python when I read "Advanced Perl Programming"? IIRC, one of the author's footnotes says something like "But Python is my favorite OO scripting language". So if you want to continue to use Perl, I'd recommend you do so mainly so you can write books about it. -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From kuchler at ajubasolutions.com Sat Sep 23 14:34:02 2000 From: kuchler at ajubasolutions.com (Dan Kuchler) Date: Sat, 23 Sep 2000 11:34:02 -0700 Subject: app slow down References: <39CD415A.CC498224@uni-bremen.de> Message-ID: <39CCF79A.7B383EFE@ajubasolutions.com> me wrote: > > Hi; > > My application shows strange delays at several points. Opening Window a) > > needs 2 minutes - opening another similar Window b) 2 secounds. The > application does not do any > computations that can cause such delays. I used truss to pin down the > problem . The interpreter sleeps in read - 60..120 secounds - read(6, > 0x0071FD7C, 5120) (sleeping...) - and then starts again. > > This happends on my Solaris 8 (6/2000) installation with python 1.52 and > 1.6 (with TclTk 8.3 , Pmw and PyXML). I think some change in my > application triggered is ?? > > I searched the FAQs for knows Bugs or programming errors that can cause > this but did't found > anything .... > Any ideas how to solve this are welcome ! > What window manager are you using? This problem you describe might be specific to the window manager that you are using. --Dan From neilh at scintilla.org Sat Sep 9 06:28:46 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Sat, 09 Sep 2000 10:28:46 GMT Subject: Python Class iteration howto ! References: <8pd1k7$6t9$1@nnrp1.deja.com> Message-ID: Sindh wrote: > Suppose I have a class xyz with attributed name,age,sex,address etc. How > do I iterate the values. > ... > def iter(a): > for n in dir(a): > print a.n def iter(a): for n in dir(a): print a.__dict__[n] Neil From kirschh at lionbioscience.com Wed Sep 20 07:38:21 2000 From: kirschh at lionbioscience.com (Harald Kirsch) Date: 20 Sep 2000 13:38:21 +0200 Subject: where is upvar Message-ID: In Tcl there exists the possibility to create in a function an alias for a variable in the calling stack frame. The mechanism is upvar parentsVar myNameForParentsVariable Every reference to myNameForParentsVariable in fact reads or writes the variable in the calling stack frame. Is there such a mechanism in python besides doing things like eval(theScriptReturnedByThisFunctionCall()) in the calling function? And then, how can I check if a certain variable exists in a given stack frame? Harald Kirsch -- ----------------+------------------------------------------------------ Harald Kirsch | kirschh at lionbioscience.com | We make the tools to LION Bioscience | +49 6221 4038 172 | reverse engineer nature. From sholden at holdenweb.com Thu Sep 14 12:56:11 2000 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 14 Sep 2000 12:56:11 -0400 Subject: socket problem? References: <857l8ir5wh.fsf@localhost.rgz.ru> <8pkerq$iq9$0@216.39.151.169> <8566o1r8xs.fsf@localhost.rgz.ru> <854s3kquv4.fsf@localhost.rgz.ru> <851yyn8lsc.fsf@localhost.rgz.ru> Message-ID: <39C1032B.D7E25B8B@holdenweb.com> Zajcev Evgeny wrote: > > actually I'm intented in creation not in destruction > but I need understand TCP, UDP over IP in lowerest level > whithout understanding, network programming became > waste spending time IMHO. > I chose python for learning protcols becouse of it is greate programming > language :) > You can develop understanding without programming the complete TCP transport layer over again! > by the way one of application of sending random tcp packets over sock_raw is > some printers have telnet service and have no authentification > so if any user telnet on it he have administrator privileges > the solution of this problem: > your PC in the same sub-net with who want to telnet to printer > sniifing net, and when there any SYN packet to printer:23 > send to printer RST packet from villain address (ACK and souce port is knowing from sniffing)so he even cant estableash connect. > This seems pretty extreme, but does at least explain why you might want to simulate a TCP reset using a raw socket. However, have you checked that the IP layer in the printer will respond as you want? It all depends on how it uses the ARP cache, since some IP implementations won't accept packets from the same IP address and different MAc addresses. One of the reasons is to avoid accepting the spoofed packets you are intending to raise! Wouldn't it be simpler to impose some sort of filtering at the printer, or simplt to turn the telnet service off? regards Steve > thanks for helping. > > -- > zev -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ From mail at jbrisbin.net Fri Sep 29 10:14:25 2000 From: mail at jbrisbin.net (Jon Brisbin) Date: Fri, 29 Sep 2000 09:14:25 -0500 Subject: version 0.7.0a of Python Server Pages References: <8qtkoc$jmt$1@saltmine.radix.net> Message-ID: Cary O'Brien wrote in message news:8qtkoc$jmt$1 at saltmine.radix.net... > Couple-o-things > > 1) Isn't there another Python Server Pages project out there, one > that uses JPython? yes...the webware distribution also has a PSP implementation, as does the mod_snake project...there are also a number of home-grown PSP implementations floating around... > 2) Is this a pure interpreter, or are the pages turned into byte-compiled > python .pyc files? basically, it simulates the JSP implementation in that it turns your webpage into pure python code by putting print """\ ... """ around your HTML, and using the [$...$] convention to indent your code (i.e. for if's def's while's , etc...) and the [+...+] but putting a print statement in front of that block...then it exec's your code *within* the current namespace, which, to me, is important for cuurent and later functionality that isn't built in quite yet...it does *not* compile the code, however...it just parses it to create pure python code, then exec's that...the compilation and caching feature is down the line... i *first* wanted to create an implementation that was extremely small and easy to integrate with the absolute most set-ups without making you install anything extra, or depending on some other package to be installed for this to work...eventually there will be fastcgi support, mod_snake (probably the first supported), and several others... > 3) Any reason not to switch to the JSP <> based tag format? People, and > more importantly web-page editors, are used to looking at <> based tags. my implementation of PSP will support several diffent syntax types, like ASP/JSP (<% and <%=) and PHP ()...another PSP implementation uses <%psp %>...but I personally like the Embeded perl method, which is the one I adopted for several reasons...the most important of which is that my parser must use the second character of the delimiter to determine what to do with that block of code. i suppose i could have used the <%@ syntax instead of [$, but what I'm using now is one character less to type, and the length of the delimiter doesn't change (always 2 :-). while working on this, i usually have the Page.proc_total_time (or self.proc_total_time :-) displayed on my pages and I notice that every single line of code that is inserted that has to do something to parse my code bumps the time up by 1 or 2 thousandths every line...so I'm going to constantly try and lessen that by keeping fancy stuff to a minimum and not do anything more than absolutely neccessary to parse and exec the code... > Keep up the good work! thanks! Jon Brisbin Python ServerPages http://www.jbrisbin.net/PythonServerPages From tdelaney at avaya.com Sun Sep 24 21:52:29 2000 From: tdelaney at avaya.com (Delaney, Timothy) Date: Mon, 25 Sep 2000 12:52:29 +1100 Subject: Functional Programming (was: Of what use is 'lambda'???) Message-ID: The difference is that in *pure* functional programming, everything *only* returns a parameter. There are no side effects of any kind. Obviously, pure functional programming is not much use ... so functional languages usually have a few functions which do have side effects (for example, i/o routines). However, if you treat these as black boxes, you can do your programming entirely functionally. So, this means you can't have a function such as (pseudocode) function add (a, b) temp = a + b // side effect a = 4 return temp a = 1 b = 2 c = add(a, b) Results: a == 4 b == 2 c == 3 If you wanted to modify a you would have to assign it directly or call a function and assign the result to a. > -----Original Message----- > From: jonadab at bright.net [mailto:jonadab at bright.net] > Sent: Monday, 25 September 2000 12:38 PM > To: python-list at python.org > Subject: Re: Of what use is 'lambda'??? > > > Erik Max Francis wrote: > > > > I have a question. What is the difference between functional > > > programming and procedural programming? I know I should know > > > this, but... > > > > To start with, in functional programming everything returns a value. > > That's true in C and Inform, but I think both are traditionally > regarded as procedural. Is the difference that the returned > value is always significant? Or is there more? > > - jonadab > -- > http://www.python.org/mailman/listinfo/python-list > From darrell at dorb.com Tue Sep 26 09:39:54 2000 From: darrell at dorb.com (Darrell Gallion) Date: Tue, 26 Sep 2000 09:39:54 -0400 Subject: Using the re module (Regular expressions) References: Message-ID: <066801c027bf$421122f0$6401a8c0@home> Try this r'(?s)Returned-Path:\s<.*>\012Recieved:' --Darrell ----- Original Message ----- From: "Morten W. Petersen" > I want to match a string, 'Returned-Path: \nRecieved:'. > > Why doesn't re.compile(r'Return-Path:\s<.*>^Recieved:',re.MULTILINE) return > a search object that'll match that line? > From robin at jessikat.fsnet.co.uk Tue Sep 12 03:29:50 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Tue, 12 Sep 2000 08:29:50 +0100 Subject: Numpy 16.0 binaries available? (Win32) References: <39BD90C7.94D7D559@home.com> Message-ID: In article <39BD90C7.94D7D559 at home.com>, mykbourassa at home.com writes >Hi. I'm a Python newbie trying to kick the Matlab habit. I've got Python >2.0beta for Win. does anyone have a Numpy for that version? (I'm not into >Linux yet. One new thing at a time :-) > >myk ... please ask the NumPy developers to provide a location for these. I'm fed up with mailing them it's on its way -- Robin Becker From bristol at users.ch Tue Sep 12 10:34:54 2000 From: bristol at users.ch (Bristol) Date: Tue, 12 Sep 2000 16:34:54 +0200 Subject: Python 1.6 The balanced language References: <39AB712E.805ACB4B@nowonder.de> <39BE0B75.E6A8712@appliedbiometrics.com> Message-ID: <39BE3F0E.4A84EF3A@users.ch> Christian Tismer wrote: > > [...] having coroutines in Java: Is > it possible without changing the Java VM? > > I'm proetty shure it is impossible by creating java scourcecode, > but I'm no longer sure that the VM is incapable to do it. > This code would just have no Java equivalent. Quite the suspense. I am sure I'm not the only one that would be delighted just by the principle of it before even the practice. A computer-language equivalent to famous "sealed" litterature. True wizardry ;-) BTW, I wonder if the time has not come to transpose Unicode from the case of language alphabets to that of VM alphabets - e.g. "VM bytecode strings". Imagine a lib giving access to a bunch of different VMs. BTW^2 : does someone possess a pointer to a summary of .NET ?... I have no heart to forage ms.com for it. - B. From hzhu at users.sourceforge.net Fri Sep 29 19:46:38 2000 From: hzhu at users.sourceforge.net (Huaiyu Zhu) Date: Fri, 29 Sep 2000 23:46:38 GMT Subject: PEP: Adding new operators for elementwise/objectwise operations References: <8q7u9k$kso$1@nnrp1.deja.com> <39D2609B.EF5948BF@spacenet.tn.cornell.edu> <8qvb8e$23i$1@slate.INS.CWRU.Edu> Message-ID: On 28 Sep 2000 11:49:34 GMT, Kevin Jacobs wrote: >Tom Loredo wrote: >> I am developing a statistical computing framework in Python, and may use >> "~" in this already-accepted fashion; I would hate to see its meaning >> "overloaded" this way. > >If possible, I suggest that you bring your statistical computing framework >ideas to the newsgroup, or at least the very motivated subset of us who are >thinking about or working on the same thing. Personally, my dream is to >have a Python based environment that will allow me to throw away SAS and >S-Plus. That would be very useful indeed. Count me in the subset, please. I had attempted to implement some of that functionality in Matlab sometime ago. Of course Python would be a much better tool. > >-Kevin > >PS: Just to put in my vote, I am strongly for having the ability to > overload ~ operators. I too use BUGS, and while its a neat trick, > its ~ operator is pure syntactic sugar. The PEP on new operators > addresses readability and maintainability, which are major issues > when an expression may have upwards of 10 infix operators (vs. > BUGS which uses at most one ~ per statement). > Exactly. I've just viewed the BUGS pages, and indeed the ~ operator is binary and can only appears once per statement. I think that using a function or a method call would achieve similar effect. If we really need this kind of syntactic sugar we could overload a binary operator like a^b., for example. Huaiyu -- Huaiyu Zhu hzhu at users.sourceforge.net Matrix for Python Project http://MatPy.sourceforge.net From johngrayson at home.com Thu Sep 14 16:39:12 2000 From: johngrayson at home.com (John Grayson) Date: Thu, 14 Sep 2000 20:39:12 GMT Subject: PMW ComboBox width? References: <75F7304BB41CD411B06600A0C98414FCB368F6@ORSMSX54> Message-ID: <8prd1c$lsi$1@nnrp1.deja.com> In article <75F7304BB41CD411B06600A0C98414FCB368F6 at ORSMSX54>, "Daley, Mark W" wrote: > OK, I figured out the list update thing for the PMW ComboBox. I need to get > more docs. Now that I have been poring over the docs for two days, I can't > figure out how to adjust the width of the ComboBox. Is this possible? I > would think it is, since the listbox component of the MegaWidget allows it, > but I can't seem to find the right syntax. > > - Mark > Try this: combobox.component('entryfield').component('entry').configure(width=10) John Grayson Sent via Deja.com http://www.deja.com/ Before you buy. From billtj at z.glue.umd.edu Wed Sep 27 11:01:46 2000 From: billtj at z.glue.umd.edu (William Djaja Tjokroaminata) Date: 27 Sep 2000 15:01:46 GMT Subject: How to Lock Globar Variables across Modules? References: <8qnqpa$p4f$1@hecate.umd.edu> <8qrvho$seo$1@panix2.panix.com> Message-ID: <8qt24q$cld$1@hecate.umd.edu> Aahz Maruch wrote: : In article <8qnqpa$p4f$1 at hecate.umd.edu>, : William Djaja Tjokroaminata wrote: :> :>I am having this problem. Suppose in 'module1.py' I declare a global :>variable named 'globvar_mod1'. In another module, called 'module2.py', I :>have the statement 'from module import *'. :> :>It looks like when I am running the program, the global variable in code :>in module2 only refers to the initial value in module1, unless I use an :>explicit name. : "Doctor, it hurts when I bang my head into the wall." : "Well, then, don't do that." : Same principle applies here. What you're trying to do doesn't fit well : with Python's model -- nor does it fit well with good programming style. : If you explain what your goal is, we may be able to give a better way to : accomplish it. Meanwhile, I suggest you stick with module.var_name. : -- : --- Aahz (Copyright 2000 by aahz at pobox.com) : Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ : Hugs and backrubs -- I break Rule 6 : "Perhaps God rewards martyrs, but life seldom does..." --Ulrika O'Brien ------------------------------------------------------ I am creating a network simulation tool in python. It is based on discrete-event simulation model. In the simulation, there is only one "process" that can run at one time (no modeling of thread in the simulation). Because I follow the function call model in another commercial simulation tool, all the function calls do not refer to the currently running process. I figured out that I can create exactly the same function call formats by putting the currently running process in a global variable in the main module (hence 'globvar_mod1'). As I use inheritance in other modules, I need to refer the currently running process. I have read many times that global variables are dangerous. But I think if we use it judiciously, it can make the programming simpler. I have only one global variable; for example, it is simply called 'sv'. In the main module, all the code will look like schedule (sv.current_time) But the same code in other modules will have to look like schedule (main_module.sv.current_time) I want something that is consistent across all the simulation modules. Using function call as suggested by another person is not too atractive to me because it destroys the consistency (and also longer). If possible, I want also to reduce the amount of typing in the other modules if I can just refer to the variable as 'sv' and not 'main_module.sv' :) Regards, Bill From yslee at vmstech.po.my Wed Sep 20 08:10:48 2000 From: yslee at vmstech.po.my (yslee) Date: Wed, 20 Sep 2000 20:10:48 +0800 Subject: Embed python interpreter in multi-threaded c++ application Message-ID: <007601c022fb$cfd91520$1d76e4c0@sweetysl> This is my Python script (test.py) : ===================================== test.py ===================================== import time, sys name=sys.argv[0] id=sys.argv[1] i=0 delay=int(id) while i<10: print name, id, i i=i+1 time.sleep(delay) ===================================== end of test.py ===================================== In the following simple C++ test program (test.cpp), I'm creating 3 threads each will run the above script. ===================================================== test.cpp ===================================================== #include "stdafx.h" #include "python.h" DWORD WINAPI MyThreadProc(LPVOID lpParameter) { if (Py_NewInterpreter()==NULL) printf("Fails to create new sub interpreter (%d)\n", (int)lpParameter); FILE* fp; char *argv[2]; argv[0]="d:\\projects\\python\\test\\test.py"; char temp[256]; sprintf(temp, "%d", (int)lpParameter); argv[1]=temp; PySys_SetArgv(2, argv); if( (fp = fopen( "test.py", "r" )) == NULL ) printf( "The file 'test.py' was not opened (%d)\n", (int)lpParameter); else printf( "The file 'test.py' was opened (%d)\n", (int)lpParameter); if (PyRun_SimpleFile(fp, "d:\\projects\\python\\test\\test.py")!=0) printf("PyRun_SimpleFile fails (%d)\n", (int)lpParameter); printf("thread (%d) exiting\n", (int)lpParameter); return(0); } int main(int argc, char* argv[]) { Py_Initialize(); PyEval_InitThreads(); printf("Hello World!\n"); DWORD id; for (int i=1;i<4;i++) CreateThread(NULL, 0, MyThreadProc, (LPVOID)i, 0, &id); getch(); Py_Finalize(); return 0; } ====================================================== end of test.cpp ====================================================== The script in thread 1 will print 1 to 10 at an interval of 1 second, 2 second for thread 2, 3 second for thread 3. Therefore script in thread 1 will end first (i.e. after 10 seconds). My problem is : right after thread 1 exits, the script in thread 2 and 3 will stop executing in the middle. What have I done wrong? YS Lee C/C++ Software Developer From claird at starbase.neosoft.com Thu Sep 14 10:29:00 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 14 Sep 2000 09:29:00 -0500 Subject: scripting language newbie - compatibility References: <8mov1c$jdo$2@newshost.accu.uu.nl> <5F9CA331C1AE8845.FBC506A6C7B692DE.98843FA4AFCA9804@lp.airnews.net> <8mp9oo02uc2@news2.newsguy.com> Message-ID: <3415DCBFDE543BE9.5D8867F7598A0F69.A027AD744EA0C704@lp.airnews.net> In article <8mp9oo02uc2 at news2.newsguy.com>, Alex Martelli wrote: >"Cameron Laird" wrote in message . . . >> An example is currently under discussion in comp.lang.tcl. >> $file close >> resists significant byte compilation, because $file might >> be *anything*--this command could, with little strain, have >> the effect of printing the word, "close", to the screen. > >Sorry, but I don't catch the big difference wrt > thefile.close() >which could just as easily print the word to the screen...? . . . Moshe correctly called me on this one, too. First, I apologize for the delay. We live in exciting times. I continue to regard Tcl as more dynamic than Python in the sense that it has natural constructs that are more resistant to byte-code compilation. I must recommend this as a purely personal view, though; I'm unwilling at this point to construct a useful example, so I'll concede that, as a practical matter, impartial observers should believe them indistinguishable. There is either no big difference, or it's one beyond my current ability to explain. Thanks, by the way, for your yeoman work in c.l.p. I learn a lot from you. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From jcm at bigskytel.com Tue Sep 26 13:21:58 2000 From: jcm at bigskytel.com (David Porter) Date: Tue, 26 Sep 2000 11:21:58 -0600 Subject: Colorized HTML from Python source In-Reply-To: ; from insyte@petra.squad51.net on Tue, Sep 26, 2000 at 04:41:28PM +0000 References: <39D00FAB.9A993B@fiber.net> Message-ID: <20000926112158.A16856@bigskytel.com> * insyte at petra.squad51.net : > >As an unabashed and incurable Vim bigot, I must point out that Vim lets you > >define whatever highlighting you want. Then you can choose Syntax->Convert > >to HTML to get an HTML version of your file with the same highlighting. > > As an unabashed and incurable Vim bigot, I would be extremely interested > in the specifics of how to do what you are describing. I have not used > syntax highlighting very much... He is describing how to do it in gvim through menu selection. In normal vim: :so /usr/share/vim/vim56/syntax/2html.vim works for me. Of course, this is very easy in (X)Emacs: M-x htmlize-buffer (this comes with XEmacs but needs to installed for GNU Emacs). David From db3l at fitlinxx.com Mon Sep 25 12:24:18 2000 From: db3l at fitlinxx.com (David Bolen) Date: 25 Sep 2000 12:24:18 -0400 Subject: Writing a win32 installer in Python? References: <8qlv83$f1d$2@riker.addcom.de> Message-ID: jpl at remotejava.NOSPAM.com (Jan Ploski) writes: > This is certainly a very newbie-ish question, but is it possible to write > code in Python and then compile it into a win32 executable? It's not really compiling, but you can use Gordan McMillan's installer package (at http://www.mcmillan-inc.com/install1.html). This automatically tracks down the various dependencies of your script and puts it all together (along with some very nice archive formats for the various library routines) into an executable that can be run directly. You generally end up with the exe, a pyz for python library files a few standlone files (like exceptions.pyc) and any external modules (dll/pyd). That collection of files is all you need to run your application. The installer package has a simple installation script (console based - prompts for a directory and unpacks), but you can combine the installer with a Windows installation package. That can be InstallShield, Wise, or for my purposes, I use the free Inno Setup (http://www.jrsoftware.org), and you end up with your Python application looking just like a native installed Windows application, and being totally self-contained within its installation directory. Users install/uninstall it just like any other Windows application. > Specifically, I would like to know whether it makes sense to try to write > a custom installer in Python for a Java application (some file copying, > extraction, and manipulation of the Windows registry is needed). I would not > like to buy nor learn Visual C++ for that purpose. Buying a shrink-wrapped > installer like InstallAnywhere is an alternative, but I am curious if Python > could come to rescue. If that's completely unrealistic (i.e. a 5 MB Python > interpreter needed to get started), let me know. I have no idea. I'd probably go with an established solution (which doesn't have to mean commercial) if it were me. Not because Python couldn't do it - I'm sure you could - but because there can be a lot of messiness with Windows installations (locked files, DLL registration, etc...). Also, while it wouldn't be 5MB, any Python installation tool would certainly take at least the 500-600K of the Python DLL and whatever extensions (such as the win32 registry module) you used. That contrasts with about 275K for Inno Setup, for example. Not much of an issue with network based installs, but could hurt on a diskette setup. -- -- 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 LinkSwap at trafficsites.com Fri Sep 15 18:59:12 2000 From: LinkSwap at trafficsites.com (LinkSwap at trafficsites.com) Date: Fri, 15 Sep 2000 15:59:12 -0700 (MST) Subject: Would you like to swap links? Message-ID: <200009152259.PAA38347@akshayni.iserver.net> Hello, python-list at cwi.nl I'm not sure if you are the one I should be writing to, but I just wanted to find out if you would be interested in swapping links with us. Currently, we have an automated service to ensure a fair link swap. If interested please visit: http://www.trafficsites.com Sincerely, The TrafficSites Team From aahz at panix.com Wed Sep 27 01:36:26 2000 From: aahz at panix.com (Aahz Maruch) Date: 26 Sep 2000 22:36:26 -0700 Subject: Of what use is 'lambda'??? References: Message-ID: <8qs10q$5om$1@panix3.panix.com> In article , Tim Peters wrote: > >They (lambda/map/filter/reduce) were contributed code, and he put them in >because he *liked* them. Unfortunately, other people *loved* them in their >native homes, and it's been a flamewar ever since. Guido does not love >them. "I do not love thee, lambda; let me count the ways..." -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Perhaps God rewards martyrs, but life seldom does..." --Ulrika O'Brien From maxm at normik.dk Thu Sep 28 08:44:43 2000 From: maxm at normik.dk (=?iso-8859-1?Q?Max_M=F8ller_Rasmussen?=) Date: Thu, 28 Sep 2000 14:44:43 +0200 Subject: Newbie question... Message-ID: <7BD10B680501D411B9DF009027E06F32011BF3@exchange> From: shindich at my-deja.com [mailto:shindich at my-deja.com] >Huh? Since when do you need to write separate functions for adding >numbers and strings in Python? The buty of the language is that you can >write template-like function easily. >The following function will do the job: Shure can, but I was not trying to write clever code, I was trying to teach a lesson. My experience from my teaching days has shown me that I don't come across more clearly by showing the answer as a more complicated example than the one the student allready had trouble understanding. If somebody has trouble understanding a problem, split it up in more simple subproblems, don't show what can be done if you allready understand the problem. Lecturing'ly yours - Max M From speed at ?.com Fri Sep 29 16:01:10 2000 From: speed at ?.com (Jake Speed) Date: Fri, 29 Sep 2000 20:01:10 -0000 Subject: Fractal Dimension Computation in Python Code References: <3d4s2zxo20.fsf@kronos.cnri.reston.va.us> Message-ID: speed@?.com (Jake Speed) wrote in : >And of course, it was the actual dimension calculation >that was incorrect. And having said that, here's an updated version. Note that in the examples the points aren't limited to the 0.0 -> 1.0 range anymore. import math def fractal_box_count(pointlist, scale): """Returns the box coverage of pointlist for boxes of size scale,""" boxlevel = 1.0 / scale pointdict = {} for point in pointlist: box = (int(point[0] * boxlevel), int(point[1] * boxlevel), int(point[2] * boxlevel)) if not pointdict.has_key(box): pointdict[box] = 1 return len(pointdict) return (math.log(num), math.log(boxlevel)) def fractaldim(pointlist, scale1, scale2): """Returns the approximate fractal dimension of pointlist between box scales scale1 and scale2.""" log = math.log c1 = fractal_box_count(pointlist, scale1) c2 = fractal_box_count(pointlist, scale2) return (log(c2) - log(c1)) / (log(1.0/scale2) - log(1.0/scale1)) print "line dimension" list1d = [] for x in xrange(100): list1d.append((x/100.0, 0, 0)) for level in xrange(1,10): scale1 = (.5 ** level) scale2 = scale1 / 4.0 print level, fractaldim(list1d, scale1, scale2) print "plane dimension" list2d = [] for x in xrange(100): for y in xrange(100): list2d.append((x/50.0, y/50.0, 0)) for level in xrange(1,10): scale1 = (.5 ** level) scale2 = scale1 / 4.0 print level, fractaldim(list2d, scale1, scale2) print "space dimension" list3d = [] for x in xrange(30): for y in xrange(30): for z in xrange(30): list3d.append((x/120.0, y/120.0, z/120.0)) for level in xrange(1,10): scale1 = (.5 ** level) scale2 = scale1 / 4.0 print level, fractaldim(list3d, scale1, scale2) def makekoch(x1, y1, x2, y2, level, flist=[]): xd = (x2 - x1) yd = (y2 - y1) xa = x1 + xd / 3.0 ya = y1 + yd / 3.0 xb = x1 + xd * 2.0 / 3.0 yb = y1 + yd * 2.0 / 3.0 xm = (x1 + x2) / 2.0 - 0.866 * yd / 3.0 ym = (y1 + y2) / 2.0 + 0.866 * xd / 3.0 flist.append((xa,ya,0)) flist.append((xm,ym,0)) flist.append((xb,yb,0)) if (level > 0): makekoch(x1, y1, xa, ya, level-1, flist) makekoch(xa, ya, xm, ym, level-1, flist) makekoch(xm, ym, xb, yb, level-1, flist) makekoch(xb, yb, x2, y2, level-1, flist) return flist print "koch dimension" listfract = makekoch(0,0,1,0,6) for level in xrange(1,10): scale1 = (.5 ** level) scale2 = scale1 / 4.0 print level, fractaldim(listfract, scale1, scale2) From guyrez at easynet.fr Thu Sep 7 07:57:15 2000 From: guyrez at easynet.fr (Guy Reza) Date: Thu, 7 Sep 2000 13:57:15 +0200 Subject: Python and fast display Message-ID: I have the following need : * I am monitoring data on a RS 232 line on a PC (10-15 short blocks of data / second, basically X-Y coordinates) * I need to display data on the PC screen the coordinates in such a way that the user has the impression of smooth movement Python and its extensions are fine for all that except (at least as far as I know) for the smooth display, which would need something like double buffering (for example as it is implemented in Direct X). Does anyone have an idea in order to have a smooth display with Python ? Thanks in advance for all the information. Guy PS : The volume of data to be displayed is not so high : a cursor moving smoothly according to data sent over the RS 232 line over a fixed drawing or image would be enough. The point is that the display shoulb be smooth, like the cursor of a mouse for example. From htling at cyberway.com.sg Thu Sep 21 09:11:27 2000 From: htling at cyberway.com.sg (Maurice Ling) Date: Thu, 21 Sep 2000 21:11:27 +0800 Subject: IDLE startup prob!! Message-ID: <39CA08FF.768B6B9E@cyberway.com.sg> Help... I dont seems to be able to start up IDLE on my system... any help will be appreciated thkx maurice From cg at schlund.de Mon Sep 18 09:51:03 2000 From: cg at schlund.de (Carsten Gaebler) Date: Mon, 18 Sep 2000 15:51:03 +0200 Subject: "<" special character in re? References: <8FB39D54Astefanwitzelzvwunigo@134.76.98.67> Message-ID: <39C61DC7.6EE63C4C@schlund.de> Stefan Witzel wrote: > > When I try to extract all characters between "<" and ">" using re ... > > import re > hit = re.match('<(?P[a-z]*)>', 'abef') > if hit: > print hit.group('i') > else: > print 'no hit' > > ... I always get "no hit". Is "<" a special character in re? You'll have to use re.search() because re.match() matches only the beginning of a string (see the docs). cg. From pehr at pehr.net Thu Sep 14 00:59:22 2000 From: pehr at pehr.net (pehr anderson) Date: Thu, 14 Sep 2000 04:59:22 GMT Subject: Hum, i want use htmlgen to generate html References: <39BF3104.5FDF6DBC@ensai.fr> Message-ID: <39C05B2A.8ECD236E@pehr.net> Dear Stephane, I hate to propose such a simple suggestion but when I am learning python, I ususally look in the file with the source code of the modules. Often there is excellent documentation, introductions, tutorials, etc. hidden in the module files themselves. I was pleasantly surprised when I discovered this convention. If you don't know where htmlgen is, you can find it with the locate command. $ locate htmlgen -pehr Stephane Trainel wrote: > > Hye, > > (Sorry for my so perfect english...) > > I want use a module of python : htmlgen. > My pb : i do not succeed to generate a html file. > > I am looking for a example.... or a tutorial. > The website of htmlgen is poor on informations > Thanks. > -- > St?phane Trainel mailto:stephane.trainel at ensai.fr > Phone (fax) : 33 2 99 05 32 56 (32 06) http://www.ensai.fr From effbot at telia.com Sun Sep 10 04:31:02 2000 From: effbot at telia.com (Fredrik Lundh) Date: Sun, 10 Sep 2000 08:31:02 GMT Subject: importing out of cwd References: <8peedb01ut5@news1.newsguy.com> Message-ID: Alex Martelli wrote: > You do have to temporarily add to sys.path the directory you want, > before importing; then, you can take it off again. This should work: > > import sys > sys.path = [".."] + sys.path > import whatever > sys.path = sys.path[1:] insert and pop (or del) is slightly more efficient. more importantly, it's a good idea to wrap the import inside a try/finally clause, so you don't screw up the path if things go wrong: sys.path.insert(0, "..") try: import whatever finally: sys.path.pop(0) From SBrunning at trisystems.co.uk Fri Sep 22 08:18:59 2000 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Fri, 22 Sep 2000 13:18:59 +0100 Subject: Multiple string replacement... Message-ID: <31575A892FF6D1118F5800600846864D5B113D@intrepid> I'm trying to put together a script which will replace values in files. The idea is that you can specify multiple replacements at once. For example you can replace 'Spam' with 'eggs' and 'Jesus' with 'Brian' in one pass. So, I read the replacement sets in from a file, and store them in a list of lists, thus: replacements = [['Spam', 'eggs,], ['Jesus', 'Brian']] Then I read in my file data, and do: for replacement in replacements: filedata = filedata.replace(replacement[0], replacement[1]) This all works OK, except... I set up a ROT13 replacement set, which looks like: [['A', 'N'], ['B', 'O'], ['C', 'P'], ['D', 'Q'], ['E', 'R'], ['F', 'S'], ['G', 'T'], ['H', 'U'], ['I', 'V'], ['J', 'W'], ['K', 'X'], ['L', 'Y'], ['M', 'Z'], ['N', 'A'], ... and so on. The problem here is that after 'A' and been replaced by 'N', it gets replaced back again. Anyone got a cunning plan? Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk P.S. Sorry about the legal gibberish below - out of my hands, I'm afraid. I wouldn't mind so much, except for the poor grammar... ----------------------------------------------------------------------- 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 rumjuggler at cryptarchy.org Wed Sep 13 00:34:17 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Wed, 13 Sep 2000 04:34:17 GMT Subject: the death of lecter References: <39BD1074.6090BBCB@alcyone.com> <39BE9612.253083CC@seebelow.org> Message-ID: On Tue, 12 Sep 2000 21:46:10 +0100, Grant Griffin wrote: >Erik Max Francis wrote: >> >> Michal Wallace wrote: >> >> > * immediate if: >> > print 'x is', x > 0 ? 'positive' : 'negative' >> > >> > # I still wish we had a ?: operator.. >> > # It would be great for lambdas! >> >> Yeah, an if-else operation compacted into an operator would be rather >> convenient. > >I guess I would vote against this: after all, as Tim's Python philosophy >says "readability counts", and IMHO, this is the singlemost unreadable >construct in all of C. On the other hand, when people try to include it in lambdas anyway, the result isn't exactly clear: (A and (B,) or (C,))[0] -- Barnabas T. Rumjuggler's page of dumbth: members.home.net/rumjuggler No photographs. Only memories. -- Joe Frank, "A Tour of the City" From sjuranic at condor.ee.washington.edu Thu Sep 14 14:06:19 2000 From: sjuranic at condor.ee.washington.edu (Steve Juranich) Date: Thu, 14 Sep 2000 11:06:19 -0700 Subject: Worth of [] += Message-ID: First off, I've only been hacking Python for about 2 months now, so please be patient. I'm a little confused about this whole thing of += with a list object. Didn't we already have that with the list.append() function? Does the += operate differently (so that end users like me will notice)? If it does work differently, what will be the benefit of += that list.append() didn't have? TIA ---------------------------------------------------------------------- Stephen W. Juranich sjuranic at ee.washington.edu Electrical Engineering http://students.washington.edu/sjuranic University of Washington http://rcs.ee.washington.edu/ssli From pinard at iro.umontreal.ca Sat Sep 2 09:04:02 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 02 Sep 2000 09:04:02 -0400 Subject: Python and COBOL In-Reply-To: Dennis Lee Bieber's message of "Fri, 01 Sep 2000 20:39:25 -0700" References: <8oed4p017r7@news2.newsguy.com> <13s0rssmlvrslq6o8s8mdvi54e5acupvun@4ax.com> Message-ID: [Dennis Lee Bieber] > Of course, FORTRAN had the > assign