From max at alcyone.com Sat Sep 22 14:15:59 2001 From: max at alcyone.com (Erik Max Francis) Date: Sat, 22 Sep 2001 11:15:59 -0700 Subject: newbie question: converting integer to string References: Message-ID: <3BACD55F.5E3B53CA@alcyone.com> Ignacio Vazquez-Abrams wrote: > On Sat, 22 Sep 2001 adina_levin at mindspring.com wrote: > > > how can I generate a string representation of num? > > `num` str(num) would probably be more appropriate than repr(num) if, say, num were a long. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ If you can't fight and you can't flee, flow. \__/ Robert Elliot Computer science / http://www.alcyone.com/max/reference/compsci/ A computer science reference. From thomas at gatsoft.no Mon Sep 3 07:40:13 2001 From: thomas at gatsoft.no (Thomas Weholt) Date: Mon, 03 Sep 2001 11:40:13 GMT Subject: Web Application Server in Python: which one to choose ? References: <3B9364F8.2C477597@el_simpatico.be> Message-ID: My experience with the ones I've tested ( Zope and Webware ) is that if you can find either products ( in zope ) or allready existing features in the system that fits your needs, you might get productive rather quick. If you on the other hand want to develop highly customized solutions you might have to invest more time and possibly money. How you like to work, if you like using *SP-based solutions like DHTML in Zope and PSP and Webware etc. will also play a big part in deciding what package you want to use. I think Webware and Zope work just fine if you're way of working is compatible with the concept behind one of those packages. I found Zope too complex, almost bloated, Webware was interesting and showed alot of promise, but failed to invoke serious interest. I've started developing my own application server based on Medusa and take parts of the concept behind Zope, Webware, other Java-based application servers like Tomcat and Enhydra and it's coming along nicely, soon becoming ready for a beta-release. I wanted 100% control of my code, complete seperation of design and code, "web-components", simpler user/access-management etc. and at the same time learn how it all worked, that's why I decided to create a new project. Perhaps no real answer to your question, but ... Thomas "Weet Vanniks" wrote in message news:3B9364F8.2C477597 at el_simpatico.be... > The subject title says it all or almost ... > There seems to exist a great offering: > Zope, Bobo, Webware,SkunkWeb, Quixote,Twisted, etc... > This makes my choice very difficult. Can I get an unbiased opinion about > the merits of each of these solutions. I've been told that Zope is > complex and that Webware is great. Could you confirm ? > Thanks for helping me out. > > Weet > From ignacio at openservices.net Thu Sep 13 22:49:39 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Thu, 13 Sep 2001 22:49:39 -0400 (EDT) Subject: (no subject) In-Reply-To: <001301c13cc6$52a94260$0b01a8c0@hossein> Message-ID: On Fri, 14 Sep 2001, Hossein Hosseini wrote: > I am a beginner on PYTHON. I would appreciate your help on my following question: > what is the simplest way to send and read the array of PYTHON to C extending function? PySequence_GetItem() -- Ignacio Vazquez-Abrams From skip at pobox.com Sat Sep 29 09:54:02 2001 From: skip at pobox.com (Skip Montanaro) Date: Sat, 29 Sep 2001 08:54:02 -0500 Subject: How do I distinguish a string from a sequence? In-Reply-To: References: Message-ID: <15285.53882.284160.732978@beluga.mojam.com> asgard> I am using 2.2a3 documentation and it's not written there (in asgard> types module). Now fixed in CVS docs. Thanks for pointing out the omission. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From aleax at aleax.it Fri Sep 14 05:48:29 2001 From: aleax at aleax.it (Alex Martelli) Date: Fri, 14 Sep 2001 11:48:29 +0200 Subject: Keeping os context possible? Re: Python a good thing for sysadmins ? References: <3BA14452.B72EFE1A@thinkware.se> Message-ID: <9nsjpf023t0@enews2.newsguy.com> "Magnus Lycka" wrote in message news:3BA14452.B72EFE1A at thinkware.se... ... > A unix shell script or an NT cmd file would live in the os > context. It wouldn't spawn a new process for every command, Unix shell scripts always spawn a new process for every command, where the "command" is an external program (or other script) rather than a shell builtin. So does CMD.EXE, actually, it just has stuff built-in that most Unix shells keep out, such as file-copying. So I'm not sure what that 'db2' command (program?) is doing that lets it keep state from one call to the other under a shell but not when run from Python...! Alex From dean.hall at computer.org Tue Sep 25 16:16:50 2001 From: dean.hall at computer.org (Dean Hall) Date: 25 Sep 2001 13:16:50 -0700 Subject: dismantling code objects References: <998474b8.0109240713.6070692e@posting.google.com> Message-ID: <998474b8.0109251216.5b9d07c6@posting.google.com> Martin von Loewis wrote in message news:... > dean.hall at computer.org (Dean Hall) writes: > > > I'd appreciate any feedback on the doc (I consider it a rough draft > > and won't be offended by constructive criticism). > > I find your text well-written, and I'd encourage you to keep it > up-to-date (e.g. Python 2.2 will add a few byte codes). > > I think the type setting could use some improvements, e.g. the figure > numbers are never printed, and the tables with empty fields look ugly > (e.g. opcodes 93,94). Thank you for the feedback. My rough draft is in HTML and I plan to migrate to TeX, which will solve some of the typesetting and numbering. I thought the empty byte code cells would lead people to think that I hadn't documented that byte code... I guess I'll insert "UNUSED" or the like. > I'd spend a few more words on marshal, so that the reader atleast gets > an idea of what it does - you may leave out the information of how > exactly it does that(*). You mean I should spend a few more words than zero? In my grand plan, the subjects of .pyc and marshal would be another doc. And byte codes and the interpreter would be a third doc. !!Dean From thomas at xs4all.net Fri Sep 7 10:04:36 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 7 Sep 2001 16:04:36 +0200 Subject: newbie: cannot import name error In-Reply-To: References: Message-ID: <20010907160436.A22331@xs4all.nl> On Fri, Sep 07, 2001 at 01:28:58PM +0000, rjberman at NOSPAMrodessaNOSPAM.com wrote: > Anyway, I installed Python version "1.6a2 (#1, Jun 1 2000, 13:24:17) Eep. That's the second _alpha_ of a release that was made because of contractual obligations. The release itself is functional, but you are definately better off with Python 2.1.1, the newest release, or even 2.0.1. You definately do not want an alpha release in any case ;P Trust my completely unbiased opinion and get Python 2.1.1 ;-) Remember!-Python-2.1._1_!-ly y'rs, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From kseehof at neuralintegrator.com Wed Sep 12 15:27:48 2001 From: kseehof at neuralintegrator.com (Ken Seehof) Date: Wed, 12 Sep 2001 12:27:48 -0700 Subject: [Poll] Private variables References: Message-ID: <005301c13bd3$9fe1d400$4d14b43f@kens> Actually a member is private if it starts with 2 underscores and does not end with 2 underscores. There is no special meaning for a single terminating underscore. By convention, starting and ending with double underscore is reserved for special functions such as __init__ and __add__ (which are not private). >>> class X: ... def __init__(self): ... self.__priv = 'spammity' ... >>> x = X() >>> x.__priv Traceback (most recent call last): File "", line 1, in ? AttributeError: X instance has no attribute '__priv' >>> x._X__priv 'spammity' I rarely use private members, and tend to use the single underscore convention to say that a member is intended to be private. You could say I don't really mind giving my users enough rope to shoot themselves in the foot. :-) I use true private members when I feel like being extra careful, or when I want to avoid base class / derived class namespace clashes. There are some silly people who would claim that python doesn't have private members at all (and therefore is not object oriented) because the so called private members are accessible by the _class__attr notation. All I can say to such people is "you are silly". Anyway I can be silly too: it turns out that C++ is not object oriented either because you can include the following: #define private public I've also heard a particularly bizzare counterargument. Apparently it is possible for private to change the relative addresses of member data, so the above hack is totally unsafe, therefore C++ is object oriented after all. Huh? ----- Original Message ----- From: "Alexandre Fayolle" Newsgroups: comp.lang.python To: Sent: Wednesday, September 12, 2001 2:16 AM Subject: [Poll] Private variables > It is possible in python to get private class members by using names > beginning with 2 underscores, and finished by at least 1 underscore. > > I personnally tend to use class member names beginning with one > underscore to indicate that the member is 'internal' and should not > be called by external applications, and from looking at the standard > library source code, it seems that this is more common than the official > way mentionned hereabove. > > I would like to hear what the opinion of pythoneers is on that topic. > > Please feel free to point me to the list archives if this has already > debated over and over. > > Alexandre Fayolle > -- > LOGILAB, Paris (France). > http://www.logilab.com http://www.logilab.fr http://www.logilab.org > Narval, the first software agent available as free software (GPL). > -- > http://mail.python.org/mailman/listinfo/python-list From hungjunglu at yahoo.com Tue Sep 18 14:00:32 2001 From: hungjunglu at yahoo.com (hungjunglu at yahoo.com) Date: Tue, 18 Sep 2001 18:00:32 -0000 Subject: voodoo: modifying class methods a posteriori Message-ID: <9o8240+ahvu@eGroups.com> Hi, This is a problem that has bugged me for a while, now. (Related topic might be "function closure", which I don't understand much.) What follows is pure Python voodoo. But when voodoo is used properly, it does wonders. :) Say, you have a class "A" with method "f(self)" (which potentially could be the constructor __init__() or destructor __del__(), by the way.) Instance-bound methods can be overriden easily. (I am not interested in derived subclass, see the reason a bit later.) class A: def f(self): print 'hello' def g(self): print 'bye' a = A() a.f() import new a.f = new.instancemethod(g, a, A) a.f() The class-bound method f() can be overriden, easily, too: class A: def f(self): print 'Hello' def g(self): print 'Bye' a = A() a.f() A.f.im_func.func_code = g.func_code a.f() Now, all that is nice. BUT, usually, when you override a method, you probably want to do just a bit more than what the old method was doing. Say, you may only want to add a print statement when the method is called, or you may want to insert a statement to the constructor/destructor so object instances can automatically register/deregister to a particular event handler. When you have many subclasses derived from subclasses of other classes, especially when you don't have access to the source code for one reason or another, or when you don't want to or you can't modify the source code of the superclass, is there a way of inserting statements into the class methods? In derived class, what you would do is something like: class A: def f(self): print 'Hello' class AA(A): def f(self): print 'before saying Hello' A.f(self) print 'after saying Hello' a = AA() a.f() Notice you are able to insert statements before and after the base class method call. Is there a way of doing the same thing without subclassing? ============= hmm.... I think I just answered myself, I'll post it to the mailing list anyway: class A: def f(self): print 'Hello' def g(self): print 'before saying Hello' self.f_old() print 'after saying Hello' a = A() a.f() import new A.f_old = A.f A.f = new.instancemethod(g, None, A) a.f() ===================== Wow! It's fun! I wonder why people are still using Java. :) Hung Jung From ibarona at tid.es Fri Sep 14 10:48:03 2001 From: ibarona at tid.es (Isaac Barona) Date: Fri, 14 Sep 2001 14:48:03 GMT Subject: ANN: USPP (Universal Serial Port Python) Library version 0.1 Message-ID: <3ba217ee.980307075@tid> Hi all, I have just released the first version of a python library called USPP (Universal Serial Port Python). USPP Library is a multi-platform Python module to access serial ports. At the moment, it only works in Windows and Linux (the platforms I have access to) but as it is written entirely in Python I hope you can extend it to support any other platforms. The module has the following features: - hight level access to serial port under several platforms. - autodetects the platform in which it is working and exports the correct classes for that platform. - object oriented approach. - file object semantic operations over the ports. - allows using the serial port with different speeds and characteristics. - RS-232 and RS-485 modes (now only RS-232). In RS-485 mode the communication is half-duplex and uses the RTS line to control the direction of the transference. - blocking, non-blocking or configurable timeout reads. The library is under the GPL license and can be found in: http://balder.prohosting.com/ibarona/en/python/uspp/uspp_en.html Greatings from Spain, Isaac. Isaac Barona Mart?nez Madrid (SPAIN) From petr at kubanek.net Fri Sep 28 15:52:44 2001 From: petr at kubanek.net (Petr Kubanek) Date: Fri, 28 Sep 2001 21:52:44 +0200 Subject: Repost: execfile() confusion References: <9p2iuk$1au@gap.cco.caltech.edu> Message-ID: <9p2k4n$f05$02$2@news.t-online.com> What's happen, if you use global in test2.py? x is local to test2.py. Another possibility is to use __main__ module. But these is now depreciated. > ############## > #### test2.py #### global x > x = 'spam' > > #### test.py #### > def doit(): > execfile( 'test2.py' ) # x = 'spam' global x > print x > > doit() > ############## From jgoerzen at complete.org Thu Sep 6 13:51:30 2001 From: jgoerzen at complete.org (John Goerzen) Date: Thu, 06 Sep 2001 17:51:30 GMT Subject: Function to merge sorted lists References: <3B8F1BE0.6060108@erols.com> Message-ID: <87r8tkb51x.fsf@complete.org> "Edward C. Jones" writes: > Here is a Python program that does the same thing: There's a more straightforward way to do it: def merge(l1, l2): ret = [] l2c = 0 for item in l1: while l2c < len(l2) and l2[l2c] < item: ret.append(l2[l2c]) l2c += 1 ret.append(item) return ret + l2[l2c:] -- John Goerzen GPG: 0x8A1D9A1F www.complete.org From aleax at aleax.it Tue Sep 4 10:15:23 2001 From: aleax at aleax.it (Alex Martelli) Date: Tue, 4 Sep 2001 16:15:23 +0200 Subject: Winer on MS scripting strategy: implications for Python.NET? References: Message-ID: <9n2nm109bd@enews3.newsguy.com> "Martin von Loewis" wrote in message news:j4oformfee.fsf at informatik.hu-berlin.de... > fluxent at yahoo.com (Bill Seitz) writes: > > > Thoughts? > > I know that python.net will be different, in language semantics, from > CPython and Jython, and I guess that the differences will be larger > than between the C and J variants. That won't pose a problem to users I wonder -- the semantics of the JVM and MSIL aren't all that far apart, after all. It should be quite feasible to have a Python.NET that's quite close to Jython in most respects. > of Python.NET, since their code won't port to CPython, anyway, because > the libraries are so dramatically different. Or, if they have portable > code, why run it in Python.net, if you can run it in standard Python > as well? For example because there may well be platforms that run .NET but not classic Python, if .NET has significant success -- e.g. such devices as new-generation cellphones, etc, may well one day come out .NET-enabled by default, while a port of Python may be something between very hard and unfeasible. > Selection of specific libraries always produces subcommunities, > e.g. people that use PyQt, NumPy, SWIG, PyXML, PythonWin, ... will > have code that is tied to those libraries. .NET won't be any different > - it is just another set of libraries. It's more than that, in the same way Jython is more than "just another set of libraries" when compared to Classic Python. Alex From TerryByrne1963 at yahoo.com Tue Sep 4 10:50:22 2001 From: TerryByrne1963 at yahoo.com (Terry Byrne) Date: 4 Sep 2001 07:50:22 -0700 Subject: newbie question - executing system commands References: <9n23h1$qsc$1@news.formus.pl> Message-ID: <93d52e82.0109040650.4b2c2912@posting.google.com> I've had good luck with this combo... cmdPipe = os.popen(aCmdLine) resultStream = cmdPipe.read() At this point you can look through resultStream for any error codes that may have been returned by the command line process. Good luck! HTH, Terry "Borzoj" wrote in message news:<9n23h1$qsc$1 at news.formus.pl>... > I'm newbie both in shell scripting and pyhon so please be kind :) > What would be the Python equivalent for following shell code: > > for IMAGE_NAME in `ls`; do { > #processing of $IMAGE_NAME > };done > > > ...or in other words what is the easiest way to execute shell > command/external program from python and > get access to it's output? > > thx > ____________ > This will be your new motto: dance like it hurts, love like you need money, > work when pepole are watching. > Dogbert From michael at rcp.co.uk Wed Sep 5 09:15:46 2001 From: michael at rcp.co.uk (Michael Abbott) Date: Wed, 5 Sep 2001 13:15:46 +0000 (UTC) Subject: dde? References: <20010905120928.B2068@xs4all.nl> <9n53rh01kut@enews1.newsguy.com> Message-ID: "Alex Martelli" wrote in news:9n53rh01kut at enews1.newsguy.com: > ActivePython (and win32all as an add-on to normal Python) does > support dde, but you're *FAR* better off avoiding it -- use > COM instead. DDE is a zombie -- dead since many years ago, > yet keeps walking (stumbling) around and doing damage. I would say several things here. 1. The implementation of DDE in ActivePython is very poor, and doesn't do very much. In particular, it is very incomplete. 2. Unfortunately, the DDEML library (Microsoft's canonical implementation of DDE) is also poor and contains serious bugs. 3. DDE has a number of potentially crippling faults, but it is quite wrong to describe it as a damaging zombie. When used correctly, it works extremely well. 4. DDE is the only well behaved and reliable way to push dynamically updating data into Excel (this is a *very* long story). > > Anyway, if you're keen on DDE -- no docs, AFAIK, but you'll > find tangential mention in the thread at: > http://mail.python.org/pipermail/python-list/1999-July/007106.html > including one tiny example. On the other hand, I concur with Alex: if you don't need to use it, don't. Particularly if you're planning to write your own server: it's quite a lot harder to get it right than meets the eye at first. From markus at schabi.de Mon Sep 17 12:49:38 2001 From: markus at schabi.de (Markus Schaber) Date: Mon, 17 Sep 2001 18:49:38 +0200 Subject: Direct TK interface Message-ID: <2764949.5mLc6kNg2l@lunix.schabi.de> Hi, I was just wondering whether it is possible (and worth in sense of speed etc.) to directly interface TK into python (without using the TCL interpreter inbetween). markus -- "The strength of the Constitution lies entirely in the determination of each citizen to defend it. Only if every single citizen feels duty bound to do his share in this defense are the constitutional rights secure." -- Albert Einstein From jonas.b at home.se Sat Sep 15 07:19:24 2001 From: jonas.b at home.se (Jonas Bengtsson) Date: 15 Sep 2001 04:19:24 -0700 Subject: Python's architecture References: <4e2ddb70.0109140241.1d9666b0@posting.google.com> <4e2ddb70.0109140637.1a603460@posting.google.com> Message-ID: <4e2ddb70.0109150319.37e94984@posting.google.com> Thanks for you answer! Now I finally got a source with an explanation of the architecture of Python: http://wiki.cs.uiuc.edu/cs427/PYTHON But it would be nice to have some other sources... About reading the source code they state: "Constructing an architectural picture from only source code is very tedious work" /Jonas Bengtsson "Terry Reedy" wrote in message news:... > "Jonas Bengtsson" wrote in message > news:4e2ddb70.0109140637.1a603460 at posting.google.com... > > I want documentation about the python interpretator > > The best documentation you will find is the source code itself. > Seriously. If you know enough to use the word 'architecture', you > should be able to anwer most of your questions is a couple of hours. > It is all pretty clearly written C. > > Some hints: last time I looked, that was one file for the grammar, one > for the lexer, one or more for parser/compiler, one for the PyCode > evaluation loop (the interpreter proper), and one for each built-in > type, each of these having the same format. The last point means that > there is much less to look at than it would initially seem. > > Terry J. Reedy From breakfast at 10.am Thu Sep 27 12:20:51 2001 From: breakfast at 10.am (mallum) Date: Thu, 27 Sep 2001 17:20:51 +0100 Subject: file find module Message-ID: <20010927172051.B1120@10.am> Hi all; Does a module exist ( pref in standard dist ) that will recursively search directorys for filenames matching a certain pattern ( like Perl's File::Find ) - or will I have to write something for scratch ? -- mallum From phd at phd.pp.ru Fri Sep 28 09:44:40 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Fri, 28 Sep 2001 17:44:40 +0400 Subject: mysql-python: How can I retrieve the ID of the last record I added? In-Reply-To: <166330214503.20010928154627@buz.ch>; from gabriel_ambuehl@buz.ch on Fri, Sep 28, 2001 at 03:46:27PM +0200 References: <166330214503.20010928154627@buz.ch> Message-ID: <20010928174440.B4218@phd.pp.ru> On Fri, Sep 28, 2001 at 03:46:27PM +0200, Gabriel Ambuehl wrote: > Hello, > I've got a MySQL table which has got an id field that is declared as > auto_increment so every record added gets its own unique id. So far > so > good, but how can I fetch the id of the last record added? I know I > can do some SELECT to gather the ID but if there are two completely > identical records, which is possible, it won't do me any good. So is > there some library function to reliably retrieve the id of the last > record I inserted into the table? SELECT LAST_INSERT_ID() Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From phr-n2001 at nightsong.com Tue Sep 25 23:21:54 2001 From: phr-n2001 at nightsong.com (Paul Rubin) Date: 25 Sep 2001 20:21:54 -0700 Subject: importing symbols from module objects References: Message-ID: <7xvgi6r60d.fsf@ruckus.brouhaha.com> "Sean 'Shaleh' Perry" writes: > when you try to get around the language, "weird" calls is all you have. You > example may not truly reflect what you are trying to do because: > > from EggsBaconSpam import breakfast, SpamException > > gives you what you want and has only the one line to change. There's lots of different classes in EggsBaconSpam.py. I don't want to import all its symbols into the caller's namespace--just a few of them. The other ones, I want to refer to as provider.symbolname. > In some of my own code I have: > > d = {} > exec open(py) in d > self.unpack.register(d['filetype'], d['unpack']) I guess I don't mind such weirdness in the EggsBaconSpam module but I'd like to keep the caller's interface clean. Got any alternative suggestions for implementing service providers? From loewis at informatik.hu-berlin.de Mon Sep 17 04:09:34 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 17 Sep 2001 10:09:34 +0200 Subject: Python's architecture References: <4e2ddb70.0109140241.1d9666b0@posting.google.com> <4e2ddb70.0109140637.1a603460@posting.google.com> <4e2ddb70.0109150319.37e94984@posting.google.com> Message-ID: jonas.b at home.se (Jonas Bengtsson) writes: > Thanks for you answer! > Now I finally got a source with an explanation of the architecture of > Python: http://wiki.cs.uiuc.edu/cs427/PYTHON Well-done research. It seems that this might be well the best write-up in the style that you seem to be asking for. If you go through the text and find all the errors, that might be just about the right amount of work. If you have any specific questions, like Is it really true that "Python developers would say that the code evaluator is highly optimized and optimizing across multiple instructions (...) wouldn't result in that much of a performance gain." don't hesitate to ask. [On this specific question, I'd personally answer "no"; I think many Python developers would guess that byte-code level optimization could achieve good results. The elimination of SET_LINENO is just one example.] > About reading the source code they state: "Constructing an > architectural picture from only source code is very tedious work" Indeed, and this shows the true value of the work of Jim Jackson and Kar-Han Tan. In another article, you write > I believe that there has to be some kind of documentation. ... If > not, how do the developers get any overview of the interpretator? There is certainly documentation of the API, and comments throughout the source code. I'm quite certain that most developers got their overview without any introductory material into "the Python architecture". Instead, they got the overview from inspecting the source code, and matching that with their textbook knowledge, and by asking specific questions in this group. Also, many contributors can contribute without having a "detailed overview" of the full system: To make the zlib module thread-safe, you don't have to know how the recursive-descend-parser works. So Python's "architecture", beyond what the dragon book describes, is rather a collection of "micro-architectures". As the authors found, there is one for the compiler technology, one for the memory management, one for the polymorphism. There is also one for multi-threading. I think you are quite lucky to have found this reference. To get specific answers in this group, you need to ask specific questions. The answer to the question "What architecture overview documents do the Python developers regularly use?" is probably "None". Regards, Martin From James_Althoff at i2.com Wed Sep 19 14:29:15 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Wed, 19 Sep 2001 11:29:15 -0700 Subject: Proposed PEP for a Conditional Expression Message-ID: Tom Payne wrote: >I have a similar objection to the syntax: > > cond( , lambda:, lambda: ) > >Moreover it doesn't scale up to multiple tests very well: > > cond( , lambda:, lambda:cond( , lambda:, lambda: ) ) > >or stacked/indented version thereof. ... which is perhaps mitigated by the fact that nested conditional expressions is probably not a great idea for readability in any case. Jim From richard at bizarsoftware.com.au Wed Sep 19 22:24:49 2001 From: richard at bizarsoftware.com.au (Richard Jones) Date: Thu, 20 Sep 2001 12:24:49 +1000 Subject: PIL 1.1.2 for Python 2.1.1 In-Reply-To: References: Message-ID: <0109201224492N.01597@ike> On Thursday 20 September 2001 12:10, Tom Babbitt wrote: > "Anders Eriksson" wrote in message > news:iscfqt0gj9lfc9e2p37e6kug2rfkmg0t53 at 4ax.com... > > > Hello! > > > > Why doesn't import Image work anymore? > > > > Why do I have to use import PIL.Image? > > > > // Anders > > I have had this problem also, PIL must have changed. If you take the > > files > > from the PIL directory and copy them to your lib directory you can import > Image again. "from PIL import Image" works for me if I put the PIL directory in my site-packages. No PIL.pth or other hackery required.... Richard From k7on at earthlink.net Fri Sep 21 20:50:37 2001 From: k7on at earthlink.net (Brian Short) Date: Sat, 22 Sep 2001 00:50:37 GMT Subject: Serial Question (newbie) Message-ID: <3bac4d8d.87704841@news.earthlink.net> I am fairly new using Python. That said, I started with the Win32 version 2.2. Today I tried to access the COM ports using the Serial module. Actually, I downloaded the version 2.1 module and it will not install, giving an error that version 2.1 is not installed. What do I need to do? -- mailto:k7on at earthlink.net >or< http://www.qsl.net/k7on/ -- From thp at cs.ucr.edu Tue Sep 4 19:00:10 2001 From: thp at cs.ucr.edu (thp at cs.ucr.edu) Date: Tue, 4 Sep 2001 23:00:10 +0000 (UTC) Subject: Conditional operator in Python? References: <9n1vir$chl$1@glue.ucr.edu> Message-ID: <9n3mdq$s5r$1@glue.ucr.edu> Terry Reedy wrote: : wrote in message : news:mailman.999590706.31784.python-list at python.org... :> which reads better with a couple of if's added: :> :> p = lambda k, n : :> if k < 1 or k > n then :> 0 :> else if n == 1 or n == k then :> 1 :> else :> p( k-1, n-1 ) + p (k, n-k ) :> :> I'm not lobbying for ?: notation in particular. I simply want :> something better than (a and [b] or [c])[0]. In fact, the :> if/then/else notation is my personal favorite. : So use def/return instead of lambda/whatever : def p(k,n): : if k < 1 or k > n: return 0 : elif n == 1 or n == k: return 1 : else: return p( k-1, n-1 ) + p (k, n-k ) : This could hardly be any clearer. The point is that lambda notation is equally clear to procedural notation in this situation, namely: p = lambda k, n: if k < 1 or k > n: 0 elif n == 1 or n == k: 1 else: p( k-1, n-1 ) + p (k, n-k ) and clearer in others, e.g.: y = derivative( ( lambda x: sqrt(3*x) ), at = 4.28 ) Lambda expressions are to functions what literals are to numbers. Some folks advocate getting rid of literals ("magic numbers") in complex expressions by assigning them to "meaningful" variables and using those variables instead. There are, however, still places where the use of numeric literals in expressions improves readability. The same goes for lambda expressions, including those that involve selection operations. Tom Payne From tim at zope.com Tue Sep 4 14:50:02 2001 From: tim at zope.com (Tim Peters) Date: Tue, 4 Sep 2001 14:50:02 -0400 Subject: 3-arg float pow() In-Reply-To: Message-ID: [Marcin 'Qrczak'] > I would expect pow to use multiplication when the exponent is an > integer (with a signle division if it's negative), As I said, that's less accurate than a decent libm pow() when floats are involved, so is a bad idea in that case. > and the libm pow or equivalently exp(b*ln(a)) if the exponent is a float. Sorry, but a libm that implemented pow(x, y) literally as exp(b*ln(a)) couldn't be given away (it's numerically atrocious for large |ln(a)| and/or large |b| -- decent fp math libraries are much harder to write than I expect you're aware of). > So (-3)**2 would be defined, but (-3)**2.0 would be not. Current CVS Python handles both fine, and even a raw libm pow() should have no problems with pow(-3, 2.0). > And 3**(-2) should return a rational. If we had rationals, sure. In the meantime 0.1111111111111111 is better than 0. From mcherm at destiny.com Tue Sep 18 10:50:46 2001 From: mcherm at destiny.com (Michael Chermside) Date: Tue, 18 Sep 2001 09:50:46 -0500 Subject: Proposed PEP for a Conditional Expression Message-ID: <3BA75F46.3040504@destiny.com> In Don O'Donnel wrote: ... > ...to me, this addition to the language is not a high priority, and I > would rather see scarce developer resources used in other areas. > > But, just in case this PEP is approved, and the conditional expression > makes it's way into the language, I would like to contribute my humble > opinion to the syntax arguments. [ several excellent points snipped ] > Just my 2 cents, for what it's worth. Thank you, Don... that was worth far more than 2 cents... it comes to slightly different conclusions thatn _I_ was beginning to reach, but was one of the most insightful and useful posts yet. -- Michael Chermside From peter at engcorp.com Fri Sep 28 23:43:02 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 28 Sep 2001 23:43:02 -0400 Subject: "self" vs other names References: <1001621496.801193@cswreg.cos.agilent.com> <9p058k01q7a@drn.newsguy.com> <3BB3EF91.BA8B9D59@engcorp.com> <9p21ro0cip@drn.newsguy.com> Message-ID: <3BB54346.1F99C18B@engcorp.com> Grant Griffin wrote: > > In article <3BB3EF91.BA8B9D59 at engcorp.com>, Peter says... > > > >Grant Griffin wrote: > >> > >[LOL... snip brilliant comic treatise on self] > >> > >>For me, four letters isn't too many. I can't really justify that except to say > > > >Ah, but there's the one mistake yourself made. For "me", four letters > >would be two letters too many. Otherwise it would be "meee", or "melf" > >or something like that. Still acceptable to Python, naturally, but > >curiously enthusiastic-sounding to most other programmers. > > > >> Grant R. Griffin g2 at dspguru.com > >> Publisher of dspGuru http://www.dspguru.com > >> Iowegian International Corporation http://www.iowegian.com > > > >Iowegian is definitely a better name than Me-o-us-gian though... > > > > Very good--you topped me! Oh, I don't think so! I've saved your posting for distribution to lighten the mood at work sometime. :) > tickled-just-to-see-that-somebody-got-it-ly y'rs, Not sure which part I "got"... did you drop that "for me, four letters..." part deliberately? Or the company name? I *know* you didn't pick the company name just to let you write parodies about self in Python! :) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From aleax at aleax.it Wed Sep 19 06:20:49 2001 From: aleax at aleax.it (Alex Martelli) Date: Wed, 19 Sep 2001 12:20:49 +0200 Subject: How to sort a list? NOT a newbie question. References: <9o4i4h$2ql@ascc.artsci.wustl.edu> <4jcgqtsvc9dc7or96alisr6rhcv776qhd1@4ax.com> <9o9ggs$sgs$1@serv1.iunet.it> <9o9mga$fmp@ascc.artsci.wustl.edu> Message-ID: <9o9ri0$nqh$1@serv1.iunet.it> "Michael James Barber" wrote in message news:9o9mga$fmp at ascc.artsci.wustl.edu... I had claimed Michael needed to test set-equality, but he notices: ... > Actually, this won't work in general. Consider having repeated roots of, > say, [1j,1j,-1j]. True! So, you need to test MULTI-SET equality -- i.e. to associate a *count* (number of occurrences) to each member in the (multi-)set. > It needs to be slightly modified to something like: > > def all_coefficient_are_real(roots): > rootset = {} > for root in roots: > rootset[root] = rootset.get(root,0)+1 > for root in roots: > if rootset[root] != rootset.get(root.conjugate(),0): > return 0 > return 1 > > Untested, but it looks right. Yep. Or, one could be slightly trickier, e.g.: def all_coefficient_are_real(roots): rootset = {} for root in roots: conj = root.conjugate() rootset[root] = rootset.get(root,0)+1 rootset[conj] = rootset.get(conj,0)-1 return not filter(None, rootset.values()) (also "untested, but":-) -- however, the simpler approach is no doubt preferable! Alex From weeks at vitus.scs.agilent.com Sun Sep 30 14:54:50 2001 From: weeks at vitus.scs.agilent.com (Greg Weeks) Date: Sun, 30 Sep 2001 18:54:50 +0000 (UTC) Subject: sameness/identity Message-ID: <1001876090.367103@cswreg.cos.agilent.com> I said in an earlier note that I didn't want to get into the whole issue of "sameness" and how Python "got it wrong". Well, I changed my mind. I'll first admit that "got it wrong" is a poor choice of words. Allow me to explain what I meant. Consider: x = 6.02 y = 6.02 Are x and y identical? They are identical as *numbers* (which I'll call conceptual identity) but not as Python *implentations* of numbers (since id(x) != id(y)). Good programming style requires us to think of numbers primarily as numbers and not as their implementations. So we are more interested in conceptual identity than in implementation identity. Now consider a simple Bank_account class: class Bank_account: def __init__(me, initial_balance): me.balance = initial_balance def deposit(me, amount): me.balance += amount def withdraw(me, amount): me.balance -= amount def get_balance(me): return me.balance my_bank_account = Bank_account(100) your_bank_account = Bank_account(100) Are the two bank accounts the same bank account? No. (How would you feel, for example, if I withdrew money from your bank account?) x and y are conceptually the same, but my_bank_account and your_bank_account are not. Why is (conceptual) identity of numbers different from (conceptual) identity of bank accounts? Because bank accounts are mutable. A bank account can have different states at different times. A number can't. So, we've encountered three kinds of identity in this discussion: A. conceptual identity B. implementation identity C. state identity In Python, B corresponds to "is". And to many Python programmers, C corresponds to "==". But that leaves A without an operator. I'm unable to swallow that. So, I use "==" for A; I never use "is"; and if I need C -- which hasn't happened yet -- I write a method for it. This works pretty well. It works for all the immutable types. It also works for bank accounts *as defined above*. That's why you won't find me adding __cmp__ and __hash__ methods to bank accounts. Note, by the way, that the above bank accounts are suitable hash table keys (and I have found that useful on occasion). Unfortunately, "==" does not represent conceptual identity for lists and dictionaries. (Lists and dictionaries are like bank accounts. They are not conceptually identical even if they happen to have the same state.) That's what I mean when I say Python "got it wrong". I can't *prove* that it is wrong. I *prefer* an operator for conceptual identity. And I have a *hunch* that programs are better with an operator for conceptual identity. But -- as all of you know -- 95% of my hunch is really just my preference. Greg From ignacio at openservices.net Sat Sep 22 01:09:54 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Sat, 22 Sep 2001 01:09:54 -0400 (EDT) Subject: Declaring function definition parameters In-Reply-To: Message-ID: On Sat, 22 Sep 2001, Ignacio Vazquez-Abrams wrote: > On 22 Sep 2001, Patio87 wrote: > > > I know how to use the function definition command but, I dont know how to use > > the parameters. If someone could explain to a learner how to use parameter it > > would be apreciated. Email me at patio87 at aol.com, thanks > > http://... Argh! I did it again. http://www.python.org/doc/current/tut/node6.html#SECTION006600000000000000000 -- Ignacio Vazquez-Abrams From mmhamze at pleiades.net Fri Sep 7 13:30:05 2001 From: mmhamze at pleiades.net (Maan M. Hamze) Date: Fri, 7 Sep 2001 12:30:05 -0500 Subject: Creating Excel files on Linux References: <3B97A39C.6A5234D7@olen.to> <873d5ygbzx.fsf@lumen.med.iupui.edu> Message-ID: "Michael A. Miller" wrote in message news:873d5ygbzx.fsf at lumen.med.iupui.edu... > >>>>> "Maan" == Maan M Hamze writes: > > > When I say that the world speaks the XLS language I mean > > that is what your average Joe Blow and Jane Doe understand > > behind their desks in their offices. > > My experience has been that the average user doesn't understand > that at all :) This is fine. But in my experience, the average user can create a Macro and be trained to create useful forms in Excel in a much shorter time than it will take to get a Computer Science degree in order to be able to step through a JAVA function. The issue here Michael, in my opinion, is that many attack Microsoft on the premise of the MYTH of an open platform that is being called on by many sides including companies that would not give a dime about this concept if they have the same market share as Microsoft. Maan From rickp at telocity.com Tue Sep 18 18:08:39 2001 From: rickp at telocity.com (Rick Pasotto) Date: Tue, 18 Sep 2001 22:08:39 GMT Subject: Tkinter - getting canvas window size References: Message-ID: On Tue, 18 Sep 2001 17:41:51 GMT in comp.lang.python, Fredrik Lundh wrote: > Rick Pasotto wrote: > > Why do the print statements in the following program show zero? > > "cget" returns the option value as specified (or in this case, the > default value), not the actual size. How do I get the actual size? The packed label might or might not contain a nl. I don't necessarily know the font size. I need to know the height of the frame (inside the canvas.create_window()) so I can position another one underneath it. > > How can I figure out the size of the frame? > > Use winfo_width/height (current size) or winfo_reqwidth/reqheight > (requested size). the latter is usually what you want. This always gives '1' as an answer no matter the actual size. winfo_geometry also always gives 1x1+0+0. How do I get this to work with the integer that canvas.create_window() returns? > more info here: > > http://www.pythonware.com/library/tkinter/introduction/basic-widget-methods.htm > => Window Related Information This is not helping me for widgets placed on a canvas. -- How could men dream of blaming themselves for their woes when they have been persuaded that by nature they are inert, that the source of all action, and consequently of all responsibility, lies outside themselves, in the will of the sovereign and of the lawgiver? -- Fr?d?ric Bastiat (1801-1850) Rick Pasotto rickp at telocity.com http://www.niof.net From andtherewaswater at yahoo.com Sat Sep 29 01:36:44 2001 From: andtherewaswater at yahoo.com (A.A) Date: Sat, 29 Sep 2001 09:36:44 +0400 Subject: Justifying text. Message-ID: <3BB55DEC.67F78190@yahoo.com> Hello, Has anybody written a program in python to justify text ? It is not so difficult except where the line has to be expanded (padded) to reach the margin. In most traditional heavy-weight text editors written in C, there is an option to justify. Do the programmers use a traditional method/formula ? A.A. From dale at riverhall.NOSPAMco.uk Sat Sep 29 04:37:48 2001 From: dale at riverhall.NOSPAMco.uk (Dale Strickland-Clark) Date: Sat, 29 Sep 2001 09:37:48 +0100 Subject: stdin broken on Win2K? References: <43u9rtsgorpj5fh4r07hkoakkh9bkh2u22@4ax.com> Message-ID: Thanks to all. It is a bug in Windows and qualifying the whole command in full overcomes it. I should have remembered this. I got cought by it a long time ago and it *REALLY* should have been fixed by now. -- Dale Strickland-Clark Riverhall Systems Ltd From rdacker at pacbell.net Tue Sep 11 13:58:07 2001 From: rdacker at pacbell.net (rdack) Date: 11 Sep 2001 10:58:07 -0700 Subject: can't connect to postgresql using pygresql Message-ID: <644f6688.0109110958.284cc26d@posting.google.com> using pygresql-3.2, postgresql-7.1.3, mac os x 10.0?, g4 i can import _pg, but get error on connect: >>>db=_pg.connect('tt1', 'localhost') _pg.error: PQconnectPoll() -- connect() failed: Connection refused Is the postmaster running (with -i) at 'localhost' and accepting connections on TCP/IP port 5432? port# problem? how do i determine what port postgresql is waiting on? could it be a path problem? i can run psql and see my db from the directory python is running from. anything else i could check? From cxu1 at china.com Mon Sep 24 07:30:30 2001 From: cxu1 at china.com (C.S. Xu) Date: 24 Sep 2001 04:30:30 -0700 Subject: python implementation of NETANTS ? References: <3a04f47b.0109191616.3cda741a@posting.google.com> Message-ID: <3a04f47b.0109240330.7bb8c76e@posting.google.com> Thank you very much. It's true that no "rest" option in Python 1.5.2 library reference, ;-) Now I've composed a simple python script: pyget. For example, to download the second fourth part of aFile from ftp.someDomain, I can use: pyftp --part 2/4 ftp://ftp.someDomain/aFile Then I can download every part at the same time, when they're all done, I can just `cat` them together. I've put this short script at: http://xucs.tripod.com/soft/pyftp It can also continue an interrupted downloading. Thanks again. > see > > 11.6.1 FTP Objects > > retrbinary(command, callback[, maxblocksize[, rest]]) > Retrieve a file in binary transfer mode. command should be an appropriate > "RETR" command, i.e. 'RETR filename'. The callback function is called for > each block of data received, with a single string argument giving the data > block. The optional maxblocksize argument specifies the maximum chunk size > to read on the low-level socket object created to do the actual transfer > (which will also be the largest size of the data blocks passed to callback). > A reasonable default is chosen. rest means the same thing as in the > transfercmd() method. > > transfercmd(cmd[, rest]) > Initiate a transfer over the data connection. If the transfer is active, > send a "PORT" command and the transfer command specified by cmd, and accept > the connection. If the server is passive, send a "PASV" command, connect to > it, and start the transfer command. Either way, return the socket for the > connection. > If optional rest is given, a "REST" command is sent to the server, passing > rest as an argument. rest is usually a byte offset into the requested file, > telling the server to restart sending the file's bytes at the requested > offset, skipping over the initial bytes. Note however that RFC 959 requires > only that rest be a string containing characters in the printable range from > ASCII code 33 to ASCII code 126. The transfercmd() method, therefore, > converts rest to a string, but no check is performed on the string's > contents. If the server does not recognize the "REST" command, an > error_reply exception will be raised. If this happens, simply call > transfercmd() without a rest argument. > > and remember not all servers will allow multiple threads > > Tom From bac at OCF.Berkeley.EDU Wed Sep 19 18:39:18 2001 From: bac at OCF.Berkeley.EDU (Brett Cannon) Date: Wed, 19 Sep 2001 15:39:18 -0700 Subject: I have a problem..please help In-Reply-To: <20010919181037.23562.00000920@mb-cp.aol.com> References: <20010919181037.23562.00000920@mb-cp.aol.com> Message-ID: I just typed both lines in IDLE and I get 70 returned (which is what the interpreter should spit back and no 70 like you said). Can you clarify a little bit more about what the problem is? If you just want the result of the equation printed out just do: print hp - 30 If you meant something else, please clarify. -Brett C. On 19 Sep 2001, Patio87 wrote: > Im trying to make a game and was wondering if someone could help me > I have a couple of lines of code that will only work in interactive mode. > here is: > > hp = 100 > hp - 30 > > > and just a simple couple lines is what is confusing me. It spits out 30 in > interactive mode but when i run it in ide it just gives me a prompt > please help me, pAT > From asgard at hellnet.cz Sat Sep 29 18:45:57 2001 From: asgard at hellnet.cz (asgard) Date: Sun, 30 Sep 2001 00:45:57 +0200 (CEST) Subject: Are user-defined objects good keys? In-Reply-To: <1001794368.355210@cswreg.cos.agilent.com> Message-ID: On Sat, 29 Sep 2001, Greg Weeks wrote: > My central question is: Can I use user-defined mutable instances (that are > "==" iff their ids are equal) as dictionary keys? On my system I can. > What about others? I don't see the point. You could only find something in such dictionary by using the exactly same object as key, not a different instance with the same content. This probably isn't what would one expect. Regards, Jan Samohyl From spam at melkor.dnp.fmph.uniba.sk Tue Sep 4 03:06:32 2001 From: spam at melkor.dnp.fmph.uniba.sk (Radovan Garabik) Date: Tue, 4 Sep 2001 09:06:32 +0200 Subject: Is 0 > None?? (fwd) References: Message-ID: Marcin 'Qrczak' Kowalczyk wrote: : Sat, 1 Sep 2001 21:19:43 +0200, Radovan Garabik pisze: :> and you heard correctly that it is a bad idea. : I never heard a convincing argument. :> A very bad idea indeed, because it could happen that my program :> would stop working for anybody with different locale charset. : Such program would currently not work *at all* - hardly an improvement. At least it forces the author think about the issue - not just assume everybody uses latin1 (as is the case in many programs). well, I would prefer utf-8 encoding - this is what one can expect to use when there is already need for unicode strings. :> And for those on OpenBSD as well (since OpenBSD does not have proper :> locale support) : So because of poor locale support on OpenBSD it won't work on Linux? : Let's drop os.fork then - it's not available under Windows. it is, for cygwin version -- ----------------------------------------------------------- | Radovan Garabik http://melkor.dnp.fmph.uniba.sk/~garabik | | __..--^^^--..__ garabik @ fmph . uniba . sk | ----------------------------------------------------------- Antivirus alert: file .signature infected by signature virus. Hi! I'm a signature virus! Copy me into your signature file to help me spread! From mcherm at destiny.com Fri Sep 14 16:29:59 2001 From: mcherm at destiny.com (Michael Chermside) Date: Fri, 14 Sep 2001 15:29:59 -0500 Subject: Proposed PEP for a Conditional Expression Message-ID: <3BA268C7.5000904@destiny.com> James_Althoff writes: > With apologies for possibly having missed some parts of this thread . . . > > Given: > 1) nested scopes, and > 2) recent proposals becoming more and more complicated and convoluted -- > e.g., embedding "break" and "return" statements inside if:else: expression > syntax, highly overloaded meanings of if:else: , > inside/outside/upside/downside ordering of if:else: keywords, etc., . . . > > Why not just start with something simple like a builtin "cond" function > approximating the following: > > I *think* I can answer your question by quoting from the PEP: > WORKAROUND_1: (this DOESN'T WORK!) > > def cond(c, a, b): > > if c: return a > > else: return b > > x = cond(c, a, b) > This fails, because it does not short-circuit... the > arguments the the function are always evaluated before > the function is invoked. Thus, for instance, the > following would not work properly when a == 0: > > x = cond( a==0, DEFAULT_VAL, 100/a ) Do you see why the "cond" solution won't do? -- Michael Chermside From ullrich at math.okstate.edu Tue Sep 4 10:17:17 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Tue, 04 Sep 2001 14:17:17 GMT Subject: 3-arg float pow() References: Message-ID: <3b94e106.465287@nntp.sprynet.com> On Mon, 3 Sep 2001 17:06:09 -0400, "Tim Peters" wrote: >[David C. Ullrich] >> Seems like pow(3., 500., 7.) can't possibly do anything except just >> 3.**500. % 7(???), hence the random nature of the result and the utter >> uselessness. > >[Markus Schaber] >> The trick is that it is a exponential function with large result modulo >> a small number. (such operations are e. G. used in the RSA crypto >> algorithm) >> ... [and an explanation of the modular square-and-multiply method] ... > >I'm sure David knows all that. I was pretty sure I knew all that - if _you_'re sure I did then I'm certain I did.... Could be telepathy, could be the fact that I mentioned the algorithm in my post, who knows. Regarding what you said about what I said: Never mind then - certainly didn't mean to say that you shouldn't make the change you had in mind, was just curious about exactly what you meant. > He's responding specifically to that these >are not integers, but floating-point numbers. David C. Ullrich From claird at starbase.neosoft.com Mon Sep 17 14:41:04 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 17 Sep 2001 13:41:04 -0500 Subject: GUI frontend IPC question References: Message-ID: In article , Campbell wrote: >Hello, > >Again, because I'm working in Python, my own design issues become >on-topic. :) > >I have an app servicing up to 120 'clients' at one time. I would like >to make a gui which will display current status of each of the ports >(idle, active), and some other information. > >I originally made this gui a part of the server .py file, but wxPython >takes a chunk of time out of my 'wait for event' loop (while it >processes windows events), which then cannot respond to incoming events >fast enough. Creating the GUI as another application is easy, but how >will the front end know what the state of the actual application is? > >So it all boils down to 'what does IPC look like and what options do I >have', I guess. Every program I have written before now, had both the >display and the inner core, both in one process, so this is very new to >me. . . . Tcl people started such a list at . -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From juan.alcolea at bt.es Tue Sep 11 07:29:31 2001 From: juan.alcolea at bt.es (juan.alcolea at bt.es) Date: Tue, 11 Sep 2001 13:29:31 +0200 Subject: Asking for advice: Using Python for data validation Message-ID: <9BF904D9BF6FD511B6B70008C7DBDD230193A7@ESLICASAEX2> Hi! I need a piece of advice: In a little project where I am currently working, we must receive and load data from very different sources and very different geographic locations. The data comes as plain ascii text files, and we are having a lot of problems with the quality of the data we are receiving, so a lot of time is wasted trying to load wrong-formatted or incomplete data, finding out where is the offending data and what the problem is, asking the remote administrator to correct and resend the files, etc... I'm thinking about using python to code a set of scripts that perform some data validation (format, completeness) of the files *before* they are sent to us, so any error is detected as close to the source as possible (and as far from us as possible ;-) in order to minimize this bad-data time waste. The questions are: - Do you think that Python is a good choice for this task? Please note that the scripts must run in very differente platforms (NT, *nix, maybe Mac...). I'm fairly new to Python, and although I'm impressed with it, I'm not sure about it being really and easily portable unless you're a C & OS guru... - Is there any module or library specially designed for this kind of task? (parsing text data files with fixed or variable length fields, validating date formats, etc...) Big thanks in advance! Juan Jes?s Alcolea Picazo - jjalcolea at inad.es ********************************************** Noticia legal Este mensaje electr?nico contiene informaci?n de BT Telecomunicaciones S.A. que es privada y confidencial, siendo para el uso exclusivo de la persona(s) o entidades arriba mencionadas. Si usted no es el destinatario se?alado, le informamos que cualquier divulgaci?n, copia, distribuci?n o uso de los contenidos est? prohibida. Si usted ha recibido este mensaje por error, por favor borre su contenido y comun?quenoslo en la direcci?n postmaster at bt.es. Gracias From ahenshawatapowerdotcom Fri Sep 7 19:58:10 2001 From: ahenshawatapowerdotcom (Andrew Henshaw) Date: Fri, 7 Sep 2001 19:58:10 -0400 Subject: list comprehensions: sorting? References: <9n7aim020of@enews1.newsguy.com> <9na4190avo@enews1.newsguy.com> Message-ID: "Alex Martelli" wrote in message news:9na4190avo at enews1.newsguy.com... > "Clark C . Evans" wrote in message > news:mailman.999804189.8996.python-list at python.org... > ... > > | map(process, sorted_by(2, > > | [x for x in mylist if x[4]], descend=1)) > > > > It works... but it's a bit ugly. I'd like a > > more "intuitive" syntax... and without having > > to roll my own sort function. I would think > > that sorting lists as part of a list comprehension > > would be a common activity... I certainly do it > > often enough. > > Some kind or other of sorting is very common, but > the specific case your "sortdesc" keyword might > cover if it existed is far too specific and thus > rare -- sorting on a specific "column" of a > list of tuples *before* further processing. > > I don't recall offhand the last time I had such > a very specific need -- I sort very frequently, > but it generally has to be descending on this or > ascending on that and guaranteed stable, or > something like that. And generally I don't > need the further processing to be done after > sorting -- it's fine either way. ...snip... This is somewhat off topic, but I recently posted a cookbook recipe to Activestate for a class that provides for multiple-key, multiple-direction sorting. It's designed to mimic the SQL "ORDER BY" clause so that you can pass in a list of sort keys (attributes of the class) with optional 'ASC' or 'DESC' modifiers. It could use some improvements, but I find it quite useful. Andrew Henshaw From ignacio at openservices.net Fri Sep 21 18:37:49 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Fri, 21 Sep 2001 18:37:49 -0400 (EDT) Subject: To re or not to re ... ( word wrap function?) In-Reply-To: <3BABBDFA.456B4B45@home.net> Message-ID: On Fri, 21 Sep 2001, Chris Barker wrote: > I was just asked if it would be hard to write a script that would take > the output from an MS word: "save as text" operation, and re-format it > so it was wrapped to 80 character lines. I said it would be easy, then I > thought about it and realised it was not quite as trivial as I thought. > First I came up with a function that used a few string methods, but was > mostly "by hand". Then I tried an re version. It turned out to be not > much easier or shorter, though probably a little faster. I have not > benchmarked it, and frankly, speed is of little concern here: I'm after > elegance. > > Anyway, I figured that: > A) someone else must have done this already Yup. The following will do an entire document at once: --- def wordwrap(text, width): i=0 while ilen(text): i=len(text) else: findnl=string.find(text, '\n', i) findspc=string.rfind(text, ' ', i, i+width+1) if findspc!=-1: if findnl!=-1 and findnl From ignacio at openservices.net Wed Sep 12 21:14:20 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Wed, 12 Sep 2001 21:14:20 -0400 (EDT) Subject: unicode strings and such In-Reply-To: <3BA0012C.8060307@hp.com> Message-ID: On Wed, 12 Sep 2001, Garth Grimm wrote: > The environment is a Python driven web server. We build a list of two-element tuples by running one > file. The tuples represent a regular expression pattern to match against, and the appropriate patch > to use for substitution. The other file loops through the list and modifies a unicode string as > appropriate. > > The data file - written with UTF-8 encoding, representing Japanese characters: > > > > The processing file: > > > > That's what worked. > Here's some notes on other things we tried and thought -- none of which seem to do any good. > 1) including encoding:utf-8 in the first line of the data file didn't do anything. I can't for the life of me understand why that would work, but anyways... > 2) prefixing the data in the data file to be u'(?f~?f??f--)(\d{3})' didn't work at all. No, because then you're saying that the text in the string is UCS-2, not UTF-8. > 3) why is the str() call needed? I don't know, but the text that I'm seeing in the message doesn't seem to be valid UTF-8 so I can't be sure why. > Here's how I thought things should have worked... > > a) Use UTF-8 encoding on the data file and use u'^????? ??.??"$' notation in it. This would create two-element tuples > of unicode strings. No. See my response to point 2 above, > b) loop through repairList, assigning references to each element of the tuple to patch and pattern, > which would be references to unicode strings. ... > c) go straight to the re.compile() call, since pattern references a unicode string. Once the other issues are mopped up, certainly. -- Ignacio Vazquez-Abrams From aaronf at NOSPAMtelusplanet.net Fri Sep 14 21:15:48 2001 From: aaronf at NOSPAMtelusplanet.net (Aaron Fransen) Date: Sat, 15 Sep 2001 01:15:48 GMT Subject: H E L P References: Message-ID: <8Zxo7.43894$Gi6.5030543@news0.telusplanet.net> I've used the standard ODBC module included with the Python distribution (ActivePython anyway!) to connect to both MySQL and an IBM AS/400 with virtually no issues. Possibly the only problem is that you have to create the DSN record as a SYSTEM DSN, NOT a User DSN. Windows (2000 anyway, can't speak for 9x) treats ODBC calls within an application as running through a different user space. "Charles" wrote in message news:mailman.1000326495.8581.python-list at python.org... > Hi > Anybody know how can i connect a goddam microsoft SQL Server > with linux python ? > > mxODBC not work. > Dave Cole MSSQL module with Sybase ASE 11.9.2 > not work too... > > regards > Charles > > From gerson.kurz at t-online.de Sat Sep 15 06:01:56 2001 From: gerson.kurz at t-online.de (Gerson Kurz) Date: Sat, 15 Sep 2001 10:01:56 GMT Subject: what's the best methode to crypt/encode the python code. References: <3BA210A5.E027C11B@yahoo.com> Message-ID: <3ba32596.14949031@news.t-online.de> PyAES provides Rijndael (=> AES) encryption capabilities for python, implemented in an external module so its fast, too: http://sourceforge.net/projects/pyaes The "Don't-Store-The-Password"-Mechanism explained, since this comes up again and again: A symetric encryption alg (like Rijndael) does this algorithm(data,key) => encrypted_data algorithm(encrypted_data,key) => data See, given the key you can encode a message, and decode it back again. So, for any given encrypted message, there is only one possible decrypted message (and vice versa). At least, thats what the books say. Password checks is implemented like this: 1) Calculate algorithm(data,key) where data is the password you want to use. This gives you an encrypted password that you can store in your db. 2) When you want to check if a password is valid, you do algorithm(user-input,key) if the result - the encrypted password - is the same as the password previously encrypted, the input was correct. Easy, right? From rnd at onego.ru Fri Sep 14 15:38:00 2001 From: rnd at onego.ru (Roman Suzi) Date: Fri, 14 Sep 2001 23:38:00 +0400 (MSD) Subject: pygettext and PEP #?# Message-ID: Hello! I remeber we had hot discussion about how to tell Python which encoding it's code is in. po-files use the following convention: "Project-Id-Version: PACKAGE VERSION\n" "POT-Creation-Date: Fri Sep 14 21:32:52 2001\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: ENCODING\n" "Generated-By: pygettext.py 1.3\n" Probably Python's module-level doc-string could also adopt RFC-822 style header which will provide such meta-information? (Right now doc strings do not concatenate). That is, making __doc__ RFC822 message which header has metainfromation and body - usual comments. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Friday, September 14, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "URA Redneck if you own a homemade fur coat." _/ From anon at nowhere.net Thu Sep 13 17:47:19 2001 From: anon at nowhere.net (Anon) Date: Thu, 13 Sep 2001 23:47:19 +0200 Subject: [PyQt] Confused by this class hierachie ... (large) References: <9nqgdb$h2i$1@news.netcologne.de> <9nqu1s$6hl$1@news1.xs4all.nl> Message-ID: <9nr9fo$d89$07$1@news.t-online.com> Dear Mr. Rempt, thank you for your answer to my post. Unfortunately it seems that I must have been unclear about my problem. Actually it is not my problem to *show* the dialog, rather it is to let the dialog perform actions on a specific class instance. Let me present you some code snippets: ----------------- file 'widgets.py' ----------------- from qt import * class myMultiLineEdit(QMultiLineEdit): def __init__(self, *args): apply(QMultiLineEdit.__init__, (self, ) + args) def mousePressEvent(self,e): if e.button() == QMouseEvent.RightButton: contextMenu = QPopupMenu(self) id_link = contextMenu.insertItem("menuItem") r = contextMenu.exec_loop(e.globalPos()) if r == id_link: dialog(self.parent()) else: QMultiLineEdit.mousePressEvent(self,e) - class widget(QWidget) o uses myMultiLineEdit - class mainWidget(QWidget) o uses widget class dialog(QDialog): def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl) Now lets say the user is asked to input some arbitrary values which should be added to the shelve object defined below. Therefore I think the dialog instance above has to know about 'w' as an instance of 'gui' - but how? ------------ file 'ui.py' ------------ from qt import * import widgets, shelve class gui(QMainWindow): def __init__(self, parent=None, name=None, filename='/tmp/test'): self.db = shelve.open(filename) ... self.mw = widgets.mainWidget(self) self.setCentralWidget(self.mw) ... def add(self): self.db['key'] = 123 --------------- file 'start.py' --------------- import sys, ui from qt import * if __name__ == '__main__': a = QApplication(sys.argv) QObject.connect(a,SIGNAL('lastWindowClosed()'),a,SLOT('quit()')) w = ui.gui() a.setMainWidget(w) w.show() a.exec_loop() I hope that it is now expressed more clearly what my problem actually is. If you could (once again) give me an advice? Kind regards. Boudewijn Rempt wrote: > > Well, without some actual code it's difficult to tell exactly what your > problem is. What I mostly do is create the dialogs in the constructor of > my main window class - that makes it available everywhere. You create > the dialog with the main window instance as parent, and that means you > can get at the main window from the dialog with self.parent(). > > You can take a look at http://stage.linuxports.com/pyqt/x1771.htm or > http://stage.linuxports.com/pyqt/c3816.htm - the first is about the > standard dialogs PyQt offers, the second about creating real, complex > dialogs. > > If those chapters don't clear away your confusion, please tell > me - then I can adapt the text and make it clearer! > > -- > > Boudewijn Rempt | http://www.valdyas.org > From aleax at aleax.it Fri Sep 28 16:43:22 2001 From: aleax at aleax.it (Alex Martelli) Date: Fri, 28 Sep 2001 22:43:22 +0200 Subject: Python in The Economist's "Technology Quarterly", September 22 Message-ID: <9p2nda$hr8$1@lancelot.camelot> A bit tangentially, but... if you subscribe to their online edition you can read the story at: http://www.economist.com/displayStory.cfm?Story_ID=S%26%28%280%25QQ%2F%2A%0A In the print edition, it's page 14 of "Technology Quarterly" in the middle of the September 22 printed Economist. "A lingua franca for the Internet" is the title, and the article purports to be mostly about the clash between Java and C#, but... The article *starts* with a mention of '''weighty tomes with titles such as "UML in a Nutshell" and "Programming Python"''' -- Sinan Si Alhir and Mark Lutz, and O'Reilly who publishes them both, must be grateful for being singled out like this (particularly in a publication co-owned by Pearson, also owner of their worthy competitor New Riders!-). Later on it talks about languages "flexible and adaptable to the needs of the Internet: examples incude Perl, a language that can be used to communicate between a web server and its clients, and Python, a language used, among other things, for managing discussion forums on the Internet". I particularly like how they used the "among other things" for Python and NOT for Perl:-). Overall not quite as good an article as I've come to expect from "The Economist" over the years, but still pretty good if you can get it... Alex From n8gray at caltech.edu.is.my.e-mail.address.com Fri Sep 28 20:28:34 2001 From: n8gray at caltech.edu.is.my.e-mail.address.com (Nathaniel Gray) Date: Fri, 28 Sep 2001 17:28:34 -0700 Subject: Repost: execfile() confusion References: <9p2iuk$1au@gap.cco.caltech.edu> <9p2k4n$f05$02$2@news.t-online.com> Message-ID: <9p353h$beb@gap.cco.caltech.edu> Petr Kubanek wrote: > [snip] I almost forgot: thanks for the reply! :-) -n8 -- Nathaniel Gray California Institute of Technology Computation and Neural Systems -- From claysjunkmail at yahoo.com Wed Sep 5 07:53:11 2001 From: claysjunkmail at yahoo.com (Clayton Brown - Emmie Osawa) Date: 5 Sep 2001 04:53:11 -0700 Subject: PythonWin - Clearing output in interactive menu? Message-ID: <1b9aff84.0109050353.2fb8f810@posting.google.com> is there a simple command which will clear any history in the interactive menu similar to CLS in a dos shell to be placed at the start of a script. Would be intersted in one that perhaps works when in dos shell also... From donn at drizzle.com Sat Sep 22 01:01:21 2001 From: donn at drizzle.com (Donn Cave) Date: Sat, 22 Sep 2001 05:01:21 -0000 Subject: "shell-commands" and python! References: <1001087411.956907@cswreg.cos.agilent.com> <3BAB6306.D9CF4F1A@alcyone.com> <1001090296.877856@cswreg.cos.agilent.com> <3BABF683.5154906F@alcyone.com> Message-ID: <1001134880.573740@yabetcha.drizzle.com> Quoth Erik Max Francis : [... re making Python do the shell's work ...] | Because Python is not a shell script, and should not strive to be like | them. It's a different language. That's absolutely right, the Bourne shell is a true application scripting language, where the application is UNIX, and its nature is all about providing a convenient interface to UNIX. Python on the other hand is a general purpose programming language, and you can't roll up all the advantages of these two in one language. However, | Furthermore, many of the cases you talk about don't make sense. Shell | script redirections, pipes, etc. all assume there are sensible streams | of data moving around. That makes perfect for a shell, where they | organize programs being run and their input and output, but what does it | mean for Python code in general where no such streams exist? | | I think you're getting One Hammer Syndrome. Why not use both, each for | the purposes at which they're best suited? It really is not a trivial matter to get a comprehensive grasp of the Bourne shell, or worse the more bloated Korn shell or Bash. And the shell isn't exactly the perfect programming environment. When you start pushing data around, Python is far better. So there are valid reasons to think about using Python in place of the shell, a way to deploy UNIX programs. But for practical purposes, it really is always going to be easier in most cases to use the shell, when in need of a shell. Donn Cave, donn at drizzle.com From paulp at ActiveState.com Fri Sep 7 17:20:29 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 07 Sep 2001 14:20:29 -0700 Subject: Nested scopes: why is it weird? References: <3B98F3B0.53AC2524@swiftview.com> <9nau9o01ni5@enews2.newsguy.com> <3B991FA6.EAB19A71@ActiveState.com> <01090712591203.02565@logiplex1.logiplex.net> Message-ID: <3B993A1D.154B034F@ActiveState.com> Cliff Wells wrote: > >... > > a = 5 > > > > def foo(): > > a = 6 > > > > It would be better to require one of the names to be changed. > > It silently does the right thing. Changing the value of a variable from an > enclosing scope is a _bad_ idea. This is what is called a "side effect" and > was one of the things structured programming was created to prevent. Side effects are a fundamental part of Python programming. If they weren't, Python wouldn't have the "global" keyword. I think it is great that Python requires you to be explicit when you want to overwrite a global variable. I think it should similarly reqiure you to be explicit when you want to shadow one. Or it could simply disallow the shadowing -- it isn't very useful anyhow. Just call the inner a "inner_a". -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From boyd at insultant.net Thu Sep 27 07:59:34 2001 From: boyd at insultant.net (Boyd Roberts) Date: Thu, 27 Sep 2001 13:59:34 +0200 Subject: Using glob (was Re: Remove files of same type (extension)) References: <9on1mq$pj8$04$1@news.t-online.com> <3BAF3754.68BDA949@yahoo.com> <3BB00766.CC23290C@engcorp.com> <9ophr4$7u8$1@quark.noos.net> <9os8qv$d96$1@neon.noos.net> <3BB1DDE2.DD45D2C8@engcorp.com> <9osnri$l9$1@quark.noos.net> <3BB298B9.B266995C@engcorp.com> <9ou8qk$dog$1@neon.noos.net> Message-ID: <9ov4hc$hg0$1@neon.noos.net> "Chris Gonnerman" a ?crit dans le message news: mailman.1001564610.605.python-list at python.org... > But what is the point you are belaboring? oh it was late, i was tired and got too focused on the 'dot question'. in the fog of battle i overlooked the fact that 'ls -a' is a superset of 'echo .*'. win some, lose some :) all this dot trickery was a bad idea. plan 9 has removed this and the '-a' option to ls. i am currently attempting a native plan 9 port of 2.1.1. i have the odd azerty keyboard problem to sort out first. From aleax at aleax.it Wed Sep 5 03:41:16 2001 From: aleax at aleax.it (Alex Martelli) Date: Wed, 5 Sep 2001 09:41:16 +0200 Subject: COM/CORBA/DCOP (was: Hello people. I have some questions) References: <7xsne7en0r.fsf@ruckus.brouhaha.com> <9mvp3505rt@enews2.newsguy.com> <9n292n01lg1@enews3.newsguy.com> Message-ID: <9n4kut013qk@enews1.newsguy.com> "Erno Kuusela" wrote in message news:kug0a2h37i.fsf at lasipalatsi.fi... > In article <9n292n01lg1 at enews3.newsguy.com>, "Alex Martelli" > writes: > > | "Erno Kuusela" wrote in message > | news:kusne3hcry.fsf at lasipalatsi.fi... > || > || "joy" and "nat" in the same sentence? ugh! > > | With ipf/ipnat, the oxymoron of joyful nat'ting > | magically became possible:-). > > but it's a fundamentally broken concept! I guess we'll just have to agree to disagree on this point. > over here isps tend to sell ip connections with 10.x addresses + nat > as "internet" to people and then you can't do anything except > browse the web and read email. ...and irc and news and cvs and ntp and okbridge and icq and... I don't particularly care about video-on-demand at this point in time, but with nat &c correctly configured, I see no fundamental technical reason it couldn't be made to work. Of course, I'll have to go with dynamic DNS to match the dynamic IP assignment if I want to offer servers, but that's got nothing to do with NAT'ting -- even just one box with a dynamic IP address would be in the same boat. > there is a good rant about this and other internet breaking stuff > at http://www.technetcast.com/tnc_play_stream.html?stream_id=311>. If you can give me URL's to transcripts of this, or other _written_ material, I'll be happy to read and ponder over them, but I don't do video/audio at this point. > i suppose it might be ok if you do it in the privacy of your > own home and don't impose it on hapless users who aren't aware > it breaks a lot of stuff. You could argue I'm imposing it on my hapless girlfriend, who, while a whiz website designer, can't tell ICMP from IGMP (but I'm sure she'll be great at Python when I finally manage to workaround her instinctive "no way I'm not a programmer I'm not gonna even look at this" reaction:-). > | for security-crucial functions...? "The pieces that aren't > | there are those you know won't break", etc, etc". > > well, putting X on the firewall doesn't make it any more or less > stable In theory, but -- the difference between theory and practice, in practice, is larger than the difference between practice and theory, in theory. _Maybe_ I can have X and a zillion other things and everything will be just peachy -- and then, maybe again, I can't... what unsuspected exploitable bugs may lie in software I've installed when I could well have avoided installing it? *the pieces that aren't there are the ones you KNOW won't break*. > (unless you allow untrusted users shell accounts on it, > but you can't really defend someone with a shell account > from rootnig a unix box (including openbsd) anyway). I wonder -- when it's consolidated and hardened enough, I might experiment with that. But anyway, who's happy with a single layer of defense? I want security in depth, and all feasible precautions. Not have avoidable accounts on the firewall box, but not have avoidable pieces of software on it either (minimal base OpenBSD 2.9 install, plus of course *Python*, which *is* absolutely indispensable, and _maybe_ some proxies just so I can tighten the FW down even more while still allowing the PC's to access the internet through the proxies). > i've been pretty happy with running packet filtering on my single > computer i have at home, but then i don't attempt anything very > ambitious functionality wise. As for me, I do need to share the ADSL connection among half a dozen PC's (both Windows and Linux ones), and also eventually run some small servers accessible from the outside (unless that means code-red scans tie up all my very modest bandwidth, of course:-) -- and I aim to do it all in the safest way I can devise. We'll see... Alex From loewis at informatik.hu-berlin.de Mon Sep 17 04:24:11 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 17 Sep 2001 10:24:11 +0200 Subject: iso-8859-2 in sax References: Message-ID: arturs at iidea.pl (Artur Skura) writes: > Has anyone succeeded in making 8859-2 encoding work in Python's xml.sax? > If I put it in the header of my XML docs, it complains "unknown encoding", > (if I just ignore that, it chokes on first non-ASCII char anyway). > I think I should be able to declare some UnknownEncoding handler with > expat, but I don't know if it's possible in Python. Pity, because SAX > is ideal for what I'm doing now. What version of Python are you using? The pyexpat of Python 2.1, and of PyXML 0.6.6, both are capable of using Python codecs for converting documents into Unicode. Regards, Martin From andorxor at gmx.de Sat Sep 8 08:08:15 2001 From: andorxor at gmx.de (Stephan Tolksdorf) Date: Sat, 8 Sep 2001 14:08:15 +0200 Subject: Translating a Perl regex into Python References: <9naa3a$182$05$1@news.t-online.com> Message-ID: <9nd1l2$2ah$00$1@news.t-online.com> > Try just taking the original Perl regex, and just wrap r'''...''' around > it. ie: Thanks for the help. How could I forget to use raw strings? But it still doesn't work for me... This perl program -- $str = "// one line of comment \nfunction () { /* another comment */ }"; $str =~ s#/\*[^*]*\*+([^/*][^*]*\*+)*/|//[^\n]*|("(\\.|[^"\\])*"|'(\\.|[^'\\])*'|.[^ /"'\\]*)#$2#gs; print $str; --- returns the correct output. The python program -- import re rex = re.compile(r'''/\*[^*]*\*+([^/*][^*]*\*+)*/|//[^\n]*|("(\\.|[^"\\])*"|'(\\.| [^'\\])*'|.[^/"'\\]*)''', re.M | re.S) str = re.sub(rex, r"\2", "// one line of comment \nfunction () { /* another comment */ }") print str -- returns the error "sre_constants.error: empty group". I'm stuck... Greetings, Stephan From aleax at aleax.it Wed Sep 12 07:06:43 2001 From: aleax at aleax.it (Alex Martelli) Date: Wed, 12 Sep 2001 13:06:43 +0200 Subject: cygwin+python+XML? Message-ID: <9nnfk402ddc@enews1.newsguy.com> Has anybody managed to build expat (1.95.2 is the latest release I can see on Sourceforge -- the zip I saw on the expat's site itself seems to be a Win/VC++ only install?) on a recent cygwin (I've just downloaded and installed it on this old Win/NT box, and got the 2001-05-20 version of Cygwin), so as to enable Python (2.1.1 is the version that comes with Cygwin, from their contrib directories) to do XML processing? Building expat from sources fails midway with a lot of undefined-reference errors for symbols of the form __imp_*, and the reason for that is clear: expat.h forces a __declspec(dllimport) on every symbol when it finds __declspec is defined (clearly to accomodate VC++?), but that's not how it has built the expat library. I did see a mention on Python's XML-SIG about having to use DLEXPORT on all symbols, but I was hoping to avoid having to patch the expat sources. I do have a full working Python 2.1.1 for Win32/VC++6 on the same disk where I'm trying to set up the Cygwin version, in case any piece can be copied and reused (...but I sort of doubt it...). I just wanted to set up the cygwin version too because sometimes I get help requests about it, and it would be nice to have a complete working version of Python -- complete with XML processing, Tkinter and all -- on the cygwin side to answer such requests! Alex From garth.scheck at intp.com Fri Sep 14 15:53:30 2001 From: garth.scheck at intp.com (gs) Date: 14 Sep 2001 12:53:30 -0700 Subject: visual basic DLL's Message-ID: <5270853d.0109141153.54b0f74c@posting.google.com> Does Python support DLL's created in Visual Basic? If so does anyone have an example of how to import a Visual Basic DLL? From loewis at informatik.hu-berlin.de Fri Sep 14 08:33:26 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 14 Sep 2001 14:33:26 +0200 Subject: Python's architecture References: <4e2ddb70.0109140241.1d9666b0@posting.google.com> Message-ID: jonas.b at home.se (Jonas Bengtsson) writes: > Is there any good resources 'out there' that describes the > architecture of Python? The most material I have found has been about > the syntax and such. > We are a group that are going to have a presentation about Python's > architecture as a school work (for about 30 min). I'm not quite sure what you are asking. Do you want to know how the Python language is organized? If so, I'd say it is structured as most other languages, i.e. syntax, semantics of the core language, plus standard libraries. Details on how these are organized is available in the reference manuals. Or do you want to know how the C implementation of the Python interpreter is organized? I don't think there is much overview information on that available - most people dealing with that are expected to know about compiler construction, i.e. from reading the Dragon Book (Aho, Seti, Ullmann. Compilers - Principles, Techniques and Tools). The Python interpreter follows many of the principles explained there (lexer, parser, AST, semantics analysis, code generation, ...). HTH, Martin From bill-bell at bill-bell.hamilton.on.ca Sun Sep 2 10:33:46 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Sun, 2 Sep 2001 10:33:46 -0400 Subject: COM MakePy utility in PythonWin In-Reply-To: <999425655.236.76886.l10@yahoogroups.com> Message-ID: <3B920B0A.31170.9A59438@localhost> "Maan Hamze" wrote, in part: > Hope someone can give some hints as to what does [makepy] do exactly. Maan, Have you noticed Chapter 12 of Hammond & Robinson, "Python Programming on Win32"? The book as a whole is a good read and well worth the price. Last time I looked that chapter was available on the O'Reilly site. Bill From drew_csillag at geocities.com Mon Sep 24 12:47:05 2001 From: drew_csillag at geocities.com (Drew Csillag) Date: Mon, 24 Sep 2001 12:47:05 -0400 Subject: [ANN] SkunkWeb 3.1 Beta 2 released! Message-ID: <20010924124705.A4451@starmedia.net> Release 3.1 Beta 2 of The SkunkWeb Web Application Server has just been released. The release is available from the SkunkWeb home page at http://skunkweb.sourceforge.net or directly from http://prdownloads.sourceforge.net/skunkweb/skunkweb-3.1beta2.tgz What's new? (from 3.0) ------------------------------ * Major performance tweaks. Should now be about 30% faster overall. * Now supports FastCGI * PyDO improvements (mainly PostgreSQL related) * new service - userdir - which makes it so that requests to /~user/foo will go to /public_html/foo * print statements in <:call:> tags now work. * <:call:> tag now handles multiline expr argument properly. Now you can do things like: <:call `def foo(x): return 'the value is %s' % x print foo(3)`:> Very best wishes to all, -Drew -- print(lambda(m,d,y):['Sun','Mon','Tues','Wednes','Thurs','Fri','Satur' ][(lambda(m,d,y):(23*m/9+d+4+y/4-y/100+y/400)%7)(m<3and(m,d+y,y-1)or( m,d+(y-2),y))])(map(int,raw_input('mm/dd/yyyy>').split('/')))+'day' From ignacio at openservices.net Sat Sep 22 14:22:08 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Sat, 22 Sep 2001 14:22:08 -0400 (EDT) Subject: "shell-commands" and python! In-Reply-To: <1001180602.810784@cswreg.cos.agilent.com> Message-ID: On Sat, 22 Sep 2001, Greg Weeks wrote: > Ignacio Vazquez-Abrams (ignacio at openservices.net) wrote: > : Ease of redirection and backgrounding has not been a part of Python in the > : past, and we have to wonder whether adding those features is an actual > : improvement or just a nicety. > > Three points: > > 1. The tone of this discussion has been disappointing, although my thanks > to those who tried to keep it above board. I apologize for my tone at times. I haven't been feeling 100% lately, but there's no reason for it to spill over to an online discussion. > 2. There is no point in *arguing* about this stuff, so I won't. But > silence does not imply consent. Agreed. Let's end this thread here. > 3. Regarding "adding those features": I doubt you'll find anyone on the > planet less interested in adding new features to the Python *language* than > I am. Nor am I interested in adding a new module to the library, unless > someone thinks of something really neat. I was just interested in how to > program. (Misunderstanding my motives is still no excuse for rudeness.) Once again, I apologize. > Blecch, > Greg -- Ignacio Vazquez-Abrams From joonas at olen.to Thu Sep 6 12:22:40 2001 From: joonas at olen.to (Joonas Paalasmaa) Date: Thu, 06 Sep 2001 19:22:40 +0300 Subject: Writing Excel files on Linux Message-ID: <3B97A2D0.49ECEDAC@olen.to> Is there any way to create xls or some other files, that Excel can read exclusing CSV-files. -- Joonas From pete at shinners.org Wed Sep 5 11:29:36 2001 From: pete at shinners.org (Pete Shinners) Date: Wed, 05 Sep 2001 15:29:36 GMT Subject: appropriate graphics Lib? References: Message-ID: "Bob Roberts" wrote > Let me clarify a bit. I would like to be able to draw these irregular > shapes from images to make them look better than simple polygons. > Which graphics lib would facilitate drawing these images on the screen > and knowing which one was picked? hmm, i don't know if the tkinter canvas supports images like this, you'd really have to check, but i suspect no. you might think about pyopengl or pygame at this point. with pyopengl you can easily do things like change the color, plus you are more likely to get hardware acceleration. as for pygame, it could also handle the task. it supports images with colorkeys or alpha planes, which would handle the nonrectengular shaped images. using Numeric python, you can very easily alter the color of truecolor images. you could also use colormaps, and easily change a couple values in the colormap. if you decide to go with pygame, i'd be glad to help out :] but don't let that rule out pyopengl first, especially the higher level object stuff that mike mentioned in an earlier post. From patio87 at aol.com Sat Sep 22 00:58:39 2001 From: patio87 at aol.com (Patio87) Date: 22 Sep 2001 04:58:39 GMT Subject: Declaring function definition parameters Message-ID: <20010922005839.05732.00000127@mb-mf.aol.com> I know how to use the function definition command but, I dont know how to use the parameters. If someone could explain to a learner how to use parameter it would be apreciated. Email me at patio87 at aol.com, thanks From jason at tishler.net Wed Sep 12 11:28:37 2001 From: jason at tishler.net (Jason Tishler) Date: Wed, 12 Sep 2001 11:28:37 -0400 Subject: cygwin+python+XML? In-Reply-To: <9nnfk402ddc@enews1.newsguy.com> Message-ID: <20010912112837.G1312@dothill.com> Alex, On Wed, Sep 12, 2001 at 01:06:43PM +0200, Alex Martelli wrote: > Has anybody managed to build expat (1.95.2 is the latest > release I can see on Sourceforge -- the zip I saw on the > expat's site itself seems to be a Win/VC++ only install?) Yes, but see below... > [snip] > > but I was hoping to avoid having to patch the expat sources. AFAICT, the attached tiny patch is necessary. With this patch, expat built cleanly for me. However, since a regression test is not supplied, I don't know whether or not Cygwin expat works properly. Please apply the attached patch to your source and build. If expat functions as expected, then I encourage you to submit it to expat CVS for consideration. Sorry, but I don't use XML (right now) so I don't have the motivation to pursue this further. > I do have a full working Python 2.1.1 for Win32/VC++6 on > the same disk where I'm trying to set up the Cygwin version, > in case any piece can be copied and reused (...but I sort > of doubt it...). I just wanted to set up the cygwin > version too because sometimes I get help requests about > it, and it would be nice to have a complete working version > of Python -- complete with XML processing, Tkinter and > all -- on the cygwin side to answer such requests! See the follow for a way to build Cygwin Tkinter: http://www.vso.cape.com/~nhv/files/python/tinker.html Jason -------------- next part -------------- --- expat.h.in.orig Wed Sep 12 11:13:32 2001 +++ expat.h.in Wed Sep 12 11:13:49 2001 @@ -9,7 +9,7 @@ See the file COPYING for copying permiss #include #ifndef XMLPARSEAPI -# if defined(__declspec) && !defined(__BEOS__) +# if defined(__declspec) && !defined(__BEOS__) && !defined(__CYGWIN__) # define XMLPARSEAPI(type) __declspec(dllimport) type __cdecl # else # define XMLPARSEAPI(type) type From wzdd at lardcave.net Wed Sep 19 09:43:22 2001 From: wzdd at lardcave.net (Nicholas FitzRoy-Dale) Date: Wed, 19 Sep 2001 23:43:22 +1000 (EST) Subject: regular expressions with other string classes In-Reply-To: <9o9r95$fpi$1@slb0.atl.mindspring.net> Message-ID: On 19 Sep, Andrew Dalke wrote: > Nicholas FitzRoy-Dale wrote >> mboxMap = mmap.mmap (handle.fileno(), getFileLength (self.sourceFilename), >> mmap.MAP_SHARED, mmap.PROT_READ) > > Well, there's my problem. I've nearly no clue on how to use > the mmap module, so I assumed I could use the defaults. Ah, right. > Just tried out what you did, and it works. > > The following doesn't work: > In this case, the mmap call is missing the MAP_SHARED flag > (which is the default, so should be fine). It's also missing > the PROT_READ flag, so the default of PROT_READ | PROT_WRITE > is used. > > I guess that's the problem, but you can see why the error message > threw me off. Actually, I just did a bit of testing, and it seems that it's the file length param that's causing that error - supplying 0 doesn't work. I initially supplied a very large file length and predictably got sigsegv or something when the re ran off the end of the file :-) so I actually supplied the correct length and it worked. I agree that "expected string or buffer" doesn't come close to indicating "you've got a zero-length mmap, fix!" though. :) -- - Nicholas FitzRoy-Dale http://www.lardcave.net /. signature: "Hit a man on the head with a fish, and he'll have a headache for a day..." From aleax at aleax.it Fri Sep 14 09:45:06 2001 From: aleax at aleax.it (Alex Martelli) Date: Fri, 14 Sep 2001 15:45:06 +0200 Subject: finding pathname from within a module? References: <3BA0E766.F7ABCAD9@integretechpub.com> Message-ID: <9nt1l702oe9@enews2.newsguy.com> "Alex Rice" wrote in message news:3BA0E766.F7ABCAD9 at integretechpub.com... > I know there must be a more pythonic way than this. My module needs to > be able to read a datafile in the same directory the module is defined. > What I came up with for creating the filename is this: > > pathEls = string.split(__file__, os.sep)[:-1] > pathEls.append('my.data') > fileName = string.join(pathEls, os.sep) > > Is there a way to do something like .__path__? os.path.dirname(os.path.abspath(__file__)) should be just that. Remember to use os.path.join to put that directory path together with a file's basename, *NOT* string.join with os.sep, though!!! Alex From skip at pobox.com Thu Sep 20 22:16:08 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 20 Sep 2001 21:16:08 -0500 Subject: bsddb3 vs zodb In-Reply-To: <3BAAA147.550FD359@engcorp.com> References: <3BA9A72A.1D5A6067@yahoo.com> <9ocbso$m72$1@slb7.atl.mindspring.net> <3BA9F383.9ED5C436@yahoo.com> <3BAAA147.550FD359@engcorp.com> Message-ID: <15274.41704.709572.603209@beluga.mojam.com> >> But I've other processes (not deamon) that will read and write into >> the same DB. Peter> I'm pretty sure a single ZODB FileStorage can only be used from Peter> within a single Python program, unless you run Zope itself and Peter> perform all database accesses using one of the defined protocols Peter> such as HTTP or FTP, or maybe use SOAP or XML-RPC. Yes, but I think that is what ZEO does for you. It provides a ClientStorage object that communicates over a network. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From boyd at insultant.net Wed Sep 26 06:11:52 2001 From: boyd at insultant.net (Boyd Roberts) Date: Wed, 26 Sep 2001 12:11:52 +0200 Subject: read stdin NON-BLOCKING References: <9on9ic$eik$1@kermit.esat.net> Message-ID: <9osa4q$f23$1@neon.noos.net> "Martin von Loewis" a ?crit dans le message news: j4u1xra1zk.fsf at informatik.hu-berlin.de... > When you say 'blocking', do you mean 'line-buffered'? Are you using a > Unix system? it depends what you're trying to read. > os.system("stty raw") that is a ghastly idea. > I don't know which specific parameters to use, though - if you find out, > could you please post them? it's a termios thing. turn off ICANON and set VMIN and VTIME appropriatly (both to zero iirc). i don't have the stomach to RTFM, but i do have this example (of working code) that deals with character echo: # yes it's part of a bundle [shar] echo tty.c sed 's/.//' >tty.c <<'//GO.SYSIN DD tty.c' -/* - * @(#)tty.c 1.1 - * - * Horrible system dependent tty routines. - */ - -#include "mace.h" -#include - -/* - * Is echo on? - */ -int -ttyechoing(int fd) -{ - struct termios t; - - if (tcgetattr(fd, &t) == SYSERROR) - return SYSERROR; - - return (t.c_lflag & ECHO) != 0; -} - -/* - * Turn echo off/on? - */ -int -ttyecho(int fd, int on) -{ - struct termios t; - - if (tcgetattr(fd, &t) == SYSERROR) - return SYSERROR; - - if (on) - t.c_lflag |= ECHO; - else - t.c_lflag &= ~ECHO; - - return tcsetattr(fd, TCSADRAIN, &t); -} //GO.SYSIN DD tty.c From tim.one at home.com Thu Sep 6 01:12:55 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 6 Sep 2001 01:12:55 -0400 Subject: Performance of list comprehensions vs. map In-Reply-To: <3B966B1C.120D0AF6@home.net> Message-ID: [Chris Barker] > ... > I've proposed similar ideas in the past, and not gotten much response. I > imagine my ideas are full of holes, but no one has taken the time to > point them out to me yet. I have come to the conclusion that the really > sharp minds on this list (and the folks that might be qualified to > actually impliment such a thing) are not really interested in something > like this that is a perfomance only improvement. Am I right? or is the > idea just so stupid that it's not worth commenting on? None of the above, although I'm not sure that's good news . We're really not lacking for ideas, what we need is worker bees. If you have time, here are two achievable (and ancient) ideas for optimization that would benefit all programs: 1. Remove the need for SET_LINENO opcodes. They're not needed for line numbers in tracebacks (tracebacks work fine under -O already, which suppresses SET_LINENO). They're only used for line-by-line tracing (as, e.g., used to implement debugger breakpoints), and that's a very rare need. 2. Move PEP 267 ("Optimized Access to Module Namespaces") closer to reality. More work than #1, but more potential gain too. That these still haven't been done is simply evidence of how little work gets volunteered in these areas. everyone-has-opinions-but-opinions-aren't-executable-ly y'rs - tim From brian at sweetapp.com Mon Sep 17 13:27:00 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Mon, 17 Sep 2001 10:27:00 -0700 Subject: Question: Which Python to choose? In-Reply-To: <3bc15fa1_4@corp-goliath.newsgroups.com> Message-ID: <000501c13f9d$f5b1f360$445d4540@Dell2> > www.python.org and www.activestate.com seem to release their versions with > almost identical version numbers, at very close release dates. Is there a > linkage between the two or are they completely separate products? Which > on is more stable? The core of both Python distributions is identical so neither is more stable than the other. ActivePython just has a nicer installer, includes more modules (like the Win32 extensions on Windows) and has an automatic module installer that can download and install modules from the ActiveState website. But you can't go wrong with either one. Cheers, Brian From ignacio at openservices.net Sat Sep 8 19:28:30 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Sat, 8 Sep 2001 19:28:30 -0400 (EDT) Subject: A question? In-Reply-To: Message-ID: On Sat, 8 Sep 2001, vin wrote: > PyImport_GetModuleDict() which is the same as sys.modules and which > returns a dictionary already contains 'exmpl' > To see that just insert > > PyRun_SimpleString("import sys\n"); > PyRun_SimpleString("print sys.modules\n"); > > after > > module=PyImport_ImportModule("exmpl"); > > Therefore inserting 'exmpl' module doesn't help. Huh. Okay... Ah, I think I have it. Use PyEval_GetGlobals() to get a borrowed reference to the global dictionary and use PyDict_SetItemString() to set it, or you can just use PyModule_GetDict() to get the module's dictionary, then use PyDict_Keys(). -- Ignacio Vazquez-Abrams From eleven11 at hushmail.com Thu Sep 20 01:10:20 2001 From: eleven11 at hushmail.com (eleven11 at hushmail.com) Date: Thu, 20 Sep 2001 22:10:20 +1700 Subject: 11 Message-ID: World Trade Center Disaster Facts The date of the attack 9/11 9+1+1=11 September 11th is the 254th day of the year: 2+5+4=11 After September 11th there are 111 days left to the end of the year. Twin Towers - standing side by side look like the number 11. The first plane to hit the towers was Flight 11. State of New York is the 11th state added to the union. New York City 11 letters The Pentagon 11 letters Afghanistan 11 letters Ranzi Yousef 11 letters (Convicted of orchestrating the 1993 attack on the WTC) September 11 11 letters Flight 11 had 92 on board 9+2=11 Flight 77 had 65 on board 6+5=11 From dietmar at nospam.wohnheim.fh-wedel.de Mon Sep 17 05:09:04 2001 From: dietmar at nospam.wohnheim.fh-wedel.de (Dietmar Lang) Date: 17 Sep 2001 09:09:04 GMT Subject: No spam in books References: Message-ID: >> To mail me, remove "nospam.". > > Somewhat appropriate ... Oh, I guess it should have been "spam." ;) -- To mail me, remove "nospam.". From ekock at movatis.com Tue Sep 18 09:43:28 2001 From: ekock at movatis.com (Eike Kock) Date: Tue, 18 Sep 2001 15:43:28 +0200 Subject: ekock@movatis.com References: <9o7hpg$trp$03$1@news.t-online.com> Message-ID: <9o7io5$o1c$07$8@news.t-online.com> I accendently posted this message here. I tried to cancel it but the my groups server won't let me (441). Sorry, Eike From ibwonrr at yahoo.com Sun Sep 9 11:55:19 2001 From: ibwonrr at yahoo.com (ibwonrr at yahoo.com) Date: Sun, 09 Sep 2001 15:55:19 GMT Subject: wav player using wxPython and pygame - wavplayer.py (0/1) Message-ID: <3b9b8fe1.96155183@news.chnd1.az.home.com> I've written a simple (read: ugly) wav player using pygame and wxPython. It can play, stop, pause, and shows the current and total time of the wav file. It can also convert wav files to mp3 using BladeEnc (freeware for win32). My goal was to write an mp3 player, but I couldn't get mp3s to load using pygame.mixer.music.load() (under windows 2000). If anyone knows how to do this, please let me know. I would also like to add a wxSlider control or ScanForward and ScanBackward buttons to choose the position in the wav file. I haven't done this because I don't know how to set pygame to a certain point in the wav file. I've attached the python file to this post. Any comments or suggestions would be appreciated. Thanks Dave Raffensperger From EmailcdSoftware79 at yahoo.com Sat Sep 29 12:02:35 2001 From: EmailcdSoftware79 at yahoo.com (Internet Marketing Solutions) Date: Sat, 29 Sep 2001 09:02:35 -0700 Subject: 50 Million Fresh Email Addresses $79.95 Free Emailer Message-ID: SELL YOUR PRODUCTS AND MAKE 'BIG MONEY' $$$ WITH OUR EMAIL ADDRESSES ***************************************************** => 50 MILLION HOT - Fresh Email Addresses => Valuable 7 MILLION Remove List Of Known COMPLAINERS => FREE Bulk Email Software => On CD FOR ONLY $79.95 USD!! Normally $249.00 SAVE 68% We have SLASHED Our Prices! Order Today!! This Offer Ends On October 7, 2001! ***************************************************** AND YOU'LL ALSO GET.... => 2 FREE Fully Functional BULK E-MAIL Software Programs => Free Email Verifier software - verify each email addresses for delivery => Free List Manager software - clean and organize your email addresses => Free Web site Encryption software - protect your hosting account => Free Classified Ad Listings - places to post your free classifieds => THE BULK EMAIL SURVIVAL GUIDE - Great for Experts and Beginners (do's and don't of bulk emailing) => Over 100 HOT Selling In Demand Reports - with Full RESALE RIGHTS => GREAT SELLING Software With Full RESALE RIGHTS => A List of NEWSGROUPS that are literally GOLD-MINE! => FREE Business Tools and Tutorials - that will help you in your current business or start one up [valued over $150.00] => FREE Fully Functional AWESOME Marketing Submission Software: classifieds, newsgroups.. => We have a HUGE list, they are too many to list - Over 20 Software and E-Book Titles on this one CD! Also TRUE SOURCES For: - BULK EMAIL ISP DIALUP Accounts - Foreign BULK Email Friendly Web Hosting Accounts - Reliable Blind Relay Servers - Good Sources Of Great Email Addresses THIS IS A LIMITED TIME OFFER! You Will Receive All Of The Above FOR ONLY $79.95 USD! Normally $249.00 SAVE 68% We have SLASHED Our Prices! Order Today!! This Offer Ends On October 7, 2001! ***************************************************** Our CD is a Must for anyone that wants to Make BIG Money On The Internet! This Awesome CD is not only jammed packed with 50 MILLION hot fresh email addresses of INTERNET BUYERS, but also contains 2 fully functional bulk email software programs that you can immediately begin using to sell your products or services. Hey, do you need products to sell? Well, we've got them. We also give you PROVEN, Hot Selling reports and software that you can RESELL and KEEP ALL OF THE MONEY! Not only that, but our CD contains a Valuable REMOVE LIST which will greatly reduce complaints that you would have received. Knowing who NOT to send email to is as important as knowing WHO to send email to!!!! (over 7 million REMOVE EMAILS) These email addresses are FRESH and Super-Cleaned thru our largest database of Remove list with NO DUPLICATIONS! The files are in a .txt [text] format, and grouped into bundles of approximately 100,000 email addresses in each file, and zipped up for space and ease of use. If you don't already know, let me tell you, Bulk Email Marketing is the most cost effective form of advertising and that's why you receive them every day. 1) Let's say you... Sell a $24.95 PRODUCT or SERVICE. 2) Let's say you... Broadcast Email FREE to 500,000 PEOPLE DAILY. 3) Let's say you... Receive JUST 1 ORDER for EVERY 2,500 EMAILS. CALCULATION OF YOUR EARNINGS BASED ON THE ABOVE STATISTICS: [Day 1]: $4,990 [Week 1]: $34,930 [Month 1]: $139,720 All for a simple investment of $79.95 + $5.00 for US Shipping. All for a simple investment of $79.95 + $35.00 for international. You've seen other people charge $250 for only 10 million names. That means you would pay $1250.00 for 50 Million names. YOU ONLY PAY $79.95 + You'll Receive All Of The Other Great Bonuses Too! REMEMBER: We Have SLASHED Our Prices For A Limited Time Only Normally $249.00 SAVE 68% You Will Receive All Of The Above FOR ONLY $79.95 USD! This Offer Ends On October 7, 2001! ***************************************************** Easy Ordering Instructions ========================== ----------------------Cut & Paste---------------------- ---------------------EZ Order Form--------------------- [TO ORDER BY POSTAL MAIL]: To order our 'Big Money' CD with a Cashiers Check, Credit Card, US Money Order, or US Personal Check, by postal mail, please print out the order form at the bottom of this email and complete all necessary blanks. Then, send it along with payment of U.S. $79.95 postmarked by October 7th or $249.00 after October 7th to: Internet Marketing Solutions 6080 S. Hulen St. Dept. 360-288 Fort Worth, TX 76132 USA Once your order is received we will IMMEDIATELY RUSH out your 'Big Money' CD to you! --------------------------------- [TO ORDER BY FAX]: To order our 'Big Money' CD by fax with a Credit Card, please print out the order form at the bottom of this email and complete all necessary blanks. Then, fax the completed order form to: => FAX TO: 1-214-853-5305 **** Please Print **** ===================================================== Company Name: ______________________________________ Your Name: _________________________________________ NON PO BOX SHIPPING ADDRESS: __________________________________________________ City: ________________________ State/Province: _______ Zip/Postal Code: _______________ Country: ________ Phone Number: ___________________ Fax Number: _____________ Email Address: ________________________________________________ ** email address required to send your order confirmation ** ******************************************************************* ** To Purchase by Credit Card, Please Complete the Following: Visa [ ] Mastercard [ ] AmEx [ ] Discover [ ] Name on Credit Card: _____________________________________________ CC Number: _________________________________ Exp. Date: _____ 3 Digit Code After Card # on Back of Card: ______ (Master Card and Visa Only) Issuing Bank Phone Number: _________________________ (From Back of Card) Amount to Charge Credit Card (Including Shipping): ______________ BILLING ADDRESS: _________________________________________________ City: ________________________ State/Province: ________ Zip/Postal Code: _______________ Country: _______ Signature: _______________________________________________________ I understand that I am purchasing the e-mail address on CD, and authorize the above charge to my credit card, the addresses are not rented, but are mine to use for my own mailing, over-and-over. Free bonuses are included, but cannot be considered part of the financial transaction. I understand that it is my responsibility to comply with any laws applicable to my local area. As with all software, once opened the CD may not be returned, however, if found defective it will be replaced with like product at no charge. => FAX TO: 1-214-853-5305 ****************************************************** Normally $249.00 SAVE 68% You Will Receive All Of The Above FOR ONLY $79.95 US Dollar Shipping costs: (within the US) - $5.00 International Shipping costs: (typically 14 - 21 business days) - $35.00 ****************************************************** -=-=-=-=--=-=-=-=-=-=-=Remove Instructions=-=-=-=-=-=-=-=-=-=-=-= This message is sent in compliance with the new email bill section 301. Per Section 301, Paragraph (a)(2)(C) of S. 1618 and is not intended for residents in the State of WA, NV, CA & VA. If you have received this mailing in error, or do not wish to receive any further mailings pertaining to this topic, reply to this email with "remove" in the subject. We respect all removal requests. From ignacio at openservices.net Mon Sep 3 15:38:27 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Mon, 3 Sep 2001 15:38:27 -0400 (EDT) Subject: Is 0 > None?? (fwd) (fwd) In-Reply-To: Message-ID: On Mon, 3 Sep 2001, Lulu of the Lotus-Eaters wrote: > What can I do to get 'lst' to sort properly? If the answer is to use a Modify your site.py file and replace the current value of encoding with something more appropriate (e.g., "latin-1"). -- Ignacio Vazquez-Abrams From michael at rcp.co.uk Tue Sep 11 03:18:49 2001 From: michael at rcp.co.uk (Michael Abbott) Date: Tue, 11 Sep 2001 07:18:49 +0000 (UTC) Subject: PEP proposal for round(x,n) enhancement References: Message-ID: Ignacio Vazquez-Abrams wrote in news:mailman.1000159037.21288.python-list at python.org: > On Mon, 10 Sep 2001, Christopher Smith wrote: > >> I would like to see an additional syntax added to the round function. > > How about a new function instead: sigfig(x, n). That way we don't end up > overloading round() too much. Much better idea! From tyler at tylereaves.com Sat Sep 1 01:28:06 2001 From: tyler at tylereaves.com (Tyler Eaves) Date: Sat, 01 Sep 2001 05:28:06 GMT Subject: newbie.string.listless References: <9mpn11$3h2pq$1@ID-11957.news.dfncis.de> Message-ID: Emile van Sebille wrote: >>>> l = ['this','is','a','test,'] >>>> nl = [x.capitalize() for x in l] >>>> nl > ['This', 'Is', 'A', 'Test,'] > > HTH, > > -- > > Emile van Sebille > emile at fenx.co You scare me :) From =?iso-8859-5?Q?=DF=D5=DD=D3=E3=D8=DD=D8=E1=E2=D0?= at =?iso-8859-5?Q?=DC=D0=D8=DB?=.=?iso-8859-5?Q?=DD=D5=E2?=.=?iso-8859-5?Q?=DC=DA?= Mon Sep 10 14:55:41 2001 From: =?iso-8859-5?Q?=DF=D5=DD=D3=E3=D8=DD=D8=E1=E2=D0?= at =?iso-8859-5?Q?=DC=D0=D8=DB?=.=?iso-8859-5?Q?=DD=D5=E2?=.=?iso-8859-5?Q?=DC=DA?= (=?iso-8859-5?Q?=B4=D0=DC=F8=D0=DD_=B3=2E?=) Date: 10 Sep 2001 19:55:41 +0100 Subject: SMS sending from Python Message-ID: <3b9cfe9d@news.mt.net.mk> Hello everybody, I was wondering, if there is python module for sending SMS messages. Perhaps a wrapper for gsmlib? If there is not such a thing, how hard it would be to create the wrapper around gsmlib (gsmlib is a C++ library). -- ?????? Anything you code can and will be used against you From akuchlin at mems-exchange.org Tue Sep 25 10:30:45 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 25 Sep 2001 10:30:45 -0400 Subject: Near Final PEP 247 - API for Cryptographic Hash Functions References: Message-ID: <3dofnztka2.fsf@ute.cnri.reston.va.us> "Tim Peters" writes: > It's unclear whether all modules conforming to this spec must support both > flavors of "new". The syntax of the second flavor of new() is also unclear; > perhaps > new(key[, string]) > was intended? I expect I'd like it better if the string argument always > came first, and that hash methods requiring a key require a keyword "key=" > argument. That seemed backwards to me. With a keyed hash, the key is required and a string is optional, so the key should therefore come first. It's irritating that this can cause potential confusion if you switched from an unkeyed to a keyed hash -- an initial string can be interpreted as the key -- but it would be more irritating to have the first parameter not be the only required one. A recent suggestion from Rich Salz is to be even more minimal and simply drop the string argument to the constructor; that's not such a bad idea, since it ensures TOOWTDI. (Obviously I wouldn't rip out the initial string argument for the MD5 and SHA modules included with Python.) --amk From gustav at morpheus.demon.co.uk Tue Sep 25 17:25:33 2001 From: gustav at morpheus.demon.co.uk (Paul Moore) Date: Tue, 25 Sep 2001 22:25:33 +0100 Subject: Simple process IO capture (Was: "shell-commands" and python!) - process.py (0/1) References: <4u4vqts8urqfa5n6t2ih3n38il5fm5ats3@4ax.com> Message-ID: <8co1rtgavpbottq51qvjbq3riqdin0rqjo@4ax.com> On Mon, 24 Sep 2001 13:42:22 -0700, Neil Schemenauer wrote: >Here's my humble attempt at a popen replacement. Note that it doesn't >use the shell (a feature IMHO) and it only works on Unix systems. >Suggestions for the module name are welcome. I would like to get >something like this in the standard library. I like the idea of having some form of "simplified piping" module in the standard library. But I would *much* rather see something that is portable (at least to Unix and Windows - I've no idea if the Mac has the concept of a command line which would make sense here). The low-level building blocks are of necessity non-portable, but the higher-level wrappers really ought to be (in interface, if not implementation). Precisely because the lower levels are non-portable - a portable higher level interface would make writing portable programs that bit easier. A portability requirement makes designing a suitable interface far more difficult, but I think it's worth it. (BTW, I could probably write a Win32 implementation of your interface (modulo the availability of suitable low-level calls - I'd need to depend on either win32all or dynwin). The only issue would be the argv tuples, which are *not* the lowest level Win32 form - precisely the reverse of Unix (in Unix, execv() takes argc/argv, and the shell converts command lines to argv arrays; on Win32, CreateProcess() takes a command line, and the C runtime for an individual program splits the command line into an argv array). I'm relatively happy with the _ChildProcess class as a way of encapsulating the various FDs relevant to the child. Although I miss the shortcuts my module has for passing a string as stdin direct, or getting the contents of stdout direct. Your class' equivalent is more verbose - p = execute(...) p.write(str) p.stdin.close() ret = p.read() p.stdout.close() I might simply add extra "convenience" methods, def input(self, str): self.stdin.write(str) self.stdin.close() return self # to allow chaining, see below def output(self): str = self.stdout.read() self.stdout.close() return str which allows ret = execute(...).input(str).output() Hmm, no that still feels messy. I can't get away from the fact that my version ret = run(..., input=str) feels cleaner. And by the way, your version doesn't offer any way of "merging" stdout and stderr. Not reading both, but merging as in 2>&1. And I'd *still* like to add a way of specifying a pipeline, with all the inter-process plumbing handled automatically. Something like child_obj = execute(("tr a-z A-Z", "sort", "uniq")) (reverting to command-string form rather than argv-tuple, to avoid obscuring the issue with nested tuples...) OK, that's enough unstructured brain-dumping. I'll think about this some more, and post a proposal. [BTW, I assume that avoiding the shell is an important requirement on Unix? It's less of an obvious thing to do on Win32, where a number of key commands like DIR, COPY, DEL, RENAME and MOVE are shell built-ins, and not normally available as separate EXEs] Paul. From Gareth.McCaughan at pobox.com Wed Sep 12 18:42:48 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Wed, 12 Sep 2001 23:42:48 +0100 Subject: Proposed PEP for a Conditional Expression References: <6qvgire4bk.fsf@abnoba.intevation.de> <9nidrm01j7q@enews1.newsguy.com> <9nk4t8$4qq$1@glue.ucr.edu> <9nkmjj01rha@enews3.newsguy.com> <9nnf0d$5qf$2@glue.ucr.edu> <9nnigp02g7a@enews1.newsguy.com> Message-ID: Alex Martelli wrote: > Sure! But the mistake in the PEP is putting forward the "what's > wrong with just satisfying people" rhetorical question as an > argument FOR a proposed feature. It's a grossly invalid argument > and IMHO it should be either removed from the PEP, or clearly > marked as such -- invalid as an argument. It's not an invalid argument, just a weak one. All else being equal, the fact that even one user wants a feature is an argument in its favour. If it's true that many users want conditional expressions, then that's an argument for providing them. It's not close to being a conclusive argument, of course. > The need to keep the language small and simple is an argument > against _every_ feature (new and old: I just love it when > Python is able to shed old features that don't fully pull > their weight, although that's always harder to do than "not > adding new ones", because of backwards compatibility issues). Right. And *that* should probably be in the PEP as an argument against. Much better than taking out the "lots of people want it" argument, provided it's true that lots of people do want it. -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From jjl at pobox.com Mon Sep 10 16:31:03 2001 From: jjl at pobox.com (John J. Lee) Date: Mon, 10 Sep 2001 21:31:03 +0100 Subject: large class hierarchies in python In-Reply-To: References: <9ner16$sbt$1@uni00nw.unity.ncsu.edu> <7934d084.0109091703.6414e22a@posting.google.com> <9nhhn5$g1o$1@uni00nw.unity.ncsu.edu> <9nhj3l$gqi$1@uni00nw.unity.ncsu.edu> Message-ID: On Mon, 10 Sep 2001, Jon wrote: > In article <9nhj3l$gqi$1 at uni00nw.unity.ncsu.edu>, "Justin Dubs" > wrote: [...] > APL is justly regarded as a language we don't need to know about any more > (mainly because modern keyboards don't have enough keys for it :-) )... > but just in case you are interested, take a look here: > > http://www.aplusdev.org/ > > A+ is a language grown out of APL, developed by people from Morgan > Stanley (the investment bank). There is a GPLed interpreter system which > you can download from that site. Ken Iverson, the designer of APL, went on to make J (which has no funny symbols): http://www.acm.org/sigapl/ http://www.jsoftware.com/ Yes, it still looks like line noise (this program, partly written by the Iverson dynasty itself, was a runner-up in the ICFP functional programming contest): http://www.ai.mit.edu/extra/icfp-contest/j-source.txt > If you are intested in even more esoteric languages, you might want to > look at the Cat's Eye Technologies website: > > http://www.catseye.mb.ca/ > > part of which is a collection of esoteric programming language -- > including two really beautiful ones: Befunge (2D source code), and I think this guy wins *that* contest :-) (the original page appears to be dead atm, this is the Google cache of it) http://www.google.co.uk/search?q=cache:o8sP21nnd-Q:www.flourish.org/zbefunge.html+ZBefunge&hl=en It's Befunge interpreter (and IDE, if you can believe that), written in Inform, which itself compiles into Z-code, the format used by Infocom for their text adventure games way back in prehistoric times. The web page shows "ZBefunge, ironically running a simple text adventure". On the question of more practical languages, there are several logic-programming languages that are being actively developed at the moment, both these look very interesting: http://www.cs.mu.oz.au/research/mercury/ http://www.mozart-oz.org/ John From jord at theinternetone.co.uk Wed Sep 19 15:00:28 2001 From: jord at theinternetone.co.uk (Jordan Elver) Date: Wed, 19 Sep 2001 15:00:28 -0400 Subject: Using MySQLdb Newbie In-Reply-To: <15272.41264.782898.285481@beluga.mojam.com> References: <01091914430909.01260@jordan.utopia.net> <15272.41264.782898.285481@beluga.mojam.com> Message-ID: <0109191500280A.01260@jordan.utopia.net> Hi, I have now installed python-devel and now the install goes further. Now I get the foloowing error. i think this is because it can't find the mysql libraries etc. I have installed mysql in /usr/loca/mysql, so I think the files it's looking for should be in /usr/loca/mysql/includes and /usr/loca/mysql/lib, is that right? Any more ideas? The error message: building '_mysql' extension gcc -O3 -fomit-frame-pointer -pipe -mcpu=pentiumpro -march=i586 -ffast-math -fno-strength-reduce -fPIC -I/usr/loca/mysql/include -I/usr/include/python2.1 -c _mysql.c -o build/temp.linux-i686-2.1/_mysql.o _mysql.c:41:19: mysql.h: No such file or directory _mysql.c:42:26: mysqld_error.h: No such file or directory _mysql.c:43:20: errmsg.h: No such file or directory _mysql.c:59: parse error before `MYSQL' _mysql.c:59: warning: no semicolon at end of struct or union _mysql.c:62: parse error before `}' _mysql.c:62: warning: data definition has no type or storage class _mysql.c:73: parse error before `MYSQL_RES' _mysql.c:73: warning: no semicolon at end of struct or union _mysql.c:77: parse error before `}' _mysql.c:77: warning: data definition has no type or storage class _mysql.c:82: parse error before `*' _mysql.c: In function `_mysql_Exception': _mysql.c:88: `c' undeclared (first use in this function) _mysql.c:88: (Each undeclared identifier is reported only once _mysql.c:88: for each function it appears in.) _mysql.c:99: `CR_MAX_ERROR' undeclared (first use in this function) _mysql.c:107: `CR_COMMANDS_OUT_OF_SYNC' undeclared (first use in this function) _mysql.c:108: `ER_DB_CREATE_EXISTS' undeclared (first use in this function) _mysql.c:109: `ER_SYNTAX_ERROR' undeclared (first use in this function) _mysql.c:110: `ER_PARSE_ERROR' undeclared (first use in this function) _mysql.c:111: `ER_NO_SUCH_TABLE' undeclared (first use in this function) _mysql.c:112: `ER_WRONG_DB_NAME' undeclared (first use in this function) _mysql.c:113: `ER_WRONG_TABLE_NAME' undeclared (first use in this function) _mysql.c:114: `ER_FIELD_SPECIFIED_TWICE' undeclared (first use in this function) _mysql.c:115: `ER_INVALID_GROUP_FUNC_USE' undeclared (first use in this function) _mysql.c:116: `ER_UNSUPPORTED_EXTENSION' undeclared (first use in this function) _mysql.c:117: `ER_TABLE_MUST_HAVE_COLUMNS' undeclared (first use in this function) _mysql.c:123: `ER_DUP_ENTRY' undeclared (first use in this function) _mysql.c:121: warning: unreachable code at beginning of switch statement _mysql.c:145: warning: passing arg 1 of `PyString_FromString' makes pointer from integer without a cast _mysql.c: At top level: _mysql.c:152: parse error before `*' _mysql.c:154: parse error before `*' _mysql.c: In function `_mysql_ResultObject_New': _mysql.c:160: `MYSQL_FIELD' undeclared (first use in this function) _mysql.c:160: `fields' undeclared (first use in this function) _mysql.c:161: `r' undeclared (first use in this function) _mysql.c:163: parse error before `)' _mysql.c:165: `conn' undeclared (first use in this function) _mysql.c:167: `result' undeclared (first use in this function) _mysql.c:176: `conv' undeclared (first use in this function) _mysql.c: In function `_mysql_connect': _mysql.c:220: `MYSQL' undeclared (first use in this function) _mysql.c:220: `conn' undeclared (first use in this function) _mysql.c:221: parse error before `*' _mysql.c:237: `c' undeclared (first use in this function) _mysql.c:237: invalid lvalue in assignment _mysql.c:239: parse error before `)' _mysql.c:243: `kwlist' undeclared (first use in this function) _mysql.c:244: `host' undeclared (first use in this function) _mysql.c:244: `user' undeclared (first use in this function) _mysql.c:244: `passwd' undeclared (first use in this function) _mysql.c:244: `db' undeclared (first use in this function) _mysql.c:245: `port' undeclared (first use in this function) _mysql.c:245: `unix_socket' undeclared (first use in this function) _mysql.c:245: `conv' undeclared (first use in this function) _mysql.c:246: `connect_timeout' undeclared (first use in this function) _mysql.c:247: `compress' undeclared (first use in this function) _mysql.c:247: `named_pipe' undeclared (first use in this function) _mysql.c:248: `init_command' undeclared (first use in this function) _mysql.c:248: `read_default_file' undeclared (first use in this function) _mysql.c:249: `read_default_group' undeclared (first use in this function) _mysql.c:269: `MYSQL_OPT_CONNECT_TIMEOUT' undeclared (first use in this function) _mysql.c:273: `MYSQL_OPT_COMPRESS' undeclared (first use in this function) _mysql.c:274: `client_flag' undeclared (first use in this function) _mysql.c:274: `CLIENT_COMPRESS' undeclared (first use in this function) _mysql.c:277: `MYSQL_OPT_NAMED_PIPE' undeclared (first use in this function) _mysql.c:279: `MYSQL_INIT_COMMAND' undeclared (first use in this function) _mysql.c:281: `MYSQL_READ_DEFAULT_FILE' undeclared (first use in this function) _mysql.c:283: `MYSQL_READ_DEFAULT_GROUP' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:299: parse error before `*' _mysql.c: In function `_mysql_ConnectionObject_close': _mysql.c:302: `args' undeclared (first use in this function) _mysql.c:303: `self' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:317: parse error before `*' _mysql.c: In function `_mysql_ConnectionObject_affected_rows': _mysql.c:320: `args' undeclared (first use in this function) _mysql.c:321: `self' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:345: parse error before `*' _mysql.c: In function `_mysql_ConnectionObject_dump_debug_info': _mysql.c:349: `args' undeclared (first use in this function) _mysql.c:350: `self' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:361: parse error before `*' _mysql.c: In function `_mysql_ConnectionObject_errno': _mysql.c:364: `args' undeclared (first use in this function) _mysql.c:365: `self' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:371: parse error before `*' _mysql.c: In function `_mysql_ConnectionObject_error': _mysql.c:374: `args' undeclared (first use in this function) _mysql.c:375: `self' undeclared (first use in this function) _mysql.c:376: warning: passing arg 1 of `PyString_FromString' makes pointer from integer without a cast _mysql.c: At top level: _mysql.c:390: parse error before `*' _mysql.c: In function `_mysql_escape_string': _mysql.c:396: `args' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:429: parse error before `*' _mysql.c: In function `_mysql_string_literal': _mysql.c:435: `args' undeclared (first use in this function) _mysql.c: In function `_mysql_escape': _mysql.c:512: parse error before `)' _mysql.c: At top level: _mysql.c:583: parse error before `*' _mysql.c: In function `_mysql_ResultObject_describe': _mysql.c:587: `MYSQL_FIELD' undeclared (first use in this function) _mysql.c:587: `fields' undeclared (first use in this function) _mysql.c:588: parse error before `unsigned' _mysql.c:589: `args' undeclared (first use in this function) _mysql.c:590: parse error before `)' _mysql.c:590: parse error before `)' _mysql.c:591: `n' undeclared (first use in this function) _mysql.c:591: `self' undeclared (first use in this function) _mysql.c:594: `i' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:615: parse error before `*' _mysql.c: In function `_mysql_ResultObject_field_flags': _mysql.c:619: `MYSQL_FIELD' undeclared (first use in this function) _mysql.c:619: `fields' undeclared (first use in this function) _mysql.c:620: parse error before `unsigned' _mysql.c:621: `args' undeclared (first use in this function) _mysql.c:622: parse error before `)' _mysql.c:622: parse error before `)' _mysql.c:623: `n' undeclared (first use in this function) _mysql.c:623: `self' undeclared (first use in this function) _mysql.c:626: `i' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:664: parse error before `*' _mysql.c: In function `_mysql_row_to_tuple': _mysql.c:671: `self' undeclared (first use in this function) _mysql.c:673: warning: assignment makes pointer from integer without a cast _mysql.c:677: `row' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:689: parse error before `*' _mysql.c: In function `_mysql_row_to_dict': _mysql.c:695: `MYSQL_FIELD' undeclared (first use in this function) _mysql.c:695: `fields' undeclared (first use in this function) _mysql.c:697: `self' undeclared (first use in this function) _mysql.c:699: warning: assignment makes pointer from integer without a cast _mysql.c:704: `row' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:728: parse error before `*' _mysql.c: In function `_mysql_row_to_dict_old': _mysql.c:734: `MYSQL_FIELD' undeclared (first use in this function) _mysql.c:734: `fields' undeclared (first use in this function) _mysql.c:736: `self' undeclared (first use in this function) _mysql.c:738: warning: assignment makes pointer from integer without a cast _mysql.c:743: `row' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:765: parse error before `*' _mysql.c:769: parse error before `*' _mysql.c: In function `_mysql__fetch_row': _mysql.c:776: `MYSQL_ROW' undeclared (first use in this function) _mysql.c:776: parse error before `row' _mysql.c:778: `skiprows' undeclared (first use in this function) _mysql.c:778: `maxrows' undeclared (first use in this function) _mysql.c:780: `self' undeclared (first use in this function) _mysql.c:781: `row' undeclared (first use in this function) _mysql.c:787: parse error before `)' _mysql.c:788: parse error before `)' _mysql.c:793: `r' undeclared (first use in this function) _mysql.c:799: warning: assignment makes pointer from integer without a cast _mysql.c: At top level: _mysql.c:810: parse error before `*' _mysql.c: In function `_mysql_ResultObject_fetch_row': _mysql.c:814: parse error before `*' _mysql.c:826: `args' undeclared (first use in this function) _mysql.c:826: `kwargs' undeclared (first use in this function) _mysql.c:829: parse error before `)' _mysql.c:829: parse error before `)' _mysql.c:837: `self' undeclared (first use in this function) _mysql.c: In function `_mysql_get_client_info': _mysql.c:913: warning: passing arg 1 of `PyString_FromString' makes pointer from integer without a cast _mysql.c: At top level: _mysql.c:918: parse error before `*' _mysql.c: In function `_mysql_ConnectionObject_get_host_info': _mysql.c:921: `args' undeclared (first use in this function) _mysql.c:922: `self' undeclared (first use in this function) _mysql.c:923: warning: passing arg 1 of `PyString_FromString' makes pointer from integer without a cast _mysql.c: At top level: _mysql.c:928: parse error before `*' _mysql.c: In function `_mysql_ConnectionObject_get_proto_info': _mysql.c:931: `args' undeclared (first use in this function) _mysql.c:932: `self' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:938: parse error before `*' _mysql.c: In function `_mysql_ConnectionObject_get_server_info': _mysql.c:941: `args' undeclared (first use in this function) _mysql.c:942: `self' undeclared (first use in this function) _mysql.c:943: warning: passing arg 1 of `PyString_FromString' makes pointer from integer without a cast _mysql.c: At top level: _mysql.c:948: parse error before `*' _mysql.c: In function `_mysql_ConnectionObject_info': _mysql.c:952: `args' undeclared (first use in this function) _mysql.c:953: `self' undeclared (first use in this function) _mysql.c:954: warning: assignment makes pointer from integer without a cast _mysql.c: At top level: _mysql.c:962: parse error before `*' _mysql.c: In function `_mysql_ConnectionObject_insert_id': _mysql.c:965: `my_ulonglong' undeclared (first use in this function) _mysql.c:965: parse error before `r' _mysql.c:966: `args' undeclared (first use in this function) _mysql.c:967: `self' undeclared (first use in this function) _mysql.c:969: `r' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:976: parse error before `*' _mysql.c: In function `_mysql_ConnectionObject_kill': _mysql.c:981: `args' undeclared (first use in this function) _mysql.c:982: `self' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:993: parse error before `*' _mysql.c: In function `_mysql_ConnectionObject_field_count': _mysql.c:996: `args' undeclared (first use in this function) _mysql.c:997: `self' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:1007: parse error before `*' _mysql.c: In function `_mysql_ResultObject_num_fields': _mysql.c:1010: `args' undeclared (first use in this function) _mysql.c:1011: parse error before `)' _mysql.c:1011: parse error before `)' _mysql.c:1012: `self' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:1017: parse error before `*' _mysql.c: In function `_mysql_ResultObject_num_rows': _mysql.c:1020: `args' undeclared (first use in this function) _mysql.c:1021: parse error before `)' _mysql.c:1021: parse error before `)' _mysql.c:1022: `self' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:1027: parse error before `*' _mysql.c: In function `_mysql_ConnectionObject_ping': _mysql.c:1031: `args' undeclared (first use in this function) _mysql.c:1032: `self' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:1043: parse error before `*' _mysql.c: In function `_mysql_ConnectionObject_query': _mysql.c:1048: `args' undeclared (first use in this function) _mysql.c:1049: `self' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:1060: parse error before `*' _mysql.c: In function `_mysql_ConnectionObject_select_db': _mysql.c:1065: `args' undeclared (first use in this function) _mysql.c:1066: `self' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:1077: parse error before `*' _mysql.c: In function `_mysql_ConnectionObject_shutdown': _mysql.c:1081: `args' undeclared (first use in this function) _mysql.c:1082: `self' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:1093: parse error before `*' _mysql.c: In function `_mysql_ConnectionObject_stat': _mysql.c:1097: `args' undeclared (first use in this function) _mysql.c:1098: `self' undeclared (first use in this function) _mysql.c:1100: warning: assignment makes pointer from integer without a cast _mysql.c: At top level: _mysql.c:1108: parse error before `*' _mysql.c: In function `_mysql_ConnectionObject_store_result': _mysql.c:1111: `MYSQL_RES' undeclared (first use in this function) _mysql.c:1111: `result' undeclared (first use in this function) _mysql.c:1113: `args' undeclared (first use in this function) _mysql.c:1114: `self' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:1128: parse error before `*' _mysql.c: In function `_mysql_ConnectionObject_thread_id': _mysql.c:1132: `args' undeclared (first use in this function) _mysql.c:1133: `self' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:1142: parse error before `*' _mysql.c: In function `_mysql_ConnectionObject_use_result': _mysql.c:1145: `MYSQL_RES' undeclared (first use in this function) _mysql.c:1145: `result' undeclared (first use in this function) _mysql.c:1147: `args' undeclared (first use in this function) _mysql.c:1148: `self' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:1162: parse error before `*' _mysql.c: In function `_mysql_ConnectionObject_dealloc': _mysql.c:1166: `self' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:1175: parse error before `*' _mysql.c: In function `_mysql_ConnectionObject_repr': _mysql.c:1178: `self' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:1192: parse error before `*' _mysql.c: In function `_mysql_ResultObject_data_seek': _mysql.c:1196: `args' undeclared (first use in this function) _mysql.c:1197: parse error before `)' _mysql.c:1197: parse error before `)' _mysql.c:1198: `self' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:1207: parse error before `*' _mysql.c: In function `_mysql_ResultObject_row_seek': _mysql.c:1211: `MYSQL_ROW_OFFSET' undeclared (first use in this function) _mysql.c:1211: parse error before `r' _mysql.c:1212: `args' undeclared (first use in this function) _mysql.c:1213: parse error before `)' _mysql.c:1213: parse error before `)' _mysql.c:1214: `r' undeclared (first use in this function) _mysql.c:1214: `self' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:1224: parse error before `*' _mysql.c: In function `_mysql_ResultObject_row_tell': _mysql.c:1227: `MYSQL_ROW_OFFSET' undeclared (first use in this function) _mysql.c:1227: parse error before `r' _mysql.c:1228: `args' undeclared (first use in this function) _mysql.c:1229: parse error before `)' _mysql.c:1229: parse error before `)' _mysql.c:1230: `r' undeclared (first use in this function) _mysql.c:1230: `self' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:1236: parse error before `*' _mysql.c: In function `_mysql_ResultObject_dealloc': _mysql.c:1238: `self' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:1246: parse error before `*' _mysql.c: In function `_mysql_ResultObject_repr': _mysql.c:1250: `self' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:1290: parse error before `)' _mysql.c:1290: initializer element is not constant _mysql.c:1290: (near initialization for `_mysql_ConnectionObject_memberlist[2].offset') _mysql.c:1310: parse error before `)' _mysql.c:1310: initializer element is not constant _mysql.c:1310: (near initialization for `_mysql_ResultObject_memberlist[0].offset') _mysql.c:1316: parse error before `*' _mysql.c: In function `_mysql_ConnectionObject_getattr': _mysql.c:1321: `self' undeclared (first use in this function) _mysql.c:1321: `name' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:1338: parse error before `*' _mysql.c: In function `_mysql_ResultObject_getattr': _mysql.c:1343: `self' undeclared (first use in this function) _mysql.c:1343: `name' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:1352: parse error before `*' _mysql.c: In function `_mysql_ConnectionObject_setattr': _mysql.c:1356: `v' undeclared (first use in this function) _mysql.c:1361: `c' undeclared (first use in this function) _mysql.c:1361: `name' undeclared (first use in this function) _mysql.c: At top level: _mysql.c:1366: parse error before `*' _mysql.c: In function `_mysql_ResultObject_setattr': _mysql.c:1370: `v' undeclared (first use in this function) _mysql.c:1375: `c' undeclared (first use in this function) _mysql.c:1375: `name' undeclared (first use in this function) error: command 'gcc' failed with exit status 1 On Wednesday 19 September 2001 09:44, you wrote: > Jordan> distutils.errors.DistutilsPlatformError: invalid Python > installation: unable Jordan> to open /usr/lib/python2.1/config/Makefile (No > such file or directory) > > Jordan> Whats going on now? > > You're missing a python-devel RPM. Wherever you got the Python 2.1 RPM > should also have a python-devel RPM. -- Jordan Elver Web Developer The InternetOne UK Ltd From ben at xyz.net Tue Sep 18 13:26:01 2001 From: ben at xyz.net (Ben) Date: Tue, 18 Sep 2001 19:26:01 +0200 Subject: Realtime capabilities? Message-ID: <9o8033$mhf$04$1@news.t-online.com> Hello world, some of you have probably heard (or even used) Erlang (www.erlang.org) --- a functional programming language which is executed by a virtual machine. One interesting property of this VM is guaranteed soft realtime execution of the Erlang processes. My question is whether it is possible to add (soft) realtime capabilities to the Python VM with reasonable effort? I'm just curious and not being an expert of any of the existing Python implementations I thought some of you might have a better understanding of this issue and can comment on this? Thanks, Ben. From weeks at vitus.scs.agilent.com Fri Sep 21 12:38:17 2001 From: weeks at vitus.scs.agilent.com (Greg Weeks) Date: Fri, 21 Sep 2001 16:38:17 +0000 (UTC) Subject: "shell-commands" and python! References: <1001087411.956907@cswreg.cos.agilent.com> <3BAB6306.D9CF4F1A@alcyone.com> Message-ID: <1001090296.877856@cswreg.cos.agilent.com> Erik Max Francis (max at alcyone.com) wrote: : Python is not a shell script, so why should it behave exactly the same : way. With very few exceptions, Python handles basic programming tasks as or more conveniently than other languages. With so few exceptions, why not shoot for zero exceptions? Besides, as a practical matter, I'd rather not have to evaluate every programming task as a choice between Ksh and Python. Finally, regarding program invocation with redirection and such, Perl does a slightly better job than Python, and that's never nice. Greg From loewis at informatik.hu-berlin.de Fri Sep 14 08:16:14 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 14 Sep 2001 14:16:14 +0200 Subject: 2.2a3 compile fails with __retval error References: Message-ID: Bruce Sass writes: > Anyone know how to fix it? With gcc, you should not compile strdup. For some reason, configure has failed to determine that your C library has a strdup implmentation. Could it be that you had an old config.cache before invoking configure? Regards, Martin From gerson.kurz at t-online.de Sun Sep 2 01:33:38 2001 From: gerson.kurz at t-online.de (Gerson Kurz) Date: Sun, 02 Sep 2001 05:33:38 GMT Subject: Bug or feature? References: Message-ID: <3b91c3bb.1689421@news.t-online.de> On Sat, 1 Sep 2001 15:25:31 -0400, "Tim Peters" wrote: >Neither, really -- it's just the way it works. A def in Python is an >executable stmt, and, when executed, binds the name following the "def" to >the appropriate code object, in the appropriate namespace. Hey, the more I dive into python the more cool things it has. This makes writing def a(x): ... def b(x): ... b,a = a,b possible :) And even this works as expected: funcs = [] def a(): print "code 1" funcs.append(a) def a(): print "code 2" funcs.append(a) for func in funcs: func() From ignacio at openservices.net Tue Sep 4 12:33:43 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Tue, 4 Sep 2001 12:33:43 -0400 (EDT) Subject: Question regarding commenting code In-Reply-To: <682EFA0F37A1D511868700B0D0D1AB7A31BBDD@ISTECH4> Message-ID: On Tue, 4 Sep 2001, Andrew Gould wrote: > When adding comments to scripts, can I insert lines of comments inside a > loop block? For example: > > for n in a_list: > # separate values using spaces as delimiters > a_line = string.split(n) > # get the first value > a_value = a_line[0] > # print the first value > print a_value > > > Thanks, > > Andrew Have you tried doing it yet? ;) -- Ignacio Vazquez-Abrams From samschul at pacbell.net Mon Sep 3 13:39:30 2001 From: samschul at pacbell.net (Samuel Schulenburg) Date: 3 Sep 2001 10:39:30 -0700 Subject: Use of GMPY References: <9n03in$c6o$1@pegasus.tiscalinet.it> Message-ID: "Patrick" wrote in message news:<9n03in$c6o$1 at pegasus.tiscalinet.it>... > Hi, > > I'm trying to use GMPY module but it does not seem to work !? When I import > the GMPY module into Python IDE, I get an error message telling me that one > DLL is missing, but does not give the name of this missing DLL. > > Can someone help ? > > * I use a 2.1 AtiveState version of python 'as it comes from thes > ActiveState' site, > > * I have downloaded the 0.9 version of GMPY and copied the GMPY.PYD and > PYSYMBOLICEXT.PYD files in my \Python21\lib directory... > > Help please, > Patrick I believe that the *.pyd files should go into the DLL directory Sam Schulenburg From teg at redhat.com Fri Sep 21 13:55:41 2001 From: teg at redhat.com (Trond Eivind =?iso-8859-1?q?Glomsr=F8d?=) Date: 21 Sep 2001 13:55:41 -0400 Subject: python version References: Message-ID: bobnotbob at byu.edu (Bob Roberts) writes: > How can a python program find out what version of python it is running? python -c 'import sys;print(sys.version[0:3])' does it from the commandline. -- Trond Eivind Glomsr?d Red Hat, Inc. From ignacio at openservices.net Thu Sep 20 01:05:23 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Thu, 20 Sep 2001 01:05:23 -0400 (EDT) Subject: C lexer module Message-ID: I've created a C lexer module. It's at: http://ignacio.openservices.net/devel/Clex.py I would like to hear feedback and bug reports about it. Thank you. -- Ignacio Vazquez-Abrams From christopher.abraham at verizon.net Tue Sep 4 16:24:09 2001 From: christopher.abraham at verizon.net (Chris Abraham) Date: Tue, 04 Sep 2001 16:24:09 -0400 Subject: ZPugDC is DC PIGgies for September! Message-ID: ZPugDC becomes DC PIGgie for September ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The Next DC Zope-Python User Group Meeting, which should be Wednesday, 26 September from 7-9pm. Joel Burton will be out of town on Vacation (good for him) so we will not have the opportunity to see him. But, I will be there! The meeting will be at the Support Center of Washington in Dupont, on the red line. We are going to make the next ZPugDC meeting into a Pug/PIG for this upcoming meeting because we have the opportunity of having Guido present his latest and greatest before his new baby comes and we may never see him again :-). So, are we all in favour of hosting Guido van Rossum < http://www.python.org/~guido/> as out two-hour long guest on the 26th of September? This will be some hardcore stuff. Bring your fave Python guru and come and enjoy and take notes, there will be a test! Check out for details! Cheers, Chris Abraham beehive North America -- chris abraham, managing director, beehive north america +1 202 548 0410 wk +1 202 478 0276 fax 1231 pennsylvania avenue, se, washington, dc 20003 usa pgp 951A 33D2 FC43 79DA 2F93 105D 736B 891E 16D9 5970 From Webleads4mlm at aol.com Wed Sep 26 16:13:00 2001 From: Webleads4mlm at aol.com (John ) Date: Wed, 26 Sep 2001 16:13:00 Subject: sorry Message-ID: there I go again, it is really not normal for me to do that From shwang5 at students.uiuc.edu Sun Sep 30 00:24:58 2001 From: shwang5 at students.uiuc.edu (Seung-won Hwang) Date: Sat, 29 Sep 2001 21:24:58 -0700 Subject: [Q] PyGreSQL Message-ID: Hi, I have two questions on PyGreSQL: (1) Could you let me know where the windows version of PyGreSQL is? I failed in finding one from web search. (2) What's the easiest way to load tab-separated text data to the relational database? Any easier way than writing a program that calls "INSERT INTO" for every data value? Thanks! From paul.moore at atosorigin.com Fri Sep 28 09:43:28 2001 From: paul.moore at atosorigin.com (Paul Moore) Date: Fri, 28 Sep 2001 15:43:28 +0200 Subject: How do I distinguish a string from a sequence? Message-ID: Yes, I know, a string is a sequence... I'm thinking of writing a function which can take either a string, or a sequence of strings, as an argument. A simplified example would be treating a single string as a 1-tuple - something like def foo(args): if # args is a string: args = (args,) for arg in args: print arg But I'm not sure how best to distinguish a string from a sequence - after all, a string *is* a sequence. I want to avoid explicit type tests, as that seems prone to errors (for a start, I should trap both strings and Unicode strings, and what about 2.2 subclasses of strings?) But I can't think of a suitable test. The best I can come up with is a type-test along the lines of if isinstance(args, type('')) or isinstance(args, type(u'')): but as I say, that's annoyingly "explicit". [If it matters, my "real" example is a popen-type function, which can take one string argument - a command to execute - or a sequence of strings - a pipe specification, where each element of the sequence would be a stage in the pipeline] Has anyone got any alternative suggestions? Paul. From boogiemorg at aol.com Fri Sep 7 12:12:54 2001 From: boogiemorg at aol.com (David Morgenthaler) Date: 7 Sep 2001 09:12:54 -0700 Subject: Extension load error help Message-ID: I'm writing an extension, and, when I attempt to load my extension module I get the following: >>> from SARCrates.BoomBox.SARGeom import _gridManager Traceback (most recent call last): File "", line 1, in ? SystemError: _PyImport_FixupExtension: module SARCrates.BoomBox.SARGeom._gridManager not loaded >>> Any ideas on what I did to cause this? [PS -- I'm running Py2.1 on WinNT] Thanks in advance, David M. From barry at zope.com Fri Sep 7 13:46:09 2001 From: barry at zope.com (Barry A. Warsaw) Date: Fri, 7 Sep 2001 13:46:09 -0400 Subject: RELEASED: Python 2.2a3 is out! Message-ID: <15257.2017.401346.242592@anthem.wooz.org> We've released Python 2.2a3, the third alpha for Python 2.2, for your excitement, enlightenment, and endless-amusement. Download it from: http://www.python.org/2.2/ Give it a good try, and report what breaks to the bug tracker: http://sourceforge.net/bugs/?group_id=5470 [Note: this is my first solo release as Release Manager. If you find any problems with the downloads, please let me know! -BAW] New features in this release include: - Conversion of long to float now raises OverflowError if the long is too big to represent as a C double. - The 3-argument builtin pow() no longer allows a third non-None argument in some situations. - The builtin dir() now returns more information. - Overflowing operations on plain ints now return a long int rather than raising OverflowError. - A new command line option, -Q, is added to control run-time warnings for the use of classic division. - Many built-in types can now be subclassed. - The dictionary constructor now takes an optional argument, a mapping-like object. - New built-in types `super' and `property' have been added. - The syntax of floating-point and imaginary literals has been liberalized, to allow leading zeroes. - Lots of bug fixes, contributed patches, and other stuff. See the Misc/NEWS file in the distribution, or see the release notes on SourceForge: http://sourceforge.net/project/shownotes.php?release_id=51791 As usual, Andrew Kuchling is writing a gentle introduction to the most important changes (currently excluding type/class unification), titled "What's New in Python 2.2": http://www.amk.ca/python/2.2/ There is an introduction to the type/class unification at: http://www.python.org/2.2/descrintro.html Thanks to everybody who contributed to this release, including all the 2.2 alpha 1 and 2 testers! Enjoy! -Barry From aahz at panix.com Fri Sep 14 20:53:02 2001 From: aahz at panix.com (Aahz Maruch) Date: 14 Sep 2001 17:53:02 -0700 Subject: Can't compile python w/out threads References: <3b9eb15b.28407207@news.club-internet.fr> Message-ID: <9nu8pe$pv7$1@panix2.panix.com> In article <3b9eb15b.28407207 at news.club-internet.fr>, Frederic Faure wrote: > > I'm trying to install the open-source Newsbruiser blogger >application, which requires Apache and Python. >Since no precise information is given, I figured I'd compile python >1.6.1 with mod_python 2.7.5 and apache 1.3.20, with mod_python as a >static module. I haven't even read the rest of your post; you should use Python 2.1.1. Under no circumstances should you use Python 1.6.x. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista We must not let the evil of a few trample the freedoms of the many. From bongartzfrank at yahoo.de Wed Sep 19 06:57:05 2001 From: bongartzfrank at yahoo.de (bongo_premium) Date: 19 Sep 2001 05:57:05 -0500 Subject: Python-TCL (not TCL-Python)? Message-ID: <3ba87965$0$203$45beb828@newscene.com> Hi ! Is it possible to execute TCL-Code in Python ? Since the TCL-Interpreter ist started, using Tkinter, I wonder if the TCL-Interpreter is also able to source a ANY TCL-Code. Looking forward to any suggestions... By the way: I am still trying to compile a windows-dll for TCL-Python (from Jean Luc Fontaine, http://jfontain.free.fr/ ) If anyone has solution for that problem... Thanks ! Greetings, Frank From careye at spamcop.net Thu Sep 13 08:35:23 2001 From: careye at spamcop.net (Carey Evans) Date: 14 Sep 2001 00:35:23 +1200 Subject: How to Get the Crash Errors When Embedding References: Message-ID: <87d74vgtf8.fsf@psyche.dnsalias.org> Spam Hater writes: [...] > My big problem for me is that when I have a python > interpreter exception, I can't see the stack dump. I'm not especially familiar with embedding Python, but maybe you just need to check for the exception from your C code. Guessing a bit here: /* Code that calls the Python code... */ if (PyErr_Occurred()) { PyErr_Print(); /* Any other cleanup. */ } You could also try putting code in the main function(s) you call that prints the exception on its way out to the C program. Something like: import traceback def entry_point(arg): try: real_func(arg) except: traceback.print_exc() raise You might also want to have a look at the win32trace support in win32all. From http://www.python.org/windows/win32/ : To enable this debugging, simply "import win32traceutil" somewhere in your program - thats it! This automatically re-directs the standard Python output streams to the remote collector. I hope this gives you some ideas. -- Carey Evans http://home.clear.net.nz/pages/c.evans/ You think you know... what's to come... what you are. From frederic.giacometti at arakne.com Mon Sep 17 21:43:46 2001 From: frederic.giacometti at arakne.com (Frederic Giacometti) Date: Tue, 18 Sep 2001 01:43:46 GMT Subject: PEP 271: Prefixing sys.path by command line option Message-ID: I'm pasting below the PEP 271 for python 2.2 (http://python.sourceforge.net/peps/pep-0271.html), for public debate. The purpose of the PEP is the introduction of new command line option to python (-P), whose role would be similar to java's -classpath option: providing the ability to explicitly set the PYTHONPATH value from the command line. This feature can be immensely useful when calling python from scripts (shell, Makefiles...), in situations for which either multiple PYTHONPATH values are needed, or where the PYTHONPATH inherited from the parent environment is not reliable. Last, the -P option can also be used to expose in the scripts the value of PYTHONPATH in a highly readable manner. Typical applications are in development of build, test, and configuration scripts. Comments and suggestions for improvement, and questions are welcome. Thanks! Frederic Giacometti fred at arakne.com fredg at scripps.edu ----------------------------------------------------- Abstract At present, setting the PYTHONPATH environment variable is the only method for defining additional Python module search directories. This PEP introduces the '-P' valued option to the python command as an alternative to PYTHONPATH. Rationale On Unix: python -P $SOMEVALUE will be equivalent to env PYTHONPATH=$SOMEVALUE python On Windows 2K: python -P %SOMEVALUE% will (almost) be equivalent to set __PYTHONPATH=%PYTHONPATH% && set PYTHONPATH=%SOMEVALUE%\ && python && set PYTHONPATH=%__PYTHONPATH% Other Information This option is equivalent to the 'java -classpath' option. When to use this option This option is intended to ease and make more robust the use of Python in test or build scripts, for instance. Reference Implementation A patch implementing this is available from SourceForge: http://sourceforge.net/tracker/download.php?group_id=5470&atid=305470&file_i d=6916&aid=429614 with the patch discussion at: http://sourceforge.net/tracker/?func=detail&atid=305470&aid=429614&group_id= 5470 From ffaure at bigSPAMGAMOUTAKUSANfoot.com Thu Sep 6 10:56:27 2001 From: ffaure at bigSPAMGAMOUTAKUSANfoot.com (Frederic Faure) Date: Thu, 06 Sep 2001 14:56:27 GMT Subject: RH 7.1/Fail upgrading to Python2: Why? References: Message-ID: <3b978e21.817405@news.club-internet.fr> On Wed, 5 Sep 2001 16:22:54 -0400 (EDT), Ignacio Vazquez-Abrams wrote: >Have you tried recompiling from the SRPM? No, and the RPM for Python 2.1.1 worked. The reason I asked, however, is to understand what can possibly keep RPM to complain: If all the required libraries are installed through RPM, and rpm -qa shows that all is well, what's the problem? This has already happened to me in the past, so it was an opportunity to understand the cause for such behavior. Thx FF. From hfoffani at yahoo.com Tue Sep 4 05:48:32 2001 From: hfoffani at yahoo.com (Hernan M. Foffani) Date: 04 Sep 2001 09:48:32 GMT Subject: Is 0 > None?? (fwd) (fwd) References: Message-ID: <20010904054831.982$Y9@newsreader.com> "Alex Martelli" wrote: > .... > Comparison issues, and sorting of heterogeneous lists in > particular, ARE central to the new noncomparable behavior > of complex numbers. I see no solution to THAT one, save: > a. either drop the pretense that it makes sense to > compare heterogeneous entities, or > b. regress the change that makes it illegal to compare > complex numbers. > [a] might be conceptually cleaner but would break oodles > of existing code, I think. [b] might be deemed inelegant > by some, but it WOULD be by far the most practical approach. [b] plus a RuntimeWarning on any "heterotypes" lt/gt operations? (I don't have the slightest idea of the work needed to apply this change to the core.) Regards, -Hernan -- -------------------- http://NewsReader.Com/ -------------------- Usenet Newsgroup Service From n8gray at caltech.edu.is.my.e-mail.address.com Sun Sep 30 04:06:06 2001 From: n8gray at caltech.edu.is.my.e-mail.address.com (Nathaniel Gray) Date: Sun, 30 Sep 2001 01:06:06 -0700 Subject: Repost: execfile() confusion References: Message-ID: <9p6k9d$co6@gap.cco.caltech.edu> Tim Peters wrote: > [Nathaniel Gray] >> ... >> Please, somebody, anybody, what's going on?? > > I'm afraid it takes too long to explain. The Ref Man warns that mutating > locals won't always work, and you've bumped into a place where it doesn't > work. So don't do that. Your life will be much easier if you always pass > an explicit namespace dict (or two, if you care about the local/global > distinction) to execfile. Uses that don't pass explicit dicts are likely to > get deprecated anyway. Ah. "Here there be dragons." I suspected that might be the answer. Where in the Ref Man does it talk about mutating locals? Aha, in the description of locals(), sensibly enough. > [snip] If you use execfile without > namespace-dict arguments at other than module scope, I'm afraid the shortest > path to understanding is studying the implementation (in which case you'll > eventually learn-- but without profit --that mutating locals() in fact never > works when calling a function, and that what you're seeing is no deeper than > this: > >>>> def f(): > ... x = 1 > ... locals()['x'] = 42 > ... print x > ... >>>> f() > 1 >>>> Most enlightening! > I could give you tricks to worm around that, but won't without large bundles > of untraceable cash: seeking to mutate locals by magic is disgusting, and > you can and should find a cleaner (meaning explicit) approach. Yeah, yeah, I know. I just like to be evil every now and then. It's just plain fun. You should see my object-oriented Matlab code. ;-) -n8 -- Nathaniel Gray California Institute of Technology Computation and Neural Systems -- From guido at python.org Tue Sep 4 23:34:37 2001 From: guido at python.org (Guido van Rossum) Date: Tue, 04 Sep 2001 23:34:37 -0400 Subject: new page for Newbies Message-ID: I finally broke down and created a new page collecting the most important resources for newbies (people who are new at programming): http://www.python.org/doc/Newbies.html We get several emails per day from people asking how to get started, so I figured this definitely serves a need. Please help us making this a better resource -- send your ideas for making the page more effective to webmaster at python.org. (Note: more effective could mean removing information as well as adding!) Please add this URL to other collections of links about Python. --Guido van Rossum (home page: http://www.python.org/~guido/) From aleax at aleax.it Thu Sep 6 09:18:55 2001 From: aleax at aleax.it (Alex Martelli) Date: Thu, 6 Sep 2001 15:18:55 +0200 Subject: COM/CORBA/DCOP (was: Hello people. I have some questions) References: <7xsne7en0r.fsf@ruckus.brouhaha.com> <9mvp3505rt@enews2.newsguy.com> <9n292n01lg1@enews3.newsguy.com> <9n4kut013qk@enews1.newsguy.com> Message-ID: <9n7t4207k@enews1.newsguy.com> "Erno Kuusela" wrote in message news:ku1yllh7ra.fsf at lasipalatsi.fi... ...[we're supposed to be talking about NAT]... > it does break irc and news and cvs and ntp and icq. servers. It seems we're talking about different things. Take news, for example -- how would NAT break nntp? Or ntp -- I'm running it happily right now through NAT (through TWO layers of NAT as it happens, since both my OpenBSD box _and_ my Zyxel router do NAT'ting, but that doesn't matter much): how is NAT supposed to break ntp? If you explain to me how you believe NAT breaks nntp and ntp, I'll get a better understanding of what you mean by NAT, I'm sure -- because I just can't think of how it might (nor cvs either, but I may be missing some detail of _that_, as I sure am about irc and icq -- nntp and ntp, OTOH, I know pretty well and am using right now through the NAT that you say breaks them). > it does break lots of other stuff too. assuming we're talking > about 1:n nat here and not n:n. We're talking about M machines on a private network, to which are allocated N public internet-routable IP addresses, with N < M. > here are are some improtant things off the top of my head that i > personally use that would not work behind a NAT: > > running your own services > remote access from outside > ssh > vnc > X > ... > http > ftp > smtp > dns They all work fine as long as the number of separate *servers* you want to be visible (IP-addressable) from the outside *on the well-known ports normally associate to these services* is <=N, of course. ftp _clients_ using the "active" mode need special care, which is not hard to supply and which any decent NAT (e.g., ipnat) does of course supply -- although it seems everybody and their brother is going PASV today anyway -- and I have no real knowledge about 'vnc', but unless it's changed hugely from back when they called it RFB, it should be the same as http, etc. Note the specifics, again: how many _distinct_ servers do you need to be separately IP-addressable on single well-known ports. Of course you'll never be able to have more of those, than you own or lease separate public IP addresses. Apart from this obvious constraint, everything works just peachy -- NAT includes DNAT as well as SNAT, obviously. Indeed, DNAT is one rudimental way to load-balance multiple servers -- in this case, you may have K servers, but you do NOT want them to be separately addressed from the outside -- all requests will come to the same IP address, and DNAT will loadbalance by round-robin (or whatever). [Sure, sure, you can do better than that, but still, claiming that NAT breaks http serving, when it's so often used to ENHANCE http serving by rudimental load-balancing, is one of the things that convinces me you must be referring to something else than "Network Address Translation" when you say NAT]. > file sharing service > smb > nfs > ... > > peer-to-peer things > freenet > gnutella > ... And why ever would THESE be broken by NAT'ting? Not that I'd ever want to run stuff as unsafe as smb over the wide-open internet, but that's a completely different issue of course. > protocols that transmit ip addresses in the data payload > (some of the these can be fixed by using "ALGs" or hacks > that know about the protocol that is being run over tcp > and actually actively alter the data payload in the packets > travelling through the NAT box (this is commonly done with e.g. FTP)) > but it only works for protocols that the nat box designer has > thought of and know about before hand and is just conceptually > too horrible to contemplate Proxying is "conceptually horrible"?! Since when?! Besides, it doesn't only work for protocols thought of beforehand: as long as the nat implementation you're using is well designed, you can add to it proxies written afterwards for the purpose of hooking to it. Whenever data and metadata get confused, as in protocols that use data to carry metadata, the "impedance mismatch" may need correction, and proxying is a reasonable way to supply such correction. > most udp services (like peer to peer games, ntp, ...) Take ntp, for example, which I run quite happily. Why do you claim NAT breaks it?! Consider RFC 1305, specifically http://www.eecis.udel.edu/~mills/database/rfc/rfc1305/rfc1305b.pdf section "2.1. Implementation Model": """ In what may be the most common client/server model a client sends an NTP message to one or more servers and processes the replies as received. The server interchanges addresses and ports, over-writes certain fields in the message, recalculates the checksum and returns the message immediately. """ Where does NAT break this, or any other similar UDP-based protocol? If you're again referring to _offering_ ntp service to the outside (you own an atomic clock?-), then we're back to the server issue -- you can expose as many separately IP-addressable servers on a single well-known port as you have allocated public IP numbers, of course. The funny thing about some of these examples is that, for example, "offering" more than one ntp server from a single administrative domain (such as a private network behind a NAT gateway) is specifically "not a good thing" per RFC 1305... even if you own a fine personal collection of atomic clocks, one network should still expose just one ntp server to the rest of the world, quite apart from any NAT issues! > IP protocols other than udp or tcp > tunneling > ipsec (ok, i don't personally run this, but it is very > important not to break imho) I don't run it either, but I've read that it's specifically supported by good NAT implementations. You _are_ familiar with http://www.vpnc.org/draft-aboba-nat-ipsec, of course? While still an internet-draft, it seems pretty good and mature. IPSec AH specifically checksums the metadata and so is of course NAT-incompatible (as well as suffering from other rigidities related to that), but IPSec ESP is fine, and other such issues are addressed in the paper. > cipe > 6to4/sit > ... > > if everyone were behind a nat, no 2 computers on the internet could > communicate with each other. Again, I don't understand *WHY* one could possibly think of saying this! Typical scenario: my five home computers share one public IP address (via nat, of course). So do your three home computers share another public IP address via NAT. I choose to expose one NTP server on port 123 of my single public IP address. You choose to expose an http service on port 80 of your single public IP address. In each case, DNAT routes requests coming to that port of the NAT box to the appropriate one of the inside computers (could be more than one, load-balancing, and NAT blissfully hides internal administrative issues such as, how many computers do I have, which ones are working right now, etc, etc -- a *plus*, if you please:-). My first home computer suddenly need to establish an http conversation with your service, fine, it goes out of my NAT box via SNAT, gets to your NAT box, which DNATs it to the appropriate one of your PC's, and the reply comes back. At the same time your second computer is querying the NTP server I expose -- much of a muchness except on port 123 rather than 80. So *what's the problem?!* -- we're BOTH "behind a NAT", yet it's obvious that our computers on the internet ARE communicating with each other through their NAT boxes. So, again, you MUST mean something different by "NAT", than I do (and, than I think the acronym _means_:-). > and the alg idea is fundamentally > infeasible in the long run given we'd like to run most services > encrypted before long. NAT need not interfere with encryption, as long as there is no data/metadata mix being encrypted. In the long run, hopefully IPv6 will be widely implemented (just don't hold your breath waiting...) and the encrypted-however-you-wish services will run on *that* infrastructure, not IPv4. > it also breaks tcp - it tries to keep track of the tcp connections > that hosts keep open, but times them out if nothing happens in a while If some specific NAT implementation violates RFC 793, that's just a bug in that implementation, of course, with no meaning except that you'd better fix or change that implementation. It's not particularly hard for NAT to keep track of TCP state and respect RFC 793 religiously, of course -- ipnat/ipfilter do. > or the nat box gets rebooted/crashes in the middle of things, or if > it has a dynamic address, its address changes. that makes the network > much more fragile. My NAT box is FAR less likely to reboot than any of my boxes behind it -- orders of magnitude's difference wrt the Windows boxes, of course (needing a reboot pretty often to keep them in somewhat-usable state), but substantially less even wrt the Linux boxes, just because on those one keeps tuning/rebuilding kernels, runs Windows emulators, etc, etc. If I have 3 boxes that reboot on average twice a day, and three more that reboot on average twice a week, then a NAT that reboots on average once a month makes no substantial difference (most particularly if you count the fact that the boxes are on the same electrical circuits, so a good proportion of the NAT's reboots are "common-mode failures" in which the other boxes are ALSO going belly-up). Calling this "making the network MUCH more fragile" is a vast overbid. Note that, as I have no redundancy, but rather connect to my ISP via a single modem, router and phone line, accidents taking that modem, router and/or line out of commission kill me anyway. From my logs I notice the router's PPP is crashing (for durations of several minutes, typically -- enough to kill TCP connections with the typical default 5-minute timeout) at intervals of between 10 and 40 hours, anyway -- and that's with absolutely no NAT involved at all, just the typical "reliability" of a typical ADSL supplier, in these days and this part of the world. My NAT making this "much more fragile"?! *PAH*. Dynamic address leases changing in midstream would be just as much (or as little) of a problem without any NAT in play, of course -- NP if you're using robust protocols, crash if you're using fragile protocols that proceed on the unwarranted assumption of immutability of IP addresses in a dynamic-IP- address-assignment world:-). If this is a problem, it's a dynamic-IP-address-assigment problem, totally unrelated to NAT, just like I was saying about DNS and you quote: > | Of course, I'll have to go with dynamic DNS to match the > | dynamic IP assignment if I want to offer servers, but that's > | got nothing to do with NAT'ting -- even just one box with > | a dynamic IP address would be in the same boat. > || (unless you allow untrusted users shell accounts on it, > || but you can't really defend someone with a shell account > || from rootnig a unix box (including openbsd) anyway). > > | I wonder -- when it's consolidated and hardened enough, I > | might experiment with that. But anyway, who's happy with > | a single layer of defense? I want security in depth, and > > yeah, security in depth is good, but the layers are only > helpful when they are non-trivial to break (follow bugtraq > for a while to see why defending against local users is a > futile exercise). Maybe. And then again, maybe not. We'll see what I think when I have things in a more stable state, and can indeed start following bugtraq. Right now I see six entries on bugtraq's archive about OpenBSD 2.9: three are denial-of- service issues, one is wrt X11 (which I don't keep on my OpenBSD box), one about lpd (ditto), and id 2873 is a race condition for which OpenBSD released patches on June 21st (exactly 7 days after the race condition was published). If this is a typical, representative sample of how many vulnerabilities may 'lurk' in a stripped-down OpenBSD installation, and how much time it takes to plug them when they come to light, then I think I can keep up with things even as a very-part-time sysadm, once I've put the thing in a good, stable condition. Of course, I'd feel far less calm about it were I running something else:-). > if you don't run any services on the firewall, then you are pretty > well off. That depends on how you define "services". I do plan to put proxies there, eventually, tripwire, that sort of things. But the fewer pieces there are, the fewer pieces may break, so I'll be watching out not to load the box down with any substantial fraction of the wealth of riches easily available for it (I still think I started out on the right foot by not installing any kind of X or other graphics on it:-). > running some servers accessible from the outside might > prove challenging with a NAT. (unless you run them on > non-standard ports and/or use some sort of port-forwarding kludge). "Kludge"?! Your unexplained detestation for NAT clearly extends to DNAT just as much as to SNAT, but that's not explicatory. Again, *WHY* is it "kludgey" to put the single public IP address I lease on a machine with a bare minimum of "stuff", and DNAT services (on their well known ports, say) to one or more (not that I _plan_ to do load-balancing, with the 128 Kbps bandwidth I have outgoing from ADSL, but that's another issue:-) servers in the DMZ? Putting the servers right on the machine that's fully exposed to the "big, bad outside" (thereby making said machine more fragile -- the more it has on it, the more stuff can break!) seems far worse to me. Alex From drobinow at dayton.adroit.com Tue Sep 25 11:29:13 2001 From: drobinow at dayton.adroit.com (Robinow, David) Date: Tue, 25 Sep 2001 11:29:13 -0400 Subject: Cygwin Python -- Thread or not to thread... Message-ID: <80575AFA5F0DD31197CE00805F650D7602D015@wilber.adroit.com> setup supports experimental versions. This seems like a good candidate. That is, release your new version without threading. Then follow it, as experimental, with the same thing, thread-enabled. > -----Original Message----- > From: Jason Tishler [mailto:jason at tishler.net] > ... > So I am asking the Cygwin Python community the following: > > Should I still release my next Cygwin Python distribution with > threading enabled? Or, should I continue to disabled threading > until the above known Cygwin pthreads issue is resolved? > > There are advantages and disadvantages to either choice. By > releasing a > threaded Cygwin Python, more people will be able to exercise Cygwin's > pthreads support which will help test the implementation. This is > especially important on 9x/Me since I don't access to these platforms > and hence, have never personally tested Cygwin Python on them. The > downside is siccing a (buggy) threaded Cygwin Python on the general > public may result in significant heartache. > > The more conservative approach is to continue to release Cygwin Python > with threading disabled until the known Cygwin pthreads issue > is resolved. > Unfortunately, it maybe sometime before the race condition is > prevented > (i.e., the fix is non-trivial): > > http://www.cygwin.com/ml/cygwin-developers/2001-09/msg00438.html > > So Cygwin Python users that need threading may have to continue to be > patience for an undetermined amount of time. > > Please post your opinions instead of sending private email, so others > can see how a consensus (if any) was determined. > > Thanks, > Jason From markus at schabi.de Thu Sep 13 14:40:51 2001 From: markus at schabi.de (Markus Schaber) Date: Thu, 13 Sep 2001 20:40:51 +0200 Subject: What is Python good for? References: <3ba07016$0$1018$edfadb0f@dspool01.news.tele.dk> Message-ID: <1357944.ElGaqSPkdT@lunix.schabi.de> maxm schrub: > "Ignacio Vazquez-Abrams" wrote in message >> Here's something that came up recently that if it doesn't make you go >> "ooh-ahh", then it will make you go "whoa": > >> >>> def a(): >> ... return 'abc' >> ... >> >>> def b(): >> ... return 123 >> ... > >> >>> a.func_code=b.func_code > > wouldn't a = b satisfy your need for whoas here ? No, not always. Imagine there's some other reference to the function referenced by a. Then your assignment would have no effect on the third reference, but Ignacios example would change the function itsself (instead of assigning a new function to the name a), so the change is visible to the user of the other reference, too. markus -- "The strength of the Constitution lies entirely in the determination of each citizen to defend it. Only if every single citizen feels duty bound to do his share in this defense are the constitutional rights secure." -- Albert Einstein From skip at pobox.com Mon Sep 10 00:48:29 2001 From: skip at pobox.com (Skip Montanaro) Date: Sun, 9 Sep 2001 23:48:29 -0500 Subject: Python by RPM -> bad idea? In-Reply-To: <3b9c40dc_1@news.nwlink.com> References: <3b9c40dc_1@news.nwlink.com> Message-ID: <15260.17949.145685.38987@localhost.localdomain> pkwoods> I'm having problems, and I think they stem from my installing pkwoods> Python originally through the use of an RPM. pkwoods> By using an RPM, I get not /config directory with a Makefile, pkwoods> which sounds reasonable enough, as I didn't compile anything. If you have a python-devel RPM somewhere (probably where you got your python rpm), it will almost certainly have the missing /config directory and its contents. You only need python-devel when you are building other programs or shared libraries that use python. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From ignacio at openservices.net Fri Sep 7 09:33:52 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Fri, 7 Sep 2001 09:33:52 -0400 (EDT) Subject: Creating Excel files on Linux In-Reply-To: Message-ID: On Fri, 7 Sep 2001, Maan M. Hamze wrote: > But the question is: Can Staroffice create XLS files? If not, then it is a > major waste of time to create spreadsheets using Staroffice. It is a world > that speaks the XLS language. > Maan Yeah, but Microsoft doesn't wnat anyone else speaking it. If they did, they wouldn't have made them OLE compound documents. -- Ignacio Vazquez-Abrams From randy at dayton.akorn.net Mon Sep 3 22:20:45 2001 From: randy at dayton.akorn.net (randy at dayton.akorn.net) Date: Tue, 04 Sep 2001 02:20:45 GMT Subject: Large file support in Linux Message-ID: Hi, I'm trying to build Python 2.1.1 on Linux (RedHat 7.1) that can handle large files. I tried the configure command on the website (http://www.python.org/doc/current/lib/posix-large-files.html) but I can't get it to work. What I tried: CFLAGS='-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64' OPT="-g -O2 $CFLAGS" \ ./configure make This results in these errors during build: Objects/fileobject.c: In function '_portable_ftell': Objects/fileobject.c:267: incompatible types in return Has anyone built Python with large file support on Linux? Thanks, -Randy From ffaure at bigSPAMGAMOUTAKUSANfoot.com Tue Sep 11 20:50:36 2001 From: ffaure at bigSPAMGAMOUTAKUSANfoot.com (Frederic Faure) Date: Wed, 12 Sep 2001 00:50:36 GMT Subject: Can't compile python w/out threads Message-ID: <3b9eb15b.28407207@news.club-internet.fr> Hi, I'm trying to install the open-source Newsbruiser blogger application, which requires Apache and Python. Since no precise information is given, I figured I'd compile python 1.6.1 with mod_python 2.7.5 and apache 1.3.20, with mod_python as a static module. 1. I successfully compiled and installed Python this way: cd /usr/src/Python ; make clean ; rm -f config.cache; ./configure --prefix=/usr/local/nothread-python --with-threads=no ; make ; make install. 2. Next step, cd /usr/src/apache ; ./configure --prefix=/usr/local/apache-apache 3. Configuring mod_python, however, fails: cd ../mod_python ; ./configure --with-apache=/usr/src/apache_1.3.20 --with-python=/usr/src/Python " ****** WARNING ****** Python is compiled with thread support. " I've tried replacing /usr/src/Python with /usr/local/Python (can't find bin/python), and /usr/local/Python/bin/, but I still get the above warning, and in addition get a couple of "No such file or directory" => I also tried compiling Python with --without-threads, to no avail. How can I build a truly thread-free python? I know it's just a warning, but considering what it says about issues with Apache, I'd rather have a successful configuration. Thx FF. From maxm at normik.dk Tue Sep 11 07:07:40 2001 From: maxm at normik.dk (=?iso-8859-1?Q?Max_M=F8ller_Rasmussen?=) Date: Tue, 11 Sep 2001 13:07:40 +0200 Subject: The proper idiom for sorting objects in a list by an arbitrary pr operty Message-ID: <7BD10B680501D411B9DF009027E06F32197E27@exchange> I have written the below function to sort objects by an arbitrary property. But I wonder if there is a better way to do it? Regards Max M ############################################# def sort(objects, sortAttrib): # Sorts a list of objects in accordance to an attribute of choice # I assume that Pythons built in sort() is blistering fast # So I run around hoops to use that. # makes a list of tuples ('value of sortatrib', 'index of object') sortValues = [ (getattr(objects[i], sortAttrib), i) for i in range(len(objects)) ] sortValues.sort(), # Sorts by first value in tuple return [objects[sortTuple[1]] for sortTuple in sortValues] class my: def __init__(self, id, title): self.id = id self.title = title m1 = my(1, 'Number one') m2 = my(2, 'Number two') m3 = my(3, 'Number three') for object in sort([m1, m3, m2], 'id'): print object.title From richw at objenv.com Thu Sep 20 16:37:20 2001 From: richw at objenv.com (rw2) Date: Thu, 20 Sep 2001 15:37:20 -0500 Subject: url parsing on in-house schemes Message-ID: <20010920.153720.213975407.3413@objenv.com> I followed the general convention of scheme://host/path in creation of new schemes, but neither urlparse nor urllib want to parse our new creations. This is understandable as the RFC says that everything after the colon is scheme dependent, but I'd like to know if there's a way to coax either of them to use scheme://host/path as a default instead of throwing an exception (urllib) or putting the host in the path (urlparse) From michael1083 at gmx.de Fri Sep 14 16:16:10 2001 From: michael1083 at gmx.de (Michael Landmann) Date: Fri, 14 Sep 2001 22:16:10 +0200 Subject: What's wrong with my script? References: <9nti6o$g96$06$1@news.t-online.com> <9nsqdn.3vv3odd.1@kserver.org> Message-ID: <9ntoi8$9pu$05$1@news.t-online.com> > print "Content-type: text/html\n\n" # add this line here Doesn't work From qrczak at knm.org.pl Mon Sep 24 15:50:34 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 24 Sep 2001 19:50:34 GMT Subject: Remove files of same type (extension) References: <9on1mq$pj8$04$1@news.t-online.com> <3BAF3754.68BDA949@yahoo.com> Message-ID: Mon, 24 Sep 2001 17:38:28 +0400, A.A pisze: > You can use the fnmatch module to match using dos/unix like patterns: Or the glob module. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From peter at engcorp.com Fri Sep 7 14:38:24 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 07 Sep 2001 14:38:24 -0400 Subject: newbie: cannot import name error References: <3B98D4F6.445C1525@engcorp.com> <9nalad0unl@enews1.newsguy.com> Message-ID: <3B991420.357A85F2@engcorp.com> Alex Martelli wrote: > > "Peter Hansen" wrote in message > news:3B98D4F6.445C1525 at engcorp.com... > ... > > On the other hand, you're trying to do something I've _never_ > > needed to do yet, after almost two years with Python. Any time > > (to date) I've needed to install an extension, I've been okay > > with just copying it to the python/lib folder, or with adding > > Then maybe you use a platform for which precompiled C extensions > are easier to come by than for Solaris, and have never needed to > build your own (because the distutils are the easiest way to > build C extensions anyway). While that is quite true, I thought we were talking about Python extensions, not C extensions. Whatever... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From msottil at datamat.it Wed Sep 5 06:51:31 2001 From: msottil at datamat.it (Marco Sottilaro) Date: Wed, 5 Sep 2001 12:51:31 +0200 Subject: GUI toolkit Message-ID: <005f01c135f8$b99b2a80$691b010a@datamat.it> I'm searching an open source toolkit, like "Visual TCL" ( http://vtcl.sourceforge.net/ ), to build GUIs (with "'tkinter") for my Python applications. This toolkit to have to generate Python code. Can you help me ? Thanks ! Greetings, Marco Ing. Marco Sottilaro Datamat Ingegneria dei Sistemi S.p.A. Divisione Difesa & Spazio Via Laurentina, 760 - 00143 ROMA e-mail : msottil at datamat.it -------------- next part -------------- An HTML attachment was scrubbed... URL: From quinn at retch.ugcs.caltech.edu Sun Sep 23 19:04:01 2001 From: quinn at retch.ugcs.caltech.edu (Quinn Dunkan) Date: 23 Sep 2001 23:04:01 GMT Subject: Ksh-ish functionality on Unix systems References: <1001022297.843756@cswreg.cos.agilent.com> <9oe11j$6ls$1@nntp6.u.washington.edu> Message-ID: On 21 Sep 2001 00:18:59 GMT, Donn Cave wrote: >Quoth weeks at vitus.scs.agilent.com (Greg Weeks): >| The low-level support is far too verbose for casual use. The higher-level >| stuff seems incomplete. However, the higher-level stuff becomes a lot more >| complete if the command arguments are passed to, say, /bin/sh on Unix >| systems. In that case, os.system and getstatusoutput capture the above Ksh >| functionality, and os.popen and popen2.* are bonuses. >| >| So: Is it a reasonable approach as a Unix user to rely on the fact that the >| os.system and getstatusoutput commands are passed to a shell? >| >| Or is that tacky? If that *is* tacky, is there a *convenient* alternative? > >system() and getstatusoutput() will indeed invoke the shell, that's >a given. What's tacky about that is a multiple evaluation problem, >when you construct the shell command out of input data from some not >entirely predictable source. When the shell evaluates its command line, >results are lowered to another, unpleasant dimension of unpredictability. Another possibility is to use a more sane shell, like rc. The problem with sh (and ksh too, I'm sure) is that their "parsing" is so complicated no one really wants to figure out exactly how they work except Evil Hackers. rc has much simpler quoting rules. If there were a high level plumbing module for python, one possibility is that it would implement a little language that would look something like a simplified more regualr version of sh. rc is already reasonably close to this. Or you could turn around and try a set of pure python plumbing classes that wrap up all the nasty pipe() and fork()iness; it sounds like a fun project. From tjreedy at home.com Fri Sep 28 10:35:33 2001 From: tjreedy at home.com (Terry Reedy) Date: Fri, 28 Sep 2001 14:35:33 GMT Subject: Problem with os.system() References: <3bb480af_1@news.newsgroups.com> Message-ID: "Janos Blazi" wrote in message news:3bb480af_1 at news.newsgroups.com... > I have the following code: > > prog=r'"C:\Programme\Windows Media Player\mplayer2"' > f=r'c:\WINNT\Media\Microsoft Office 2000\APPLAUSE.WAV' > os.system(prog+' /Play '+f) > > Now first it seems as though it worked and the wav file is played. The > problem is that after the wav file has ben played my program does not regain > the control i.e. the next statement is not executed. If I close the Media > Player window manually, my program resumes. I use Win2000 but my program > should work under MS-DOS. Your 'problem' is not with your Python program, but with mplayer not closing itself by itself after playing one song. Perhaps there is a command line option that would tell it to do so. Perhaps you should find a wav-file player that behaves better for your purpose. I believe that pygame may give you access to some such. Terry J. Reedy From db3l at fitlinxx.com Thu Sep 6 19:15:51 2001 From: db3l at fitlinxx.com (David Bolen) Date: 06 Sep 2001 19:15:51 -0400 Subject: so no more debug packages??? References: <924efc60.0109061410.36a497f1@posting.google.com> Message-ID: srowley at ids.net (Stephen Rowley) writes: > i was reading the specs for 2.2 and it said that they stopped making > the debug package. said it was too "confusing". i've been messing > around with c and python and i found the debug quite useful. Since you're already doing development, just grab the Python sources and rebuild for a debugging version locally. -- -- 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 sjoshi at ingr.com Wed Sep 26 13:51:25 2001 From: sjoshi at ingr.com (Sunit Joshi) Date: 26 Sep 2001 10:51:25 -0700 Subject: COMServer questions!! Message-ID: <8f8ffe67.0109260951.24b74c40@posting.google.com> Hi All I was wondering if someone else has noted this problem: I'm calling a PythonCOM object from VB and if I pass a variable to it then I seem to loose the value of the variable. Is it because all variables are passed by reference ? For ex: Set oTestCom = CreateObject("PyCom.FileAccess") If Not oTestCom Is Nothing Then oTestCom.OpenFile selectedFile, "r" lblFileName.Caption = selectedFile 'I loose selectedFile value here 'Everything else works fine though Is this a WAD or am'I doing something wrong here thanks Sunit From tim at vegeta.ath.cx Thu Sep 27 18:42:30 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Thu, 27 Sep 2001 22:42:30 GMT Subject: scanf style parsing References: <3BB16A50.BAE082FE@cygnus-software.com> <3BB2C7DA.F63EEAA7@cygnus-software.com> Message-ID: Me parece que Duncan Booth dijo: > tim at vegeta.ath.cx (Tim Hammerquist) wrote in > news:slrn9r61oo.uim.tim at vegeta.ath.cx: > > > But don't think regex's are disposable just because Python's string type > > is more convenient. Consider the following: > > > > # perl > > if ($filename =~ /\.([ps]?html?|cgi|php[\d]?|pl)$/) { ... } > > # python > > re_web_files = re.compile(r'\.([ps]?html?|cgi|php[\d]?|pl)$') > > m = re_web_files.search(filename) > > if m: > > ... > > > > This is a very complicated (but relatively efficient way) to match files > > with all the folowing extensions: > > .htm .html .shtm .shtml .phtm .phtml > > .cgi > > .php .php2 .php3 .php4 > > .pl > > Wouldn't you be happier with this?: > > extensions = ['.htm', '.html', '.shtm', '.shtml', '.phtm', > '.phtml', '.cgi', '.php', '.php2', 'php3', '.php4', '.pl'] > ext = os.path.splitext(filename)[1] > if ext in extensions: > ... > > which has the arguable advantage of matching what your description says > instead of what your original code does. The main point of the example was to demonstrate my own peeve (Python's clumsy re implementation), not to show an example of good idiomatic Python. As I said, this is a good thing; it keeps those of us with Perl experience in check. You're solution is quite good, and probably one I'd use; in practice, I would add the .lower() method to the ext var, just as I would add the re.I flag in the re.compile() statement...unless I wanted to put IIS servers through Hell. > regexes are wonderful: in moderation. That bore repeating. Thank you. =) -- Destinations are often a surprise to the destined. -- Thessaly, The Sandman From fractal97 at hotmail.com Sat Sep 8 19:02:36 2001 From: fractal97 at hotmail.com (vin) Date: Sat, 08 Sep 2001 23:02:36 GMT Subject: A question? References: Message-ID: PyImport_GetModuleDict() which is the same as sys.modules and which returns a dictionary already contains 'exmpl' To see that just insert PyRun_SimpleString("import sys\n"); PyRun_SimpleString("print sys.modules\n"); after module=PyImport_ImportModule("exmpl"); Therefore inserting 'exmpl' module doesn't help. Ignacio Vazquez-Abrams wrote: > On Sat, 8 Sep 2001, Ignacio Vazquez-Abrams wrote: > >> On Sat, 8 Sep 2001, vin wrote: >> >> > Gven a file exmpl.py >> > >> > def foo(x,y): >> > return x,y; >> > >> > Why does the following .... >> > >> > module=PyImport_ImportModule("exmpl"); >> > PyRun_SimpleString("print dir(exmpl)\n"); >> > >> > give .... >> > >> > Traceback (most recent call last): >> > File "", line 1, in ? >> > NameError: name 'exmpl' is not defined >> >> You have to put this line between the two: >> >> PyDict_SetItemString(PyModule_GetModuleDict(), "exmpl", module); > > Sigh. I meant PyImport_GetModuleDict(), of course... > From phr-n2001 at nightsong.com Wed Sep 12 18:22:20 2001 From: phr-n2001 at nightsong.com (Paul Rubin) Date: 12 Sep 2001 15:22:20 -0700 Subject: math.frexp - what's it mean? References: Message-ID: <7xae00123n.fsf@ruckus.brouhaha.com> The term "mantissa" in math traditionally means the fractional part of log_10(x). Programmers sometimes use the term to mean frac(x) but that's inconsistent with the math usage. So I think "frexp" is more accurate and clear than "manexp". From loewis at informatik.hu-berlin.de Tue Sep 4 06:59:18 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 04 Sep 2001 12:59:18 +0200 Subject: what makes a good enhancement? References: <9mm02m02shi@drn.newsguy.com> Message-ID: Grant Griffin writes: > After submitting a PEP recently (PEP 265), I think I might have gained at least > a little insight into what makes a good Python enhancement. (By "enhancement", > I mean a change or addition to Python's features, not a bug-fix.) What I've > learned (or at least what I _think_ I've learned) doesn't seem to be written > down anywhere, so as a "service" to the community, I thought I'd try to codify > it here. Please feel free to agree/disagree/modify (not that I can stop you > .) Note that much of this is or ought to be covered in PEP 5. So if you find any significant aspects missing in PEP 5, I recommend to contact the author of this PEP (Paul Prescod), and/or put a patch to this PEP onto SF. > - Is fully backwards compatible (e.g. a new library module). No patch is full backwards compatible. If you add a new module, say, x5673, then the code try: import x5673 except ImportError: print "PASS" else: print "FAIL" would fail after the addition of the new module. Instead, a PEP should clearly identify all aspects of backwards incompatibility that it will necessarily introduce. It is then up to the judgement of the reader whether these changes are serious or not. > - Speeds Python in some significant way (e.g. xreadlines). There have been cases in the past where such changes where rejected, since the implementation resulted in a loss of clarity. Also, improving the speed of Python without enhancing the language or its libraries are better than changes that do extend/enhance: With such a change, all existing code suffering from the speed deficiency must be updated to use the new API, which then causes a backwards-compatibility problem in case the code needs to work on different Python versions. > - Makes Python somehow easier to learn and/or use (e.g. unifying long integers > and integers). There is always a danger that such a change violates TOOWTDI, see the recent discussion on making copy and len methods. > Intolerable aspects: > - Slows Python in any way. By that rule, a number of recent (and not-so-recent) enhancements to Python should have been rejected (e.g. rich comparisons). Usually, implementing a feature initially will result in a speed drop for some applications, unless the intent is specifically to improve the speed, and can be shown to do so in all cases. > - (However, one > continues to doubt that any number of __future__ statments can ever make Python > wart-free .) I couldn't agree more - all those should have used the directive keyword from the beginning :-) Regards, Martin From tdelaney at avaya.com Sun Sep 16 20:57:56 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Mon, 17 Sep 2001 10:57:56 +1000 Subject: No spam in books Message-ID: > Well, I like to associate the Python name more with this bad*ss large > snake that crushes its prey. It just sounds meaner. }:-)> But Monthy > Python's OK, too. It is well documented that the name "Python" comes from "Monty Python" and not the snake - hence the common silliness in the mailing list/newsgroup. However, the secondary meaning has resulting in the icons ... > To mail me, remove "nospam.". Somewhat appropriate ... Tim Delaney From leind at sofcom.com Fri Sep 14 00:47:42 2001 From: leind at sofcom.com (leind at sofcom.com) Date: Fri, 14 Sep 2001 04:47:42 GMT Subject: Writing binary files Message-ID: <20010914.045538.373028728.15936@taurus.bull> I have a large amount of binary data in memory (am image) and I'm trying to write it to a file. But I can't find a simple example showing how this is done. I just need to write the data "as is" to a file. I've looked at the 'struct' module but that doesn't look like what I need. Also the 'pickle' module appears to be used for formating binary data. Again, not what I need. Does python have the ablitiy to open a file and write binary data to it? I'm running under Mandrake linux using python 2.0 -Daniel From polopunk209 at hotmail.com Mon Sep 10 00:57:00 2001 From: polopunk209 at hotmail.com (Josh) Date: 9 Sep 2001 21:57:00 -0700 Subject: Invisible Pygame Car!? Message-ID: For some reason, the picture of my car won't show up in my upcoming driving/shooter game. most of this code is taken from the aliens example. I used to see the car, and the road fine, but after some tinkering, I can't see the car anymore. Also, when the car was showing up, I could only move it a few pixels back and forth, instead of the width of the screen, any help would be appreciated. Here's the code... import whrandom, os.path, sys import pygame, pygame.image from pygame.locals import * #image loader def load_image(file, transparent): "loads an image, prepares it for play" file = os.path.join('data', file) try: surface = pygame.image.load(file) except pygame.error: raise SystemExit, 'Could not load image "%s" %s'%(file, pygame.get_error()) if transparent: corner = surface.get_at((0, 0)) surface.set_colorkey(corner, RLEACCEL) return surface.convert() def load_back(file): "loads background, prepares it for play" file = os.path.join('background', file) try: surface = pygame.image.load(file) except pygame.error: raise SystemExit, 'Could not load image "%s" %s'% (file, pygame.get_error()) return surface.convert() #constants SCREENRECT = Rect(0, 0, 350, 450) PLAYER_SPEED = 5 #some globals for friendly access dirtyrects = [] # list of update_rects next_tick = 0 # used for timing class Img: pass # container for images class Bg: pass # container for backgrounds class Actor: "An enhanced sort of sprite class" def __init__(self, image): self.image = image self.rect = image.get_rect() def update(self): "update the sprite state for this frame" pass def draw(self, screen): "draws the sprite into the screen" r = screen.blit(self.image, self.rect) dirtyrects.append(r) def erase(self, screen, background): "gets the sprite off of the screen" r = screen.blit(background, self.rect, self.rect) dirtyrects.append(r) class Player(Actor): "Cheer for our hero" def __init__(self): Actor.__init__(self, Img.car) self.alive = 1 self.reloading = 0 self.rect.centerx = SCREENRECT.centerx self.rect.bottom = SCREENRECT.bottom - 5 def move(self, direction): self.rect = self.rect.move(direction*PLAYER_SPEED, 0).clamp(road) class Road(Actor): "The proving grounds" def __init__(self): Actor.__init__(self, Bg.road) self.rect.centerx = SCREENRECT.centerx def main(): global dirtyrects #initiate pygame/display settings pygame.init() screen = pygame.display.set_mode(SCREENRECT.size, 0) pygame.display.set_caption('Cop Chase') pygame.mouse.set_visible(0) # Load the Resources Img.cop = load_image('cop.bmp', 1) Img.car = load_image('car.bmp', 1) ###Bg.road = load_back('road.bmp') #create background background = pygame.Surface(screen.get_size()) background.fill((25,150,25)) #flip display/show background screen.blit(background,(0,0)) screen.blit(Bg.road, (0,0)) pygame.display.flip() while 1: # Initialize Game Actors player = Player() #quit game pygame.event.pump() keystate = pygame.key.get_pressed() if keystate[K_ESCAPE] or pygame.event.peek(QUIT): break # Clear screen and update actors for actor in [player]: actor.erase(screen, background) actor.update() # Move the player direction = keystate[K_RIGHT] - keystate[K_LEFT] player.move(direction) # Draw everybody for actor in [player]: actor.draw(screen) pygame.display.update(dirtyrects) dirtyrects = [] if __name__ == '__main__': main() From sill at optonline.net Sun Sep 9 18:32:18 2001 From: sill at optonline.net (Andrei Kulakov) Date: Sun, 09 Sep 2001 22:32:18 GMT Subject: wav player using wxPython and pygame - wavplayer.py (0/1) References: <3b9b8fe1.96155183@news.chnd1.az.home.com> Message-ID: On Sun, 09 Sep 2001 15:55:19 GMT, ibwonrr at yahoo.com wrote: > I've written a simple (read: ugly) wav player using pygame and > wxPython. It can play, stop, pause, and shows the current and total > time of the wav file. It can also convert wav files to mp3 using > BladeEnc (freeware for win32). > > My goal was to write an mp3 player, but I couldn't get mp3s to load > using pygame.mixer.music.load() (under windows 2000). If anyone knows > how to do this, please let me know. Look into xaudio (xaudio.com). There's also pyxaudio. Alternatively, you could just call mpg123 or somesuch. I made an mp3 player that does that - in the sig. - Andrei -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: cy.silmarill.org From web.mail at lycos.com Mon Sep 17 17:53:36 2001 From: web.mail at lycos.com (Alan Green) Date: 17 Sep 2001 14:53:36 -0700 Subject: Log4p References: Message-ID: <270c68fe.0109171353.532b08a8@posting.google.com> Martin von Loewis wrote in message news:... > I don't think they are good. They copy the Java API 1:1 to Python, > including package names; this is not a good thing to do. Perhaps, but if it works, I'd just use it and not think too hard about the implementation. Alan. From tyler at tylereaves.com Sun Sep 16 17:13:13 2001 From: tyler at tylereaves.com (Tyler Eaves) Date: Sun, 16 Sep 2001 21:13:13 GMT Subject: SMTPLIB module - how to add subject ? References: Message-ID: A wrote: > Hi, > I tried > 11.11.2 SMTP Example from Python docs. > Does anyone know how I can add subject to an email send by this example? > Thank you very much for help > Ladislav Any headers needed to be included in the message body. IE: (Assuming s is the smtpconenction) s.sendmail('from at foo.com','to at foo.com','Subject: This is the subject\n\nMessage body starts here.') From loewis at informatik.hu-berlin.de Tue Sep 4 05:50:58 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 04 Sep 2001 11:50:58 +0200 Subject: Is there any python 2.1 decompiler ??? References: Message-ID: Oleg Broytmann writes: > dis.py in standard library. > http://groups.google.com/groups?q=dis.py&safe=off I think it does not really qualify as a decompiler; I'd rather call it a disassembler. I don't think there is a decompiler for all of the 2.1 byte code; for most of 2.0 byte code, you can use decompyle: http://goebel-consult.de/decompyle/ I'm sure Hartmut Goebel would appreciate contributions to update this to the current Python feature set. Regards, Martin From rnd at onego.ru Sat Sep 29 15:32:51 2001 From: rnd at onego.ru (Roman Suzi) Date: Sat, 29 Sep 2001 23:32:51 +0400 (MSD) Subject: Off-topic: hiding your email address - don't bother... In-Reply-To: Message-ID: On Sat, 29 Sep 2001, Tim Peters wrote: I do not understand those who hides: after I subscribed to c.l.p SPAM percent became less than 1 ;-) Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Saturday, September 29, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Windows: From the people who brought you EDLIN!" _/ From SSchukat at dspace.de Fri Sep 7 11:07:06 2001 From: SSchukat at dspace.de (Stefan Schukat) Date: Fri, 7 Sep 2001 16:07:06 +0100 Subject: AW: Evidence of pythoncom bug? Message-ID: <84257D042AA7D411B3F700D0B7DB9B7C13ADB3@newsintern.dspace.de> > > > ---------- > > Von: Bill Bell[SMTP:BILL-BELL at BILL-BELL.HAMILTON.ON.CA] > > Gesendet: Freitag, 7. September 2001 14:42:52 > > An: Mark Hammond > > Cc: python-list at cwi.nl > > Betreff: RE: Evidence of pythoncom bug? > > Diese Nachricht wurde automatisch von einer Regel weitergeleitet. > > > > > On 7 Sep 2001, at 23:34, Mark Hammond wrote: > > Yes - pythoncom does not support arbitary vtable based interfaces. > > This limitation has existed since day 1, and may soon be able to be > > removed. However, it still exists today. So I am afraid it is a > > simple case of it being a known and documented limitation. > > Thanks very much! > > I don't suppose you could point me toward some kind of > workaround? > > Thanks in any case. > > Bill > > Bill Bell, Software Developer > You could probably make your own pyd which wraps this custom interface. Mark provided scripts for that in ..\com\win32com\makegw. In makegw.py is a short explanation what to be done. If you don't have an IDL file for your interface try to make a new one out of the typelib via the OLEVIEW.EXE utility shipped with Visual Studio. With this you could generate then the .h anc .c files needed for the makegw utility. Any further question I could only answer on Monday. Bye Stefan ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Dipl. Phys. Stefan Schukat Software Development EXP-CTA dSPACE GmbH Technologiepark 25, 33100 Paderborn, Germany phone : +49 - 5251 - 1638 - 612 fax : +49 - 5251 - 16198 - 611 mailto : sschukat at dspace.de http://www.dspace.de ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From lluang at northwestern.edu Fri Sep 21 16:43:36 2001 From: lluang at northwestern.edu (Louis Luangkesorn) Date: Fri, 21 Sep 2001 15:43:36 -0500 Subject: SWIG: MSVC++ [LINK : fatal error LNK1104: cannot open file "python21_d.lib"] References: <3BA56CB6.5786D4C2@northwestern.edu> <3BA8E9CE.638D69D5@northwestern.edu> Message-ID: <3BABA678.3E329B53@northwestern.edu> Louis Luangkesorn wrote: > Now I've run into a new problem. When I try to link, I get the following > error: > > swig > Compiling... > numint.c > cnumint_wrap.c > Linking... > LINK : fatal error LNK1104: cannot open file "python21_d.lib" > Error executing link.exe. > > cnumint.dll - 1 error(s), 0 warning(s) Finally got it to work. I figured I'd post it here for future reference on using SWIG with MSVC. There were a number of places under Project -> Settings that specified debuging. The one that seemed to matter was under C++ -> Code Generation -> Use run-time library. The default setting for creating a DLL is "Debug multithreaded DLL". I changed this to "Multithreaded DLL" Of course, this is after deleting a number of "_DEBUG" definitions throughout the Settings dialog so I don't know if there was a combination of actions that made it work of if was just this. Now onto getting the rest of my work done. . . Louis -- K Louis Luangkesorn lluang at northwestern.edu http://pubweb.nwu.edu/~kll560 PGP:0xF3E2D362 Whatsoever things are true, ... honest, ... just, ... pure, ... lovely, ... of good report; if there be any virtue, and if there be any praise, think on these things.- motto - Northwestern University From gerson.kurz at t-online.de Thu Sep 13 09:28:16 2001 From: gerson.kurz at t-online.de (Gerson Kurz) Date: Thu, 13 Sep 2001 13:28:16 GMT Subject: new user References: Message-ID: <3ba0b2ce.1772156@news.t-online.de> On Thu, 13 Sep 2001 05:54:42 -0700, "byron okubasu anangwe" wrote: >What I would like to know is: - > How much time is it going to take to learn python with experience of programming in BASIC and FOTRAN? I would say, a week? If you know already another programming language or two, the tutorial is really easy. > Can python support scientific and mathematical computations such as iterations, obtaining values of a particular item from list of a predefined set to use in an equation? Check out NumPy at http://www.pfdubois.com/numpy/ From ws-news at gmx.at Wed Sep 5 11:52:41 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Wed, 5 Sep 2001 17:52:41 +0200 Subject: dde? References: <20010905120928.B2068@xs4all.nl> <9n53rh01kut@enews1.newsguy.com> <3b9631aa$0$28956$6e365a64@newsreader02.highway.telekom.at> Message-ID: <3b964af9$0$60724$6e365a64@newsreader02.highway.telekom.at> "Michael Abbott" wrote in message news:Xns9113A5D55CB87michaelrcpcouk at 194.238.50.13... ... ... > Let's not go into the details of what is wrong with Windows NT, eh? Of course not :-) Just wanted to emphasize that DDE is probably one of the least desirable IPC mechanisms (for new applications) today. (Apart from asking the user to transfer the data manually, of course) BTW: Windows NT and 2k is still a much better choice than Win 9x/ME in my opinion. best regards Werner From pinard at iro.umontreal.ca Sun Sep 16 14:04:37 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 16 Sep 2001 14:04:37 -0400 Subject: Pymacs 0.6 Message-ID: Hi! A new release of Pymacs is available as: http://www.iro.umontreal.ca/~pinard/pymacs/pymacs.tar.gz Pymacs allows Emacs users to extend Emacs using Python, where they might have traditionally used Emacs LISP. Pymacs runs on systems having sub-processes. Reports and comments are welcome! Thanks to all people who gave feedback. This release addresses one portability problem, and corrects a serious bug about match data not being properly restored. Emacs now displays Python doc-strings, if any, for the documentation of Pymacs-loaded functions. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From ignacio at openservices.net Thu Sep 20 20:00:27 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Thu, 20 Sep 2001 20:00:27 -0400 (EDT) Subject: Allocation/deallocation of a BIG list in Linux Message-ID: When running 'python -c range\(3e7\)' under Linux, I;'e noticed something interesting with regards to memory allocation and deallocation. In the beginning, memory allocation is fairly constant for the first quarter or so. After that it slows down a bit, but still climbs. Then it hits a plateau at about 560000K, where it stays for about a second or so. Then it drops about 115MB in a tiny fraction of a second, then trickles down to nothing. This behaviour is exhibited in Python 1.5.2, 2.1.1, and 2.2a3. My questions are: 1) Why does the speed of allocation change? 2) How come there is a large drop in memory when deallocating, then a (slightly) more gentle descent? 3) Is this exhibited on other operating systems? **NOTE: I'm running this under 768MB of RAM, so people with less RAM should use a smaller number in range() to test. -- Ignacio Vazquez-Abrams From tilinna at iobox.fi Thu Sep 13 05:47:41 2001 From: tilinna at iobox.fi (Timo Linna) Date: 13 Sep 2001 02:47:41 -0700 Subject: WBMP support for PIL? Message-ID: <50accedd.0109130147.13ceb56c@posting.google.com> Hi, Has anyone a working link for Duncan Booth's wbmpconvsrc.zip? The only one I know (http://www.rcp.co.uk/distributed/Downloads/) doesn't work anymore. Here's a link to Duncan's original post: http://groups.google.com/groups?selm=8F1B74290duncanrcpcouk%40194.238.50.13 BR, timo From gabriel_ambuehl at buz.ch Sat Sep 29 11:09:54 2001 From: gabriel_ambuehl at buz.ch (Gabriel Ambuehl) Date: Sat, 29 Sep 2001 17:09:54 +0200 Subject: Reading from the serial port? In-Reply-To: References: Message-ID: <6421621359.20010929170954@buz.ch> -----BEGIN PGP SIGNED MESSAGE----- Hello Luis, Saturday, September 29, 2001, 3:08:25 PM, you wrote: > My inquire comes because a few days ago i was checking a router via > the console interface and i thought to write some dumb python > aplication to send the commands and read the answer. In order to do > that i need to be able to open the serial port and cant find any > info around. Please Help You could open /dev/[whateverdevicethereisonyourbox] for r/w.. Best regards, Gabriel -----BEGIN PGP SIGNATURE----- Version: PGP 6.5i iQEVAwUBO7XWNsZa2WpymlDxAQGWSQgAu8zJ4PU01gcR6NSeeWY9yOeJgABfC2uZ jK2LA7FDlAfn8T2dy5woxnMAsEZfYjH13sZmbglo8+iZN9jfB6WZi71zUGwZ5PiA /UM9yz7kIbUQ+9FvCdTMJPcIn3E1EJN8VdXVzP9ePv4MNnSfAogbrTwUgWG4R4jz xt4xgICWaTRMuyq0sQ2J/HeYcI29kBqMWEYovxDR/hDfkmWxwO7ig+QdptyjWeqW LbLEs4aRXdKpuTAgjAm7R5KTp0gRyzcAyJC10xRnulN6sSZjt8Q1lJMVFeyepnY8 ABSmgte+XTki2CgcljYq1mweA4g1eikw++T5rooxu3KoBrNUnpdY6A== =xw/R -----END PGP SIGNATURE----- From rnd at onego.ru Mon Sep 17 00:50:42 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 17 Sep 2001 08:50:42 +0400 (MSD) Subject: Tkinter + threads = trouble? In-Reply-To: <9o36bs$b50se$1@ID-22517.news.dfncis.de> Message-ID: Here is an example I prepared. It runs OK on Linux/X window, but stops dead on Win98SE (do I file a bug report on windows98.sourceforge.net ;-)? (WARNING: Windows could require rebooting to return to normal look) -------------------------------------------------------------- import thread, time, sys from Tkinter import * distance = 300 colors = ["Red","Orange","Yellow","Green","Blue","DarkBlue","Violet"] nrunners = len(colors) def quit(): tk.quit() sys.exit(0) tk = Tk() tk.title("Race") c = Canvas(tk, width=distance, height=len(colors)*20) c.pack() rects = [] for i in range(nrunners): rects.append(c.create_rectangle(0, i*20, 0, i*20+10, fill=colors[i])) champion = StringVar() Label(tk, textvariable=champion).pack() b = Button(text="Go", command=tk.quit) b.pack(side=LEFT) qb = Button(text="Quit", command=quit) qb.pack(side=RIGHT) def run(n): while 1: graph_lock.acquire() positions[n] = x = positions[n] + 1 c.coords(rects[n], 0, n*20, x, n*20+10) tk.update_idletasks() if x == distance: if not champion.get(): champion.set("%s - champion!" % colors[n]) # TROUBLE tk.update_idletasks() graph_lock.release() break graph_lock.release() def prepare(): champion.set("") for i in range(nrunners): c.coords(rects[i], 0, i*20, 0, i*20+10) thread.start_new_thread(run, (i,)) tk.update_idletasks() graph_lock = thread.allocate_lock() while 1: b.config(state=NORMAL); qb.config(state=NORMAL) tk.mainloop() b.config(state=DISABLED); qb.config(state=DISABLED) graph_lock.acquire() positions = [0]*nrunners prepare() graph_lock.release() while reduce(lambda x, y: x+y, positions, 0) < distance*nrunners: time.sleep(0.1) tk.update_idletasks() print champion.get() ---------------------------------------------------------------------- Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Monday, September 17, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Murphy was an optimist." _/ From mlh at idi.ntnu.no Sat Sep 29 14:39:05 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Sat, 29 Sep 2001 20:39:05 +0200 Subject: Justifying text. References: <3BB55DEC.67F78190@yahoo.com> <9p4hjr$h2v$1@neon.noos.net> Message-ID: <9p54ga$loj$1@tyfon.itea.ntnu.no> "Boyd Roberts" wrote in message news:9p4hjr$h2v$1 at neon.noos.net... > "A.A" a ?crit dans le message news: 3BB55DEC.67F78190 at yahoo.com... > > In most traditional heavy-weight text editors written in C, there is an > > option to justify. Do the programmers use a traditional method/formula ? > > the general case is reasonable chunk of code (ie. variable width fonts). > > what do you mean by text? > > a 'text editor' that justifies text is not a text editor. What - you haven't heard of Emacs? And C-u M-q? (I'm sure vi has the same functionality, as does the UNIX program fmt.) -- Magnus Lie Hetland http://www.hetland.org "Reality is that which, when you stop believing in it, doesn't go away." -- Philip K. Dick From ignacio at openservices.net Tue Sep 25 19:26:09 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Tue, 25 Sep 2001 19:26:09 -0400 (EDT) Subject: Validating HTML from Python In-Reply-To: <3BB1113D.6464070A@thinkware.se> Message-ID: On Wed, 26 Sep 2001, Magnus Lycka wrote: > I'm currently writing some programs that produce HTML. > I'd like to validate the HTML in my unittests. > What is the simplest solution for that? > > [snip] > > This doesn't have to be a "pure python" solution as > long as it's simple to access from python, and works > on Windows and Linux. http://tidy.sourceforge.net/ -- Ignacio Vazquez-Abrams From tjreedy at home.com Wed Sep 12 13:12:06 2001 From: tjreedy at home.com (Terry Reedy) Date: Wed, 12 Sep 2001 17:12:06 GMT Subject: Proposed PEP for a Conditional Expression References: <6qvgire4bk.fsf@abnoba.intevation.de> <9nk3jd$4lc$1@glue.ucr.edu> <9nnsa3$bjl$1@news.mathworks.com> Message-ID: "Joshua Marshall" wrote in message news:9nnsa3$bjl$1 at news.mathworks.com... > thp at cs.ucr.edu wrote: > > Bernhard Herzog wrote: > > [...] > > : Another way that come to mind: > > > : if else > > One thing I don't like about this suggestion is that is > evaluated before the first is [potentially] evaluated, even > though syntactically precedes . I agree that the above is backwards. if else would remove that objection and make the syntax parallel to ? : Terry J. Reedy From jdhunter at nitace.bsd.uchicago.edu Mon Sep 24 16:00:02 2001 From: jdhunter at nitace.bsd.uchicago.edu (John Hunter) Date: 24 Sep 2001 15:00:02 -0500 Subject: CrossProductSweeper References: <1rn1439eux.fsf@video.bsd.uchicago.edu> Message-ID: <1rwv2otl4t.fsf@video.bsd.uchicago.edu> >>>>> "Marcin" == Marcin 'Qrczak' Kowalczyk writes: Marcin> Generators which are a recent feature of Python make it Marcin> much easier. Here is an example - works with Marcin> Python-2.2a1: Thanks for the examples. Any good links where I can read about generators? One thing missing from this implementation is the is_end_of_loop feature that CrossProductSweeper has, which is something that I often use in practice, like computing some summary stats at the end of each inner loop. Any way to get this with the generator approach? Thanks, JDH From brueckd at tbye.com Wed Sep 5 19:48:52 2001 From: brueckd at tbye.com (brueckd at tbye.com) Date: Wed, 5 Sep 2001 16:48:52 -0700 (PDT) Subject: SocketServer In-Reply-To: <01090516293000.23511@magneto> Message-ID: On Wed, 5 Sep 2001, Charles wrote: > Anybody know where ca i find a good tutorial or > examples to create a Socket Server ? Hi Charles, The BaseHTTPServer (which uses SocketServer) has a test() function that should help you. -Dave From guido at python.org Sun Sep 9 01:38:50 2001 From: guido at python.org (Guido van Rossum) Date: Sun, 09 Sep 2001 05:38:50 GMT Subject: typechecks: just say no! (was Re: Determining Types) References: <9mvo0u04o8@enews2.newsguy.com> <3b938f31.2123170@nntp.sprynet.com> Message-ID: ullrich at math.okstate.edu (David C. Ullrich) writes: > But in other places it's good to be able to refer to > fields with non-literal names, so I add a __getitem__ > so that rec['thisfield'] returns rec.thisfield. > (Actually the main reason I want this is so that I > can use a Rec as a mapping in a string format thing: > > 'Your name is %(Name)s' % rec) > > In yet other places I want to iterate over the fields > of a record, as in > > for key, value in rec: > > So in __getitem__ I check the type of index, returning > getattr(self, index) if index is a string and saying > > fieldname=self.__fieldnames__[index] > return (fieldname, getattr(self, fieldname)) > > if index is an integer. In 2.2, you can define an iterator rather than overloading __getitem__. --Guido van Rossum (home page: http://www.python.org/~guido/) From donn at u.washington.edu Tue Sep 11 14:05:13 2001 From: donn at u.washington.edu (Donn Cave) Date: 11 Sep 2001 18:05:13 GMT Subject: os.spawn References: Message-ID: <9nljop$26dq$1@nntp6.u.washington.edu> Quoth syt at pegasus.logilab.fr (Sylvain Thenault): | how can I do for knowing what happend when I do an os.spawnv() | | for example, if i do | | import os | os.spawnv(P_WAIT, '/bin/echo', 'this is a spawn test') | | I can't see anything, and don't know what have been made... Normal return from os.spawnv should be 0. Anything else indicates failure. >>> print os.spawnv.__doc__ spawnv(mode, file, args) -> integer Execute file with arguments from args in a subprocess. Args here should be a tuple or list like sys.argv: os.spawnv(os.P_WAIT, '/bin/echo', ('echo', 'this is a spawn test')) Donn Cave, donn at u.washington.edu From mmhamze at pleiades.net Mon Sep 3 12:57:12 2001 From: mmhamze at pleiades.net (Maan Hamze) Date: Mon, 03 Sep 2001 16:57:12 GMT Subject: cgi type=file problems References: Message-ID: Dag If I understand you correctly, you need to be able to browse for a file in a form that contains: Case 1: using enctype=multipart/form-data #put in your own values Then you want to browse and be able to get the file name that you pick from the browse button. If you submit this form using: import cgi form cgi.FieldStorage() print form["userfile"].value What you get is not the file name but the actual file (binary or text). To get the actual string in the field use: import cgi form cgi.FieldStorage() print form["userfile"].filename This prints the actual string in the field. Case 2: if you do not use enctype=multipart/form-data THEN print form["userfile"].value does give you the actual string used through the browse button. And print form["userfile"].filename prints None does this cover what you want? Maan "Dag" wrote in message news:mailman.999512165.15540.python-list at python.org... > > > > On 3 Sep 2001, Dag wrote: > > D> I have a HTML form with a type=file input element and I simply want to > > D> get the file name as a string. I'm not interested in the actual file. > > D> However the value from the file part of the form doesn't seem to get > > D> passed at all. > > D> For example I have the following form and script; > > D> > > D>
> > > > enctype="multipart/form-data"> > > Thanks, but unfortunately this doesn't quite seem to work the way I want it > to. adding enctype="multipart/form-data" seems to makes the script upload > the entire file, which is something I want to avoid, since I only need the > filename and just want to use the file browsing to simplify entering the > data, and make sure no typos are made. Copying several megs across the > network to simply extract a 50 byte string seems a bit of a waste. > > Dag > > From tim.one at home.com Fri Sep 7 17:17:24 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 7 Sep 2001 17:17:24 -0400 Subject: functional vs procedural list comprehension In-Reply-To: Message-ID: [Peter Dobcsanyi] > ... > I would be interested in the reasons for the procedural choice and > arguments for functional vs procedural behavior. I wouldn't. If somebody wants faster listcomps, don't argue about it, implement it. If it actually has a killer speed advantage, have faith that Guido will rationalize away any change in semantics -- but first be sure there actually is a killer speed advantage. potential-isn't-always-easy-to-actualize-ly y'rs - tim From facelle at jumpy.it Thu Sep 27 13:57:01 2001 From: facelle at jumpy.it (Fabrizio) Date: Thu, 27 Sep 2001 19:57:01 +0200 Subject: R: Py2exe beginner troubles References: <9ot7pg$ci1$1@serv1.albacom.net> <9ot8an$f0fau$1@ID-59885.news.dfncis.de> Message-ID: <9ovov0$6qk$1@serv1.albacom.net> Thank you, now it works ! By the way, is PIL (Python Imaging Library) supported by py2exe ? I have tried it, but I got an error message. Thanks in advance, Fabrizio C. Thomas Heller wrote in message 9ot8an$f0fau$1 at ID-59885.news.dfncis.de... > > "Fabrizio" wrote in message news:9ot7pg$ci1$1 at serv1.albacom.net... > > Hi, > > > > I am trying to use Py2exe to build a standalone executable of a very basic > > program (see below), but with no luck. > > > > This is what I get: > > > > error: invalid command 'py2exe' (no module named 'distutils.command.py2exe') > > > > > > What am I doing wrong ? > The common mistake which leads to this problem is to > have your scripts in the python\py2exe directory. > > Move your script and your setup.py file somewhere else, > and it will work. > > py2exe is a package containing a module named py2exe, > and executing 'import py2exe' in the package directory > will pick up the module instead of the package. > I think i will have to rename the module to something else... > > Thomas > > From apetala2 at yahoo.com Tue Sep 25 12:40:35 2001 From: apetala2 at yahoo.com (MA Booker) Date: 25 Sep 2001 09:40:35 -0700 Subject: Pasting from clipboard with Tkinter Message-ID: <73068d8d.0109250840.38f51147@posting.google.com> I'm a bit of a newbie with Tkinter, and I've developed a fairly simple entry screen application with Tkinter and Python Mega Widgets. This application is being used on a Windows NT machine. The application has a series of entry fields packed one below the other. I can copy a single line of text from another Windows application and use Ctrl-v to paste it into one of the entryfields. However, if I copy multiple line from another program (such as Notepad, Excel, Word, etc.), all of the copied text appears in one entry like this: Entry 1: line1[square]line2[square]line3 Entry 2: Entry 3: I'm assuming that the little [square]'s correspond to CR and/or NL characters What I want it to do is this: Entry 1: line1 Entry 2: line2 Entry 3: line3 Basically, I have a user that wants to copy a column from an Excel spreadsheet into the series of entries, and I cannot figure out how to get it to work. Any ideas out there? From aleax at aleax.it Thu Sep 6 07:46:49 2001 From: aleax at aleax.it (Alex Martelli) Date: Thu, 6 Sep 2001 13:46:49 +0200 Subject: pymacs! :-) References: <9n5pch$806$1@animus.fel.iae.nl> Message-ID: <9n7nna02mai@enews1.newsguy.com> "Carel Fellinger" wrote in message news:9n5pch$806$1 at animus.fel.iae.nl... > Fran?ois Pinard wrote: > ... > > My real end goal is using Python instead of LISP for an extension language > > for Emacs, as needed. I'm jealous of "vim" users! :-) > > Me too, I even tried to wrap my mind to dig the modes of vim, but in vain. I think that's because the mind is not the part that learns the modes: it's rather the fingers. If I stop to think out "what mode am I in" when editing, my performance drops to even lower than it is with non-vi-based editors -- if I just let my fingers fly and keep my mind on more strategically oriented issues, such as "what am I supposed to be writing about", then the speed is excellent and my hands don't get tired as they do with other editors... It's like walking -- if you think about exactly where and how you should be moving and placing each foot, you'll walk slowly and haltingly; your _feet_ are the parts of you that really knows about walking's low-level issues, so, use your mind for strategic overview instead, don't let it micro-manage the feet, and stroll happily along:-). Alex From aleax at aleax.it Mon Sep 17 04:02:25 2001 From: aleax at aleax.it (Alex Martelli) Date: Mon, 17 Sep 2001 10:02:25 +0200 Subject: Why not 3.__class__ ? References: <3v9bqtogrl53sfqor0f81oojaa94tr0qt5@4ax.com> Message-ID: <9o4amf02357@enews4.newsguy.com> "Kirby Urner" wrote in message news:3v9bqtogrl53sfqor0f81oojaa94tr0qt5 at 4ax.com... > > Since I can invoke string methods using string.method() notation, > or go > > >>> 'a'.__class__ > > > why is it that 3.__class__ or 3.__add__(4) are syntax errors. > It looks ugly maybe, but no one says you have to use it. > Why not include for consistency? > > Probably good reasons why not. I'm here to learn. The semantics are there in Python 2.2 alpha 3: C:\Python22>python Python 2.2a3 (#23, Sep 7 2001, 01:43:22) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> (3).__class__ >>> (3).__add__(4) 7 >>> The reason you cannot omit the parentheses around the literal in this case is that "3." is a valid token in and by itself, and lexical analysis takes place first, and by a "maximal munch" strategy (simplest, after all). As long as you work around the tokenization issue, the rest works fine, e.g.: >>> 3 .__class__ >>> 3..__class__ >>> 3L.__class__ >>> 0x3.__class__ The whitespace, or the trailing . or L, or the leading 0x, all suffice to tell the tokenizer that the dot before the attribute name is a separate token from the literal, just as do the parentheses used earlier. But tokenizing "3.whatever" as anything different from a "3." token followed by a "whatever" token would break backwards compatibility -- and it's definitely NOT worth the BIG hassle to make the tokenizer way more complicated to deal with this single, specific case, rare and marginal, by making the tokenization of "3.whatever" depend on the "whatever" or even wider syntax issues. E.g., >>> 3.and 4 4 this MUST keep lexing with 3. first -- and having "3." tokenize differently depends on what FOLLOWS it would make everything horribly more convoluted. C++ has a similar issue, which comes up MUCH more often, since it also uses maximal-munch tokenizing (one rare case where C++ has chosen simplicity:-): ">>" is a single token (shift-right), but ">" as a token is widely overloaded and in particular "<" and ">" are used as 'parentheses' for templates, so a VERY common beginner's mistake is to write: std::vector> myvar; which gives a syntax error because the ">>" tokenizes as "shift-right" which is incorrect here; so one soon learns to write, e.g.: std::vector< std::list > myvar; where the space in "< std" is irrelevant, but is generally used for symmetry, while the space in "> >" is absolutely crucial (it ensures each ">" is seen as a separate token). Python tries to avoid overloading characters, but a few cases are inevitable, to have both the nice "3." notation for floating-point literals AND the nice "x.feep" notation for attribute access -- the dot must be overloaded lexically. Alex From kent at goatnospamhill.org Thu Sep 27 10:45:05 2001 From: kent at goatnospamhill.org (Kent Polk) Date: 27 Sep 2001 14:45:05 GMT Subject: Is xmlrpclib slow? References: <9ov48m$eao$1@tyfon.itea.ntnu.no> Message-ID: <1001602255.345648@fezzik.endicor.com> On Thu, 27 Sep 2001 13:58:14 +0200, Magnus Lie Hetland wrote: > > I've been working on a little server lately, and I've > been toying with using xmlrpc in it... And just for > fun, I thought I'd test its performance. Since I'm > working on a not-quite-up-to-date Sun box, I'm not > quite sure what processor I have... But it seems reasonable. > (Not exactly fast, but OK, e.g. about 10000 records > written to MetaKit takes 1 second.) ... > Is it just the machine I'm using that's really slow, or > is the xmlrpclib module a big bottleneck here? It can be extremely slow with a lot of tags. I have an application that transfers a list of records to be inserted in a database. I first tried sending the data as a list of lists and it took 5 minutes for the server, a 333MHz Ultra 5, to decode the data for about 500k of data, mostly very small record items. I then used string.join to join the record lists with a unique separator and it took about one minute to decode and split the strings back into records. Then I did similar with the records and it's down to about 3 seconds to decode (one big string) and split the data back into a list of lists. So I would recommend that one consider bundling up the data into a simple data type before sending with xmlrpc. From aleax at aleax.it Sun Sep 16 10:25:03 2001 From: aleax at aleax.it (Alex Martelli) Date: Sun, 16 Sep 2001 16:25:03 +0200 Subject: Python errors messages in Windows References: Message-ID: <9o2cnv$nqc$2@lancelot.camelot> Vesselin Peev wrote: > Dear Colleagues, > > Does anyone know about a straightforward way of capturing the Python error > messages in a Windows application embedding Python? That is, is there are > version of PyErr_Print not using stdout? PyErr_Print doesn't use stdout. Rather, it uses sys.stderr. Therefore, capturing the error messages is indeed straightforward -- just bind sys.stderr to your favourite file-like object, e.g. an instance of type cStringIO.StringIO, and its contents will be the "capture" you want. Alex From flognat at flognat.myip.org Fri Sep 21 11:08:23 2001 From: flognat at flognat.myip.org (Andrew Markebo) Date: Fri, 21 Sep 2001 15:08:23 GMT Subject: The $HOME of Windows. References: <9of6vk$e9q$1@norfair.nerim.net> <5328070.CHz00ifERb@lunix.schabi.de> Message-ID: / Markus Schaber wrote: | Hi, | | Gillou schrub: | | > This is not pure Pyhtonic problem but... | > I'm looking for a place to store user settings in a portable Python | > app. For Unix users, I use ~/.myapp.defaults | > What's the equivalent for Windoze (I don't want to use the registry). | > Knowing that the path to this "My documents" folder depends on wether | > it's Win98, Win2000 (...) and on the locale. | | As far as I know, the Multi User Wins (NT, 2000, XP) and - when using a | network profile from a Win PDC also 9X/ME - define an environment | variable HOME that points to the users home directory. Nope they (WinNT/2k/XP) don't, but they normally define: HOMEDRIVE HOMEPATH HOMESHARE /Andy -- The eye of the beholder rests on the beauty! From jamesm at xyke.com Mon Sep 24 22:12:51 2001 From: jamesm at xyke.com (james m) Date: 24 Sep 2001 19:12:51 -0700 Subject: Threading and the HTTPD server classes Message-ID: I've created a simple http server based on the code given in the python library reference. Next, I would like to spin this server off into another thread of execution. I find that calling t = threading.Thread(None, my_httpd_proc) t.start() t.isAlive() yields a live thread, but the web browser (IE) complains that it cannot find server / DNS. If I modify the httpd function so that threading.Thread() is called on httpd.serve_forever then everything works correctly. The web browser connects and displays the root of the IDLE tree. This is the code: ## Begin code def httpd(): import BaseHTTPServer import SimpleHTTPServer print "begin jem_httpd" server_class = BaseHTTPServer.HTTPServer handler_class = SimpleHTTPServer.SimpleHTTPRequestHandler server_address = ("jamesmcn-i8k", 3380) httpd = server_class(server_address, handler_class) print ("about to serve forever") httpd.serve_forever() def threaded_httpd(): import BaseHTTPServer import SimpleHTTPServer import threading print "begin jem_httpd" server_class = BaseHTTPServer.HTTPServer handler_class = SimpleHTTPServer.SimpleHTTPRequestHandler server_address = ("jamesmcn-i8k", 3382) httpd = server_class(server_address, handler_class) print ("about to serve forever") t = threading.Thread(None, httpd.serve_forever) t.start() print t.isAlive() ## End code threaded_httpd() works correctly. httpd() works, but stalls the IDLE process t2 = threading.Thread(None, httpd()) t2.start() appears to do nothing. Why? Thanks! -james From phd at phd.pp.ru Tue Sep 11 03:46:22 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 11 Sep 2001 11:46:22 +0400 Subject: Python and Zope In-Reply-To: ; from tim@vegeta.ath.cx on Mon, Sep 10, 2001 at 11:30:12PM +0000 References: <9nettc$ce1$1@slb7.atl.mindspring.net> Message-ID: <20010911114622.D26326@phd.pp.ru> On Mon, Sep 10, 2001 at 11:30:12PM +0000, Tim Hammerquist wrote: > > We are talking about "Apache vs web-application servers". In this > > context modules are so like CGIs (forked and killed) so I don't need to > > make a distinction. > > We probably just have a Point-Of-View problem. I'm thinking of CGI in > the strict sense of an application designed to produce web content using > STD filehandles and environment variables. In all fairness, my ftpd > conforms to your (most recent) definition of CGI, as do half of the > daemons on my system. In this "web-application server" context - they are! :) Because thay cannot hold a persistent DB connection. > I probably took offense to the picture you painted of Apache, being a > ruthless, discompassionate Nazi of a daemon, kill arbitrarily, which > is, of course, not true. If I have a module that have opened DB connection - how can I prevent Apache from killing the child (because I want to hold that connection open)? Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From aleax at aleax.it Wed Sep 12 11:09:26 2001 From: aleax at aleax.it (Alex Martelli) Date: Wed, 12 Sep 2001 17:09:26 +0200 Subject: Proposed PEP for a Conditional Expression References: <6qvgire4bk.fsf@abnoba.intevation.de> <9nidrm01j7q@enews1.newsguy.com> <9nk4t8$4qq$1@glue.ucr.edu> <9nkmjj01rha@enews3.newsguy.com> <9nnf0d$5qf$2@glue.ucr.edu> <9nnigp02g7a@enews1.newsguy.com> Message-ID: <9nntr703057@enews1.newsguy.com> "Marcin 'Qrczak' Kowalczyk" wrote in message news:slrn9purii.765.qrczak at qrnik.zagroda... > Wed, 12 Sep 2001 13:56:09 +0200, Alex Martelli pisze: > > > I think the proposed conditional operator would be just about at > > the threshold (I wouldn't particularly care either way if it got in > > or stayed out) EXCEPT for the risk that it may in fact encourage > > people to write more lambda's rather than named local functions, > > which I see as a substantial minus. > > If we prefer list comprehensions to for loops with appends, > in this case it encourages in the right direction. Good point! Yes, a conditional operator might be of some help in writing a list comprehension in certain cases. I can't think, offhand, of a real-life example where I felt that need, but theoretical examples are easy to construct. Alex From aaronf at NOSPAMtelusplanet.net Wed Sep 19 23:19:45 2001 From: aaronf at NOSPAMtelusplanet.net (Aaron Fransen) Date: Thu, 20 Sep 2001 03:19:45 GMT Subject: New Python WebMail app References: Message-ID: Hm, I understand your concern Roman, but for the purposes of my "customer base" if you will, the functionality of HTML 3.2 simply didn't provide the tools I needed to complete the app. Alex: Yeah, Mozilla 6 does support IFRAME...but only as a display window, not as an edit window. This is where I wonder what Microsoft's motives were: Was IFRAME designed within the HTML spec to be an editing window? Or is this a Microsoft hack? The scuttlebutt is that some future version of Mozilla (near? far?) will support some kind of rich-text editing function, and whether that will be IFRAME or not is anyone's guess...except the developers of Mozilla of course :) "Roman Suzi" wrote in message news:mailman.1000729400.18090.python-list at python.org... > On Mon, 17 Sep 2001, Alex Martelli wrote: > > > "Aaron Fransen" wrote in message > > news:fQxo7.43891$Gi6.5026247 at news0.telusplanet.net... > > ... > > > It's got address books, HTML support (like HotMail, but only on IE of > > > course...at least until Netscape and Opera suppor the IFRAME tag), a full > > > > Mozilla 6 does support IFRAME (which is perfectly good standard HTML 4.01 > > after all), so I would expect Netscape 6 to (doesn't it...?) -- see > > http://www.mozilla.org/docs/web-developer/upgrade_2.html. Opera 5 also > > support IFRAME, of course. So does KDE's Konqueror. > > > > Netscape 4.* is, of course, a zombie -- a walking dead still going > > around doing damage. (Yes, yes, I know I used exactly the same > > metaphor to describe DDE a week or so ago -- feels completely apt > > in both cases to me). There are (barely) enough copies of NS 4 > > still in use, as to inhibit web designers who need to reach a > > really wide audience from using standard HTML -- just because > > a browser designed many years ago was unable to support the correct > > standard and some people (who understandably don't want to upgrade > > to NS6, heavier and still rather buggy; and, less understandably, > > don't want to move to light, fast, solid Opera, or to any of the > > several decent open source browsers around) stick with it. Sigh. > > Nonetheless, some of us use Netscape 3. And I still use Netscape 4 while > waiting for stable Mozilla. > > And, of course, those who has something to say use HTML 3.2 ;-) Everything > else is for special needs. Usually sites with "heavy design" are empty > information-wise and on the contrary, those who has good content to share > could use simpler means. I really hate when site is using some js instead > of a-href. > > > Sincerely yours, Roman A.Suzi > -- > - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - > > From mmhamze at pleiades.net Fri Sep 14 18:14:41 2001 From: mmhamze at pleiades.net (Maan Hamze) Date: Fri, 14 Sep 2001 22:14:41 GMT Subject: Newbie Question.. What is the replacement for the ELSE command?. References: Message-ID: Cable Can you give an exact example of Python code with 'else' that is not working? Please include all indentations with the code you are using. something that works, say for example: if x==1: print 'happy' else: print 'sad' Maan "Cable" wrote in message news:qiv4qtkbhi5tgeb2knf14m4r5ikh9jesf1 at 4ax.com... > I am trying to teach myself Python. All the online tutorials, have > examples with the else command. I cant get it to work is there a > replacement? > > Thanks. From jblazi at hotmail.com Sat Sep 22 07:54:20 2001 From: jblazi at hotmail.com (Janos Blazi) Date: Sat, 22 Sep 2001 13:54:20 +0200 Subject: Tkinter questions Message-ID: <3bac7bfd_5@news.newsgroups.com> (1) How can I find out the actual height of a frame and create another frame of the same height containing a canvas of the same height? Grayson says that sizing an object can be a frustrating task... (2) How can I set the width of the entry field of a Pmw.CounterDialog? To show you my desparation I tried (among many other things) z.Counter.entryfield.entry.configure(width=3) (where z is a Pmw.CounterDialog instance) but of course iit did not work. J.B. -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! Check out our new Unlimited Server. No Download or Time Limits! -----== Over 80,000 Newsgroups - 19 Different Servers! ==----- From cfelling at iae.nl Wed Sep 5 14:02:57 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 5 Sep 2001 20:02:57 +0200 Subject: pymacs! :-) References: Message-ID: <9n5pch$806$1@animus.fel.iae.nl> Fran?ois Pinard wrote: ... > My real end goal is using Python instead of LISP for an extension language > for Emacs, as needed. I'm jealous of "vim" users! :-) Me too, I even tried to wrap my mind to dig the modes of vim, but in vain. > We could progressively build a cache about whether LISP symbols are `boundp' > or `fboundp' or not, and use that information afterwards. (Underlines would > be translated to dashes, of course.) For the rest, I wonder if I could not > replace __builtins__ with an instance of a class of my own. Any other idea? Like Marcin, I would prefer a lisp.fun notation. And as many lisp names use funny characters like -, I suggest adding a [] interface as well, so we easily can access those weird emacs names like in count = lisp["1+"](count) -- groetjes, carel From qrczak at knm.org.pl Tue Sep 4 13:53:20 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 4 Sep 2001 17:53:20 GMT Subject: newbie question - executing system commands References: <9n23h1$qsc$1@news.formus.pl> <9n2o1m09se@enews3.newsguy.com> Message-ID: Tue, 4 Sep 2001 16:21:35 +0200, Alex Martelli pisze: >> for IMAGE_NAME in `ls`; do { >> #processing of $IMAGE_NAME >> };done You can omit { } here. The body is already delimited by do and done. > for image_name in os.popen('ls').readlines(): > process(image_name) It's better to use * instead of `ls` in shell and os.listdir('.') or glob.glob('*') in Python. So it won't break on filenames containing spaces. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From skip at pobox.com Sun Sep 30 09:50:01 2001 From: skip at pobox.com (Skip Montanaro) Date: Sun, 30 Sep 2001 08:50:01 -0500 Subject: MySQLdb where's fetchoneDict()? In-Reply-To: <112484592256.20010930103925@buz.ch> References: <112484592256.20010930103925@buz.ch> Message-ID: <15287.8969.607364.965202@beluga.mojam.com> Gabriel> I wonder whether there's a fetchoneDict() equivalent to Gabriel> fetchallDict() in version 0.9 in case one wants to fetch only Gabriel> one row and thus don't want to have the data in a a list of Gabriel> dictionaries. (The reason I don't just want to use fetchone() Gabriel> is that I've got tables with some 20 fields and it's rather Gabriel> hard to handle that many fields in a tuple when you have only Gabriel> numerical indexes in order to access them...). Gabriel, When you create the database connection you can specify the type of cursor to use by passing a cursorclass parameter, e.g.: self.db = MySQLdb.Connection(host=self.host, user=self.user, passwd=self.password, db=self.database, cursorclass=MySQLdb.cursors.DictCursorNW) Try pydoc.help(MySQLdb.cursors) for all the possibilities... -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From scholey at totalise.co.uk Sun Sep 23 05:51:03 2001 From: scholey at totalise.co.uk (Sam Scholey) Date: Sun, 23 Sep 2001 10:51:03 +0100 Subject: GUI? Message-ID: Hi There, I am a programming newbie and was told that Python would be a good first language because of its extensive documentation and clean, readable code. Anyway, it sounds great as a scripting language and I wanted to know if Python can create GUI applications?, perhaps using GTK? Thanks From boyd at insultant.net Fri Sep 21 21:49:46 2001 From: boyd at insultant.net (Boyd Roberts) Date: Sat, 22 Sep 2001 03:49:46 +0200 Subject: "shell-commands" and python! References: Message-ID: <9ogqtb$oe8$1@quark.noos.net> > On Fri, 21 Sep 2001, Greg Weeks wrote: > > < > >> 2> 2>> 2>&1 # REDIRECTION if you want perl, you know where to find it. From cce at clarkevans.com Wed Sep 5 20:40:01 2001 From: cce at clarkevans.com (Clark C . Evans) Date: Wed, 5 Sep 2001 20:40:01 -0400 Subject: list comprehensions: sorting? Message-ID: <20010905204001.B12124@doublegemini.com> As an SQL junkie... I've gotten addicted to list comprehensions like... especially in list of tuples... [process(x) for x in mylist if x[4] I read the above as something like... SELECT process(x) FROM mylist AS x WHERE x[4] What I always want to do is "sort" in this context, let's say on column two; something like an ORDER BY clause. Here is the best I can think of... newlist = [x for x in mylist if x[4]] newlist.sort(lambda x,y: cmp(x[2],y[2])) That's ok... but I'd like to have a nicer way to say "sort by column #2" ; preferably as part of the longer expression... [process(x) for x in list if x[4] sortdesc x[2] ] Where "sortdesc" is an expression that I want the list sorted by descending. This would make my code much more readable... Thoughts? Any better alternative to what I'm writing above? Best, Clark From jdhunter at nitace.bsd.uchicago.edu Wed Sep 5 17:57:25 2001 From: jdhunter at nitace.bsd.uchicago.edu (John Hunter) Date: 05 Sep 2001 16:57:25 -0500 Subject: reading floats from file References: <1ru1yid6u7.fsf@video.bsd.uchicago.edu> <3B955B3A.2070402@visionart.com> Message-ID: <1r8zftxpve.fsf@video.bsd.uchicago.edu> >>>>> "Pete" == Pete Shinners writes: Pete> John Hunter wrote: >> I have a file of ascii data arranged as a matrix of floats, eg >> 0.3125 0.9418 1.2843 0.924516 0.92855 0.3125 0.6593 1.2843 >> 0.900514 0.900914 0.1667 0.9757 1.5611 0.893318 0.893699 I want >> to read this data and process it a line at a time This works: >> fh = open(dataDir + 'freqs_and_amps.dat') for line in >> fh.readlines(): line = re.sub('^[ ]+', '', line) x = map(float, >> re.split('[\r\n\t ]+', line[0:len(line)-1])) Pete> strings already have a split() method that will split the Pete> string based on whitespace. no need to bring RE into the mix Pete> for this. Thanks for the response. How about this: is this the best way to print a row of floats to a file? x = (1.0, 2.0, 3.0, 4.0) fOut.write( string.join( map( str, x ) ) + '\n' ) Thanks, John Hunter From karthikg at aztec.soft.net Wed Sep 12 05:29:41 2001 From: karthikg at aztec.soft.net (Karthik Gurumurthy) Date: Wed, 12 Sep 2001 14:59:41 +0530 Subject: python equivalent of wantarray() : newbie In-Reply-To: <3B9F14DD.3B9CC835@telia.com> Message-ID: please bear with me, am still learning. is there a way to determine whether a return value is expected from a method? like the way wantarray() works in perl. perl can determine the type of the variable used @array = call()//so it's list context so call can return a list $var = call()//scalar context so call can return say a string. But can python determine the same?? i guess it can't and that's why we don't have a wantarray() equivalent in python?? thanks, karthik. From skip at pobox.com Fri Sep 14 08:37:46 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 14 Sep 2001 07:37:46 -0500 Subject: Proposed PEP for a Conditional Expression In-Reply-To: <5293894.qXVLH7GnMW@lunix.schabi.de> References: <3BA00239.DECE6412@cosc.canterbury.ac.nz> <5293894.qXVLH7GnMW@lunix.schabi.de> Message-ID: <15265.64026.317978.237539@beluga.mojam.com> Markus> What about "(: return [else return : return else: return -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From greg at electricrain.com Fri Sep 7 19:22:16 2001 From: greg at electricrain.com (Gregory P. Smith) Date: Fri, 7 Sep 2001 16:22:16 -0700 Subject: McMillan Installer or Py2Exe? In-Reply-To: <270c68fe.0109051808.600a9a82@posting.google.com>; from web.mail@lycos.com on Wed, Sep 05, 2001 at 07:08:57PM -0700 References: <270c68fe.0109051808.600a9a82@posting.google.com> Message-ID: <20010907162216.B5796@zot.electricrain.com> On Wed, Sep 05, 2001 at 07:08:57PM -0700, Alan Green wrote: > We've used the McMillan Installer very successfully, but we're just > starting a new project and there also seems to be quite a buzz around > py2exe. > > Has anybody experience of both the McMillan Installer and Py2Exe and > care to comment on their relative strengths? I have used both. I personally find py2exe easier to control, use and understand since it is based on distutils. However recent versions of Gordons Installer can apparently make standalone packages on linux in addition to windows so it does have some neat benefits. From peter at engcorp.com Wed Sep 26 09:58:48 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 26 Sep 2001 09:58:48 -0400 Subject: python script plug-in? References: <3BB2114E.1CF6370A@gol.ge> Message-ID: <3BB1DF18.18C7BF6E@engcorp.com> Giorgi Lekishvili wrote: > > why don't exist a plug-in enabling one to make python scripts? it would > be not bad to make also python server pages.... > Or, does this exist? Is there anybody doing these? The Windows distribution (with win32all I suppose) can be used within Internet Explorer for Active Scripting, which sounds equivalent to what you are suggesting as a "plug-in", I think. There are many equivalents to "python server pages", including things that are far more sophisticated. So the answers are "yes", and "yes". -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From heikowu at ceosg.de Sat Sep 1 09:42:42 2001 From: heikowu at ceosg.de (Heiko Wundram) Date: Sat, 1 Sep 2001 15:42:42 +0200 Subject: COM/CORBA/DCOP (was: Hello people. I have some questions) References: Message-ID: <9mqoc8$kln$02$1@news.t-online.com> Bruce Sass wrote on Fri, 31 Aug 2001 13:02:54 -0600 (MDT): > Another faction (KDE) has DCOP. They started out using CORBA, iirc, > but then went their own way. Is DCOP even fancier than CORBA, or > are they just being different?. Is it possible to get COM, CORBA, and > DCOP to talk to each other? Hmm... I dunno whether you can get them to talk to each other, but about DCOP: It is basically an RPC-interface that is directly bound to KDE's class structure, and which is also quite "simplistic", unlike Corba, etc. What the KDE people said was that they wouldn't need all the features Corba had to offer, and so they chose for something that would be simpler to implement, and out came DCOP. Just my 2 cents contribution on this topic. ;) Heiko W. From max at alcyone.com Tue Sep 4 11:17:27 2001 From: max at alcyone.com (Erik Max Francis) Date: Tue, 04 Sep 2001 08:17:27 -0700 Subject: Can I set up a developers environment and make an exe in windows? References: <3b94cca4.48865344@news.sttl.uswest.net> <9n2mvk0837@enews3.newsguy.com> Message-ID: <3B94F087.822F72B8@alcyone.com> Alex Martelli wrote: > Yes, it's quite possible, and OH YES, it IS worthwhile. I have > very high C++ proficiency (top percentile according to Brainbench, > or I wouldn't be an MVP of theirs) yet my Python productivity is > *WAY* higher -- 2 to 10 times in most realms. One can certainly be more productive in Python than in C++. There's another, slightly orthogonal factor, as well: As a programmer by profession, I write C++ code at work. When I come home and want to do recreational programming, I'm much more likely to be interested in programming in some other, simpler language, than in C++. Python fits that bill very nicely. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Only the ephemeral is of lasting value. \__/ Ionesco The laws list / http://www.alcyone.com/max/physics/laws/ Laws, rules, principles, effects, paradoxes, etc. in physics. From skip at pobox.com Thu Sep 27 22:39:47 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 27 Sep 2001 21:39:47 -0500 Subject: scanf style parsing In-Reply-To: <3BB3D2F5.872BC907@cosc.canterbury.ac.nz> References: <3BB16A50.BAE082FE@cygnus-software.com> <3BB2C7DA.F63EEAA7@cygnus-software.com> <3BB3D2F5.872BC907@cosc.canterbury.ac.nz> Message-ID: <15283.58099.710978.373810@beluga.mojam.com> Greg> The syntax conventionally used for REs is atrocious for anything Greg> beyond the simplest cases, IMO. Yeah, that's why Ping wrote the module he did (can't remember the name at the moment) that sits as a layer above the old regex module. In my own stuff I wrote an application-specific higher-level encoding that "compiles" to regular expressions: http://musi-cal.mojam.com/help-patterns.shtml It can generate some truly horrendous regular expressions, and I'm not doing anything particularly fancy. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From MarkH at ActiveState.com Mon Sep 10 03:56:18 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Mon, 10 Sep 2001 07:56:18 GMT Subject: Pythonwin and .NET References: <3B997A5E.6010801@bigpond.net.au> <9nfei002hac@enews1.newsguy.com> Message-ID: <3B9C72EE.5020504@ActiveState.com> Alex Martelli wrote: > ... > I think you're confusing "what shows on the outside of a component" (which > is constrained by CRL rules, etc) with what goes on inside it. I want to > use Python (and others will want Eiffel, or Cobol, or Mercury, etc) because > I am convinced it gives me incredibly good productivity to implement and > consume those externally-constrained interfaces. I may want to use Python > on .NET, or on the JVM, or with COM, etc, if and when deployment issues > make that preferable to (e.g.) classic Python with C/API extensions -- it's > as simple as that. I agree 100% for the few excellent programmers out there, and also for the "shrink-wrapped component" authors. However, the majority of programmers really know only a few languages with a high degree of competence - I know that I do. I am very unlikely to write code in either Mercury or Cobol (or even Perl :). A software house selling a component certainly may choose to, but most users - especially those in the large corporate shops - will not, and will stick with 1-3 languages. Python should have a place here, but this newsgroup is preaching to the choir. Python already has excellent Win32 integration capabilities - so I am unsure what about .NET will suddenly make Python more visible or viable on Windows than the existing Python+COM has. > Sure, many shops won't get it, and will happily go on Cobol'ing or > whatever. Think of it as evolution in action, as Niven and/or Pournelle > used to say:-). If my competitors get half my productivity because they > prefer to use other languages, _I_ am not gonna complain:-). Again, I agree 100%. However, this exact same option is available to them today. I am not sure I see anything in .NET that makes Python *more* attractive than it already is on Windows, and can see a few things that make it less attractive on V1 than C# and VB for .NET, for example. > No, but you're just as certainly *the* guy with the most experience merging > Python and .NET at this point in time, so your opinion carries enormous > weight (and well it should!). Should one be able to sway your opinion, the > prospects of Python on .NET might well change for the better;-). I may have given the wrong impression here :) I believe .NET is very cool, and Python is very cool. But I don't really see much in the marriage of Python and .NET that suddenly creates a whole greater than the sum of the parts. And on the more pragmatic side, there is still *significant* work remaining to be done before Python on .NET is really viable, and I know of no commercial effort underway to implement this. From memory, JPython took a number of years to be considered viable and to transform into Jython. Mark. From dacut at kanga.org Mon Sep 24 10:55:41 2001 From: dacut at kanga.org (David Cuthbert) Date: Mon, 24 Sep 2001 10:55:41 -0400 Subject: Python-TCL (not TCL-Python) References: <3baf38d9$0$390$45beb828@newscene.com> Message-ID: <3BAF496D.2030806@kanga.org> [Note: cross-posted and followups set to comp.lang.python] Frank Bongartz wrote: > Is it possible to execute TCL-Code in Python ? > > Since the TCL-Interpreter ist started, using Tkinter, I wonder if the > TCL-Interpreter is also able to source a ANY TCL-Code. Certainly. As you note, Tkinter does just this. I'm a bit fuzzy on the details, as it has been awhile since I've used Tkinter; however, you will probably get a better response on comp.lang.python. From emile at fenx.com Thu Sep 6 07:22:23 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 6 Sep 2001 04:22:23 -0700 Subject: dictionary and __getattr__ References: Message-ID: <9n7mj2$5sv79$1@ID-11957.news.dfncis.de> You could try: >>> class myDict(UserDict): ... def __getattr__(self, attr): ... return self.data[attr] ... >>> d = myDict() >>> d['a'] = 'this is a' >>> d.a 'this is a' HTH, -- Emile van Sebille emile at fenx.com --------- "Harald Kirsch" wrote in message news:yv28zfsr6e8.fsf at lionsp093.lion-ag.de... Wouldn't it be nice if this would work: d = {'x': 1} print d.x i.e. every entry in a dictionary is also an attribute of the dictionary itself. Is there a class wrapper for that somewhere available? Harald Kirsch -- ----------------+------------------------------------------------------ Harald Kirsch | kirschh at lionbioscience.com | "How old is the epsilon?" LION bioscience | +49 6221 4038 172 | -- Paul Erd?s *** Please do not send me copies of your posts. *** From robin at jessikat.fsnet.co.uk Sat Sep 8 04:34:41 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sat, 8 Sep 2001 09:34:41 +0100 Subject: PyArg_ParseTuple O format semantics References: Message-ID: In article , Tim Peters writes >[Robin Becker] >> Steve Alexander kindly forwarded me a note relating to a change in .... see below > >News to me, and I see nothing about that in the CVS log. The only 2.0.1 >patch to getargs.c plugged a memory leak in vgetargskeywords(); it was >leaving the refcounts on names of keyword arguments too high, when iterating >over a keyword dict. > I guess that might be it. I suppose if anyone had taken action to correct the memory leak then when it was fixed --> 2.0.1 then their extra DECREF would be wrong. >> The documentation doesn't mention any increment so it seems to return a >> borrowed ref. > >The docs are explicit: "any Python object references which are provided to >the caller are borrowed references; do not decrement their reference >count!". > That's what I thought. I guess I hadn't noticed if any leaks were happening. >> I'm using the O flag a bit and would like to know if I should be >> patching to cover the change -->2.0.1? > >Doubt it; there doesn't appeart to be any relevant change in 2.0.1, but I >haven't seen the note you're paraphrasing either. > > This is his included Note ================================================================= Subject: [Zope-dev] Zope (and Python) crashing bug found Date: 06 Sep 2001 02:37:05 -0400 From: Andy Dustman To: zope-dev at zope.org There have been a couple of reports from various people (myself included) about a bug that will cause Zope to mysteriously die and dump core. I myself had the same problem, particularly with MySQLdb on recent versions of Python. I decided I better hunt the bastard down sooner rather than later... Symptoms: Mysterious core dumps fairly early on after starting up MySQLdb, isolated to the first query. After some investigation, I determined that this did not occur with Python 1.5.2 or 2.0, but does occur with 2.0.1, 2.1, and 2.1.1. Now, when calling _mysql.connect(), one of the items that you MySQLdb will pass in is a type conversion dictionary as a keyword argument, i.e. apply(connect, args, kwargs). After injecting some print statements here and there, and some getrefcount(), I found that the refcount on the converter dictionary was going to zero, i.e. getrefcount() returns 1. However, this only happened with Python > 2.0. So I got out diff and found the critical difference between 2.0 (MySQLdb not broken) and 2.0.1 (MySQLdb broken): diff -u -r Python-2.0/Python/getargs.c Python-2.0.1/Python/getargs.c --- Python-2.0/Python/getargs.c Mon Oct 16 17:49:29 2000 +++ Python-2.0.1/Python/getargs.c Sat Mar 31 08:18:35 2001 @@ -1124,6 +1124,7 @@ return 0; } converted++; + Py_DECREF(item); } else { PyErr_Clear(); The general upshot of this is: In versions of Python (numerically) prior to 2.0.1, if you use the O format with PyArgs_ParseTupleAndKeywords() (and possibly also PyArgs_ParseTuple()) to return a PyObject *, you get a new reference. In 2.0.1 and later, you get a borrowed reference and must Py_INCREF() if you want to keep it. In Python 1.5.2, however, doing this causes a memory leak! Since I want to keep compatibility with Python 1.5.2 for now, my solution is this: if (!conv) conv = PyDict_New(); #if PY_VERSION_HEX > 0x02000100 else Py_INCREF(conv); #endif In this example, conv is initialized to NULL, and PyArgs_ParseTupleAndKeywords() may or may not set it to some object pointer if it was passed in. Since Zope is only going to be supporting 2.1 and newer releases, this is not necessary. However, it may be worth auditing the code to see if the O format is being used, and if so, do Py_INCREF()s need to be added. I suspect some might, since with Python 1.5.2, having them there is a memory leak. I'm going to bed now... ================================================================= -- Robin Becker From syt at pegasus.logilab.fr Thu Sep 13 04:14:52 2001 From: syt at pegasus.logilab.fr (Sylvain Thenault) Date: Thu, 13 Sep 2001 08:14:52 +0000 (UTC) Subject: kill a subprocess Message-ID: hi! I wish to know if there is a portable way to kill a subprocess with Python ? -- Sylvain Thenault LOGILAB From loewis at informatik.hu-berlin.de Mon Sep 17 04:33:19 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 17 Sep 2001 10:33:19 +0200 Subject: Tkinter + threads = trouble? References: Message-ID: "Tim Peters" writes: > for-more-info-read-the-tcl/tk-source-code-ly y'rs - tim I'd actually recommend the _tkinter source as a starting point. The fact that Python protects Tcl with a global lock is noteworthy, as it may explain many strange behaviours. This lock, of course, is necessary since Tcl itself is not thread-safe. Regards, Martin From andtherewaswater at yahoo.com Sun Sep 23 01:04:45 2001 From: andtherewaswater at yahoo.com (A.A) Date: Sun, 23 Sep 2001 09:04:45 +0400 Subject: Python for SysAdmins Message-ID: <3BAD6D6D.6D91BA11@yahoo.com> Hello, I'm contemplating writing a (python) module that contains functions necessary for common system administration tasks. With regards to SysAdmin tasks, I feel that Python, while promising, has not been pushed enough. Does such a module sound realistic ? Would it be of real use ? From max at alcyone.com Fri Sep 21 11:55:50 2001 From: max at alcyone.com (Erik Max Francis) Date: Fri, 21 Sep 2001 08:55:50 -0700 Subject: "shell-commands" and python! References: <1001087411.956907@cswreg.cos.agilent.com> Message-ID: <3BAB6306.D9CF4F1A@alcyone.com> Greg Weeks wrote: > But what about the following program invocation perks that we want to > be as > easy in Python as they are in Ksh?: > > < > >> 2> 2>> 2>&1 # REDIRECTION > & # BACKGROUND > | # PIPING > $() or `` # CAPTURING STDOUT Python is not a shell script, so why should it behave exactly the same way. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Human love is often but the encounter of two weaknesses. \__/ Francois Mauriac Alcyone Systems' Daily Planet / http://www.alcyone.com/planet.html A new, virtual planet, every day. From pedroni at inf.ethz.ch Sun Sep 9 20:16:37 2001 From: pedroni at inf.ethz.ch (Samuele Pedroni) Date: Mon, 10 Sep 2001 02:16:37 +0200 Subject: Pythonwin and .NET References: <3B997A5E.6010801@bigpond.net.au> Message-ID: <3b9c06e7@pfaff.ethz.ch> Hi. > > If .NET never has this capability, it will mean that Python itself can > only take advantage of Python's features - so why use the .NET > implementation of Python at all? > I don't get this argument. At least it doesn't work for Jython and the JVM. If it were true nobody would be using Jython. But anybody with the right feeling about when performance is important and when not and grasps Jython knows that is is worth using in many, many cases .... regards, Samuele Pedroni. From db3l at fitlinxx.com Mon Sep 17 14:31:34 2001 From: db3l at fitlinxx.com (David Bolen) Date: 17 Sep 2001 14:31:34 -0400 Subject: How to sort a list? NOT a newbie question. References: <9o4i4h$2ql@ascc.artsci.wustl.edu> Message-ID: "Ken Seehof" writes: > Obviously the policy of python is that all things are sortable. I really > can't imagine how complex numbers got left out. Actually, everything being sortable really hasn't been true ever since objects could implement their own __cmp__ mechanisms (back in 1.5 I think), and thus any object can raise an exception during sorting. I do think it's true that complex numbers are the only built-in types that aren't comparable however, as of 2.1. It doesn't seem like it would be terribly hard to wrap your own class around a complex number and implement __cmp__ if you wanted to create your own definition for comparing complex numbers. The uncertainty as to the "best" manner in which to compare two such numbers was at least part of the reason for leaving it out of the core implementation, but that doesn't prevent anyone from implementing their own approach. This change occurred during Python 2.1 (I believe) along with rich comparisons. The argument at the time was the lack of mathematical meaning in comparing complex numbers (which isn't in my area to judge), but I think that was more along the lines of justifying the behavior than forcing the change. But the most logical argument against such a change I've tended to see since is in fact the case brought up here - being able to sort lists with complex numbers in them, or just in general being able to sort arbitrary, heterogeneous lists. But the latter isn't true in general anyway (as above), and the former can be solved with a private class implementing an acceptable comparison for the particular application domain in question. -- -- 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 g.haering at ___skynamics.com.invalid Thu Sep 20 13:00:00 2001 From: g.haering at ___skynamics.com.invalid (Gerhard =?ISO-8859-1?Q?H=E4ring?=) Date: Thu, 20 Sep 2001 19:00:00 +0200 Subject: How to do * and & C-lang. operations in Python? References: <61f6bfa8.0109200846.77af2300@posting.google.com> Message-ID: <3BAA2090.9090807@___skynamics.com.invalid> Toni Gaya wrote: > I have a variable defined on one module, and want to use _exactly_ the > same variable in other module. Example: > > module1: > a = 1 > > module 2: > import module1 > a = module1.a > Now, I have module1.a value in a, not a reference to module1.a in a > (module2.a). > Assignaments are done by 'value', not by 'reference'. Function calls > are done by 'reference'. How to do assignaments by reference? Use instances of classes. Assignments work by reference with class instances. >>> class A: ... def __init__(self, value): ... self.value = value ... >>> x = A(5) >>> y = x >>> x <__main__.A instance at 007E446C> >>> y <__main__.A instance at 007E446C> >>> y.value 5 >>> x.value = 6 >>> y.value You can see that x and y refer to the same class instance. Gerhard -- Gerhard H?ring skynamics AG g.haering at skynamics.com http://www.skynamics.com From paul at boddie.net Mon Sep 10 11:11:43 2001 From: paul at boddie.net (Paul Boddie) Date: 10 Sep 2001 08:11:43 -0700 Subject: language growth References: <1000085015.952637@cswreg.cos.agilent.com> Message-ID: <23891c90.0109100711.3ea4ce41@posting.google.com> weeks at vitus.scs.agilent.com (Greg Weeks) wrote in message news:<1000085015.952637 at cswreg.cos.agilent.com>... > I just happened to notice a PEP stating that a certain additional construct > would be "a good idea". I imagine that there are lots of good ideas out > there, genuine and perhaps even significant language improvements. But I'm > move convinced of this: If every significant language improvement were > added to the language, it wouldn't be an improvement at all. All those > good things would add up to a bad thing. The optimal size for a language > is not enormous. I think that this was one of the points that people made before and, increasingly, during the big division debate. Whilst the PEP process is a good way of formalising language changes and the ideas which support such changes, it can appear like a method of getting one's "pet project" into the language provided that one can justify it enough in writing. That's not to say that this was the case with the division proposal, nor that documentation is undesirable - far from it, in fact - but it might be frustrating for some to see some previously discussed construct, absent from Python, being actively debated when there are so many other areas in which Python's position could improve. Thankfully, there seems to be a fair amount of activity in areas which have stagnated in the past; perhaps, any mass temptation to change the language is now in decline and the creative energies of the community at all levels are mostly focused in other, more worthy areas. Paul From gerson.kurz at t-online.de Sun Sep 2 03:58:36 2001 From: gerson.kurz at t-online.de (Gerson Kurz) Date: Sun, 02 Sep 2001 07:58:36 GMT Subject: COM MakePy utility in PythonWin References: Message-ID: <3b91e631.1383281@news.t-online.de> On Sun, 02 Sep 2001 05:09:43 GMT, "Maan Hamze" wrote: >1. In addition to using the excellent Lemburg's mxODBC, I have been using >DAO to connect to Access using Jet engine, and using ADO too. Of course the >last two depend on using Hammond's COM clients in PythonWin. >I am just curious though as to the advantages of using the COM MakePy >utility. >Hope someone can give some hints as to what does it do exactly. One reason to do this is, that you otherwise have to manually define keywords for constants defined in TLB files. If you use Makepy, you can access all constants defined by the office objects using win32com.client.constants. For example, to get the default contacts folder from Outlook, you can write f = mapi.GetDefaultFolder(win32com.client.constants.olFolderContacts) provided you've make-pyed before. >2. I have a povray modelling program that offers a COM interface. I was >able to connect to it through Hammond's Python win32com. But the interface >itself is not listed in the COM browser in PythonWin. I looked for it in >the registry and found it and tried it in PythonWin and it worked. I am >just wondering why the object did not appear in the COM Broswer? - do you implement IDispatch ? COM alone (eg. IUnknown + custom derived interface) isn't enough to be usable in Python (or VB). - Do you have the .tlb properly registered ? From fredrik at pythonware.com Sat Sep 8 08:36:13 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 08 Sep 2001 12:36:13 GMT Subject: Greyscale Display w/PIL/tkinter References: <9nai06$ph4$2@news2.isis.unc.edu> Message-ID: <1hom7.1433$sn6.294594@newsc.telia.net> Eric Frey wrote: > I am writing an application where I need to display grayscale images on > both 8 (pseudocolor) and 24 bit displays. I am using PIL and ImageTk to > display the images. It works fine on 24 bit displays. However, it doesn't > work on 8 bit displays since there are only a very small number of gray > levels. What i would like to happen is for the application to have a > private colormap that is installed when the cursor is in the window. I > have used the colormap='new' option to a Frame that fills my root window > or to a Toplevel widget. try passing "palette=256" to the PhotoImage constructor. From tanzer at swing.co.at Sun Sep 16 03:44:59 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Sun, 16 Sep 2001 09:44:59 +0200 Subject: [Poll] Private variables In-Reply-To: Your message of "Sun, 16 Sep 2001 02:23:48 EDT." Message-ID: "Tim Peters" wrote: > > The name mangling of `__bar` names misbehaves if the class name starts > > with a single underscore. To be able to use `__bar` names safely one > > has to avoid `_Foo` class names. > > > > This is the only example of accidental feature interaction in Python > > that I'm aware of. > > It's not an accident: the compiler goes out of its way to remove leading > underscores from class names while mangling, and this behavior is documented > in section 5.2.1 (Identifiers -- Private name mangling) of the Ref Man. When was this documentation added? I don't remember reading that (back in 1.5.x times; of course, my brain might just have chosen to selectively ignore it). Feature or bug, it still is an example of feature interaction waiting to spring surprises on you. > Suppose it didn't do this. Then the mangled name in _A would be __A_beep, > and in A would (still be) _A_beep. How then in A would you be able to > access _A's version of beep? If you typed __A_beep within the scope of A, > it would get mangled to _A__A_beep: the point of the rule is so that a > mangled name never ever "looks like" a private name, so that in turn you can > always do the mangling by hand (when needed) and not have the compiler > interfere. I understand the difficulty. I still think it would have been better to just use a different (and documented) mangling scheme for class names starting with a single underscore (like ___A_beep ). > You could protest that if you *wanted* to access _A's beep from within A you > never would have made it a private name to begin with -- but Guido knows you > don't really mean that, so Python makes sure you can cheat despite your > idealistic intentions . My use of `__` names isn't motivated by privacy. The `__` names work well to allow each class in the hierarchy to have its own unique variables if it chooses so -- that is handy for some design patterns. That this variables are open for inspection is a bonus, IMHO. My consequence is to never use `_Foo` class names. Too bad, that that means that some classes might be imported by `from X import *` when I'd rather they wouldn't. Some-features-are-warts-even-if-documented-ly y'rs Christian -- Christian Tanzer tanzer at swing.co.at Glasauergasse 32 Tel: +43 1 876 62 36 A-1130 Vienna, Austria Fax: +43 1 877 66 92 From qrczak at knm.org.pl Tue Sep 4 04:25:05 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 4 Sep 2001 08:25:05 GMT Subject: Is 0 > None?? (fwd) References: Message-ID: Tue, 4 Sep 2001 09:06:32 +0200, Radovan Garabik pisze: > : Such program would currently not work *at all* - hardly an improvement. > > At least it forces the author think about the issue - not just > assume everybody uses latin1 (as is the case in many programs). The current way lets him assume that everybody uses ASCII (as is the case in some programs). I said wrong: the program will work as long as all data supplied is ASCII. This is bad, and by your measure: worse than a program which doesn't work at all (e.g. doesn't allow conversion between Unicode and byte strings). I don't propose to assume latin1! I propose to assume the encoding which has been set in the system configuration for this purpose: for assuming the encoding of 8-bit texts appearing in the system which were not marked otherwise. Text files in my system are not ASCII. They are mostly ISO-8859-2. Filenames too. > well, I would prefer utf-8 encoding - this is what one can expect > to use when there is already need for unicode strings. And thus I would set my locale to UTF-8. This is what it is for! Now all correctly written programs will assume UTF-8. Except programs written in Python. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From emile at fenx.com Thu Sep 6 10:27:59 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 6 Sep 2001 07:27:59 -0700 Subject: dictionary and __getattr__ References: <8827e15d.0109060614.59036c18@posting.google.com> Message-ID: <9n81ge$5v8rn$1@ID-11957.news.dfncis.de> "Chris Ryland" wrote in message news:8827e15d.0109060614.59036c18 at posting.google.com... > > Hey, won't the new 2.2 support for extending built-in classes such as > dictionaries make this both easy and complete? > > --Chris Ryland, Em Software I'm not sure that any level of getattr trickery will be complete. How would you ever recognize both 1's in: d = {1:1, '1':'One'} d.1 #?? what does this mean ?? -- Emile van Sebille emile at fenx.com --------- From grante at visi.com Tue Sep 18 14:18:16 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 18 Sep 2001 18:18:16 GMT Subject: bitwsie operator help please References: Message-ID: In article , David In VA wrote: > I am not sure how to properly write the bitwise operator but I think it > will be useful for some thing I need to do. If I want to print "Hello" > if the value 2^2 (4) is in a given value (lets say testvalue) how would > I do this? I have been trying this > > if 4 & testvalue: > print "hello" It works for me. How exactly is it not working? -- Grant Edwards grante Yow! FOOLED you! Absorb at EGO SHATTERING impulse visi.com rays, polyester poltroon!! From ignacio at openservices.net Fri Sep 7 11:44:47 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Fri, 7 Sep 2001 11:44:47 -0400 (EDT) Subject: Very elementary help in using Python on Windows 98 In-Reply-To: <3b98e582.0@news.acay.com.au> Message-ID: On Sat, 8 Sep 2001, Jeff Melvaine wrote: > I have begun to experiment with Python on Win98 on my personal laptop. When > I set up a script xxx.py and double click the icon to run it, I get a window > (presumably some kind of debugging console)which lasts for a few seconds, > flashes a message and dies instantly so I can't read it. There is evidently > a problem in my script somewhere, but how can I get the window to hang > around long enough to see what it is? Try opening a DOS window and running your scripts from there. -- Ignacio Vazquez-Abrams From paul at boddie.net Tue Sep 25 08:46:04 2001 From: paul at boddie.net (Paul Boddie) Date: 25 Sep 2001 05:46:04 -0700 Subject: Interactive web image using Python References: <3BB01440.5E6EE94@tpg.com.au> Message-ID: <23891c90.0109250446.6cdcbc3@posting.google.com> Michael Palm wrote in message news:<3BB01440.5E6EE94 at tpg.com.au>... > I want to have a web image where you can change the color of parts of > the image by clicking on it. > e.g. color>. This is for a clothing > manufacturer. I am (of course) using Python on the client side. Don't you mean server side? > Any ideas on the best way to do this from Python (PIL, PIDDLE, OpenGL > etc...). Or should I > be using a Java applet or Shockwave file instead? The shading program > will need to know > about the component shapes so that it can fill each one. Somewhere on > the web I saw a duck > whose clothing you could change in this way, but I can't find it again > or recall what they used. I also played with that demo. In fact, I'm sure I have an image saved somewhere of a strangely dressed duck from that site. ;-) > I guess I could use their method and just store a library of each > compoment shaded in all > possible colors, then overlay the pieces. Well, you could use the various imaging toolkits to render and colour the pieces and combining them into a single image. The challenge then is to make different parts of the image selectable - you could either implement a server-side imagemap, or instead generate a client-side imagemap when you generate the image. The latter would be preferable, I think, especially for vector-based images, but you would need to have some way of generating the image (of course), generating area details for the imagemap, producing the imagemap definition, incorporating the imagemap into a dynamically generated Web page and incorporating the image into the Web page. The last thing could, I suppose, be done by either saving the image somewhere which is accessible from the user's browser (so that the "img" tag can pick the generated image up from a static resource), by generating the image independently of the Web page (and imagemap) (so that the image is only generated when the browser attempts to load the "src" of the "img" tag), or by sending the image with the Web page to the browser. I must admit that I haven't looked too much into the latter, but it might be an elegant solution. I'm clearly rambling here, but I hope this is helpful in its own small way. :-) Paul From ignacio at openservices.net Mon Sep 17 11:43:45 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Mon, 17 Sep 2001 11:43:45 -0400 (EDT) Subject: Best database for Time Series Data [slightly OT] In-Reply-To: <66757C91639C7C419D9AD6C8925C5E3EE697B5@chqmail.corp.oge.com> Message-ID: On Mon, 17 Sep 2001, Scott, M Clay wrote: > What is the best database to use for time-series data? I work for an > electric utility in Load Research. Load Research is the study of how > customers and groups of customers use energy. It deals with large amounts > of time-series data (periodic meter readings on [typically] 15-minute > intervals). The volume of data would be in the magnitude of 35,000 (for a > single meter) to 35,000,000 (for a group of 1,000 meters) data elements for > a single year. Obviously, multiple years means more data. > > I am looking to take advantage of Python for some of the data processing. > We currently use a package that utilizes Btreive which can be connected to > via ODBC. However, I would like to know about other alternatives. > > Is MySQL well-suited for this task? What are other Python-able databases? > Which of these are good for time-series data? This is a cakewalk for MySQL. Other companies are using MySQL for comparable amounts of data: http://www.mysql.com/documentation/mysql/bychapter/manual_MySQL_customer_usage.html -- Ignacio Vazquez-Abrams From dietmar at nospam.wohnheim.fh-wedel.de Fri Sep 14 04:25:22 2001 From: dietmar at nospam.wohnheim.fh-wedel.de (Dietmar Lang) Date: 14 Sep 2001 08:25:22 GMT Subject: create documentation with the comments present in the source code References: <9nsdkl$s3q$1@s1.read.news.oleane.net> Message-ID: Hi! > As it is possible to put comment in 'python' code just after a function, a > class as following : > > def Function(): > """ > My comment > """ > if ... > > As it is possible to get this comment in the python command with an simple > instruction... Yes, here's a little interactive session: >>> def Voila(): """This is documentation for Voila()""" pass >>> print Voila.__doc__ This is documentation for Voila() >>> There you go... If more details are needed, maybe someone here will jump in... > Is there an utility which realize a pretty documentation with these comments > ? There propably is, else why don't you make one? ;) Kudos, Dietmar -- To mail me, remove 'nospam.'. From phd at phd.pp.ru Sun Sep 9 00:52:22 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Sun, 9 Sep 2001 08:52:22 +0400 Subject: Demo/xml/roundtrip.py In-Reply-To: ; from rwest@opti.cgi.net on Sat, Sep 08, 2001 at 08:02:02PM +0000 References: Message-ID: <20010909085222.A4497@phd.pp.ru> On Sat, Sep 08, 2001 at 08:02:02PM +0000, Richard West wrote: > I'm trying to parse the ODP (dmoz.org) RDF files with Python but I Look at Oedipus http://oedipus.sourceforge.net/ and ZopenDirectory http://www.zope.org/Members/CodeSyntax/zOpenDirectoryNewsItem. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From qrczak at knm.org.pl Fri Sep 14 16:54:59 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 14 Sep 2001 20:54:59 GMT Subject: CrossProductSweeper References: <1rn1439eux.fsf@video.bsd.uchicago.edu> Message-ID: 10 Sep 2001 11:42:46 -0500, John Hunter pisze: > Here is a simple class to systematically investigate a cross product > space, which you might normally do with a series nested for loops. > I suspect that there is an existing way to do this, but sometimes its > easier to roll your own that find the right package. Please point > me to the light if there is an existing way to do this I should be > aware of. Generators which are a recent feature of Python make it much easier. Here is an example - works with Python-2.2a1: from __future__ import generators def cross_product(seqs): result = [None] * len(seqs) def level(i): if i == len(seqs): yield(tuple(result)) else: for x in seqs[i]: result[i] = x for r in level(i+1): yield r for r in level(0): yield r for x in cross_product(((1,2,3,4), (5,6), (7,8,9,10))): print x Here is a nicer but less efficient implementation: def cross_product(seqs): if seqs: for x in seqs[0]: for xs in cross_product(seqs[1:]): yield (x,) + xs else: yield () -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From phd at phd.pp.ru Thu Sep 27 10:59:41 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 27 Sep 2001 18:59:41 +0400 Subject: scanf style parsing In-Reply-To: <8351bb33.0109270648.75af3371@posting.google.com>; from jkn@nicorp.f9.co.uk on Thu, Sep 27, 2001 at 07:48:14AM -0700 References: <3BB16A50.BAE082FE@cygnus-software.com> <8351bb33.0109270648.75af3371@posting.google.com> Message-ID: <20010927185941.C25063@phd.pp.ru> On Thu, Sep 27, 2001 at 07:48:14AM -0700, Jon Nicoll wrote: > trivial followup: isn't it ... amazing ... the number of programs > which still have this kind of output? > > > > > > > smtpmail.exe - 0 error(s), 0 warning(s) > ___ ___ No, it is not. In Russian, for example, it is very hard to automatically change a word - Russian is very computer-unfriendly :) There are far too many rules, conditions, exceptions and so on. On the lighter side - it has very simple rules of pronounciation. Unlike that damn English, that has exactly One Rule of Pronounciation: every word is an exception :))) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From pkwoods at nospam.nwlink.com Sun Sep 9 01:58:09 2001 From: pkwoods at nospam.nwlink.com (Paul) Date: Sat, 8 Sep 2001 22:58:09 -0700 Subject: disutils looking for .../python2.1/config/makefile Message-ID: <3b9b034d$1_2@news.nwlink.com> I have Mandrake 8.0, upon which I installed Python 2.1 using the RPM available on python.org. I am trying to install the MySQLdb module, and keep getting this error message: unable to open /usr/lib/python2.1/config/Makefile (no such file or directory) I do not have a config directory, and would appreciate a pointer. Thank you in advance, Paul From cgaston at moonqzie.com Mon Sep 17 09:43:42 2001 From: cgaston at moonqzie.com (Carlos Gaston Alvarez) Date: Mon, 17 Sep 2001 15:43:42 +0200 Subject: re documentation error References: <01b301c13f65$b95b9c00$a500a8c0@moonqzie> <005d01c13f72$e4109c40$0101010a@local> Message-ID: <020201c13f7e$c443c750$a500a8c0@moonqzie> It seems that I dont understand. I am reading the doc at http://py-howto.sourceforge.net/regex/node19.html and the example is the 5.2 (search and replace). I run the example (at last) and the results where >>> re.sub('x*', '-', 'abxc') '-a-b--c-' >>> re.sub('x', '-', 'abxc') 'ab-c' there is an small diference, in doc it said that the first one should return '-a-b-d-' when it returned '-a-b--c-' So there was a small mistake. :_) . Anyway, now I undestand why it is putting the - in from of every letter. I was reading x* as if it were an x+. It seems that it starts matching not from the first letter but before (with an empty string, so it does match). Thanks, Gaston ps: stupid of me. Instead of trying it and asking myself why it was 'misbehaving' I blamed the documentation. ps2: 'intelligence in the world remains constant but population keeps growing' ----- Original Message ----- From: "Chris Gonnerman" To: "Carlos Gaston Alvarez" Cc: Sent: Monday, September 17, 2001 2:18 PM Subject: Re: re documentation error > ----- Original Message ----- > From: "Carlos Gaston Alvarez" > > > > Empty matches are replaced only when not they're not adjacent to a > previous > > match. > > I don't understand how this ^ has anything to do with this v > > > >>> p = re.compile('x*') > > >>> p.sub('-', 'abxd') > > '-a-b-d-' > > You have an expression matching zero or more x's, and you are substituting > a dash. This result is exactly right. > > > I would expect the result to be. > > 'abd' > > Why? You are putting a dash into the string. If you had said you expected > the result to be 'ab-d' I would know you didn't understand the expression, > but evidently you do. Do you think that a dash in the *substitution* string > means something special? With the exception of backslash-escapes, there is > *nothing* special about that string. > > > If the '-' is representing no char, an empty string (as the text says) > then > > The text (2.1 is what I am looking at) says nothing of the sort where the > example you show is described. It says, to wit: > > Empty matches for the pattern are replaced only when not adjacent to a > previous match, so "sub('x*', '-', 'abc')" returns '-a-b-c-'. > > Are you mixing this up with the example a few paragraphs prior? That > example > is using a *function* for the replacement value and has nothing to do with > the rule you are complaining of. > > > I would like it to say > > >>> p = re.compile('x*') > > >>> p.sub('', 'abxd') > > 'abd' > > > > Which is an example that does teachs nothing new. > > > > is - an special char of re for representing nothing? > > Dont think so. > > In fact, it's not. The example doesn't say it is. > > > Chau, > > > > Gaston > > > > > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > > > > From loewis at informatik.hu-berlin.de Mon Sep 17 04:54:37 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 17 Sep 2001 10:54:37 +0200 Subject: How to parse XHTML with xml.parsers.xmlproc? References: <873d5mo5cz.fsf@zazu.vip.fi> Message-ID: Paavo Hartikainen writes: > These are the errors that parsers gives: > > fatal: End tag for 'head' seen, but 'meta' expected > fatal: End tag for 'html' seen, but 'meta' expected > fatal: Premature document end, element 'meta' not closed > > I am sure it is just because it does not know XHTML DTD. I'm pretty sure this is not the problem. Instead, it looks like your document has a structure like Well, this is ill-formed XML. You need a closing meta tag before you can close the head tag. You can, of course, make use of the "empty content" abbreviation of XML. As for finding DTDs: If your document contains PUBLIC identifier, xmlproc will attempt to search catalogs. If there is only a SYSTEM identifier, it will interpret this as an URL. If it looks like a relative path name, it will look for the DTD relative to the current directory. Regards, Martin From ken at positive-edge.com Sat Sep 8 22:49:34 2001 From: ken at positive-edge.com (Ken Egervari) Date: Sun, 09 Sep 2001 02:49:34 GMT Subject: Zope problem with directory structure Message-ID: <2NAm7.129219$n75.31078825@news4.rdc1.on.home.com> One of the problems I've been having is this backwards way of including files (or dtml variables). Usually I would have a site structure like (from a PHP environment that is) / (index and few other files) /css (stylesheets) /src (all site source code) /src/data (data access components) /src/application (everything to glue the application's presentation and data) /src/presentation (usually templates that construct base html pages as well as interfaces to application code) /graphics (images and sub-dirs for specific type of graphics) /lib (all my library code that I can reuse) Now, with zope, I understand that you have to put things that are common in the / directory of Zope. Well, in my current website directory structure, that would basically be a lot of stuff that would be unorganized. Is there anyway to just call /graphics/imageObject directory? I don't want to have to make all my pages have graphics and associate files in the common folder that it's associated with because 9 times out of 10, it really doesn't belong there since I need it somewhere else too. Thanks for the help. From rafael at zumnet.com.br Tue Sep 4 11:14:27 2001 From: rafael at zumnet.com.br (Rafael Mentz Aquino) Date: Tue, 04 Sep 2001 12:14:27 -0300 Subject: Hi, there Message-ID: <3B94EFD3.3360D44B@zumnet.com.br> Hi, everybody! I'm new on this list and a begginer with Python, with special interests in Tkinter. I hope I can help and get help from here ;-) Let me start with a little problem...? I'm making an experience, but I can't put the result of an os.system to a variable.... just the exit status.... How can I read the stdout to solve that..? Thanks already!!!! Rafael Mentz Aquino Porto Alegre - Brazil From jacobs at darwin.epbi.cwru.edu Tue Sep 18 08:49:36 2001 From: jacobs at darwin.epbi.cwru.edu (Kevin Jacobs) Date: 18 Sep 2001 12:49:36 GMT Subject: missing class PiddleWxDc(piddle.Canvas) - newbie question References: <9o51up$ui$1@taliesin2.netcom.net.uk> Message-ID: <9o7ft0$efp$1@eeyore.INS.cwru.edu> Stilian Trifonov wrote: > I installed py21-pil-1.1.2-20010910.exe and I tried to run piddleWxDcDemo.py > (from http://darwin.cwru.edu/~pjacobs/ ) but I received an error about > missing class piddle.Canvas. I assumed I should change 'piddle' to 'Image' > but there is no Canvas class in Image.py either. What am I missing? Wow! I didn't think anyone was using that anymore. I'd certainly forgotten it even existed. Anyhow, speaking for my brother Paul, you need the Piddle and wxPython. HOWEVER, the code was written well over a year ago and the wxPython API may have changed significantly since then. I sugges that you send e-mail to pjacobs @ penguin.no-spam-theopalgroup-no-spam.com (after removing the spaces and no-spam's) if you have any additional problems. Regards, -Kevin -- -----------> Kevin Jacobs <-----------|-------> (216) 986-0710 <-------- Bio-Informatics Consultant | Department of Epidemiology Primary mail: jacobs at theopalgroup.com | & Biostatistics Alternate mail: jacobs at darwin.cwru.edu | Case Western Reserve University ---------------------------------------------------------------------------- From tbabbitt at commspeed.net Fri Sep 7 20:24:13 2001 From: tbabbitt at commspeed.net (Tom Babbitt) Date: Fri, 7 Sep 2001 17:24:13 -0700 Subject: can't download References: <20010907153108.15642.00000577@mb-fq.aol.com> Message-ID: "SETTLESNATHAN" wrote in message news:20010907153108.15642.00000577 at mb-fq.aol.com... > when i try to download python-2.1.1.exe off of the python.org website I get a > page with the quicktime logo in the middle of it and then after the page > finishes loading up the re is what looks like a piece of broken movie film(the > kind on the big wheels at movie theateres)can someone help me, i really do want > to learn how to do this > > thanks in advance > > nathan What is your platform. If it is Windows try right clicking and choosing 'Save Target As' and save it to your desktop. Tom Babbitt From rjroy at NO-SPAM.magma.ca Mon Sep 10 12:20:07 2001 From: rjroy at NO-SPAM.magma.ca (Robert Roy) Date: Mon, 10 Sep 2001 16:20:07 GMT Subject: Help building Python-2.1.1 under HP-UX Release 11.00 References: Message-ID: <3b9ce672.7065439@news> On Mon, 10 Sep 2001 13:43:29 +0200, juan.alcolea at bt.es wrote: >Hi, > > I've been playing a little with Python under Windows, and I've found >it's a very interesting tool. I'm trying to build >Python-2.1.1 under HP-UX Release 11.00, so I can do some sample development >in our test server, but I'm getting some problems (please note that I'm not >a unix administrator, just a plain basic user). I downloaded the .tgz file, >decompressed it and ran the "configure" script. Then a did a "make", and >this is what I got: > I have not tried to build on 11.00 but have done so on several 10.20 systems. From what I recall, using the basic cc compiler is problematic. You might want to install gcc and use it instead. http://hpux.connect.org.uk/hppd/hpux/Languages/python-2.1/ has a precompiled binary for 2.1 From ZnickZm at alum.mit.edu Mon Sep 17 16:43:57 2001 From: ZnickZm at alum.mit.edu (Nick Mathewson) Date: Mon, 17 Sep 2001 20:43:57 GMT Subject: Possible wart in PEP-0253 Message-ID: Hello all. In playing around with PEP-0253 behavior, I think I've found a possible wart. If it isn't a wart, it's at least a hole in the documentation. I went to write the following test code: class Foo(tuple): def __setattr(self, attr, val): raise AttributeError("You can't set attributes here") def __init__(self): # Here's the standard workaround. self.__dict__['parrot'] = 'no more' Of course, when I called Foo(), I got a TypeError, because __dict__ is set to None until object.__setattr__ is called. There's no way to modify __dict__ except by calling object.__setattr__, so to make my code work, I needed to use object.__setattr__(self, 'parrot', 'no more') instead. My suggestion is this: would it be possible to relax the assignment-to-__dict__ rule at least so far that if __dict__ is None, you can assign a new empty __dict__? Or add to a declaration (__init_dict__?) that makes the metaclass always materialize an empty __dict__ when __new__ is called? Otherwise, from now on, the generic way to spell "self.__dict__['foo'] = bar" will be instead "object.__setattr__(self,'foo',bar)". Except that: for classes that don't extend types, the first spelling will continue to work. And for classes that *do* extend types, the first spelling will work in all cases but the first. Though I can quite gladly accept that this is as intended, it certainly took me a while to figure it out for myself. :) So, what ought I do? Submit this to sourceforge? To the FAQ? Or just accept that PEP-0253 is heavy business, and try to come to terms with it on my own? :) But-quite-possibly-this-isn't-so-confusing-as-I'm-making-it-sound-ly Y'rs, -- Nick Mathewson Remove Z's to respond. No spam. From rnd at onego.ru Wed Sep 19 07:40:20 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 19 Sep 2001 15:40:20 +0400 (MSD) Subject: Using MySQLdb Newbie In-Reply-To: <01091912253206.01260@jordan.utopia.net> Message-ID: On Wed, 19 Sep 2001, Jordan Elver wrote: > Hi, > This is my first post to the list, please be gentle. > I'm trying to get python talking to my mysql server. I think the way to this > is to use the MySQLdb library. So I'm trying to set it up. But I get the > following error when running the setup.py script: If I understood correctly, you are trying to use MySQL + MySQLdb on some UNIX system. How are you doing it? AFAIK, it's simply: python setup.py install from the MySQLdb distro directory! > "error in setup script: invalid distribution option 'platforms'" > > Can someone point me to information or tutorials or other help? You can ask here, but please provide more details. Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From markus at schabi.de Wed Sep 12 16:06:48 2001 From: markus at schabi.de (Markus Schaber) Date: Wed, 12 Sep 2001 22:06:48 +0200 Subject: references/pointers in Python? References: Message-ID: <20841991.xaV6nBDHxo@lunix.schabi.de> Hi, Anton Lavrik schrub: > Hi. > I've Started learning Python, and can't find how can I do something > like $a = \$b > or > $a = \*$b > in Perl. > > Generally, I want to define a referce to an integer, or to the > identifier, that holds it. > Python is full of references, is it possible to define it directly? Or > maybe there are some different ways to do it? I don't speak perl, but I hope I can help you: To create a reference to an integer, just assing it to a name: a = 3 This creates a reference to the (immutable) integer 3 and assigns it to the name a. markus -- "The strength of the Constitution lies entirely in the determination of each citizen to defend it. Only if every single citizen feels duty bound to do his share in this defense are the constitutional rights secure." -- Albert Einstein From tim.one at home.com Sun Sep 23 00:27:37 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 23 Sep 2001 00:27:37 -0400 Subject: Realtime capabilities? In-Reply-To: <9ojlhn$q1k$1@panix2.panix.com> Message-ID: [Aahz Maruch] > In other words, if the original poster is doing more than a tiny amount > of I/O, standard Python/OS threads will probably beat Erlang processes > for fairness, I don't know how Erlang deals with C-style I/O, so can't guess. > but if an application is almost completely compute-bound, > Erlang will probably beat even Stackless Python. Why? Scheduling fairness has nothing directly to do with speed, it has to do with whether a process ready to run is assured to get a chance to run "soon". A process that needs to deliver a result within a given time delta needs to know (at least) that it can't be swapped out for longer than that time delta. The speed of each process on its own is at best a second-order effect on that, compared to the granularity and fairness of the time-slicing policy, and especially when running thousands of processes (which Erlang is designed for). I *expect* Erlang switches context more frequently than Stackless, so all else being equal (which I'm sure it's not), it would be slower overall (due to higher switching overhead, simply because switching more often) if so. Real-time has to do with getting specific pieces of work done by specific times, not primarily with maximizing the amount of work done per unit time (if the latter is your goal-- "peak speed" --best to stay away from context switching entirely). From peter at engcorp.com Thu Sep 6 12:24:09 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 06 Sep 2001 12:24:09 -0400 Subject: dictionary and __getattr__ References: <8827e15d.0109060614.59036c18@posting.google.com> Message-ID: <3B97A329.3412631C@engcorp.com> Skip Montanaro wrote: > > > Wouldn't it be nice if this would work: > > d = {'x': 1} > > print d.x > > i.e. every entry in a dictionary is also an attribute of the > > dictionary itself. > > Chris> Hey, won't the new 2.2 support for extending built-in classes > Chris> such as dictionaries make this both easy and complete? > > Yup: > > >>> class AttributeDict(dictionary): > ... __getattr__ = dictionary.__getitem__ > ... > >>> d = AttributeDict() > >>> d['a'] = 1 > >>> d.a > 1 Great, so now instead of KeyError you can get either KeyError _or_ AttributeError for what is effectively the same problem? -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From tim.one at home.com Mon Sep 3 03:05:53 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 3 Sep 2001 03:05:53 -0400 Subject: 3-arg float pow() Message-ID: Python's builtin 3-argument pow() exists because, e.g., >>> pow(3L, 500, 7) 2L >>> can be done very much faster, and with much less memory, than >>> 3L**500 % 7 2L >>> There isn't any compelling use I know of for 3-arg pow() given float arguments, though, and what you get back is a platform-dependent accident: >>> pow(3., 500., 7.) 4.0 >>> You may get some other integer there, or an Infinity or a NaN, depending on the Python release, and the compiler used to build Python, and the configuration of your libm. That example was done under CVS 2.2a2+ on Windows; here's the same thing but under 2.2.1: >>> pow(3., 500., 7.) 0.0 >>> Since 3-argument float pow() *appears* to be at best useless, I'm taking it away in 2.2a3, unless someone can testify to a reasonable use case that's actually used. more-trouble-than-it's-worth-if-it-isn't-worth-anything-ly y'rs - tim From tolot at solar-system.dynodns.net Fri Sep 7 07:23:06 2001 From: tolot at solar-system.dynodns.net (Marc Christiansen) Date: Fri, 7 Sep 2001 13:23:06 +0200 Subject: Unexpected return value from __add__ References: <3B989F3D.8D355CC4@thinkware.se> Message-ID: Magnus Lycka wrote: > def __str__(self): > res = [] > while self.addr: > self.addr, digit = divmod(self.addr,256) > res.append(str(digit)) > res.reverse() > return ".".join(res) After calling __str__, self.addr is 0L. Insert 'addr = self.addr' at the beginning and use 'addr'. HTH Marc From erlangen72 at hotmail.com Sat Sep 1 13:28:07 2001 From: erlangen72 at hotmail.com (Mark_Pryor) Date: Sat, 01 Sep 2001 17:28:07 GMT Subject: browse builtins and Dedent in Win32 Message-ID: Hi, Using ActivePython v 2.1.212 on Win98 While coding interactively in PythonWin, how can I browse the __builtins__ and have them appear in a drop down box? Also, when coding a function what is the best way to Dedent or Unindent? I thought 2 carriage returns might do it, but no. tia, Mark Pryor pgp KeyID: 0x1A966EC5 From grey at despair.dmiyu.org Fri Sep 14 06:59:39 2001 From: grey at despair.dmiyu.org (Steve Lamb) Date: Fri, 14 Sep 2001 10:59:39 -0000 Subject: Python a good thing for sysadmins ? References: Message-ID: On Thu, 6 Sep 2001 21:14:08 +0200, Aurelien wrote: >I'd like to know if Python could be used for system administration. And >if there are people out there who use it for that. I noted for instance >that there were no SIG relating to this topic... Given the choice I'd use Python, even for "simple" tasks that "aught" to be done in shell. I've run into too many cases in shell where the fork/exec of every little operation killed the speed of the script. I've also hit many instances where something that I could readily to in Perl or Python I simply could not figure out how to do in shell and found it simpler to just rewrite the script, from scratch, in Perl (at work) or Python (at home). Personally I'm in love with the idea of Python scripts also being libaries to other scripts with a minimal amount of effort. Esp. when it comes to a large set of scripts that need to be called both manually and automatically. I much prefer having true exception handling than passing status back and forth through shell. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. To email: Don't despair! | -- Lenny Nero, Strange Days -------------------------------+--------------------------------------------- From tim.one at home.com Thu Sep 6 23:50:59 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 6 Sep 2001 23:50:59 -0400 Subject: Simple Newbie Question - (slightly OT) In-Reply-To: <66757C91639C7C419D9AD6C8925C5E3EE69787@chqmail.corp.oge.com> Message-ID: [Scott, M Clay] > What is the proper pronunciation for "Tuple"? > > Does it rhyme with "Couple"? Or does it rhyme with "Hoople"? At Luxurious PythonLabs World Headquarters, everyone says tuple-hoople. Tuple-couple is a disease contracted from too much exposure to database types. The mortality rate is close to 100%, but it's not especially contagious. wear-a-condom-and-you'll-be-fine-ly y'rs - tim From mmhamze at pleiades.net Fri Sep 7 14:20:45 2001 From: mmhamze at pleiades.net (Maan M. Hamze) Date: Fri, 7 Sep 2001 13:20:45 -0500 Subject: [OT] Re: Creating Excel files on Linux References: Message-ID: Roman I agree with you, and it is not my intention or my inclination to be put on a side that hypes things. Most of the software on my own PC is open source software. When I say realistic I mean the following: we live in a society (at least in the US) that is based on hype after all, and software is only one indication of the hype that surrounds everything. I have run into many that attack Microsoft to only sing the praises of Sun. Even many tools that run on Linux are getting to be hyped. I was by the way one of the earliest adapters of Linux. So, I believe we are talking about the same thing but in different terms. And we are in agreement. I personally dislike the commercial hype of software and I use open source software. But when it comes to my work I just have to survive in a marketplace that is based on hype and buzzwords. If a manager wants to use .NET (whatever the hell .NET is) then I have to look at it and ensure that our processes will run fine with the new technology. Maan "Roman Suzi" wrote in message news:mailman.999884530.6996.python-list at python.org... > On Fri, 7 Sep 2001, Maan M. Hamze wrote: > > >> But again, am I free not to deal with this world? > > > >Yes, you are free not to deal with it. But it depends on what world you are > >living in. I am not defending Microsoft here, but I am being realistic. > > I've heard that realistic ~= pessimist. > > MIcrosoft "invented" .NET and now everybody who is "realistic" > adopts is as fast as possible or at least learn what that mean. > > IT industry is drived by hypes and not technical merits. Yes, ordinary > user doesn't know what "operating system" is unless reminded about the > "clouds" at startup. And THIS is realistic. > > I share the views of Oleg but I feel "realistic" about this too. I can't > change the world. I must live with all those stupid MS Office documents in > my mailbox and ohs of my collegues having fun while their system goes > down. > > >In the same way, an open platform is a MYTH. > > Oh, no! Open doesn't mean "free of charge". Windows NT is also > open (to some extent unless MS lied). > > Linux and Python ARE open. What myth are they? Probably you've meant that > sincerity of large corporations regarding open platforms is a myth. I > agree. I do not believe them. And this doesn't make me feel bad. > > >Larry Anderson of Oracle likes > >to talk about this while he flies his own jet looking down on everything. > >Sun talks of open platform because they want their Java to be the standard > >that runs........on their very own machines. Mark Andressen (sp?) talked of > >the ever present CORBA on every server. Is not that a covered talk of > >monopolies too? > >We live in a world of arrogant men and greedy corporations, and they play > >with concepts of the open platform. > > May be they are playing. But if laws have any effect, they leave > good things in open space too. > > >As far as I am concerned, getting a job done is the issue here. Anyone can > >learn VBA during a lunch hour. This is what I call empowerment for people > >who got to work for a living, not to philosophize about the open platform > >myth where people do not know what language they are using. > > And what about those who want to work not only for living but > being interested in the process itself? > > Sincerely yours, Roman Suzi > -- > _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ > _/ Friday, September 07, 2001 _/ Powered by Linux RedHat 6.2 _/ > _/ "Dreams are free, but you get soaked on the connect time." _/ > > From tim.one at home.com Thu Sep 6 02:40:45 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 6 Sep 2001 02:40:45 -0400 Subject: Stackless Python and Python 2.x In-Reply-To: Message-ID: [Michael Abbott] > How does the Python interpreter maintain the state of a generator during > calls to yield? Evidently the entire state has to be restored from > wherever it's being kept and plonked back onto the current stack. > > Perhaps this is a slightly stupid question, but it's more > interesting than the other "What part of ... do you not understand?" > stuff. Oh, I don't know about *that* , but it's a not a stupid question at all. The implementation is simple but subtle. Here's the C struct that holds a generator (strictly speaking, a generator-iterator): typedef struct { PyObject_HEAD /* The gi_ prefix is intended to remind of generator-iterator. */ PyFrameObject *gi_frame; /* True if generator is being executed. */ int gi_running; } genobject; "PyObject_HEAD" is a macro with which every Python object declaration begins -- it expands to a pointer to the type object, and to a refcount. Other than that, it simply stores a pointer to a frame object, and a 1-bit flag saying whether the generator is currently active. That's all there is to it! The frame object is ordinary in every respect, containing stuff like the current set of locals, a virtual instruction pointer, and an evaluation stack (each Python code object computes, at compile-time, exactly how much stack space it needs, and space for its stack is allocated in the frame object when the code object is executed). The point of all that was to convince you that reading the Python source code can be an enjoyable adventure: much of it is frighteningly clear and simple, and Neil Schemenauer's generator implemenation is particularly clean. As Aahz said, at a high level the only other trick in this game is that a generator-iterator simply refrains from decrementing the refcount on its gi_frame when a generator yields. That's all it takes to keep the frame alive. The frame stays alive until the generator-iterator itself becomes trash, at which point its gi_frame gets decref'ed as a matter of course in the generator's destructor, the full source code for which is here: static void gen_dealloc(genobject *gen) { PyObject_GC_Fini(gen); Py_DECREF(gen->gi_frame); PyObject_Del(gen); } Dince generators can be part of reference cycles (although it's not particularly easy to provoke that), the PyObject_GC_Fini business is telling the cycle collector that this object is no longer interesting. [Aahz] > ... > The part I don't understand (though if I had access to 2.2a2, I could > probably test it easily enough) is what happens when you re-enter a > generator and trigger an exception (an exception that isn't > StopIteration, for any smartasses out there). Nothing special: the exception is caught by the frame or not, and if not propagates out of the frame. Generators do nothing special at all here, and since they always return to their immediate invoker, there are no debatable issues about *which* frame *to* propagate an uncaught exception (general coroutines are muddier in this respect, and general continuations even worse). There is one "slick trick" here in support of generators: near the start of eval_frame(), you'll find this: stack_pointer = f->f_stacktop; assert(stack_pointer != NULL); f->f_stacktop = NULL; where f is the PyFrameObject being eval'ed, and f->f_stacktop is the current top of the frame's eval stack. Note that if nothing sets f->f_stacktop non-NULL again, it would be an assert-error to enter eval_frame() with this f again. Now in all of eval_frame(), there is only one way to get f_stacktop non-NULL again, and that's in the body of the YIELD opcode: case YIELD_VALUE: retval = POP(); f->f_stacktop = stack_pointer; f->f_lasti = INSTR_OFFSET(); why = WHY_YIELD; break; Any other way of leaving the frame (exception or return) leaves f_stacktop NULL, in turn making the frame unresumable. That's how the .next() method of a generator-iterator knows whether eval_frame yielded or returned: static PyObject * gen_iternext(genobject *gen) { ... gen->gi_running = 1; result = eval_frame(f); gen->gi_running = 0; ... /* If the generator just returned (as opposed to yielding), signal * that the generator is exhausted. */ if (result == Py_None && f->f_stacktop == NULL) { Py_DECREF(result); result = NULL; } return result; } there's-so-little-to-it-it's-amazing-it-works-at-all-ly y'rs - tim From sjoshi at ingr.com Tue Sep 25 15:42:56 2001 From: sjoshi at ingr.com (Sunit Joshi) Date: 25 Sep 2001 12:42:56 -0700 Subject: COMServer thru Py2Exe question !! Message-ID: <8f8ffe67.0109251142.43246129@posting.google.com> Hello COM Gurus: I have a small problem: I can get VB6 to instantiate a PyCom object created thru py2exe. However each time I try to create the COM Server, a DOS window flashes for a second, I guess because of the line D:\PROGRA~1\TestCom\testCom.exe {3882ECFF-3B74-4444-BB47-BDC2285CEB95} where the testCom.exe is run. Is there any way of getting rid/minimizing the DOS window ?? thanks Sunit sjoshi at ingr.com From ignacio at openservices.net Fri Sep 7 09:35:20 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Fri, 7 Sep 2001 09:35:20 -0400 (EDT) Subject: Playing mp3 files with wxPython In-Reply-To: <3b98c252.1395867@news.chnd1.az.home.com> Message-ID: On Fri, 7 Sep 2001 ibwonrr at yahoo.com wrote: > On Fri, 07 Sep 2001 04:42:57 GMT, "Pete Shinners" > wrote: > > I've tried pygame but get the following error when I call load() for > an mp3 file: > File "", line 1, in ? > pygame.error: Module format not recoginized > > pygame works fine for wav files, but another part of my application > requires mp3. As a work around, I would consider converting my mp3 to > wav so it can be played, then discarding the wav. However I don't > know a python way to convert mp3 to wav. Use .ogg files instead. They have the same features as MP3s, but (IMHO) they're of better quality. -- Ignacio Vazquez-Abrams From ignacio at openservices.net Mon Sep 17 02:32:26 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Mon, 17 Sep 2001 02:32:26 -0400 (EDT) Subject: problem with extending python with C In-Reply-To: <3BA59512.A59B33EF@club-internet.fr> Message-ID: On Mon, 17 Sep 2001, LAMY Bertrand wrote: > now I've got another problem. I got a segfault at the end of my program, > after python has destroyed all the objects (I know that because I've put > a printf in the dealloc functions. so this is not very important since > it crashes only at termination). I got the segfault in that case : > - I've got 2 type object defined in C (if 1 of the 2 is defined in > Python, it won't crash) : one is a carrier which a Pyobject* (given at > creation, the carrier Py_INCREF the PyObject given and Py_DECREF it at > deallocation), the second is a carried (handled by the carrier of course > :) I had exactly this problem once. What was happening was that I was over-decrementing so that when Python exited it decremented one more time and so blew up. I'll be happy to take a look at your code. Feel free to send it directly to my address. -- Ignacio Vazquez-Abrams From never_spam_me at yahoo.com Wed Sep 12 21:04:40 2001 From: never_spam_me at yahoo.com (Spam Hater) Date: Wed, 12 Sep 2001 18:04:40 -0700 (PDT) Subject: Why can't I import Tkinter from embedded python? In-Reply-To: Message-ID: <20010913010440.34407.qmail@web14912.mail.yahoo.com> Hey all: >From an embedded python interpreter, if I do "import Tkinter" in the script which it calls, the script crashses (and I can't see the error, because stack traces somehow don't end up in my re-directed stderr). However if I run the same script from a command line, it works just perfectly. Note, I can import all kinds of other python modules line string, math, etc. (BTW I'm using Python2.0.) Is there some kind of path that's messed up? I checked sys.path and it points to every conceivable python directory. This is maddening! --matt __________________________________________________ Do You Yahoo!? Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger http://im.yahoo.com From phd at phd.pp.ru Tue Sep 11 04:55:45 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 11 Sep 2001 12:55:45 +0400 Subject: Python and Zope In-Reply-To: ; from tim@vegeta.ath.cx on Tue, Sep 11, 2001 at 08:33:52AM +0000 References: Message-ID: <20010911125545.G26326@phd.pp.ru> On Tue, Sep 11, 2001 at 08:33:52AM +0000, Tim Hammerquist wrote: > I don't remember persistence of DB connections being mentioned in the > CGI spec. I don't believe databases are mentioned at all. And this is the main point of this discussion - Zope has many advantages over Apache modules. Short resume: Zope is a *server* with ability to manage persistent DB connections; Zope is *integrated* server with templates, security, ODB, through-the-web interface, indexing/searching; Zope is *object-publisher* with powerful mechanisms (notably *acquisition*); Zope is component-based with such wonderful components as ZServer, ZPublisher, ZODB, DTML and ZPT, ZCatalog; Zope is *object-oriented* and provides developers with well-defined APIs and objects (classes). Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From rdsteph at earthlink.net Sun Sep 9 09:09:08 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Sun, 09 Sep 2001 13:09:08 GMT Subject: Pythonwin and .NET References: <3B997A5E.6010801@bigpond.net.au> Message-ID: <3B9B6B7D.3F5DBC2E@earthlink.net> Yet another reason, form the Ruby nnewsgroup: """"I'm a sysadmin for several NT, Solaris, and Linux boxes. I currently use both Perl and increasingly Python to manage my systems. I am beginning to enjoy Ruby quite a bit but it seemingly is devoid of NT related functionality in the areas of: services management printer and disk management COM(+) user and group administration security sockets ODBC Can anyone comment on any available modules (not in Beta, etc.) that are available and mature in nature? I believe that if there is anything that prevents the more widespread use of Ruby on WIN32 is that it may be lacking these tools.""""" Many people like to use their language of choice, but can only do so if it has good Windows tools and integration. From tim.one at home.com Wed Sep 12 16:38:25 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 12 Sep 2001 16:38:25 -0400 Subject: Long int too large to convert? In-Reply-To: Message-ID: [fbasegmez] > I got this error message and not sure what it means? > > >>> for i in xrange(1L, 5 * pow(10L, 40)): > ... x = i * x > ... > Traceback (most recent call last): > File "", line 1, in ? > OverflowError: long int too large to convert > >>> Python has two kinds of integers, ints and longs. longs are unbounded; ints are the same size as signed C longs on your box, most often 32 bits. xrange is restricted to ranges with no more than sys.maxint elements. > Any ideas? i, limit = 1L, 5 * 10L**40 while i < limit: x = i * x ... i += 1 > First I was going to use scientific notation instead of pow(x, y) but > then I decided not to because, > >>> long(5e40) > 50000000000000000310004322520389159747584L > >>> > I am aware of numerical precision issues but this still managed to > surprise me. >>> import math >>> mantissa, exponent = math.frexp(5e40) >>> mantissa # The input is exactly equal to mantissa * 2**exponent 0.57397185098744508 >>> exponent 136 >>> mantissa * 2L**53 # 53 bits is all the mantissa holds 5169878828456423.0 >>> long(mantissa * 2L**53) << (exponent - 53) 50000000000000000310004322520389159747584L >>> IOW, the result you got is the best possible 754 double-precision approximation to 5e40, and the exact decimal value of this approximation is 50000000000000000310004322520389159747584L You can't do better than that with 53 bits of floating precision. The closest representable 754 doubles on each side are worse approximations to 5e40: >>> 5169878828456422L << (exponent - 53) 49999999999999990638597765603355762098176L >>> 5169878828456424L << (exponent - 53) 50000000000000009981410879437422557396992L >>> From junkster at rochester.rr.com Wed Sep 12 05:48:02 2001 From: junkster at rochester.rr.com (Benjamin Schollnick) Date: Wed, 12 Sep 2001 09:48:02 GMT Subject: Creating EXE file from Python References: Message-ID: Run, don't walk and pick up Gordon Mcmillians Installer package. Very versatile, and generally simple.... PY2EXE is also another choice, but it's more complicated than the Installer package. http://www.mcmillan-inc.com/intro.html - Benjamin In article , "Ray" wrote: > First, I am new to python. I like to know if there is anyway to create > standalone executable from *.py ? and How? > > -- > * ; > ;~~---__**; ; /~--___ > ,/ /---__\ , / > \ / I am from this place. > \__________ _ / > V > > From rushing at earthling.net Mon Sep 17 16:54:34 2001 From: rushing at earthling.net (S11001001) Date: Mon, 17 Sep 2001 15:54:34 -0500 Subject: Mac python and Carbon References: <3BA65728.C5C8FC8F@home.net> <0109180917561S.01597@ike> Message-ID: <3BA6630A.3C95DA76@earthling.net> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hate to interrupt your foray into GUI wrappers, but I am here to ask about a new GUI possibility. I see Swing as a very good possible widget set; it is portable to anything with a JVM. Of course, for speed reasons, it would have to be implemented in a _real_ compiled language. I like the layout managers and cross-platform capabilities of Swing. Feel free to string either intelligent replies or flames to this thread; this could very well be a bad idea. - -- CRN: MicroSoft CEO Steve Ballmer has finally said Linux is the No. 1 threat to Windows. What's your response to that? Linus: "Tag, you're it." I don't care. They've had a lot of enemies in their time. Let them fight one enemy that doesn't care for a change. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: Down with the Clipper chip! iD8DBQE7pmLtie0ImkiP3+ERAqQnAJsGUv25XQSjxGmshzSK3ESVyAwr/ACfS0Em +/oXmjmN0RKv7+1VD7HlJTA= =B9nN -----END PGP SIGNATURE----- From doy20 at telcel.net.ve Sun Sep 23 16:06:28 2001 From: doy20 at telcel.net.ve (Doy) Date: Sun, 23 Sep 2001 16:06:28 -0400 Subject: Help plz!!!! Message-ID: <6frr7.1551$7o.278@news01.t-net.net.ve> How do i compile a python scrypt to a exe?????? -- ------------------------------------ Make Unlimited phone calls from your PC to ANY phone in the World! http://www.eboom.com/free/ From wul at protek.no Fri Sep 14 07:19:39 2001 From: wul at protek.no (Arne Wulvik) Date: Fri, 14 Sep 2001 13:19:39 +0200 Subject: Python parsers that parse Java? References: Message-ID: <3ba1e7db$0$24944@ams2eusosrv31.ams.ops.eu.uu.net> Hi! You can also use Jython to convert your Python scripts to Java code right away. Arne "Carlos Gaston Alvarez" wrote in message news:mailman.1000460214.24682.python-list at python.org... > Hi Kevin, > > If you want to do it right you should not execute java source. OK, may be > you can but if they call an api how will you handle it? Also you can insert > parser bugs. > What you should do is to execute the java program (its bytecodes) in a > java virtual machine. > You have two options. > Number one is Jython www.jython.org which is python in java, it runs in > a jvm and it intercases in a really easy way with java. Take a look and see > if it works for you. If so it is the easiest and best way to do it. > The second, but less recomendable is to instanciate a jvm from a C > program (interfaced with java). Download the java jdk and you will see some > source that lets you intancitate and call it from a C program. > > Chau, > > Gaston > > > ----- Original Message ----- > From: "Kevin Dahlhausen" > Newsgroups: comp.lang.python > To: > Sent: Friday, September 14, 2001 2:36 AM > Subject: Python parsers that parse Java? > > > > Is there a readily availble parser written in Python that can parse > > java code? I'm forced to use java for a project, and would like to > > automate some code generation with Python. I don't have a lot of time > > to devote to this, so something ready to go would be best. > > > > Thanks > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > > From Weet.Vanniks at el_simpatico.be Mon Sep 3 07:09:45 2001 From: Weet.Vanniks at el_simpatico.be (Weet Vanniks) Date: Mon, 03 Sep 2001 13:09:45 +0200 Subject: Web Application Server in Python: which one to choose ? Message-ID: <3B9364F8.2C477597@el_simpatico.be> The subject title says it all or almost ... There seems to exist a great offering: Zope, Bobo, Webware,SkunkWeb, Quixote,Twisted, etc... This makes my choice very difficult. Can I get an unbiased opinion about the merits of each of these solutions. I've been told that Zope is complex and that Webware is great. Could you confirm ? Thanks for helping me out. Weet From aleax at aleax.it Fri Sep 14 09:23:07 2001 From: aleax at aleax.it (Alex Martelli) Date: Fri, 14 Sep 2001 15:23:07 +0200 Subject: Namespace confusion References: <9nssgi$oiv$1@news.netcologne.de> Message-ID: <9nt0m002n6j@enews2.newsguy.com> "Luna Tic" wrote in message news:9nssgi$oiv$1 at news.netcologne.de... ... > I get an error message certainly because of the interdependence of those > two modules, am I right? Not really -- you get the error message because you're trying to append (in bar.bacon.__init__) to an attribute (list) that you haven't yet bound in object foo.i. But. Cycles of dependency between allegedly separate parts are an utter disaster in the design of any system, in any language -- they make a mockery of the "separation" and turn it into a nightmare instead. So: the error you made in switching the two statements in foo.foo.__init__ was a lucky one. It alerted you to a deep architectural defect in your design, before that defect bit too deeply. Refactor the defect away NOW -- you'll be glad you did! > How then can I resolve this issue? Note that I'd like to keep those two > files separated. If the components are separated, then you must remove the mutual dependency. Managing dependency is as crucial in software architecture as managing risk is in finance. If you don't manage it, if you just let it happen, you're not architecting software at all -- just like a bank that's not managing risk is not a real financial institution at all. Here, why should classes bar and foo be in separate modules at all, given that the mutual dependency makes a mockery of their alleged "separation"? Put them into one module, say foo. If you have some external constraints (e.g. backwards compatibility) that force you to let _other_ client code import bar and access class bar.bacon, just make file bar.py a compatibility-mandated skeleton which just does from foo import bacon and be done with it... Alex From s.keim at laposte.net Fri Sep 28 11:21:42 2001 From: s.keim at laposte.net (sebastien) Date: 28 Sep 2001 08:21:42 -0700 Subject: "self" vs other names References: Message-ID: <7da8d8f8.0109280721.755ef767@posting.google.com> > > I'd mention the possibility. > not that I subscribe to this, but another common form is simply 's'. You get > things like 's.dict' or 's.pid'. I personnaly prefer stu, because this give me 'stu.pid' ;-) I think, that coherence is more important than 2 characters more or less. If you want to use s. or me., why not ? But if I had to read your code, I'd find you kind to follow the Python habit's to call self 'self' because: - I could use 'self' in grep search in both your and my code - this is the name my brain is trained to, and it is very tired (just look before)... From marcus.nilsson at emw.ericsson.se Thu Sep 6 03:15:39 2001 From: marcus.nilsson at emw.ericsson.se (Marcus Nilsson) Date: Thu, 06 Sep 2001 09:15:39 +0200 Subject: python GUI without windowhandle References: <3B94EB4E.D4416A8C@emw.ericsson.se> Message-ID: <3B97229B.F6A7065C@emw.ericsson.se> Hi again, Yes, I'm using the Tkinter toolkit, Johns's tip to use the overrideredirect(1) worked beautifully, thank you John. However, thers is one little snag, the windows I create without handles show up on every virtualdesktop-window I have, always on top of the other windows. Can I do anything abolut this from pyhton/thinter? Maybe it is a windowmanager thing ... /Marcus From johnroth at ameritech.net Sat Sep 1 15:21:36 2001 From: johnroth at ameritech.net (John Roth) Date: Sat, 1 Sep 2001 12:21:36 -0700 Subject: Bug or feature? References: <3b912589.12116843@news.t-online.de> Message-ID: "Gerson Kurz" wrote in message news:3b912589.12116843 at news.t-online.de... > Consider: > > class a: > def b(self,x): > print "call #1" > > def b(self,x): > print "call #2" > > v = a() > v.b(42) > > This code raises no warning, and can be executed ('call #2' will be > printed), on Python 2.1.1 (ActivePython Build 212). Bug or feature? > > Neither one, I'd say. That's just the way Python's object model works. "def b ..." binds the code object to the variable "b". Since variables aren't typed, there's no way of telling in advance whether you really wanted it to be done once, or not. On the other hand, I've been bitten a couple of times by that one myself, and I'd like to see at least a warning while loading a module. Or maybe not, I can think of several fairly complicated modules that check what's available in the environment, and then select one of several routines to present to the user under that name. John Roth From link99 at 263.net Sat Sep 29 01:23:39 2001 From: link99 at 263.net (link99) Date: Sat, 29 Sep 2001 01:23:39 -0400 Subject: A neat text link exchang website Message-ID: <9p3lo8$142m$1@spnode25.nerdc.ufl.edu> http://go.to/link99 It's Coool! You'll get a neat exchanging link, and never get messy! From nospam at newsranger.com Mon Sep 10 15:21:32 2001 From: nospam at newsranger.com (Norman Shelley) Date: Mon, 10 Sep 2001 19:21:32 GMT Subject: Proposed PEP for a Conditional Expression References: Message-ID: <0p8n7.2614$%u4.8825@www.newsranger.com> I agree that ARG_24 is THE most important point. I believe this same point is THE most important point behind the new assignment feature, e.g. x += 1 x *= 4 .. and the same argument is THE most important point to make for a CASE/SWITCH statement in python. While you're in the PEP writing mode why not create another PEP where ARG_24 is extended and pushed for all areas where it makes sense and show where new features have been added that fit this point. In article , Michael Chermside says... > > >For the sake of full disclosure, I'll also express my own opinion here >(I have tried hard to keep the PEP evenhanded). With reference to the >PEP, I find ARG_1, ARG_3, and ARG_23 unconvincing, while ARG_21, ARG_22, >and ARG_3 all make sense to me. But for me, ARG_24 is the overwhelming >point and convinces me that adding a conditional expression would be a >good idea. Norman Shelley From nmw at ion.le.ac.uk Mon Sep 24 09:05:20 2001 From: nmw at ion.le.ac.uk (nmw at ion.le.ac.uk) Date: 24 Sep 2001 14:05:20 +0100 Subject: Read Matlab files with Python and Numeric? References: Message-ID: gb at cs.unc.edu writes: > Does anyone have an extension for Python+Numeric to read Matlab format > .mat files? I'm trying to get off Matlab after years of use and have > lots of data files that I would like to read. > > Thanks > gb Yes. I have a module which will load MATLAB files. It's not entirely complete but handles most MATLAB files (the most obvious omission is sparse matrices). It requires NumPy as the MATLAB matrices are loaded as Numeric arrays. For MATLAB 5 files, cells are loaded as lists and structures as dictionaries. If the entire contents of the .mat file are loaded then they are returned in a dictionary rather than being inserted into the current workspace as MATLAB does. e.g. >>> import Numeric >>> import matfile >>> a=matfile.load('tau0_GUP_202_12.8.mat') To list the matrices loaded: >>> a.keys() ['Nkill', 'c_addr1', 's_addr1', 'datalen', 'c_addr2', 's_addr2', 'ngup', 'b_addr1', 'b_addr2', 'Sysconst'] or you can load specific matrices which will be returned in a list in the order requested, e.g. to load the datalen and ngup matrices : >>> b=matfile.load('tau0_GUP_202_12.8.mat','datalen','ngup') >>> b [array([ 31632.]), array([ 26278.])] >>> a['datalen'] array([ 31632.]) >>> a['ngup'] array([ 26278.]) >>> b[0][0] 31632.0 >>> a['datalen'][0] 31632.0 If you would like more info e-mail me and I can send details. -- ----------------------------------------------------------- Nigel Wade, System Administrator, Space Plasma Physics Group, University of Leicester, Leicester, LE1 7RH, UK E-mail : nmw at ion.le.ac.uk Phone : +44 (0)116 2523568, Fax : +44 (0)116 2523555 From db3l at fitlinxx.com Tue Sep 4 16:03:28 2001 From: db3l at fitlinxx.com (David Bolen) Date: 04 Sep 2001 16:03:28 -0400 Subject: char** to {'':('',)} References: <9mocc301q7f@drn.newsguy.com> <9n2ofo0aro@enews3.newsguy.com> Message-ID: "Alex Martelli" writes: > That's why try/finally was introduced -- ENSURE "needed cleanup" > does get performed no matter how the try-block is exited (this > includes return as well as exceptions). I can get try/finally in C (the samples of code under discussion)? (Well, I guess MS has some custom extensions that work, but it's not portable) I agree in languages that support it, that the try/finally construct is perfect for this sort of thing. But absent such support, I'm not a big fan of multiple exits from a code path unless really necessary. -- -- 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 davygrvy at pobox.com Thu Sep 6 08:06:07 2001 From: davygrvy at pobox.com (David Gravereaux) Date: Thu, 06 Sep 2001 05:06:07 -0700 Subject: TCL-Python for Windows ? References: <9n7mq9$k1j$1@trinity.hannover.sgh-net.de> <3B9764A8.4060704@winealley.com> Message-ID: Jean-Luc Fontaine wrote: >> If yes - how do make a compilation and install the python package ? > >Unfortunately, I am not knowledgeable in that area, but the only problem >is generating the DLL, although it is only a single C source file. >Installing should be no problem. Uh oh, I didn't send you a binary? I'll email you one tomorrow.. whoops. -- David Gravereaux Tomasoft Engineering, Hayward, CA [species: human; planet: earth,milkyway,alpha sector] Please be aware of the 7.5 year ping times when placing a call from alpha centari From peter at engcorp.com Wed Sep 5 16:10:58 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 05 Sep 2001 16:10:58 -0400 Subject: ipc : dde? References: <20010905120928.B2068@xs4all.nl> Message-ID: <3B9686D2.C5187208@engcorp.com> Carlos Gaston Alvarez wrote: > > I am doing a python applicaction in Windows. I need a grafica aplication > witten in C++ to comunicate with it. > Opening ports is not aceptable. I'm curious _why_ opening ports is not considered acceptable. Is this thought to be a security problem or something? -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From logiplexsoftware at earthlink.net Fri Sep 7 15:59:12 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 7 Sep 2001 12:59:12 -0700 Subject: Nested scopes: why is it weird? In-Reply-To: <3B991FA6.EAB19A71@ActiveState.com> References: <3B98F3B0.53AC2524@swiftview.com> <9nau9o01ni5@enews2.newsguy.com> <3B991FA6.EAB19A71@ActiveState.com> Message-ID: <01090712591203.02565@logiplex1.logiplex.net> On Friday 07 September 2001 12:27, Paul Prescod wrote: > Why forevermore? PEP a change to the behaviour and then we can put in a > warning. Python's current behaviour is both confusing and dangerous and > I would love to see someone champion a change. This just shouldn't > silently do the wrong thing: > > a = 5 > > def foo(): > a = 6 > > It would be better to require one of the names to be changed. It silently does the right thing. Changing the value of a variable from an enclosing scope is a _bad_ idea. This is what is called a "side effect" and was one of the things structured programming was created to prevent. This is bad: >>> a = 5 >>> foo() >>> a 6 If a function is going to alter a global variable or a variable from an enclosing scope, then it should be passed as an argument or returned as a value so that someone reading the code can reasonably expect that variable to be changed. Better: >>> a = 5 >>> a = foo() >>> a 6 Note that _accessing_ a variable from an enclosing scope (or global, for that matter), isn't nearly as bad and again, Python does the correct thing: it allows you to see the variables from the enclosing scope, but the minute you try to assign to them, they become local to the current scope (even if you do the assignment _after_ you try to read the value - this IS confusing if you don't know why) Regards, -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From kahikatea at nissidesign.f2s.com Thu Sep 6 17:45:42 2001 From: kahikatea at nissidesign.f2s.com (Kahikatea) Date: 6 Sep 2001 14:45:42 -0700 Subject: zope installation References: <9ca06fb.0109031830.72f5b863@posting.google.com> <3b949e9f$0$26756$6e365a64@newsreader02.highway.telekom.at> Message-ID: <9ca06fb.0109061345.559f87e2@posting.google.com> Digging a little further (/var/log/zope) reveals that it is hiccuping on something to due with syslog. However, not knowing python I have no idea what to do next..... "Werner Schiendl" wrote in message news:<3b949e9f$0$26756$6e365a64 at newsreader02.highway.telekom.at>... > Hi, > > not a Linux expert, but you normally need to configure which port should be > used for which protocol and purpose. Further, ports below 1024 are > priviledged under Linux. > > I think it is inetd, which needs be configured. Ask some expert in Linux on > how to do it. > > hth > Werner > > "Kahikatea" wrote in message > news:9ca06fb.0109031830.72f5b863 at posting.google.com... > > Unfortunately this is happening to me too. Help! > > > > LeoDeBeo wrote in message > news:... > > > using redhat 7.1, i downloaded and installed the zope and zserver > > > rpm-packages > > > i start zserver by typing: service zope start (sysV-initialization > script) > > > it says that startup was ok but the server immediately dies > > > in the messages file (/var/log/messages), the following error pops up > > > > > > zope: zserver.sh startup succeeded > > > z2[1381]: Startup exception: error: (91, 'Protocol wrong type for > socket') > > > > > > anyone an idea > > > help much appreciated From phd at phd.pp.ru Thu Sep 13 04:03:11 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 13 Sep 2001 12:03:11 +0400 Subject: Reading variable length records... In-Reply-To: <6957F6A694B49A4096F7CFD0D900042F27DBC2@admin56.narex.com>; from BPettersen@NAREX.com on Wed, Sep 12, 2001 at 04:21:47PM -0600 References: <6957F6A694B49A4096F7CFD0D900042F27DBC2@admin56.narex.com> Message-ID: <20010913120311.C18360@phd.pp.ru> On Wed, Sep 12, 2001 at 04:21:47PM -0600, Bjorn Pettersen wrote: > I'm trying to read records from a 2 GB datafile, but my brain has > stopped working, so I was wondering if someone has allready solved this > problem. The records are variable length and are separated by a five > character delimiter. I was trying to use file.read(n) with a blocksize > of ~1Mb, but got a serious brainfart when trying to think of how to > handle the case where only part of the delimiter was read in the current > block. The pattern to do it is called "sliding window", and I recommend to use memory mapped files (if it possible) - theys are simpler to manipulate at this level (and probably faster, as OS will optimize access). Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From thp at cs.ucr.edu Wed Sep 12 07:34:54 2001 From: thp at cs.ucr.edu (thp at cs.ucr.edu) Date: Wed, 12 Sep 2001 11:34:54 +0000 (UTC) Subject: Proposed PEP for a Conditional Expression References: <9nkvss$cmq$1@glue.ucr.edu> Message-ID: <9nnh8u$5qf$4@glue.ucr.edu> Terry Reedy wrote: : wrote in message news:9nkvss$cmq$1 at glue.ucr.edu... :> : WORKAROUND_2: (this SOMETIMES works) :> : > x = c and a or b :> The problem of determining whether or not a given expression ever :> evaluates to false is equivalent to determining whether a given : Turing :> machine halts, i.e., the general case is not algorithmically : solvable. : True, but so what? Most real examples seem to involve constants that : are triviallly either true or false or simple expressions that are : trivial to decide in context. I agree that "most" real examples fall into this category, but we still need a general selection operator for the rest. Also, using the short-circuited evaluation of logical operators for selection is something of a hack. Sure it's an idiom that people can get used to, but I would prefer code to say what it means more directly. Tom Payne From pete at shinners.org Fri Sep 14 11:43:05 2001 From: pete at shinners.org (Pete Shinners) Date: Fri, 14 Sep 2001 15:43:05 GMT Subject: what's the best methode to crypt/encode the python code. References: <3BA210A5.E027C11B@yahoo.com> Message-ID: "vincent delft" wrote > I've written a Python code that check an application (registration > into the DB, execution of commands, ...). And I would like to put > this code on the production machine. My problem is that some > passwords and some private info are into the python code. first, you definitely want the passwords info in a different file than the actual code. overall, the best thing may be to set no "read" access to the file for anyone but yourself. i'm personally not sure how "secure" the windows file access protection is, but if it does what it is supposed to, nobody but you should be able to read the file. it shouldn't be too hard to encrypt the password data. look into the "rotor" module. one problem is that people can always look into your python source to get the decryption "key". perhaps this is a good idea (just came to me). create the key programmatically, based on static file info, like full path, creation time info, etc. this will make it a bit more inconvenient just a simple string key. if someone does get read access to your password file, they'll need a little program of their own (likely cut&pasted from your original source) to create the key for that file. another quick benefit to that is, if someone makes their own copy of your password file, its not going to work anymore (since fullpath, creation time, etc, have changed) that should do it. for better security, i guess no one should have read access to the python script either. (or at least the part of the python code that knows the decoding key). but if you ever share that, they will have all the info they need to get at your password. (again, only if they can actually read the password file) anyways, these are just ideas off the top of my noggin. just to warn you i've never personally done anything that needed security like this, so there may be some unintentional backdoors here :/ From nas at python.ca Tue Sep 4 15:58:29 2001 From: nas at python.ca (Neil Schemenauer) Date: Tue, 4 Sep 2001 12:58:29 -0700 Subject: Hi, there In-Reply-To: <3B952D01.7735584A@zumnet.com.br>; from rafael@zumnet.com.br on Tue, Sep 04, 2001 at 04:35:29PM -0300 References: <682EFA0F37A1D511868700B0D0D1AB7A31BBDB@ISTECH4> <3B952D01.7735584A@zumnet.com.br> Message-ID: <20010904125829.A12636@glacier.arctrix.com> Rafael Mentz Aquino wrote: > So I get a great result doing something like that...: > > a=string.split(os.popen("ls").read(),"\n) Perhaps you want: os.listdir(".") instead. Neil From slinkp23 at yahoo.com Mon Sep 17 14:21:36 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Mon, 17 Sep 2001 18:21:36 GMT Subject: No spam in books References: <9o4kr6.3vv3q41.1@kserver.org> Message-ID: >:Andrew Nguyen wrote: >:> The O'Reilly books have no mention of spam. I seem to remember a lot of spam in Learning Python... let's go see. The chapter examples can be downloaded from: http://examples.oreilly.com/lpython/ [pw]$ grep "spam" examples/*.txt solutions/*.txt | wc --lines 102 In other words, there are 102 lines containing the word "spam" in the examples and solutions in Learning Python. --Paul Winkler From James_Althoff at i2.com Tue Sep 4 14:05:05 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Tue, 4 Sep 2001 11:05:05 -0700 Subject: how to distinguish a python expression from a statement? Message-ID: Thanks for your response, Peter. Actually, that is the approach I had been experimenting with. But I was worried that catching the SyntaxError in eval as a way of "discovering" a statement (as opposed to an expression) could somehow mask an actual syntax error in an expression. But in thinking about it more, I guess there is no problem with that since the exec works on both expressions and statements. And so a bad expression passed to exec will result in exec throwing a SyntaxError a second time, which I suppose is fine for my purposes. I will also look into the code module more. But I'm not really doing an exact replica of the interactive Python interpreter. I'm doing a GUI-based variant that is more like a Smalltalk workspace -- but with the twist that the output always goes into a separate (from the input) text pane. Maybe the code module will still help. Thanks again, Jim Peter Hansen wrote: ===================== James_Althoff at i2.com wrote: > > I have a string, inputText, which is a fragment of python code plucked from > a text control in a GUI. If the value of inputText is an expression then > I will do "result = eval(inputText,globalsDict,localsDict)" and show result > in the GUI. If it is a statement, I will do "exec inputText in > globalsDict, localsDict" (and I know about redirecting sys.stdout while > doing either). > > I have all of this working except that I don't know how to distinguish > between expressions and statements (without making the end user push one of > two different buttons in order to tell me -- yuk). I am using Jython and > so the parser module is not available (so I can't use parser.isexpr). > > Is there any means to accomplish this what-I-had-thought-would-be-routine > task short of writing a Python parser? This might give you some ideas: >>> def f(str): ... try: ... result = eval(str) ... except SyntaxError: ... exec str ... result = None ... return result ... >>> f('5*5') 25 >>> f('print "hi"') hi >>> On the other hand, as some kind soul showed me when I asked a related question a while back, there are also the modules 'codeop' and 'code', which probably already have want you need... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com -- http://mail.python.org/mailman/listinfo/python-list From phd at phd.pp.ru Thu Sep 6 12:14:53 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 6 Sep 2001 20:14:53 +0400 Subject: Suspected Unicode problem when reading text from Excell In-Reply-To: <20010906174145.A14840@qrnik.zagroda>; from qrczak@knm.org.pl on Thu, Sep 06, 2001 at 05:41:45PM +0200 References: <3b9611ec$0$262$edfadb0f@dspool01.news.tele.dk> <20010906191004.B29330@phd.pp.ru> <20010906174145.A14840@qrnik.zagroda> Message-ID: <20010906201453.H29330@phd.pp.ru> On Thu, Sep 06, 2001 at 05:41:45PM +0200, Marcin 'Qrczak' Kowalczyk wrote: > > > This is a great evidence that the default encoding should be the one > > > specified in the locale, not ASCII. > > > > FAQ 4.102: > > http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.102.htp > > I meant that it should be changed in the default installation, Are there many people who BY DEFAULT want to configure locale and import locale module? Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From jbranthoover at yahoo.com.NOSPAM Thu Sep 13 16:27:34 2001 From: jbranthoover at yahoo.com.NOSPAM (John Branthoover) Date: Thu, 13 Sep 2001 20:27:34 GMT Subject: Newbie: How To Convert A Float Into Two Sixteen Bit Integers.....? Message-ID: Hello All, Can any tell me how I can take a single precision floating point number and convert it into two sixteen bit integers using Python? I need to store some floating point numbers in a eight bit wide EEPROM. Any information that you can give me will be greatly appreciated. Thank you for your time. From wayne at tbnets.com Wed Sep 5 22:55:29 2001 From: wayne at tbnets.com (Wayne Ringling) Date: Wed, 5 Sep 2001 22:55:29 -0400 Subject: Question on python script in c wrapper with apache. Message-ID: I am trying to use a python script to run as root for small special tasks. I have done the following and at the present getting these errors. Compiled setuid-prog.c with the below command cc -DFULL_PATH='"/some_dir/myscriptname.py"' setuid-prog.c -o myscriptname Copied the wrapper to my web servers cgi-bin dir and it has (for now) 755 permissions. Next I created /some_dir/myscripname.py as follows and it has permissions 755. ---------------------------------------------------------------------------- ------- #!/usr/bin/python import string lines = open('/etc/passwd').readlines() dict={} for line in lines: splitline = string.splitfields(line, ':') uid = splitline[2] dict[string.atoi(uid)] = line keys = dict.keys() keys.sort() print 'Content-type: text/html\n\n' for uid in dict.keys(): print dict[uid], ---------------------------------------------------------------------------- -------- The script runs fine from command line but not from the web server. Error msgs are : access_log: XXX.XXX.XXX.XXX - - [06/Sep/2001:04:48:52 +0000] "GET /cgi-bin/admin HTTP/1.1" 500 614 error_log: myscriptname: could not execute the script [Thu Sep 6 04:48:52 2001] [error] [client XX.XX.XX.XX] Premature end of script headers: /usr/local/httpd/cgi-bin/admin Any ideas greatly appreciated. Wayne From pinard at iro.umontreal.ca Mon Sep 17 10:14:15 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 17 Sep 2001 10:14:15 -0400 Subject: Pymacs - tuples/lists .vs. proper-lists/vectors In-Reply-To: <6e0ad3b1.0109170126.47a97bdb@posting.google.com> References: <6e0ad3b1.0109170126.47a97bdb@posting.google.com> Message-ID: [Brian McErlean] > While there are patterns I use in python with lists that rely on extending, > eg. building lists like: > l=[] > while cond: > > l.append(next_element) > I wouldn't use a similar pattern in lisp with either lists or tuples, > so I don't think this is an issue. Very, very often, people write things like: (setq accumulator (cons 'new-item accumulator)) or more simply: (push accumulator new-item) That is, proper lists are good for appending stuff, yet in LISP, we "append at the beginning" for speed. So, proper lists in LISP and lists in Python are the normal things for which length is easily modified. Some .reverse() or (nreverse ...) operation might be needed on either side in case speed is especially important and many modifications happen in a row on the same side, while order of elements ought to be preserved. We cannot so easily change the size of a vector, the same as it requires a bit more stunts to "modify" a tuple. The shape of these objects is fixed. > Don't underestimate the benefit of similar syntax too. I think it is > a useful reminder. Yes. This has been one point in my reluctance to the change. Now that it is done, I think it will not be difficult (for me at least) to get used to the equivalence. Note that in Python, both tuples and lists have O(1) access. So, there is no real speed consideration there. LISP is different: vectors have O(1) access while lists have O(N) access. But the rigidity of LISP vectors is such that people do not resort to vectors unless there is a speed issue, so in real LISP practice, vectors are used parsimoniously. So parsimoniously, in fact, that LISP vectors are overloaded for what they are not meant: for example, very small vectors are used to represent X events in key-maps, programmers only want to test for the vector type, and users like bracketed syntax. Speed of access is hardly an issue. Whenever, under the new Pymacs scheme, a LISP vector is needed, one has to write `tuple(python_list)' while transmitting the object. Such transmissions are most probably to be unusual, as people are not going to blindly transmit whole big structures back and forth between Emacs and Python, they would rather do it once in a while only, and do only local modifications afterwards. Since LISP proper lists and Python lists are the bread-an-butter of algorithms modifying structures, at least in my experience, I guess they are more naturally mapped into one another, this will spare many casts. Mapping vectors to tuples, which is admittedly strange, will only be done if the Python side requests an expanded copy, otherwise an opaque LISP object is seen in Python. While in the other direction, the infrequent casting to `tuple' for getting a LISP vector seems to be a reasonable compromise. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From aleax at aleax.it Thu Sep 13 06:26:02 2001 From: aleax at aleax.it (Alex Martelli) Date: Thu, 13 Sep 2001 12:26:02 +0200 Subject: What is Python good for? References: <6f8cb8c9.0109120541.132432d4@posting.google.com> Message-ID: <9nq1js01qvh@enews2.newsguy.com> "Ken Seehof" wrote in message news:mailman.1000336096.664.python-list at python.org... ... > purpose language. In fact, there really isn't any fancy trademark > ooh-aah feature to set python apart. It's just a general purpose > language done particularly well. Maybe not "fancy trademark", but the extremely simple way in which Python exposes most internals does keep making ME go "ooh-aah" -- it's really _close_ to Scheme in this, but I think it goes even farther. One of my happiest recent moments was finally coming up with a *simple* way to do away with the durned Singleton design-pattern in favour of arbitrary numbers of instances sharing shate -- and finding out that all it takes is adding *one* simple statement to __init__, see http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531 for the idea (& quite a bit of somewhat-heated discussion with Singleton-lovers on the issue:-). Alex From nhodgson at bigpond.net.au Mon Sep 10 18:21:24 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Mon, 10 Sep 2001 22:21:24 GMT Subject: windll/win32client question References: <3B9D0A16.AEF5BB0D@integretechpub.com> Message-ID: Alex Rice: > I tried using python's calldll/windll to access the functions in the > .dll. However, the "preferred entry point" for this SDK is the .wll > file. Furthermore the .wll defines extra functions which I need which > are not defined in the .dll. The .dot files AFAIK are just VBA wrappers > for the .dll and .wll functions. So I need to access the .wll. The way that a WLL works is to expose one function (easily callable using calldll) which then calls back into the host (Word) to register the functions. Creating a suitable host environment in Python would be difficult. If you really need this functionality and see no other way to access, then consider writing a WLL hosting environment in C. There is an article on WLLs in the May 1994 Microsoft Systems Journal. Neil From barthe at magic.fr Wed Sep 5 10:58:57 2001 From: barthe at magic.fr (Alain Barthe) Date: Wed, 05 Sep 2001 15:58:57 +0100 Subject: How to get the return status of a command runned by os.popen4 References: <3B93C945.EB6DF7A8@magic.fr> <93d52e82.0109040657.68633c40@posting.google.com> Message-ID: <3B963DB1.A5CEE481@magic.fr> > > Alain, > > I've had good luck on Windows NT 4 with the following combination: > > cmdPipe = os.popen(aCmdLine) > resultStream = cmdPipe.read() > > At this point you can read resultStream for any stdout feedback > returned by aCmdLine. Is that what you need? Not really. I catch easily stdout, stdin and stderr. My need is to catch the decimal return code of the command. On UNIX, 0 means success, anything else means failure. With os.popen, the close method returns this decimal code: cmdPipe = os.popen(aCmdLine) return_code = cmdPipe.close() With os.popen4, it does not :-( Thanks Terry. Another idea ? > > -Terry > > Alain Barthe wrote in message news:<3B93C945.EB6DF7A8 at magic.fr>... > > Hi, > > > > I cannot get the return status of a command runned by os.popen4 or > > popen2.popen4. File closing does not return the status as os.popen does. > > > > I can get it with an object popen2.popen4, but it's not Windows > > compliant. > > > > Anybody has the solution ? > > > > Thanks. -- Alain Barthe From aahz at panix.com Mon Sep 17 00:58:09 2001 From: aahz at panix.com (Aahz Maruch) Date: 16 Sep 2001 21:58:09 -0700 Subject: nested-scopes redux References: Message-ID: <9o3vt1$v8$1@panix1.panix.com> In article , Cliff Wells wrote: > >Sorry to bring this subject back up again, but I just noticed a somewhat >annoying feature of the current nested-scope implementation. One of the big >pluses of nested scopes is doing away with default arguments in lambda >functions. Unfortunately the following bits of code behave differently: > >foo = [] >for i in [1, 2]: > foo.append(lambda i = i: i) > >and > >from __future__ import nested_scopes >foo = [] >for i in [1, 2]: > foo.append(lambda: i) > >In the first case the output from foo[0]() and foo[1]() is 1 and 2, >respectively - and it's what one would probably want. In the second case, >the output is always 2. This may be the expected behavior, but it kind of >does away with the benefits to providing a cleaner lambda call. Because I'm not qualified to answer this, I posted this to python-dev, and Guido sent this response: Cliff expects variable references to be bound to the value. That's not how it works -- the idea of nested scopes is that the owner of the variable (the surrounding scope) can change the variable's value, and the user (the inner scope) will pick up the changes. This is useful e.g. when an outer function calls an inner function repeatedly. This is how nested scopes work in other languages. If Cliff wants to create N different lambdas with N different values for i, he'll have to do it the old way. Can you post this reply? --Guido van Rossum (home page: http://www.python.org/~guido/) Tim Peters noted somewhat acerbically that I'd ignored a long thread from last week that covered this issue in great detail, which is probably why your post didn't get a response. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista We must not let the evil of a few trample the freedoms of the many. From markus at schabi.de Wed Sep 26 03:59:03 2001 From: markus at schabi.de (Markus Schaber) Date: Wed, 26 Sep 2001 09:59:03 +0200 Subject: Are there 'Interfaces' in Python?? References: <9orb19$ba6$1@slb6.atl.mindspring.net> <7xzo7ipvok.fsf@ruckus.brouhaha.com> Message-ID: <2168206.PzL39ZcT7Z@lunix.schabi.de> Hi, Richard Jones schrub: > On Wednesday 26 September 2001 11:50, Paul Rubin wrote: >> "tszeto" writes: >> > Was wondering if Python supported 'Interfaces' (something akin to >> > Java interfaces)? Or if there's a workaround to get the same thing. >> >> Java interfaces are a workaround for java's non-support of multiple >> base classes in objects. Python supports multiple base classes, so >> it doesn't need a workaround for their absence. > > Er, no. They may be percieved as that, but since interfaces can't > actually _do_ anything, whereas multiple inheritance _can_, I believe > this is a dead herring. It gets even somehow perverse in java: interfaces can bring code with them in the never java versions, using inner classes: public interface container { public class embedded { public void test() { System.out.println("Hello"); } } } > Interfaces are an extremely useful form of "type" checking for OO > systems. Python already has "interfaces" in the form of agreed methods > - witness the "pass a file-like object" requirements in a lot of APIs. > An interface would just formalise that. That is correct. In a lot of cases, such interfaces are a helpful instrument to find bugs, because they force such agreements. But the way they are implemented in Java, those are not as flexible as someone could wish it in some cases. Python doesn't enforce anything, thus the programmer has to know what he does - but he also can do whatever he wants because he knows what he does. markus -- "The strength of the Constitution lies entirely in the determination of each citizen to defend it. Only if every single citizen feels duty bound to do his share in this defense are the constitutional rights secure." -- Albert Einstein From aleax at aleax.it Thu Sep 13 09:18:23 2001 From: aleax at aleax.it (Alex Martelli) Date: Thu, 13 Sep 2001 15:18:23 +0200 Subject: What is Python good for? References: <6f8cb8c9.0109120541.132432d4@posting.google.com> <9nnsck02uat@enews1.newsguy.com> Message-ID: <9nqbmv023f7@enews2.newsguy.com> "Cameron Laird" wrote in message news:DB970ED273F1D438.26EBEC5BA8411626.AA8111A85F31A2C1 at lp.airnews.net... ... > There's abundant evidence, in my estimation, that the > mass of programmers who "hand-tune C code" *degrade* > their applications' performance. Alex knows this, of Agreed, because said "mass" is [a] tuning WAY prematurely, [b] working on a mental model of the underlying machines' (and compilers') abilities that's typically 20 years out of date, [c] tinkering at the margins of architectures that most often have some major performance bottlenecks due to unfortunate design choices. Fortunately it most often doesn't matter since the apps' performance is plenty good enough anyway (which is also why we get to use Python so widely:-), but it IS fun (in a perverse way) to think of that much wasted effort. > course. He also knows that C itself doesn't reach > compromise-free "100% hardware performance". Not in the general case, sure (it will never fully exploit very high level, very special purpose machine instructions -- it's unlikely in the extreme that those instructions' semantics exactly match the ones needed for C...). But for CPU's developed in the last few years, those 'big' instructions are there for backwards compatibility anyway -- it's faster to use the simpler/slimmer intructions:-). Modern C/C++ compilers are pretty good at generating CPU specific code that optimizes cache use, overlaps, branch prediction and so on -- and the CPU's are well tuned to the compilers' abilities, since those are known to dominate the benchmarks that will be used to choose a CPU:-). Sure, one can in theory do a little bit better still. In practice, though, I've had no occasion to write machine-code in anger over the last 6/7 years -- and the few times I tried just to keep in practice, I was humbled to see optimizing compilers' generated code run rings around mine (well, I'm exaggerating, OK, but the compilers' code WAS faster, when using the specific CPU models they targeted -- I just can't wrap my brain around the pipeline tricks &c as effectively as the compilers' authors can:-). Alex From slinkp23 at yahoo.com Tue Sep 25 13:57:07 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Tue, 25 Sep 2001 17:57:07 GMT Subject: Proposal: add vector arithmetic to array module References: <7x4rprs2cl.fsf@ruckus.brouhaha.com> <3BB0B2CA.96C5681B@home.net> <7xelovql5y.fsf@ruckus.brouhaha.com> Message-ID: On 25 Sep 2001 09:39:53 -0700, Paul Rubin wrote: >Chris Barker writes: >> BTW, MacPython includes Numeric, and it is part of the extended module >> support of ActiveState Python, so it's really not hard for your users to >> download. > >What if they're not using Macintoshes? You missed half the statement above: "it is part of the extended module support of ActiveState Python" From pinard at iro.umontreal.ca Mon Sep 10 17:56:43 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 10 Sep 2001 17:56:43 -0400 Subject: Releasing Pymacs 0.3 Message-ID: Hi! A new release of Pymacs is available as: http://www.iro.umontreal.ca/~pinard/pymacs/pymacs-0.3.tar.gz Pymacs allows Emacs users to extend Emacs using Python, where they might have traditionally used Emacs LISP. Pymacs runs on systems having sub-processes. Installation is now done using a small `Makefile', see `README' for details. Improvements went to portability and protocol error detection. Reported bugs have also been corrected. Thanks to all people who gave feedback. Reports and comments are welcome! (mailto:pinard at iro.umontreal.ca) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From donod at home.com Wed Sep 26 01:28:10 2001 From: donod at home.com (Don O'Donnell) Date: Wed, 26 Sep 2001 05:28:10 GMT Subject: importing symbols from module objects References: <7xd74eephr.fsf_-_@ruckus.brouhaha.com> Message-ID: <3BB1681D.762AA451@home.com> Paul Rubin wrote: > > Is there a non-messy way to import a symbol from a module object? > I don't see one but I might be missing something. ... I'm probably missing something here, but why not just: SpamException = breakfastdish.SpamException ??? -Don From peter at engcorp.com Sun Sep 23 10:35:37 2001 From: peter at engcorp.com (Peter Hansen) Date: Sun, 23 Sep 2001 10:35:37 -0400 Subject: Realtime capabilities? References: <9o8033$mhf$04$1@news.t-online.com> <9oienp$h40$1@panix2.panix.com> <3BACEA2C.EBE41B5E@engcorp.com> Message-ID: <3BADF339.52D329F1@engcorp.com> Peter Hansen wrote: > > Aahz Maruch wrote: > > > > In article <9o8033$mhf$04$1 at news.t-online.com>, Ben wrote: > > > > > >some of you have probably heard (or even used) Erlang (www.erlang.org) --- > > >a functional programming language which is executed by a virtual machine. > > >One interesting property of this VM is guaranteed soft realtime execution > > >of the Erlang processes. > > > > > >My question is whether it is possible to add (soft) realtime capabilities > > >to the Python VM with reasonable effort? I'm just curious and not being an > > >expert of any of the existing Python implementations I thought some of you > > >might have a better understanding of this issue and can comment on this? > > We might be better guided by the terminology as defined by those > who actually _do_ realtime work, as opposed to whatever it is > these Erlang people are (those who just write about it?). Before I get too badly flamed for this one, I'll admit I'd overlooked _who_ "these Erlang people" actually were, and had I realized they were Ericsson I would have investigated further to see whether they were really making statements such as "the VM guarantees soft realtime execution", which out of context is meaningless to someone doing realtime work. Paul Foley emailed me (maybe it will come to the list, too): > FWIW, "these Erlang people" are primarily Ericsson, a large > manufacturer of telephony equipment (driving which is the purpose they > created Erlang in the first place, though it's apparently quite widely > used outside Ericsson nowadays, too). [It's designed for, and running > in, real life hard realtime high availability applications. So no, > they don't just write about it] Thanks Paul :-). After looking at their FAQ, however, I see they only talk about providing soft realtime support, not hard realtime. Since they don't explicitly say there is any hard realtime guarantee, I wonder whether the applications you refer to are not just the telecomm apps they talk about below, which are "soft". I may have overlooked other information. They have these excellent definitions in the FAQ (so they clearly know something about the issues): """ A hard realtime system is one which can guarantee that a certain action will always be carried out in less than a certain time. Many simple embedded systems can make hard realtime guarantees, e.g. it is possible to guarantee that a particular interrupt service routine on a Z80 CPU will never take more than 34us. It gets progressively harder to make such guarantees for more complex systems. Many telecomms systems have less strict requirements, for instance they might require a statistical guarantee along the lines of "a database lookup takes less than 20ms in 97% of cases". Soft realtime systems, such as Erlang, let you make that sort of guarantee. """ Note the last sentence. One can guarantee a particular response characteristic, but if it leaves 3% of the cases open to question it is not deterministic, therefore not "hard" realtime. (Note, for those new to realtime, that the absolute values are not relevant. The above examples code just as easily have been "34ms" for the hard realtime case, and "20us in 97% of cases" for the soft realtime case. All that matters between hard and soft is whether the response is deterministic.) Peter Hansen wrote: > Python is definitely suitable for "soft" realtime applications, > by any definition of "soft" the realtime people generally accept. > I use it in several complex "soft" realtime applications. Judging by the FAQ, it appears that to some extent they believe Erlang's suitability for soft realtime revolves around the lightweight-ness of the threads, providing fast switching and therefore lower latency, and the fact that garbage collection is on a per-process basis. Neither of these issues is in any way involved in determining whether something is "soft" or "hard" realtime, but it can make a language more or less suitable _in a particular application_, such as Ericsson's. Python can be restricted to use only reference counting, which is more deterministic than garbage collection inherently. Note that Erlang's implementation is unsuitable for their claims anyway (and even their "per-process" garbage collection halts other processes while running!). """ The current GC is a "stop the world" generational mark-sweep collector. Each Erlang process has its own heap and these are collected individually, so although every process is stopped while GC happens for one processes, this stop time is expected to be short because each process is expected to have a small heap. """ The first item they mention in the FAQ, however, is "Language features which make it hard(er) for programmers to roughly estimate performance were never added to Erlang. For instance, Erlang doesn't have lazy evaluation." This statement is important to the issue. In fact, it's the only statement that is important. There are probably features in Python which make it difficult to estimate performance, even roughly, so unless you are willing to exclude those features, it might be fair to say Erlang is "more suitable" than Python in this regard, so long as you realize "more suitable" means simply "more amenable to analysis and estimation". Peter Hansen wrote: > No language is suitable for hard realtime without a hard > realtime operating system underlying it (unless you dispense with > operating systems entirely, as in an embedded system). Either > Python or Erlang could probably be used for hard realtime work with > adequate analysis and measurement, since all you really need to do > is guarantee the maximum duration of each of the operations > performed _in the actual application_. If there are no operations > which are used in the program which have unbounded execution times, > then it is possible to guarantee the response time to an external > stimulus, meaning you can call it "hard" realtime. Revisiting this statement after learning just enough more about Erlang to be dangerous, I'll venture way out on a limb and say that it seems that *Python* is more suitable for hard realtime work than Erlang, but that Erlang is more suitable for most types of work which people refer to as "soft" realtime. Usually people talking about "soft" realtime think that short context switch times are somehow important. What they really mean is that for *their* application, short context switch times are very important. Since Erlang was obviously designed specifically to provide low latency (other than that danged garbage collector), it probably suits the needs of some "soft" realtime applications better than Python does. Stackless Python, with which I have no experience, probably works almost as well in this regard. And all any of this says is that without defining the context (e.g. telecomm apps which needs 20ms response 97% of the time), generalizations about which language is "better" than the other are misleading or meaningless. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From ignacio at openservices.net Thu Sep 20 22:16:10 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Thu, 20 Sep 2001 22:16:10 -0400 (EDT) Subject: Where is my memory usage? (getrusage) In-Reply-To: <859c71be.0109201757.45a0f5b@posting.google.com> Message-ID: On 20 Sep 2001, Soren Ragsdale wrote: > ============================================================== > linux-i386 > Self (0.01, 0.01, 0, 0, 0, 0, 115, 293, 0, 0, 0, 0, 0, 0, 0, 0) > Child (1.88, 0.55, 0, 0, 0, 0, 34597, 507, 0, 0, 0, 0, 0, 0, 0, 0) > ============================================================== > irix646 > Self (0.04718, 0.047292, 320, 0, 0, 0, 182, 6, 0, 17, 0, 0, 0, 0, 61, > 103) > Child (3.722367, 0.582003, 102784, 0, 0, 0, 208, 0, 0, 1, 0, 0, 0, 0, > 43, 0) > ============================================================== > > Why doesn't getrusage report the memory usage of my child process? It > looks like this bug only appears under linux in both 2.2 and 2.4 > kernels. To refresh your memory: Looking through the Linux source code, it appears as though getrusage() only provides values for elements 0, 1, 6, 7, and 8. -- Ignacio Vazquez-Abrams From tjreedy at home.com Wed Sep 12 22:02:22 2001 From: tjreedy at home.com (Terry Reedy) Date: Thu, 13 Sep 2001 02:02:22 GMT Subject: Proposed PEP for a Conditional Expression References: <6qvgire4bk.fsf@abnoba.intevation.de> <9nk3jd$4lc$1@glue.ucr.edu> <9nnsa3$bjl$1@news.mathworks.com> <3BA00239.DECE6412@cosc.canterbury.ac.nz> Message-ID: "Greg Ewing" wrote in message news:3BA00239.DECE6412 at cosc.canterbury.ac.nz... > "Terry Reedy" : > > > I agree that the above is backwards. > > if else > > No! That sounds way too much like Forth! It is exactly like C, whose ? : equivalent is the impetus for the proposed change. Of course, if you don't like the form of C's conditional expressions, you won't like its translation into Python. Terry J. Reedy From dalke at dalkescientific.com Fri Sep 7 19:33:22 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Fri, 7 Sep 2001 17:33:22 -0600 Subject: trouble running Grail References: Message-ID: <9nblb9$koi$1@slb4.atl.mindspring.net> Lance E Sloan: > massaged.append((g, c), v % fparms_dict) > TypeError: append requires exactly 1 argument; 2 given > >Why would the Grail author give two arguments to append? Was >there an old version of Python that allowed two arguments? Old, old Python would append all arguments, and if there's more than one would put them in a tuple. Newer (1.2?) Pythons deprecated it. Newest Pythons (2.x) make it illegal. Things should work if you change > massaged.append((g, c), v % fparms_dict) to append a tuple explicitly, as in > massaged.append(((g, c), v % fparms_dict)) Andrew From backslash at student.vsu.ru Mon Sep 24 11:35:01 2001 From: backslash at student.vsu.ru (Dmitry Sustretov) Date: 24 Sep 2001 08:35:01 -0700 Subject: wxWindows dialog designer Message-ID: <3385be36.0109240735.32fba204@posting.google.com> Hello ! I'm looking for free wxWindows/wxPython dialog designer. wxDesigner seemed to do the thing, but, alas, was not free. -- Dmitry From sallison at netcomuk.co.uk Fri Sep 14 12:29:06 2001 From: sallison at netcomuk.co.uk (Steve Allison) Date: 14 Sep 2001 09:29:06 -0700 Subject: COM, Recieve by reference Message-ID: <8a8e724d.0109140829.2400dc5d@posting.google.com> Hi, I'm just starting out to investigate whether Python is a good choice of language for COM development. One problem I have come across is how to pass variables into Python COM servers by reference. For instance, in C++ I can have a COM server with a method like: int MyComServer::foo(int* x, int* y) { *x = 21; *y = 64; return OK; } so the COM client's x and y variables are set to 21 and 64 respectively. I can't see how this can be achieved in Python. As I understand it the following: class MyComServer: def foo(self, x, y): x = 21 y = 64 simply creates local copies of x and y and so teh callers copy of those variables is left unset. Is there a way of having a Python COM server recieve and use variables passed by reference? Thanks for any help Steve. From heikowu at ceosg.de Mon Sep 17 16:55:04 2001 From: heikowu at ceosg.de (Heiko Wundram) Date: Mon, 17 Sep 2001 22:55:04 +0200 Subject: :-) In-Reply-To: References: Message-ID: <01091722550405.01695@phoenix> On Monday 17 September 2001 22:40, Roman Suzi wrote: > On 17 Sep 2001, :-) wrote: > > [snip] > > What worries me, that our domain was put in the "From". Please, do not > reply to the message blindly! They did not put a From:-header in the Message. If a mailserver (at least sendmail does that the way it's normally configured) doesn't find the From:-header, it inserts it as coming from the postmaster or something appropriate of the main mail relay site. I for example have localhost at post.webmailer.de as the sender of that message. (post.webmailer.de is my mailexchange gateway) Don't worry, everyone got something different; there'll be noone to trace it back to you! ;) > > Sincerely yours, Roman Suzi -- Yours sincerely, Heiko Wundram From Michael at RCP.co.uk Wed Sep 5 10:34:10 2001 From: Michael at RCP.co.uk (Michael Abbott) Date: Wed, 5 Sep 2001 15:34:10 +0100 Subject: Stackless Python and Python 2.x Message-ID: <217F6DFA440ED111ACDA00A0C906B00601AAE70C@arsenic.rcp.co.uk> Skip Montanaro (skip at pobox.com): > I believe simple generators can only yield back to their caller, so all > that's necessary (in my simple-minded view of things) is to retain a > reference to the stack frame when yield is executed and not reinitialize the > stack frame the next time the generator is called. I'm pretty sure that doesn't work for generators, because I suspect that part of the point of their simplified implementation is that only one stack frame is required. In particular, this probably means that the generator's stack frame has to be "torn down" each time the generator yields back to its caller. From porter at et.byu.edu Tue Sep 11 16:28:48 2001 From: porter at et.byu.edu (C. Porter Bassett) Date: 11 Sep 2001 13:28:48 -0700 Subject: idea: Robocode for Python References: <84552519.0109110751.6abc9e27@posting.google.com> Message-ID: <84552519.0109111228.1071dc1d@posting.google.com> > Looks like some naming problem. I don't know how this is handled with > jython. As said above in java you usualy write one public class per file > and the file must have the name of the class + '.java'. The Java compiler > produeces then a file with the class name + '.class'. I think jython should > create a file named pyrobot.class in your case. > Yes, I get files called pyrobot.java, pyrobot.class, and pyrobot$_PyInner.class. From ignacio at openservices.net Thu Sep 6 02:45:36 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Thu, 6 Sep 2001 02:45:36 -0400 (EDT) Subject: lexical closures and python In-Reply-To: <20010905225609.A18903@BinQ.org> Message-ID: On Wed, 5 Sep 2001, John Beppu wrote: > Hi, > > My understanding is that Python does not support lexical closures. > I've also heard that it should not be expected to appear any time > in the near future. Can anyone confirm or deny this? Based on what I understand about lexical closures (which, BTW, to begin to understand I had to go through LISP 101, Beginning LISP, LISP for Dummies, LISP for Idiots, and LISP for Complete F*cking Morons... ;) ), no, Python does not support them directly. You can use a modified/perverted form of them by exploting the fact that default values in functions are evaluated once only: --- >>> def func2(a={}): ... print a ... if a=={}: ... a['foo']='bar' ... print a ... >>> func2() {} {'foo': 'bar'} >>> func2() {'foo': 'bar'} {'foo': 'bar'} >>> --- but I don't think that that's quite the same thing. Other than lambdas, you can also mention the map(), reduce(), and filter() functions, which as I may have heard somewhere do FP-like operations. Also, I gotta ask: How the hell does JavaScript support them? -- Ignacio Vazquez-Abrams From boyd at insultant.net Sat Sep 22 21:27:32 2001 From: boyd at insultant.net (Boyd Roberts) Date: Sun, 23 Sep 2001 03:27:32 +0200 Subject: Near Final PEP 247 - API for Cryptographic Hash Functions References: <20010921143506.F16738@phd.pp.ru> <1001136038.838566@yabetcha.drizzle.com> Message-ID: <9ojdvi$a8h$1@neon.noos.net> MD5 deals with bits, not bytes. i think there's a problem with: digest_size An integer value; the size of the digest produced by the hashing objects created by this module, measured in bytes. You could also obtain this value by creating a sample object and accessing its 'digest_size' attribute, but it can be convenient to have this value available from the module. Hashes with a variable output size will set this variable to 0. normally we're dealing with bytes, but, for the sake of argument, the digest size should be measured in bits. to quote _network security_: http://www1.fatbrain.com/asp/bookinfo/bookinfo.asp?theisbn=0130614661&vm= The message digest is a 128-bit quantity. it just so happens that this is divisible by 8. i am also unconvinced of the semantics of: update(arg) Update this hashing object with the string 'arg'. it's unclear whether update() appends or replaces. now if update() appends then it's ok, but if it replaces you'll only ever be able to checksum stuff that fits in memory. due to the padding of the last block, it only really make sense to call digest() right at the end. bundling it all into one crypto module is probably a bad idea. future hash functions may not fit the current model. >>> m.hexdigest() '900150983cd24fb0d6963f7d28e17f72' i think the digest should be returned as an ascii hex string (as above). it only makes sense to do equality comparisons; LongType seems to me to be overkill. From ws-news at gmx.at Wed Sep 5 05:59:18 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Wed, 5 Sep 2001 11:59:18 +0200 Subject: Registering COM Server dynamically ?? References: <8f8ffe67.0109040504.7acd1022@posting.google.com> <9n2ltk$505p6$1@ID-11957.news.dfncis.de> <8f8ffe67.0109041235.6e3c2718@posting.google.com> Message-ID: <3b95f828$0$28408$6e365a64@newsreader02.highway.telekom.at> Hi, > > Actually I'm using Python COM objects from VB. Since the vbprogram.exe > will need to call these objects, I thought I have to register them on > each machine where the program is used since I (guess) I cannot use > the same _clsid_ part. > Why shouldn't you register the same class with the same CLSID on every machine? This is the desired way to register a class! (A class ID identifies a particular class, _not_ a particular installation of that class) regards Werner From heikowu at ceosg.de Mon Sep 17 13:42:40 2001 From: heikowu at ceosg.de (Heiko Wundram) Date: Mon, 17 Sep 2001 19:42:40 +0200 Subject: Exceptions - built-in and home-grown In-Reply-To: References: Message-ID: <01091719424000.01695@phoenix> On Monday 17 September 2001 18:42, you wrote: > Where can I find a list of all the built-in Python exceptions? Look at the Python Library Reference (chapter 2.2, I think..., somewhere at the beginning). > Why would I want to define my own exceptions if suitable Python ones > exist? You should want to define your own exceptions because Python does not define suitable exceptions for returning a certain error condition in your program. In other words, the answer to your question above is: don't. :) > Do people do processing in the init routine in their own exceptions? Yep. I've attached an example of an Exception virtual base class. It is derived directly from Python's Base Exception class and uses some __init__ magic to log the exceptions to a file, if the user desires this. A derived exception only has to overwrite Create() and errormsg(), the rest is done in the base object. Btw: I've put the import statements for the two extra classes that are referenced at the back, because otherwise a circular import would take place... :) If you're nterested in the whole project (CGIgen), look for it on SourceForge.net. > Thanks for any insight. Hope this helps! -- Yours sincerely, Heiko Wundram ====== """CGIgenException.py This file defines the class that is the base class of all exceptions that are used in CGIgen. It is itself derived from the toplevel Exception class. This Exception class enhances the basic Exception class in that it supports logging the exception to a file, as well as catching exceptions that were the base of this exception. Copyright (C) 2001 by Heiko Wundram. All rights reserved.""" import os import sys import string import time import types import inspect import traceback logfile = None loglevel = 0 def setlogfile(newlogfile): """Sets the logfile that is supposed to be used from now on to newlogfile. This file is created, if it doesn't exist, and messages will keep being appended to the file as they arise. Pass in None to stop any logging.""" global logfile logfile = newlogfile def setloglevel(newloglevel): """Sets the loglevel to level. The most severe errors have loglevel 0, and decreasing from there.""" global loglevel loglevel = newloglevel def logmessage(message, severity): """Logs the message message to the logfile, in case the severity is less than or equal to the current loglevel.""" global logfile global loglevel if not logfile or severity == -1: return if severity > loglevel: return mutex = CGIgen.Base.Mutex.FileMutex(logfile) mutex.acquireExclusive() try: log = open(logfile,"a+") except: raise CGIgenExceptions.CGIgenLoggingError(0) try: try: log.write(time.asctime()+"\n") log.write(message) if message[-1] != '\n': log.write("\n") log.write("\n") log.close() finally: mutex.release() except: raise CGIgenExceptions.CGIgenLoggingError(0) class CGIgenException(Exception): """This class supports a rich interface to look at exceptions. It can be subclassed, but in a subclass, only the Create and the errormsg functions should be overridden.""" def __init__(self, severity, *args, **kwargs): """Initializes a CGIgenException object and logs it if that is wished. The severity parameter is always processed by __init__. It decides whether the message is logged or not, the exception is thrown nevertheless.""" if sys.exc_info()[0]: self.__old_exctype = sys.exc_info()[0] self.__old_excvalue = sys.exc_info()[1] self.__old_exctraceback = sys.exc_info()[2] else: self.__old_exctype = None self.__severity = severity apply(self.Create,args,kwargs) self.log() def Create(self): """This function only serves as the base to a functional create in a submodule. That create function is passed all the parameters that were given in the call to init.""" raise CGIgenExceptions.CGIgenExceptionError(0) def log(self): """This function performs all tasks that are necessary to log the exception to the logfile, if that is wished by the user of CGIgen.""" message = "Error: "+self.errormsg()[0]+"\n" message += str(self)+"\n" message += "Raised in:\n" message += string.join(traceback.format_stack(inspect.getouterframes(inspect.currentframe())[2][0],3)) if self.__old_exctype: message += "\nError was raised due to catching another error.\n" if type(self.__old_excvalue) == types.InstanceType and isinstance(self.__old_excvalue,CGIgenException): message += "Old Error: "+self.__old_excvalue.errormsg()[0]+"\n" message += str(self.__old_excvalue)+"\n" else: message += "Old Exception: "+str(self.__old_exctype)+"\n" if self.__old_excvalue: message += str(self.__old_excvalue)+"\n" message += "Traceback:\n" message += string.join(traceback.format_tb(self.__old_exctraceback),"") logmessage(message,self.__severity) def __str__(self): """This function returns the string value (error message) of the current exception object. It uses self.errormsg() to construct the error message.""" return string.join(self.errormsg()[1:],", ")+"." import CGIgen.Base.Mutex import CGIgenExceptions From loewis at informatik.hu-berlin.de Mon Sep 17 03:36:10 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 17 Sep 2001 09:36:10 +0200 Subject: 2.2a3 compile fails with __retval error References: Message-ID: Bruce Sass writes: > No, I had rm-ed config.cache before the configure that immediately > preceeded make; but it is/was something I did with configure. > > It looks like it was a bad idea to see what: > --with-{signal-module,cycle-gc,pymalloc,fpectl} would do. > If I leave those options off it seems to be working... > is that `not surprising', or is `something funny going on' ? I cannot reproduce this. On a Debian unstable installation, Python 2.2a3, being configured with ./configure --with-signal-module --with-cycle-gc --with-pymalloc --with-fpectl builds fine for me. If you want to investigate this, you should find out why HAVE_STRDUP is not defined in your pyconfig.h, by inspecting config.log. Perhaps something is strange with your C library? Of the options you are giving, --with-signal-module --with-cycle-gc are redundant, since those are activated by default. Regards, Martin From localhost Mon Sep 17 15:06:43 2001 From: localhost (:-)) Date: 17 Sep 2001 19:06:43 -0000 Subject: :-) Message-ID: <1000753603.87306.qmail@ech> _______________________________________________________________________ Powered by List Builder To unsubscribe follow the link: http://lb.bcentral.com/ex/manage/subscriberprefs?customerid=15216&subid=D81C92793C65D570&msgnum=2 -------------- next part -------------- An HTML attachment was scrubbed... URL: From peter at engcorp.com Fri Sep 14 20:02:50 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 14 Sep 2001 20:02:50 -0400 Subject: Newbie Question.. What is the replacement for the ELSE command?. References: Message-ID: <3BA29AAA.A2D1CB01@engcorp.com> Cable wrote: > > I am trying to teach myself Python. All the online tutorials, have > examples with the else command. I cant get it to work is there a > replacement? When posting problem reports, it is necessary to post the _specific_ code you are trying to run, and preferably the details of the error message generated. The best approach is to use the interactive prompt, then cut and paste from your console window into your mail message. For example: Python 2.0 (#1, Dec 20 2000, 15:28:16) [GCC 2.96 20000731 (Red Hat Linux 7.0)] on linux2 Type "copyright", "credits" or "license" for more information. >>> def test(): ... if 1==2: ... print 'yikes!' ... else File "", line 4 else ^ SyntaxError: invalid syntax >>> def test(): ... if 1==2: ... print 'yikes!' ... else: ... print 'phew!' ... >>> test() phew! (In the unlikely event you were missing the colon after else, please read the above two functions carefully.) Cheers, -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From fredrik at pythonware.com Sat Sep 22 08:05:49 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 22 Sep 2001 12:05:49 GMT Subject: tkFileDialog and Multiple Filetypes References: <1984df93.0109210801.8c00851@posting.google.com> Message-ID: "Brian" wrote: > I haven't been able to turn up an example of specifying more than one > file type per line.e.g > > n=askopenfilename(filetypes=[("Image Files","*.jpg;*.gif"), > ("JPEG",'*.jpg'), > ("GIF",'*.gif'), > ('All','*')]) use a tuple: filetypes = [ ("Image Files", ("*.jpg", "*.gif")), ("JPEG",'*.jpg'), ("GIF",'*.gif'), ('All','*') ] From ignacio at openservices.net Tue Sep 25 14:16:10 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Tue, 25 Sep 2001 14:16:10 -0400 (EDT) Subject: Error when using curses.wrapper modules In-Reply-To: <20010925133601.A13383@newcreature.org> Message-ID: On Tue, 25 Sep 2001, Ben Logan wrote: > If I take out the "scrn.border()" line, it works...of course it'll be > hard to do anything useful that way. :) Anyone got any suggestions? It looks as though someone forgot to update Modules/_cursesmodule.c when the changeover from 1.5->2.x happened. It uses PyArg_Parse(), but uses features only allowed for PyArg_ParseTuple(). Has anyone bothered with a patch for this? -- Ignacio Vazquez-Abrams From wade at lightlink.com Tue Sep 4 13:07:50 2001 From: wade at lightlink.com (Wade Leftwich) Date: 4 Sep 2001 10:07:50 -0700 Subject: Web Application Server in Python: which one to choose ? References: <3B9364F8.2C477597@el_simpatico.be> <23891c90.0109040133.3eb7afa7@posting.google.com> Message-ID: <5b4785ee.0109040907.2cde21f3@posting.google.com> paul at boddie.net (Paul Boddie) wrote in message news:<23891c90.0109040133.3eb7afa7 at posting.google.com>... > > Yes, this is where it's less true to say that "Zope is Python's killer > app" than it is to say that "Zope is Zope's killer app". ;-) Zope is > pretty much designed to be used at a higher level, or at least it used > to be, with the intention that most of the work done in developing a > Web site takes place using DTML manipulating objects which sit in the > object database. DTML is powerful and reasonably nice (certainly nicer > than *SP mechanisms) but has potentially been overloaded too much, > leading to its current dubious reputation. > DTML scared me away from Zope, but ZPT (Zope Page Templates) brought me back. By using Python Scripts for application logic, and ZPT's for presentation, you get a nice Pythonic subset of Zope. I'm building an application now where the data lives in SQLServer, application and presentation code are in the ZODB using the two modules just mentioned, and it's hooked up with ZSQL methods. Much of the ZPT development has been done by GvR, BTW . . . From duncan at NOSPAMrcp.co.uk Tue Sep 25 09:27:49 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Tue, 25 Sep 2001 13:27:49 +0000 (UTC) Subject: finding the file of a module from inside a class References: Message-ID: "Thomas Weholt" wrote in news:E_Yr7.373$n5b.170821632 at news.telia.no: > > Tried this code : > > import os > > class MyClass: > def __init__(self): pass > def myfile(self): return os.path.abspath(__file__) > > if __name__ == '__main__': > x = MyClass() > print x.myfile() > > With this result : > > Traceback (most recent call last): > File "c:\python21\pythonwin\pywin\framework\scriptutils.py", line > 298, in > RunScript > debugger.run(codeObject, __main__.__dict__, start_stepping=0) > File "c:\python21\pythonwin\pywin\debugger\__init__.py", line 60, in > run > _GetCurrentDebugger().run(cmd, globals,locals, start_stepping) > File "c:\python21\pythonwin\pywin\debugger\debugger.py", line 582, in > run > _doexec(cmd, globals, locals) > File "c:\python21\pythonwin\pywin\debugger\debugger.py", line 924, in > _doexec > exec cmd in globals, locals > File "C:\Temp\Script10.py", line 9, in ? > print x.myfile() > File "C:\Temp\Script10.py", line 5, in myfile > def myfile(self): return os.path.abspath(__file__) > NameError: global name '__file__' is not defined >>>> > > Hm ... if it was that simple it would be too good to be true. > It is that simple. You said you had a module test.py, but your example is using a script not a module. The __file__ attribute is set for every module, but it isn't set for a script---sorry, I should have mentioned that. It also isn't set in a few other situations that shouldn't worry you (like builtin modules or using exec to build your module). I believe that for a script, the first element on sys.path will be the directory from which the script is loaded (unless someone has modified sys.path). -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? From gabriel_ambuehl at buz.ch Sun Sep 30 10:20:27 2001 From: gabriel_ambuehl at buz.ch (Gabriel Ambuehl) Date: Sun, 30 Sep 2001 16:20:27 +0200 Subject: MySQLdb where's fetchoneDict()? In-Reply-To: <15287.8969.607364.965202@beluga.mojam.com> References: <112484592256.20010930103925@buz.ch> <15287.8969.607364.965202@beluga.mojam.com> Message-ID: <103505053798.20010930162027@buz.ch> -----BEGIN PGP SIGNED MESSAGE----- Hello Skip, Sunday, September 30, 2001, 3:50:01 PM, you wrote: > When you create the database connection you can specify the type of > cursor to use by passing a cursorclass parameter, e.g.: > self.db = MySQLdb.Connection(host=self.host, > user=self.user, > passwd=self.password, > db=self.database, > > cursorclass=MySQLdb.cursors.DictCursorNW) > Try pydoc.help(MySQLdb.cursors) for all the possibilities... Oops. I thought the fact that DictCursor is a completely empty class except for the MixIns (which don't do much either) would mean DictCursor is gone. (I know found that some of the old code supposedly run with a hacked MySQLdb which didn't made it necessary to specify DictCursor in order to use its features). Thanks a lot! Best regards, Gabriel -----BEGIN PGP SIGNATURE----- Version: PGP 6.5i iQEVAwUBO7ccH8Za2WpymlDxAQHIlggAvkp+n5HgL6tfXbld3sZ3/VuX0i+pfa/E 59pCb+j52IRNALumFEuLDThPruPoKSTsWPZU5ElfIiMrR6QD+vPNc7aSgrw4TPom s2APwGcFck+GTysJv+XFQkNDvQS4fNG38osYs0ezJ+L4e2iAtdaZot7i9an1i1g2 WGAXTqBCrFfS5nhFbdjIIcnlUTXxIR6jZzenS5VMduX+6+DvkeRroraPmjoyZzhT UJxgtSE1s9m2vVMdL77cD1+3KaO1DF4cqEvwcLfGygCuNdBDpmpW6hKoF3qHHUCo 8pV2rHmoqFDzzA9bnR9Fp1C3OaRH6v9liHHsIK9nRQ+qDsHK+IK+WQ== =9yN5 -----END PGP SIGNATURE----- From max at alcyone.com Mon Sep 10 11:47:02 2001 From: max at alcyone.com (Erik Max Francis) Date: Mon, 10 Sep 2001 08:47:02 -0700 Subject: idea: Robocode for Python References: Message-ID: <3B9CE076.2A329A10@alcyone.com> Roman Suzi wrote: > Cool idea (read on /.) for those who seek interesting project: There is already a language-independent architecture for competing bots: http://realtimebattle.sourceforge.net/ -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ What a crime to waste [youth] on children. \__/ George Bernard Shaw Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From qrczak at knm.org.pl Tue Sep 11 09:39:43 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 11 Sep 2001 13:39:43 GMT Subject: Proposed PEP for a Conditional Expression References: <9nkvss$cmq$1@glue.ucr.edu> Message-ID: Tue, 11 Sep 2001 12:26:04 +0000 (UTC), thp at cs.ucr.edu pisze: > WORKAROUND_7 > > eval( c and "" or "" ) > I don't like this hack either, but under interpretative > execution it's probably more efficient than creating > one-member lists (see WORKAROUND_3). I don't believe. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From thomas at gatsoft.no Fri Sep 28 04:32:44 2001 From: thomas at gatsoft.no (Thomas Weholt) Date: Fri, 28 Sep 2001 08:32:44 GMT Subject: ANN: XMLRecord 0.1.1 Message-ID: XMLRecord Current version: 0.1.1, Alpha License: Pythonic Requirements: Python 2.x, pyxie from pyxie (http://pyxie.sourceforge.net ) XMLRecord takes a XML-document describing a record-like structure and turn it into an object similar to a dataset found in VBScript. It reads the XML sequentially and parses each "record" into a DOM-object using the minidom-module. Provided helper-methods makes it easy to extract values of tags, attributes and list-structures. XMLRecord is inspired by RAX http://www.xml.com/pub/a/2000/04/26/rax/index.html ). It didn't handle lists the way I wanted so I made XMLRecord. Pyxies simplistic syntax made it easy to parse. It works on XML-structures like this (info in this xml-piece is fictional. ) : Thomas 26 short fat dumb thomas at weholt.org Roger Wilco 30 tall slim smart roger at wilco.com Dilbert 32 Mr Johnson 47 johnson at mail.com To use XMLRecord, do something like this ( source edited to fit page ) : # xml_data is a string containing the XML above import XMLRecord x = XMLRecord.XMLRecord('rec', xml_data) while not x.eof: print "Name = %s, age = %s" % (x.getTagValue('name'), x.getTagValue('age')) x.nextRecord() The result: Name = Thomas, age = 26 Name = Roger Wilco, age = 30 Name = Dilbert, age = 32 Name = Mr Johnson, age = 47 XMLRecord also provides a helper-method getListFromTag that constructs a list of items from a piece of XML like this: short fat dumb into this ['short','fat','dumb'] The tags inside the tag marking up the list don't have to have the same name as long as the piece of xml is well-formed. One could easily use something like this : short fat dumb The available helper methods so far is: getAttributeFromTag(self, tag, attr) getAttributesFromTag(self, tag) getTagValue(self, tag) getListFromTag(self, tag) Tips and comments are very welcome. Source is available at http://projects.weholt.org Thomas Weholt, thomas at weholt.org From altis at semi-retired.com Tue Sep 18 12:16:56 2001 From: altis at semi-retired.com (Kevin Altis) Date: Tue, 18 Sep 2001 09:16:56 -0700 Subject: ANN: PythonCardPrototype release 0.4.5 Message-ID: PythonCard is a software construction kit (in the spirit of Apple's HyperCard) written in Python. You can download the latest release at: http://sourceforge.net/project/showfiles.php?group_id=19015 Samples included in the latest release: addresses, conversions, dbBrowser, dialogs, doodle, findfiles, hopalong, minimal, proof, resourceEditor, samples, searchexplorer, sounds, SourceForgeTracker, textIndexer, tictactoe, turtle, widgets, worldclock To see screenshots of some of the samples, visit: http://pythoncard.sourceforge.net/samples.html A description of each sample is included in the docs directory and the readme.txt file in each sample directory. PythonCard home page http://pythoncard.sourceforge.net/ SourceForge summary page http://sourceforge.net/projects/pythoncard/ Mailing list http://lists.sourceforge.net/lists/listinfo/pythoncard-users PythonCard requires Python 2.1.x or later and wxPython 2.3.x. wxPython is available at http://www.wxpython.org/ PythonCard relies on wxPython, it will support the Macintosh once wxPython has been ported to the Mac. PyCrust 0.6 PyCrust by Patrick K. O'Brien is required by PythonCard, but is no longer included as part of the PythonCardPrototype releases. Please visit the home page at http://sourceforge.net/projects/pycrust/ and download the latest release at http://sourceforge.net/project/showfiles.php?group_id=31263 ---------------------------- Changes since release 0.4.3 (2001-08-23): Release 0.4.5 2001-09-17 PyCrust is no longer included in the PythonCardPrototype distribution, please download PyCrust at: http://sourceforge.net/project/showfiles.php?group_id=31263 moved Bitmap class to graphic.py module added getPILBits and setPILBits to Bitmap class to simplify using PIL with PythonCard added BitmapCanvas widget to widget.py added doodle and hopalong samples which use BitmapCanvas The BitmapCanvas is very experimental and will be enhanced and improved Debug windows are now children of the app window Namespace Viewer, Property Editor, Shell added 'Save Configuration' option to Debug menu this will create a pythoncard.user.config.py file with the current debug window position and sizes changed Message Watcher to use sizers renamed readDictionaryFile to readAndEvalFile updated addresses.py and searchexplorer.py to use the new function Release 0.4.4.5 2001-09-08 posted Help Wanted on SourceForge http://sourceforge.net/people/?group_id=19015 posted Python Conference request for papers/tutorials http://aspn.activestate.com/ASPN/Mail/Message/PythonCard/767719 added addMethod to Scriptable class for dynamically adding handlers at runtime, see: http://aspn.activestate.com/ASPN/Mail/Message/PythonCard/770015 added 'openBackground' message to replace using __init__ changed background handlers to on_mouseClick form modified SourceForgeTracker so that double-clicking on a topic launches the web page for that topic in a browser Neil added Pyker.hta and PykerLaunch.hta see the following URL for more info http://aspn.activestate.com/ASPN/Mail/Message/PythonCard/766307 Andy added a TODO.txt to document short-term plans for PythonCard development Property Editor and resourceEditor sample were changed to use default size (-1, -1) values added enable and check menu items to menu.py see the url below and thread replies http://aspn.activestate.com/ASPN/Mail/Message/PythonCard/766371 started some documentation for the Button class http://aspn.activestate.com/ASPN/Mail/Message/PythonCard/764832 added display of .rsrc.py files in samples.py Patrick added dot notation support to the Font class Jeff and Neil provided some Unix screenshots These show we need to get sizers working to deal with variable size widgets and fonts on different platforms http://aspn.activestate.com/ASPN/Mail/Message/PythonCard/763602 http://aspn.activestate.com/ASPN/Mail/Message/PythonCard/763659 res.py eval() changed to support using Windows-style line endings under Unix added "Redirect stdout to Shell" option to Debug menu Release 0.4.4.1 2001-08-31 added samples.py to launch the the various sample programs see samples\samples.py added readme.txt files to all samples that didn't already have one. the readme.txt is displayed as the 'description' for a sample Release 0.4.4 2001-08-30 added getting_started.html to docs\html added basic status bar support statusbar.py module see test_turtle.py for an example turtle sample updated test_turtle.py now uses a status bar and displays the time required to draw a design added line(x1, y1, x2, y2) method to turtle added extra parametes to FileDialog to support saving files see resourceEditor for an example see dialog.py for complete list of options added Namespace Viewer using PyFilling (part of PyCrust 0.6) fixed numerous Property Editor edit/display bugs widgets are now displayed in the proper order added Font support to all widgets Font class moved to font.py module the actual text descriptions of the fonts is going to change, so if you use them, just be aware that the format of the font descriptions will change by the next release a font can be passed to the Font dialog to set the initial font displayed commented out 'import warnings' for Python 2.0 support but PyCrust usage still means that you need Python 2.1.x if any Debug windows like the shell will be used fixed unitialized empty bitmaps on win98 added append method to Choice class added setFocus method to Widget dbBrowser sample updated to version 0.2 resourceEditor changes resourceEditor can now save .rsrc.py files make sure to only work on copies in case of bugs also some hand editing of .rsrc.py is still necessary depending on what you're trying to do Duplicate Widget menu item now causes the duplicate to be offset 10 pixels so it can be selected to select added template.rsrc.py for defaults worldclock sample demonstrates simple use of logging From george_planansky at harvard.edu Mon Sep 3 13:00:58 2001 From: george_planansky at harvard.edu (George Planansky) Date: 03 Sep 2001 13:00:58 -0400 Subject: Web Application Servers in Python: Hopeful Monsters ? References: <3B9364F8.2C477597@el_simpatico.be> Message-ID: The current situation with pythonic web software seems analogous to the evolutionary situation that pertains with the opening of a new biological niche, as e.g. with the denizens of the Burgess Shale, ca. 600 m.y. B.P. . That makes Zope, Webware, et. al., pythonic "Hopeful Monsters". Small comfort to those wondering which horse to ride. A better question might be, "Which trilobite?". For more on the Burgess Fauna etc., S. Gould's paperbacks are a good read. For a fine read on on objects and methods from a bioware p.o.v., check out: http://www.bbc.co.uk/science/horizon/hopefulmonsterstran.shtml Apologies in advance to the ICR types reading this who will be wondering, "How in hell did I end up in a comp.lang list?" . :) "Thomas Weholt" wrote: > > My experience with the ones I've tested ( Zope and Webware ) is that if you > can find either products ( in zope ) or allready existing features in the > system that fits your needs, you might get productive rather quick. If you > on the other hand want to develop highly customized solutions you might have > to invest more time and possibly money. How you like to work, if you like > using *SP-based solutions like DHTML in Zope and PSP and Webware etc. will > also play a big part in deciding what package you want to use. I think > Webware and Zope work just fine if you're way of working is compatible with > the concept behind one of those packages. > > I found Zope too complex, almost bloated, Webware was interesting and showed > alot of promise, but failed to invoke serious interest. I've started > developing my own application server based on Medusa and take parts of the > concept behind Zope, Webware, other Java-based application servers like > Tomcat and Enhydra and it's coming along nicely, soon becoming ready for a > beta-release. I wanted 100% control of my code, complete seperation of > design and code, "web-components", simpler user/access-management etc. and > at the same time learn how it all worked, that's why I decided to create a > new project. > > Perhaps no real answer to your question, but ... > > Thomas > > "Weet Vanniks" wrote in message > news:3B9364F8.2C477597 at el_simpatico.be... > > The subject title says it all or almost ... > > There seems to exist a great offering: > > Zope, Bobo, Webware,SkunkWeb, Quixote,Twisted, etc... > > This makes my choice very difficult. Can I get an unbiased opinion about > > the merits of each of these solutions. I've been told that Zope is > > complex and that Webware is great. Could you confirm ? > > Thanks for helping me out. > > > > Weet > > From gustav at morpheus.demon.co.uk Sat Sep 29 17:02:05 2001 From: gustav at morpheus.demon.co.uk (Paul Moore) Date: Sat, 29 Sep 2001 22:02:05 +0100 Subject: How do I distinguish a string from a sequence? References: <87ite3befn.fsf@lisboa.ifm.uni-kiel.de> <8lk9rtgkaote8hup7ipbp2b86aorjbilf5@4ax.com> Message-ID: On Fri, 28 Sep 2001 15:02:17 -0500, Skip Montanaro wrote: > > Paul> "Ability to be passed to popen2()" is what I'm after (at least in > Paul> the initial version, later I might use fork/exec or low-level > Paul> Win32 calls) and that isn't testable for... > >Why not simply call popen2() with your argument and if it squawks, do >something about it? Good point. I was worried about just catching all errors, and I wasn't sure what specific exception I could catch. But a bit of checking shows that I get a TypeError, which makes perfect sense. So trying the call and catching TypeError is right. Thanks, Paul. From andorxor at gmx.de Sat Sep 8 11:38:54 2001 From: andorxor at gmx.de (Stephan Tolksdorf) Date: Sat, 8 Sep 2001 17:38:54 +0200 Subject: Translating a Perl regex into Python References: <9naa3a$182$05$1@news.t-online.com> <1Pom7.1443$sn6.295783@newsc.telia.net> Message-ID: <9nde02$k66$07$1@news.t-online.com> Thanks for the long answer. It has solved all my problems. Best regards, Stephan From tist.verdonck at mailandnews.com Thu Sep 6 06:41:49 2001 From: tist.verdonck at mailandnews.com (Tist Verdonck) Date: 6 Sep 2001 03:41:49 -0700 Subject: length of dictionaries Message-ID: <8e84aae6.0109060241.5af3dad2@posting.google.com> is there a limit to the length of a dictionary?? I seem to get an error after adding a 257th key to my dictionary. Tist Verdonck tist.verdonck at mailandnews.com From qrczak at knm.org.pl Thu Sep 6 11:05:46 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 6 Sep 2001 15:05:46 GMT Subject: Simple Newbie Question - (slightly OT) References: Message-ID: Thu, 6 Sep 2001 08:37:51 -0500, Scott, M Clay pisze: > What is the proper pronunciation for "Tuple"? > > Does it rhyme with "Couple"? Or does it rhyme with "Hoople"? This question has been asked here 6 weeks ago. It seems that there is no simple answer, various people pronounce "tuple" differently. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From sam at localhost.localdomain Fri Sep 14 21:06:39 2001 From: sam at localhost.localdomain (Sam Penrose) Date: 14 Sep 2001 18:06:39 -0700 Subject: What is Python good for? Message-ID: <1000515999.1442.113.camel@localhost.localdomain> "Ignacio Vazquez-Abrams" wrote in message > Here's something that came up recently that if it doesn't make you go > "ooh-ahh", then it will make you go "whoa": > >>> def a(): > ... return 'abc' > ... > >>> def b(): > ... return 123 > ... > >>> a.func_code=b.func_code Max M adds: > wouldn't a = b satisfy your need for whoas here ? It's perhaps a little easier to see the potential usefulness of the instance version of this Stupid Python Trick: >>> class A: ... def f(self): ... print 'calling A.f' ... >>> class B: ... def g(self): ... print 'calling B.g' ... >>> a = A() >>> a.f() calling A.f >>> b = B() >>> a.f = b.g >>> a.f() calling B.g In other words, you can dynamically and arbitrarily mix and match instance methods. How does this demonstrate Python's wonderfulness? 1) You can do "paradigm-breaking" things like this with such little fuss. It doesn't get much simpler than "a.f = b.g" No new keywords, no hidden context. 2) There are no (?) common cases where the language's governing paradigm forces you to do something this arbitrary (a counterexample for Java might be the fact that "Hello World" is a class definition invoking half a dozen keywords whose name is the same as the file containing it). 3) Because of 2), the culture of the language guides you away from these tricks in the common cases. This is a big deal; it helps us understand each other's dialects of Python. In other words, it helps you read that library module you need to import and helps newbies and *bots feel like they are engaged in a common enterprise. (Perl is arguably the crowning jewel of the opposite philosophy: every Stupid Trick is worth trying.) 4) When you do roll your own Stupid Python Trick, Python will often astonish you with the robustness of the results. If they work at all, they will usually just work. From James_Althoff at i2.com Mon Sep 17 12:30:11 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Mon, 17 Sep 2001 09:30:11 -0700 Subject: Proposed PEP for a Conditional Expression Message-ID: Tom Payne wrote: >As far as I can tell, it doesn't work if x is a local variable. Have >you actually tried it? Yes. And the following example Python run was included in my original post: Python 2.2a1 (#21, Jul 18 2001, 04:25:46) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> >>> from __future__ import nested_scopes >>> >>> def cond(expr, iftrue, iffalse=lambda:None): ... if expr: return iftrue() ... return iffalse() ... >>> x = -2 >>> abs = cond(x>=0, lambda:x, lambda:-x) >>> abs 2 >>> l = [7,8,9] >>> firstItem = cond(len(l)>0, lambda:l[0]) >>> firstItem 7 >>> l = [] >>> firstItem = cond(len(l)>0, lambda:l[0]) >>> print firstItem None >>> Jim From michael at rcp.co.uk Wed Sep 5 10:27:45 2001 From: michael at rcp.co.uk (Michael Abbott) Date: Wed, 5 Sep 2001 14:27:45 +0000 (UTC) Subject: Where does my output go? Message-ID: So, I write a small bit of Python (one line): write.py -------- print 'hello' -------- I then run it from the command line: C:\TEMP>ver Windows NT Version 4.0 C:\TEMP>write Hello C:\TEMP>write >write.txt C:\TEMP>dir write.txt Volume in drive C is SKYLARK Volume Serial Number is 2801-8D16 Directory of C:\TEMP 05/09/01 15:27 0 write.txt 1 File(s) 0 bytes 1,080,729,088 bytes free C:\TEMP> Where did my output go? This is most perplexing! From greg at cosc.canterbury.ac.nz Mon Sep 3 23:21:18 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Tue, 04 Sep 2001 15:21:18 +1200 Subject: 3-arg float pow() References: <7xy9nvexgp.fsf@ruckus.brouhaha.com> Message-ID: <3B9448AE.D81FD05D@cosc.canterbury.ac.nz> Paul Rubin wrote: > > That doesn't seem so bad. 2**-5 is already not allowed. When new division comes into force, shouldn't this be allowed too? -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From aahz at panix.com Wed Sep 12 01:43:40 2001 From: aahz at panix.com (Aahz Maruch) Date: 11 Sep 2001 22:43:40 -0700 Subject: newbie: cannot import name error References: <3B991420.357A85F2@engcorp.com> <3B9D11B9.D665D36A@engcorp.com> Message-ID: <9nmsmc$r03$1@panix2.panix.com> In article <3B9D11B9.D665D36A at engcorp.com>, Peter Hansen wrote: > >Meanwhile, is it really the case that "extension" refers exclusively >to code not written in Python? If so, please refer me to where the >official definition has been made so I can set my mind at ease. I don't think it's official, but that does seem to be the standard usage based on my, um, three years here. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista We must not let the evil of a few trample the freedoms of the many. From gerhard.nospam at bigfoot.de Tue Sep 18 16:09:36 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Tue, 18 Sep 2001 22:09:36 +0200 Subject: nntplib and xover References: Message-ID: On Tue, 18 Sep 2001 16:38:17 GMT, Rick Pasotto wrote: >Some news servers return the Xref: line in response to the XOVER >command. Currently the nntplib does not include this line. > >1) Will this be included in future versions? Perhaps, if you submit a patch at Sourceforge. If you don't, it won't. I've changed the xover method to support this, feel free to change this in your Python source tree, create a patch and submit it: ############# def xover(self,start,end): """Process an XOVER command (optional server extension) Arguments: - start: start of range - end: end of range Returns: - resp: server response if successful - list: list of (art-nr, subject, poster, date, id, references, size, lines, xref)""" resp, lines = self.longcmd('XOVER ' + start + '-' + end) xover_lines = [] for line in lines: elem = line.split("\t") xref = None if len(elem) >= 8 and elem[8].startswith('Xref:'): xref = elem[8] try: xover_lines.append((elem[0], elem[1], elem[2], elem[3], elem[4], elem[5].split(), elem[6], elem[7], xref)) except IndexError: raise NNTPDataError(line) return resp,xover_lines ############# >2) What is the best way to get this line now? See the above code :-) Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ public key at homepage public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From bishop at cs.unc.edu Wed Sep 19 10:00:01 2001 From: bishop at cs.unc.edu (Gary Bishop) Date: 19 Sep 2001 07:00:01 -0700 Subject: Python/Cygwin PyOS_InputHook Message-ID: <334cd997.0109190600.d8022f7@posting.google.com> I'm trying to build the pygist graphing extension for python 2.1.1 on cygwin (latest version). The link building the dll fails with undefined symbol PyOS_InputHook. I see the definition in Parser/myreadline.c and the extern DL_IMPORT declaration in Include/pythonrun.h. The same source builds and works on Mac OS/X so I'm guessing this is a cygwin problem with references to variables in DLL's? One more detail. I can see the symbols using "nm" on libpython2.1.dll.a. This one is shown with an "I" flag as most of them are but unlike the others it has no "unmunged" name associated with it. Only an __imp__* style name. I don't know enough to know if that is a clue or not. Thanks you any pointers you can give. gb From erno-news at erno.iki.fi Wed Sep 5 13:23:05 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 05 Sep 2001 20:23:05 +0300 Subject: COM/CORBA/DCOP (was: Hello people. I have some questions) References: <7xsne7en0r.fsf@ruckus.brouhaha.com> <9mvp3505rt@enews2.newsguy.com> <9n292n01lg1@enews3.newsguy.com> <9n4kut013qk@enews1.newsguy.com> Message-ID: In article <9n4kut013qk at enews1.newsguy.com>, "Alex Martelli" writes: | "Erno Kuusela" wrote in message | news:kug0a2h37i.fsf at lasipalatsi.fi... || over here isps tend to sell ip connections with 10.x addresses + nat || as "internet" to people and then you can't do anything except || browse the web and read email. | ...and irc and news and cvs and ntp and okbridge and icq and... | I don't particularly care about video-on-demand at this point | in time, but with nat &c correctly configured, I see no | fundamental technical reason it couldn't be made to work. it does break irc and news and cvs and ntp and icq. servers. it does break irc client side (dcc) unless you have an ALG kludge. well, ok, i bet you can come up with a long list of simple tcp services that it doesn't break. it does break lots of other stuff too. assuming we're talking about 1:n nat here and not n:n. here are are some improtant things off the top of my head that i personally use that would not work behind a NAT: running your own services remote access from outside ssh vnc X ... http ftp smtp dns ... file sharing service smb nfs ... peer-to-peer things freenet gnutella ... protocols that transmit ip addresses in the data payload (some of the these can be fixed by using "ALGs" or hacks that know about the protocol that is being run over tcp and actually actively alter the data payload in the packets travelling through the NAT box (this is commonly done with e.g. FTP)) but it only works for protocols that the nat box designer has thought of and know about before hand and is just conceptually too horrible to contemplate most udp services (like peer to peer games, ntp, ...) IP protocols other than udp or tcp tunneling ipsec (ok, i don't personally run this, but it is very important not to break imho) cipe 6to4/sit ... if everyone were behind a nat, no 2 computers on the internet could communicate with each other. and the alg idea is fundamentally infeasible in the long run given we'd like to run most services encrypted before long. it also breaks tcp - it tries to keep track of the tcp connections that hosts keep open, but times them out if nothing happens in a while or the nat box gets rebooted/crashes in the middle of things, or if it has a dynamic address, its address changes. that makes the network much more fragile. | Of course, I'll have to go with dynamic DNS to match the | dynamic IP assignment if I want to offer servers, but that's | got nothing to do with NAT'ting -- even just one box with | a dynamic IP address would be in the same boat. || there is a good rant about this and other internet breaking stuff || at . | If you can give me URL's to transcripts of this, or other | _written_ material, I'll be happy to read and ponder over | them, but I don't do video/audio at this point. okay... || (unless you allow untrusted users shell accounts on it, || but you can't really defend someone with a shell account || from rootnig a unix box (including openbsd) anyway). | I wonder -- when it's consolidated and hardened enough, I | might experiment with that. But anyway, who's happy with | a single layer of defense? I want security in depth, and yeah, security in depth is good, but the layers are only helpful when they are non-trivial to break (follow bugtraq for a while to see why defending against local users is a futile exercise). if you don't run any services on the firewall, then you are pretty well off. || i've been pretty happy with running packet filtering on my single || computer i have at home, but then i don't attempt anything very || ambitious functionality wise. | As for me, I do need to share the ADSL connection among | half a dozen PC's (both Windows and Linux ones), and also | eventually run some small servers accessible from the outside | (unless that means code-red scans tie up all my very modest | bandwidth, of course:-) -- and I aim to do it all in the | safest way I can devise. We'll see... running some servers accessible from the outside might prove challenging with a NAT. (unless you run them on non-standard ports and/or use some sort of port-forwarding kludge). -- erno From bwharvey at hotmail.com Thu Sep 27 19:20:27 2001 From: bwharvey at hotmail.com (BWH) Date: 27 Sep 2001 16:20:27 -0700 Subject: Has anyone gotten WMI to work on Win2000? GetObject("WinMgmts......... Message-ID: I've seen several messages on the group of people trying to get things working, but I constantly get Attribute Err. from win32com.client import GetObject processes = GetObject("WinMgmts://127.0.0.1/root/cimv2").\ InstancesOf("Win32_process") for process in processes: print process.Name Thanks, Brad From owen at astrono.junkwashington.emu Mon Sep 17 15:26:05 2001 From: owen at astrono.junkwashington.emu (Russell E. Owen) Date: Mon, 17 Sep 2001 12:26:05 -0700 Subject: PEP proposal for round(x,n) enhancement References: Message-ID: <9o5iof$338m$1@nntp6.u.washington.edu> >...The enhancement that I would like to see is the ability to indicate the >number of digits counting *from the 1st non-zero digit* that should be >reported. These digits are often called the significant digits. Both >12345 and 1.2345 when rounded to the 3rd significant digit are 12300 >and 1.23 but instead of having to inspect the numbers to figure out >what digit to round them to, an argument that would be interpreted as >"the 3rd digit counting from the first non-zero digit" would do the job >instead. > >*** >How to add this syntax to the round function: > > >round(x,n) will test to see if there is a decimal portion to n. If >there is, n will be multiplied by 10 and the integer of the resulting >value will be the number of digits to which x will be rounded. I like the idea of having this functionality, but I find the proposed user interface too subtle and confusing. I suggest one of the following implementations, either of which would be much clearer: - add an optional keyword argument to round to obtain the other behavior - create a new function (possibly in the math library) to produce this behavior This brings up a more general point. Keyword arguments seem rather underutilized in the libraries. For instance we have various functions that combine lists. Some of them stop at the end of the shortest list. Others go on to the end of the longest list. Why this inconsistency? Presumably both behaviors are useful, and an optional keyword argument for each function would permit either behavior as desired. -- Russell From slinkp23 at yahoo.com Mon Sep 17 15:48:37 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Mon, 17 Sep 2001 19:48:37 GMT Subject: How to get a directory size with win32 api ? References: <85e27928.0109170448.693d122b@posting.google.com> Message-ID: On Mon, 17 Sep 2001 20:30:40 +0100, Dale Strickland-Clark wrote: >francois-regis.chalaoux at sanofi-synthelabo.com (copter24) wrote: > >>Hi, >> >>How to get a directory size with win32 api ? >>Any code exemple ? >> >>FR > >If you mean in terms of total kbytes occuplied, I don't think you can. You could always do it the hard way: use os.path.walk() with a visit function that uses os.path.getsize() and keeps a total of the results. This approach would be platform-independent. --PW From aleax at aleax.it Mon Sep 17 07:47:32 2001 From: aleax at aleax.it (Alex Martelli) Date: Mon, 17 Sep 2001 13:47:32 +0200 Subject: What is Python good for? References: <6f8cb8c9.0109120541.132432d4@posting.google.com> <9nnsck02uat@enews1.newsguy.com> <9nqbmv023f7@enews2.newsguy.com> <4si4qt4jup5to8v1egutl50mk2mi60tngb@4ax.com> <3BA29952.AF81B7AD@engcorp.com> Message-ID: <9o4nsk02obn@enews4.newsguy.com> "Peter Hansen" wrote in message news:3BA29952.AF81B7AD at engcorp.com... ... > Not speaking for Cameron, but I would say that the phrase > "hand-tune" implies specifically *not* using tools such as > profilers in the process. I think most programmers who I can't speak for Cameron either, but that's not how _I_ use the phrase. To me, it implies tuning by hand, rather than via some automatic scheme (as I recall using on SGI machines many years ago) whereby the code would first be compiled in a mode where it keeps a log (e.g. of what way the branches go, cache behavior, paging behavior...) over "typical use sessions", then the compiler is run again (with the log as input) and builds compiler-tuned code (by optimizing branch prediction, cache use, locality of references to minimize page faults, etc). When I hand-tune code I still use a lot of tools, such as profilers, editors, disassemblers (when the compiler itself can't give me a readable machine-code listing), just not as automatic and integrated tools as I would if the "tuning" abilities were built into the compiler. Alex From James_Althoff at i2.com Fri Sep 14 14:21:31 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Fri, 14 Sep 2001 11:21:31 -0700 Subject: Proposed PEP for a Conditional Expression Message-ID: With apologies for possibly having missed some parts of this thread . . . Given: 1) nested scopes, and 2) recent proposals becoming more and more complicated and convoluted -- e.g., embedding "break" and "return" statements inside if:else: expression syntax, highly overloaded meanings of if:else: , inside/outside/upside/downside ordering of if:else: keywords, etc., . . . Why not just start with something simple like a builtin "cond" function approximating the following: Python 2.2a1 (#21, Jul 18 2001, 04:25:46) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> >>> from __future__ import nested_scopes >>> >>> def cond(expr, iftrue, iffalse=lambda:None): ... if expr: return iftrue() ... return iffalse() ... >>> x = -2 >>> abs = cond(x>=0, lambda:x, lambda:-x) >>> abs 2 >>> l = [7,8,9] >>> firstItem = cond(len(l)>0, lambda:l[0]) >>> firstItem 7 >>> l = [] >>> firstItem = cond(len(l)>0, lambda:l[0]) >>> print firstItem None >>> Seems like this would handle many of the common, simple cases. Jim ps. Then attention could be focused on defining a mechanism for general-purpose, unnamed, "in-place" code blocks. If we had such, we could then create many convenient idioms using functions and methods -- instead of constantly wrangling with new syntactic forms and keywords. From rickp at telocity.com Tue Sep 18 12:38:17 2001 From: rickp at telocity.com (Rick Pasotto) Date: Tue, 18 Sep 2001 16:38:17 GMT Subject: nntplib and xover Message-ID: Some news servers return the Xref: line in response to the XOVER command. Currently the nntplib does not include this line. 1) Will this be included in future versions? 2) What is the best way to get this line now? -- If you start with the already absurd assumption that the government is the morally active force and that the nation is passive, are you not putting morals, doctrines, opinions, wealth, everything that makes up the life of the individual at the mercy of the men who one after another come to power? -- Fr?d?ric Bastiat (1801-1850) Rick Pasotto rickp at telocity.com http://www.niof.net From mmhamze at pleiades.net Fri Sep 7 10:13:49 2001 From: mmhamze at pleiades.net (Maan M. Hamze) Date: Fri, 7 Sep 2001 09:13:49 -0500 Subject: Creating Excel files on Linux References: Message-ID: Ignacio My question was the following: Can Staroffice create XLS files? Yes or no! As to the 'poetics' of what I meant by 'XLS language', it was a metaphor and my answer to this issue appears in my answer to Oleg in that very same thread: the language of XLS is the language that the office secretaries and managers and editors and a host of other million people understand. Figuratively that is - not as a computer programming language. Maan "Ignacio Vazquez-Abrams" wrote in message news:mailman.999869659.17871.python-list at python.org... > On Fri, 7 Sep 2001, Maan M. Hamze wrote: > > > But the question is: Can Staroffice create XLS files? If not, then it is a > > major waste of time to create spreadsheets using Staroffice. It is a world > > that speaks the XLS language. > > Maan > > Yeah, but Microsoft doesn't wnat anyone else speaking it. If they did, they > wouldn't have made them OLE compound documents. > > -- > Ignacio Vazquez-Abrams > > From phd at phd.pp.ru Mon Sep 3 05:20:22 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Mon, 3 Sep 2001 13:20:22 +0400 (MSD) Subject: Is there any python 2.1 decompiler ??? In-Reply-To: <20010903121231.A22538@profile4u.com> Message-ID: On Mon, 3 Sep 2001, Frederic Quin wrote: FQ> I am looking for a python 2.1 decompiler... dis.py in standard library. http://groups.google.com/groups?q=dis.py&safe=off Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From kdahlhaus at yahoo.com Thu Sep 13 20:36:58 2001 From: kdahlhaus at yahoo.com (Kevin Dahlhausen) Date: 13 Sep 2001 17:36:58 -0700 Subject: Python parsers that parse Java? Message-ID: <283adf56.0109131636.59e1122f@posting.google.com> Is there a readily availble parser written in Python that can parse java code? I'm forced to use java for a project, and would like to automate some code generation with Python. I don't have a lot of time to devote to this, so something ready to go would be best. Thanks From ignacio at openservices.net Fri Sep 21 14:40:55 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Fri, 21 Sep 2001 14:40:55 -0400 (EDT) Subject: How to sort a list? NOT a newbie question. In-Reply-To: <20010921143201.A1637@node0.opengeometry.ca> Message-ID: On Fri, 21 Sep 2001, William Park wrote: > Then, how does Python compare complex now? It doesn't; it raises an exception. -- Ignacio Vazquez-Abrams From ralph at inputplus.demon.co.uk Sun Sep 30 06:31:34 2001 From: ralph at inputplus.demon.co.uk (Ralph Corderoy) Date: 30 Sep 2001 11:31:34 +0100 Subject: Off-topic: hiding your email address - don't bother... References: <9p5aio$50a$1@inputplus.demon.co.uk> Message-ID: <9p6sa6$30b$1@inputplus.demon.co.uk> Hi Chris, > i immediatly removed my nospam string in the address. it's not > helping anyway: Thanks! One down, a few more to go. > some spammers are surely clever enough to detect such fake emails and > they may even correct it. (removing spaces, replacing 'at'=='@', > remove strings like 'no.spam' etc. isn't a big thing, is it?) That's right. Reapers do these common kind of fixes. That's why people have to be more inventive. But it's all futile. If a human replies to a post, works out the real email address, and CC's the person being replied to then their `plain text' email address is there for all to see. In fact, if I had the time I'd take the effort to always CC such people :-) Ralph. From emile at fenx.com Mon Sep 3 11:09:45 2001 From: emile at fenx.com (Emile van Sebille) Date: Mon, 3 Sep 2001 08:09:45 -0700 Subject: typechecks: just say no! (was Re: Determining Types) References: <9mvo0u04o8@enews2.newsguy.com> <3b938f31.2123170@nntp.sprynet.com> Message-ID: <9n06s8$4isc7$1@ID-11957.news.dfncis.de> Couldn't you always coerce it? str('hello') str(123) -- Emile van Sebille emile at fenx.com --------- "Skip Montanaro" wrote in message news:mailman.999528483.6865.python-list at python.org... > > One place that I've actually found typechecking useful is at the boundary of > my XML-RPC server. If I'm expecting a string input (say, the name of a > band) and someone on the other side inputs "311" to a Perl-based website > which then passes the query to my server, I get an integer that I have to > coerce back to a string. In my comments I call it a "Perl guard". ;-) > > -- > Skip Montanaro (skip at pobox.com) > http://www.mojam.com/ > http://www.musi-cal.com/ > From jblazi at hotmail.com Fri Sep 28 09:52:34 2001 From: jblazi at hotmail.com (Janos Blazi) Date: Fri, 28 Sep 2001 15:52:34 +0200 Subject: Problem with os.system() Message-ID: <3bb480af_1@news.newsgroups.com> I have the following code: prog=r'"C:\Programme\Windows Media Player\mplayer2"' f=r'c:\WINNT\Media\Microsoft Office 2000\APPLAUSE.WAV' os.system(prog+' /Play '+f) Now first it seems as though it worked and the wav file is played. The problem is that after the wav file has ben played my program does not regain the control i.e. the next statement is not executed. If I close the Media Player window manually, my program resumes. I use Win2000 but my program should work under MS-DOS. Can anybody help me? J.B. -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! Check out our new Unlimited Server. No Download or Time Limits! -----== Over 80,000 Newsgroups - 19 Different Servers! ==----- From rnd at onego.ru Sun Sep 9 02:04:33 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 9 Sep 2001 10:04:33 +0400 (MSD) Subject: Creating Excel files on Linux In-Reply-To: <9ne0bq02jq1@enews2.newsguy.com> Message-ID: On Sat, 8 Sep 2001, Alex Martelli wrote: >Roman Suzi wrote: > ... >> mercilessly.) So, if MIcrosoft monopoly will last, my non-conformistic >> views will make me non-conformic with the whole society, because I will > >...unless said monopoly switches to using open formats for its documents, >and, as it happens, this is indeed going on (you can write .RTF, which is >an open and documented format equivalent to .DOC from Word's viewpoint, >with many systems; Office XP uses XML as its native format, I think, and >the future Office .NET surely will; etc, etc). Microsoft takes open standards and make some little "improvements" to them. I do not know, what is wrong, but I was unable to communicate RTF from StarOffice to Office 2002 (==XP?) due to loss of some letters. >> not be able to interface with state using free systems. For example, if I >> had a firm, I *MUST* pay for at least MSDOS under which works the program >> to prepare tax-reports! While such programs are probably just several >> screens of Python code + database of classificators, etc. > >The recently-released version 1.0.2 of DOSEMU, with FreeDos on top, can >probably let you run that program on a good Linux i386 machine. Yes, I know. But the program could be open source - there is nothing proprietary in it, only special format it uses must stricly conform to what tax office uses. >> The only hope is to convince gov's to use free software as happens in the >> West. > >I'm not too sure about "the West" -- there's a lot of non-free software in >governmental use around here (and now that, as a part of the recent >government, we had the guy who headed Microsoft Italia until joining said >government, my personal hopes that this will change have gone down:-). > >Rather, it seems to me that China is pursuing a strong policy of free-sw >use (in their case the point being definitely the free-as-in-beer part), >and France may be heading in the same direction (in _their_ case, the >desire of resisting American cultural hegemony is probably uppermost). Interesting. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Sunday, September 09, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Another case of Cherry Coke down the programming hatch!" _/ From phd at phd.pp.ru Thu Sep 27 11:45:10 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 27 Sep 2001 19:45:10 +0400 Subject: hacking In-Reply-To: <002701c1476b$58902900$2092fc3e@007887420090>; from andym645@ntlworld.com on Thu, Sep 27, 2001 at 04:44:50PM +0100 References: <002701c1476b$58902900$2092fc3e@007887420090> Message-ID: <20010927194510.F25063@phd.pp.ru> On Thu, Sep 27, 2001 at 04:44:50PM +0100, andym645 wrote: > i would like to know how other users can hack into your computer while > your online, is there any books out there on this subject that would it > explain it to me, and how i can prevent them from doing so. http://www.google.com/search?q=network+security+books Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From wangye1 at auburn.edu Tue Sep 25 11:50:53 2001 From: wangye1 at auburn.edu (clio) Date: Tue, 25 Sep 2001 10:50:53 -0500 Subject: Problem on SWIG/C++/Python Message-ID: <3BB0A7DD.5000908@auburn.edu> Hi, I am trying to make a C++ code be used by Python. I used swig to build the interface between Python and C++. This is the interface file: /*clientapi.i*/ %module clientapi %{ #include "nr.hh" #include "dr.hh" %} extern NRSimpleAttributeFactory TargetAttr; extern NRSimpleAttributeFactory AppDummyAttr; extern NRSimpleAttributeFactory AppStringAttr; extern NRSimpleAttributeFactory AppCounterAttr; extern int lookup_service( char * sv_type, char * spec_svname, NRAttrVec *In_list, NRAttrVec *Out_list, int &intertype ); extern int service_exec( char *serv_name, NRAttrVec *Sv_In, NRAttrVec * & Sv_Out, int intertype ); -------------------------------- "NRSimpleAttributeFactory" and "NRAttrVec" are defined in "nr.hh", the two functions are what I want to use in Python code. I get it compiled and get the shared library, clientapimodule.so. But I saw this in Python: Python 1.5.2 (#1, Mar 3 2001, 01:35:43) [GCC 2.96 20000731 (Red Hat Linux 7.1 2 on linux-i386 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import clientapi Traceback (innermost last): File "", line 1, in ? ImportError: ./clientapimodule.so: undefined symbol: __builtin_new >>> Anybody can tell me why I got this error and how to fix this problem. Thank you! Clio From gerson.kurz at t-online.de Mon Sep 10 10:38:27 2001 From: gerson.kurz at t-online.de (Gerson Kurz) Date: Mon, 10 Sep 2001 14:38:27 GMT Subject: how to get enough privilege to use LogonUser? References: Message-ID: <3b9ccff5.6422250@news.t-online.de> On 10 Sep 2001 04:12:12 -0700, sshark97 at hotmail.com (TH Lim) wrote: >Hi, > >I tried win32security.LogonUser(...) method according to the >ActiveState document. However, I was thrown the exception 'Not all >privileges referenced are assigned to the caller.' Quote from MSDN: "In Windows 2000, the process calling LogonUser requires the SE_TCB_NAME privilege....In some cases, the process that calls LogonUser must also have the SE_CHANGE_NOTIFY_NAME privilege enabled; ... to log on a user with the LOGON32_LOGON_INTERACTIVE flag, the user (or a group to which the user belongs) must have the SE_INTERACTIVE_LOGON_NAME account right." For more info, see http://msdn.microsoft.com From gmcm at hypernet.com Wed Sep 12 17:30:39 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 12 Sep 2001 21:30:39 GMT Subject: Locating Relative Resource Files References: <3B9FC419.42BADEE4@bgb.cc> Message-ID: [posted and mailed] Don Garrett wrote: > Is there some way to determine the location of the file from which > the currently executing source was loaded? Or the file/directory of > the initial python script? os.path.dirname(sys.argv[0]) should do it (although it may be '', meaning os.getcwd() is the script's directory). - Gordon From rbodapatla at hotmail.com Wed Sep 26 14:09:54 2001 From: rbodapatla at hotmail.com (Radhika Bodapatla) Date: 26 Sep 2001 11:09:54 -0700 Subject: Packaging problem[py2exe, Inno setup] - pywintypes.com_error Message-ID: My application[eclient.py, on winNT4.0] uses win32com.client[win32com.client.Dispatch('MSXML2.XMLHTTP'), win32com.client.dynamic.Dispatch("Excel.Application")] and also xml.sax for xml parsing. I create a setup.py file: ;-----setup.py----------- from distutils.core import setup import py2exe setup(name="eclient", scripts=["eclient.py"], data_files=[("template",["expenseform.xls"])],) ;------------------------ I run it using py2exe: python setup.py py2exe -p _xmlplus,win32com This creates 2folders build and dist. In the dist folder it creates eclient folder in which it has the eclient.exe and other .dlls. Also creates a folder tcl with 2more folders in it- tcl8.3 and tk8.3. Then I use Inno setup[I only include the files in the dist folder] to create my .exe so that I can install it on a machine that doesn't have python installed on it. But this is the error I get when I try to run it from another machine: Traceback : File "", line 332, in ? File "", line 12, in __init__ File "win32com\client\__init__.pyc, line 94, in Dispatch File "win32com\client\dynamic.pyc, line 81, in _GetGoodDispatchandUserName File "win32com\client\dynamic.pyc, line 72, in _GetGoodDispatch pywintypes.com_error: (-2147221005, 'Invalid class string', None, None) ----------------------------------------------- I tried using the --force-imports win32com option but with no luck. It runs fine on my machine[ofcourse, I have python installed] I tried changing the path & pythonpath and also renamed the win32com folder on my machine and the .exe still runs fine on my machine. Any help or tips appreciated. Thank you. Radhika. From phd at phd.pp.ru Tue Sep 18 04:49:05 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 18 Sep 2001 12:49:05 +0400 Subject: re source code In-Reply-To: <025501c1401e$b13854a0$a500a8c0@moonqzie>; from cgaston@moonqzie.com on Tue, Sep 18, 2001 at 10:48:30AM +0200 References: <025501c1401e$b13854a0$a500a8c0@moonqzie> Message-ID: <20010918124905.C9854@phd.pp.ru> On Tue, Sep 18, 2001 at 10:48:30AM +0200, Carlos Gaston Alvarez wrote: > I want to read re source code. > I want to know why it is more tolerant to .* than to .*? and so on. The > final documentation is the source. I want that. The final documentation is the source... but in this case. Reading regex implementations is the way to explode your brain. Regex implementations use a lot of deep mathematical and programming concepts. If you are sure you can understand them - then welcome! Use the Source, Luke! Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From mmhamze at pleiades.net Sun Sep 9 09:45:03 2001 From: mmhamze at pleiades.net (Maan Hamze) Date: Sun, 09 Sep 2001 13:45:03 GMT Subject: Pythonwin and .NET References: <3B997A5E.6010801@bigpond.net.au> <3B9B6590.60CD81A5@earthlink.net> Message-ID: Ron Beautifully said. When I asked the question to Mark I was hoping to get different comments from people in the know as I was about to start working my way through Mark's book. Also, Mark's reservations are to expected. I believe he is being a bit cautious which is understood. But, personally, I only expect good things for Python to come out of this. Maan "Ron Stephens" wrote in message news:3B9B6590.60CD81A5 at earthlink.net... > Hello Mark, I am loving your book. > > I hesitate only a few seconds before adding my comments to those of Mark Hamond > and Alex Martelli, for reasons only Alexander Pope might fully understand. > > I well make a prediction: > > Despite the reservations of a genius, Mark will help secure such a place in .NET > for Python, that this extension of Python will be one of the major reasons for the > ultimate advancement of the language Python to a pre-eminent role in the further > evolution of computer science. > > I feel this in my bones. I cannot expect to offer detailed reasons on the level of > Alex and Mark. But my bones are normally prescient, and not to be ignored. > > God bless mark Hammond and Python...and .NET. > > ...from one of the legions who will buy any future Mark Hammond book sight unseen. > > Ron Stephens > From dale at riverhall.NOSPAMco.uk Thu Sep 13 09:51:36 2001 From: dale at riverhall.NOSPAMco.uk (Dale Strickland-Clark) Date: Thu, 13 Sep 2001 14:51:36 +0100 Subject: XML confusion Message-ID: <0be1qt8qon2mjb9dj2s94po54gi6h7gt9q@4ax.com> I'm reading what I can find on XML with Python and came upon this: http://py-howto.sourceforge.net/xml-howto/node14.html The first paragraph makes reasonable sense but it goes sharply down hill after that. Does that look like Java definitions? -- Dale Strickland-Clark Riverhall Systems Ltd From jagbdotx at yahoo.com.br Wed Sep 5 10:19:07 2001 From: jagbdotx at yahoo.com.br (=?ISO-8859-1?Q?Jo=E3o?= Alfredo) Date: 05 Sep 2001 11:19:07 -0300 Subject: Widget tooltips Message-ID: <999699581.1025.12.camel@spoc> Hi all, Does Tkinter supports widget tooltips?? If yes, how?? Thanks in advance. []'s Jo?o Alfredo _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From kwg at renre-europe.com Wed Sep 19 05:11:12 2001 From: kwg at renre-europe.com (Ken Guest) Date: Wed, 19 Sep 2001 10:11:12 +0100 Subject: No spam in books Message-ID: <50C760B14D9DD511B00D009027DE2CCD028C6F@ROEEX01> Sounds like your describing a toolsmith.... >From Jargon File (4.2.3, 23 NOV 2000) : toolsmith n. The software equivalent of a tool-and-die specialist; one who specializes in making the tools with which other programmers create applications. Many hackers consider this more fun than applications per se; to understand why, see uninteresting. Jon Bentley, in the "Bumper-Sticker Computer Science" chapter of his book "More Programming Pearls", quotes Dick Sites from DEC as saying "I'd rather write programs to write programs than write programs". (www.dict.com is very handy!) -----Original Message----- From: Greg Ewing [mailto:greg at cosc.canterbury.ac.nz] Sent: 19 September 2001 01:36 To: python-list at python.org Subject: Re: No spam in books Me parece que Alex Martelli dijo: > We're supposed to make it *LOOK* that way, yes, but, hey, deep > down many of us aren't driven by *application needs* in tinkering > with tools. Very true. A friend of mine once remarked "Computer scientists are people who spend all their time writing programs to help them write other programs." -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg -- http://mail.python.org/mailman/listinfo/python-list From peter at engcorp.com Thu Sep 20 22:09:11 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 20 Sep 2001 22:09:11 -0400 Subject: bsddb3 vs zodb References: <3BA9A72A.1D5A6067@yahoo.com> <9ocbso$m72$1@slb7.atl.mindspring.net> <3BA9F383.9ED5C436@yahoo.com> Message-ID: <3BAAA147.550FD359@engcorp.com> vincent delft wrote: > > I just would like to have a very small DB with concurrent read and write. > > I've a daemon collect data and store them into the DB. > > But I've other processes (not deamon) that will read and write into the same > DB. I'm pretty sure a single ZODB FileStorage can only be used from within a single Python program, unless you run Zope itself and perform all database accesses using one of the defined protocols such as HTTP or FTP, or maybe use SOAP or XML-RPC. This sounds way more complex than what you seem to need. > What about the performances (how many read/write per seconds, what about the > memory used by those solutions, ...) What requirements do you have? (Issues such as performance and memory consumption should generally be addressed first by defining your own needs, then checking whether a given solution is adequate. If you start by picking the fastest solution, or the least memory intensive, just because it is the fastest or most efficient, you are effectively optimizing before you have a working solution. You are also putting a lower priority on ease of use, reliability, and other more important issues. Just set a minimum threshold and exclude any solutions which don't meet your requirement. Then pick from the remaining ones based on other criteria.) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From greg at cosc.canterbury.ac.nz Thu Sep 6 22:46:37 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 07 Sep 2001 14:46:37 +1200 Subject: [Tutor] Why I'm learning Python (OT and long) References: <3B97C008.5080303@hp.com> Message-ID: <3B98350D.5C6995A9@cosc.canterbury.ac.nz> Garth Grimm wrote: > > And often the guy that can *design* the engine can't fix it, That's no problem. If it breaks down, he can just design a new one! -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From aleax at aleax.it Sun Sep 16 09:36:37 2001 From: aleax at aleax.it (Alex Martelli) Date: Sun, 16 Sep 2001 15:36:37 +0200 Subject: Flatfile update? References: <20010916.125521.1909002904.11525@mailandnews.com> Message-ID: <9o29t5$nmm$1@lancelot.camelot> pwgk wrote: > Hi, > I am trying to find out if it is possible to open a flat (ascii) file for > update in python, so I can change it's contents directly, without having > to copy the entire contents. Yes, the "r+" option to the built-in open function lets you open an existing file so you can both read and write its data. However, on just about all of today's operating systems/filesystems, any bytes you should write at a given offset are just overwriting the bytes that were there before; so, in practice, this is only useful if each field you may want to overwrite is of fixed length. There is no way to "insert" bytes in-between ones that were there, or "remove" bytes from somewhere in the middle of the file (as opposed to overwriting those bytes with others). > Is this possible, and if yes, does anyone know how? > Or do I have to start digging into MySQL for that? Any RDBMS, and some lighter-footprint alternatives such as the Berkeley DB (which Python lets you access easily) will no doubt provide a vastly more flexible alternative. However, they do not meet your stated specs of "changing an ascii's file's contents directly" -- they operate in completely different ways. Alex From eric at jazzy.org Mon Sep 3 00:33:30 2001 From: eric at jazzy.org (Eric Co) Date: 2 Sep 2001 21:33:30 -0700 Subject: import module under windows Message-ID: hi, i write a C/C++ extension module under windows. it compile to be a dll, say spam.dll. then i use "import spam" to import this module to python. the problem is that my spam have to link with other dll that contain codes with __declspec( thread ) static char szFoo[_MAX_PATH]; so it crash due to the problem here: http://support.microsoft.com/support/kb/articles/Q118/8/16.ASP so i would like to know is it possible to build my spam.dll statically into python21.dll? thanks. -Eric Co From ignacio at openservices.net Wed Sep 5 23:16:36 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Wed, 5 Sep 2001 23:16:36 -0400 (EDT) Subject: Question on python script in c wrapper with apache. In-Reply-To: Message-ID: On Wed, 5 Sep 2001, Wayne Ringling wrote: > Any ideas greatly appreciated. I'm just mucking around in the source here, and it looks like the script may have to be chowned root.root and the executable has to be 6755. -- Ignacio Vazquez-Abrams From skip at pobox.com Fri Sep 14 18:14:54 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 14 Sep 2001 17:14:54 -0500 Subject: Newbie Question.. What is the replacement for the ELSE command?. In-Reply-To: References: Message-ID: <15266.33118.589206.175859@beluga.mojam.com> >> I am trying to teach myself Python. All the online tutorials, have >> examples with the else command. I cant get it to work is there a >> replacement? Not really. Here are some tips: 1. Post some example code that's not working. 2. Make sure your "else" lines up with your "if" and that their subsidiary clauses are indented properly, e.g., if age > 90: print "hey, I'm gettin' old!" else: print "geez, I'm just a whippersnapper!" 3. Check out the tutor and python-help mailing lists. More about them is here: http://www.python.org/psa/MailingLists.html 4. Check out the various tutorial information at http://www.python.org/doc/ -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From syt at pegasus.logilab.fr Fri Sep 14 06:06:47 2001 From: syt at pegasus.logilab.fr (Sylvain Thenault) Date: Fri, 14 Sep 2001 10:06:47 +0000 (UTC) Subject: minidom References: <1000460361.559401@newsmaster-04.atnet.at> Message-ID: On Fri, 14 Sep 2001, Bernhard Trummer wrote: >My XML-file looks like: >---------------------------------------------------------------- > > > > Eisenstadt: Europaplatz, zwischen B?rgerspitalgasse und >Kurzwiesenweg: > > > A2 Autobahn: > >... > >---------------------------------------------------------------- > >The error message: >---------------------------------------------------------------- > File "F:\\Scripts\XMLTest2.py", line 54, in handlePoint > print "
  • %s
  • " % getText(point.childNodes) >UnicodeError: ASCII encoding error: ordinal not in range(128) >---------------------------------------------------------------- > >The phython code (where it crashes) >---------------------------------------------------------------- >def handlePoint(point): > print "
  • %s
  • " % unicode(getText(point.childNodes)) > >def getText(nodelist): > rc = "" > for node in nodelist: > if node.nodeType == node.TEXT_NODE: > rc = rc + node.data > return rc >---------------------------------------------------------------- You have this error because by default, python guess that your string contains only ASCII characters, so when you try to encode it, it raise an 'ASCII encoding error'. You have to say that your string contains latin1 characters for unicode translation, and then encode it a printable form the following should work: --- def handlePoint(point): print "
  • %s
  • " % \ unicode(getText(point.childNodes), 'iso8859-1').encode('iso8859-1') --- as you see, the same thing is available for translation from unicode string to latin1 string. Hope it helps -- Sylvain Thenault LOGILAB From dradul at yahoo.com Mon Sep 3 18:30:49 2001 From: dradul at yahoo.com (P. Alejandro Lopez-Valencia) Date: Mon, 3 Sep 2001 17:30:49 -0500 Subject: Necessary Python stuff on Sun References: Message-ID: <9n108r$4dide$1@ID-99513.news.dfncis.de> In article , writeson at earthlink.net says... >Hi, > >For various reasons I put the Python source tar file in /usr/local/bin on my >Sun Solaris 2.6 machine in order to compile it and get it running. Now I've >got it running and I'd like to move the necessary libaries and runtime stuff >to another machine. First off can anyone tell me if putting the source tar >file in /usr/local/bin was a bad idea and if so why? If it was a bad idea, >what should I have done to compile and install it? Now that it's done, how >can I extract just the stuff I need to run Python on another Solaris 2.6 >machine? > >Thanks in advance, >Doug > As already said, the right place is /usr/local/src, or /opt/src if you have lots of space in the /opt partition (usually not true). I do have a tip that addresses previous postings at the end of July (can't find them in my news cache :) as I tried to compile my own version of Python instead of using ActiveState's, having built the latest gcc 3.01 and all ;). I was bitten hard. When compiling dynamic extensions that extract objects from static libraries compiled with gcc (or SunPro cc, be it WorkShop or Forte), the linker will fail nastily. The problem is that the compiler will not make dynamically reallocatable objects in the libraries unless you explicitly say so! This is particularly important when compiling shared extensions and forcing a link to static libraries in order to bypass the limitations of the dynamic loader (Python extensions, some Perl XSs). The solution is to add the -fPIC flag to gcc or the -KPIC flag to SunPro cc. Thus in an ultrasparc, the basic compiler flags are: gcc: -fPIC -Wa,-xarch=v8plus -mcpu=v9 cc: -KPIC -xarch=v8plus -xtarget=ultra This means you will have to recompile all static libraries that you want to link into Python extensions, before compiling Python using the same flags. I ran into this problem with OpenSSL, gdbm, GTK, wxWindows, readline, BerkeleyDB and a few others. Thus, prepare yourself for a field day or leave everything in cron and go out for good chinese food and come back in the morning. Cheers! -- Alejandro Lopez-Valencia Kenkon Itteki --- Heaven and Earth at one stroke From niessink at serc.nl Mon Sep 10 16:42:28 2001 From: niessink at serc.nl (Frank Niessink) Date: 10 Sep 2001 20:42:28 GMT Subject: Tkinter and unittest Message-ID: <9nj8jk$9gg$1@newshost.accu.uu.nl> Hi, I'm trying to write unittests for a Tkinter based application, but have trouble combining the Tkinter mainloop and the unittest control loop. Does anyone have any experience with this they'd want to share? Thanks in advance, Frank -- Orbiting this [sun] at a distance of roughly ninety-two million miles is an utterly insignificant little blue green planet whose ape-descended life forms are so amazingly primitive that they still think digital watches are a pretty neat idea. -- Douglas Adams, 'So long, and thanks for all the fish' From ykingma at accessforall.nl Sat Sep 1 06:04:17 2001 From: ykingma at accessforall.nl (Ype Kingma) Date: Sat, 01 Sep 2001 11:04:17 +0100 Subject: JBuilder References: <8d148763.0108312223.1aea4f6c@posting.google.com> Message-ID: <3B90B2A0.A84B38A1@accessforall.nl> yaipa wrote: > > Has anyone developed a "plug-in" for Jbuilder? > I use it at work for Java Development and would > like to use it at home for Python. I would use > UltraEdit, but work is Sun and UltraEdit is Win32 > only. You might try using jython, a java implementation of python. It allows direct access from python to java classes on the class path, so you don't need a plug-in: www.jython.org Have fun, Ype -- email at xs4all.nl From rangerrandy at hotmail.com Tue Sep 18 00:48:37 2001 From: rangerrandy at hotmail.com (Randy) Date: 17 Sep 2001 21:48:37 -0700 Subject: wxPython event question Message-ID: Hi, I'm just learning wxPython, and I have a question about using the wxComboBox widget. After the user enters text into the widget, I want to capture the event from "Enter" key to process the new text. Thanks for any help, Randy From jason at tishler.net Mon Sep 24 00:15:53 2001 From: jason at tishler.net (Jason Tishler) Date: Mon, 24 Sep 2001 00:15:53 -0400 Subject: time.timezone gives strange results on cygwin In-Reply-To: Message-ID: <20010924001553.I1904@dothill.com> Andy, On Mon, Sep 24, 2001 at 03:16:27AM +0000, Andy Todd wrote: > time.timezone is returning an incorrect value on cygwin python. > > [snip] > > But from cygwin on the same machine; > > $ python > Python 2.1.1 (#2, Aug 23 2001, 10:41:44) > [GCC 2.95.3-5 (cygwin special)] on cygwin > Type "copyright", "credits" or "license" for more information. > >>> import time > >>> print time.tzname > ('AUSEST', 'AUSEDT') > >>> print time.timezone > 1834228892 > >>> > > Any suggestions? See the following: http://sourceforge.net/tracker/index.php?func=detail&aid=459385&group_id=5470&atid=305470 Jason From greg at cosc.canterbury.ac.nz Thu Sep 13 18:56:09 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 14 Sep 2001 10:56:09 +1200 Subject: Proposed PEP for a Conditional Expression References: <6qvgire4bk.fsf@abnoba.intevation.de> <9nk3jd$4lc$1@glue.ucr.edu> <9nnsa3$bjl$1@news.mathworks.com> <3BA00239.DECE6412@cosc.canterbury.ac.nz> Message-ID: <3BA13989.19EF1BC7@cosc.canterbury.ac.nz> Terry Reedy wrote: > > if else > > ... is exactly like C, whose ? : equivalent is the impetus for the > proposed change. No, it's not, because the C syntax doesn't use English words in a misleading way. That's what I was objecting to, not the order of the operands. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From peter at engcorp.com Thu Sep 6 23:25:46 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 06 Sep 2001 23:25:46 -0400 Subject: how to run python script from Unix Shell? References: Message-ID: <3B983E3A.139A8B71@engcorp.com> David wrote: > > Can you help to advise how to run python script from Unix Shell? > What I am doing is: > 1)chmod +x script name > 2)put #!/usr/bin/python at first line > 3)when I type the script name under Shell, > the message is: > bash: Script name command not found. Note: always cut and paste the *precise* error message (and preferably the *precise* command you entered) when you are reporting a problem. This avoids confusion. In this case, I'm assuming what you saw looked more like: [phansen]$ test.py bash: test.py: command not found If this is the case, you should probably try ./test.py instead. The shell does not execute files which are not in one of the directories in the PATH unless you refer to them explicitly (relative or absolute path). If you move the file to somewhere in the PATH it should work. > Actually, it works if I type: > python "script name" The other problem could be that your python is not really in /usr/bin (type "which python" to be sure) but then your error message would say: bash: ./test.py: No such file or directory (This all on Red Hat release 7.1.) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From eif at ukonline.co.uk Sat Sep 1 12:07:19 2001 From: eif at ukonline.co.uk (eif) Date: Sat, 1 Sep 2001 17:07:19 +0100 Subject: Converting a text file to a string? Message-ID: can anyone please help me out here? - im running a python cgi script that outputs a database in a text file format something that looks like this: 999347857||9/1/2001 at 13:37:37|016354|jim o shea|jim at mmu.ac.uk|126|0161025658 999347943||9/1/2001 at 13:39:03|223654|roy saberton|roy at mmu.ac.uk|201|0161236510 999347943||9/1/2001 at 13:39:03|223654|roy saberton|roy at mmu.ac.uk|201|0161236510 I can open and read this file, but the problem is I want to convert this file into a list - in order to access and manipulate each individual element. can anyone tell me how to do this or am I going the wrong way about the problem? cheers From isabelle.todescato at libertysurf.fr Thu Sep 27 11:52:20 2001 From: isabelle.todescato at libertysurf.fr (Fabien) Date: 27 Sep 2001 08:52:20 -0700 Subject: Using WinSwig-1.3.9 with MsVC5.0 under WNT4.0-LinkingError Message-ID: Dear Pythoners, I am trying to build an extension module for Python2.1.1 using WinSwig-1.3.9 under WindowsNT4.0, following the explanations of the excellent user's guide. I have no problems compiling, but have the following error at linking time : C:\Python21\libs\python21.lib : fatal error LNK1106: invalid file or disk full: cannot seek to 0x3b59776f The on-line MSVC help suggests that the trouble may arise from the disk being full - which is not the case - or from the disk being corrupted, which is unlikely to be the case... Is it possible that the .lib from the distribution may be corrupted ? Does any one of you have stumbled upon a similar problem ? Thanks to you all, Fabien TODESCATO From gerson.kurz at t-online.de Thu Sep 6 09:09:04 2001 From: gerson.kurz at t-online.de (Gerson Kurz) Date: Thu, 06 Sep 2001 13:09:04 GMT Subject: Difference pythonw.exe / python.exe ! References: <3b97e659.275590207@news.mch.sni.de> Message-ID: <3b977506.730234@news.t-online.de> On Thu, 06 Sep 2001 21:11:09 GMT, nikolai.kirsebom at siemens.no (Nikolai Kirsebom) wrote: >I observe that when the application is run with 'python.exe applic.py >...' searching works, however when the application is run with >'pythonw.exe applic.py ...', searching fails (does not find matches). >Does anyone have an idea ? In case you really mean it doesn't find anything (and not: I don't see anything), you might check if you provide a complete path to the database. Perhaps you don't and expect the db to be in the current directory; and that might be different for pythonw. In case you mean I don't see anything, well, pythonw.exe has no output console, its a Windowing application. From erno-news at erno.iki.fi Wed Sep 5 13:20:00 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 05 Sep 2001 20:20:00 +0300 Subject: COM/CORBA/DCOP (was: Hello people. I have some questions) References: <7xsne7en0r.fsf@ruckus.brouhaha.com> <9mvp3505rt@enews2.newsguy.com> <9n292n01lg1@enews3.newsguy.com> <9n4kut013qk@enews1.newsguy.com> Message-ID: In article <9n4kut013qk at enews1.newsguy.com>, "Alex Martelli" writes: | "Erno Kuusela" wrote in message | news:kug0a2h37i.fsf at lasipalatsi.fi... || over here isps tend to sell ip connections with 10.x addresses + nat || as "internet" to people and then you can't do anything except || browse the web and read email. | ...and irc and news and cvs and ntp and okbridge and icq and... | I don't particularly care about video-on-demand at this point | in time, but with nat &c correctly configured, I see no | fundamental technical reason it couldn't be made to work. it does break irc and news and cvs and ntp and icq. servers. it does break irc client side (dcc) unless you have an ALG kludge. well, ok, i bet you can come up with a long list of simple tcp services that it doesn't break. it does break lots of other stuff too. assuming we're talking about 1:n nat here and not n:n. here are are some improtant things off the top of my head that i personally use that would not work behind a NAT: running your own services remote access from outside ssh vnc X ... http ftp smtp dns ... file sharing service smb nfs ... peer-to-peer things freenet gnutella ... protocols that transmit ip addresses in the data payload (some of the these can be fixed by using "ALGs" or hacks that know about the protocol that is being run over tcp and actually actively alter the data payload in the packets travelling through the NAT box (this is commonly done with e.g. FTP)) but it only works for protocols that the nat box designer has thought of and know about before hand and is just conceptually too horrible to contemplate most udp services (like peer to peer games, ntp, ...) IP protocols other than udp or tcp tunneling ipsec (ok, i don't personally run this, but it is very important not to break imho) cipe 6to4/sit ... if everyone were behind a nat, no 2 computers on the internet could communicate with each other. and the alg idea is fundamentally infeasible in the long run given we'd like to run most services encrypted before long. | Of course, I'll have to go with dynamic DNS to match the | dynamic IP assignment if I want to offer servers, but that's | got nothing to do with NAT'ting -- even just one box with | a dynamic IP address would be in the same boat. || there is a good rant about this and other internet breaking stuff || at . | If you can give me URL's to transcripts of this, or other | _written_ material, I'll be happy to read and ponder over | them, but I don't do video/audio at this point. okay... || (unless you allow untrusted users shell accounts on it, || but you can't really defend someone with a shell account || from rootnig a unix box (including openbsd) anyway). | I wonder -- when it's consolidated and hardened enough, I | might experiment with that. But anyway, who's happy with | a single layer of defense? I want security in depth, and yeah, security in depth is good, but the layers are only helpful when they are non-trivial to break (follow bugtraq for a while to see why defending against local users is a futile exercise). if you don't run any services on the firewall, then you are pretty well off. || i've been pretty happy with running packet filtering on my single || computer i have at home, but then i don't attempt anything very || ambitious functionality wise. | As for me, I do need to share the ADSL connection among | half a dozen PC's (both Windows and Linux ones), and also | eventually run some small servers accessible from the outside | (unless that means code-red scans tie up all my very modest | bandwidth, of course:-) -- and I aim to do it all in the | safest way I can devise. We'll see... running some servers accessible from the outside might prove challenging with a NAT. (unless you run them on non-standard ports and/or use some sort of port-forwarding kludge). -- erno From michael at rcp.co.uk Wed Sep 5 05:15:10 2001 From: michael at rcp.co.uk (Michael Abbott) Date: Wed, 5 Sep 2001 09:15:10 +0000 (UTC) Subject: Stackless Python and Python 2.x References: Message-ID: "Tim Peters" wrote in news:mailman.999678188.20206.python-list at python.org: > What part of Simple Generators does anyone not yet understand? > How does the Python interpreter maintain the state of a generator during calls to yield? Evidently the entire state has to be restored from wherever it's being kept and plonked back onto the current stack. Perhaps this is a slightly stupid question, but it's more interesting than the other "What part of ... do you not understand?" stuff. From magnus at thinkware.se Tue Sep 25 19:20:29 2001 From: magnus at thinkware.se (Magnus Lycka) Date: Wed, 26 Sep 2001 01:20:29 +0200 Subject: Validating HTML from Python Message-ID: <3BB1113D.6464070A@thinkware.se> I'm currently writing some programs that produce HTML. I'd like to validate the HTML in my unittests. What is the simplest solution for that? Primarily, I just need something that complains unless a string is a correct HTML 4.0 document. It seems that it should be possible to do this in a simpler way than by writing a script that uploads the string to w3c's validator and then parses the resulting file for error messages... Secondly, I suppose it would be useful to use SAX etc to check that the content of the files follow some of my expectations, but that's not my primary concern. This doesn't have to be a "pure python" solution as long as it's simple to access from python, and works on Windows and Linux. TIA /Magnus -- Magnus Lyck? | ?lvans v?g 99 | magnus at thinkware.se | tel: 070-582 80 65 Thinkware AB | 907 50 UME? | www.thinkware.se | fax: 070-612 80 65 From miracle at paradise.net.nz Thu Sep 6 03:05:05 2001 From: miracle at paradise.net.nz (Matthew Sherborne) Date: Thu, 06 Sep 2001 19:05:05 +1200 Subject: IRC Chanel for python chat Message-ID: <3B972021.3030207@paradise.net.nz> If anyone feels like python chatting come to irc.xchat.org #python I registered this chanel because I couldn't find any other python IRC channels GBU Matthew From markus at schabi.de Tue Sep 25 12:12:10 2001 From: markus at schabi.de (Markus Schaber) Date: Tue, 25 Sep 2001 18:12:10 +0200 Subject: Idea about method parameters References: <2728946.ogB4TqSGss@lunix.schabi.de> <7da8d8f8.0109250330.1e5263c0@posting.google.com> Message-ID: <1081943.SPYKUYFuaP@lunix.schabi.de> Hello, sebastien schrub: > I have suggested at: > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/68424 > a few class that try to answer your problem. > > In fact it do a litle more since it allow you to manage your > parameters by groups. This looks good, although a "foreign" reader must know the meaning of the helper classes to understand the meaning. But it doesn't cover parameters without default values (who have to be given). Those are allowed, but not covered by your mechanism. That at least is what I read out of the page, but maybe I simply did not get it. I also had the problem that my browser killed the formatting of the code examples on this site, but this may be the fault of Opera. Does anyone know whether the use of inside of
    . Well, at least 
    validator.w3c.org and www.cast.org/bobby spot out lots of HTML4 errors 
    so I still can believe Opera is correct here :-)
    
    markus
    -- 
    "The strength of the Constitution lies entirely in the determination of 
    each citizen to defend it. Only if every single citizen feels duty 
    bound to do his share in this defense are the constitutional rights 
    secure." -- Albert Einstein
    
    
    From donn at drizzle.com  Thu Sep  6 23:17:39 2001
    From: donn at drizzle.com (Donn Cave)
    Date: Fri, 07 Sep 2001 03:17:39 -0000
    Subject: how to run python script from Unix Shell?
    References: 
    Message-ID: <999832657.64669@yabetcha.drizzle.com>
    
    Quoth davidnet800 at yahoo.com (David):
    
    | Can you help to advise how to run python script from Unix Shell?
    | What I am doing is:
    | 1)chmod +x  script name
    | 2)put #!/usr/bin/python   at first line
    | 3)when I type the script name under Shell,
    | the message is:
    | bash: Script name command not found.
    |
    | Actually, it works if I type:
    | python "script name"
    |
    | But the problem is I want run it by typing "script name"
    
     3) PATH=$PWD:$PATH
    
    Bash is looking for a file that's (1) executable.  The file needs
    the interpreter line (2) to be successfully executed.  Bash will
    look for it only in certain places (3).  (You can use "." or ""
    in PATH to run commands in the local directory.  I wouldn't do
    that, but if you must, put it at the very end of PATH.)
    
    	Donn Cave, donn at drizzle.com
    
    
    From cgale1 at _remove_home.com  Wed Sep 12 19:34:52 2001
    From: cgale1 at _remove_home.com (Van Gale)
    Date: Wed, 12 Sep 2001 23:34:52 GMT
    Subject: What is Python good for?
    References: <6f8cb8c9.0109120541.132432d4@posting.google.com> <9nnsck02uat@enews1.newsguy.com> 
    Message-ID: 
    
    "John Beppu"  wrote in message
    news:mailman.1000330590.19641.python-list at python.org...
    > [  date  ] 2001/09/12 | Wednesday | 04:44 PM
    > [ author ] Alex Martelli 
    >
    > > If you think Perl is easy to master, then you're a very unusual
    > > sort of person.
    >
    > Not necessarily unusual -- just different from you.
    >
    > My background in /bin/sh and C programming made perl
    > really easy, because it just felt like perl fit
    > right in the middle.  I can't say perl was very hard
    > for me to learn
    
    When I first learned perl (sometime after 1.0, but before 2.0), I was having
    to do a lot of system glue work with sh/csh/awk/sed.  Perl was a god-send
    for me, and quite easy to learn.  Since then I had to work on an extremely
    large project that was using perl 5.  I had a difficult time adjusting to
    that environment in spite of having mastered perl 2, and maintenence of code
    written by others on the project was a complete nightmare.
    
    I'd define mastered as: 1) not having to reference the man page or a book
    for anything during coding, 2) being able to read and understand code that
    is intentionally obfuscated by the author, 3) know what language constructs
    to avoid and how to use others properly (e.g. knowing how to construct a
    regular expression with no, or at least minimal, backtracking).
    
    I'd agree with Alex that Perl 5 is not easy to master using that definition.
    Points 1 and 2 make Python easy to master.  Point 3 is a little harder in
    Python, but even if you use a construct improperly (e.g. inefficiently)
    someone else won't have any problem reading your code and understanding what
    you were trying to do.  (Hmm, I suppose that isn't true for a program with
    bad OO design... I find tracing object hierarchies tedious)
    
    
    
    
    
    From chrishbarker at home.net  Mon Sep 24 14:52:50 2001
    From: chrishbarker at home.net (Chris Barker)
    Date: Mon, 24 Sep 2001 11:52:50 -0700
    Subject: Idea about method parameters
    References: <2728946.ogB4TqSGss@lunix.schabi.de>
    Message-ID: <3BAF8102.70E435C8@home.net>
    
    Markus Schaber wrote:
    
    > Now I'd love to have the possibility to shorten this by typing:
    > 
    > class A:
    >     def m(self, self.value):
    >         pass # or the other work to be done
    
    I suspect that this will clash with the internals somewhere, but I love
    it!
    
    -Chris
    
    
    -- 
    Christopher Barker,
    Ph.D.                                                           
    ChrisHBarker at home.net                 ---           ---           ---
    http://members.home.net/barkerlohmann ---@@       -----@@       -----@@
                                       ------@@@     ------@@@     ------@@@
    Oil Spill Modeling                ------   @    ------   @   ------   @
    Water Resources Engineering       -------      ---------     --------    
    Coastal and Fluvial Hydrodynamics --------------------------------------
    ------------------------------------------------------------------------
    
    
    From gerhard.nospam at bigfoot.de  Mon Sep 24 13:19:21 2001
    From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=)
    Date: Mon, 24 Sep 2001 19:19:21 +0200
    Subject: Linux and Numeric extensions...
    References: 
    Message-ID: 
    
    On Sun, 23 Sep 2001 16:31:51 GMT, Carl Johan Rehn wrote:
    >Dear friends, 
    >
    >I am running Linux Suse 7.2 and have recently installed the Numeric 
    >extensions to Python, but when I import the Numeric library the Python 
    >interpreter cannot find the library.
    
    Lets see. Do you have installed it as per the instructions in the README:
    
    $ python setup_all.py install
    
    as user root?
    
    >I suppose I have to add
    >the path to the site-packages/Numeric library somewhere, but I don't know 
    >where.
    
    No, that's not necessary.
    
    I have set my umask to a non-default value, so usually have to do a
    
    $ chmod -R go+rX /usr/lib/python2.1
    
    after installing modules. Make that /usr/lib/python2.0 if you have the original
    Python 2.0 from SuSE 7.2.
    
    Gerhard
    -- 
    mail:   gerhard  bigfoot  de       registered Linux user #64239
    web:    http://www.cs.fhm.edu/~ifw00065/    OpenPGP public key id 86AB43C0
    public key fingerprint: DEC1 1D02 5743 1159 CD20  A4B6 7B22 6575 86AB 43C0
    reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))
    
    
    From skip at pobox.com  Wed Sep  5 15:21:27 2001
    From: skip at pobox.com (Skip Montanaro)
    Date: Wed, 5 Sep 2001 14:21:27 -0500
    Subject: Performance of list comprehensions vs. map
    In-Reply-To: <3B966B1C.120D0AF6@home.net>
    References: <3B966B1C.120D0AF6@home.net>
    Message-ID: <15254.31543.427137.830680@localhost.localdomain>
    
        Chris> I just took another look at:
    
        Chris> http://musi-cal.mojam.com/~skip/python/fastpython.html
    
        Chris> specifically, the loops section:
    
        fp.html> List comprehensions were added to Python in version 2.0 as
        fp.html> well. They provide a syntactically more compact way of writing
        fp.html> the above for loop:
    
        fp.html> newlist = [s.upper() for s in list]
    
        fp.html> It's not really any faster than the for loop version, however.
    
        Chris> my question is: Why not? 
    
    map() is a single function that doesn't return control to the interpreter
    until it's work is done.  List comprehensions are essentially just syntactic
    sugar for the equivalent for loop.  Both the for loop and list comprehension
    are implemented as loops using multiple virtual machine instructions.
    Perhaps the easiest way to see this is to write three equivalent functions
    and disassemble them:
    
        def map_str(n):
            return map(str, range(n))
    
        def lc_str(n):
            return [str(i) for i in range(n)]
    
        def for_str(n):
            l = []
            append = l.append
            for i in range(n):
                append(str(i))
    
        assert map_str(5) == lc_str(5) == for_str(5)
    
        import dis
        print "disassembling map_str"
        dis.dis(map_str)
        print "disassembling lc_str"
        dis.dis(lc_str)
        print "disassembling for_str"
        dis.dis(for_str)
    
        Chris> I like list comprehensions a lot, and they would seem to offer a
        Chris> way to get optimization over a for loop, much like map does, but
        Chris> apparently not. If map can do the loop in C, why can't a list
        Chris> comprehension?
    
    In theory, an optimizer could identify and replace some list comprehensions
    with calls to map, but they wouldn't be quite equivalent.  In the examples
    above, there is no guarantee that the definition of the str function doesn't
    change during the execution of either the for loop or the list comprehension
    (think multiple threads of execution ;-).  The call to map, on the other
    hand, binds str once before map is called.
    
        Chris> I think a big stumbling block is that Python has no concept of
        Chris> the "homogenous" sequence. There are modules that provide such a
        Chris> thing (Numeric, array), and indeed, the string type is a
        Chris> homogenous sequence, but Python itself does not understand this
        Chris> concept, so that if a map or list comprehesion is using a
        Chris> homogenous list, it still has to check the type of every element
        Chris> as it goes through the list. For example:
    
        Chris> [2*a for a in list]
    
        Chris> If the interpreter could just check once what the type of all the
        Chris> elements of list were, it would only have to figure out what 2*a
        Chris> meant once, and it could whip through the list very
        Chris> quickly. Indeed, if you do:
    
        Chris> [2*a for a in a_string]
    
    But there is no guarantee that the list you are operating on isn't modified
    by another thread during execution.
    
    I've been thinking of this a little in the context of Ken Simpson's recently
    announced PyInline module.  The biggest reason I can't use it right now
    (ignoring it's pre-alpha version number ;-) in my own code is precisely that
    I operate on dicts, lists and tuples a lot.  I'm sure that's true for other
    Python programmers.  The problem of easily writing C code that can operate
    on lists (for example) boils down to deciding how you will map Python's
    lists to something that is efficiently representable in C.  Perl's inline
    module does this with something called typemaps.  (Look in something like
    /usr/local/lib/perl5/5.6.1/ExtUtils for a file called "typemap".)  I don't
    really understand everything that's going on in that file, but it does
    provide mappings.  For instance, a "char **" argument followed by an
    "unsigned int" arg might map to and from a list of strings and a length, an
    "int *" followed by "unsigned int" might map to and from a list of ints,
    etc.  I'm not sure quite how you'd do dicts (or if you could in a reasonable
    fashion without listifying them somehow).
    
    I suspect this is about as close as Python will ever come to understanding
    homogeneous containers at the language level.
    
        Chris> I've proposed similar ideas in the past, and not gotten much
        Chris> response. I imagine my ideas are full of holes, but no one has
        Chris> taken the time to point them out to me yet. I have come to the
        Chris> conclusion that the really sharp minds on this list (and the
        Chris> folks that might be qualified to actually impliment such a thing)
        Chris> are not really interested in something like this that is a
        Chris> perfomance only improvement. Am I right? or is the idea just so
        Chris> stupid that it's not worth commenting on?
    
    It's not a matter of lack of interest as much as a desire to keep the
    semantics of Python and lack of time.  Here are some efforts I'm aware of.
    Note that there are lots of ways performance can be addressed, not just by
    constraining types.
    
        * Rattlesnake (my thing) - a new register-oriented virtual machine whose
          premise is that the current stack-oriented virtual machine does far
          too much data shuffling
    
        * Psyco (Armin Rego) - a run-time specializing virtual machine that sees
          what sorts of types are input to a function and compiles a type- or
          value-specific version of that function on-the-fly.  I believe Armin
          is looking at some JIT code generators in addition to or instead of
          another virtual machine.
    
        * Static typing SIG (http://www.python.org/sigs/types-sig/) - I'm not
          familiar with this SIGs work, so you'll have to browse the archives.
    
        * Python2C (Bill Tutt, Greg Stein) - A "module compiler" that generates
          a C version of a Python module.  http://www.mudlib.org/~rassilon/p2c/
    
        * PEP 266 - A "pie in the sky" PEP I wrote that proposes that global
          data could be accessed like local data if you reverse the roles of who
          keeps references up-to-date.
    
        * Various peephole optimizers - I wrote one a few years ago.  There's
          also Michael Hudson's bytecodehacks project (on Sourceforge).  The
          xfreeze bytecode freezer (part of the standard distribution?) also
          does some peepholing.
    
    I'm sure there are several I'm missing.
    
    -- 
    Skip Montanaro (skip at pobox.com)
    http://www.mojam.com/
    http://www.musi-cal.com/
    
    
    
    From boyd at insultant.net  Fri Sep 21 21:52:17 2001
    From: boyd at insultant.net (Boyd Roberts)
    Date: Sat, 22 Sep 2001 03:52:17 +0200
    Subject: How to configure and install Python
    References:  
    Message-ID: <9ogr21$jc4$1@neon.noos.net>
    
    "Oleg Broytmann"  a ?crit dans le message news: mailman.1001081723.23491.python-list at python.org...
    >    Yes, but you do not have C compiler. Install gcc.
    
    or your PATH is wrong doesn't include a C compiler.
    
    install gcc?  the beginning of the end ...
    
    
    
    
    
    From kseehof at neuralintegrator.com  Thu Sep 13 07:26:36 2001
    From: kseehof at neuralintegrator.com (Ken Seehof)
    Date: Thu, 13 Sep 2001 04:26:36 -0700
    Subject: Fw: What is Python good for?
    Message-ID: <018201c13c46$f416d980$4d14b43f@kens>
    
    
    > On Wed, 12 Sep 2001, Ken Seehof wrote:
    >
    > > Oh yes, the overall effect is definitely "ooh-ahh".  I was
    > > just commenting that I haven't noticed any specific unique
    > > python features that are "ooh-ahh".
    >
    > Here's something that came up recently that if it doesn't make you go
    > "ooh-ahh", then it will make you go "whoa":
    >
    > ---
    > >>> def a():
    > ...   return 'abc'
    > ...
    > >>> def b():
    > ...   return 123
    > ...
    > >>> a.func_code=b.func_code
    > >>> a()
    > 123
    > Ignacio Vazquez-Abrams  
    
    Whoa.  Check this out (python 2.1 or later required):
    
    from __future__ import nested_scopes  # if this is python 2.1
    
    def enhance_method(klass, method_name, replacement):
        'replace a class instance method'
        method = getattr(klass, method_name)
        setattr(klass, method_name, new.instancemethod(
            lambda *args, **kwds: replacement(method, *args, **kwds),
            None, klass))
     
    This replaces a method in an existing class with a function that takes the
    original method as an argument.  The replacement function is of the form:
    
    def replacement(old_method, self, *args, **kwds):
       ...
       r = old_method(self, *args, **kwds)
       ...
       return r
    
    Enjoy,
    - Ken
     
    
    
    
    
    
    From fredrik at pythonware.com  Sat Sep 29 12:05:55 2001
    From: fredrik at pythonware.com (Fredrik Lundh)
    Date: Sat, 29 Sep 2001 16:05:55 GMT
    Subject: scanf style parsing
    References: <3BB16A50.BAE082FE@cygnus-software.com>  <3BB2C7DA.F63EEAA7@cygnus-software.com>  <9p4a4f$kdd$1@inputplus.demon.co.uk>
    Message-ID: 
    
    Ralph Corderoy wrote:
    > > or, much more preferably:
    > >
    > >     if filename[-4:] == '.txt':
    >
    > Overall, the Perl code's better.  It didn't have to hard-code the
    > length of the string.
    
    if it matters, use endswith instead:
    
        if filename.endswith('.txt'):
            ...
    
    
    
    
    
    
    From stevesusenet at yahoo.com  Wed Sep 12 09:41:21 2001
    From: stevesusenet at yahoo.com (Steve)
    Date: 12 Sep 2001 06:41:21 -0700
    Subject: What is Python good for?
    Message-ID: <6f8cb8c9.0109120541.132432d4@posting.google.com>
    
    I heard about Python briefly a few years ago when I just got out of
    school and started programming professionally.
    
    Now that I have a good command of some other languages and I see that
    there is a windows port of Python I am thinking about learning it.
    
    Why should I?
    
    By that, I mean most languages try to do it all, but they usually end
    up having unique strengths in some areas that draw users to it.
    
    Java is great for server side programming.  Perl is easy, and has a
    lot of built in features for text processing.  Visual Basic makes
    generating windows client app interfaces very fast.
    
    
    What is Python's major strength?  What benefit will someone have by
    taking the time to learn it?
    
    Where does Python fall short?
    
    Thank in advance.
    
    
    From tim at vegeta.ath.cx  Thu Sep 27 06:19:40 2001
    From: tim at vegeta.ath.cx (Tim Hammerquist)
    Date: Thu, 27 Sep 2001 10:19:40 GMT
    Subject: Does there exist a Python-to-Perl translator ?
    References: <3BB2D226.3C260A2C@Spam.Please>
    Message-ID: 
    
    Me parece que Weet Vanniks  dijo:
    > This would help me produce Perl code after developing it in Python.
    > 
    > Thanks to all for answering.
    > 
    > Weet
    
    Whatever for?  If you have to produce Perl code, why don't you write it?
    Otherwise, what have the thousands of Perl programmers spent months
    learning it for?
    
    (Besides, if no one had to learn Perl, O'Reilly and Associates would
    lose 60% of their sales...) 
    
    OTOH, Perl 6's internals (codename: Parrot, ironically) may be your
    answer.  In theory (and not anywhere near done), Perl and Python would
    both compile to a common bytecode, executable by the same VM.  With that
    in place, some have speculated on the ability to compile Python code to
    Parrot bytecode, then spewing out equivalent Perl code.  See Eric
    Raymond's article here:
    
        http://mail.python.org/pipermail/python-dev/2001-July/016406.html
    
    This may very well be what you're looking for, but don't count on it
    producing optimized code, and especially not pretty code.  Besides, Perl
    6 isn't even due out for another few years, and Perl 6 will have a
    significantly different syntax than Perl 5.
    
    You might just have to learn Perl after all. 
    
    Please, no flames from over-zealous Pythonistas.  Whether I know Perl or
    not, I still spend 70% of my time programming at the '>>>' prompt or
    with '#!/usr/local/bin/python' at the top of the buffer.
    
    'ly 'yrs
    
    Tim
    -- 
    How do I type "for i in *.dvi do xdvi i done" in a GUI?
        -- discussion in comp.os.linux.misc
    
    
    From alf at orion.logilab.fr  Thu Sep 13 02:53:49 2001
    From: alf at orion.logilab.fr (Alexandre Fayolle)
    Date: Thu, 13 Sep 2001 06:53:49 +0000 (UTC)
    Subject: [Poll] Private variables
    References: 
    Message-ID: 
    
    On Wed, 12 Sep 2001 16:13:42 -0400, Tim Peters  wrote:
    >[Alexandre Fayolle]
    >> It is possible in python to get private class members by using names
    >> beginning with 2 underscores, and finished by at least 1 underscore.
    >
    >You don't need an underscore at the end.  A name in a class is private if
    
    Wooops. I, of course, meant 'at most 1 underscore'. 
    
    Alexandre Fayolle
    -- 
    LOGILAB, Paris (France).
    http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org
    Narval, the first software agent available as free software (GPL).
    
    
    From TerryByrne1963 at yahoo.com  Tue Sep  4 10:57:27 2001
    From: TerryByrne1963 at yahoo.com (Terry Byrne)
    Date: 4 Sep 2001 07:57:27 -0700
    Subject: How to get the return status of a command runned by os.popen4
    References: <3B93C945.EB6DF7A8@magic.fr>
    Message-ID: <93d52e82.0109040657.68633c40@posting.google.com>
    
    Alain,
    
    I've had good luck on Windows NT 4 with the following  combination:
    
        cmdPipe = os.popen(aCmdLine)
        resultStream = cmdPipe.read()
    
    At this point you can read resultStream for any stdout feedback
    returned by aCmdLine. Is that what you need?
    
    -Terry
    
    Alain Barthe  wrote in message news:<3B93C945.EB6DF7A8 at magic.fr>...
    > Hi,
    > 
    > I cannot get the return status of a command runned by os.popen4 or
    > popen2.popen4. File closing does not return the status as os.popen does.
    > 
    > I can get it with an object popen2.popen4, but it's not Windows
    > compliant.
    > 
    > Anybody has the solution ?
    > 
    > Thanks.
    
    
    From loewis at informatik.hu-berlin.de  Wed Sep 26 11:28:27 2001
    From: loewis at informatik.hu-berlin.de (Martin von Loewis)
    Date: 26 Sep 2001 17:28:27 +0200
    Subject: what encoding is this?  How can I tell?  How can I translate?
    References:  <87zo7j4fk1.fsf@psyche.dnsalias.org>   <3bb0b75c$0$53006$6e365a64@newsreader02.highway.telekom.at>
    Message-ID: 
    
    "Werner Schiendl"  writes:
    
    > > Regardless, most of the latin-based encodings use the full range of
    > > 256 bytes, yet they all differ from latin-1 (unless they are identical
    > > to latin-1). Therefore, all of them, without exception, have characters
    > > that cannot be transformed to UTF-8.
    > >
    > 
    > I guess this is just a typo, but of course you can transform _any_ known
    > encoding to Unicode (without loss of information).
    
    Indeed; that should be "to latin-1".
    
    Thanks,
    Martin
    
    
    From ws-news at gmx.at  Fri Sep  7 04:59:58 2001
    From: ws-news at gmx.at (Werner Schiendl)
    Date: Fri, 7 Sep 2001 10:59:58 +0200
    Subject: zope installation
    References:  <9ca06fb.0109031830.72f5b863@posting.google.com> <3b949e9f$0$26756$6e365a64@newsreader02.highway.telekom.at> <9ca06fb.0109061345.559f87e2@posting.google.com>
    Message-ID: <3b988d40$0$22352$6e365a64@newsreader02.highway.telekom.at>
    
    Hi,
    
    try to post your problem to the Zope mailing list, if you did not already do
    so.
    If you are new to Zope, you should consider joining this mailing list
    anyway.
    
    see http://www.zope.org/Resources/MailingLists
    
    The generic 'Zope' mailing list should be your best bet, there are lots of
    people on it running Zope on Linux.
    
    Search the archives in advance - the search works very well.
    
    hth
    Werner
    
    "Kahikatea"  wrote in message
    news:9ca06fb.0109061345.559f87e2 at posting.google.com...
    > Digging a little further (/var/log/zope) reveals that it is hiccuping
    > on something to due with syslog. However, not knowing python I have no
    > idea what to do next.....
    >
    > "Werner Schiendl"  wrote in message
    news:<3b949e9f$0$26756$6e365a64 at newsreader02.highway.telekom.at>...
    > > Hi,
    > >
    > > not a Linux expert, but you normally need to configure which port should
    be
    > > used for which protocol and purpose. Further, ports below 1024 are
    > > priviledged under Linux.
    > >
    > > I think it is inetd, which needs be configured. Ask some expert in Linux
    on
    > > how to do it.
    > >
    > > hth
    > > Werner
    > >
    > > "Kahikatea"  wrote in message
    > > news:9ca06fb.0109031830.72f5b863 at posting.google.com...
    > > > Unfortunately this is happening to me too. Help!
    > > >
    > > > LeoDeBeo  wrote in message
    > >  news:...
    > > > > using redhat 7.1, i downloaded and installed the zope and zserver
    > > > > rpm-packages
    > > > > i start zserver by typing: service zope start (sysV-initialization
    > >  script)
    > > > > it says that startup was ok but the server immediately dies
    > > > > in the messages file (/var/log/messages), the following error pops
    up
    > > > >
    > > > > zope: zserver.sh startup succeeded
    > > > > z2[1381]: Startup exception: error: (91, 'Protocol wrong type for
    > >  socket')
    > > > >
    > > > > anyone an idea
    > > > > help much appreciated
    
    
    
    
    From s713221 at student.gu.edu.au  Mon Sep 17 01:31:49 2001
    From: s713221 at student.gu.edu.au (Joal Heagney)
    Date: Mon, 17 Sep 2001 15:31:49 +1000
    Subject: Problems when building PIL
    References: <3BA4D7CE.71F8E72B@olen.to>
    Message-ID: <3BA58AC5.BC027954@student.gu.edu.au>
    
    Joonas Paalasmaa wrote:
    > 
    > I get the following error when trying to build PIL on Linux.
    > Python version is 1.5.1 .
    
    Everything up to here seems fine.
    
    > rdx313 at myra:~/Imaging-1.1.2/libImaging$ make check
    > ./coretest
    > >>> processing lena.ppm...
    > >>> elapsed time: 0
    > >>> as far as we tested, everything seems to be ok...
    > xv test.ppm
    > make: xv: Command not found
    
    This part is just the check, which uses  the non-GPL program xv, which
    may not be available on your machine. Don't worry about it.
    
    > rdx313 at myra:~/Imaging-1.1.2/libImaging$ cd ..
    > rdx313 at myra:~/Imaging-1.1.2$ make -f Makefile.pre.in boot
    > rm -f *.o *~
    > rm -f *.a tags TAGS config.c Makefile.pre python sedscript
    > rm -f *.so *.sl so_locations
    > VERSION=`python -c "import sys; print sys.version[:3]"`; \
    > installdir=`python -c "import sys; print sys.prefix"`; \
    > exec_installdir=`python -c "import sys; print sys.exec_prefix"`; \
    > make -f ./Makefile.pre.in VPATH=. srcdir=. \
    >         VERSION=$VERSION \
    >         installdir=$installdir \
    >         exec_installdir=$exec_installdir \
    >         Makefile
    > make[1]: Entering directory `/home/rdx/web/rdx313/Imaging-1.1.2'
    > make[1]: *** No rule to make target
    > `/usr/lib/python1.5/config/Makefile', needed by `sedscript'.  Stop.
    > make[1]: Leaving directory `/home/rdx/web/rdx313/Imaging-1.1.2'
    > make: *** [boot] Error 2
    > rdx313 at myra:~/Imaging-1.1.2$
    
    Okay. I'm not entirely sure what's happening here. Did you enter the
    make -f bit yourself? Is it something stated to do in the instructions? 
    Oh hold on. Sorted it out. You need to install the python-devel rpm.
    This contains the config/Makefile that python was built with, and which
    is used to configure modules with. It also contains all the python
    headers you'll need.
    Happy pythoneering.
    -- 
          Joal Heagney is: _____           _____
       /\ _     __   __ _    |     | _  ___  |
      /__\|\  ||   ||__ |\  || |___|/_\|___] |
     /    \ \_||__ ||___| \_|! |   |   \   \ !
    
    
    From rwhite at netins.net  Sun Sep 16 11:48:53 2001
    From: rwhite at netins.net (Ron White)
    Date: Sun, 16 Sep 2001 10:48:53 -0500
    Subject: Confused newbie
    References: <9o07ri$9o3$1@ins20.netins.net>
    Message-ID: <9o2iu0$aki$1@ins20.netins.net>
    
    Last night I discovered that the 486 with 16 meg of ram was the problem.  I
    installed Python on a machine with more ram and the program runs just fine.
    Thank you for your help.
    Ron
    
    "Ron White"  wrote in message
    news:9o07ri$9o3$1 at ins20.netins.net...
    > I downloaded Python 2.1.1 (a little over 6 meg) and installed it in a
    win95
    > machine.
    >
    > I am going through Josh Cogliati's Non-Programmers Tutorial for Python and
    > there are several questions I hope I can get answers to.
    > First, is there a document which tells you how to indent the various
    cammand
    > lines?  I have a lot of trouble with that.
    >
    > Secondly, I have typed in a program for printing out a calendar, but when
    I
    > try to run it I get the error that this program has committed a fatal
    error
    > and will be shut down.
    > I thought maybe I didn't have the calendar library, but it appears that I
    do
    > in lib.
    > One thing I've wondered is if I should have installed Python on drive c
    > instead of drive e - maybe the program can't find the lib directory?
    > The program is:
    >
    > import calendar
    > year = input("Type in the year number:")
    > calendar.prcal(year)
    >
    > Any help will be greatly appreciated.
    > Thanks in advance,
    > Ron
    >
    >
    > --
    > Ron White
    > Amateur Radio  WA0MWW
    > "God answers all knee mail"
    >
    >
    
    
    
    
    From sheila at spamcop.net  Sun Sep  2 12:45:36 2001
    From: sheila at spamcop.net (Sheila King)
    Date: Sun, 02 Sep 2001 16:45:36 GMT
    Subject: Help with Unicode? in Tkinter?
    References:  
    Message-ID: <6fn4pts9rnfu4akjqh5lm0e97qjaadg0o4@4ax.com>
    
    On Sun, 2 Sep 2001 15:03:20 +0400 (MSD), Oleg Broytmann 
    wrote in comp.lang.python in article
    :
    
    :On Sat, 1 Sep 2001, Sheila King wrote:
    :SK> >>> print unichr(231)
    :SK> Traceback (most recent call last):
    :SK>   File "", line 1, in ?
    :SK>     print unichr(231)
    :SK> UnicodeError: ASCII encoding error: ordinal not in range(128)
    :
    :   This error indicates that you didn't edit your site.py (or
    :sitecustomize.py) and didn't chnge default "ascii" encoding to the encoding
    :of your terminal/locale.
    
    Are you sure? I tried changing my locale to France, and I still get the
    same errors I was getting when my locale was not France:
    
    
    Python 2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit (Intel)] on win32
    Type "copyright", "credits" or "license" for more information.
    IDLE 0.8 -- press F1 for help
    >>> import locale
    >>> loc = locale.setlocale(locale.LC_ALL)
    >>> locale.setlocale(locale.LC_ALL, 'fr')
    'French_France.1252'
    >>> print u'\xe7'
    Traceback (most recent call last):
      File "", line 1, in ?
        print u'\xe7'
    UnicodeError: ASCII encoding error: ordinal not in range(128)
    >>> print unichr(231)
    Traceback (most recent call last):
      File "", line 1, in ?
        print unichr(231)
    UnicodeError: ASCII encoding error: ordinal not in range(128)
    >>> print chr(231)
    ?
    >>> 
    
    Although, note that printing the ordinal 231 as a chr instead of as a
    unichr works just fine.
    
    Here is an interesting snippet, that I executed immediately following
    the above:
    
    >>> import string
    >>> string.letters
    'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\x83\x8a\x8c\x8e\x9a\x9c\x9e\x9f\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff'
    >>> print string.letters
    ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz??????????????????????????????????????????????????????????????????????
    >>> locale.setlocale(locale.LC_ALL, loc)
    'C'
    >>> string.letters
    'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
    >>> print string.letters
    ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
    >>> 
    
    I guess I have found a way to proceed, thanks to Ignacio's suggestion. I
    wonder if this is the usual way?
    
    --
    Sheila King
    http://www.thinkspot.net/sheila/
    http://www.k12groups.org/
    
    
    
    From fredrik at pythonware.com  Mon Sep 17 13:28:49 2001
    From: fredrik at pythonware.com (Fredrik Lundh)
    Date: Mon, 17 Sep 2001 17:28:49 GMT
    Subject: No spam in books
    References: 
    Message-ID: 
    
    Andrew Nguyen wrote:
    > The O'Reilly books have no mention of spam.
    
    have you read them all?  there were exactly 87 spam references
    in the final draft of my standard library book, and I'm pretty sure
    the copy editor didn't remove all of them...
    
    
    
    
    
    
    From s713221 at student.gu.edu.au  Sun Sep  2 10:09:44 2001
    From: s713221 at student.gu.edu.au (Joal Heagney)
    Date: Mon, 03 Sep 2001 00:09:44 +1000
    Subject: wxpython
    References: <7592d940.0109020157.5e3212e7@posting.google.com>
    Message-ID: <3B923DA8.B50D3288@student.gu.edu.au>
    
    Jock Mackenzie wrote:
    > 
    > I have been learning python/wxpython & have written a small program in
    > wxpython that asks for input from the user  [using the function
    > wxGetNumberFromUser()] then applies a formula and produces a long integer as
    > a result.  I want to display the resulting number from the calculation on
    > the wxFrame or wxPanel or in a dialogbox. I cannot find a function for doing
    > this. Most message boxes only want to return a string not a long integer as
    > I want.
    > How do you do this??
    > thanks in advance
    > regards Jock.
    
    You could pass it a string containing the string representation of the
    integer
    
    First we create a long integer.
    >>> a = 10000000000000000000000000000000000000L
    >>> a
    10000000000000000000000000000000000000L
    
    Then there's the str function
    >>> str(a)
    '10000000000000000000000000000000000000'
    
    Then there's string substitution
    >>> "%s" % a
    '10000000000000000000000000000000000000'
    
    Which finally allows you to construct sentences with dynamically filled
    values.
    >>> "%s is a %s" % (a, type(a))
    "10000000000000000000000000000000000000 is a "
    -- 
          Joal Heagney is: _____           _____
       /\ _     __   __ _    |     | _  ___  |
      /__\|\  ||   ||__ |\  || |___|/_\|___] |
     /    \ \_||__ ||___| \_|! |   |   \   \ !
    
    
    From kirschh at lionbioscience.com  Fri Sep 21 06:28:46 2001
    From: kirschh at lionbioscience.com (Harald Kirsch)
    Date: 21 Sep 2001 12:28:46 +0200
    Subject: How to derive import dependency structure
    Message-ID: 
    
    Let B.py be imported by A.py which generates --- in a very time
    consuming process --- some data structure A.dat.
    
             import         generate
       B.py --------> A.py ----------> A.data
    
    Currently A.dat is only generated if A.py is newer, but this is not
    enough since A.dat must also be generated, if B.py is changed.
    
    A.py and B.py is user written code and B.py represents in fact a more
    complicated import-structure.
    
    I could of course do some 'grep import A.py', but I guess there are
    more pythonic solutions to find the dependency structure?
    
    TIA,
      Harald Kirsch
    
    -- 
    ----------------+------------------------------------------------------
    Harald Kirsch   | kirschh at lionbioscience.com | "How old is the epsilon?"
    LION bioscience | +49 6221 4038 172          |        -- Paul Erd?s
           *** Please do not send me copies of your posts. ***
    
    
    From db3l at fitlinxx.com  Fri Sep 21 17:39:22 2001
    From: db3l at fitlinxx.com (David Bolen)
    Date: 21 Sep 2001 17:39:22 -0400
    Subject: python version
    References: 
    Message-ID: 
    
    "Steven D. Majewski"  writes:
    
    > Of course, if you want to do it from the command line, you can just do:
    > 
    > =09python -V
    
    For those still managing older stuff, note that this is only Python 2.0+
    1.5.2 (not sure about earlier) does have sys.version and sys.hexversion,
    but the tuple sys.version_info also got introduced in 2.0.
    
    (For 2.0, 1.6 may also be valid but I generally ignore that release :-))
    
    --
    -- 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 jhg at acm.org  Sun Sep  2 12:36:48 2001
    From: jhg at acm.org (Jim Garrison)
    Date: Sun, 02 Sep 2001 16:36:48 GMT
    Subject: Changed Zope Site Root -- Site Disappeared!  Pls Help.
    References: 
    Message-ID: <3B92601F.248E4B8A@acm.org>
    
    I did as you said and searched Google Groups for _SUPPRESS_SITEROOT.
    It returned NO hits (except for your message below).  Which other
    archives should I be searching?
    
    Oleg Broytmann wrote:
    > 
    > On Fri, 31 Aug 2001, James Garrison wrote:
    > JG> I accidentally changed the Site Root setting for a Zope folder,
    > JG> and now all attempts to access the folder from the admin interface
    > JG> (i.e. to fix the site root) return "Zope Error - Resource Not Found".
    > JG> The folder still appears in the manage UI, but I can't get to it
    > JG> to fix it.
    > JG>
    > JG> How do I correct this problem?
    > 
    >    This question was answered many times in zope mailing lists. Just search
    > the archive for _SUPPRESS_SITEROOT.
    
    -- 
    Jim Garrison (jhg at acm.org) 
    PGP Keys at http://www.acm.org/~jhg RSA 0x04B73B7F DH 0x70738D88
    
    
    From chrishbarker at home.net  Mon Sep 17 17:56:07 2001
    From: chrishbarker at home.net (Chris Barker)
    Date: Mon, 17 Sep 2001 14:56:07 -0700
    Subject: How to sort a list?  NOT a newbie question.
    References: <9o4i4h$2ql@ascc.artsci.wustl.edu>
    Message-ID: <3BA67177.6F3E807A@home.net>
    
    >In Matlab,
    > complex numbers are sorted based on their magnitudes, and then by phase
    > angle if the magnitudes are the same.  Comparing complex numbers using <,
    > <=, >, and >= always returns false.
    
    Hmm. this isn't a solution that would be easy to use for Python, as
    Python is more general purpose, so the list sort() method has to do the
    same thing as the comparison operators. Also, you can write your own
    sort function, so it would not be hard to deal with complex numbers
    however you wanted.
    
    Note that NumPy sort chokes on complex numbers as well, so I suppose you
    could do something like MATLAB in Numpy.
    
    One possible solution is for list.sort() have a way to deal with
    "non-sortable" objects. I've had this problem when sorting a set of
    two-tuples, when the second item in the tuple was not sortable.
    list.sort() would choke, even though I was happy for it to ignore the
    second item.
    
    hhhmmm...
    
    -Chris
    
    
    
    
    -- 
    Christopher Barker,
    Ph.D.                                                           
    ChrisHBarker at home.net                 ---           ---           ---
    http://members.home.net/barkerlohmann ---@@       -----@@       -----@@
                                       ------@@@     ------@@@     ------@@@
    Oil Spill Modeling                ------   @    ------   @   ------   @
    Water Resources Engineering       -------      ---------     --------    
    Coastal and Fluvial Hydrodynamics --------------------------------------
    ------------------------------------------------------------------------
    
    
    From amylang at zedat.fu-berlin.de  Sat Sep 15 13:18:09 2001
    From: amylang at zedat.fu-berlin.de (amy)
    Date: Sat, 15 Sep 2001 19:18:09 +0200
    Subject: berlin (absolute newbie)
    Message-ID: <9o02gp$9sqr7$1@fu-berlin.de>
    
    hello, i am learning python and have read several documentations.
    in fact, i have so many questions left that would blast the capacity of this
    newsgroup, and i am wondering if there is somebody living in berlin, a bit
    more familiar with python who would care to explain me some things in
    realtime.....?
    would be great, thanx
    amy
    
    
    
    
    From aleax at aleax.it  Wed Sep  5 08:23:08 2001
    From: aleax at aleax.it (Alex Martelli)
    Date: Wed, 5 Sep 2001 14:23:08 +0200
    Subject: Suspected Unicode problem when reading from excell
    References: <3b9612db$0$217$edfadb0f@dspool01.news.tele.dk>
    Message-ID: <9n55fe01nsn@enews1.newsguy.com>
    
    "maxm"  wrote in message
    news:3b9612db$0$217$edfadb0f at dspool01.news.tele.dk...
        ...
    >     print question, options, answerText
    >
    > But when I run it I get the following error:
    >
    > >>>  File "C:\div\uninstalled\python\excell\jensMarius.py", line 9, in ?
    > >>>    print question, options, answerText
    > >>>UnicodeError: ASCII encoding error: ordinal not in range(128)
    >
    > If I replace line 9 with this block, it prints out every question without
    > Danish characters.
    >
    >     try:
    >         print question
    >     except:
    >         pass
    >
    > So my guess is that it's caused by a problem with Danish characters.
    >
    > Has anybody got a possible solution?
    
    sure,
        print question.encode('latin-1')
    should work fine if your terminal is indeed using Latin-1 encoding.
    Similarly, question.encode('mbcs') will work find if your screen
    uses MBCS (MultiByte-Character-Set) encoding on Windows, 'cp437'
    if it uses Codepage-437, and so on, and so forth.
    
    Generally, to display Unicode strings, you must encode them in
    the way that is suitable for your intended display device.  By
    default, Python uses 'ascii' encoding and 'strict' error handling,
    so you'll basically never get anything mis-displayed (well, hardly
    ever -- the 7-bit ascii subset does tend to be OK on most kinds
    of display devices, but even it can't cover ALL:-) and will get
    exceptions you can trap and handle suitably, rather than missing
    characters, question=marks, and so on:-).
    
    If you DO want question-marks for "nonencodable" characters,
    that's easy too:
        print question.encode('ascii','replace')
    (or, use 'ignore' instead of 'replace' to have nonencodable
    characters just omitted).
    
    
    Alex
    
    
    
    
    
    
    From chrishbarker at home.net  Fri Sep  7 18:33:24 2001
    From: chrishbarker at home.net (Chris Barker)
    Date: Fri, 07 Sep 2001 15:33:24 -0700
    Subject: Performance of list comprehensions vs. map
    References: 
    Message-ID: <3B994B34.95755255@home.net>
    
    Tim Peters wrote:
    > > One more question: is it possible for a function to be
    > > mutable??
    > func_code has been writable for some time.  Here under 2.2a3:
    > 
    > >>> def f():
    > ...     pass
    > ...
    > >>> def g():
    > ...     return 666
    > ...
    > >>> f.func_code = g.func_code
    > >>> f()
    > 666
    
    YOW!
    
    this really makes optimizing even harder than I thought, and I always
    thought it was hard.
    
    Thanks, folks, I know I've learned a lot.
    
    -Chris
    
    
    
    -- 
    Christopher Barker,
    Ph.D.                                                           
    ChrisHBarker at home.net                 ---           ---           ---
    http://members.home.net/barkerlohmann ---@@       -----@@       -----@@
                                       ------@@@     ------@@@     ------@@@
    Oil Spill Modeling                ------   @    ------   @   ------   @
    Water Resources Engineering       -------      ---------     --------    
    Coastal and Fluvial Hydrodynamics --------------------------------------
    ------------------------------------------------------------------------
    
    
    From skip at pobox.com  Thu Sep 27 12:12:40 2001
    From: skip at pobox.com (Skip Montanaro)
    Date: Thu, 27 Sep 2001 11:12:40 -0500
    Subject: bsddb3 vs zodb
    In-Reply-To: <20010927020213.A18855@zot.electricrain.com>
    References: <3BA9A72A.1D5A6067@yahoo.com>
            <3BA9EBFD.3F7ABFFA@engcorp.com>
            <9oebkq$8k6$1@slb4.atl.mindspring.net>
            <9opu3g$8cr$1@inputplus.demon.co.uk>
            <20010927020213.A18855@zot.electricrain.com>
    Message-ID: <15283.20472.419234.846833@beluga.mojam.com>
    
        Greg> True.  It's worth noting however that BerkeleyDB 3.3 adds support
        Greg> for automated "secondary indexing" which really gives it a
        Greg> significant chunk of capabilities that people often end up using
        Greg> for full fledged relational databases for. 
    
    Can you explain what "secondary indexing" is?  I was never aware I needed it
    and am using relational databases because of it. ;-)
    
    Thx,
    
    -- 
    Skip Montanaro (skip at pobox.com)
    http://www.mojam.com/
    http://www.musi-cal.com/
    
    
    
    From max at alcyone.com  Thu Sep  6 11:35:24 2001
    From: max at alcyone.com (Erik Max Francis)
    Date: Thu, 06 Sep 2001 08:35:24 -0700
    Subject: dictionary and __getattr__
    References: 
    Message-ID: <3B9797BC.3D667896@alcyone.com>
    
    Harald Kirsch wrote:
    
    > Wouldn't it be nice if this would work:
    > 
    >   d = {'x': 1}
    >   print d.x
    > 
    > i.e. every entry in a dictionary is also an attribute of the
    > dictionary itself.
    
    Why would it?
    
    Furthermore, what do you do in the not so obvious cases?  What happens
    if your key is a number?  Or contains spaces?  Or worse yet, is a 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
    /  \ In principle I am against principles.
    \__/ Tristan Tzara
        Kepler's laws / http://www.alcyone.com/max/physics/kepler/
     A proof of Kepler's laws.
    
    
    From markus at schabi.de  Mon Sep  3 13:34:55 2001
    From: markus at schabi.de (Markus Schaber)
    Date: Mon, 3 Sep 2001 19:34:55 +0200
    Subject: 3-arg float pow()
    References:  <3b938b3c.1110872@nntp.sprynet.com>
    Message-ID: <2078976.8kZL3ZeAuk@lunix.schabi.de>
    
    Hi,
    
    David C. Ullrich  schrub:
    
    > Seems like pow(3., 500., 7.) can't possibly do anything except just
    > 3.**500. % 7(???), hence the random nature of the result and the utter
    > uselessness. 
    
    The trick is that it is a exponential function with large result modulo 
    a small number. (such operations are e. G. used in the RSA crypto 
    algorithm)
    
    When calculating the exponential function using software emulation (as 
    I know of no decent hardware support for long Integers), you have more 
    or less a loop of multiplications or so (depending how optimized your 
    algorithm is).
    
    One optimized algorithm is to split the 500 into powers of two, so 
    3**500 gets to 3**(256 + 128 + 64 + 32 + 16 + 4) == (3**256) * (3**128) 
    * (3**64) * (3**32) * (3**16) * (3**4). As you see, you can generate 
    the bracketed values by repeatedly multiplying the number with itsself 
    (which is rather fast) and then multiplying all those values. In a 
    computer, you can quite optimize this, as the 500 is already given in 
    binary. Thus one can iterate like the following:
    
    def simple(base, exp, modulo):
      res = 1L
      while exp != 0L:
          if exp & 1L:
              res *= base
          exp >>=1L
          base *= base
      return res%modulo
    
    This gives 9 rounds with two comparisons, one shift and maximum two 
    multiplications per loop, thus a maximum of 45 operations compared to 
    500 when using simple plain loop.
    
    The problem is when the intermetiate number gets rather large (which is 
    the case here, we get 3**500 == 
    36360291795869936842385267079543319118023385026001623040346035832580600191583895484198508262979388783308179702534403855752855931517013066142992430916562025780021771247847643450125342836565813209972590371590152578728008385990139795377610001). 
    Using dynamically sized numbers (as our long integers are), this can 
    get rather big (and thus memory- and cpu-intensive) compared to the 
    final result 2.
    
    But as we calculate modulo 7, we can apply the modulo after every 
    single step of shifting, and so keep the numbers small (which 
    is much faster given some numbers, and uses much less memory)
    
    def optimized(base, exp, modulo):
      res = 1L
      while exp != 0L:
          if exp & 1L:
              res *= base
              res %= modulo
          exp >>=1L
          base *= base
          base %= modulo
      return res
    
    Especially when calculating lots of numbers (such as applying this to a 
    list or matrix), this can save some megabyte intermediate storage.
    
    A test like 
    
    start = time.clock()
    for i in xrange(1000):
      void = simple(3L,5000L,7L)
    stend = time.clock()
    print 'simple:',round(stend-start,2)
    
    gives 7.28 seconds for the simple and 0.24 seconds for the 
    modulo-optimized version on my machine.
    
    On the other side this doesn't apply when using small integers (as they 
    don't expand in size), and doesn't gain much when the exponental result 
    and the modulo factor are about the same size. E. G. using 50 as exp in 
    the example above gives 0.09 seconds in the simple and 0.13 seconds in 
    the optimized version due to the additional modulo operations. 
    
    Additionally, the second algorithm can be rewritten to calculate the 
    result using ordinary integers (simply remove all the "L"s in the def 
    and at the call), and this way only needs 0.05 seconds, whereas the 
    first algorithm gives an OverflowError. A math library coder could use 
    some heuristics to dynamically decide which algorithm to use.
    
    I ran an additional test, calculating pow(3,5000000,7), and the 
    unoptimized version (all Longs) needs about 50 seconds for _one_ loop, 
    whereas the optimized version needs for _1000_ loops 0.35 seconds using 
    longs, and 0.13 seconds using integers. Btw, the builtin pow function 
    needs 0.15 and 0.01 seconds
    
    But I don't know whether this trick is usable in floating point, as 
    most floating point is done in hardware nowadays. I can imagine that 
    some FPU have machine commands to gain additional speed and maybe 
    exactness this way.
    
    Another point may be that when processing arrays or matrices, a 
    sophisticated programmer may use MMX, 3DNow!, ISSE or AltiVec to gain 
    speed by processing something in parallel, but I'm afraid this would be 
    not so easy to incorporate in python, because there numbers are stored 
    as references to objects.
    
    PS: I'm away for a week from tomorrow on, so please be patient with my 
    answers to your comments / questions.
    
    markus
    -- 
    "The strength of the Constitution lies entirely in the determination of 
    each citizen to defend it. Only if every single citizen feels duty 
    bound to do his share in this defense are the constitutional rights 
    secure." -- Albert Einstein
    
    
    From news at davidglasser.net  Wed Sep 26 18:00:39 2001
    From: news at davidglasser.net (David Glasser)
    Date: Wed, 26 Sep 2001 18:00:39 -0400
    Subject: Sort documentation inaccurate?
    References: <3BB16F36.A7BAE259@cygnus-software.com>
    Message-ID: <1f0csar.16wevqq1sza16oN%news@davidglasser.net>
    
    Bruce Dawson  wrote:
    
    > >>> mylist = [1, 2, 3, 5, 4, 6]
    > >>> def compare1(x, y):
    > ...  return x < y
    > ...
    > >>> mylist.sort(compare1)
    > >>> mylist
    > [1, 2, 3, 5, 4, 6]
    
    The comparison "x < y" can return two values: 1 if x < y, and 0 if
    x >= y.  But a sort function really needs to be more specific,
    differentiating between x < y, x > y, and x == y.  The standard for sort
    functions, based on C's strcmp, is to return:
    
       -1 if x < y
       0  if x == y
       +1  if x > y
    
    (It appears that any negative value is as good as -1, and any positive
    for +1, but the documentation just say those specific values.)  This is,
    as you said, so a function can do something along the lines of "return x
    - y".
    
    The really good news, though, is that you can ignore most of this by
    using Python's cmp function.  For example, to sort by absolute value:
    
    >>> x = [1, 0, -2, 52, -32, 4]
    >>> def abssort(x, y):
    ...    return cmp(abs(x), abs(y))
    ... 
    >>> x.sort(abssort)
    >>> x
    [0, 1, -2, 4, -32, 52]
    
    
    -- 
    David Glasser
    news at davidglasser.net               http://www.davidglasser.net/
    
    
    From martin.franklin at westgeo.com  Wed Sep  5 12:08:11 2001
    From: martin.franklin at westgeo.com (Martin Franklin)
    Date: Wed, 5 Sep 2001 17:08:11 +0100
    Subject: Widget tooltips
    References: 
    Message-ID: <9n5ihb$1ikk$1@mail1.wg.waii.com>
    
    Jo?o Alfredo wrote:
    
    > Hi all,
    > 
    > Does Tkinter supports widget tooltips?? If yes, how??
    
    
    The Pmw extensions do have balloon help....  check the vaults
    
    
    
    
    > 
    > Thanks in advance.
    > 
    > []'s
    > Jo?o Alfredo
    > 
    > 
    > 
    > 
    > _________________________________________________________
    > Do You Yahoo!?
    > Get your free @yahoo.com address at http://mail.yahoo.com
    > 
    > 
    > 
    
    
    
    From mmhamze at pleiades.net  Wed Sep  5 09:48:57 2001
    From: mmhamze at pleiades.net (Maan M. Hamze)
    Date: Wed, 5 Sep 2001 08:48:57 -0500
    Subject: Selecting varray using python
    References: 
    Message-ID: 
    
    Amin
    You lost me here.  Are you sure that DCOracle works with Oracle 8i?  I know
    that DCOracle2 does.
    Maan
    
    "Amin Abdulghani"  wrote in message
    news:f5b09a2f.0109041358.20f1290d at posting.google.com...
    > Hi,
    >
    > I have recently installed DCOracle 1.3.2 to interface Oracle 8i
    > with python. The problem I seem to be facing is trying to access
    > a varray column using the interface. Does anyone have anyone
    
    
    
    
    
    From greg at cosc.canterbury.ac.nz  Thu Sep 13 18:59:57 2001
    From: greg at cosc.canterbury.ac.nz (Greg Ewing)
    Date: Fri, 14 Sep 2001 10:59:57 +1200
    Subject: Proposed PEP for a Conditional Expression
    References:  <6qvgire4bk.fsf@abnoba.intevation.de> <9nk3jd$4lc$1@glue.ucr.edu> <9nnsa3$bjl$1@news.mathworks.com>  <3BA00239.DECE6412@cosc.canterbury.ac.nz>  <5xXn7.2447$w62.1612177@news1.denver1.co.home.com> 
    Message-ID: <3BA13A6D.BA6E1922@cosc.canterbury.ac.nz>
    
    Ken Seehof wrote:
    > 
    > Also, I would propose that ... else None should be implicit.
    >    >>> print 'eeek' if pi == 3
    >    None
    > 
    > But ... people could easily be confused and misinterpret the syntax as:
    >     if  [ else  ]
    
    That's a good argument for making the else mandatory.
    It's less easy to misinterpret
    
       print 'eeek' if pi == 3 else None
    
    It would be even clearer if parentheses were required:
    
       print ('eeek' if pi == 3 else None)
    
    So I suggest that parentheses always be required around
    if..else expressions. That would clear up any potential
    confusion in list comprehensions, and anywhere else that
    it might occur.
    
    -- 
    Greg Ewing, Computer Science Dept, University of Canterbury,	  
    Christchurch, New Zealand
    To get my email address, please visit my web page:	  
    http://www.cosc.canterbury.ac.nz/~greg
    
    
    From adina_levin at mindspring.com  Sun Sep 30 14:21:57 2001
    From: adina_levin at mindspring.com (adina_levin at mindspring.com)
    Date: Sun, 30 Sep 2001 13:21:57 -0500
    Subject: newbie question: help with polymorphism and/or programming style
    Message-ID: <9p7o8l$4q5$1@slb2.atl.mindspring.net>
    
    Hello, Pythonites.
    
    I am teaching myself python programming, and have created a toy storefront
    program.
    
    If the customer wants to pay with cash, the program should return change. If
    the customer wants to pay using a credit card, the program should validate
    the customer's ability to pay, and return an approval.
    
    Several questions regarding programming style:
    
    a) Is it desirable to replace the "if" statement in paymenthandler with
    subclasses, PayCash(Payment) and PayCredit(Payment).  If so, doesn't that
    just push the "if" statement upstream, where you PayCash() if the customer
    says she wants to pay cash?  I am clearly missing something!! :-(
    
    b) Is it bad style to return different kinds of information, depending on
    whether the customer pays with cash or credit? If so, how should this be
    handled cleanly?
    
    c) Any other programming style problems?
    
    This is a toy, so no reason to comment on lack of full detail in the
    simulation.
    
    class Payment:
        def __init__(self):
            self.payobject=Customer().getpaymentinput()
    
        def payhandler(self,sum):
            self.sum=sum
            if self.payobject.paytype == "cash":
                result=self.payobject.cashamount-self.sum
                print result
    
            elif self.payobject.paytype == "credit":
                self.crednum=self.payobject.crednum
                result=Creditcheck().creditapprove(self)
    
            return result
    
    
    
    
    
    
    From jkraska at san.rr.com  Sun Sep  2 14:25:36 2001
    From: jkraska at san.rr.com (Courageous)
    Date: Sun, 02 Sep 2001 18:25:36 GMT
    Subject: Stackless Python and Python 2.x
    References:  
    Message-ID: 
    
    >The advantages over real threads are enormous:
    > - lightweight
    
    This can be a real issue if you begin running enough
    threads where context-switching speed begins to matter.
    
    > - system level locks never needed
    > - user level locks rarely needed
    >
    >The only downside is relatively minor - I have to make
    >sure that one "thread" doesn't monopolize the CPU.
    
    One alternative is to use one or more real threads to
    manage your continuation-threads. As your executive
    thread is preemptively threaded, it can possibly
    terminate unresponsive c-threads.
    
    C//
    
    
    
    From db3l at fitlinxx.com  Fri Sep 28 20:28:12 2001
    From: db3l at fitlinxx.com (David Bolen)
    Date: 28 Sep 2001 20:28:12 -0400
    Subject: stdin broken on Win2K?
    References: <43u9rtsgorpj5fh4r07hkoakkh9bkh2u22@4ax.com>
    Message-ID: 
    
    Dale Strickland-Clark  writes:
    
    > This:
    > 
    > # stdintest.py
    > # Copy stdin to stdout
    > 
    > import sys
    > l = sys.stdin.readline()
    > while l:
    > 	print l,
    > 	l = sys.stdin.readline()
    > 
    > 
    > doesn' work from the Win2K command prompt in either of the following
    > cases:
    > 
    > stdintest  type source.txt | stdintest
    > 
    > However, if you don't redirect stdin, it will happily reflect console
    > input to the console.
    
    At least NT has a bug in CMD.EXE when using automatic execution of
    Python scripts via the PATHEXT variable and command line redirection.
    Perhaps it's still present in Win2K's CMD.EXE.
    
    What happens if you use "python stdintest.py" rather than just
    "stdintest" in your command?
    
    --
    -- 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 hnowak at cuci.nl  Mon Sep  3 04:27:03 2001
    From: hnowak at cuci.nl (Hans Nowak)
    Date: Mon, 3 Sep 2001 10:27:03 +0200
    Subject: Can I build a dictonary with a list-comprehension?
    Message-ID: <3B95A738@twigger.nl>
    
    >===== Original Message From "Marcin 'Qrczak' Kowalczyk"  
    =====
    >Fri, 31 Aug 2001 15:48:05 +0200, spex66  pisze:
    >
    >> dict = {}
    >> LIST = [...] #What you want
    >> [dict.update({x: 'spam'}) for x in LIST]
    >
    >Using list comprehensions when the result is ignored is misleading
    >and inefficient. A for loop is better.
    >
    >When there is only a single value, insted of update it's simpler to
    >use __setitem__.
    >
    >In general, where items come in (key,value) pairs, dictionary can be
    >built like this:
    >
    >dict = {}
    >LIST = [...]
    >for k, v in LIST:
    >    dict[k] = v
    >
    >and there is no simple builtin list-comprehension-like syntax in the
    >form of an expression (but you can write a function to convert a list
    >to a dictionary).
    
    Un an entirely unrelated note, maybe there should be dictionary 
    comprehensions, too... :)
    
    { k,v for k,v in dict if type(v) == type("") }
    
    
    
    --Hans Nowak
    
    
    
    
    From digitig at cix.co.uk  Sun Sep  9 13:48:00 2001
    From: digitig at cix.co.uk (Tim Rowe)
    Date: Sun, 9 Sep 2001 18:48 +0100 (BST)
    Subject: constant in python?
    References: <7xsneoijz7.fsf@ruckus.brouhaha.com>
    Message-ID: 
    
    In article <7xsneoijz7.fsf at ruckus.brouhaha.com>, phr-n2001 at nightsong.com 
    (Paul Rubin) wrote:
    
    > "Alex Martelli"  writes:
    > > > problem with enforcing privacy is that the designer can seldom
    > > > anticipate all of the possible uses of their code and placing 
    > > > arbitrary
    > > > access restriction can make it impossible for the user to accomplish
    > > > their task.
    > > 
    > > Hear, hear!  Designers aren't omniscient and a language that lets
    > > me workaround a limitation in the design of a framework or library
    > > I need to use is just what I need.
    > 
    > The trouble is, the very existence of a workaround is sometimes itself
    > a limitation, e.g. in implementing an applet sandbox.
    > 
    > > > Python is a general purpose programming language and its design 
    > > > should
    > > > not be significantly compromised to make a particular (uncommon) 
    > > > usage
    > > > more convenient i.e. security environments.
    > > 
    > > Yep.  Besides, rexec and Bastion (could use some spiffying up,
    > > but) are pretty good for this.
    > 
    > I'll check into those.  However, a true general purpose language
    > should be useable in all environments.  
    
    I don't much believe in general purpose languages. The trouble is, a 
    language that can do everything won't be very good at anything. Be aware 
    of the strengths and weaknesses of different languages, have more than one 
    string to your bow, and know how to choose which one to use. I doubt if 
    Python could ever be the language of choice for real-time operating system 
    design, embedded control or safety critical for instance, and should 
    resist adding complication in an attempt to move into those fields. IMHO 
    Python development should play to its strengths and not try to turn it 
    simultaneously into Haskell, Ada, Forth, C++ and Smalltalk!
    
    
    From qrczak at knm.org.pl  Tue Sep  4 08:05:37 2001
    From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk)
    Date: 4 Sep 2001 12:05:37 GMT
    Subject: Is 0 > None?? (fwd) (fwd)
    References:  
    Message-ID: 
    
    Tue, 4 Sep 2001 10:01:02 +0200, Alex Martelli  pisze:
    
    > Comparison issues, and sorting of heterogeneous lists in
    > particular, ARE central to the new noncomparable behavior
    > of complex numbers.  I see no solution to THAT one, save:
    >     a. either drop the pretense that it makes sense to
    >         compare heterogeneous entities, or
    >     b. regress the change that makes it illegal to compare
    >         complex numbers.
    
    c. Have two kinds of comparison, homogeneous and heterogeneous.
    This solves the complex numbers problem, but unfortunately not the
    str <-> unicode problem.
    
    The real problem is that if Unicode strings and byte strings are
    treated like alternative representation of the same data (as numeric
    types are), i.e. they compare equal if they represent the same text,
    then there are two incompatible orders involved: lexicographically by
    Unicode character values and byte values. It would break transitiveness
    of comparisons.
    
    Actually it does break it if something othar than ASCII or Latin1 is
    chosen as the default encoding!
    
        '?' > '?'
        '?'.decode('iso-8859-2') < u'\u00D1' < '?'.decode('iso-8859-2')
        '?' < u'\u00D1' < '?'   # when 'iso-8859-2' is the default
    
    Since byte strings and Unicode strings can't be reliably compared
    anyway, a solution would be to drop their equivalence, treat as
    separate types, let 'A' != u'A', require explicit coercions in either
    direction for homogeneous comparisons.
    
    Alternatively comparison could consistently use the Unicode ordering -
    but it's unworkable in practice, even with a sane default (not ASCII).
    Byte strings are supposed to be able to represent binary data as well,
    and it's inefficient.
    
    -- 
     __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
     \__/
      ^^                      SYGNATURA ZAST?PCZA
    QRCZAK
    
    
    From News at eduplay.intensive.co.no.muppets.uk  Fri Sep 28 14:36:18 2001
    From: News at eduplay.intensive.co.no.muppets.uk (Ben Ainsworth)
    Date: Fri, 28 Sep 2001 19:36:18 +0100
    Subject: RM Connect and Python
    Message-ID: <3bb4c322$1_1@lon-news.intensive.net>
    
    I'm trying to persuade the school I teach at to place Python on the network
    as I'd like a real programming language for my teaching. However the IT
    staff tell me they have problems with many programs and the RM Connect
    software they use for security. Does anyone have experience of installing
    Python on a network that uses RM Connect?
    
    
    
    
    From flognat at flognat.myip.org  Sat Sep 15 15:30:17 2001
    From: flognat at flognat.myip.org (Andrew Markebo)
    Date: Sat, 15 Sep 2001 19:30:17 GMT
    Subject: Why Tcl/Tk
    References: <3ba27ba1_8@news.newsgroups.com>
    Message-ID: 
    
    I have seen a couple of answers to this question and I would like to
    throw in an answer.. 
    
    Basically Python and Tkinter existed before you could even think of it
    on windows! What happened was that someone who needed good GUI-stuff
    did Tkinter.. And it went into python..  
    
    Later on python started to be able to compile on dos/windows, but no
    tcl/tk.. 
    
    Later on tcl/tk was ported to windows, and wee it was no big problem
    getting Tkinter to work.. And it is now in everybodys (well
    almost.. ok.. my) spine.. 
    
    Meanwhile regarding GTK+ and so on, it is simple to get it into python
    I think... just get a couple together and do a good job and it might
    slip into the dist and get used.. 
    
            /Andy
    
    
    / "Janos Blazi"  wrote:
    | My question has probably been discussed for ages. Why uses Python Tcl/Tk as
    | de facto GUI toolkit?
    | I think that both GTK+ and Qt are generally considered more powerful than
    | Tcl/Tk and I was very much surprised that in fact bindings for both
    | libraries exist for Python.
    
    -- 
     The eye of the beholder rests on the beauty!
    
    
    From dale at riverhall.NOSPAMco.uk  Thu Sep 27 11:00:14 2001
    From: dale at riverhall.NOSPAMco.uk (Dale Strickland-Clark)
    Date: Thu, 27 Sep 2001 16:00:14 +0100
    Subject: Class mutation
    References: <8626rt838oe59d1njrtrisccm0oe02shvf@4ax.com> <9ov336$fpp6v$1@ID-59885.news.dfncis.de>  <1015343.vhalqRGMn8@lunix.schabi.de>
    Message-ID: 
    
    >But it exactly does what you want. It assigns the new class to your job 
    >object.
    >
    It does indeed do exactly what I want but if there is a chance of the
    feature being removed, it's a bit of a risk using it.
    
    Thanks for your help, however, we've gone for a state attribute
    instead. Tthe Job class will contain all the methods needed in the
    active state as well.
    
    
    --
    Dale Strickland-Clark
    Riverhall Systems Ltd
    
    
    From logiplexsoftware at earthlink.net  Wed Sep 12 18:52:41 2001
    From: logiplexsoftware at earthlink.net (Cliff Wells)
    Date: Wed, 12 Sep 2001 15:52:41 -0700
    Subject: Parrot for real?
    In-Reply-To: <9nonos$4ms@gap.cco.caltech.edu>
    References: <3B9F8AD0.94C81526@lindbergs.org>  <9nonos$4ms@gap.cco.caltech.edu>
    Message-ID: <01091215524105.01493@logiplex1.logiplex.net>
    
    On Wednesday 12 September 2001 15:25, Nathaniel Gray wrote:
    
    > http://mail.python.org/pipermail/python-dev/2001-July/016406.html
    
    !!!!!
    
    -- 
    Cliff Wells
    Software Engineer
    Logiplex Corporation (www.logiplex.net)
    (503) 978-6726 x308
    (800) 735-0555 x308
    
    
    
    From phr-n2001 at nightsong.com  Tue Sep 25 14:26:37 2001
    From: phr-n2001 at nightsong.com (Paul Rubin)
    Date: 25 Sep 2001 11:26:37 -0700
    Subject: Proposal: add vector arithmetic to array module
    References: 
    Message-ID: <7xy9n3w2hu.fsf@ruckus.brouhaha.com>
    
    "Mike C. Fletcher"  writes:
    > Numeric is becoming a very widely used module, so if there is something
    > going into the core, it would be my vote.  However, I'd still like to see a
    > better mechanism for distributing extensions (e.g. auto-downloading signed
    > packages from a Zope server somewhere) so that the list of "included"
    > modules can _shrink_, rather than grow.
    > 
    > But then everyone wants that,
    
    I certainly don't want any automated software downloads happening
    without my permission, signed code or not.  Also, just because code is
    signed doesn't mean I trust whoever signed it.  I'm generally willing
    to trust the maintainers of highly visible systems (e.g. the main
    Python distribution) if I'm getting the source code.  But if it's
    something infrequently used from a random developer who I don't know,
    I'll usually inspect the source code before compiling it, which takes
    quite a bit of time.  I do *not* want dozens of packages signed by
    unknown random distributors installed on my machine automatically.
    
    
    From ungrzr2 at ubatxbat.pbz  Thu Sep 20 03:50:47 2001
    From: ungrzr2 at ubatxbat.pbz ({-- Rot13 - Hateme)
    Date: 20 Sep 2001 07:50:47 GMT
    Subject: simple example of mimelib?  and embedding (not attaching) images in email sent with python.
    References: <97ae44ee.0108140526.63a22745@posting.google.com>   
    Message-ID: 
    
    Speaking of email, has anyone done a module for
    threading emails according to the message-id and
    subject? something as described in 
    http://www.jwz.org/doc/threading.html
    
    
    From sarcangeli at montrouge.sema.slb.com  Mon Sep 17 05:38:01 2001
    From: sarcangeli at montrouge.sema.slb.com (Silvio Arcangeli)
    Date: Mon, 17 Sep 2001 10:38:01 +0100
    Subject: optional arguments
    Message-ID: <4.3.2.7.2.20010917103131.00b0d8b0@popper.montrouge.tt.slb.com>
    
    Hello everybody,
    sorry for this question that may seem silly.
    I have an object whose __init__  looks like the following:
    
    class Connection:
    	def __init__(self, ip=def_ip, port=def_port)
    		...
    
    I have to call two different functions when the object is instantied like
    c=Connection()
    and when it is instantiated like
    c=Connection(def_ip, def_port)
    
    how can I tell wheter no arguments were passed from the user or whether 
    they were passed but they were just like the default values?
    
    Silvio.
    
    
    
    
    From tim.one at home.com  Wed Sep 26 00:55:38 2001
    From: tim.one at home.com (Tim Peters)
    Date: Wed, 26 Sep 2001 00:55:38 -0400
    Subject: Proposal: add vector arithmetic to array module
    In-Reply-To: <7x4rprs2cl.fsf@ruckus.brouhaha.com>
    Message-ID: 
    
    [Tim]
    > Use NumPy -- can't be suppressed .  Why do you think
    > NumPy is a big package?  Doing this right is neither simple nor lean,
    > and as soon as one array op is added, the rest are inevitable.
    
    [Paul Rubin]
    > Huh?  Adding pointwise addition means you have to add eigenvalues?
    
    I hope you didn't believe that merits a response <0.5 wink>.
    
    > The reason I don't want to use NumPy is that it isn't included in
    > standard Python distributions.  It's yet another thing for the user
    > to download, and it's maintained and distributed by a separate group
    > of people than the Python maintainers.  All in all, it's harder to
    > deal with and there's more ways to go wrong.
    
    That's all true of every module that's not in the core distribution.  If the
    NumPy maintainers really wanted it in the core, I bet they could prevail --
    but I doubt the current crop of core Python maintainers has the bandwidth to
    take this over from them (the PythonLabs crew does not), let alone to
    reinvent it.  So "really want" includes volunteering ongoing work too.
    
    > If NumPy became part of standard Python, then I'd happily use it.
    
    Same here.
    
    heck-i'd-use-perl-again-if-it-were-part-of-core-python-ly y'rs
        - tim
    
    
    
    
    From ignacio at openservices.net  Tue Sep 18 04:49:30 2001
    From: ignacio at openservices.net (Ignacio Vazquez-Abrams)
    Date: Tue, 18 Sep 2001 04:49:30 -0400 (EDT)
    Subject: re source code
    In-Reply-To: <025501c1401e$b13854a0$a500a8c0@moonqzie>
    Message-ID: 
    
    On Tue, 18 Sep 2001, Carlos Gaston Alvarez wrote:
    
    > I want to read re source code.
    > I want to know why it is more tolerant to .* than to .*?  and so on. The
    > final documentation is the source. I want that.
    
    Feel free to download the source tarball and extract the files from that.
    
    -- 
    Ignacio Vazquez-Abrams  
    
    
    
    
    From jjl at pobox.com  Sun Sep 16 15:08:32 2001
    From: jjl at pobox.com (John J. Lee)
    Date: Sun, 16 Sep 2001 20:08:32 +0100
    Subject: Python as ActiveScripting language for IE
    In-Reply-To: <3ba449d1.4461765@news.t-online.de>
    References: <3ba449d1.4461765@news.t-online.de>
    Message-ID: 
    
    On Sun, 16 Sep 2001, Gerson Kurz wrote:
    
    > I'm using Python as client-side scripting language in IE. It works
    > really great! But, when I do this
    [...]
    > it seems that the Python runtime gets unloaded between the first two
    > steps, only to be loaded back again later. The problem is that loading
    [...]
    
    There must (?) a good solution to this, but I don't know it.
    
    I presume Java doesn't do this?  If so, since you'll have to install
    Python on the clients anyway, you may as well install Java as well, and
    run Jython instead, if that works around the problem.  When you figure
    out how to get CPython to stick around, it should be easy to move back
    again.
    
    You may even be able to avoid any need to manually install things on the
    client side, if the version of Java installed is good enough to let
    Jython work.
    
    
    John
    
    
    
    From uselesspython at yahoo.com  Mon Sep  3 20:11:20 2001
    From: uselesspython at yahoo.com (Rob)
    Date: Tue, 04 Sep 2001 00:11:20 GMT
    Subject: Small program trouble WAS Re: Small proram troble
    References: 
    Message-ID: <3B941BF2.4020006@yahoo.com>
    
    Ignacio Vazquez-Abrams wrote:
    
    > On 3 Sep 2001, Patio87 wrote:
    > 
    > 
    >>I have a problem with this simple program but im very new to python and this is
    >>the biggest program i have written. Now I think the problem is the while loop
    >>but im not sure if someone could take a look at this it would be apprecitaed
    >>
    > 
    > Yikes. Here's my fixed version:
    > 
    > ---
    
    
    And here's my fixed version of the fixed version:
    
    import sys
    
    choice = 0
    
    def print_options():
        print "Options:"
        print "'1' Print Options"
        print "'2' Add numbers"
        print "'3' Subtract numbers"
        print "'4' Multiply number"
        print "'5' Divide number"
        print "'6' Exit"
    
    print_options()
    
    while choice != 6:
        choice = raw_input("What would thou like to do?")
        if choice == "1":
            print_options()
        elif choice == "2":
            add = input("What number would you like to add?")
            add2 = input("What other number do you want to add?")
            print "The awnser is", add + add2
        elif choice == "3":
            sub = input("What number do you want to subtract?")
            sub2 = input("What 2nd number do you want to subtract?")
            print "Your awnser is,", sub + sub2
        elif choice == "4":
            mul = input("What number do you want to multiply")
            mul2 = input("What 2nd number do you want to multiply")
            print "Your multiplicated number is", mul * mul2
        elif choice == "5":
            div = input("What is your dividend?")
            div2 = input("What is your numerator?")
            print "Your awnser is", div/div2
        elif choice == "6":
            print "thanks for using my program"
            sys.exit()
    
    
    ooh-this-is-fun-ly,
    Rob
    -- 
    A {} is a terrible thing to waste.
    Useless Python!
    http://www.lowerstandard.com/python
    
    
    
    From sholden at holdenweb.com  Mon Sep 10 19:50:05 2001
    From: sholden at holdenweb.com (Steve Holden)
    Date: Mon, 10 Sep 2001 19:50:05 -0400
    Subject: [OT] Strange IE5.5 Caching Behavior
    Message-ID: 
    
    Sorry about this post being off-topic, but c.l.py is the largest collection
    of web-heads I have easy access to. If you know nothing about HTTP, please
    ignore this.
    
    I'm serving static content, looking at the client's "If-Modified-Since"
    header, and returning a 304 response if the file's Last-Modified date is
    before that. When I serve the content I include a "Last-Modified:" header to
    identify the age of the file.
    
    For some reason the incoming "If-Modified-Since" headers *always* seem to be
    three minutes and 27 seconds before the "Last-Modified:" date of the file.
    I've searched Google, and Microsoft's Knowledge Base, without finding
    anything relevant.
    
    If anyone knows what's causing this (and even better, how to fix it) I'd be
    very grateful for a pointer.
    
    regards
     Steve
    --
    http://www.holdenweb.com/
    
    
    
    
    
    
    From markus at schabi.de  Wed Sep 19 14:13:06 2001
    From: markus at schabi.de (Markus Schaber)
    Date: Wed, 19 Sep 2001 20:13:06 +0200
    Subject: Direct TK interface
    References: <2764949.5mLc6kNg2l@lunix.schabi.de> <23891c90.0109190625.1a15d464@posting.google.com>
    Message-ID: <1442950.reEdlvqk35@lunix.schabi.de>
    
    Paul Boddie  schrub:
    
    > Markus Schaber  wrote in message
    > news:<2764949.5mLc6kNg2l at lunix.schabi.de>...
    >> Hi,
    >> 
    >> I was just wondering whether it is possible (and worth in sense of
    >> speed etc.) to directly interface TK into python (without using the
    >> TCL interpreter inbetween).
    > 
    > What about "Tkinter 3000" from Pythonware (http://www.pythonware.com)?
    > Isn't this supposed to have similar goals, or is the idea to have the
    > same API but to use a different implementation technology?
    
    I read the page, and it sounded promising (although the documentation 
    doesn't really go into technical details).
    
    My two motivations were efficiency and possible elimination of the 
    (IMHO) ugly and not python-like Tkinter.StringVar() construct (which is 
    not necessary in TCL/TK because of the direct integration, and might 
    perhaps be implemented using the new get/set attributes.)
    
    markus
    -- 
    "The strength of the Constitution lies entirely in the determination of 
    each citizen to defend it. Only if every single citizen feels duty 
    bound to do his share in this defense are the constitutional rights 
    secure." -- Albert Einstein
    
    
    From aleax at aleax.it  Wed Sep 12 08:04:26 2001
    From: aleax at aleax.it (Alex Martelli)
    Date: Wed, 12 Sep 2001 14:04:26 +0200
    Subject: python equivalent of wantarray() : newbie
    References: 
    Message-ID: <9nnj0a02gs5@enews1.newsguy.com>
    
    "Karthik Gurumurthy"  wrote in message
    news:mailman.1000286203.3187.python-list at python.org...
    >
    > please bear with me, am still learning.
    >
    > is there a way to determine whether a return value is expected from a
    > method?
    > like the way wantarray() works in perl.
    
    No, because Python accepts just about anything the method
    wants to return.  Perl is very context-driven, Python is
    not: whatever object the method wants to return, including
    None, will typically do, since all objects are first-class.
    
    It's possible that _operations_ *later* applied on the
    returned value may imply certain "desires" regarding said
    value, but that doesn't really change the context-free
    operation of Python.
    
    
    > perl can determine the type of the variable used
    >
    > @array = call()//so it's list context so call can return a list
    > $var = call()//scalar context so call can return say a string.
    >
    > But can python determine the same?? i guess it can't and that's why we
    don't
    > have a wantarray() equivalent in python??
    
    Right.  Even if you could magically determined that an indexing
    call()[something] was later to be applied, this STILL wouldn't
    tell you whether one 'wants' a list or a string -- both are quite
    able to be indexed (and so are dictionaries, other built-in
    objects such as arrays, and of course many user-defined classes).
    So, again, things ARE basically context-free.
    
    
    Alex
    
    
    
    
    
    From lud at sogetek.fr  Wed Sep  5 08:57:46 2001
    From: lud at sogetek.fr (lud)
    Date: Wed, 5 Sep 2001 14:57:46 +0200
    Subject: a simple question for writtting module
    Message-ID: 
    
    Hi !!
    
    my problem :
    
    first i write in python :
            import mymodule
            data="is a test"
            mymodule.show()
    
    ###################
    now in c :
    static PyObject *
    mymodule_show(PyObject * self, PyObject *args)
    {
    /*bla bla bla ....*/
    }
    so i want get the value of data without transmit her in the call of the
    function show
    
    any idea ?
    
    thx, Ludo
    
    
    
    
    From aleax at aleax.it  Mon Sep 17 07:06:04 2001
    From: aleax at aleax.it (Alex Martelli)
    Date: Mon, 17 Sep 2001 13:06:04 +0200
    Subject: optional arguments
    References: 
    Message-ID: <9o4les02kg6@enews4.newsguy.com>
    
    "Silvio Arcangeli"  wrote in message
    news:mailman.1000716020.11396.python-list at python.org...
    > Hello everybody,
    > sorry for this question that may seem silly.
    > I have an object whose __init__  looks like the following:
    >
    > class Connection:
    > def __init__(self, ip=def_ip, port=def_port)
    > ...
    >
    > I have to call two different functions when the object is instantied like
    > c=Connection()
    > and when it is instantiated like
    > c=Connection(def_ip, def_port)
    >
    > how can I tell wheter no arguments were passed from the user or whether
    > they were passed but they were just like the default values?
    
    By *NOT* using, as default values for the arguments, values
    that could indeed equally well be passed by the client-code.
    
    class Connection:
        class __Boo: pass
        __None = __Boo()
        def __init__(self, ip=__None, port=__None):
            if ip is self.__None:
                print "ip was NOT passed"
            else: print "ip was passed as",ip
    
    etc, etc.
    
    See http://www.penguin.it/pipermail/python/ if you'd
    like help and/or discussion about Python in Italian.
    
    
    Alex
    
    
    
    
    
    From skip at pobox.com  Mon Sep 24 17:09:17 2001
    From: skip at pobox.com (Skip Montanaro)
    Date: Mon, 24 Sep 2001 16:09:17 -0500
    Subject: Why so few Python jobs?
    In-Reply-To: 
    References: <20010924204805.C22856@software.plasmon>
            
    Message-ID: <15279.41213.664043.82516@beluga.mojam.com>
    
        daveb> Indentation is the first and most important indicator of block
        daveb> structure, followed by a very distant 2nd place contestant, the
        daveb> block delimiters, which is why people commit those "classic" bugs
        daveb> I mentioned above.
    
    And why many local C style guides require you to always use braces with
    if/while/for/do etc, even when there is only a single statement in the
    block... .
    
    Cheers,
    
    Skip
    
    
    
    From gbourgeois at silicom.fr  Tue Sep  4 06:59:40 2001
    From: gbourgeois at silicom.fr (Gilles Bourgeois)
    Date: Tue, 04 Sep 2001 11:59:40 +0100
    Subject: tree widget in python
    Message-ID: <3B94B41C.4CDB3B87@silicom.fr>
    
    hi ,from france
    does anyone gnows if tree widget exists in wxpython
    I need a kind of expandable graphical tree  (like when brosing a file
    system with the Windoze file explorer)
    
    My aim is to use a tree to have a expandable view of a C structure ;
    
    this could be :
    typedef {
     char* toto;
     struct titi {
     int x;
     int y;}
    }S
    
    and I want to  give a graphical representation of S, the user then may
    access to all fields of the S 'C structure' and fill in the parameter.
    
    TIA
    gilles
    
    
    From qrczak at knm.org.pl  Tue Sep  4 07:19:33 2001
    From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk)
    Date: 4 Sep 2001 11:19:33 GMT
    Subject: 3-arg float pow()
    References: 
    Message-ID: 
    
    Mon, 3 Sep 2001 16:51:19 -0400, Tim Peters  pisze:
    
    > This is *less* accurate than using a good-quality libm pow() (which
    > should have worst-case final error strictly less than 1 ULP), so
    > current CVS Python uses the libm pow() instead.  The last few bits
    > may differ -- or as many as the last 15-or-so bits if the platform
    > libm pow() truly sucks.
    
    I would expect pow to use multiplication when the exponent is an
    integer (with a signle division if it's negative), and the libm
    pow or equivalently exp(b*ln(a)) if the exponent is a float.
    All independently of the base.
    
    So (-3)**2 would be defined, but (-3)**2.0 would be not.
    And 3**(-2) should return a rational.
    
    -- 
     __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
     \__/
      ^^                      SYGNATURA ZAST?PCZA
    QRCZAK
    
    
    From db3l at fitlinxx.com  Wed Sep 19 19:27:47 2001
    From: db3l at fitlinxx.com (David Bolen)
    Date: 19 Sep 2001 19:27:47 -0400
    Subject: Size in bytes of a dictionary
    References:  <3BA8D294.1D974F89@home.com>
    Message-ID: 
    
    Don O'Donnell  writes:
    
    > Also beware of automatic interning of strings.  Of course this won't be
    > an issue with your key strings, since they must be unique, but duplicate
    > value strings may use the same memory location.  I'm not sure under what
    > conditions auto-intern takes place but it seems to be related to the
    > length of the string.  Here's a little test I just ran:
    
    It's of course potentially version specific, but I think in all recent
    (1.5.2+) variants of CPython the interning rule is that it must be a
    string consisting soley of alphanumerics and the underscore.  Length
    does not appear to be a factor.  (See compile.c in the CPython
    source).
    
    --
    -- 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 shuggy at volcanomail.com  Mon Sep  3 00:51:25 2001
    From: shuggy at volcanomail.com (rob shugg)
    Date: 2 Sep 2001 21:51:25 -0700
    Subject: Tkinter and a clock
    Message-ID: <62a98d55.0109022051.7d323e1a@posting.google.com>
    
    I have an application where I need to display a clock during a data
    acquisition operation. The clock needs to display seconds and I need
    to be able to start stop and reset it like a stopwatch. I have been
    reading about threading issues with Tkinter and am wondering what
    aproach to take. Can someone give me some pointers?
    
    rob
    
    
    From pinard at iro.umontreal.ca  Thu Sep  6 11:39:18 2001
    From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard)
    Date: 06 Sep 2001 11:39:18 -0400
    Subject: pymacs! :-)
    In-Reply-To: <6e0ad3b1.0109060128.6c9adc8@posting.google.com>
    References: 
    	<6e0ad3b1.0109060128.6c9adc8@posting.google.com>
    Message-ID: 
    
    [Brian McErlean]
    
    > Oh dear - oddly enough I'm currently writing exactly the same thing -
    > I'd even decided to call it pymacs :-) Rather worryingly, it looks like
    > I've even implemented it in a similar way.
    
    That's why it is a good thing to announce what we are working at, if we
    know we have any chance to get through, so to trigger collaboration! :-)
    
    > > In LISP, I also gave me some more direct tools:
    > > 
    > >    (exec-python "PYTHON-STATEMENTS")
    > >    (eval-python "PYTHON-EXPRESSION")
    > >    (apply-python FUNCTION ARGUMENTS)
    
    > I just have one function, (pymacs-eval "python-statement-or-expression").
    > This evaluates either, but returns nil for a statement.  [...]  Actually,
    > I think your way having seperate exec and eval may be a better idea -
    
    So far, on my side, I found out that "python-exec" (I moved "python" as a
    prefix rather than a suffix) is not really needed in practice.  The most
    useful is "python-apply", yet the user almost never use it directly: these
    are only used indirectly through the LISP "defun" which get installed in the
    LISP space through the action of "python-import".  As for "python-eval",
    I found it useful for writing quick tests, but I would not think it very
    useful in real applications.
    
    In practice on the LISP side, one does "(python-import MODULE)" and merely
    use the imported functions, without paying much attention anymore if they
    were written in LISP or Python.  To make thins a bit more transparent,
    I'm pondering some "(autoimport ...)"  function to mimick "(autoload ...)",
    unless -- this is unlikely -- I find a neat way to overload "(autoload ...)".
    
    > > From the Python side, I may also call Emacs for help:
    > >    eval_lisp("LISP-EXPRESSION")
    
    Since then, I changed that to the simpler:
    
        from pymacs import lisp
        ...
        value = lisp("LISP-EXPRESSION")
    
    In fact, not much besides `lisp' is needed from the `pymacs' module,
    and Python functions not needing Emacs services do not even need `lisp'.
    The rest is fairly automatic.
    
    > Sometimes doing seemingly simple things can mean a lot of work - eg.
    > (funcall (pymacs-eval "map") (pymacs-eval "lambda x:x+1") (1 2 3 4 5))
    
    I paid attention so opaque LISP objects could be made available on the
    Python side, and found back automatically when transmitted back to the
    LISP side from Python.  You paid attention to the other way, and found
    ways to represent non-simple Python objects on the LISP side.  So it seems
    we solved complementary problems, and this is enough for me to be quite
    interested in your works! :-)
    
    I confess that I did not tackle Python opaque representations in LISP,
    because I do not see how to avoid memory leaks.  If one creates a Python
    object meant to be returned on the LISP side, one has to keep a reference
    active to that object on the Python side, and later copies of corresponding
    references could be made on the LISP side.  But then, how do one gets a clue
    about when the references on the LISP side still exists or not?  Without
    clues, I do not see other choices than keeping the Python object around
    forever, and it might not be acceptable in long running Emacs sessions,
    where a lot of Python objects could be progressively tied in this way.
    
    On the other hand, I easily forgave myself for not doing so, as I was not
    loosing so much.  I aim writing LISP extensions in the Python language,
    much more than give a Python flavour to my LISP writings.  After all,
    I'd rather write in Python than in LISP whenever I seek a Python flavour.
    I think LISP objects like windows, buffers, markers, overlays, etc. should
    be fully usable from the Python side, even if this implies a lot of automatic
    synchronisation between Emacs and LISP.  I guess I reached that goal.
    
    > > Two things are missing before I'm happy.  First, this is all too
    > > fragile to errors: a Python exception should properly be seen on the
    > > Emacs side, and vice-versa.
    
    > My error handling is fairly simple really - I have a special character
    > I return to python as the response to a call - ">" indicates emacs is
    > makeing another call to python, "&" indicates a response to pythons call,
    > and "!" indicates an error, after which I just throw a LispError() - which
    > will in turn be passed to emacs using an error code.  It would be nice
    > to provide some kind of backtrace up both emacs and python calls though.
    
    Currently in my things, the Python backtrace gets displayed in the
    mini-buffer (which is resized for the circumstance) *and* the LISP backtrace
    is shown in the `*Backtrace*' window.  Together with the `*Pymacs*'
    communication window, that makes plenty for debugging.  I made no kind of
    effort to transmit the LISP backtrace on the Python side, as I do not see
    a purpose for it: all debugging is done within Emacs windows anyway.
    
    If cross-calls between LISP and Python nest deeply, an error will raise
    successive exceptions alternatively on both size as things unstack, and
    the diagnostic gets transmitted back and forth, slightly growing as we go.
    I hope my logic is correct: these things are a bit complex to sort out
    and I did not overly tested it yet.
    
    > I have several functions on the emacs class:
    
    > emacs.get_func(name)  - looks up (symbol-function 'name) and returns
    > it, or None
    > emacs.get_value(name) - just calls emacs.eval(name)
    > and __getitem__       - return get_func(name) or get_value(name)
    
    As you might guess, I had to think on similar lines, but was happy to
    use `__call__' to sort out if a LISP object is meant as a function or as
    a value.  Simplifying my code, I found out that the easiest avenue was to
    merely shovel that problem on the LISP side, and I guess I did it cleanly.
    
    > I considered using automatic `_' to `-' and having syntax like
    > emacs.add_hook, using `__getattr__' but I didn't like the automatic
    > conversion - what do you do for functions that do contain `_'?
    
    The automatic conversion is really useful, it is well worth, so I support
    it fully on both sides.  In my current Emacs here, there are only four
    symbols having an underscore: `shift_jis', `shift_jis-dos', `shift_jis-mac',
    and `shift_jis-unix', and they are only useful for their property lists.
    Because "lisp.shift_jis" would really refer to `shift-jis', in such cases,
    I would use "lisp['shift_jis']".  Automatic conversion only occurs for
    the attribute notation.
    
    > Your implementation does sound very interesting though - maybe we should
    > collaborate and take the best of our respective designs?
    
    By all means!  Deep down, these are the goal and result which attract me,
    not really imposing my ideas.  A single better tool has more chance growing
    roots, than two competing and lesser packages.  You understand that I would
    like enjoying some ideas I had, when I dare considering them good ideas! :-)
    
    > Currently, I had planned on releasing my version sometime next week.  
    > I don't have the source with me at work, but I'll see about maybe
    > posting a preliminary release sometime soon.
    
    Do you prefer that we post our respective versions and let these influence
    our respective designs, or that we seek some integrated solution through
    private communications, before posting?  Or should we discuss publicly?
    It depends a bit on if there are many Emacs users who have practical
    interest in writing `.py'/`.pyc' files next to their `.el`/`.elc' files!
    
    -- 
    Fran?ois Pinard   http://www.iro.umontreal.ca/~pinard
    
    
    
    From jkraska at san.rr.com  Sun Sep  2 14:58:35 2001
    From: jkraska at san.rr.com (Courageous)
    Date: Sun, 02 Sep 2001 18:58:35 GMT
    Subject: Stackless Python and Python 2.x
    References:   <3B8EF2E6.CAEB05CC@cosc.canterbury.ac.nz>
    Message-ID: 
    
    On Fri, 31 Aug 2001 14:13:58 +1200, Greg Ewing  wrote:
    
    >Michael Abbott wrote:
    >> 
    >> I've seen Guido van Rossum quoted as being against this because it's
    >> incompatible with the Java Virtual Machine (as I understood it).
    >
    >The other reason is that, by all accounts, if anyone
    >other than Christian Tismer tries to do anything with
    >the core code, their brain explodes.
    
    I know you were being a bit tongue-in-cheek, however I
    would like to point out that the conceptual leap to
    understanding that first-class continuations is to
    understand that they offer the programmer a direct
    instrument by which to create a stack-safe dynamic
    goto label which can cross function-definition boundaries.
    They're really nothing more than an instrument by which
    the programmer can force their own context-switch.
    
    Stacklessness isn't strictly required for this, it's
    just considerably more efficient.
    
    C//
    
    
    
    From mlh at idi.ntnu.no  Sun Sep  2 21:44:58 2001
    From: mlh at idi.ntnu.no (Magnus Lie Hetland)
    Date: Mon, 3 Sep 2001 03:44:58 +0200
    Subject: Migrating from PHP to Python...
    References:  
    Message-ID: <9munaq$9up$1@tyfon.itea.ntnu.no>
    
    "Richard Jones"  wrote in message
    news:mailman.999474243.26942.python-list at python.org...
    
    > > From what I've read, PHP
    > > is faster, less resource intensive, and more prevalent (especially with
    web
    > > hosts).
    >
    > So why bother? Really, why are you here at all with this sort of attitude?
    
    That's not very helpful, is it?
    
    (Yes, the rest of your post _was_ very helpful, I'm sure ;)
    
    Basically, AFAIK what he says is fact, not "attitude". But the question is
    valid nonetheless, isn't it? I believe the strengths of Python in this case
    is its readability, its object-orientedness etc., etc. But even though
    Python is what I use for most of my programming, I still use PHP for a
    lot of web development, simply because it is almost ubiquitous, and because
    it is fast etc. Python doesn't have the same "server page" focus as PHP,
    and there is really no reason why it should.
    
    >
    >     Richard
    >
    
    --
    
      Magnus Lie Hetland         http://www.hetland.org
    
     "Reality is that which, when you stop believing in
      it, doesn't go away."           -- Philip K. Dick
    
    
    
    
    
    From hungjunglu at yahoo.com  Fri Sep 28 10:42:29 2001
    From: hungjunglu at yahoo.com (hungjunglu at yahoo.com)
    Date: Fri, 28 Sep 2001 14:42:29 -0000
    Subject: Fwd:  Re: Problem with os.system()
    Message-ID: <9p228l+jhl8@eGroups.com>
    
    --- In python-list at y..., "Terry Reedy"  wrote:
    >Perhaps there is a command line option that would tell it to do so.
    
    In the time it takes to type and post your message, you could have 
    just visited google and hit the right answer:
    
    mplayer2 /play /close applause.wav
    
    see:
    
    http://support.microsoft.com/support/kb/articles/Q241/4/22.ASP
    
    Hung Jung
    
    
    
    
    
    From skip at pobox.com  Tue Sep 25 16:22:54 2001
    From: skip at pobox.com (Skip Montanaro)
    Date: Tue, 25 Sep 2001 15:22:54 -0500
    Subject: Why not 3.__class__ ?
    In-Reply-To: 
    References: <3v9bqtogrl53sfqor0f81oojaa94tr0qt5@4ax.com>
            <9o4amf02357@enews4.newsguy.com>
            
            
            
    Message-ID: <15280.59294.607840.917806@beluga.mojam.com>
    
        >> No, but that wouldn't be the only cause of ambiguity. Consider
        >> "3.e17". This could be either a number in scientific notation, or the
        >> e17 attribute of the 3. literal.
    
        Marcin> Numbers don't have attributes named with 'e' and digits, so
        Marcin> resolving this ambiguity to scientific notation doesn't cause
        Marcin> trouble to any useful program.
    
    The float type will be subclassable in the future (if not already today in
    2.2a3), at which point floating point numbers could indeed have attributes
    that begin with the letter 'e' or even an attribute named 'e17'.
    
    -- 
    Skip Montanaro (skip at pobox.com)
    http://www.mojam.com/
    http://www.musi-cal.com/
    
    
    
    From thp at cs.ucr.edu  Mon Sep  3 23:29:43 2001
    From: thp at cs.ucr.edu (thp at cs.ucr.edu)
    Date: Tue, 4 Sep 2001 03:29:43 +0000 (UTC)
    Subject: Conditional operator in Python?
    References: <3AC68CB8.22AAF7B8@alcyone.com> <9a631k$3s8qb$1@ID-11957.news.dfncis.de>  <3AC6BB2E.1E09B5AA@alcyone.com> 
    Message-ID: <9n1hr7$7op$1@glue.ucr.edu>
    
    Marcin 'Qrczak' Kowalczyk  wrote:
    : Sat, 31 Mar 2001 21:22:54 -0800, Erik Max Francis  pisze:
    
    :> The Python FAQ, for instance, suggests x ? a : b can be reliably
    :> substituted with
    :> 
    :>     (x and [a] or [b])[0]
    
    : It computes both a and b. 
    
    No.
    
    : A correct solution is
    :     (0 and (lambda: a) or (lambda: b))()
    
    Yes.
    
    : Yes, it is ugly.
    
    Agreed.  Something more aesthetic is definitely needed.  I hate writing:
    
      factorial = lambda x : (x<=1 and [1] or [x*factorial(x-1)])[0] 
    
    Tom Payne
    
    
    From porter at et.byu.edu  Tue Sep 11 11:51:55 2001
    From: porter at et.byu.edu (C. Porter Bassett)
    Date: 11 Sep 2001 08:51:55 -0700
    Subject: idea: Robocode for Python
    References: 
    Message-ID: <84552519.0109110751.6abc9e27@posting.google.com>
    
    > Wouldn't jython fill the bill in this case?  
    
    I had the same thought, and decided to try it.  Since I don't have any
    java nor jython experience, I didn't get very far.  I'll post my
    progress here in the hopes that somebody can help me get a litte
    further.
    
    First of all, here's a very simple .java robot:
    
      package porter;
      import robocode.*;
    
      public class CPB extends Robot
      {
        public void run()
    
    
          while(true)
    
    
            ahead(100);
            turnGunRight(360);
            back(100);
            turnGunRight(360);
          }
        }
    
        public void onScannedRobot(ScannedRobotEvent e)
        {
          fire(1);
        }
      }
    
    I have no idea what the package porter; line is for, so I ignored it. 
    I
    added the robocode.jar to my classpath, and tried to translate this
    java
    code to python.  Here's my python file:
    
      from robocode import *
      class pyrobot(Robot):
         def run(self):
            while(1):
               ahead(100)
               turnGunRight(360)
               back(100)
               turnGunRight(360)
         def onScannedRobot(self, event):
            fire(1)
    
    I ran that through jythonc, and it compiled, but I got a depracation
    warning.  I recompiled with -deprecation, and here's the output from
    jythonc:
    
      0932:PWORK://d/robocode/robots/porter$ jythonc pyrobot.py
      processing pyrobot
    
      Required packages:
        robocode.dialog
        robocode.jdk13bugfix
        robocode.editor
        robocode*
    
      Creating adapters:
    
      Creating .java files:
        pyrobot module
          pyrobot extends robocode.Robot
    
      Compiling .java to .class...
      Compiling with args: ['c://jdk1.3.1_01/bin/javac.exe',
    '-deprecation',
    '-classpath', 'C:\\jython-2.0\\jython.jar;.;C:\\Program
    Files\\proe2000i2\\modchk\\java\\xml\\xml4j.jar;c:\\jython-2.0\\jython.jar;d
    :\\robocode\\robocode.jar;.\\jpywork;;C:\\jython-2.0\\Tools\\jythonc;d:\\rob
    ocode\\robots\\porter\\.;C:\\jython-2.0\\Lib;c:\\jython\\lib;C:\\jython-2.0'
    , '.\\jpywork\\pyrobot.java']
      0  .\jpywork\pyrobot.java:100: warning:
    jfindattr(org.python.core.PyProxy,java.lang.String) in
    org.python.core.Py
    has been deprecated
              PyObject inst = Py.jfindattr(this, "onScannedRobot");
                                ^
      .\jpywork\pyrobot.java:110: warning:
    jfindattr(org.python.core.PyProxy,java.lang.String) in
    org.python.core.Py
    has been deprecated
              PyObject inst = Py.jfindattr(this, "run");
                                ^
      2 warnings
    
    When I try to run a robocode battle with this robot, the robocode
    console
    gives me the following error:
    
    
      java.lang.NoClassDefFoundError: porter/jpywork/pyrobot (wrong name:
    pyrobot)
              at java.lang.ClassLoader.defineClass0(Native Method)
              at java.lang.ClassLoader.defineClass(Unknown Source)
              at java.lang.ClassLoader.defineClass(Unknown Source)
              at
    robocode.JBotsClassLoader.loadRobotClass(JBotsClassLoader.java:55)
              at robocode.Battle.initialize(Battle.java:350)
              at robocode.Battle.run(Battle.java:42)
              at java.lang.Thread.run(Unknown Source)
    
    Because of my utter lack of java knowledge, I am completely stuck.  Is
    it
    even possible to do what I am trying to do?  If so, what should I try
    next?
    
    
    From robin at jessikat.fsnet.co.uk  Fri Sep  7 14:44:15 2001
    From: robin at jessikat.fsnet.co.uk (Robin Becker)
    Date: Fri, 7 Sep 2001 19:44:15 +0100
    Subject: PyArg_ParseTuple O format semantics
    Message-ID: 
    
    Steve Alexander kindly forwarded me a note relating to a change in
    getargs.c that occurred between  2.0 and 2.0.1. Basically it was implied
    that O format conversion was buggy before in term of the refcount of the
    returned object.
    
    The documentation doesn't mention any increment so it seems to return a
    borrowed ref.
    
    I'm using the O flag a bit and would like to know if I should be
    patching to cover the change -->2.0.1?
    -- 
    Robin Becker
    
    
    From ignacio at openservices.net  Thu Sep  6 12:39:07 2001
    From: ignacio at openservices.net (Ignacio Vazquez-Abrams)
    Date: Thu, 6 Sep 2001 12:39:07 -0400 (EDT)
    Subject: Help getting python/Apache working together on windows
    In-Reply-To: 
    Message-ID: 
    
    On Thu, 6 Sep 2001, Ignacio Vazquez-Abrams wrote:
    
    > On 6 Sep 2001, Brian Sweeting wrote:
    >
    > > I have two questions...
    > >
    > > 1) Is there any way I can run it the same way as php without messing
    > > with the httpd.conf file all the time?  I have seen quite a few
    > > tutorials on running python as a cgi, but I would like to be able to
    > > go to a url and run that script.
    >
    > AddHandler cgi-script py pyc pyo
    
    D'oh. I forgot putting index.py, index.pyc, and index.pyo in DirectoryIndex.
    
    -- 
    Ignacio Vazquez-Abrams  
    
    
    
    
    From chrishbarker at home.net  Mon Sep 24 14:44:25 2001
    From: chrishbarker at home.net (Chris Barker)
    Date: Mon, 24 Sep 2001 11:44:25 -0700
    Subject: To re or not to re ... ( word wrap function?)
    References: 
    Message-ID: <3BAF7F09.767225B6@home.net>
    
    Thanks to all of you who posted code: I've learned something from each
    one.
    
    
    I did notice that no one used an re-based solution, except Skip using
    
    re.split(r'\s+', s)
    
    Is this any different than string.split(s) ?
    
    Note that I didn't want to use either of these, as they would kill any
    sequences of whitespace, such as two spaces after a sentence.
    
    
    tex_wrap looks very nice but is really overkill for this application.
    
    
    I also noticed that no one took my approach, which was to start at the
    end of the line and work backwards looking for space. You all took the
    approach of building the new line word by word from the beginning.
    
    hmmmm.
    
    -Chris
    
    
    -- 
    Christopher Barker,
    Ph.D.                                                           
    ChrisHBarker at home.net                 ---           ---           ---
    http://members.home.net/barkerlohmann ---@@       -----@@       -----@@
                                       ------@@@     ------@@@     ------@@@
    Oil Spill Modeling                ------   @    ------   @   ------   @
    Water Resources Engineering       -------      ---------     --------    
    Coastal and Fluvial Hydrodynamics --------------------------------------
    ------------------------------------------------------------------------
    
    
    
    From tjreedy at home.com  Sun Sep  9 16:08:21 2001
    From: tjreedy at home.com (Terry Reedy)
    Date: Sun, 09 Sep 2001 20:08:21 GMT
    Subject: Proposed PEP for a Conditional Expression
    References: 
    Message-ID: 
    
    "Michael Chermside"  wrote in message
    news:mailman.1000046772.19777.python-list at python.org...
    > Included in this email is a PEP which I am putting together dealing
    with
    > the idea of introducing a conditional expression into Python. I
    would
    > welcome any discussion, suggestions, and/or help, sent either to
    this
    > newsgroup under this topic, or emailed to me at .
    
    I'll do both
    
    > PEP, I find ARG_1, ARG_3, and ARG_23 unconvincing, while ARG_21,
    ARG_22,
    > and ARG_3 all make sense to me
    
    Do you really find ARG_3 both unconvincing and sensible> or is there a
    typo?
    
    I suggest relabeling arguments A1, A2, ... (anti) and P1, P2,
    ...(pro).
    
    > ------------------- DRAFT PEP
    FOLLOWS ----------------------------------
    > PEP: NO-NUM-YET
    > Title: Creating a Short-Circuiting Conditional Expression
    ...
    >      ARG_1: Workarounds exist.
    
    It's really hard to fairly present arguments you find 'unconvincing',
    so I will help you.
    (Please note: I am impressed at how well you did do, especially for
    version 1.)
    I'm going to split this into two anti arguments, A1 and A2, and one
    pro argument, P1.
    
    A1: Python has conditional statements for conditional assignments.
    >              > if c:
    >              >     x = a
    >              > else:
    >              >     x = b
    >              Of course, many people would say that just writing it
    out
    >              is probably the best solution. It can be done in 4
    line,
    >              or in 2, like this:
    >              > if c: x = a
    >              > else: x = b
    
    P1.            In either case, though, this is NOT an expression, so
    >              using it may require creating a temporary variable and
    >              splitting a formula into two lines, or replacing a
    lambda
    >              expression with a named function.
    
    A2: Python already has short-circuiting conditional expressions (even
    if some proponents of an alternative syntax refuse to recognize them
    as such by dismissing them as 'workarounds').
    
             First, the conditional expression that DOESN'T short-circuit:
             > def cond(c, a, b):
             >     if c: return a
             >    else: return b
             > x = cond(c, a, b)
             This fails to short-circuit because arguments to a function
    are always
             evaluated before the function is invoked. Thus, for instance,
    the
             following would not work properly when a == 0:
             > x = cond( a==0, DEFAULT_VAL, 100/a )
    
            Next, the expression that ALMOST ALWAYS short-circuits
    correctly:
            > x = c and a or b # or, almost equivalently
            > x = (not c) and b or a
            The advantage of this simple form is that it syntactically
    matches
            the conditional expression of C with (and,or) substituted for
    (?,:).
            Because the boolean operators 'and' and 'or' short circuit,
    this idiom
            works whenever a (or b) is certain to evaluate as true for all
    values
            of the variables.  This is true of most (all?) realistic
    examples given
            by proponents of a new syntax.  Examples:
            > inverses = map( lambda x: x==0 and "Inf" or 1.0/x, values )
            > tags = [ (s is not None and '<%s>' % s or None) for s in
    keys ]
    
            If it is possible that both a and b can evaluate to 'false',
    there are clumsier
            but GUARENTEED-TO-WORK forms:
            > x = (c and [a] or [b])[0]
            > x = (c and (a,) or (b,))[0]
            These index into one-element sequences which are definitely
    not false.
            The tuple version is slightly faster but more awkward to type
    and read.
            > x = (c and (lambda:a) or (lambda:b))()
            Functions are also never false.  The version takes longer to
    type
            and may be less readable, especiaoly within an outer lambda.
    
            In short, this PEP only proposes a new syntax and not a new
    funtionality,
            and the argument for the new syntax must adress why such is
    worth the
            accompanying costs.
    ..
    >      ARG_21: Simplifies lambda expressions.
    ...
    >      ARG_22: Makes a functional style easier.
    ...
    >       ARG_24: Clarifies intent when used for assignments.
    
    All of these are arguments for the use of expressions rather than
    statements.  They all apply equally well to the existing expression
    forms. They are not, in themselves, arguments for a new form.
    
    >      ARG_23: Lots of people ask for it.
    >          Lots of people ask for a conditional expression.
    
    Some are ignorant of the current forms, some deny that they are what
    they are, and some want something we do not currently have (a simple
    form without cruft, like C's, that always works) but have not settled
    on anything specific for the rest of us to consider.  I hope this
    'PEP' helps all three groups.
    
    Terry J. Reedy
    
    
    
    
    
    From phil.harris at zope.co.uk  Wed Sep 12 07:49:37 2001
    From: phil.harris at zope.co.uk (Phil Harris)
    Date: 12 Sep 2001 04:49:37 -0700
    Subject: Python with threads for Cygwin.
    Message-ID: 
    
    All,
    
    Has anyone ever managed to create a version of Python with threads on Cygwin?
    
    If so, what is the secret incantation?
    
    Phil
    
    
    From root at rainerdeyke.com  Wed Sep  5 15:15:57 2001
    From: root at rainerdeyke.com (Rainer Deyke)
    Date: Wed, 05 Sep 2001 19:15:57 GMT
    Subject: no parallel threading?
    References: 
    Message-ID: 
    
    > On Wed, 5 Sep 2001, Tobias Unruh wrote:
    >
    > >Hi,
    > >
    > >I tried to execute two threads in parallel (linux 2.4.9, python 2.0):
    > >
    > >import time
    > >import threading
    > >
    > >def test_thread_func1():
    > >    print "Hallo1"
    > >    time.sleep(3.0)
    > >    print "Hallo1"
    > >
    > >def test_thread_func2():
    > >    print "Hallo2"
    > >    time.sleep(3.0)
    > >    print "Hallo2"
    > >
    > >printlock = threading.Lock()
    > >
    > >test_thread1 = threading.Thread(None,test_thread_func1())
    > >test_thread2 = threading.Thread(None,test_thread_func2())
                                                             ^^
    
    You are calling 'test_thread_func1', and passing the result to
    'threading.Thread'.  In other words, your function has already terminated
    before the thread object is created.  Try leaving off the '()' after
    'test_thread_func1' and 'test_thread_func2'.
    
    
    --
    Rainer Deyke (root at rainerdeyke.com)
    Shareware computer games           -           http://rainerdeyke.com
    "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor
    
    
    
    
    From tjreedy at home.com  Tue Sep 18 11:51:43 2001
    From: tjreedy at home.com (Terry Reedy)
    Date: Tue, 18 Sep 2001 15:51:43 GMT
    Subject: Request for example of state machine using generators
    References: 
    Message-ID: 
    
    "Tim Peters"  wrote in message
    news:mailman.1000792880.26234.python-list at python.org...
    > In 2.2a3 (or CVS), you can look at Tools/scripts/cleanfuture.py for
    an
    > extended example of using generators to avoid state machines, there
    in a
    > parsing context.  Lib/test/test_generators.py also has many examples
    of
    > generator techniques.
    
    One can view both of these files directly from CVS source with browser
    by starting at
    
    http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/
    
    Terry J. Reedy
    
    
    
    
    
    From qrczak at knm.org.pl  Wed Sep 12 10:16:50 2001
    From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk)
    Date: 12 Sep 2001 14:16:50 GMT
    Subject: Proposed PEP for a Conditional Expression
    References:  <6qvgire4bk.fsf@abnoba.intevation.de> <9nidrm01j7q@enews1.newsguy.com> <9nk4t8$4qq$1@glue.ucr.edu> <9nkmjj01rha@enews3.newsguy.com> <9nnf0d$5qf$2@glue.ucr.edu> <9nnigp02g7a@enews1.newsguy.com>
    Message-ID: 
    
    Wed, 12 Sep 2001 13:56:09 +0200, Alex Martelli  pisze:
    
    > I think the proposed conditional operator would be just about at
    > the threshold (I wouldn't particularly care either way if it got in
    > or stayed out) EXCEPT for the risk that it may in fact encourage
    > people to write more lambda's rather than named local functions,
    > which I see as a substantial minus.
    
    If we prefer list comprehensions to for loops with appends,
    in this case it encourages in the right direction.
    
    -- 
     __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
     \__/
      ^^                      SYGNATURA ZAST?PCZA
    QRCZAK
    
    
    From gh_pythonlist at gmx.de  Sun Sep 30 01:49:28 2001
    From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-1?Q?H=E4ring?=)
    Date: Sun, 30 Sep 2001 07:49:28 +0200
    Subject: [Q] PyGreSQL
    In-Reply-To: ; from shwang5@students.uiuc.edu on Sat, Sep 29, 2001 at 09:24:58PM -0700
    References: 
    Message-ID: <20010930074925.A1967@lilith.hqd-internal>
    
    On Sat, Sep 29, 2001 at 09:24:58PM -0700, Seung-won Hwang wrote:
    > Hi,
    > 
    > I have two questions on PyGreSQL:
    > 
    > (1) Could you let me know where the windows version of PyGreSQL is? I failed
    > in finding one from web search.
    
    On my homepage you can find one (see sig). I'd recommend you use my
    Windows port of pyPgSQL instead, though. The win32 version is now
    available from the official homepage
    (http://www.sourceforge.net/projects/pypgsql/) and  I'm also a developer
    in this project, so think of this as the officially supported one :-))
    
    > (2) What's the easiest way to load tab-separated text data to the relational
    > database? Any easier way than writing a program that calls "INSERT INTO" for
    > every data value?
    
    AFAIK, all the easy ways involve proprietary tools. Below I've put a
    draft of a function that might do what you want. It's not perfect, and I
    don't know how to handle things like auto-increment columns.
    
    Gerhard
    
    #############################################################################
    #!/usr/bin/env python
    import PgSQL
    
    def importTable(cursor, tablename, filename):
        """Imports data from filename into the table tablename. Each line in the
        data file is one record. The fields are tab-seperated."""
        # Build a list of lists; the inner list contains the columns to be inserted
        f = open(filename, "r")
        entries = []
        for line in f.readlines():
    	if line.strip() != "":
    	    entries.append(line.strip().split("\t"))
        f.close()
        numcolumns = len(entries[0])
        # Build the SQL statement; using %s for any column type is pyPgSQL specific
        sql = "insert into %s values " % tablename
        sql += "(" + ", ".join(["%s"] * numcolumns) + ")"
        cursor.executemany(sql, entries)
        
    db = PgSQL.connect()
    cursor = db.cursor()
    importTable(cursor, "test", "testdata.txt")
    db.commit()
    -- 
    mail:   gerhard  bigfoot  de       registered Linux user #64239
    web:    http://www.cs.fhm.edu/~ifw00065/    OpenPGP public key id 86AB43C0
    public key fingerprint: DEC1 1D02 5743 1159 CD20  A4B6 7B22 6575 86AB 43C0
    reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))
    
    
    
    From mmhamze at pleiades.net  Fri Sep  7 09:04:47 2001
    From: mmhamze at pleiades.net (Maan M. Hamze)
    Date: Fri, 7 Sep 2001 08:04:47 -0500
    Subject: Creating Excel files on Linux
    References: <3B97A39C.6A5234D7@olen.to> 
    Message-ID: 
    
    But the question is:  Can Staroffice create XLS files?  If not, then it is a
    major waste of time to create spreadsheets using Staroffice.  It is a world
    that speaks the XLS language.
    Maan
    
    "Carlos Gaston Alvarez"  wrote in message
    news:mailman.999798189.20175.python-list at python.org...
    > Staroffice can run java programs the same way Office can run Visual Basic.
    > If you dont know java it may be easier for you to jython (python in java).
    > Staroffice (for the moment) is free.
    >
    > Why dont you take a look? If it works please mail me. I have never used it
    > that way. Neither I know where the jdk is.
    >
    > Chau,
    >
    > Gaston
    >
    >
    > ----- Original Message -----
    > From: "Joonas Paalasmaa" 
    > Newsgroups: comp.lang.python
    > To: 
    > Sent: Thursday, September 06, 2001 6:26 PM
    > Subject: Creating Excel files on Linux
    >
    >
    > > Is there any way to create xls or some other format that
    > > MS Excel can read excluding CSV.
    > > I am using Linux so I think that COM is not an option.
    > >
    > > --
    > > Joonas
    > > --
    > > http://mail.python.org/mailman/listinfo/python-list
    > >
    >
    >
    
    
    
    
    From rdsteph at earthlink.net  Sun Sep  9 12:50:41 2001
    From: rdsteph at earthlink.net (Ron Stephens)
    Date: Sun, 09 Sep 2001 16:50:41 GMT
    Subject: Python and Zope
    References:  
    Message-ID: <3B9B9F92.DF67BC9@earthlink.net>
    
    Three points:
    
    1. Python will work with .NET (see ActiveState's web site for Visual Python .NET
    beta. So, any work you do now in Python will not be lost if you later convert to
    the .NET runtime, in fact, Python will offer a fully compatible, more productive
    development environment for .NET than any other language.
    
    2. .NET is simply not ready *yet*, so I suspect it would be a little hard to do
    your work right now in .NET. I agree with you that .NET looks promising and is
    well thought out, but it is very early in the day to be committing a major
    project to .NET, especially when the Python option is so inviting, both now
    (fully mature development environment) and in the future (fully compatible .NET
    language).
    
    3. Zope works, is more powerful than any other option available at this time,
    and because its written in Python, has a great future.
    
    Cheers,
    
    Ron Stephens
    
    
    
    Ken Egervari wrote:
    
    > I'm actually very used to the PHP interpreter as I've done a few large
    > websites with it.  It's not powerful enough for my needs and I need to go to
    > something with higher performance, scalability, cleanliness and just into a
    > better multi-tiered, OO environment.  I know you can hack and do it in PHP -
    > I'm looking for a nice framework that works that can help me deploy faster.
    >
    > Some I'm looking at:
    > Java Enterprise (which I have previous experience in)
    > .NET (i'm very impressed)
    > Python and/or Zope
    >
    > Java doesn't look that great sinec I have to spend a lot more money on
    > servers to get it running at the same performance as Python.  I'm not sure
    > of the speeds that .NET provides.  I can't see it being ultra fast since the
    > common language layer and the extra-added framework to make development
    > easier will no-doubtedly slow it down.  Zope looked very interesting, but
    > it's very akward to get used to structuring websites when you have been
    > doing large frameworks for a long time in a traditional environment.
    >
    > Any help appreciated.
    > Ken
    >
    > "Ignacio Vazquez-Abrams"  wrote in message
    > news:mailman.1000048100.22478.python-list at python.org...
    > > On Sun, 9 Sep 2001, Oleg Broytmann wrote:
    > >
    > > >    Apache modules are just CGIs. Apache forks off a child at random, and
    > at
    > > > random kills children. On the other hand, web-application server is
    > always
    > > > in memory. This allows for the server to create persistence connection
    > to a
    > > > DB. How can you implement persistence connection in Apache module? Those
    > > > "solutions" that are in mod_perl and mod_python are (in my not so humble
    > > > opinion) just unstable hacks.
    > >
    > > Bzzt! Thank you for playing.
    > >
    > > I can't talk about mod_python or mod_perl, but mod_php's interpreter is
    > not
    > > CGI; it runs in Apache's memory space. Persistent connections are quite
    > easy
    > > to create (xxx_pconnect() instead of xxx_connect()).
    > >
    > > Also, Apache does not fork and kill children at random. A certain minimum
    > > number of children are created at startup, more are created up to a
    > maximum
    > > number if necessary, and once a child has served a certain number of
    > > connections, it is killed. This results in maximum stability because any
    > > memory problems only have a limited amount of time to live.
    > >
    > > --
    > > Ignacio Vazquez-Abrams  
    > >
    > >
    
    
    
    From cb921 at voice.co.za  Tue Sep 25 16:05:22 2001
    From: cb921 at voice.co.za (Campbell)
    Date: Tue, 25 Sep 2001 22:05:22 +0200
    Subject: Lniker Error
    Message-ID: 
    
    Hi,
    
    I've finished up my nice new interface.  I wrote all texts on a Linux
    box, using the xxmodule.c from my source .tar.gz for a start.  But it
    won't compile on NT, I've pasted the output from VC++ below.
    
    What stupid thing did I forget?
    
    Windows NT 4 plus Microsoft Visual C++ 6.
    
    --------------------Configuration: testmodule - Win32 Debug--------------------
    Linking...
    testmodule.obj : error LNK2001: unresolved external symbol __imp___Py_Dealloc
    testmodule.obj : error LNK2001: unresolved external symbol __imp___Py_RefTotal
    testmodule.obj : error LNK2001: unresolved external symbol __chkesp
    testmodule.obj : error LNK2001: unresolved external symbol __imp__Py_InitModule4TraceRefs
    LINK : error LNK2001: unresolved external symbol __DllMainCRTStartup at 12
    Debug/testmodule.dll : fatal error LNK1120: 5 unresolved externals
    Error executing link.exe.
    
    testmodule.dll - 6 error(s), 0 warning(s)
    
    Cheers,
    Campbell
    
    
    
    From warkid at storm.ru  Fri Sep  7 14:55:40 2001
    From: warkid at storm.ru ( Kerim Borchaev ( WarKiD ) )
    Date: Fri, 7 Sep 2001 22:55:40 +0400
    Subject: Customizing module globals
    In-Reply-To: 
    References: 
    Message-ID: <14955.010907@storm.ru>
    
    >> But te problem is that import fails...
    >>
    >>   File "ModuleUser.py", line 1, in ?
    >>     import Module
    >>   File "Module.py", line 1, in ?
    >>     Object.doThings()
    >>   NameError: name 'Object' is not defined
    TR> OK, You can't modify a module until it has been imported successfully,
    TR> and you cannot run something during import that has not yet been
    TR> defined.  So module would have to import Object from somewhere else
    TR> before it tries to access Object.
    
    But there _is_ a module that isn't explicitly imported - __builtins__ .
    And may be one can specify other names to be present in module's
    namespace just before it is executed?
    
    Best regards,
     Kerim                            mailto:warkid at storm.ru
    
    
    
    
    
    From facelle at jumpy.it  Wed Sep 26 14:12:03 2001
    From: facelle at jumpy.it (Fabrizio)
    Date: Wed, 26 Sep 2001 20:12:03 +0200
    Subject: Py2exe beginner troubles
    Message-ID: <9ot7pg$ci1$1@serv1.albacom.net>
    
    Hi,
    
    I am trying to use Py2exe to build a standalone executable of a very basic
    program (see below), but with no luck.
    
    This is what I get:
    
    error: invalid command 'py2exe' (no module named 'distutils.command.py2exe')
    
    
    What am I doing wrong ?
    
    Any help will be appreciated.
    
    Thanks in advance,
    
    Fabrizio
    
    -----------------------------------------------------------------
    
    Here are the details:
    
    I use :
    
    Python 2.0 installed in C:\Python20
    Windows98
    py2exe-0.2.6.win32-py2.0.exe installed in C:\Python20\py2exe
    
    -------------
    
    This is the program I am trying to "compile" :
    
    
    def fact (x):
        f=1
        for t in range (1, x+1):
            f=f*t
        print f
    
    z = input("Input a number ")
    fact (z)
    
    -----------------
    
    
    And this is my setup script :
    
    from distutils.core import setup
    import py2exe
    setup(name="fact",
                   scripts=["fact.py"],
             )
    
    ----------------
    
    I run it using :
    
    c:\python20\python setup.py py2exe -W
    
    
    
    
    
    From matt at mondoinfo.com  Mon Sep 24 23:36:52 2001
    From: matt at mondoinfo.com (Matthew Dixon Cowles)
    Date: Tue, 25 Sep 2001 03:36:52 GMT
    Subject: Tkinter and frame resizing question
    References: 
    Message-ID: 
    
    On Mon, 24 Sep 2001 22:40:13 +0200, Laura Creighton 
    wrote:
    
    >When I use grid_remove() to remove a big frame, the window is
    >redrawn from the top down, and so my tiny frame moves upwards.
    >I don't want this.  I'd prefer to anchor the tiny frame to the
    >bottom of the screen and then have the top of the window rise
    >or fall depending on how many big frames I grid.  Does anybody
    >know how to do this?
    
    Dear Laura,
    I don't think you're going to have much luck doing things that way.
    At best, I think you'd have a window that bounced around the screen.
    The reason for that is that the location of the upper left of your
    window is under the window manager's control (you can use the
    geometry() method to request that it be moved). I doubt that you'd
    have much success in getting your window manager to move the window
    down just as you were shortening your window. I'd suggest that you
    consider a couple of alternatives:
    
    You could put the frame with the control buttons near the top of your
    window.
    
    You could used a fixed-size frame (perhaps one with scroll bars) above
    your control buttons and pack or grid your other frames into it. Pmw
    has a scrolled-frame:
    
    http://pmw.sourceforge.net/doc/ScrolledFrame.html
    
    You could use a Pmw PanedWidget; it allows you to add and remove sub-widgets
    and they can have varying heights:
    
    http://pmw.sourceforge.net/doc/PanedWidget.html
    
    Regards,
    Matt
    
    
    From jinu_lee at hotmail.com  Tue Sep 11 22:36:25 2001
    From: jinu_lee at hotmail.com (Jinu Lee)
    Date: Wed, 12 Sep 2001 02:36:25 GMT
    Subject: "weird" behavior of __file__ attribute
    References: <9naf7h$ojk$1@news.urz.uni-heidelberg.de>
    Message-ID: 
    
    The result is not related to the way you call mytest.py.
    The first time you call it, mytest.py imports mytestA.py and python
    interpreter creates compiles mytestA.py into mytestA.pyc.
    After that, when you call mytest.py again and it imports mytestA.py, the
    interpreter finds mytetsA.pyc and imports that file.
    
    If you delete the mytestA.pyc file and call mytest.py in your second way,
    you will get the same result as the first one.
    
    Jinu
    
    
    
    "cherzog"  wrote in message
    news:9naf7h$ojk$1 at news.urz.uni-heidelberg.de...
    > Hello All,
    > The __file__ attribute of a module behaves in a way I do not understand:
    > I have the following example on Windows with Python 2.1: I got two files
    in
    > C:\
    > first: C:\mytest.py
    > second: C:\mytestA.py
    >
    > mytest.py is:
    > #----------start of file------
    > import os
    > import mytestA
    > print "cwd: ", os.getcwd()
    > print "mytestA.__file__: ", mytestA.__file__
    > #----------end of file
    >
    > while mytestA.py says simply hello:
    >
    > #----------start of file------
    > print "hello"
    > #----------end of file
    >
    > If I type:
    > C:\>mytest.py
    > I get:
    > Hallo
    > cwd:  C:\
    > mytestA.__file__:  C:\mytestA.py
    >
    > But if I type:
    > C:\>C:\programme\python21\python mytest.py
    > I get:
    > Hallo
    > cwd:  C:\
    > mytestA.__file__:  mytestA.pyc
    >
    > This is not what I wanted because I hoped to find out the exact path of
    > module mytestA.py no matter  how I call mytest.py.
    > Please, can someone help me?
    > Thank you
    > Christoph
    >
    >
    
    
    
    
    From chris.gonnerman at newcenturycomputers.net  Thu Sep 27 00:29:43 2001
    From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman)
    Date: Wed, 26 Sep 2001 23:29:43 -0500
    Subject: Using glob (was Re: Remove files of same type (extension))
    References: <9on1mq$pj8$04$1@news.t-online.com> <3BAF3754.68BDA949@yahoo.com>  <3BB00766.CC23290C@engcorp.com>  <9ophr4$7u8$1@quark.noos.net>  <9os8qv$d96$1@neon.noos.net> <3BB1DDE2.DD45D2C8@engcorp.com> <9osnri$l9$1@quark.noos.net> <3BB298B9.B266995C@engcorp.com> <9ou8qk$dog$1@neon.noos.net>
    Message-ID: <006d01c1470d$11f80b60$0101010a@local>
    
    I too am perplexed as to what ls has to do with the glob module...
    what IS the point?  You have adequately pointed out obvious matters
    regarding the results of shell globbing and of the output of ls -a;
    we can all see that you understand Unix reasonably well.  But what
    is the point you are belaboring?
    
    (BTW visited your site, loved it overall).
    
    ----- Original Message -----
    From: "Boyd Roberts" 
    Newsgroups: comp.lang.python
    To: 
    Sent: Wednesday, September 26, 2001 11:06 PM
    Subject: Re: Using glob (was Re: Remove files of same type (extension))
    
    
    > "Peter Hansen"  a ?crit dans le message news:
    3BB298B9.B266995C at engcorp.com...
    > > Boyd Roberts wrote:
    > > >
    > > > "Peter Hansen"  a ?crit dans le message news:
    3BB1DDE2.DD45D2C8 at engcorp.com...
    > > > > I don't understand the part about it being only "with the complicity
    of ls".
    > > >
    > > > echo *
    > > > echo `ls`
    > >
    > > This is meaningless.  ls returns the non-hidden files.
    >
    > i see you've used a unix system recently:
    >
    > $ echo *
    > bin dead.letter junk pester.txt s src
    > $ echo `ls`
    > bin dead.letter junk pester.txt s src
    > $ echo .*
    > . .. .Xauthority .article .basser .cai .facesrc .forward.mhs
    .forward.plan9 .ft
    > .history .mail_dir .mailrc .mini .news_time .plan .planete .pnewsexpert
    .profile
    >  .sh_history .sig .smp.g8-3 .xsession-errors
    > $ echo `ls -a`
    > . .. .Xauthority .article .basser .cai .facesrc .forward.mhs
    .forward.plan9 .ft
    > .history .mail_dir .mailrc .mini .news_time .plan .planete .pnewsexpert
    .profile
    >  .sh_history .sig .smp.g8-3 .xsession-errors bin dead.letter junk
    pester.txt s s
    > rc
    > $
    >
    > how much more chapter and verse would you like?
    >
    >
    >
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >
    >
    
    
    
    
    From richard at bizarsoftware.com.au  Thu Sep 27 04:02:27 2001
    From: richard at bizarsoftware.com.au (Richard Jones)
    Date: Thu, 27 Sep 2001 18:02:27 +1000
    Subject: Does there exist a Python-to-Perl translator ?
    In-Reply-To: <3BB2D226.3C260A2C@Spam.Please>
    References: <3BB2D226.3C260A2C@Spam.Please>
    Message-ID: <0109271802270U.13278@ike>
    
    On Thursday 27 September 2001 17:15, Weet Vanniks wrote:
    > This would help me produce Perl code after developing it in Python.
    
    OK, I'll bite - WHY?
    
    As far as I know, no such beast exists.
    
    
        Richard
    
    
    
    From markus at schabi.de  Fri Sep 14 06:05:26 2001
    From: markus at schabi.de (Markus Schaber)
    Date: Fri, 14 Sep 2001 12:05:26 +0200
    Subject: Newbie:  Why Does This Work This Way...Global Variables And The Signal Module....
    References: <2bao7.472498$ai2.35646143@bin2.nnrp.aus1.giganews.com>
    Message-ID: <1389985.cojqenx9y0@lunix.schabi.de>
    
    Hi,
    
    John Branthoover  schrub:
    
    >     I have written a simple program to break out of a endless loop by
    > hitting control C,  see below.  This program works OK but I don't
    > understand why I have to define the global variable "Loop_Run" twice
    > to get it to work. I thought that you had only to define a global
    > variable once at the beginning of a program and that made it available
    > to rest of the module.
    
    The global statement is no definition in this way. All variables are 
    usually from their local scope, so if you do
    
    def f():
            loop_run=0
    
    then this sets the variable local to the current function. The global 
    statement just tells the byte-code compiler to use the global variable 
    loop_run during the current function whenever anything accesses 
    loop_run. Imagine this as some kind of "search redirection" which says 
    "don't use local scope, but global scope for this name".
    
    So you have to tell this in every function and method you need it.
    
    Also remember that the variable is created on the first write access to 
    it. A "definition" - as known from static languages - is not knowt to 
    python.
    
    Another point is that the python interpreter allows omitting the global 
    statement whenever the variable is only read and not written in the 
    function - because in this case, there can't be a local variable.
    
    So you could rewrite your example as follows:
    
    #!/usr/local/bin/python
    import signal
    
    def signal_handler(signal, frame):
        global Loop_Run
        Loop_Run=0
        print 'Signal Handler',Loop_Run
    
    def Main():
        while Loop_Run<>0:
            print 'Loop is running because Loop_Run = ',Loop_Run
        print  'Loop is stopped because Loop_Run = ',Loop_Run
    
    Loop_Run=1
    signal.signal(signal.SIGINT, signal_handler)
    
    if __name__=='__main__':
        Main()
    
    markus
    -- 
    "The strength of the Constitution lies entirely in the determination of 
    each citizen to defend it. Only if every single citizen feels duty 
    bound to do his share in this defense are the constitutional rights 
    secure." -- Albert Einstein
    
    
    From jriveramerla at yahoo.com  Sat Sep 15 03:13:58 2001
    From: jriveramerla at yahoo.com (Jose Rivera)
    Date: 15 Sep 2001 00:13:58 -0700
    Subject: Thanks for the help...
    Message-ID: <11e94203.0109142313.759a300b@posting.google.com>
    
    Thanks... the problem was that I was using wxPython 2.3.1
    
    When I changed to wxPython 2.2.5 BOA worked ok and I finished the
    Getting Started Tutorial witout any problem.
    
    thanks...
    
    
    From peter at engcorp.com  Wed Sep 26 23:10:49 2001
    From: peter at engcorp.com (Peter Hansen)
    Date: Wed, 26 Sep 2001 23:10:49 -0400
    Subject: Using glob (was Re: Remove files of same type (extension))
    References: <9on1mq$pj8$04$1@news.t-online.com> <3BAF3754.68BDA949@yahoo.com>  <3BB00766.CC23290C@engcorp.com>  <9ophr4$7u8$1@quark.noos.net>  <9os8qv$d96$1@neon.noos.net> <3BB1DDE2.DD45D2C8@engcorp.com> <9osnri$l9$1@quark.noos.net>
    Message-ID: <3BB298B9.B266995C@engcorp.com>
    
    Boyd Roberts wrote:
    > 
    > "Peter Hansen"  a ?crit dans le message news: 3BB1DDE2.DD45D2C8 at engcorp.com...
    > > I don't understand the part about it being only "with the complicity of ls".
    > 
    > echo *
    > echo `ls`
    
    This is meaningless.  ls returns the non-hidden files.  Echoing them
    is no different than just displaying the names.  What do you expect
    to see from echo `ls` that you don't see from just ls ?
    
    Anyway, what the hell is your point?  You aren't even arguing a point
    here, just posting snippets of apparently (to me... please enlighten me)
    useless and meaningless shell code without even attempting to explain
    why you think it's relevant.
    
    Again another way: ls is just a command, one of many.  You don't
    need to use it or even have it on your system, and yet the shell
    still goes ahead doing globbing (e.g. echo *) and following the
    rules of shell globbing referred to in the first place.  Just what
    this has to do with ls and its supposed complicity in the matter
    is really beyond me.
    
    (Please reply with English rather than shell script if you have 
    a point to make.)
    
    (Apologies for sounding curt, but this is the third message from
    you on the topic which doesn't seem to catch the point.  Maybe 
    I'm just missing something that's obvious to you.)
    
    -- 
    ----------------------
    Peter Hansen, P.Eng.
    peter at engcorp.com
    
    
    From fdrake at acm.org  Thu Sep  6 15:34:38 2001
    From: fdrake at acm.org (Fred L. Drake)
    Date: Thu,  6 Sep 2001 15:34:38 -0400 (EDT)
    Subject: [development doc updates]
    Message-ID: <20010906193438.C242828845@cj42289-a.reston1.va.home.com>
    
    The development version of the documentation has been updated:
    
        http://python.sourceforge.net/devel-docs/
    
    Documentation for 2.2 alpha 3.
    
    
    
    
    From mlh at idi.ntnu.no  Mon Sep  3 16:11:20 2001
    From: mlh at idi.ntnu.no (Magnus Lie Hetland)
    Date: Mon, 3 Sep 2001 22:11:20 +0200
    Subject: Can I build a dictonary with a list-comprehension?
    References: 
    Message-ID: <9n0o58$d1a$1@tyfon.itea.ntnu.no>
    
    "Hans Nowak"  wrote in message
    news:mailman.999504963.22471.python-list at python.org...
    
    > Un an entirely unrelated note, maybe there should be dictionary
    > comprehensions, too... :)
    >
    > { k,v for k,v in dict if type(v) == type("") }
    >
    > 
    
    I suggested this quite a while ago, but it didn't catch on.
    
    --
    
      Magnus Lie Hetland         http://www.hetland.org
    
     "Reality is that which, when you stop believing in
      it, doesn't go away."           -- Philip K. Dick
    
    
    
    
    From cable40 at hotmail.com  Fri Sep 14 18:48:30 2001
    From: cable40 at hotmail.com (Cable)
    Date: Fri, 14 Sep 2001 22:48:30 GMT
    Subject: Newbie Question..  What is the replacement for the ELSE command?.
    References:  
    Message-ID: <3g15qt4nc8jfg1tcobo2j97ite4pvsthsu@4ax.com>
    
    Thanks for the reply.
    
    The question you asked me, put me on the right track.  I used your
    example. after the second line when I hit return, It starts my 3rd
    line, directly under the second.  I did a dedent region and it worked.
    
    It will take me a while......  its fun though....
    
    thanks for the help.
    
    
    
    
    
    
    On Fri, 14 Sep 2001 22:14:41 GMT, "Maan Hamze" 
    wrote:
    
    >Cable
    >Can you give an exact example of Python code with 'else' that is not
    >working?  Please include all indentations with the code you are using.
    >something that works, say for example:
    >
    >if x==1:
    >  print 'happy'
    >else:
    >  print 'sad'
    >
    >Maan
    >
    >"Cable"  wrote in message
    >news:qiv4qtkbhi5tgeb2knf14m4r5ikh9jesf1 at 4ax.com...
    >> I am trying to teach myself Python.  All the online tutorials, have
    >> examples with the else command.  I cant get it to work is there a
    >> replacement?
    >>
    >> Thanks.
    >
    
    
    
    From ignacio at openservices.net  Fri Sep 14 09:57:18 2001
    From: ignacio at openservices.net (Ignacio Vazquez-Abrams)
    Date: Fri, 14 Sep 2001 09:57:18 -0400 (EDT)
    Subject: evaluate a variable
    In-Reply-To: <9nt218+i3lv@eGroups.com>
    Message-ID: 
    
    On Fri, 14 Sep 2001 dimitry_snezhkov at yahoo.com wrote:
    
    > I just started learning Python. Of, course , reading  output of
    > __doc__
    > is very pleasant. I decided to output documentation for every def in
    > a module. How do I evaluate a variable that is dynamicaly generated.
    > Sort of hello.$bye.see_ya in Perl :
    >
    > Here's my code :
    >
    >     import sys
    >
    >     for each in range(len(dir(sys))):
    >         method='sys' + '.' + dir(sys)[each] + '.' + '__doc__'
    >         ## i cannot do
    >         print method.__doc__
    >         ## this doesn't evaluate method properly.
    >         ## Does eval work in this situation?
    >
    > Also, please, let me know if what I am trying to do is awkward way of
    > doing it. How does Python approach such evaluation.
    
    import sys
    
    for each in dir(sys):
      try:
        print '%s: %s' % (each, getattr(sys, each).__doc__)
        print
      except AttributeError:
        print
    
    -- 
    Ignacio Vazquez-Abrams  
    
    
    
    
    From aleax at aleax.it  Mon Sep  3 06:11:07 2001
    From: aleax at aleax.it (Alex Martelli)
    Date: Mon, 3 Sep 2001 12:11:07 +0200
    Subject: COM/CORBA/DCOP (was: Hello people. I have some questions)
    References:  <9mu5si$9gg$1@pea.uk.research.att.com>
    Message-ID: <9mvkvr01db@enews2.newsguy.com>
    
    "Duncan Grisby"  wrote in message
    news:9mu5si$9gg$1 at pea.uk.research.att.com...
        ...
    > I don't know why people would consider CORBA too heavyweight for
    > connecting desktop apps -- the few performance comparisons between COM
    > and CORBA I have seen show CORBA to be as fast or faster than COM.
    
    For *in-process* interaction?!  There's something askew here... I
    did the measurements myself back around 1994/1995, under Windows/NT,
    using COM (in-process and out-of-process) and Iona's Orbix, which
    Iona claimed was the fastest ORB for NT, and the difference in
    terms of performance overhead was *at least* an order of magnitude
    in favour of COM (using C to program "toy"-level servers and
    clients, instrumented for measuring communication overhead, and
    striving to simulate the kinds of loads our own applications would
    place on a componentization infrastructure).  Have things changed
    so drastically since then?
    
    Now, depending on the kind of interoperation those "desktop apps"
    do in fact use, a slow-down by a factor of 10 or 20 in the
    communication overhead itself may be irrelevant (or else you
    wouldn't see any *Automation* usage on top of COM -- the mostly
    interpretive nature of Automation dispatching does impose at
    least that much extra overhead when compared to down-to-the-
    metal COM on binary interfaces).  But "Corba faster than COM"
    (except any _remoting_ scenario -- I'm *NOT* saying DCOM is a
    match for IIOP, mind you!-) is really news to me.
    
    
    Alex
    
    
    
    
    
    From timr at probo.com  Thu Sep  6 00:42:16 2001
    From: timr at probo.com (Tim Roberts)
    Date: Wed, 05 Sep 2001 21:42:16 -0700
    Subject: Question regarding commenting code
    References: <682EFA0F37A1D511868700B0D0D1AB7A31BBDD@ISTECH4> 
    Message-ID: 
    
    Roman Suzi  wrote:
    
    >On Tue, 4 Sep 2001, Andrew Gould wrote:
    >
    >>When adding comments to scripts, can I insert lines of comments inside a
    >>loop block?  For example:
    >>
    >>for n in a_list:
    >># separate values using spaces as delimiters
    >>	a_line = string.split(n)
    >># get the first value
    >>	a_value = a_line[0]
    >># print the first value
    >>	print a_value
    >
    >This is not good.
    
    However, without judging the moral implications, this IS legal.  I assume
    that was the purpose of the question.
    --
    - Tim Roberts, timr at probo.com
      Providenza & Boekelheide, Inc.
    
    
    From fredrik at pythonware.com  Sun Sep  9 20:01:26 2001
    From: fredrik at pythonware.com (Fredrik Lundh)
    Date: Mon, 10 Sep 2001 00:01:26 GMT
    Subject: os.stat() ?
    References: 
    Message-ID: 
    
    "Agent Drek" wrote:
    > $ touch myfile
    > $ ls -l myfile
    > -rw-r--r--  1 drek  pow  0 Sep  9 17:07 myfile
    >
    > import os, stat
    > print os.stat('myfile')[stat.ST_MODE] & 0777
    >
    > I get '420' from os.stat
    
    >>> oct(420)
    '0644'
    
    
    
    
    
    
    From andy_todd at spam.free.yahoo.com  Tue Sep  4 08:32:04 2001
    From: andy_todd at spam.free.yahoo.com (Andy Todd)
    Date: 4 Sep 2001 12:32:04 GMT
    Subject: newbie question - executing system commands
    References: <9n23h1$qsc$1@news.formus.pl>
    Message-ID: 
    
    "Borzoj"  wrote in
    <9n23h1$qsc$1 at news.formus.pl>: 
    
    >I'm newbie both in shell scripting and pyhon so please be kind :)
    >What would be the Python equivalent for following shell code:
    >
    >for IMAGE_NAME in `ls`; do {
    >#processing of $IMAGE_NAME
    >};done
    >
    >
    >...or in other words what is the easiest way to execute shell
    >command/external program from python and
    >get access to it's output?
    >
    >thx
    >____________
    >This will be your new motto: dance like it hurts, love like you need
    >money, work when pepole are watching.
    >Dogbert
    >
    >
    
    Look at the documentation for the module 'os' - 
    http://www.python.org/doc/current/lib/module-os.html
    
    To convert your example above into Python, try;
    
    >>> for imageName in os.listdir('.'):
    ...     print imageName
    
    at the interactive prompt and see what you get.
    
    -- 
    Content free posts a speciality
    
    
    From thomas.heller at ion-tof.com  Thu Sep 27 07:38:14 2001
    From: thomas.heller at ion-tof.com (Thomas Heller)
    Date: Thu, 27 Sep 2001 13:38:14 +0200
    Subject: Class mutation
    References: <8626rt838oe59d1njrtrisccm0oe02shvf@4ax.com>
    Message-ID: <9ov336$fpp6v$1@ID-59885.news.dfncis.de>
    
    "Dale Strickland-Clark"  wrote in message news:8626rt838oe59d1njrtrisccm0oe02shvf at 4ax.com...
    > Lets say we have a class 'Job' and another class derived from that
    > 'ActiveJob'.
    >
    > I'd like to mutate a Job object into the extended ActiveJob object
    > without re-assigning all the attributes.
    >
    class Job:
        def work(self):
            print "I'm inactive"
    
    class ActiveJob(Job):
        def work(self):
            print "Ok, later"
    
    job = Job()
    
    print job
    job.work()
    
    job.__class__ = ActiveJob
    
    print job
    job.work()
    
    prints:
    
    <__main__.Job instance at 007B5EBC>
    I'm inactive
    
    <__main__.ActiveJob instance at 007B5EBC>
    Ok, later
    
    Thomas
    
    
    
    
    From aleax at aleax.it  Mon Sep  3 11:24:35 2001
    From: aleax at aleax.it (Alex Martelli)
    Date: Mon, 3 Sep 2001 17:24:35 +0200
    Subject: typechecks: just say no! (was Re: Determining Types)
    References:         <9mvo0u04o8@enews2.newsguy.com>        <3b938f31.2123170@nntp.sprynet.com> 
    Message-ID: <9n07bi01ptd@enews1.newsguy.com>
    
    "Skip Montanaro"  wrote in message
    news:mailman.999528483.6865.python-list at python.org...
    >
    > One place that I've actually found typechecking useful is at the boundary
    of
    > my XML-RPC server.  If I'm expecting a string input (say, the name of a
    > band) and someone on the other side inputs "311" to a Perl-based website
    > which then passes the query to my server, I get an integer that I have to
    > coerce back to a string.  In my comments I call it a "Perl guard". ;-)
    
    So why not just use str(whateverthingyyouget) [or the Unicode
    equivalent if Unicode is what you need]?  Beats going around
    with "if type..." (or even "if isinstance..."), IMHO.
    
    [BTW, you'll probably be out of luck if somebody needs a
    band called "0800" -- you'll get some octalized thing, yes?-)]
    
    
    Alex
    
    
    
    
    
    From claysjunkmail at yahoo.com  Sat Sep  1 20:50:58 2001
    From: claysjunkmail at yahoo.com (Clayton Brown - Emmie Osawa)
    Date: 1 Sep 2001 17:50:58 -0700
    Subject: String Comparisons returning score
    Message-ID: <1b9aff84.0109011650.76116213@posting.google.com>
    
    Is there an approved standard library/function/algarithm for comparing
    two similar strings and returning a percentage match?
    
    I am aware of soundEx.py / .c  which is based on the grammar and
    phonetics of words, but from what I have read it seems to be flawed..
    and thus removed from the python standard library.
    
    I have noticed similar techniques in other languages which are based
    on shift matrixes, working out the minimum number of changes to
    transform string A into string B.
    
    I am more looking for one which looks at 
    words/
    chars/
    char-order/
    length/
    similarity
    perhaps omitting spaces, and a common library (the,a,and,mr,mrs......)
    with a weighted scoring mechanism...
    
    Thanks in advance...
    Clayton Brown / Emmie Osawa
    
    
    From ralph at inputplus.demon.co.uk  Thu Sep 27 16:29:52 2001
    From: ralph at inputplus.demon.co.uk (Ralph Corderoy)
    Date: 27 Sep 2001 21:29:52 +0100
    Subject: bsddb3 vs zodb
    References: <3BA9A72A.1D5A6067@yahoo.com> <9opu3g$8cr$1@inputplus.demon.co.uk> <20010927020213.A18855@zot.electricrain.com> 
    Message-ID: <9p0280$plh$1@inputplus.demon.co.uk>
    
    Hi Skip,
    
    > > True.  It's worth noting however that BerkeleyDB 3.3 adds support
    > > for automated "secondary indexing" which really gives it a
    > > significant chunk of capabilities that people often end up using
    > > for full fledged relational databases for. 
    >
    > Can you explain what "secondary indexing" is?  I was never aware I
    > needed it and am using relational databases because of it. ;-)
    
    Have any of your tables got an index built on any column, or
    combination of columns, other than the primary key?
    
    For example, given (user_id, surname) then user_id would be the unique
    primary key.  No two people would have the same user_id.  Your
    relational database can give you a list of all people called `Smith'
    but it would have to do this by sequentially stepping through each row
    examining the row's surname.
    
    If `surname' is made a secondary key then the database will also
    maintain an index of the surnames and you'd have told it they aren't
    unique;  there may be more than one Smith in the world.  Then when you
    ask for all the Smiths it can use the index for the surname secondary
    key to give you the answer much more efficiently.
    
        user_id surname
        5       Smith
        1       Able
        3       Baker
        2       Charlie
        4       Smith
    
        surname user_ids
        Smith   5, 4
        Able    1
        Charlie 2
        Baker   3
    
    
    Ralph.
    
    
    
    From ivo at nospamAmaze.nl  Tue Sep  4 19:34:37 2001
    From: ivo at nospamAmaze.nl (ivo at nospamAmaze.nl)
    Date: 4 Sep 2001 23:34:37 GMT
    Subject: Mapping into two lists
    References: 
    Message-ID: <9n3oed$1i3$1@news1.xs4all.nl>
    
    Marcus Stojek  wrote:
    : Hi,
    
    : I have a sorted list of int.  To generate an input file for
    : a special software I have to split this list into two. Instead of
    : explaining I'll give an example:
    
    : List: [ 1, 3,4,5,6,7, 9, 11,12,13,14,15, 17]
    
    : # start and end value of continuous list segment:
    : Output list1: [3,7, 11,15] 
    : # single values:
    : Output list2: [1,9,17] 
    
    The following code (no map() used) does what you want (if I understand
    correctly what you want :)
    
    l = [1, 3,4,5,6, 9, 11,12,13, 19, 21, 30,31, 77]
    
    singles = []
    ranges = []
    
    cur = [ l[0] ]
    
    for i in l[1:]:
        if i = cur[-1]+1:
            cur.append(i)
        else:
            if len(cur) == 1:
                singles.append(cur[0])
            else:
                ranges.extend([cur[0], cur[-1]])
            cur = [i]
    
    if len(cur) == 1:
        singles.append(cur[0])
    else:
        ranges.extend([cur[0], cur[-1]])
    
    
    'cur' contains the current set you're working on, and it's initialized with
    the first element of the original data. In each iteration, you check if the
    new item 'extends the current set' or 'terminates the current set'. If it
    does the latter, check the size of the set: if it's 1, it's a non-range,
    else it's a range. Then you store them in the singles/ranges lists respectively.
    
    At the end you have to check the reming set of the iteration. (you could
    remove this check by doing 1 extra iteration by adding a guaranteed smaller
    value to the list over which you iterate, i.e. "for i in l[:1] + [-1]",
    or perhaps even [None], but that would ugly IMHO)
    
    Btw, the algorithm will fail on an empty list.
    
    Cheers,
    
    	Ivo
    
    
    -- 
    Drs. I.R. van der Wijk                              -=-
    Brouwersgracht 132                      Amaze Internet Services V.O.F.
    1013 HA Amsterdam                                   -=-
    Tel: +31-20-4688336                          Linux/Web/Zope/SQL
    Fax: +31-20-4688337                           Network Solutions
    Web:     http://www.amaze.nl/                    Consultancy
    Email:   ivo at nospamAmaze.nl                         -=-
    
    
    
    From jsnyder at trelis.com  Wed Sep 19 17:17:15 2001
    From: jsnyder at trelis.com (jsnyder)
    Date: 19 Sep 2001 14:17:15 -0700
    Subject: peek poke for win32
    Message-ID: 
    
    Is there any python library function that will implement a simple
    peek/poke to the PC parallel port, bypassing the HAL.  I did a deja
    news search and only found things from 1998 or earlier.  Hopefully
    someone has done this since then.
    
    Joe Snyder
    
    
    From pinard at iro.umontreal.ca  Sat Sep  8 12:40:09 2001
    From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard)
    Date: 08 Sep 2001 12:40:09 -0400
    Subject: pymacs! :-)
    In-Reply-To: <20010908115146.A935@bestweb.net>
    References: 
    	<6e0ad3b1.0109060128.6c9adc8@posting.google.com>
    	
    	
    	
    	 <20010908115146.A935@bestweb.net>
    Message-ID: 
    
    [Paul Winkler]
    
    > You had written:
    
    > lisp.global_set_key([lisp.f7], lisp.manglers_break_on_whitespace)
    
    > So you want to put all the possible keys in the lisp namespace?  Seems
    > messy.
    
    My knowledge of English fails on me, here.  I do not understand your comment.
    Would you be kind enough to explain?
    
    Maybe you are worried with `[lisp.f7]' ?  There is nothing special with it.
    [item] is a Python list, which yields a LISP vector.  `lisp.f7' merely
    translates to the LISP symbol `f7'.  So, Python `[lisp.f7]' is LISP `[f7]'.
    
    > And what about key combinations?  How would you say something like 'C-x w'?
    > I would suggest simply writing them as strings, and the programmer
    > will have to know the elisp way of naming them.  Example:
    
    > lisp.global_set_key(['C-x w'], lisp.manglers_break_on_whitespace)
    
    In LISP, this would be written:
    
       (global-set-key "\C-xw" manglers-break-on-whitespace)
    
    Triggering this from Python requires that you write the string the
    Python way, and Python does not recognise the "\C-" escape.  Knowing
    that `C-x' is chr(0x18), one could write:
    
       lisp.global_set_key('\x18w', lisp.manglers_break_on_whitespace)
    
    Maybe it could be useful to have a service function to help writing more
    LISP-looking strings in Python?  `pymacs' does not have any service library
    yet, but if the need arise, we can progressively build one.  Maybe there
    would not be much things in it, if any.  Hard to know in advance.
    I'd rather keep the API as bare as possible, if this is reasonable.
    
    -- 
    Fran?ois Pinard   http://www.iro.umontreal.ca/~pinard
    
    
    
    From brian at sweetapp.com  Mon Sep 17 15:16:53 2001
    From: brian at sweetapp.com (Brian Quinlan)
    Date: Mon, 17 Sep 2001 12:16:53 -0700
    Subject: Newbie Question
    In-Reply-To: <000001c15029$b80374c0$aed1bfa8@c6e7e9>
    Message-ID: <001001c13fad$4f9d5e50$445d4540@Dell2>
    
    Mel wrote:
    > My apologies for appearing to complain. I was simply trying to point
    out
    > that I had already done what you suggested, and had said so in my
    original
    > question.
    
    I wasn't the one who answered your question; I just pointed out that you
    were a bit rude to the one who did.
    
    > However, when I use any of the suggested fixes things work just fine.
    > Since I usually need much of the math modeule, my choice is to start
    with
    >          from math import *
    > and similarly for the other modules that I  may need. But the other
    fixes
    > also work.,
    
    I was not critiquing those solutions (though the frequent use of "from x
    import *" statements should be avoided), I'm pointing out a
    misconception that you might have about name lookup:
    
    When python encounters an expression like this:
    
    a()
    
    It does two things:
    
    1. It looks up the object associated with the name "a"
    2. It calls that object
    
    That is why Python said that a name/variable could not be found and not
    a function; step one is only concerned with name lookup, it doesn't know
    anything about the name's usage context.
    
    Cheers,
    Brian
    
    
    
    
    From aahz at panix.com  Sat Sep 22 23:39:35 2001
    From: aahz at panix.com (Aahz Maruch)
    Date: 22 Sep 2001 20:39:35 -0700
    Subject: Realtime capabilities?
    References: 
    Message-ID: <9ojlhn$q1k$1@panix2.panix.com>
    
    In article ,
    Tim Peters  wrote:
    >
    >This means that an Erlang process (unlike a Python thread) can't hog
    >the CPU for a long time (provided the native OS is letting Erlang
    >run).  In addition, the Erlang process scheduler guarantees fairness.
    >Thus, and so long as Erlang is getting cycles, each Erlang process is
    >"guaranteed" to get a timeslice before X seconds have passed (where
    >X depends on lots of stuff, including the total number of Erlang
    >processes running).  A programmer can exploit all that to deliver
    >probabilistic bounds on response time.
    >
    >So "soft" means "no, we can't absolutely guarantee anything, but we've
    >designed the language from the ground up to make it very likely that
    >what we deliver in practice will be 'good enough', and provided you
    >program intelligently in our model".
    
    In other words, if the original poster is doing more than a tiny amount
    of I/O, standard Python/OS threads will probably beat Erlang processes
    for fairness, but if an application is almost completely compute-bound,
    Erlang will probably beat even Stackless Python.
    -- 
                          --- Aahz  <*>  (Copyright 2001 by aahz at pobox.com)
    
    Hugs and backrubs -- I break Rule 6                 http://www.rahul.net/aahz/
    Androgynous poly kinky vanilla queer het Pythonista   
    
    We must not let the evil of a few trample the freedoms of the many.
    
    
    From donn at drizzle.com  Mon Sep 24 00:41:04 2001
    From: donn at drizzle.com (Donn Cave)
    Date: Mon, 24 Sep 2001 04:41:04 -0000
    Subject: Simple process IO capture (Was: "shell-commands" and python!) - process.py (0/1)
    References: <9ogit0$e7c$1@newshost.accu.uu.nl>   
    Message-ID: <1001306463.868543@yabetcha.drizzle.com>
    
    Quoth Paul Moore :
    [ ... pipe & fork wrapper ...]
    
    | I did some looking. The attached is a fairly simple prototype of a module for
    | process handling. The simple examples
    |
    |     >>> output = process.run("echo hello")
    |     >>> print output
    |     hello
    |     >>> print process.run("tr a-z A-Z", input="hello")
    |     HELLO
    |
    | are similar to shell "backticks", with the ability to provide input. There are
    | features to allow merging of stdout and stderr, raise an exception if the
    | command fails (the default action is to continue, but make the return code
    | available as process.retval()), and set teh mode of the pipe (text or binary).
    |
    | It's a fairly simple wrapper around popen2/popen4, but it seems fairly useful to
    | me. Comments anyone?
    |
    | I have ideas to work on this - things like allowing a sequence of strings as the
    | "command", which acts like a Unix pipe (the plumbing is messy to set up, so
    | encapsulating this might be nice...) or maybe some sort of class-based interface
    | (but the simplicity of the examples above is important, and should remain).
    |
    | What do people think? Is this a useful idea?
    
    Sure!  You probably won't be surprised to hear that it has been done
    a couple of times before - because on one hand, it's useful, and as
    you found, it isn't really terribly hard to do.
    
    I don't know if anyone has pushed to get something like this into the
    library.  Haven't looked at yours, but since you're working with popen2,
    I wonder if you could work it up to be submitted as an enhancement to
    that module?
    
    Are you thinking about reading stderr for use in the exception?
    I find that very useful, but deadlock potential with two separate
    input sources will make you earn your pay.
    
    	Donn Cave, donn at drizzle.com
    
    
    From dale at riverhall.NOSPAMco.uk  Wed Sep 12 09:04:02 2001
    From: dale at riverhall.NOSPAMco.uk (Dale Strickland-Clark)
    Date: Wed, 12 Sep 2001 14:04:02 +0100
    Subject: XML using standard Python modules
    Message-ID: 
    
    I'm trying to get to grips with XML using Python.
    
    A simple app to start with, it will read a plain text file containing
    some data, convert it to XML and write an XML file.
    
    Later that file will be used as a random-access data source.
    
    Where do I start?
    
    I'm reading this: http://py-howto.sourceforge.net/xml-howto/SAX.html
    at the moment. Is it up-to-date?
    
    There seems to be half a dozen XML modules. Which is the right one for
    this type of application? XML.SAX?
    
    Thanks for any pointers.
    --
    Dale Strickland-Clark
    Riverhall Systems Ltd
    
    
    From dgrisby at uk.research.att.com  Sun Sep  2 16:47:14 2001
    From: dgrisby at uk.research.att.com (Duncan Grisby)
    Date: 2 Sep 2001 20:47:14 GMT
    Subject: COM/CORBA/DCOP (was: Hello people. I have some questions)
    References: 
    Message-ID: <9mu5si$9gg$1@pea.uk.research.att.com>
    
    In article ,
     Ignacio Vazquez-Abrams   wrote:
    
    >> I don't know anything about DCOP but my guess is that it's closer to
    >> COM than CORBA.  Most people considered CORBA too heavyweight for
    >> connecting desktop apps and were surprised that ORBit (the Gnome ORB)
    >> was able to get as good performance as it does.
    >
    >The difference was that MICO (KDE's ORB) was written in C++, while ORBit is
    >written in C. ORBit has been tweaked and honed to death, whereas they could
    >only do so much for MICO.
    
    There's nothing inherently slow about C++ ORBs. MICO was never
    designed for performance -- indeed its stated design goal is code
    clarity and wide feature range at the expense of performance. Why the
    KDE people didn't pick one of the better-performing C++ ORBs, I don't
    know.
    
    I don't know why people would consider CORBA too heavyweight for
    connecting desktop apps -- the few performance comparisons between COM
    and CORBA I have seen show CORBA to be as fast or faster than COM.
    
    Cheers,
    
    Duncan.
    
    -- 
     -- Duncan Grisby  \  Research Engineer  --
      -- AT&T Laboratories Cambridge          --
       -- http://www.uk.research.att.com/~dpg1 --
    
    
    From ignacio at openservices.net  Fri Sep 14 09:54:56 2001
    From: ignacio at openservices.net (Ignacio Vazquez-Abrams)
    Date: Fri, 14 Sep 2001 09:54:56 -0400 (EDT)
    Subject: Compiling MySQLdb ?
    In-Reply-To: 
    Message-ID: 
    
    On Fri, 14 Sep 2001, Peter Moscatt wrote:
    
    > "ld can't find -lz"
    >
    > ld is installed, so why can't it find -lz ??
    
    Because zlib isn't installed.
    
    -- 
    Ignacio Vazquez-Abrams  
    
    
    
    
    From aleax at aleax.it  Tue Sep 11 06:11:17 2001
    From: aleax at aleax.it (Alex Martelli)
    Date: Tue, 11 Sep 2001 12:11:17 +0200
    Subject: COM/CORBA/DCOP (was: Hello people. I have some questions)
    References:  <_Q2m7.21724$bY5.123263@news-server.bigpond.net.au> <9nahpm0qis@enews1.newsguy.com>  <9nfdb802r3n@enews4.newsguy.com> <6bcn7.35171$bY5.182509@news-server.bigpond.net.au>
    Message-ID: <9nko0601t5j@enews3.newsguy.com>
    
    "Neil Hodgson"  wrote in message
    news:6bcn7.35171$bY5.182509 at news-server.bigpond.net.au...
        ...
    > > >    So you are prepared to not follow the letter of the specification
    for
    > > >    the
    > > > dispatch identifier? (Of course I can argue both sides :-) )
    > >
    > > Absolutely not!  Where are you reading this?!
    >
    >
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/automat/htm
    > _hh2/chap5_61id.asp
    >
    > """dispIdMember
    > Identifies the member. Use GetIDsOfNames or the object's documentation to
    > obtain the dispatch identifier. """
    
    Yes, and the object's documentation (if the object claims to support
    COM and Automation) includes by reference the documentation of the
    COM and Automation standards.  Therefore, by (e.g.) using DISPID_VALUE
    directly as the (attempted) dispatch identifier, I'm following this --
    and I have full right to expect an appropriate HRESULT from Invoke,
    rather than a crash or any other form of exception, if the object
    has no default-property and thus doesn't have any meaningful
    implementation of DISPID_VALUE.
    
    
    Alex
    
    
    
    
    
    From DavidA at ActiveState.com  Wed Sep 19 19:47:42 2001
    From: DavidA at ActiveState.com (David Ascher)
    Date: Wed, 19 Sep 2001 16:47:42 -0700
    Subject: Direct TK interface
    References: <2764949.5mLc6kNg2l@lunix.schabi.de> <3BA7FC3F.D21E3A95@student.gu.edu.au>
    Message-ID: <3BA92E9E.C180B0C@ActiveState.com>
    
    Joal Heagney wrote:
    > 
    > Markus Schaber wrote:
    > >
    > > Hi,
    > >
    > > I was just wondering whether it is possible (and worth in sense of
    > > speed etc.) to directly interface TK into python (without using the TCL
    > > interpreter inbetween).
    > >
    > > markus
    > 
    > Don't know if this is what you want, but you can look up Rivet in the
    > Vaults.
    
    AFAIK, Rivet has been dead since before Tk 8.0
    
    -- David Ascher
       ActiveState
    
       New! ASPN - ActiveState Programmer Network
       Essential programming tools and information
       http://www.ActiveState.com/ASPN
    
    
    
    From joonas at olen.to  Tue Sep 18 08:33:29 2001
    From: joonas at olen.to (Joonas Paalasmaa)
    Date: Tue, 18 Sep 2001 12:33:29 GMT
    Subject: Executing Perl CGI scripts with CGIHTTPServer
    References: <3BA732F2.797D617A@olen.to>
    Message-ID: <3BA73F64.F737CBD9@olen.to>
    
    Joonas Paalasmaa wrote:
    > 
    > How can I use non-Python scripts with CGIHTTPServer.
    > I would like use Python, but in this case I really must use Perl.
    
    Strange. Perl scripts doesn't work on windows but does work on linux.
    I think that this is some kind of os.fork issue.
    
    
    From emile at fenx.com  Fri Sep 28 10:05:16 2001
    From: emile at fenx.com (Emile van Sebille)
    Date: Fri, 28 Sep 2001 07:05:16 -0700
    Subject: How do I distinguish a string from a sequence?
    References: 
    Message-ID: <9p20be$ftrtb$1@ID-11957.news.dfncis.de>
    
    "Paul Moore"  wrote in message
    news:v3v8rtsdmp5ij8bqq7pfndnf6rihm3bujd at 4ax.com...
    > Yes, I know, a string is a sequence...
    >
    > I'm thinking of writing a function which can take either a string, or a
    sequence
    > of strings, as an argument.
    
    As long as you're still thinking about it, you could make the interface
    non-ambiguous ala
    def foo(cmdStr=None, cmdList=None):
    
    > A simplified example would be treating a single
    > string as a 1-tuple - something like
    >
    >    def foo(args):
    >       if # args is a string:
    >          args = (args,)
    >       for arg in args:
    >          print arg
    >
    > But I'm not sure how best to distinguish a string from a sequence
    
    Maybe it's easier then to distinguish a sequence from a string?  ;-)
    
    isinstance(args, .types.ListType)
    
    HTH,
    
    --
    
    Emile van Sebille
    emile at fenx.com
    
    
    
    
    
    From ignacio at openservices.net  Mon Sep 10 17:59:08 2001
    From: ignacio at openservices.net (Ignacio Vazquez-Abrams)
    Date: Mon, 10 Sep 2001 17:59:08 -0400 (EDT)
    Subject: installation fails ?
    In-Reply-To: <9njbdj$ml$1@fstgss02.tu-graz.ac.at>
    Message-ID: 
    
    On Mon, 10 Sep 2001, Armin Samide wrote:
    
    > Hi,
    >
    > I'have downloaded the Python 2.1.1 source code package and wanted to build
    > it on Windows with the Microsoft Visual C Compiler but a few headers are
    > missing, as there are: zlib.h, xmlparse.h, db.h, tcl.h
    > Are these headers included somewhere else or what else is wrong ?
    >
    > thanks,
    > Armin
    
    Python is dependent on a number of external libraries for some of it's
    functionality. You need to get the libraries that contain those files: zlib,
    expat, bsddb, Tcl/Tk, etc.
    
    -- 
    Ignacio Vazquez-Abrams  
    
    
    
    
    From gahanr at gofree.indigo.ie  Sat Sep 15 09:08:34 2001
    From: gahanr at gofree.indigo.ie (Robert Gahan)
    Date: Sat, 15 Sep 2001 14:08:34 +0100
    Subject: Python RE Query. 
    Message-ID: 
    
    Hi all,
    
    I am trying to use Python RE to return the arguements associated with a
    C function signature. Trying to "group" each parameter arguement by use of
    parenthesis.
    
    It does not seem to be working for me !!.
    Can anyone give me a hand ??.
    
    Thans again,
    Rob.
    
    import re
    
    # I am trying to create a regular expression such that if given a C
    signature, I can
    # extract all of the parameter arguements
    # e.g. for int print_date(char *date, char *month, char *year);
    # I return say the following tuple -> ("char *date", "char *month",  "char
    *year")
    
    # The example below (tries to use !) groups where a given group would be
    populated
    # with each arguement. It only seems to match the last arguement.
    # ... Can this apprach work ??.
    # ... How can I get a match on all of the arguements ???.
    
    args_from_signature = re.compile("^.* [\w]*?[(]((([^,]*?)[,]+)*?)[)][;]+",
    re.DOTALL)
    
    a = args_from_signature.match("int gg(int y);")
    b = args_from_signature.match("int gg(int y, int z, int y, int p);")
    c = args_from_signature.match("int ggz;")
    
    print a
    print b
    print b.groups()
    
    
    
    
    
    From tim at vegeta.ath.cx  Tue Sep 11 04:33:52 2001
    From: tim at vegeta.ath.cx (Tim Hammerquist)
    Date: Tue, 11 Sep 2001 08:33:52 GMT
    Subject: Python and Zope
    References:  <9nettc$ce1$1@slb7.atl.mindspring.net>         
    Message-ID: 
    
    Me parece que Oleg Broytmann  dijo:
    > On Mon, Sep 10, 2001 at 11:30:12PM +0000, Tim Hammerquist wrote:
    > > >    We are talking about "Apache vs web-application servers". In this
    > > > context modules are so like CGIs (forked and killed) so I don't need to
    > > > make a distinction.
    > > 
    > > We probably just have a Point-Of-View problem.  I'm thinking of CGI in
    > > the strict sense of an application designed to produce web content using
    > > STD filehandles and environment variables.  In all fairness, my ftpd
    > > conforms to your (most recent) definition of CGI, as do half of the
    > > daemons on my system.
    > 
    >    In this "web-application server" context - they are! :) Because thay
    > cannot hold a persistent DB connection.
    
    I don't remember persistence of DB connections being mentioned in the
    CGI spec.  I don't believe databases are mentioned at all.
    
    The fact that they are not constantly running indefinitely does *not*
    make them a subset, superset, or *any* kind of set of the Common
    Gateway Interface.
    
    In fact, to find a list of files on any system that qualify as CGI's
    according to your most recent definition, just run the following command:
    
    $ find / | grep -v 'mod_'
    
    > > I probably took offense to the picture you painted of Apache, being a
    > > ruthless, discompassionate Nazi of a daemon, kill arbitrarily, which
    > > is, of course, not true.
    > 
    >    If I have a module that have opened DB connection - how can I prevent
    > Apache from killing the child (because I want to hold that connection
    > open)?
    
    Apache's process housekeeping is neither ruthless, nor arbitrary, nor
    random (in any sense I've ever been aware of).
    
    If nothing else, your tirade reflects your dislike of Apache's
    housekeeping methods, and your disapproval of mod_(perl|python)'s
    handling of persistent db connections.
    
    However, your, shall we say, "flexibility" with the meaning of words is
    reminiscent of Humpty Dumpty: "Words mean whatever I want them to mean."
    Nevertheless, you have a luminous future in Microsoft's marketing
    division.
    
    With that in mind, what does the word *plonk* mean to you?
    
    -- 
    I am following my fish.
        -- Delirium, The Sandman
    
    
    From unknown at lee-morgan.net  Sun Sep 30 21:37:47 2001
    From: unknown at lee-morgan.net (Lee Morgan)
    Date: Mon, 01 Oct 2001 01:37:47 GMT
    Subject: How do Java interfaces translate to Python?
    References:   
    Message-ID: 
    
    Gordon Tyler  writes:
    
    > In article , Martin von Loewis
     wrote: 
    > > What exactly is it that you do with interfaces in Java?
    > 
    > Enforcing a contract between objects, i.e. if you want to work with this
    > object, your object must implement this interface.
    > 
    > I find myself unable to think of anything other than that. Which suggests
    > to me that perhaps interfaces aren't such a useful construct after all. ;)
    > 
    > I suppose the thing I'm really missing is compile-time type safety. Yes I
    > know that Python is a dynamically typed language and as such compile-time
    > type safety, compiling even, make no sense. But do you have any
    > suggestions for somebody used to compiled languages on how to deal with a
    > dynamically typed language like Python? I find myself making silly
    > syntactical mistakes which I just don't see when I visually scan the code,
    > and when I run the program it suddenly barfs in the middle of nowhere with
    > a syntax error. Very frustrating. Especially, if it takes a few minutes
    > and interaction from me to get to that point.
    > 
    
    Yeah, I've often got caught out by this myself. Also silent name bindings to
    classes (which you sometimes want) got me recently.
    
    There is a PEP for an interface enhancement, but its a still a dynamic
    enforcement, so instead of 
    
    Traceback (innermost last):
      File "", line 1, in ?
    Interface.Exceptions.BrokenImplementation:
    An object has failed to implement interface FishMarketInterface
    
    you would get
    
    Traceback (most recent call last):
      File "", line 1, in ?
    AttributeError: 'm' instance has no attribute 'getFishMonger'
    
    which to my mind isn't an improvement.
    
    If interfaces aren't checked at byte-compile time surely they just become a code
    documentation feature - perhaps useful to utils like pychecker but unlikely to
    get regular use.
    
    (Granted I've only just started looking at Interfaces in python as I wanted to
    stop getting bitten in the arse, even if they were my teeth - but interface's as
    suggested in the PEP don't seem to address the problem)
    
    Some wistful folks on this list purport the idea that python programmers need
    to know what they're doing so they don't need any sort ot type checking. Whilst
    this could well be true, under the hot iron of commercial development you need
    to come back to old code, quickly understand it, and be confident in making
    changes. Yes you could unit test extensively, but some situations make this
    tricky (gui apps for example).
    
    Anyway, sorry about the rant - I wanted interfaces to help me with the same
    problem you're having and I'm confused they wont. I'd hate to loose Pythons
    dynamic nature, but sometimes I want a little support.
    
    But, given python's lisp like dynamism you can enforce your own with varying
    degrees of success. One caveat - I'm still playing with ways to do this as my
    understanding of python grows and haven't found one I really like. Also the
    recently added inspect.py module can help here.
    
    # This class raises error if attr not one set in init func
    # It won't help complex objects, ie when __setattr__ isnt called
    class _base:
        initialising = 1
        def __init__(self):
            self.attrONE = 1
            self.initialising = 0
        def __str__(self):
            return str(self.attrONE) + str(self.initializing)
        def __setattr__(self,attr,value):
            if self.initialising:
                self.__dict__[attr] = value            
            else:
                if self.__dict__.has_key(attr):
                    self.__dict__[attr] = value
                else:
                    raise self.__class__.__name__ + " does not have attr " + attr
        def foo(self):
            pass
    
    me = _base()
    me.attrONE = 3
    me.attrONE = 5
    me.attrOEN = 4	# error raised
    
    # check some attr
    def enforceInterface(instance, requiredAttr = ['foo','foo2']):
      for attr in requiredAttr:
        if not hasattr(instance,attr):
          raise instance.__class__.__name__ + " is missing attribute " + attr
    
    #check at top level
    enforceInterface(me) # error on foo2
    
    
    
    -- 
    Lee Morgan
    
    
    From mertz at gnosis.cx  Mon Sep  3 15:18:42 2001
    From: mertz at gnosis.cx (Lulu of the Lotus-Eaters)
    Date: Mon, 03 Sep 2001 15:18:42 -0400
    Subject: Is 0 > None?? (fwd) (fwd)
    Message-ID:                 
    
    "Alex Martelli"  wrote:
    > >>> u'cia?'<'cia?'
    > Traceback (innermost last):
    >   File "", line 1, in ?
    > UnicodeError: ASCII decoding error: ordinal not in range(128)
    
    |Well, yes -- though the problem is not with the Unicode strings
    |(as I've shown, you can perfectly well compare them to anything:-)
    |The issue, it seems to me, is quite different wrt complex
    |numbers -- in that case, there is _no_ setting that lets you
    |default-sort an heterogeneous list that may contain a complex
    |number somewhere.  The Unicode issue might be finessed in
    |several ways.  The complex-number one is starker IMHO.
    
    I don't understand the differenence Alex points to.  For example, the
    below cases seem awfully similar:
    
        >>> # Try to sort Unicode values in list
        >>> lst = [ 128, chr(128), unichr(128), 'a' ]
        >>> lst
        [128, '\x80', u'\x80', 'a']
        >>> lst.sort()
        Traceback (most recent call last):
          File "", line 1, in ?
        UnicodeError: ASCII decoding error: ordinal not in range(128)
        >>> # Try to sort complex numbers in list
        >>> l2 = [ 1, 1.0, 1+1j ]
        >>> l2
        [1, 1.0, (1+1j)]
        >>> l2.sort()
        Traceback (most recent call last):
          File "", line 1, in ?
        TypeError: cannot compare complex numbers using <, <=, >, >=
    
    What can I do to get 'lst' to sort properly?  If the answer is to use a
    custom comparison function, I can do likewise with complex numbers.  I
    suppose one could say the problem was with the 'chr(128)' element rather
    than the 'unichr(128)' element... but such a characterization doesn't
    particularly bring a solution closer.
    
    Yours, Lulu...
    
    P.S. The thing that could be fixed in a later Python is the
    non-universal comparison... we are stuck with 'print >>' for backwards
    compatibility.
    
    
    
    From warkid at storm.ru  Fri Sep  7 03:48:24 2001
    From: warkid at storm.ru ( Kerim Borchaev ( WarKiD ) )
    Date: Fri, 7 Sep 2001 11:48:24 +0400
    Subject: Customizing module globals
    In-Reply-To: 
    References: 
    Message-ID: <7491.010907@storm.ru>
    
    Thursday, September 06, 2001, 11:11:43 PM, Terry Reedy answered my
    question:
    >> Can I specify what module's to be imported symbol table will be?
    >>
    >> Say I have a module named Module that assumes that there's an object
    >> Object without implicit declaration like this :
    >>
    >> Module.py
    >> ----------------
    >> Object.doThings()
    >> ----------------
    >>
    >> And I can import/run this module with specific a Object?
    
    TR> You can set module attributes in the obvious manner.
    
    TR> import module
    TR> module.Object = 
    
    But te problem is that import fails...
    
      File "ModuleUser.py", line 1, in ?
        import Module
      File "Module.py", line 1, in ?
        Object.doThings()
      NameError: name 'Object' is not defined
    
    Best regards,
     Kerim                            mailto:warkid at storm.ru
    
    
    
    
    
    From markus at schabi.de  Mon Sep 17 08:52:32 2001
    From: markus at schabi.de (Markus Schaber)
    Date: Mon, 17 Sep 2001 14:52:32 +0200
    Subject: Proposed PEP for a Conditional Expression
    References:  <9nidrm01j7q@enews1.newsguy.com> <23891c90.0109130146.60a98909@posting.google.com> <3ba21452$0$51376$edfadb0f@dspool01.news.tele.dk>
    Message-ID: <1081165.6gNhbJn0HT@lunix.schabi.de>
    
    Hi,
    
    maxm  schrub:
    
    > Besides ... what could be simpler than using the fact that booleans in
    > Python is either 1 or 0:
    > 
    > #################################
    >>>> a=3
    >>>> b=4
    >>>> print ('number two', 'number one')[a < b]
    >>>> number one
    
    This does not short-cirquit evaluate.
    
    > or if you want to get the result of a functionwith only the choosen
    > function evaluated:
    > 
    > #################################
    >>>> def n1():
    >>>>     return 'Number one'
    >>>> def n2():
    >>>>     return 'Number two'
    >>>> print (n2, n1)[a < b]()
    >>>> Number one
    > 
    > Any sane Python programmer will grasp those IMMEDIATELY!
    
    That does short-cirquit, but has limits on the expressions you can use 
    as n1 and n2 (may be that gamma and nested scopes help here).
    
    markus
    
    -- 
    "The strength of the Constitution lies entirely in the determination of 
    each citizen to defend it. Only if every single citizen feels duty 
    bound to do his share in this defense are the constitutional rights 
    secure." -- Albert Einstein
    
    
    From sholden at holdenweb.com  Wed Sep 12 20:08:25 2001
    From: sholden at holdenweb.com (Steve Holden)
    Date: Wed, 12 Sep 2001 20:08:25 -0400
    Subject: [OT] Strange IE5.5 Caching Behavior
    References: 
    Message-ID: 
    
    "Ignacio Vazquez-Abrams"  wrote in message
    news:mailman.1000171888.20415.python-list at python.org...
    > On Mon, 10 Sep 2001, Steve Holden wrote:
    >
    > > Sorry about this post being off-topic, but c.l.py is the largest
    collection
    > > of web-heads I have easy access to. If you know nothing about HTTP,
    please
    > > ignore this.
    > >
    [description of puzzling browser failure to use Last-Modified headers
    appropriately]
    > >
    > > regards
    > >  Steve
    >
    > What is the clock skew between the client and server?
    >
    I have *no* idea why, but suddenly IE5 is quite happily causing the server
    code to generate 301 responses for graphics that have not been modified. Who
    knows why the problem occurred in the first place?
    
    don't-you-just-hate-it-when-you-don't-discover-the-problem-ly y'rs  - steve
    --
    http://www.holdenweb.com/
    
    
    
    
    
    
    From peter at engcorp.com  Fri Sep  7 10:02:05 2001
    From: peter at engcorp.com (Peter Hansen)
    Date: Fri, 07 Sep 2001 10:02:05 -0400
    Subject: how to run python script from Unix Shell?
    References:  <3B983E3A.139A8B71@engcorp.com> <3B98C6DF.FCC22D4E@student.gu.edu.au>
    Message-ID: <3B98D35D.AE6F52D0@engcorp.com>
    
    Joal Heagney wrote:
    > 
    > Peter Hansen wrote:
    > > The other problem could be that your python is not
    > > really in /usr/bin (type "which python" to be sure)
    > > but then your error message would say:
    > >
    > > bash: ./test.py: No such file or directory
    > >
    > > (This all on Red Hat release 7.1.)
    > 
    > If this is so, you may want to try the magic hack
    > #!/usr/bin/env python
    
    Would this find the executable if it were not in the
    path somewhere else?  If not, then it doesn't solve
    the possible problem I described above.
    
    Besides, then you have a bunch of scripts with 
    non-conventional stuff in the first line, instead of
    the "standard" #!/usr/bin/python.  Probably better
    to just fix the environment to work with that, so 
    you don't have to rewrite scripts you download, or
    modify scripts you upload...
    
    -- 
    ----------------------
    Peter Hansen, P.Eng.
    peter at engcorp.com
    
    
    From pinard at iro.umontreal.ca  Tue Sep  4 14:25:19 2001
    From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard)
    Date: 04 Sep 2001 14:25:19 -0400
    Subject: pymacs! :-)
    In-Reply-To: 
    References: 
    	
    Message-ID: 
    
    > > Second, I'd like to find a way for any function or variable
    > > which is not defined in Python to be resolved within Emacs if
    > > possible: the idea is to use Emacs elegantly from Python, using
    > > Python syntax for function calls, without explicitly resorting to
    > > `eval_lisp("LISP-EXPRESSION")'.
    
    [Marcin 'Qrczak' Kowalczyk]
    
    > I would use something like
    >     lisp.variable_name
    > where lisp is an object with a suitable __getattr__.
    
    This traversed my mind.  I wanted to avoid such `lisp.' prefix, a bit
    because they might become cumbersome, but mostly because they force users
    to well remember if a function is implemented in LISP or not, and I would
    prefer that this be made a transparent implementation detail.
    
    On the other hand, thinking again about it, I wonder why I hesitate using
    `emacs.point()', when it does not bother me to write `string.join(...)'.
    There is indeed some name-space cleanliness at sticking to such prefixes.
    I'll think more on this.  Thanks for the triggering!
    
    -- 
    Fran?ois Pinard   http://www.iro.umontreal.ca/~pinard
    
    
    
    From ignacio at openservices.net  Mon Sep 17 01:59:36 2001
    From: ignacio at openservices.net (Ignacio Vazquez-Abrams)
    Date: Mon, 17 Sep 2001 01:59:36 -0400 (EDT)
    Subject: Getting all possible combinations of list items
    In-Reply-To: <3ba58893$0$330$6e49188b@news.goldengate.net>
    Message-ID: 
    
    On Mon, 17 Sep 2001, Greg Krohn wrote:
    
    > Does anyone know of how I should go about generating a list whose keys are
    > all the possible combinations of the items in another list?
    > e.g.
    >
    > another_list = ['a', 'b', 'c']
    >
    > magic_algorithm(another_list) -> ['aa', 'ab', 'ac', 'ba', 'bc', 'bc', 'ca',
    > 'cb', 'cc']
    >
    > I know I could do this easily with nested 'fors', but that requires me to
    > know the length of the set. Is this a case for recursive functions? I hope
    > not, those things scare me. BTW, each item in another_list will be unique,
    > if that matters.
    
    This solution treats the items in listin as values in a number system with the
    radix equal to the number of items in the list and the number of positions in
    count:
    
    ---
    def magic_algorithm(listin, count):
      for i in listin:
        if type(i)!=type(''):
          raise TypeError, 'all items in list passed to magic_algorithm must be strings'
      l=len(listin)
      return map(''.join, map(lambda x, count=count, l=l, listin=listin: map(lambda y, x=x, count=count, l=l, listin=listin: listin[((x/(l**y)) % l)], range(count)), xrange(l**count)))
    ---
    
    ---
    >>> magic_algorithm(['a', 'b', 'c'], 2)
    ['aa', 'ba', 'ca', 'ab', 'bb', 'cb', 'ac', 'bc', 'cc']
    >>>
    ---
    
    -- 
    Ignacio Vazquez-Abrams  
    
    
    
    
    From ignacio at openservices.net  Mon Sep 17 12:11:06 2001
    From: ignacio at openservices.net (Ignacio Vazquez-Abrams)
    Date: Mon, 17 Sep 2001 12:11:06 -0400 (EDT)
    Subject: PEP proposal for round(x,n) enhancement
    In-Reply-To: <1226862.F50zNuYjNa@lunix.schabi.de>
    Message-ID: 
    
    On Mon, 17 Sep 2001, Markus Schaber wrote:
    
    > Tim Peters  schrub:
    >
    > > BTW, complex numbers still have no meaning to round(), so you could
    > > use round(x, 3j) to mean "round to 3 significant digits" .
    >
    > Ouch.
    >
    > This "solutions" needs rather complex programmer brains :-)
    
    Naw, just multiply by -1j and take the real component.
    
    -- 
    Ignacio Vazquez-Abrams  
    
    
    
    
    From pobrien at orbtech.com  Wed Sep 12 21:24:12 2001
    From: pobrien at orbtech.com (Patrick K. O'Brien)
    Date: Thu, 13 Sep 2001 01:24:12 GMT
    Subject: ANNOUNCE: PyCrust 0.6 is fresh out of the oven!
    Message-ID: <0VTn7.3722$lE3.353067@newsread2.prod.itd.earthlink.net>
    
    PyCrust 0.6 is available for tasting. In particular, PyCrust now
    comes with PyShell and PyFilling.
    
    PyCrust - The Flakiest Python Shell
    Half-baked by Patrick K. O'Brien (pobrien at orbtech.com)
    ======================================================
    
    What is PyCrust?
    ----------------
    PyCrust is an interactive Python environment written in Python.
    PyCrust components can run standalone or be integrated into other
    development environments and/or other Python applications.
    
    PyCrust comes with an interactive Python shell (PyShell), an
    interactive namespace/object tree control (PyFilling) and an
    integrated, split-window combination of the two (PyCrust).
    
    
    What is PyCrust good for?
    -------------------------
    Have you ever tried to bake a pie without one? Well, you
    shouldn't build a Python program without a PyCrust either.
    
    
    Where can I get the latest release of PyCrust?
    ------------------------------------------------------------
    The latest PyCrust releases are available at:
    http://sourceforge.net/project/showfiles.php?group_id=31263
    
    
    What else do I need to use PyCrust?
    -----------------------------------
    PyCrust requires Python 2.1 or later, and wxPython 2.3.1 or later.
    PyCrust uses wxPython and the Scintilla wrapper (wxStyledTextCtrl).
    Python is available at http://www.python.org/.
    wxPython is available at http://www.wxpython.org/.
    
    ---
    Patrick K. O'Brien
    Orbtech (http://www.orbtech.com)
    "I am, therefore I think."
    
    
    
    
    
    From cce at clarkevans.com  Fri Sep  7 08:59:01 2001
    From: cce at clarkevans.com (Clark C . Evans)
    Date: Fri, 7 Sep 2001 08:59:01 -0400
    Subject: list comprehensions: sorting?
    In-Reply-To: <9na4190avo@enews1.newsguy.com>; from aleax@aleax.it on Fri, Sep 07, 2001 at 11:29:12AM +0200
    References:  <9n7aim020of@enews1.newsguy.com>  <9na4190avo@enews1.newsguy.com>
    Message-ID: <20010907085901.A25254@doublegemini.com>
    
    On Fri, Sep 07, 2001 at 11:29:12AM +0200, Alex Martelli wrote:
    | And if you can think of some 'orderby' syntax that 
    | would actually cover ALL typical sorting needs with 
    | just "a bit" of extension to the current one, we could
    | surely write a PEP for it -- but it would HAVE to be
    | "just a bit" (of extra syntax), and for very wide generality 
    | gains, or the trade-off is a losing one, I fear.
    
    Consider the following pattern...
    
       [ vSelect for vAs in vFrom if vWhere sortby vOrder ]
    
    This could be expanded into a farily generic processing
    template where vOrder is any expression..
    
      sortby = 1
      temp = []
      for vAs in vFrom:
          if vWhere:  
              val = process(x)
              if sortby: val = (vOrder,val) 
              temp.append(val)
      if sortby:
          temp.sort()
          if is_desc: temp.reverse()
          sorted = []
          for x in temp: sorted.append(x[1])
          temp = sorted
      return temp
    
    The primary problem is that sort has a few "arguments",
    as to sort descending/ascending or to do a stable sort;
    how about taking a function like syntax? sortby(desc,stable)
    
    Thoughts?
    
    Clark
    
    
    
    P.S. I also had a very fuzzy idea in my head about
         a syntax extension registry function.  This may
         be way too powerful; but it appears all of the
         list extensions could be expressed as re-writes
         of the parse tree (before compile).  So, we could
         add a function like...
    
         register regex, rewrite_function
    
         In this way "statements" which were not recognized
         by the parser would be passed through the regex of
         each registered rewrite rule.  If the rewrite matched,
         then the rewrite_function would be called on the 
         statement at compile time to produce a representation
         that is in the core language.
    
         Pretty powerful... probably too powerful.
         
    
    
    
    From ignacio at openservices.net  Mon Sep 17 00:00:17 2001
    From: ignacio at openservices.net (Ignacio Vazquez-Abrams)
    Date: Mon, 17 Sep 2001 00:00:17 -0400 (EDT)
    Subject: How to parse XHTML with xml.parsers.xmlproc?
    In-Reply-To: <873d5mo5cz.fsf@zazu.vip.fi>
    Message-ID: 
    
    On 17 Sep 2001, Paavo Hartikainen wrote:
    
    > I managed to understand enough of the xml.parsers.xmlproc to feed data
    > to it.  File I am trying to parse is valid XHTML but I have not
    > managed to make my xmlproc.XMLProcessor to parse according to correct
    > DTD in file "DTD/xhtml1-strict.dtd".
    
    You might want to try the 4Suite mailing list:
    
      http://lists.fourthought.com/mailman/listinfo/4suite
    
    -- 
    Ignacio Vazquez-Abrams  
    
    
    
    
    From rnd at onego.ru  Sat Sep  8 02:12:04 2001
    From: rnd at onego.ru (Roman Suzi)
    Date: Sat, 8 Sep 2001 10:12:04 +0400 (MSD)
    Subject: Pythonwin and .NET
    In-Reply-To: <3B997A5E.6010801@bigpond.net.au>
    Message-ID: 
    
    On Sat, 8 Sep 2001, Mark Hammond wrote:
    
    >Maan Hamze wrote:
    >
    >> This is a question for Mark Hammond.
    
    >I honestly do not know where Python and Perl really will fit in this new
    >world.  .NET imposes certain requirements on programs, so that the
    >benefits of .NET can be realized.  However, these requirements can often
    >work against languages such as Python.  The dynamic and introspective
    >nature of Python is unlikely to be able to be exploited, unless .NET
    >itself grows these same capabilities - and when .NET grows them, we can
    >expect C# to also grow them.
    
    I thought .NET has some kind of assembly-like bytecode, so Python could
    just compile into it (like Jython to Java's).  If this is not true and
    .NET's lowest level is higher than Java's bytecode level, .NET will not
    make serious impact. Nobody will buy single highlevel language platform
    even from MS. (However, who could imagine several years ago that MS
    Windows will be 95% on the desktops?). No. This will not happen with
    developers!
    
    Sincerely yours, Roman Suzi
    -- 
    _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
    _/ Saturday, September 08, 2001 _/ Powered by Linux RedHat 6.2 _/
    _/ "Aren't cats just widdle furry balls of love?" _/
    
    
    
    
    From aleax at aleax.it  Fri Sep  7 12:42:47 2001
    From: aleax at aleax.it (Alex Martelli)
    Date: Fri, 7 Sep 2001 18:42:47 +0200
    Subject: Nested scopes: why is it weird?
    References: <3B98F3B0.53AC2524@swiftview.com>
    Message-ID: <9nated01mmc@enews2.newsguy.com>
    
    "Scott Long"  wrote in message
    news:3B98F3B0.53AC2524 at swiftview.com...
    > Nested scopes seem like a nice addition (of course!) but there are some
    > weird things about it. Take a look:
    >
    > >>> from __future__ import nested_scopes
    > >>> def a():
    > ...   def b():
    > ...     k = x
    > ...     print k
    > ...   x = 1
    > ...   b()
    > ...
    > >>> a()
    > 1
    >
    > Right, this is what you would expect. But how about this?
    >
    > >>> from __future__ import nested_scopes
    > >>> def a():
    > ...   def b():
    > ...     k = x
    > ...     x = 0
    > ...     print k
    > ...   x = 1
    > ...   b()
    > ...
    > >>> a()
    > Traceback (most recent call last):
    >   File "", line 1, in ?
    >   File "", line 7, in a
    >   File "", line 3, in b
    > UnboundLocalError: local variable 'x' referenced before assignment
    >
    > Here is my explanation for this (tell me if I'm wrong):
    >
    > During pass #1 of compilation, the statement "x = 0" in b() binds x as a
    > local variable local to b(). During execution, k = x executes *before* x
    > has been assigned, resulting in this flamage.
    >
    > My first beef here is, why is the exception called UnboundLocalError?
    > The variable is certainly bound (into the local scope), it simply has
    > not been assigned. Why not call it UninitializedLocalError? I know it
    > isn't going to change, I'm just asking.
    >
    > But my main concern is that this way of selecting a binding seems very
    > unintuitive. Shouldn't the first statement referencing x be the
    > statement that specifies the binding of x? In this case, shouldn't "k =
    > x" cause x to get bound as a free variable, not a local to b()? I'm not
    > claiming that this is a bug. I am curious as to why it was decided that
    > things are going to work this way. It makes assignment to a variable in
    > an enclosing scope impossible!
    >
    > Regards,
    > Scott
    
    
    
    
    From markus at schabi.de  Fri Sep 14 05:34:53 2001
    From: markus at schabi.de (Markus Schaber)
    Date: Fri, 14 Sep 2001 11:34:53 +0200
    Subject: Proposed PEP for a Conditional Expression
    References:  <3BA00239.DECE6412@cosc.canterbury.ac.nz>  
    Message-ID: <5293894.qXVLH7GnMW@lunix.schabi.de>
    
    Hi,
    
    Gareth McCaughan  schrub:
    
    > It isn't exactly like C, because the C syntax doesn't
    > abuse the word "if". If you use words from a natural
    > language, it is best to use them in a way reasonably
    > compatible with that language. " if  ..."
    > completely fails this test, and I too think it could only
    > appeal to someone who'd got used to it by programming in
    > Forth.
    
    What about "(: return  [else return :  [else ])" would be usable.
    
    In my thinking of natural and mathematical language, the : is a way of 
    indicating that the condition proposes the expression.
     
    markus
    -- 
    "The strength of the Constitution lies entirely in the determination of 
    each citizen to defend it. Only if every single citizen feels duty 
    bound to do his share in this defense are the constitutional rights 
    secure." -- Albert Einstein
    
    
    From smt at pacific.net.hk  Thu Sep 13 11:10:13 2001
    From: smt at pacific.net.hk (Kenneth Tsang)
    Date: Thu, 13 Sep 2001 23:10:13 +0800
    Subject: MUDs...
    References: 
    Message-ID: <9nqic4$and$1@hfc.pacific.net.hk>
    
    hi, I come across this. - Pythonic MOO
    http://www.strout.net/python/poo/index.html
    
    KT
    --
    
    --
    Kenneth Tsang
    email: smt at pacific.net.hk tel: +852 9468 4772
    "Vincent A.Primavera"  wrote in message
    news:mailman.1000384156.22009.python-list at python.org...
    > Hello,
    > A while ago on the list, Python based MUDs were discussed.  Does anyone
    have any suggestions as to
    > which were/are recommended?
    >
    > Thank you,
    > Vincent A. Primavera.
    >
    
    
    
    
    From niemeyer at conectiva.com  Wed Sep  5 12:06:27 2001
    From: niemeyer at conectiva.com (Gustavo Niemeyer)
    Date: Wed, 5 Sep 2001 13:06:27 -0300
    Subject: string.split
    In-Reply-To: <9n4lj3014la@enews1.newsguy.com>; from aleax@aleax.it on Wed, Sep 05, 2001 at 09:52:02AM +0200
    References:  <9n4lj3014la@enews1.newsguy.com>
    Message-ID: <20010905130627.A6283@tux.distro.conectiva>
    
    Hi there!
    
    > > set a literal string that is the seperator. How do I split on any or all
    > > occurrences of (for example) whitespace and a comma, without using
    > regexes.
    > > I mean string.split() must be able to do it anyway to achieve the default
    > > behaviour.
    > 
    > Nope -- look at objects/stringobject.c: string_split specialcases out
    > a call to split_whitespace when the splitter argument is missing or
    > None, and split_whitespace uses C's isspace to check for splitting.
    > 
    > I think it's a reasonable feature-request to wish for split to be
    > able to split on any one of several strings (e.g., make it callable
    > with several string arguments, or maybe with an argument that's a
    > sequence of strings), but feature-request it is -- it would need
    > additional code in stringobject.c.  So, you're advised to submit it
    > as a feature request to sourceforge.
    
    Don't waste your time. I thought this would be a resonable feature and
    implemented a splitlist() method for strings, doing exactly this. After
    some discussions, it has been decided by the python crew that re.split
    was enough and adding a new functionality like this would "bloat" the
    code.
    
    If you want more information about this, have a look at python's patches
    at sourceforge. If you can't find it and want me to send the patch for
    research purposes, let me know.
    
    -- 
    Gustavo Niemeyer
    
    [ 2AAC 7928 0FBF 0299 5EB5  60E2 2253 B29A 6664 3A0C ]
    
    
    
    From skip at pobox.com  Fri Sep  7 00:25:39 2001
    From: skip at pobox.com (Skip Montanaro)
    Date: Thu, 6 Sep 2001 23:25:39 -0500
    Subject: How to convert a time object from MS Access database to string
    In-Reply-To: <3B98B2E5.21359.BE999F@localhost>
    References: 
            <3B98B2E5.21359.BE999F@localhost>
    Message-ID: <15256.19523.166611.249868@localhost.localdomain>
    
        Ng> How I can convert a time object read from the MS Access Database to
        Ng> a string.
    
        Ng> I checked the PyTime Object and used the example as follows:
    
        Ng>   rdate = time.localtime(int(rec[3]))
    
        Ng> but got the following error:
    
        Ng>   TypeError: object can't be converted to int
    
    Well, obviously rec[3] doesn't look like an integer.  What does it look like
    if you just print it out?  If it looks like a complex date/time sort of
    thing like 
    
        Thu April 1 2001 10:38
    
    you can probably parse it with time.strptime or use the functions available
    in Marc-Andre Lemburg's mx.DateTime module to parse it.
    
    -- 
    Skip Montanaro (skip at pobox.com)
    http://www.mojam.com/
    http://www.musi-cal.com/
    
    
    
    From lac at strakt.com  Thu Sep 27 07:02:05 2001
    From: lac at strakt.com (Laura Creighton)
    Date: Thu, 27 Sep 2001 13:02:05 +0200
    Subject: return command in a function. 
    In-Reply-To: Your message of "Thu, 27 Sep 2001 01:44:10 GMT."
    Message-ID: <200109271102.f8RB25Ev005796@ratthing-b246.strakt.com>
    
    Brian Lee:
    > I think that commands are like ``goto'' It is very confused for me to 
    > understand big code because such commands jump un-excepted line.
    
    'un-excepted'?
    
    1. Do you mean `The code jumps in ways I don't _expect_'?  
    or
    2. `The code should use the python Exception mechanism, but doesn't.'
    
    If 1. you are probably confusing cause and effect.  The code is bad,
    and _in addition_ it uses breaks and continues, and has a return 
    statement in the middle of it.  Rewrite it.  Since it's 'big code'
    try rewriting it _smaller_ in _more pieces_. Perhaps it could benefit
    from being more Object-Oriented; without seeing it I can't tell, but
    that is often the case with huge pieces of code that return in many 
    different places.  
    
    If 2. Very likely.
    
    Laura Creighton
    
    
    
    From BPettersen at NAREX.com  Thu Sep 27 13:03:01 2001
    From: BPettersen at NAREX.com (Bjorn Pettersen)
    Date: Thu, 27 Sep 2001 11:03:01 -0600
    Subject: file find module
    Message-ID: <6957F6A694B49A4096F7CFD0D900042F6C9E59@admin56.narex.com>
    
    > From: mallum [mailto:breakfast at 10.am]
    > 
    > Hi all;
    > 
    > Does a module exist ( pref in standard dist ) that will recursively
    > search directorys for filenames matching a certain pattern ( like
    > Perl's File::Find ) - or will I have to write something for scratch ?
    
    There's find.py in Lib/lib-old, but it will probably go away so better
    make your own copy...
    
    -- bjorn
    
    
    
    From vincent_delft at yahoo.com  Thu Sep 20 09:47:47 2001
    From: vincent_delft at yahoo.com (vincent delft)
    Date: Thu, 20 Sep 2001 15:47:47 +0200
    Subject: bsddb3 vs zodb
    References: <3BA9A72A.1D5A6067@yahoo.com> <9ocbso$m72$1@slb7.atl.mindspring.net>
    Message-ID: <3BA9F383.9ED5C436@yahoo.com>
    
    I just would like to have a very small DB with concurrent read and write.
    
    I've a daemon collect data and store them into the DB.
    
    But I've other processes (not deamon) that will read and write into the same
    DB.
    
    I've founded bsddb3 and zodb that can match those simple requirements.
    But ZODB is maybe too sophisticate for my simple problem.
    What about the performances (how many read/write per seconds, what about the
    memory used by those solutions, ...)
    
    
    
    
    
    
    
    Andrew Dalke wrote:
    
    > vincent delft wrote:
    > >does any one as analyze the pro and cons (functionalities, performances,
    > >...) between Berkley DB3 (bsddb3) and ZODB ?
    >
    > They aren't the same.
    >
    > bsddb3 does key/value mappings, where both terms are strings.
    > This is extremely useful.  But if you don't have strings you
    > need to tell it how and when to do the conversion.  There
    > is support for an automatic pickling interface for adding and
    > removing elements from the database, but it doesn't know
    > about changes to the data structure once it's pulled out of
    > the database, and it doesn't deal well with having data shared
    > across different elements.
    >
    > ZODB is a full object persistence system, meaning you can
    > keep your data as a Python data structure and let ZODB figure
    > out how to store that data - there's no need for explicit
    > data structure to/from file I/O code.  (So long as your object
    > supports pickles.)
    >
    > ZODB supports bsddb3 as one way of doing storage.
    >
    >   http://www.zope.org/Wikis/ZODB/BerkeleyStorage
    >
    > What are you trying to do?  That makes it easier to answer
    > your question.
    >
    >                     Andrew
    
    
    
    From rnd at onego.ru  Thu Sep 20 13:16:14 2001
    From: rnd at onego.ru (Roman Suzi)
    Date: Thu, 20 Sep 2001 21:16:14 +0400 (MSD)
    Subject: pgdb bug?
    Message-ID: 
    
    Well, here is the fragment which works differently
    when cur is from MySQLdb or pgdb modules:
    
    ...
    cur.execute("""SELECT name, path FROM modules;""")
    while 1:
      record = cur.fetchone()
      if not record:
        break
      print record
    ...
    
    
    With MySQLdb all records are printed (158 records).
    With the pgdb - 1st record is printed 158 times ;-)
    
    .fetchall() works as expected.
    
    Sincerely yours, Roman Suzi
    -- 
    _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
    _/ Thursday, September 20, 2001 _/ Powered by Linux RedHat 6.2 _/
    _/ "A big enough hammer fixes anything" _/
    
    
    
    
    From reqhye72zux at mailexpire.com  Sun Sep 16 09:44:09 2001
    From: reqhye72zux at mailexpire.com (Robert Amesz)
    Date: Sun, 16 Sep 2001 13:44:09 -0000
    Subject: [Tutor] SMTPLIB module - how to add subject ?
    References: <3BA3D9FE.30092.76C3D5@localhost> 
    Message-ID: 
    
    Sheila King wrote:
    
    > On Sat, 15 Sep 2001 22:45:18 +0200, "A"   wrote
    > about [Tutor] SMTPLIB module - how to add subject ?:
    > 
    > I've pasted the example below. Actually, I really dislike this
    > example. They are using
    > "\r\n"
    > as a character for newlines. Whose idea was that???
    > It should be just
    > "\n"
    
    Not so: the RFC's specify CR/LF pairs as line separators. The downside 
    is that you must make sure that under Windows or MacOS the line-endings 
    aren't translated somewhere along the way.
    
    
    Robert Amesz
    
    
    From skip at pobox.com  Thu Sep  6 18:39:14 2001
    From: skip at pobox.com (Skip Montanaro)
    Date: Thu, 6 Sep 2001 17:39:14 -0500
    Subject: Performance of list comprehensions vs. map
    In-Reply-To: <3B97EB8D.D64CE8F0@home.net>
    References: <3B966B1C.120D0AF6@home.net>
            
            <3B96C062.99E36B04@home.net>
            
            <3B97EB8D.D64CE8F0@home.net>
    Message-ID: <15255.64274.189905.782033@localhost.localdomain>
    
        >> No, this is Python's principle of least astonishment at work.
        >> Python's language is dynamic all over the place.  Placing arbitrary
        >> restrictions on those semantics because they happen to occur between
        >> "[" and "]" would have been wrong.
    
        Chris> but it's not wrong to put in the same restrictions when map is
        Chris> called?  The list comprehension syntax is new.. it's not legal in
        Chris> older version of Python. Therefore, you could put any
        Chris> restrictions you wanted in there, and the restiction that the
        Chris> lists being comprehended don't change in the middle ofhte process
        Chris> sounds like a pretty darn good one to me.
    
    I think you're still missing what I was saying.  map() *can't* possibly have
    the same semantics as for loops precisely because it doesn't return control
    to the interpreter where the name->object lookup takes place.  Could list
    comprehensions behave that way?  Yes, but in my opinion (and apparently in
    the opinion of the various powers that be), that would be wrong.  If you
    don't like all that dynamism, maybe Python's not the language for you.  I
    like it and am interested in speeding up the language as it exists, not some
    other language with Python's syntax but less dynamic semantics.
    
        Chris> If it's OK from a design standpoint to require that the function
        Chris> in a map is bound once, it seems pretty reasonable to have the
        Chris> same requirement for a list comprehension. In fact, it seems like
        Chris> a darn good idea! The fact that the current implimentation
        Chris> doesn't enforce it is a pretty poor design justification...or am
        Chris> I missing something?
    
        >> map() is like any other function written in C.  It does its thing,
        >> then returns.
    
        Chris> The fact that it is written in C should ideally not determine
        Chris> it's behaviour. Ideally the behavious or map(), and list
        Chris> comprehensions, should be determined by some sensible design
        Chris> criteria, including performance, of course.
    
    This is not an ideal world.  The fact that map() is a function (defined in C
    or Python makes no difference) determines that.  The mapping from the name
    "str" to the function object that performs stringification takes place one
    time only, when map()'s input parameters are evaluated.  As far as map() is
    concerned the name of the function may as well be
    "the_moon_is_made_of_green_cheese".
    
        >> >> But there is no guarantee that the list you are operating on isn't
        >> >> modified by another thread during execution.
        >> 
        Chris> but there should be !!
        >> 
        >> Why here and not elsewhere in the language?  
    
        Chris> I thought you said that map() doesn't allow it?
    
    map() gets a snapshot at the time it's called.  The binding of the name
    "str" can change during map()'s execution.  It just won't notice.  For loops
    and list comprehensions reevaluate the name-to-object mapping each time
    around the loop.  Let me see if I can cook up a simple example...  Okay,
    toss this in a .py file and run it from the command line:
    
        def a(i):
            global c
            c = b
            return "a"
    
        def b(i):
            global c
            c = a
            return "b"
    
        def pymap(f, l):
            newl = []
            for elt in l:
                newl.append(f(elt))
            return newl
    
        n = 5
    
        c = a
        print "maploop:", pymap(c, range(n))
    
        c = a
        l = []
        for i in range(n):
            l.append(c(i))
        print "forloop:", l
    
        c = a
        print "lcloop:", [c(i) for i in range(n)]
    
    and execute it.  You should see
    
        maploop: ['a', 'a', 'a', 'a', 'a']
        forloop: ['a', 'b', 'a', 'b', 'a']
        lcloop: ['a', 'b', 'a', 'b', 'a']
    
    Note that I don't call the real builtin map(), but a pseudo-map written in
    Python.  It still doesn't notice the change in binding of the name "c",
    because what c referred to at the point it was called was bound to pymap's
    formal parameter "f".  The same thing happens with the real map() or with
    any other function.  In the for loop and list comprehension examples, c is
    not a parameter, so they look it up each time around the loop.
    
        >> I'm afraid you're tilting at windmills.
    
        Chris> Perhaps I am. It may be that a highly dynamic language isn't well
        Chris> suited to multi-threading, but this stuff sounds pretty scary to
        Chris> me... I'll have to remember to be very careful with any
        Chris> multi-threaded code I write.
    
    Python is as well-suited to multi-threading as any other scripting language
    I'm at all familiar with.  Actually, this discussion we're having doesn't
    really have anything to do with threads at all.  I suggested threads as a
    way that object bindings could change during the execution of a chunk of
    code, but the example above demonstrates it just as well without using
    threads.
    
        >> One approach might be to propose that the array object be "brought
        >> into the fold" as a builtin object
    
        Chris> This is in PEP 209 (with NumPY arrays, whcih is much better that
        Chris> the library array). I'm looking forward to it, I wish I could do
        Chris> more to help out. Note that PEP 211 and 225 are relevent too. The
        Chris> three together would do a lot to make Python more
        Chris> "array-oriented" which I think would be wonderful.
    
    I'm not familiar with PEP 209 (one can't read everything).  In scanning the
    abstract it looks like the authors propose a redesign of Numeric, not
    incorporation of Numeric into the language.  I was suggesting that perhaps
    the array object could be elevated to the same status as lists, tuples and
    dicts, with appropriate changes made to the virtual machine to take
    advantage of arrays' homegeneity.  Moving array into the language would
    probably be a lot more modest bit of work than moving Numeric into the
    language.  Of course, if that step is to be taken, the array object could
    probably benefit from experience with Numeric.
    
        >> and modifications be made to the virtual machine so that homogeneity
        >> can be assumed when operating on arrays.
    
        Chris> That would be a great next step.... it's not in the PEP yet,
        Chris> maybe I'll send a note to authors.
    
        Chris> further off. Personally, I think a little static type
        Chris> declarations could help Py2C and the like a lot.
        >> 
        >> Sure, but then it wouldn't be Python. ;-)
    
        Chris> I'm not so sure about that... be definintion any change or
        Chris> enhancement makes something that is not python. As long as full
        Chris> dynamic typing is the default, it would still be Python.
    
    If I wrote a module in Python then compiled it to C, I would sure want it to
    behave the same.  Otherwise, the compilation process would probably
    introduce subtle bugs into the code.  I'd hate to have to debug the
    generated C code.
    
    -- 
    Skip Montanaro (skip at pobox.com)
    http://www.mojam.com/
    http://www.musi-cal.com/
    
    
    
    From MarkH at ActiveState.com  Mon Sep 10 04:01:22 2001
    From: MarkH at ActiveState.com (Mark Hammond)
    Date: Mon, 10 Sep 2001 08:01:22 GMT
    Subject: pythoncom.lib: Where may I find it, please?
    References: 
    Message-ID: <3B9C741E.6050909@ActiveState.com>
    
    Bill Bell wrote:
    
    > 
    You will need to visit starship.python.net/crew/mhammond.cvs.html, and build from the Pythoncom source code.
    
    
    Mark.
    
    
    
    
    From frederic.giacometti at arakne.com  Thu Sep 20 00:49:24 2001
    From: frederic.giacometti at arakne.com (Frederic Giacometti)
    Date: Thu, 20 Sep 2001 04:49:24 GMT
    Subject: Embeded Multi-Threaded Python: PyEval_InitThread(), PyEval_SaveThread(),...
    References:  <8e0ac4fb.0109191313.5fef1454@posting.google.com>
    Message-ID: 
    
    "Nicolas Duchastel"  wrote in message
    news:8e0ac4fb.0109191313.5fef1454 at posting.google.com...
    > Thanks for the quick response.... but.....
    >
    > I actually RTFM-ed it; that's why my question is so detailed.
    CYSPE ?? (Translation: Can you speak English ?)
    What is this funky RTFM verb ???
    
    > The doc seem to be conflicting in some areas and lacks some important
    > information.
    >
    > For example, Chapter 8 states that Py_Initialized() can be called
    > before or after PyEval_InitThreads(); so which is best ? what are the
    > implications ? any nuance between these two ways ? any examples ?
    
    This is not conflicting, it just states the order dones not matter; which is
    true.
    
    What's missing in the documentation is the indication that
    PyEval_InitThreads() creates and initialize the global lock; and thus must
    have been called before any real thread operation is engaged.
    The code of PyEval_InitThreads is only a couple of lines long. Looking at it
    might help you, too.
    
    > Also, chapter 8.1 does indicated 4 different ways to do locking:
    >   C_Function_ToCallPythonCode()
    >   {
    > PyThreadState* save = PyEval_SaveThread(); // LOCK
    > PyImport_ImportModule( ...); // load another module
    > PyRun_SimpleString(...);      // execute a 1 line of Python code
    > PyPObject_CallMethod(....); // execute a full Python method
    > PyEval_RestoreThread(save); // UNLOCK
    
    But they don't refer to the same locks.... For instance, there is a global
    interpreter lock, and an import lock; these are two different locks.
    So, yes, you're locking, but you're not locking the same thing.  Not all
    locks are the same, you know :))
    
    >   }
    > OR
    >   C_Function_ToCallPythonCode()
    >   {
    > PyEval_AcquireLock(); // LOCK
    > PyImport_ImportModule( ...); // load another module
    > PyRun_SimpleString(...);      // execute a 1 line of Python code
    > PyPObject_CallMethod(....); // execute a full Python method
    > PyEval_ReleaseLock(); // UNLOCK
    >   }
    > OR
    >   C_Function_ToCallPythonCode()
    >   {
    > PyEval_AcquireThread(??); // LOCK
    > PyImport_ImportModule( ...); // load another module
    > PyRun_SimpleString(...);      // execute a 1 line of Python code
    > PyPObject_CallMethod(....); // execute a full Python method
    > PyEval_ReleaseThread(??); // UNLOCK
    
    There are two global interpreter lock/thread function/macro sets: one which
    is source-compatible with single-threaded Python builds, and another one
    which is not.
    
    In addition to this, PyEval_InitThread() does some acrobaties to dynamically
    enable/disable thread on python extension modules, so that the same module
    can work on mutli-threaded and single-threaded python engine; non of this
    being actually documented, of course :))
    
    As resultat des courses, when you invoke binary extensions from the 'python'
    command, the PyEval_InitThread() is only executed upon loading a module
    requiring threads (e.g. the threads module).
    If you create your own binary module which might work on its own thread,
    you'll also want to insert a PyEval_InitThread() call in the module
    initialisation function.
    
    Voila...
    
    >   }
    > OR
    >   C_Function_ToCallPythonCode()
    >   {
    > Py_BEGIN_ALLOW_THREADS
    > PyImport_ImportModule( ...); // load another module
    > PyRun_SimpleString(...);      // execute a 1 line of Python code
    > PyPObject_CallMethod(....); // execute a full Python method
    > Py_END_ALLOW_THREADS
    >   }
    >
    > So which one should I use ?
    
    You should use the macros, preferably to explicit function calls, whenever
    you can...
    
    > Also, image my 2 distinct thread B and C executing the 1st snipplet of
    > code above, if the call to PyObject_CallMethod() is VERY long and
    > takes ages,...
    
    Python takes care of it, don't worry :)))
    
    > chapter 8 says
    >
    >    "In order to support multi-threaded Python programs, the
    >     interpreter regularly releases and reacquires the lock --
    >     by default, every ten bytecode instructions."
    >
    > Does that thus mean that a 2nd thread running this 1st snipplet
    > above will be interupted in the middle of its work in
    > PyObject_CallMethod() and another thread will have a go at it.
    
    That's what thread switching is about, doesn't it ?
    
    > If so, what happens to the ThreadState object when the 2nd thread
    > calls PyEval_SaveThread() ? if it doesn't swap it, it will run with
    > the 1st thread's ThreadState object. If it does swap it, when this
    > 2nd thread will also get interupted, won't the 1st thread get back
    > to run and thus it will run with the 2nd thread's object !?
    > I mean, I must be missing someting !?
    
    No (or maybe a little imagination :)): Just think of the Python virtual
    machine as a single process ressource shared between the native threads.
    
    > Also, what about the things I was asking with regards to the actual OS
    > thread's ID ? i.e. does it matter that my code starts in one thread
    > and then works from another thread ? do I need to create ThreadState
    > objects for each threads ?
    
    ?????
    
    > Thus,.. please RTFP (where P is for Posting rather than Manual)
    
    Qu'es aqueo ????
    
    >
    > Thanks,
    
    De rien.
    
    > Nicolas
    
    FG
    
    
    
    
    
    From fredp at mygale.org.nospam  Tue Sep  4 12:41:30 2001
    From: fredp at mygale.org.nospam (Fred Pacquier)
    Date: 4 Sep 2001 16:41:30 GMT
    Subject: (beginner) question on threads...
    References:    <3B928478.6DE44401@earthlink.net>  <3B9456D0.635BDC3E@student.gu.edu.au>
    Message-ID: 
    
    Joal Heagney  said :
    
    > *chuckles* You'll find this is THE best newsgroup to ask naive
    > questions in. The gurus (Tim, Emile and Guido to name a few) don't mind
    > answering the really interesting questions (Implementation, exotic
    > classes etc.) people pop up, the intermediates take this as an example
    > of good behaviour and take care of the medium level questions and then
    > people like me answer as many newbie questions that they can accuratly
    > field. The trick is to know when to shut up and let somebody more
    > experienced field the question. Plus each of us at the just-above
    > neophyte level has experience in different aspects of python, and how
    > we learnt it - I know some of the beginner-useful modules (not all) and
    > I'm very good at how to build python and python extension module rpms.
    
    Yup -- that is definitely a huge part of the global python picture. There 
    is the language itself and its own merits, and then there are the sorts of 
    people who tend to gather around it, push it in various directions, and 
    form its distinctive community. Don't know which way the chicken-and-egg 
    aspect really works, but python certainly wouldn't be where it is without 
    both...
     
    > If you look at the standard library, you'll see one of the major
    > principles of python coding is to keep the inheritance tree as flat as
    > possible. For example, you have a module A, that imports module B,
    > which imports module C. Now module A uses a function in module B that
    > comes from module C. It is better code practice to import module C into
    > module A and use the function directly, rather than rely on it being
    > included in module B.
    
    Well, in my own code I certainly take care to keep things at the simplicity 
    level I feel I can handle :-)
    But in this particular case, I was nosing through the standard lib's 
    *HTTPServer modules, where classes are effectively nested a few levels 
    deep.
     
    >> Is there not a better way ? Some tool that will build a picture of a
    >> class from its code, with all its methods and attributes, inherited or
    >> not ? 
    > 
    > from pydoc import help
    > import os
    > help(os)
    > class test:
    >      def __init__(self,blah):
    >           self.blah = blah
    >      def afunc(self,values):
    >           blahblablah
    > class test2(test):
    >      def bfunc(self):
    >           blah-blablabla - blabblah
    > help(test)
    > And then the pydoc module supports other objects that let you build
    > html/txt and output to file.
    
    Aha. This is new in 2.x, right ? Need to look into that. Thanks for the tip 
    and encouragement !
    fp
    
    -- 
    YAFAP : http://www.multimania.com/fredp/
    
    
    From joek at quantiva.com  Wed Sep  5 13:38:19 2001
    From: joek at quantiva.com (Joe Kelly)
    Date: 5 Sep 2001 10:38:19 -0700
    Subject: Building gdmodule-0.23 under Python2.1.1
    Message-ID: 
    
    I am trying to build gdmodule.so into Python2.1.1. And it is failing.
    
    Has anyone done this successfully?
    
    It builds correctly, but when I try to import gd I get:
    10026>mach(joek)$ python
    Python 2.1.1 (#1, Aug 31 2001, 20:46:16)
    [GCC 2.95.2 19991024 (release)] on sunos5
    Type "copyright", "credits" or "license" for more information.
    >>> import gd
    Traceback (most recent call last):
      File "", line 1, in ?
    ImportError: ld.so.1: python: fatal: relocation error: file
    ./gdmodule.so: symbol gdImageCreateFromJpeg: referenced symbol not
    found
    >>>
    
    I build gdmodule.so via:
    gcc -fPIC -g -O2 -Wall -Wstrict-prototypes
    -I/home/joek/build/python/pkg/python/reloc/include/python2.1
    -I/home/joek/build/python/pkg/python/reloc/include/python2.1
    -DHAVE_CONFIG_H  -I./install/include -c ././gdmodule.c -o ./gdmodule.o
    
    ld -G  ./gdmodule.o  -L./install/lib -L/usr/lib/X11 -L/usr/X11R6/lib
    -lgd -lz -lpng -ljpeg -lttf -lX11 -lXpm  -o ./gdmodule.so
    
    
    Libgd.a should have the gdImageCreateFromJpeg:
    It is in gd_jpeg.c:
    gcc -I. -I/home/joek/build/gd/gd-1.8.3/../current/install/include -O 
    -c  gd_jpeg.c
    
    
    ar rc libgd.a gd.o gd_gd.o gd_gd2.o gd_io.o gd_io_dp.o \
            gd_io_file.o gd_ss.o gd_io_ss.o gd_png.o gd_jpeg.o gdxpm.o \
            gdfontt.o gdfonts.o gdfontmb.o gdfontl.o gdfontg.o \
            gdtables.o gdttf.o gdcache.o gdkanji.o wbmp.o gd_wbmp.o
    ranlib libgd.a
    
    We have successfully built it with Python1.5.2, but not with
    Python2.1.1.
    
    The platform is Solaris on Intel.
    SunOS mach 5.8 Generic_108529-03 i86pc i386 i86pc
    
    Any help would be greatly appreciated.
    
    
    From tanzer at swing.co.at  Mon Sep 10 03:00:27 2001
    From: tanzer at swing.co.at (Christian Tanzer)
    Date: Mon, 10 Sep 2001 09:00:27 +0200
    Subject: text processing: variable interpolation and more 
    In-Reply-To: Your message of "Sun, 09 Sep 2001 17:17:29 -0000."
                 <1000055849.582487@cswreg.cos.agilent.com> 
    Message-ID: 
    
    weeks at vitus.scs.agilent.com (Greg Weeks) wrote:
    
    > Oleg Broytmann (phd at phd.pp.ru) wrote:
    > : print "Dear %(recipient)s:" % dict  ...
    > 
    > :    will extract dict[recipient] and put it into the string as string. More
    > : details in Python docs about overloaded operator %.
    > 
    > Thanks.  I (obviously) was only aware of (s % d) with d a tuple, despite
    > the fact that my textbook describes both cases in the same sentence.  Oops!
    > 
    > Still, with *two* dictionaries you can capture the entire scope.  Or,
    > rather, you could in 1.5.2.
    
    You might want to try something like this:
    
    class Scope :
        """Capture global and local variables visible in caller's scope.
    
           The index operator also supports expressions as indices and will
           return the result of such expressions as evaluated in the caller's
           scope.
    
           The supplied index operator allows Scope objects to be used as
           mapping arguments for the string formatting operator `%s':
           
           >>> "42*3 == %(42*3)d" % Scope ()
           '42*3 == 126'
        """
           
        def __init__ (self, globals = {}, locals = {}) :
            self.globals = globals
            self.locals  = locals 
        # end def __init__
        
        def __getitem__ (self, index) :
            return eval (index, self.globals, self.locals)
        # end def __getitem__
    
    With some black magic you can make Scope pick up the caller's global
    and local variables all by itself.
    
    -- 
    Christian Tanzer                                         tanzer at swing.co.at
    Glasauergasse 32                                       Tel: +43 1 876 62 36
    A-1130 Vienna, Austria                                 Fax: +43 1 877 66 92
    
    
    
    
    From mlh at idi.ntnu.no  Mon Sep 24 15:24:15 2001
    From: mlh at idi.ntnu.no (Magnus Lie Hetland)
    Date: Mon, 24 Sep 2001 21:24:15 +0200
    Subject: To re or not to re ... ( word wrap function?)
    References:  
    Message-ID: <9oo18v$f22$1@tyfon.itea.ntnu.no>
    
    "Chris Barker"  wrote in message
    news:mailman.1001355746.18274.python-list at python.org...
    > Thanks to all of you who posted code: I've learned something from each
    > one.
    >
    >
    > I did notice that no one used an re-based solution, except Skip using
    >
    > re.split(r'\s+', s)
    >
    > Is this any different than string.split(s) ?
    
    Not that I can see.
    
    > Note that I didn't want to use either of these, as they would kill any
    > sequences of whitespace, such as two spaces after a sentence.
    
    Well -- you're not supposed to have that, are you? 
    
    (A bit larger than a single space when typeset, sure -- but two
    spaces in text? Yuck...)
    
    So, you basically want to keep your whitespace? Then wrappint will
    be hard... What whitespace will you allow to be changed into
    a newline, for instance?
    
    > tex_wrap looks very nice but is really overkill for this application.
    >
    >
    > I also noticed that no one took my approach, which was to start at the
    > end of the line and work backwards looking for space. You all took the
    > approach of building the new line word by word from the beginning.
    
    I'm sure that's a nice approach -- but how do you avoid ending up with
    a short first line? (A short last line is OK.)
    
    > hmmmm.
    >
    > -Chris
    
    --
    
      Magnus Lie Hetland         http://www.hetland.org
    
     "Reality is that which, when you stop believing in
      it, doesn't go away."           -- Philip K. Dick
    
    
    
    
    
    From loewis at informatik.hu-berlin.de  Tue Sep  4 05:25:09 2001
    From: loewis at informatik.hu-berlin.de (Martin von Loewis)
    Date: 04 Sep 2001 11:25:09 +0200
    Subject: COM/CORBA/DCOP (was: Hello people. I have some questions)
    References:  <9mu5si$9gg$1@pea.uk.research.att.com>
    Message-ID: 
    
    Duncan Grisby  writes:
    
    > There's nothing inherently slow about C++ ORBs. MICO was never
    > designed for performance -- indeed its stated design goal is code
    > clarity and wide feature range at the expense of performance. Why the
    > KDE people didn't pick one of the better-performing C++ ORBs, I don't
    > know.
    
    I've heard various stories of why KDE stopped using CORBA; it being
    too slow was just one reason. Other reported problems are:
    - all client-server interaction was across address spaces, ie. there
      was no good support for in-process servers.
    - when a client broke down, it was difficult to garbage-collect the
      servers, so they had many stray processes.
    - it was perceived as being difficult to use by application developers.
      IMO, this was partially due to KDE offering wrapper libraries around
      common interfaces, for convenience. Thus, and application developer
      had many different ways to achieve the same effect, due to the layers
      of wrappers.
    
    Regards,
    Martin
    
    
    From pmoscatt at bigpond.net.au  Tue Sep 11 04:32:14 2001
    From: pmoscatt at bigpond.net.au (Peter Moscatt)
    Date: Tue, 11 Sep 2001 08:32:14 GMT
    Subject: Reading Variables From Modules ?
    Message-ID: 
    
    I have a simple question - well to some I hope :-)
    
    If I was to have a module named MyModule.py which had a function like:
    
            def TestNumber():
                    A = 10
                    return
    
    And I was importing this module into MyMain.py and then wanted to test the 
    value of A in the imported module like:
    
            import MyModule
            if MyModule.A > 10 dosomething
    
    Obviously this dosen't work, so how is the best way to test the value of 
    'A' in the imported module ?
    
    Regards
    Pete
    
    
    From aleax at aleax.it  Tue Sep  4 04:07:53 2001
    From: aleax at aleax.it (Alex Martelli)
    Date: Tue, 4 Sep 2001 10:07:53 +0200
    Subject: Conditional operator in Python?
    References: <3AC68CB8.22AAF7B8@alcyone.com> <9a631k$3s8qb$1@ID-11957.news.dfncis.de>  <3AC6BB2E.1E09B5AA@alcyone.com>  <9n1hr7$7op$1@glue.ucr.edu> <3B947E32.C5604328@el_simpatico.be>
    Message-ID: <9n224q01dfe@enews3.newsguy.com>
    
    "Weet Vanniks"  wrote in message
    news:3B947E32.C5604328 at el_simpatico.be...
    > What about :
    >
    > def cond_choose(cond,first_choice,second_choice):
    >      if cond:
    >           return first_choice
    >      return second_choice
    >
    > whatever= cond_choose(x,a,b)
    >
    > This seems much cleaner to me than all those contorsions with the syntax.
    
    It is, but it has entirely different semantics: BOTH a
    and b are FULLY evaluated BEFORE one of them is chosen.
    
    This is totally inappropriate for many uses of 'choice',
    such as guarding against incorrect operations, controlling
    recursion, and so on.
    
    E.g.:
    
        result = cond_choose(x, 23/x, 149)
    
    this tries to compute 23/x even when x is zero.  This is NOT
    the correct semantics for conditional-choice.  Any of
    the alternative approaches, such as:
        result = (x and 23/x) or 149
    WILL behave correctly: since and/or "short-circuit", the
    right-hand-side operand is *NOT* evaluated -- the division
    by zero will not happen with this coding.
    
    
    Alex
    
    
    
    
    
    From thp at cs.ucr.edu  Wed Sep 19 17:02:59 2001
    From: thp at cs.ucr.edu (thp at cs.ucr.edu)
    Date: Wed, 19 Sep 2001 21:02:59 +0000 (UTC)
    Subject: Proposed PEP for a Conditional Expression
    References: 
    Message-ID: <9ob163$a0v$1@glue.ucr.edu>
    
    James_Althoff at i2.com wrote:
    
    : Tom Payne wrote:
    :>I have a similar objection to the syntax:
    :>
    :>        cond( , lambda:, lambda: )
    :>
    :>Moreover it doesn't scale up to multiple tests very well:
    :>
    :> cond( , lambda:, lambda:cond( , lambda:, lambda:
    : ) )
    :>
    :>or stacked/indented version thereof.
    
    : ... which is perhaps mitigated by the fact that nested conditional
    : expressions is probably not a great idea for readability in any case.
    
    To me,
    
              count = 1 if by_land() else
                      2 if by_sea()  else
                      0
    
    is clearer than
    
             if by_land():
                     count = 1
             elif by_sea():
                     count = 2
             else:
                     count = 0
    
    By contrast, 
    
             count = cond( by_land(), lambda: 1,
                     cond( by_sea(),  lambda: 2,
                                      lambda: 0
                     ))
    
    is indeed "not a great idea for readability."
    
    Tom Payne
    
    
    From phd at phd.pp.ru  Mon Sep  3 05:58:17 2001
    From: phd at phd.pp.ru (Oleg Broytmann)
    Date: Mon, 3 Sep 2001 13:58:17 +0400 (MSD)
    Subject: cgi type=file problems
    In-Reply-To: 
    Message-ID: 
    
    On 3 Sep 2001, Dag wrote:
    D> I have a HTML form with a type=file input element and I simply want to
    D> get the file name as a string.  I'm not interested in the actual file.
    D> However the value from the file part of the form doesn't seem to get
    D> passed at all.
    D> For example I have the following form and script;
    D>
    D> 
    
    
    
    Oleg.
    ----
         Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
               Programmers don't die, they just GOSUB without RETURN.
    
    
    
    
    From dale at riverhall.NOSPAMco.uk  Thu Sep 13 09:59:54 2001
    From: dale at riverhall.NOSPAMco.uk (Dale Strickland-Clark)
    Date: Thu, 13 Sep 2001 14:59:54 +0100
    Subject: XML confusion
    References: <0be1qt8qon2mjb9dj2s94po54gi6h7gt9q@4ax.com>
    Message-ID: 
    
    Dale Strickland-Clark  wrote:
    
    >I'm reading what I can find on XML with Python and came upon this:
    >
    >
    >http://py-howto.sourceforge.net/xml-howto/node14.html
    >
    >The first paragraph makes reasonable sense but it goes sharply down
    >hill after that.
    >
    >Does that look like Java definitions?
    
    I think I've figured it out.
    
    The doc's not finished. Not by a long way.
    
    >From the next section onwards, it's just headings.
    
    Work in progress or abandoned? Either way, not much point in putting
    it online in this condition.
    --
    Dale Strickland-Clark
    Riverhall Systems Ltd
    
    
    From pinard at iro.umontreal.ca  Wed Sep  5 18:44:12 2001
    From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard)
    Date: 05 Sep 2001 18:44:12 -0400
    Subject: pymacs! :-)
    In-Reply-To: <9n5pch$806$1@animus.fel.iae.nl>
    References: 
    	<9n5pch$806$1@animus.fel.iae.nl>
    Message-ID: 
    
    [Carel Fellinger]
    
    > Like Marcin, I would prefer a lisp.fun notation.  And as many lisp names
    > use funny characters like -, I suggest adding a [] interface as well,
    > so we easily can access those weird emacs names like in
    
    >    count = lisp["1+"](count)
    
    Hello, Carel, and others.  Let me thank you, as well as those who wrote
    various suggestions to me.  I tried to take good care of all ideas. :-)
    
    Yes, I exactly added this (using square brackets) earlier today.  Calling
    functions as per above was already in place since one day or two.  Also,
    `lisp' itself can be used as a function to execute raw LISP code, like this:
    
         value = lisp("""
           ...
           POSSIBLY LONG LISP EXPRESSION
           ...
         """)
    
    There is another interesting feature I put in today.  Consider:
    
         def procedure(object):
            lisp.setcdr(object, 17)
    
    presuming that `object' has been given a cons-cell.  I wanted the `setcdr'
    to act on the original OBJECT, and not on a copy.  So, `object' is a handle
    to the LISP argument right in LISP space, whenever that argument is mutable.
    A slight difficulty, easily solved, was to make sure those handles are
    freed in LISP space in proper time, so they can be garbage collected.
    
    On the debugging side, Python exceptions are properly reported as
    tracebacks on the LISP side, while LISP errors occurring while Emacs is
    serving Python are more summarily reported to Python and back to LISP.
    This should not have adverse effects on later computations (I hope I did
    it right).  One may add `print' debugging statements in Python, and with
    a minimum of care, these will correctly appear in the `*Pymacs*' window.
    
    Some handles could usefully be seen as sequences, I'll explore this.
    Also, given handles and symbols have a `.value()' method, I'm thinking
    of adding a `.copy()' method for handles, that would return an expanded
    copy of the list as usable as possible on the mere Python side, without
    further communication.  LISP proper lists could become Python tuples, LISP
    vectors could become Python lists, and strings might loose their properties.
    
    On summary, that project goes well, is nearly usable, and still small:
    pymacs.el is 268 lines, pymacs.py 262 lines, and pymacs-services 11 lines.
    The growth may be explained by the fact I added some documentation! :-)
    
    -- 
    Fran?ois Pinard   http://www.iro.umontreal.ca/~pinard
    
    
    
    From Weet.Vanniks at el_simpatico.be  Tue Sep  4 06:57:55 2001
    From: Weet.Vanniks at el_simpatico.be (Weet Vanniks)
    Date: Tue, 04 Sep 2001 12:57:55 +0200
    Subject: Conditional operator in Python?
    References: <3AC68CB8.22AAF7B8@alcyone.com> <9a631k$3s8qb$1@ID-11957.news.dfncis.de>  <3AC6BB2E.1E09B5AA@alcyone.com>  <9n1hr7$7op$1@glue.ucr.edu> <3B947E32.C5604328@el_simpatico.be> 
    Message-ID: <3B94B3B3.6775EE3C@el_simpatico.be>
    
    Your counter-example seems contorted to me.
    I would never use:
        whatever = cond_choose(cond, format_disk(), leave_it_as_is())
    for the mere reason that I have been taught that:
        1. when there is room for confusion, people get confused
        2. arguments in a function call should NEVER have side-effects.
        3. obfuscated one-liners with lambda functions bring more confusion
    than anything else
            (the alledged efficiency is still to be demonstrated as you
    correctly state)
        4. The spirit of Python is : "If it ain't obvious, it ain't Python"
    and contorted syntax does not help support that spirit
    
    Weet
    
    
    
    Fredrik Lundh wrote:
    
    > Weet Vanniks wrote:
    > > What about :
    > >
    > > def cond_choose(cond,first_choice,second_choice):
    > >      if cond:
    > >           return first_choice
    > >      return second_choice
    > >
    > > whatever= cond_choose(x,a,b)
    >
    > well, compare
    >
    > whatever = cond_choose(cond, format_disk(), leave_it_as_is())
    >
    > with
    >
    >     if cond:
    >         whatever = format_disk()
    >     else:
    >         whatever = leave_it_as_is()
    >
    > > This seems much cleaner to me than all those contorsions with
    > > the syntax.
    >
    > of course, the best way to avoid those contorsions is to fix the
    > Return and Tab keys on your keyboard, and learn how and when
    > to use them...
    >
    > (it also helps to know that lambdas and list constructors are
    > expensive, and assignments to temporary locals are cheap.
    > And contrary to common belief, the Python interpreter can
    > skip over linefeeds in almost no time at all...)
    >
    > 
    
    
    
    From slinkp23 at yahoo.com  Wed Sep 12 11:46:03 2001
    From: slinkp23 at yahoo.com (Paul Winkler)
    Date: Wed, 12 Sep 2001 15:46:03 GMT
    Subject: Performance of list comprehensions vs. map
    References: <3B966B1C.120D0AF6@home.net>  <9n7n6u02leo@enews1.newsguy.com>  
    Message-ID: 
    
    On 7 Sep 2001 20:49:29 GMT, Marcin 'Qrczak' Kowalczyk  wrote:
    >Fri, 07 Sep 2001 20:17:12 GMT, Paul Winkler  pisze:
    >
    >> So for the foreseeable future, looks like map() is likely to remain
    >> the fastest way to generate lists.
    >
    >As long as the function to map is ready. If a separate function must
    >be created just for mapping (doesn't matter id by 'def' or 'lambda'),
    >I would expect a list comprehension with the function's body inserted
    >to be faster than map which must call it.
    
    Interesting idea. I just tried ...  Yes, *if* what you're doing is
    practical to inline in the list comprehension, that can beat map().
    And of course if what you're doing is calling, say, a function or
    method from the standard library, you're not going to inline that, so
    map() still looks like a good idea.
    
    Example:
    
    test = xrange(100000)
    
    def multiplier(x):
        return x * 0.99
    
    def mapper(m=multiplier, f=test):
        return map(m, f)
    
    def comprehender_inline(f=test):
        return [x * 0.99 for x in f]
    
    def comprehender(m=multiplier, f=test):
        return [m(x) for x in f]
    
    # end of example
    
    In this case, comprehender_inline wins by a very large margin,
    followed by mapper, which is in turn faster than comprehender.
    
    But here's the counterexample:
    
    import string
    test = # a 100000-character random string
    
    def mapper(m=string.upper, f=test):
        return map(m, f)
    
    def comprehender(m=string.upper, f=test):
        return [m(x) for x in f]
    
    su = string.upper
    def comprehender_inline(f=test):
        su = string.upper
        return[su(x) for x in f]
    
    
    # end example
    
    In this case, comprehender_inline is about the same speed as
    comprehender, no surprise since they're almost identical. Map wins by
    a large margin. If you rewrite comprehender_inline so it returns
    [x.upper() for x in f], it speeds up quite a lot, but still loses to
    map, and we're not really comparing apples to apples anymore.
    
    
    
    
    
    
    From tim.one at home.com  Sat Sep  1 18:11:44 2001
    From: tim.one at home.com (Tim Peters)
    Date: Sat, 1 Sep 2001 18:11:44 -0400
    Subject: Stackless Python and Python 2.x
    In-Reply-To: <3B90468D.E64ECCB7@student.gu.edu.au>
    Message-ID: 
    
    [Joal Heagney]
    > Wasn't a big part of the generator addition that it supplies a
    > simpler-to-understand solution to the majority of continuations
    > solutions?
    
    I expect that if you dug into all the applications using Stackless, you'd
    find that the majority of them rely on full-blown coroutines or
    microthreads.  It's unclear how far PEP 255's "Simple Generators" can be
    pushed towards those specific ends.
    
    Neil Schemenauer discovered that it was possible to code the "traditional"
    coroutine examples using simple generators instead, and being able to
    explicitly resume a generator object independent of magical control context
    was key to that (an ability Icon generators and CLU iterators don't have, so
    the limitations of the latter don't necessarily apply to Python's flavor of
    the idea too).
    
    But it remains unclear how far that can be pushed.  In any case, it wasn't
    PEP 255's intent to kill off Stackless, but to get at many things you *can*
    do with continuations for which continuations aren't *necessary*.  The
    implementation changes needed to support simple generators were minor by any
    measure, and the Jython folks believe it's doable on top of the JVM too.  In
    bang for the buck, they're a big win, but it's not clear they reach Big Bang
    status.
    
    but-creating-a-new-universe-wasn't-their-goal-ly y'rs  - tim
    
    
    
    
    From ht_xu at hotrmail.com  Mon Sep 10 18:09:41 2001
    From: ht_xu at hotrmail.com (Henry)
    Date: Mon, 10 Sep 2001 17:09:41 -0500
    Subject: How to know it is a list?
    References: 
    Message-ID: 
    
    Thank you all guys, your help is highly appreciated.
    
    Henry
    
    "Henry"  wrote in message
    news:jw9n7.6109$Ku4.124514 at e420r-atl2.usenetserver.com...
    > Hi guys,
    >   I have a newbie question. How do check if a variable is a list?
    >
    > Thanks in advance,
    > Henry
    >
    >
    >
    
    
    
    
    
    From strnbrg at c532352-a.frmt1.sfba.home.com  Tue Sep 25 12:27:00 2001
    From: strnbrg at c532352-a.frmt1.sfba.home.com (Theodore D. Sternberg)
    Date: Tue, 25 Sep 2001 16:27:00 GMT
    Subject: widget['command']
    Message-ID: 
    
    How do you obtain a reference to a Tkinter widget's callback?  widget['command']
    only gives me a munged version of the callback's name.  Of course what I'd like
    is a reference to a real function that I can use in "apply".  
    
    Ted Sternberg
    Berkeley, California USA
    
    
    From ignacio at openservices.net  Mon Sep 17 16:49:29 2001
    From: ignacio at openservices.net (Ignacio Vazquez-Abrams)
    Date: Mon, 17 Sep 2001 16:49:29 -0400 (EDT)
    Subject: Newbie: How to download a JPG file from the internet....?
    In-Reply-To: 
    Message-ID: 
    
    On Mon, 17 Sep 2001, John Branthoover wrote:
    
    > Hello All,
    >     Can anyone tell me how to download an image from a web site?
    > An example:
    >  that is located at www.somewhere.org
    >
    >     I have already found the urllib module and have used the urlopen
    > function to create a string from a web page,  but I don't know how to
    > proceed from here.  I can isolate the string -   SRC="./images/getme.jpg">, but then what?  I would like to eventually write
    > it to a file on my local drive.  Any information will be greatly
    > appreciated.  Thank you for your time.
    
    The first thing you have to do is get the value of the src attribute from the
    img tag.
    
    Once you have that, you have to determine if it's an absolute or relative URL.
    If it's absolute, then you just get it and write it to a file. If it's
    relative, then you have to parse the document for a base tag and apply
    the relative URL to that to get an absolute URL.
    
    If there is no base tag, then you have to apply the relative URL to the
    absolute URL of the page you are downloading and go from there.
    
    -- 
    Ignacio Vazquez-Abrams  
    
    
    
    
    
    From chrishbarker at home.net  Wed Sep 12 14:19:33 2001
    From: chrishbarker at home.net (Chris Barker)
    Date: Wed, 12 Sep 2001 11:19:33 -0700
    Subject: PEP proposal for round(x,n) enhancement
    References:  
    Message-ID: <3B9FA735.7319C83@home.net>
    
    Christopher Smith wrote:
    
    > There should be away to say "round to the 3rd digit from the first
    > non-zero digit.
    
    Absolutely.
    
    > I have checked both the Scientific and Numeric packages.  While they do
    > allow for extended sorts of formatting (like Fortran formats, etc...) I do
    > not see this sort of functionality built into them.
    
    I suggest you post to the NumPy list about this, for two reasons:
    
    1) There are some sharp people there that could help you come up with a
    robust algorithm
    
    2) It would be a whole lot easier to get this added to NumPy or SciPy as
    a Ufunc than it will be to get it into Python itself (not that it
    shouldn't be there, it should). In fact, you could wite it yourself for
    NumPy...
    
    By the way, SciPy is a different and more ambitious project than
    Scientific. Check out:
    
    www.scipy.org.
    
    -Chris
    
    
    -- 
    Christopher Barker,
    Ph.D.                                                           
    ChrisHBarker at home.net                 ---           ---           ---
    http://members.home.net/barkerlohmann ---@@       -----@@       -----@@
                                       ------@@@     ------@@@     ------@@@
    Oil Spill Modeling                ------   @    ------   @   ------   @
    Water Resources Engineering       -------      ---------     --------    
    Coastal and Fluvial Hydrodynamics --------------------------------------
    ------------------------------------------------------------------------
    
    
    
    From andy_todd at spam.free.yahoo.com  Sun Sep 23 23:16:27 2001
    From: andy_todd at spam.free.yahoo.com (Andy Todd)
    Date: 24 Sep 2001 03:16:27 GMT
    Subject: time.timezone gives strange results on cygwin
    Message-ID: 
    
    time.timezone is returning an incorrect value on cygwin python.
    
    Whilst running some code on different platforms I have identified what I 
    believe to be a bug in the timezone function of the time module on cygwin.
    This works as expected from Windows (Python 2.1.1 on Win2k, Win98, WinNT4) 
    but on the same machines via cygwin comes up with an incorrect figure.
    
    >From the documentation;
    
    """
    timezone 
         The offset of the local (non-DST) timezone, in seconds west of UTC
         (i.e. negative in most of Western Europe, positive in the US, zero in 
         the UK). 
    """
    
    The timezone set on all of my machines is AEST - Australian Eastern 
    Standard Time which is 10 hours ahead of UTC. 
    >From windows;
    
    >>> import time
    
    >>> print time.tzname
    
    ('AUS Eastern Standard Time', 'AUS Eastern Daylight Time')
    
    >>> print time.timezone
    
    -36000
    
    But from cygwin on the same machine;
    
    $ python
    Python 2.1.1 (#2, Aug 23 2001, 10:41:44)
    [GCC 2.95.3-5 (cygwin special)] on cygwin
    Type "copyright", "credits" or "license" for more information.
    >>> import time
    >>> print time.tzname
    ('AUSEST', 'AUSEDT')
    >>> print time.timezone
    1834228892
    >>>
    
    Any suggestions? I'm presuming that the underlying system function that is 
    called to calculate the timezone offset is wrong under cygwin.
    
    Regards,
    Andy
    -- 
    Content free posts a speciality
    
    
    From skip at pobox.com  Fri Sep  7 17:42:42 2001
    From: skip at pobox.com (Skip Montanaro)
    Date: Fri, 7 Sep 2001 16:42:42 -0500
    Subject: Performance of list comprehensions vs. map
    In-Reply-To: 
    References: <15257.12041.140352.873520@beluga.mojam.com>
            
    Message-ID: <15257.16210.751461.185017@beluga.mojam.com>
    
        Tim> func_code has been writable for some time.  Here under 2.2a3:
    
    Whoops!  Thanks for the correction.  I'm still working from a 1.5.2 codebase
    in the rattlesnake stuff.  That's the only context in which I've ever wanted
    to modify a function's code object, and, lo and behold, it's possible there
    as well...
    
    Skip
    
    
    
    From markus at schabi.de  Wed Sep 26 11:53:54 2001
    From: markus at schabi.de (Markus Schaber)
    Date: Wed, 26 Sep 2001 17:53:54 +0200
    Subject: importing symbols from module objects
    References: <7xd74eephr.fsf_-_@ruckus.brouhaha.com> <3BB1681D.762AA451@home.com> <7xwv2mik2i.fsf@ruckus.brouhaha.com> <3BB1DE64.E84241F0@engcorp.com>
    Message-ID: <1930273.Pv6tv2OnDr@lunix.schabi.de>
    
    Hi,
    
    Peter Hansen  schrub:
    
    >> Hey, that ought to work.  I'm the one that missed something.  I'm not
    >> totally used to this exceptions=classes=instances stuff yet.  Now I
    >> have to wonder what "from foo import bar as parrot" really does.
    >> Maybe pretty much the same thing.  Anyway, thanks, I'll give it a
    >> try.
    > 
    > It does this:
    > 
    > from foo import bar
    > parrot = bar
    > del bar
    
    Is this really true?
    
    With a.py containing:
    
    def f():
      print "hello"
    
    I did the following in python 2.0.1 interactive mode:
    >>> a = 1
    >>> f = 2
    >>> from a import f as x
    >>> print a,f,x
    1 2 
    
    Given your definition, f would be overwritten with the function and 
    then deleted, thus not be bound to 2 any more.
    
    markus
    -- 
    "The strength of the Constitution lies entirely in the determination of 
    each citizen to defend it. Only if every single citizen feels duty 
    bound to do his share in this defense are the constitutional rights 
    secure." -- Albert Einstein
    
    
    From slinkp23 at yahoo.com  Fri Sep  7 16:17:12 2001
    From: slinkp23 at yahoo.com (Paul Winkler)
    Date: Fri, 07 Sep 2001 20:17:12 GMT
    Subject: Performance of list comprehensions vs. map
    References: <3B966B1C.120D0AF6@home.net>  <9n7n6u02leo@enews1.newsguy.com>
    Message-ID: 
    
    On Thu, 6 Sep 2001 13:38:07 +0200, Alex Martelli  wrote
    
    (snip - a very long and detailed discussion of map, list
    comprehensions, and for/append loops)
    
    Thanks very much, Alex, now I understand what's happening under the
    covers! I guess that optimizing list comprehensions in this way is
    probably not worth the trouble, given the factors you mention.  The
    optional "if" clause of list comprehensions also complicates things.
    
    I tried your test script, and got comparable results to yours, with
    the exception that on my machine, use_map always beats pre_alloc even
    when len() is "wrong" (although not by much). I tried it with
    n=1000*1000 and n = 100 * 100 and got similarly proportioned results.
    
    So for the foreseeable future, looks like map() is likely to remain
    the fastest way to generate lists.
    
    -- Paul Winkler
    
    
    
    From dyoo at hkn.eecs.berkeley.edu  Sun Sep  9 15:24:13 2001
    From: dyoo at hkn.eecs.berkeley.edu (Daniel Yoo)
    Date: Sun, 9 Sep 2001 19:24:13 +0000 (UTC)
    Subject: Cookie example?
    References: 
    Message-ID: <9ngfkt$1l5q$3@agate.berkeley.edu>
    
    Tyler Eaves  wrote:
    
    : Anyone have some code that reads and sets cookies using the cookie
    : module?
    
    I have a silly example of one here:
    
        http://hkn.eecs.berkeley.edu/~dyoo/python/cookiecounter.py
    
    
    If you haven't seen it already, you might want to browse Useless Python:
    
        http://www.lowerstandard.com/python/
    
    which isn't quite organized yet, but might have some examples you can
    play with.  Also, the Vaults of Parnassus:
    
        http://www.vex.net/parnassus/
    
    is a good resource for examples (although it appears to be down at the
    moment... *sob*)
    
    
    From scott at swiftview.com  Fri Sep  7 12:20:00 2001
    From: scott at swiftview.com (Scott Long)
    Date: Fri, 07 Sep 2001 09:20:00 -0700
    Subject: Nested scopes: why is it weird?
    Message-ID: <3B98F3B0.53AC2524@swiftview.com>
    
    Nested scopes seem like a nice addition (of course!) but there are some
    weird things about it. Take a look:
    
    >>> from __future__ import nested_scopes
    >>> def a():
    ...   def b():
    ...     k = x
    ...     print k
    ...   x = 1
    ...   b()
    ...
    >>> a()
    1
    
    Right, this is what you would expect. But how about this?
    
    >>> from __future__ import nested_scopes
    >>> def a():
    ...   def b():
    ...     k = x
    ...     x = 0
    ...     print k
    ...   x = 1
    ...   b()
    ...
    >>> a()
    Traceback (most recent call last):
      File "", line 1, in ?
      File "", line 7, in a
      File "", line 3, in b
    UnboundLocalError: local variable 'x' referenced before assignment
    
    Here is my explanation for this (tell me if I'm wrong):
    
    During pass #1 of compilation, the statement "x = 0" in b() binds x as a
    local variable local to b(). During execution, k = x executes *before* x
    has been assigned, resulting in this flamage.
    
    My first beef here is, why is the exception called UnboundLocalError?
    The variable is certainly bound (into the local scope), it simply has
    not been assigned. Why not call it UninitializedLocalError? I know it
    isn't going to change, I'm just asking.
    
    But my main concern is that this way of selecting a binding seems very
    unintuitive. Shouldn't the first statement referencing x be the
    statement that specifies the binding of x? In this case, shouldn't "k =
    x" cause x to get bound as a free variable, not a local to b()? I'm not
    claiming that this is a bug. I am curious as to why it was decided that
    things are going to work this way. It makes assignment to a variable in
    an enclosing scope impossible!
    
    Regards,
    Scott
    
    
    From wilson at netvmg.com  Tue Sep 18 17:27:12 2001
    From: wilson at netvmg.com (Wilson Yeung)
    Date: 18 Sep 2001 14:27:12 -0700
    Subject: shelve vs pickle
    References: <9ntpa2+uprc@eGroups.com>  <9nu72c.3vv2ert.1@kserver.org> <3BA65739.5301558@astro.cornell.edu>
    Message-ID: 
    
    I've had good results with the Sleepycat/Berkeley DB via the
    Python interface pybsddb as my underlying store, together with
    the pickle module.
    
    Wilson
    
    
    From nhodgson at bigpond.net.au  Tue Sep  4 20:34:38 2001
    From: nhodgson at bigpond.net.au (Neil Hodgson)
    Date: Wed, 05 Sep 2001 00:34:38 GMT
    Subject: COM/CORBA/DCOP (was: Hello people. I have some questions)
    References:  <9mu5si$9gg$1@pea.uk.research.att.com> <9mvkvr01db@enews2.newsguy.com> <7xelpo86rj.fsf@ruckus.brouhaha.com> <9n2q3b0d92@enews3.newsguy.com>
    Message-ID: 
    
    Alex Martelli:
    [about Automation]
    > ..., it's mostly about marshaling
    > the arguments (they DO have to be marshaled, since the Invoke call
    > of the IDispatch interface cannot accept "a generic stack frame" --
    > it wants an array of VARIANT's, so SOME code, typically somewhere
    > in the OLE runtime, must be marshaling
    >     stackframe->array of VARIANTs->stackframe
    > and THAT is the part that normally dominates, except perhaps
    > on argument-less methods using optimized non-interpretive custom
    > marshaling for the purpose).
    
       At the risk of being pedantic (and with Alex, it is *such* a temptation
    :-) ), you can write your automation code (both client and server) to deal
    with VARIANTs directly. The cost in Automation is more that a well behaved
    server is supposed to coerce arguments into the form it requires (int->real,
    string->number and even dereferencing byref arguments are often done) and
    this often requires a bunch of tests and translation code.
    
       Neil
    
    
    
    
    
    From emile at fenx.com  Fri Sep 28 10:06:43 2001
    From: emile at fenx.com (Emile van Sebille)
    Date: Fri, 28 Sep 2001 07:06:43 -0700
    Subject: Problem with os.system()
    References: <3bb47fd9_8@news.newsgroups.com>
    Message-ID: <9p20e5$fhh23$1@ID-11957.news.dfncis.de>
    
    Well I don't see any bugs in it.  ;-))
    
    --
    
    Emile van Sebille
    emile at fenx.com
    
    ---------
    "Janos Blazi"  wrote in message
    news:3bb47fd9_8 at news.newsgroups.com...
    > I have the following code:
    >
    >
    >
    >
    > -----=  Posted via Newsfeeds.Com, Uncensored Usenet News  =-----
    > http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
    >  Check out our new Unlimited Server. No Download or Time Limits!
    > -----==  Over 80,000 Newsgroups - 19 Different Servers!  ==-----
    
    
    
    From tanzer at swing.co.at  Tue Sep 11 03:26:22 2001
    From: tanzer at swing.co.at (Christian Tanzer)
    Date: Tue, 11 Sep 2001 09:26:22 +0200
    Subject: Proposed PEP for a Conditional Expression 
    In-Reply-To: Your message of "Mon, 10 Sep 2001 10:15:16 +0200."
                 <00e801c139d0$b9d1cdc0$102b2bc1@cadlab.it> 
    Message-ID: 
    
    "Alex Martelli"  wrote:
    > """
    > One example: with a trivial class, one can put expressions into format
    > directives, like
    > 
    >     "Found %(number)d error%(if number == 1 : '' else : 's')s" % trivial
    > 
    > This doesn't look too attractive if used in a one-liner, put could be
    > put to very good use for substitution in bigger templates.
    > """
    > Definitely unattractive here -- and you don't really need to
    > change the Python language, adding complication to it, to get
    > a similar effect right now.  The __getitem__ method of the
    > class of 'trivial' can after all perfectly well define whatever
    > syntax it wants (as long as it's free of ')' charachters:-)
    > for its 'name' argument.  E.g., assuming it's OK to exclude
    > '@' and ':' as well, since ')' has to be excluded anyway:
    
    Sure, that's one of Python's strengths. I just think it's a waste if
    everybody implements his own pet class to solve one specific instance
    of a general problem like this.
    
    IMHO, conditional expressions add substantial benefit if the syntax is 
    readable.
    
    > In fact, I'd prefer a totally different
    > approach here, one allowing me to write, e.g.:
    > 
    > print "%(plur_verb number 'Found') %(plur_noun number 'error')s" % neater
    > 
    > with the parser in __getitem__ looking for spaces and using
    > them, if found, to recognize formatting keywords such as
    > 'plur_verb' -- makes for easier parsing AND for vastly easier
    > i18n of messages (neater itself would of course use gettext
    > as needed on the meaning-carrying words such as 'error' or
    > 'Found':-).
    
    Well, I'd use the contents of the interpolated string as key to get 
    the translation (via gettext or otherwise). After all, different
    languages might have totally different rules how to adapt a sentence
    to the context supplied by `neater`.
    
    -- 
    Christian Tanzer                                         tanzer at swing.co.at
    Glasauergasse 32                                       Tel: +43 1 876 62 36
    A-1130 Vienna, Austria                                 Fax: +43 1 877 66 92
    
    
    
    
    From James_Althoff at i2.com  Fri Sep 14 16:35:06 2001
    From: James_Althoff at i2.com (James_Althoff at i2.com)
    Date: Fri, 14 Sep 2001 13:35:06 -0700
    Subject: Proposed PEP for a Conditional Expression
    Message-ID: 
    
    Marcin Kowalczyk wrote:
    >    abs = if x>=0 then x else -x
    >or
    >    abs = if x>=0: x else: -x
    >looks more readable than
    >    abs = cond(x>=0, lambda:x, lambda:-x)
    >for me.
    
    That's a fair opinion.  But you have to admit that the last one beats the
    heck out of the first two in terms of implementation issues.
    
    And is not nearly as humorous as
        abs = (x>=0 and [x] or [-x])[0]
    as an available workaround.  ;-)
    
    Jim
    
    
    
    
    From tim at vegeta.ath.cx  Wed Sep 12 16:53:21 2001
    From: tim at vegeta.ath.cx (Tim Hammerquist)
    Date: Wed, 12 Sep 2001 20:53:21 GMT
    Subject: .NET and Python
    References:  <9nettc$ce1$1@slb7.atl.mindspring.net>    <8nMm7.133116$n75.31959718@news4.rdc1.on.home.com>   <9hCn7.1041$6c5.37802@news1.rdc1.sdca.home.com>
    Message-ID: 
    
    Me parece que Van Gale  dijo:
    [ snip ]
    > Most, if not all, Microsoft products improve with time.
    
    I think fortune said it best when it said:
    
    $ /usr/games/fortune
    The Microsoft Motto: "We're the leaders, wait for us!"
    $
    
    There you have it.  ;)
    
    Tim
    
    [ snip ]
    
    -- 
    Well of *course* Perl should not be taught to everyone. It should
    only be taught to people who want to like their computers.
        -- Larry Wall
    
    
    From danny.kohn at systematik.se  Sat Sep 15 11:57:13 2001
    From: danny.kohn at systematik.se (Danny Kohn)
    Date: 15 Sep 2001 11:57:13 CET
    Subject: Newbee - MySQL create database/table
    Message-ID: <1103_1000547896@DANNY>
    
    Hi.
    I wonder if someone could put here or send me a sample Python scrip on how to create a database and how to create a table using MySQL with MySQLdb.
    I have read a lot of documentation but I just cannot figure this one out or find any sample script on how to do this.
    
    Thanks in advance 
    /Danny Kohn
    
    
    
    From slinkp23 at yahoo.com  Fri Sep  7 17:22:12 2001
    From: slinkp23 at yahoo.com (Paul Winkler)
    Date: Fri, 07 Sep 2001 21:22:12 GMT
    Subject: pymacs! :-)
    References:  <6e0ad3b1.0109060128.6c9adc8@posting.google.com> 
    Message-ID: 
    
    On 06 Sep 2001 11:39:18 -0400, Fran?ois Pinard  wrote:
    (snip)
    >It depends a bit on if there are many Emacs users who have practical
    >interest in writing `.py'/`.pyc' files next to their `.el`/`.elc' files!
    
    Very much so! I love emacs, but there is a lot I can do in python that
    I haven't a clue how to do in emacs lisp. (well, almost anything!)
    
    I hope you'll excuse the lisp-newbie questions, but I think a simple
    example would really help me understand how this is going to work.
    For example, let's say I have a a module, let's call it manglers.py,
    containing this simple python function:
    
    def break_on_whitespace(some_string):
    	"""Yes, it's trivial."""
    	words = some_string.split()
    	return '\n'.join(words)
    
    Now I want to tell Emacs about this function so that I can call it on
    a region of text and replace the region with the result of the
    call. And bind this action to a key, of course.
    
    So what goes in my .emacs file?
    First I import the module:
    (import-python 'manglers')
    
    Then I can refer to (manglers-break_on_whitespace), right?
    And I think I can bind it to a key like so:
    (global-set-key (quote [f7]) (quote manglers-break_on_whitespace))
    
    But how do I pass and replace the current region?  I was hoping this
    project of yours might enable me to avoid learning any more lisp, but
    it looks like I won't be so lucky. :)
    
    --PW
    
    
    
    
    
    
    
    
    From phr-n2001 at nightsong.com  Tue Sep 25 12:10:03 2001
    From: phr-n2001 at nightsong.com (Paul Rubin)
    Date: 25 Sep 2001 09:10:03 -0700
    Subject: Threading and the HTTPD server classes
    References: 
    Message-ID: <7xvgi7qmjo.fsf@ruckus.brouhaha.com>
    
    I think you're supposed to do that using the ThreadingMixIn from the
    SocketServer class.
    
    
    From aahz at panix.com  Sun Sep 30 12:47:11 2001
    From: aahz at panix.com (Aahz Maruch)
    Date: 30 Sep 2001 09:47:11 -0700
    Subject: Realtime capabilities?
    References:  <9ol2ph$od2$1@panix2.panix.com> 
    Message-ID: <9p7iaf$gqf$1@panix3.panix.com>
    
    In article ,
    Carlos Gaston Alvarez  wrote:
    >
    >Why there is a stack and a stackless python?
    >The cuestion is: why not using allways stackless?
    
    The current implementation of Stackless Python is too Baroque to be
    integrated into the Python core.  If it ever does happen, it'll probably
    be after Python 3.0.
    -- 
                          --- Aahz  <*>  (Copyright 2001 by aahz at pobox.com)
    
    Hugs and backrubs -- I break Rule 6                 http://www.rahul.net/aahz/
    Androgynous poly kinky vanilla queer het Pythonista   
    
    We must not let the evil of a few trample the freedoms of the many.
    
    
    From MarkH at ActiveState.com  Mon Sep  3 21:32:44 2001
    From: MarkH at ActiveState.com (Mark Hammond)
    Date: Tue, 04 Sep 2001 01:32:44 GMT
    Subject: Questions on COM Objects scripting
    References: 
    Message-ID: <3B942FF4.9040006@ActiveState.com>
    
    Maan Hamze wrote:
    
    > Taking into account that the very same thing works fine with something like
    > "Excel.Application"; what does this error tell me about "Breeze.Scene"?
    
    
    That Breeze.Scene is not registering itself in the "Running Object 
    Table".  This should not be a problem - the fact that Excel works is 
    more unusual than the fact that Breeze.Scene does not.
    
    > 2.  Using Python ActiveScripting
    > From inside the applicatio itself (Breeze Designer) there is a facility to
    > run Macros with languages with ActiveScripting capabilities including
    > Python.
    > "Breeze.Scene" is created automatically when Breeze is started.
    > a macro starts with $Scripting_Language
    
    
    "Breeze.Scene" should not be created automatically - that would suck. 
    Hopefully what you mean is that a "Breeze" object is created, and it 
    should have a "Scene" attribute.
    
    You could try printing "globals()" to see exactly what is in the 
    ActiveScripting namespace.  If "Breeze.Scene" really does exist in the 
    namespace, then we will need to pull some tricks to work around a very 
    poor decision by the povray people.
    
    Keep in mind that VB is not case sensitive, but Python is.  Have you 
    tried "breeze"?
    
    Mark.
    
    
    
    From Dag at animagicnet.no  Mon Sep  3 05:11:26 2001
    From: Dag at animagicnet.no (Dag)
    Date: 3 Sep 2001 09:11:26 GMT
    Subject: cgi type=file problems
    Message-ID: 
    
    I have a HTML form with a type=file input element and I simply want to
    get the file name as a string.  I'm not interested in the actual file.  
    However the value from the file part of the form doesn't seem to get
    passed at all. 
    For example I have the following form and script;
    
    
    
    #!/usr/bin/python import cgi form=cgi.FieldStorage() #other stuff print form When I enter a filename and text string into the form, the above code returns; FieldStorage(None, None, [MiniFieldStorage('texttest', 'abc')]) So what happened to my "filetest" value? Dag From fredrik at pythonware.com Mon Sep 17 13:13:56 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 17 Sep 2001 17:13:56 GMT Subject: newbie - Scoping question References: <3281a460.0109170759.63ede66@posting.google.com> Message-ID: "P Adhia" wrote: > I'll appreciate if anyone can me clarify my Python scoping rules a > bit. scoping has nothing to do with this. > >>> from test import * in Python, a variable is a name associated with an object. the from-import statement creates new names, in the current module, which points to existing objects from another module. > >>> x = [1,2,3] assignment also creates new names in the current module. the above statement doesn't modify the original "x" object; it creates a new list, and gives it a name. > I am confused as to why "x", when not qualified with module name, does > not refer to "x" in "test", even though I did "from test import *". if the introductory book you used to learn Python didn't explain this, ask for a refund ;-) reading the following articles might help: http://effbot.org/guides/python-objects.htm http://effbot.org/guides/import-confusion.htm From cgale1 at _remove_home.com Wed Sep 12 18:59:49 2001 From: cgale1 at _remove_home.com (Van Gale) Date: Wed, 12 Sep 2001 22:59:49 GMT Subject: .NET and Python References: <9nettc$ce1$1@slb7.atl.mindspring.net> <8nMm7.133116$n75.31959718@news4.rdc1.on.home.com> <9hCn7.1041$6c5.37802@news1.rdc1.sdca.home.com> <9nnknh02j8b@enews1.newsguy.com> Message-ID: "Alex Martelli" wrote in message news:9nnknh02j8b at enews1.newsguy.com... > ...for *networking* purposes, probably. It's likely to be pretty > soon a superior way to develop & deploy for the Windows *desktop*, > greatly reducing issues of component versioning and other aspects > of "dll hell":-). Interesting. If that's the case, maybe I'll be using it sooner rather than later *grimaces* From rnd at onego.ru Sun Sep 23 17:13:10 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 24 Sep 2001 01:13:10 +0400 (MSD) Subject: google, Python, and eleven (was Re: google and Python ;-) In-Reply-To: <3BAD2890.FDE4B2F7@engcorp.com> Message-ID: On Sat, 22 Sep 2001, Peter Hansen wrote: >>>> def numerology(s): >... f = lambda x, y : x+y >... return reduce(f, map(int, str(reduce(f, map(ord, s))))) >... >>>> numerology('readablepowerfuldynamic') >11 >>>> numerology('Perl') >7 >>>> numerology('Python') >12 >>>> numerology('Ruby') >13 >>>> numerology('Smalltalk') >15 >>>> numerology('TCL') >11 Lets make PEP 11 about Numerology constraints on Python module names. There must be standard numerology API so nobody will abuse the science any more! (And backdoors for the gov'ts, as usual ;-) I am not sure ASCII codes is suitable for such use, though. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Sunday, September 23, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Alexander the Grape: He Concord the world." _/ From rafael at zumnet.com.br Fri Sep 14 10:19:36 2001 From: rafael at zumnet.com.br (Rafael Mentz Aquino) Date: Fri, 14 Sep 2001 11:19:36 -0300 Subject: Sockets Message-ID: <3BA211F8.DFCD@zumnet.com.br> Hi, there, I'm trying to create a socket script to work as server, using the example from the lib reference manual, with a little change that puts the script in looping, so I can make more than one requisition without stopping and starting the script all the time. When I execute the script, it works fine, listening in the given port and answering the requisitions... But If I try to put the script in background (in FreeBSD) I got an error saying (address already in use). I guess its because of the while 1 looping... The script is below. Thanks!!! Rafael Mentz Aquino 1 #!/usr/local/bin/python 2 3 import socket, sys, string 4 5 data = "" 6 7 def sock(): 8 data = "" 9 10 HOST='127.0.0.1' 11 PORT=50007 12 s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) 13 s.bind((HOST,PORT)) 14 s.listen(1) 15 s.setblocking(1) 16 conn, addr = s.accept() 17 print 'Connected by', addr 18 while 1: 19 data = conn.recv(1024) 20 21 if data == "quit" : sys.exit() 22 23 if data == "server": .... etc etc .... .... 100 if not data: 101 conn.close() 102 break 103 while not data == "quit": ## It's a redundancy, I know.. ;-) 104 socks() 105 conn.close() From fredrik at pythonware.com Thu Sep 6 14:27:45 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 06 Sep 2001 18:27:45 GMT Subject: problem with re References: <9n8atr$i22$1@odysseus.uci.kun.nl> Message-ID: Patrick Vrijlandt wrote: > I do not understand why the 7th regular expression does not give the same > result as 2-6. because "|" has lower precedence than just about everything else; the last pattern either matches 10 digits, *OR* two letter groups followed by a number. > mymatch(r'\n'.join([r'(\d{10})|([a-z]{10})', r'([a-z]{10})', r'(\d{10})'])) if you want three groups, remove the parens around the bar: mymatch(r'\n'.join([r'(\d{10}|[a-z]{10})', r'([a-z]{10})', r'(\d{10})'])) if you want four groups, you have to add an extra pair of non-capturing parentheses: mymatch(r'\n'.join([r'(?:(\d{10})|([a-z]{10}))', r'([a-z]{10})', r'(\d{10})'])) From phd at phd.pp.ru Sat Sep 8 05:36:02 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Sat, 8 Sep 2001 13:36:02 +0400 Subject: Creating Excel files on Linux In-Reply-To: ; from mmhamze@pleiades.net on Fri, Sep 07, 2001 at 11:04:37AM -0500 References: <3B97A39C.6A5234D7@olen.to> Message-ID: <20010908133602.M18172@phd.pp.ru> Hello! Completely offtopic. Sorry, I cannot resist. Well... On Fri, Sep 07, 2001 at 11:04:37AM -0500, Maan M. Hamze wrote: > living in. I am not defending Microsoft here, but I am being realistic. In you realism you said many bad words about people and companies. I don't want to be that kind of "realist". I want to be an idealist. Only idealists can change the world. Realists seems to be slaves of the status quo. (I am not flaming you, don't take it personnaly.) > transparent. We do not live in such a world. We live in a world controlled > by greedy corporations, let it be Sun or Microsoft or the late Netscape. That why instead of just being realistical slaves we must oppose them and create the free world. > We live in a world of arrogant men and greedy corporations, and they play Thanks goodnes I am not. I live in the world of nice, creative, open, very helpful people. Gvido van Rossum, Eric Raymond, Linus Torvalds (to name a few most notable persons); and they are not only brilliant programmers - they are idealists who are changing the world. Linux and "Computer Programming for Everybody", Python and Free Software Movements! > As far as I am concerned, getting a job done is the issue here. Anyone can Not only. Protecting our freedom, too. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From marcinm at finisar.com Tue Sep 4 20:01:11 2001 From: marcinm at finisar.com (Marcin Matuszkiewicz) Date: 4 Sep 2001 17:01:11 -0700 Subject: swig cygwin python Message-ID: I am using swig to generate a wrapper around C functions I want to call from python. I am using gcc2.95.3-5 (cygwins pecial) and python 2.1 that come with cygwin. I have a linker problem when creating .so file. Here are the details. $ swig -python example.i Generating wrappers for Python $ gcc -c example.c $ gcc -I/usr/include/python2.1 -c example_wrap.c $ gcc -shared example.o example_wrap.o -L/lib/python2.1/config -lpython2.1.dll example_wrap.o(.text+0x1e6):example_wrap.c: undefined reference to `PyExc_NameEr ror' example_wrap.o(.text+0x2b8):example_wrap.c: undefined reference to `PyExc_NameEr ror' example_wrap.o(.text+0x305):example_wrap.c: undefined reference to `PyType_Type' example_wrap.o(.text+0xef0):example_wrap.c: undefined reference to `PyExc_TypeEr ror' collect2: ld returned 1 exit status $ nm /lib/python2.1/config/libpython2.1.dll.a | grep NameError 00000000 I __imp__PyExc_NameError Does anyone know what is going on and/or how to fix it? Thank you, Marcin From ScottMC at oge.com Mon Sep 17 11:38:32 2001 From: ScottMC at oge.com (Scott, M Clay) Date: Mon, 17 Sep 2001 10:38:32 -0500 Subject: Best database for Time Series Data [slightly OT] Message-ID: <66757C91639C7C419D9AD6C8925C5E3EE697B5@chqmail.corp.oge.com> While this is slightly off-topic in a general sense, it is on-topic from a Python sense... What is the best database to use for time-series data? I work for an electric utility in Load Research. Load Research is the study of how customers and groups of customers use energy. It deals with large amounts of time-series data (periodic meter readings on [typically] 15-minute intervals). The volume of data would be in the magnitude of 35,000 (for a single meter) to 35,000,000 (for a group of 1,000 meters) data elements for a single year. Obviously, multiple years means more data. I am looking to take advantage of Python for some of the data processing. We currently use a package that utilizes Btreive which can be connected to via ODBC. However, I would like to know about other alternatives. Is MySQL well-suited for this task? What are other Python-able databases? Which of these are good for time-series data? Any direction provided will be greatly appreciated. Thanks, Clay Scott From orlov at diasoft.ru Fri Sep 21 02:52:29 2001 From: orlov at diasoft.ru (Oleg Orlov11980884) Date: Fri, 21 Sep 2001 10:52:29 +0400 Subject: attribut of the current module Message-ID: <9oeo0n$28vn$1@gavrilo.mtu.ru> How can i get attribut of the current module? Ugly way: getattr(__import__(__name__), attribname) Thnks, Oleg. From TomH at optiscan.com Wed Sep 5 02:18:32 2001 From: TomH at optiscan.com (Tom Harris) Date: Wed, 5 Sep 2001 16:18:32 +1000 Subject: string.split Message-ID: Hi, The useful split() function in the string module by default splits on whitespace, which is any combination of spaces, tabs, newlines, and possibly other stuff. So I see the following behaviour: >>> import string >>> s = 'asa \n bb cc\n\tdd' >>> string.split(s) ['asa', 'bb', 'cc', 'dd'] However the defaulted second argument to string.split() can only be used to set a literal string that is the seperator. How do I split on any or all occurrences of (for example) whitespace and a comma, without using regexes. I mean string.split() must be able to do it anyway to achieve the default behaviour. Tom Harris, Software Engineer Optiscan Imaging, 15-17 Normanby Rd, Notting Hill, Melbourne, Vic 3168, Australia email tomh at optiscan.com ph +61 3 9538 3333 fax +61 3 9562 7742 This email may contain confidential information. If you have received this email in error, please delete it immediately,and inform us of the mistake by return email. Any form of reproduction, or further dissemination of this email is strictly prohibited. Also, please note that opinions expressed in this email are those of the author, and are not necessarily those of Optiscan Pty Ltd. From tanzer at swing.co.at Mon Sep 10 02:42:16 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Mon, 10 Sep 2001 08:42:16 +0200 Subject: Proposed PEP for a Conditional Expression In-Reply-To: Your message of "Sun, 09 Sep 2001 20:00:05 +0200." <9nganb0t8f@enews1.newsguy.com> Message-ID: > Michael Chermside wrote: > > [excellent work snipped, as I just want to snipe on one point...] > > > using it may require creating a temporary variable and > > splitting a formula into two lines, or replacing a lambda > > expression with a named function. > > I consider that replacing lambda forms with named functions, in Python, is > an *excellent* practice, which should be encouraged by all means necessary. > If the lack of a conditional operator does indeed encourage people to > write more local def's and fewer lambdas, then (to me) that is the "killer > argument" for not introducing conditional operators. Conditional expressions provide some nice benefits totally unrelated to lambdas. One example: with a trivial class, one can put expressions into format directives, like "Found %(number)d error%(if number == 1 : '' else : 's')s" % trivial This doesn't look too attractive if used in a one-liner, put could be put to very good use for substitution in bigger templates. -- Christian Tanzer tanzer at swing.co.at Glasauergasse 32 Tel: +43 1 876 62 36 A-1130 Vienna, Austria Fax: +43 1 877 66 92 From vincent_delft at yahoo.com Fri Sep 14 10:13:57 2001 From: vincent_delft at yahoo.com (vincent delft) Date: Fri, 14 Sep 2001 16:13:57 +0200 Subject: what's the best methode to crypt/encode the python code. Message-ID: <3BA210A5.E027C11B@yahoo.com> hello, I've written a Python code that check an application (registration into the DB, execution of commands, ...). And I would like to put this code on the production machine. My problem is that some passwords and some private info are into the python code. How can we secure it ? I don't want that someone (the others that have acccess to the machine) can read this code. Do I use a DB ? (which often provide more secure access) unfortunately I'm on a windows server Thanks From kkto at csis.hku.hk Thu Sep 20 06:49:05 2001 From: kkto at csis.hku.hk (Isaac To) Date: 20 Sep 2001 18:49:05 +0800 Subject: How to remove "\n" in a string? References: Message-ID: <7i3d5if87y.fsf@enark.csis.hku.hk> >>>>> "rainlet" == rainlet writes: rainlet> I tried : s = ".............." s.replace ( "\n", "" ) rainlet> But it doesn't seem to work. If you remember that strings are immutable, you'd probably have written s = s.replace(...), which should do the trick. Regards, Isaac. From mr.murray at mindspring.com Sun Sep 9 01:18:52 2001 From: mr.murray at mindspring.com (Andrew Murray) Date: Sat, 8 Sep 2001 22:18:52 -0700 Subject: Python and Zope References: Message-ID: <9nettc$ce1$1@slb7.atl.mindspring.net> Frankly I was pretty unimpressed with Zope. After one gets over the 'gee-whiz' factor, I've found that the learning curve behind Zope and the relative non-portability of the code you must write for it far outweigh the benefits (what are they again btw?) of using Zope. If you've used mod_perl, mod_php or mod_python before, I'd suggest going that route. Andrew Murray "Ken Egervari" wrote in message news:vLAm7.129206$n75.31076306 at news4.rdc1.on.home.com... > How realistic is it to make large, corporate websites and extranets using > Zope? It is it better to just use Python and a regular web server? (like > say amazon.com, ibm.com, bea.com). Basically anything that sapient or > razorfish does. > > From hao-nghi.au at fr.thalesgroup.com Wed Sep 12 12:41:56 2001 From: hao-nghi.au at fr.thalesgroup.com (hao-nghi.au at fr.thalesgroup.com) Date: Wed, 12 Sep 2001 18:41:56 +0200 Subject: os.spawn Message-ID: <33105F8B185CD51182E300306E06473E270205@hermes.isr.thomson-csf.com> Hi Sylvain, when you use os.P_NOWAIT, you get the pid of the process. Perhaps you can get its return status by waitpid(). Regards, Hao-Nghi Au -----Original Message----- From: syt at pegasus.logilab.fr [mailto:syt at pegasus.logilab.fr] Sent: Wednesday, September 12, 2001 3:33 PM To: python-list at python.org Subject: Re: os.spawn On Wed, 12 Sep 2001 09:13:58, S. Thenault wrote: >On 11 Sep 2001 18:05:13 GMT, Donn Cave wrote: >>Quoth syt at pegasus.logilab.fr (Sylvain Thenault): >> >>| how can I do for knowing what happend when I do an os.spawnv() >>| >>| for example, if i do >>| >>| import os >>| os.spawnv(P_WAIT, '/bin/echo', 'this is a spawn test') >>| >>| I can't see anything, and don't know what have been made... >> >>Normal return from os.spawnv should be 0. Anything else indicates >>failure. >> >> >>> print os.spawnv.__doc__ >> spawnv(mode, file, args) -> integer >> >> Execute file with arguments from args in a subprocess. >> >>Args here should be a tuple or list like sys.argv: >> os.spawnv(os.P_WAIT, '/bin/echo', ('echo', 'this is a spawn test')) >> >> Donn Cave, donn at u.washington.edu > >thanks, i was waiting for an exception in case of error >does someone know why it isn't the default behaviour ? > >BTW, this wasn't working because as exec*, the first item of args must be >the called program's name ('echo' in this example) as you said (i read your message too fast, didn't see you said that yet) I have now another problem, I change P_WAIT to P_NOWAIT and spawnv return an integer != 0 either if spawnv succeed ! how to know if there is an error durring spawn with the P_NOWAIT flag? -- Sylvain Thenault LOGILAB -- http://mail.python.org/mailman/listinfo/python-list From phd at phd.pp.ru Sun Sep 30 11:13:55 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Sun, 30 Sep 2001 19:13:55 +0400 Subject: Off-topic: hiding your email address - don't bother... In-Reply-To: <9p6jur.3vv985j.1@kserver.org>; from sheila@spamcop.net on Sun, Sep 30, 2001 at 03:09:07PM +0000 References: <9p5aio$50a$1@inputplus.demon.co.uk> <3BB6C9DD.E36C0BFF@engcorp.com> <9p6jur.3vv985j.1@kserver.org> Message-ID: <20010930191355.B892@phd.pp.ru> On Sun, Sep 30, 2001 at 03:09:07PM +0000, Sheila King wrote: > I've often thought, that email addresses with the string "spam" just get > discarded. Otherwise, I don't know why I get so few spam emails sent to > my spamcop.net address. Probably because SpamCop.NET does an enormous effort to filter it before you see it. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From markus at schabi.de Wed Sep 12 04:55:14 2001 From: markus at schabi.de (Markus Schaber) Date: Wed, 12 Sep 2001 10:55:14 +0200 Subject: Pythonwin and .NET References: Message-ID: <1289505.6RcZxFsPTI@lunix.schabi.de> Roman Suzi schrub: > On Tue, 11 Sep 2001, Robin Becker wrote: > >> In article , Roman >> Suzi writes >> ... >> >"Python! Python! Python! ..." >> > >> >And then elect GvR the president of United Nations. >> > >> >Sincerely yours, Roman Suzi >> hope not, else perhaps 10 years down the road we'll have United >> Nations 2.2 with qualified minority voting or some such. > > But we will have too: > > from __future__ import hope Bob Hope as python module? Bizarre :-) markus -- "The strength of the Constitution lies entirely in the determination of each citizen to defend it. Only if every single citizen feels duty bound to do his share in this defense are the constitutional rights secure." -- Albert Einstein From markus at schabi.de Wed Sep 19 14:53:13 2001 From: markus at schabi.de (Markus Schaber) Date: Wed, 19 Sep 2001 20:53:13 +0200 Subject: confused by bindings References: Message-ID: <1163217.ysRUnXabfl@lunix.schabi.de> Hi, Sam Falkner schrub: > class Cell: > count = 0 This is the "class variable" called count. > def __init__(self, stuff): > self.count += 1 Here, you set an "instance variable" count. That's why you always get 1. Try Cell.count += 1 here. markus -- "The strength of the Constitution lies entirely in the determination of each citizen to defend it. Only if every single citizen feels duty bound to do his share in this defense are the constitutional rights secure." -- Albert Einstein From l0819m0v0smfm001 at sneakemail.com Thu Sep 13 18:26:03 2001 From: l0819m0v0smfm001 at sneakemail.com (Joshua Macy) Date: Thu, 13 Sep 2001 22:26:03 GMT Subject: MUDs... References: <9nqic4$and$1@hfc.pacific.net.hk> Message-ID: <3BA0FC3B.9030806@sneakemail.com> Poo was renamed MOOP, and is now on SourceForge at http://moop.sourceforge.net Joshua Kenneth Tsang wrote: > hi, I come across this. - Pythonic MOO > http://www.strout.net/python/poo/index.html > > KT > -- > > -- > Kenneth Tsang > email: smt at pacific.net.hk tel: +852 9468 4772 > "Vincent A.Primavera" wrote in message > news:mailman.1000384156.22009.python-list at python.org... > >>Hello, >>A while ago on the list, Python based MUDs were discussed. Does anyone >> > have any suggestions as to > >>which were/are recommended? >> >>Thank you, >>Vincent A. Primavera. >> >> > > From g.haering at ___skynamics.com.invalid Wed Sep 5 08:10:39 2001 From: g.haering at ___skynamics.com.invalid (Gerhard =?ISO-8859-1?Q?H=E4ring?=) Date: Wed, 05 Sep 2001 14:10:39 +0200 Subject: running Python-Skripts without having Python installed References: <9n4tsa$gl5$1@trinity.hannover.sgh-net.de> Message-ID: <3B96163F.60506@___skynamics.com.invalid> Frank Bongartz wrote: > Hi ! > > As I am new to Python I wonder if it is possible to run Python scripts on > machines, that do not have installed Python. > > In TCL, it is possible to start a "wish" in a batch-file, followed by the > tcl-script. > > Any suggestions ? win32/Linux: http://www.mcmillan-inc.com/install1.html win32: http://py2exe.sourceforge.net/ Gordon McMillan's page (first URL) explains the concepts behind these quite nicely. There's also the freeze utility in the standard Python distribution, which should work on any platform, but needs a C compiler. Gerhard -- Gerhard H?ring skynamics AG g.haering at skynamics.com http://www.skynamics.com From nhodgson at bigpond.net.au Mon Sep 24 04:29:41 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Mon, 24 Sep 2001 08:29:41 GMT Subject: Why so few Python jobs? References: <9oltnk$vv3$1@nntp9.atl.mindspring.net> Message-ID: Ted: > Any ideas on why so few Python jobs are available? Unfortunately, the increased productivity we achieve with Python means that there is often no need to hire any more developers after your first Pythonista ;) Neil From chrishbarker at home.net Tue Sep 4 19:45:49 2001 From: chrishbarker at home.net (Chris Barker) Date: Tue, 04 Sep 2001 16:45:49 -0700 Subject: appropriate graphics Lib? References: <3B955860.8040303@visionart.com> Message-ID: <3B9567AD.5B2228B8@home.net> Pete Shinners wrote: > i hear tkinter has a pretty powerful canvas widget that i > supports these things. i'm guessing wxPython would have > something like that too. Actually, the fact that wxPython does NOT have such a canvas widget is seen by many as it's greatest weekness (in comparison to tk, anyway). In wxPython, you would have to do the hit test yourself as well. There is a C++ wxCanvas that would do it, but it is not yet complete, and has not yet been wrapped for Python. TK is probably the easiest way to do it. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From jblazi at hotmail.com Sat Sep 22 15:18:35 2001 From: jblazi at hotmail.com (Janos Blazi) Date: Sat, 22 Sep 2001 21:18:35 +0200 Subject: Tkinter Questions References: Message-ID: <3bace41a_8@news.newsgroups.com> > 1) Use winfo_width() and winfo_height() to get the actual > dimensions of a component. Call update() first so that > the geometry manager has run... > > from Tkinter import * > root = Tk() > > f1 = Frame(root, width=300, height=250) > f1.pack() > root.update() > w = f1.winfo_width() > h = f1.winfo_height() > f2 = Frame(f1, width=w, height=h) > f2.pack(fill=BOTH) > c = Canvas(f2, width=w, height=h, bg='yellow') > c.pack(fill=BOTH) > > root.mainloop() > > > 2) Try using: > ~~counter~~.entryfield.component('entry').configure( options...) Thank you very much, now evrything works and I am sure I should have never found out, how to do these things. Apropos update(): "Use this method with care, since it can be a source of problems, not only by consuming CPU cycles but also by setting up race conditions." (page 440) Janos Blazi -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! Check out our new Unlimited Server. No Download or Time Limits! -----== Over 80,000 Newsgroups - 19 Different Servers! ==----- From paoloinvernizzi at dmsware.com Tue Sep 25 03:54:44 2001 From: paoloinvernizzi at dmsware.com (Paolo Invernizzi) Date: Tue, 25 Sep 2001 07:54:44 GMT Subject: python 2.2 question... References: <1387386.JiE95MRjnR@lunix.schabi.de> Message-ID: <8LWr7.8$sk6.469@nreader1.kpnqwest.net> Markus Wrote... ------------- > try setting A.__repr__ to a method or function doing whatever you want. > > >>> A.__repr__ = lambda: "hallo" > >>> print A > hallo > >>> str(A) > 'hallo' ------------- Things work differently in 2.2, and not only for "object" derived classes... (for now ;) Python 2.2a3 (#23, Sep 7 2001, 01:43:22) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. IDLE 0.8 -- press F1 for help >>> class A: pass >>> A.__repr__= lambda: "Repr of A" >>> print A __main__.A >>> str(A) '__main__.A' >>> repr(A) '' >>> class A(object): pass >>> A.__repr__= lambda: "Repr of A" Traceback (most recent call last): File "", line 1, in ? A.__repr__= lambda: "Repr of A" TypeError: can't set type attributes Paolo Invernizzi From root at rainerdeyke.com Thu Sep 13 22:45:26 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 14 Sep 2001 02:45:26 GMT Subject: Proposed PEP for a Conditional Expression References: <6qvgire4bk.fsf@abnoba.intevation.de> <9nk3jd$4lc$1@glue.ucr.edu> <9nnsa3$bjl$1@news.mathworks.com> <3BA00239.DECE6412@cosc.canterbury.ac.nz> <4xXn7.2446$w62.1612552@news1.denver1.co.home.com> <3BA13B35.991482C4@cosc.canterbury.ac.nz> Message-ID: "Greg Ewing" wrote in message news:3BA13B35.991482C4 at cosc.canterbury.ac.nz... > Rainer Deyke wrote: > > > > I was actually considering the following interpretations: > > > > [( for i in range(5)) if else ] > > That one isn't even an interpretation, it's nonsense. Just because it isn't legal Python (now or with conditional statements) doesn't mean it's nonsense. > Unless you mean it to mean > > [ for i in range(5)] if else [] Yes, that is what I mean. > and I wouldn't mind in the least being required to > write it like that if that's what I wanted. You're not addressing the real point. With the ' if else ' syntax, an 'if' enclosed in brackets has two very different meanings depending on whether or not there is an else. This makes Python harder to read, write, and grok - *unless* the new syntax is somehow conceptually unified with the list comprehension syntax. One problem is that list comprehension syntax is already confusing: [i for i in range(5)] It's easy to think of 'i for i in range(5)' as an expression that yields multiple values and can therefore only exist in the special context of a list literal. This view is unfortunately incorrect: [(x, y) for x in range(5) for y in range(5)] My instincts tell me that '(x, y) for x in range(5)' is evaluated for each 'y' in 'range(5)', but in fact it's the other way around: 'for x in range(5)' is the outer loop and 'for y in range(5)' is the inner. The 'for' and 'if' clauses in a list comprehension do not act like expressions. Imagine then the confusion if the ' if else ', which *does* act like an expression, was added to the language. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From aleax at aleax.it Wed Sep 12 08:11:57 2001 From: aleax at aleax.it (Alex Martelli) Date: Wed, 12 Sep 2001 14:11:57 +0200 Subject: [Poll] Private variables References: Message-ID: <9nnjee02hg1@enews1.newsguy.com> "Alexandre Fayolle" wrote in message news:slrn9pu9vk.iec.alf at orion.logilab.fr... > It is possible in python to get private class members by using names > beginning with 2 underscores, and finished by at least 1 underscore. Yes, and not only private *class members*: it also works for class-private *module-level names*, for example: class One: global __beep __beep = 23 def beep(self): print __beep class Two: global __beep __beep = 42 def beep(self): print __beep One().beep() Two().beep() print dir() will output: 23 42 ['One', 'Two', '_One__beep', '_Two__beep', '__builtins__', '__doc__', '__name__' ] > I personnally tend to use class member names beginning with one > underscore to indicate that the member is 'internal' and should not > be called by external applications, and from looking at the standard > library source code, it seems that this is more common than the official > way mentionned hereabove. > > I would like to hear what the opinion of pythoneers is on that topic. My personal opinion is that __beep style names serve to avoid accidental clashes of identifiers between base and derived classes -- you can use that style of identifiers without any worries about some ancestor or descendant class duplicating it by accident, and that's the only feature that makes them really useful. Inheritance hierarchies (particularly between classes that are separately developed and released) don't tend to be very deep in most Python code, so it's not such a crucial issue in most cases. But it's nice when it comes up. And tends to reassure people coming from languages such as C++ or Java which seem to think privacy is indispensable:-). Alex From chrishbarker at home.net Mon Sep 10 14:37:07 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 10 Sep 2001 11:37:07 -0700 Subject: Performance of list comprehensions vs. map References: Message-ID: <3B9D0853.8B46AE62@home.net> "Delaney, Timothy" wrote: > Yep - now you know why so many people have *not* put the effort into > optimising Python. Dynamism pervades almost every part of the language. > > The only optimisations I've seen proposed in recent times which truly look > interesting are > > PEP 266: Optimizing Global Variable/Attribute Access > http://python.sourceforge.net/peps/pep-0266.html > > PEP 267: Optimized Access to Module Namespaces > http://python.sourceforge.net/peps/pep-0267.html > > both of which need implementing and testing to determine (a) whether they > are indeed an improvement, and (b) whether they are enough of an improvement > when balanced by how much they complicate the Python core code. These both do look good, but let's face it: It's not even clear that they will help at all, and certainly not enough to make a huge difference. My issue with the dynamicism of Python is that it is wonderful and powerful, but frankly, not used in a great deal of code: How amny people even new that you could change the code of a function on the fly, let alone actually used the feature? And of those few that have used the feature, how often have they used it? What I am searching for in this discussion are ways that Python can take advantage of the fact that much code is not, in fact, all that dynamic. I suspect that most of the time that a list comprehension or map is called, the author of the code fully expects the expression (or function) to do the same thing for the duration of the call, and that the sequence is more often than not homogenous. There must be some way to take advantage of that circumstance. Granted, we could speed up map and list comprehensions a whole lot, and that wouldn't speed up the language as a whole all that much, but this is just an example. Perhaps the only way to do it would be to sprinkle a few "static" or something statements in. Frankly I think this is ugly, but the current answer to a few core functions in a Python program being too slow is to re-code it in C. Surely that is ugly! I-know-there-are-no-easy-answers-but-I-wish-there-were-ly yours, -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From mats at laplaza.org Mon Sep 17 07:35:56 2001 From: mats at laplaza.org (Mats Wichmann) Date: Mon, 17 Sep 2001 11:35:56 GMT Subject: Getting expat compiled properly References: <9mkugf$99h$1@tyfon.itea.ntnu.no> <9n4b8q$ase$1@tyfon.itea.ntnu.no> <3b95f5d8.112439689@news.laplaza.org> <9n508p$let$1@tyfon.itea.ntnu.no> Message-ID: <3b9ca572.64951735@news.laplaza.org> On Wed, 5 Sep 2001 12:54:17 +0200, "Magnus Lie Hetland" wrote: :"Mats Wichmann" wrote in message :news:3b95f5d8.112439689 at news.laplaza.org... :[snip] :> :The problem is that I'm not an administrator at this machine, so :> :it would be a bit awkward... I guess I could take the #!/usr/bin/env :> :trick to new heights, but... :> :> You're limited to one argument... : :I assume that's some strange restriction imposed by using env in the :hash-bang context? I see that it doesn't work -- although it works in :other contexts, e.g: : :$ env foobar=1 python -c 'import os; print os.getenv("foobar")' :1 Yes, it's a limit on the #! construct which is a weird hack anyway. #! path-to-interpreter argument You can only pass one argument to the interpreter. Using env as the "interpreter" means you're not hardwiring the path to Python but also means you can't pass /any/ arguments to Python. Mats Wichmann From cjensen at bioeng.ucsd.edu Tue Sep 4 12:05:30 2001 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Tue, 04 Sep 2001 09:05:30 -0700 Subject: gdb, python, and irix Message-ID: <3B94FBCA.CC4343E@bioeng.ucsd.edu> I'm trying to run gdb with python on irix. However, I never get passed the run command in gdb. It hangs indefinatly after I type "run" in the gdb shell. We're using gdb 5.0, irix 6.5 and I've tried Python 1.5.2 and Python 2.1.1 Has anyone else run into this problem? Has anyone gotten gdb to work with Python on irix? Any suggestions on getting it to work for us? Thanks. -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From kkto at csis.hku.hk Tue Sep 25 08:44:16 2001 From: kkto at csis.hku.hk (Isaac To) Date: 25 Sep 2001 20:44:16 +0800 Subject: Tkinter and frame resizing question References: <9opbul$2phe$1@mail1.wg.waii.com> <9opmat$qbk$1@mail1.wg.waii.com> Message-ID: <7i66a7phi7.fsf@enark.csis.hku.hk> >>>>> "Martin" == Martin Franklin writes: Martin> post me some code I have done a similar thing and got it Martin> working..... Doesn't seem to work for me. The question is how to make the bottom window stay at the same position. Intuitively, this means that the toplevel window should "stick" to the bottom. For example, if the window is of size 100x100 at +100+100 before forget, and is 100x80 after forget, then the position after resize should be +100+120. I think this should be wm matters. However, I've scanned the man page of wm and toplevel, it doesn't seem to have such an option to allow this. Perhaps somebody should actually check ICCCM to see whether this "sticky" option can be communicated to the window manager. Regards, Isaac. From fredp at mygale.org.nospam Mon Sep 3 12:45:05 2001 From: fredp at mygale.org.nospam (Fred Pacquier) Date: 3 Sep 2001 16:45:05 GMT Subject: (beginner) question on threads... References: <3B928478.6DE44401@earthlink.net> <3066967.SC6OKomogB@lunix.schabi.de> Message-ID: Markus Schaber said : >> Is there not a better way ? Some tool that will build a picture of a >> class from its code, with all its methods and attributes, inherited or >> not ? > > That's _really_ difficult in python, because one can add methods or > attributes to classes even at run-time, depending on user input or > random generators :-) > > But the usual, statically written in source way, it should be possible, > I've seen something like this in the Delphi environment, as pop-down > menu in the editor. On the one hand, I'm glad to learn my way of exploring is not so dumb after all. OTOH, I'm sadly disappointed that there is no magic bullet :-) -- YAFAP : http://www.multimania.com/fredp/ From qrczak at knm.org.pl Fri Sep 7 16:49:29 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 7 Sep 2001 20:49:29 GMT Subject: Performance of list comprehensions vs. map References: <3B966B1C.120D0AF6@home.net> <9n7n6u02leo@enews1.newsguy.com> Message-ID: Fri, 07 Sep 2001 20:17:12 GMT, Paul Winkler pisze: > So for the foreseeable future, looks like map() is likely to remain > the fastest way to generate lists. As long as the function to map is ready. If a separate function must be created just for mapping (doesn't matter id by 'def' or 'lambda'), I would expect a list comprehension with the function's body inserted to be faster than map which must call it. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From chatme at 263.net Thu Sep 13 01:00:41 2001 From: chatme at 263.net (limodou) Date: 12 Sep 2001 22:00:41 -0700 Subject: About Tkinter <>? References: <9np6j1$82u$1@bob.news.rcn.net> Message-ID: Jerry Gitomer wrote in message news:<9np6j1$82u$1 at bob.news.rcn.net>... > > You will find a program called GuiAppD.py in the Pmw\contrib > directory that does what you want. Thanks! I'll try. From rnd at onego.ru Thu Sep 6 14:18:42 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 6 Sep 2001 22:18:42 +0400 (MSD) Subject: problem with re In-Reply-To: <9n8atr$i22$1@odysseus.uci.kun.nl> Message-ID: On Thu, 6 Sep 2001, Patrick Vrijlandt wrote: >Hi, > >I do not understand why the 7th regular expression does not give the same >result as 2-6. > >(This is simplified from something I'm working on. The answer may be >trivial, but I don't see it) > >TIA, >Patrick Vrijlandt > >import re > >data = """1234567890 >abcdefghij >1234567890""" > >def mymatch(pattern): > mo = re.match(pattern, data) > print mo, > try: > print mo.groups() > except AttributeError: > print > > >mymatch('.*\\n.*\\n.*') >mymatch('(.*)\\n(.*)\\n(.*)') >mymatch('(.{10})\\n(.{10})\\n(.{10})') >mymatch('(\d{10})\\n([a-z]{10})\\n(\d{10})') >mymatch(r'(\d{10})\n([a-z]{10})\n(\d{10})') >mymatch(r'\n'.join([r'(\d{10})', r'([a-z]{10})', r'(\d{10})'])) >mymatch(r'\n'.join([r'(\d{10})|([a-z]{10})', r'([a-z]{10})', r'(\d{10})'])) You forgot to put () to limit your | operands. Correct version: mymatch(r'\n'.join([r'(?:(\d{10})|([a-z]{10}))', r'([a-z]{10})', r'(\d{10})'])) (if I understood your intention correctly) My problem is more complex: ... File "./prepares.py", line 64, in repl return self.search_re.sub(self.prep_replace, text) File "/usr/lib/python2.1/sre.py", line 164, in _sub return _subn(pattern, template, string, count)[0] File "/usr/lib/python2.1/sre.py", line 179, in _subn m = c.search() RuntimeError: maximum recursion limit exceeded As always: import re # sre re.match('^START(.+?)END$', text, re.M|re.S) And I grew so accustomed to .expand() already :-( I need to call GhostBusters somewhere ;-) Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Thursday, September 06, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "How many weeks are there in a light year?" _/ From aahz at panix.com Sun Sep 30 13:50:14 2001 From: aahz at panix.com (Aahz Maruch) Date: 30 Sep 2001 10:50:14 -0700 Subject: Near Final PEP 247 - API for Cryptographic Hash Functions References: <3dofnztka2.fsf@ute.cnri.reston.va.us> <9p23f1$dj2$1@panix3.panix.com> <3dite3t7pu.fsf@ute.cnri.reston.va.us> Message-ID: <9p7m0m$m6q$1@panix3.panix.com> In article <3dite3t7pu.fsf at ute.cnri.reston.va.us>, Andrew Kuchling wrote: >aahz at panix.com (Aahz Maruch) writes: >> >> How about flipping Tim's suggestion around and making the string >> argument keyword based? > >What exactly does that mean? new([string=]) new(key,[string=]) -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista We must not let the evil of a few trample the freedoms of the many. From b_lamy at club-internet.fr Mon Sep 17 02:15:46 2001 From: b_lamy at club-internet.fr (LAMY Bertrand) Date: Mon, 17 Sep 2001 08:15:46 +0200 Subject: problem with extending python with C Message-ID: <3BA59512.A59B33EF@club-internet.fr> [PS : thanks for the last answer, there was a perfidious bug in my code...] now I've got another problem. I got a segfault at the end of my program, after python has destroyed all the objects (I know that because I've put a printf in the dealloc functions. so this is not very important since it crashes only at termination). I got the segfault in that case : - I've got 2 type object defined in C (if 1 of the 2 is defined in Python, it won't crash) : one is a carrier which a Pyobject* (given at creation, the carrier Py_INCREF the PyObject given and Py_DECREF it at deallocation), the second is a carried (handled by the carrier of course :) - The carrier have an attribute that return the carried - After creating a carrier containing a carried, I ask the carrier to print the object carried Some precisions : - I don't have 100% crashes - it seems that the crash occurs only when sizeof(carried) >= 40 - I have Python 2.2a3 and work under Linux I've done the minimal code to get the crash, if someone is interested (?), I can send it (I cannot manage to send the file attached with this mail, sorry) This bug is quite strange and I wonder if my code is responsible or not ? thanks -Blam From ignacio at openservices.net Mon Sep 10 16:50:19 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Mon, 10 Sep 2001 16:50:19 -0400 (EDT) Subject: smtp.sendmail read receipt? In-Reply-To: Message-ID: On 10 Sep 2001, Scott Nadeau wrote: > I'm trying to figure out how to get a read receipt when a recipient > has read an e-mail that my program is sending. I've searched the web > for the answer, but I can't seem to find it. This is my current > (working) code... http://www.rfc-editor.org/rfc/rfc1891.txt -- Ignacio Vazquez-Abrams From stuart at bmsi.com Wed Sep 26 12:51:59 2001 From: stuart at bmsi.com (Stuart D. Gathman) Date: Wed, 26 Sep 2001 12:51:59 -0400 Subject: Embeding Python & Dynamic Callbacks References: <916a2aab.0109260249.318d156f@posting.google.com> Message-ID: <9ot13e$4od$1@nntp1-cm.news.eni.net> In article <916a2aab.0109260249.318d156f at posting.google.com>, "Paul Tate" wrote: > I can dynamically create the method table, but I cannot dynamically > create a C callback function. If I use the same callback for each > dynamically loaded function, I do not know how to find out which token > caused the callback to be called. idea 3 - allocate a callable extension type for each dynamic C function. The extension object contains whatever the common callback function needs to know to find the dynamic C function. Put the callable types in the module dictionary along with the direct methods - even for C code loaded *after* initializing the module. -- Stuart D. Gathman Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154 "Confutatis maledictis, flamis acribus addictis" - Mozart background song for the Microsoft "Where do you want to go from here?" commercial. From loki at cs.usyd.edu.au Wed Sep 5 19:39:41 2001 From: loki at cs.usyd.edu.au (Loki Patrick) Date: Thu, 06 Sep 2001 09:39:41 +1000 Subject: Parsing Python question (newbie) Message-ID: <3B96B7BD.2DB00D0D@cs.usyd.edu.au> Hi, I've been toying with writing a parser (in Python) for Python. Has someone already done this? A .py to .pyc compiler would be nice. I know there is some kind of parser generator written in C bundled with Python, but does it produce recursive descent parsers, or table driven? I'd prefer recursive descent for reasons of readability. Any help would be appreciated. Loki From deltapigz at telocity.com Sat Sep 29 17:24:57 2001 From: deltapigz at telocity.com (Adonis Vargas) Date: Sat, 29 Sep 2001 17:24:57 -0400 Subject: Threads + Enviroment Variables Message-ID: im having problems accessing enviroment variables from within a thread; the error im am getting is an 'undefined' error, but the variables i definded but in a module-level. i.e. -- in module something.py -- something = [] -- in script -- from something import * # import the variable 'something' right? def somefunction(somevalue): return somevalue+=1 def somethreadedfunction(): for i in range(10): something = somefunction(0) # boom. an 'undefined' error??? print something Thread(target=somethreadedfunction).start() -- now this is not the real code im working on; since the code im working on is very complex i chose not to paste it; just provided the general idea of what i am trying to accomplish, therefore the code provided could not be correct. any help would be greately be appreciated. Adonis From aleax at aleax.it Fri Sep 14 05:43:31 2001 From: aleax at aleax.it (Alex Martelli) Date: Fri, 14 Sep 2001 11:43:31 +0200 Subject: Newbie: Why Does This Work This Way...Global Variables And The Signal Module.... References: Message-ID: <9nsjg4023kd@enews2.newsguy.com> "Ignacio Vazquez-Abrams" wrote in message news:mailman.1000434075.23039.python-list at python.org... ... > e=select.select([sys.stdin], [], [], 0) ... > There's no reason why it couldn't catch another character if the select() > function returns on any keypress, which it doesn't seem to on Linux :/ That strictly depends (assuming sys.stdin isatty) whether the tty is in raw or cooked mode (and details of said mode). Alex From aleax at aleax.it Fri Sep 7 10:24:12 2001 From: aleax at aleax.it (Alex Martelli) Date: Fri, 7 Sep 2001 16:24:12 +0200 Subject: newbie: cannot import name error References: <3B98D4F6.445C1525@engcorp.com> Message-ID: <9nalad0unl@enews1.newsguy.com> "Peter Hansen" wrote in message news:3B98D4F6.445C1525 at engcorp.com... ... > On the other hand, you're trying to do something I've _never_ > needed to do yet, after almost two years with Python. Any time > (to date) I've needed to install an extension, I've been okay > with just copying it to the python/lib folder, or with adding Then maybe you use a platform for which precompiled C extensions are easier to come by than for Solaris, and have never needed to build your own (because the distutils are the easiest way to build C extensions anyway). Alex From jtdubs at eos.ncsu.edu Mon Sep 10 01:05:43 2001 From: jtdubs at eos.ncsu.edu (Justin Dubs) Date: Mon, 10 Sep 2001 01:05:43 -0400 Subject: large class hierarchies in python References: <9ner16$sbt$1@uni00nw.unity.ncsu.edu> <7934d084.0109091703.6414e22a@posting.google.com> Message-ID: <9nhhn5$g1o$1@uni00nw.unity.ncsu.edu> Thank you for the suggestions. I have already taught myself the basics of Prolog, Postscript and Lisp. I will look into the rest of them though. I am trying to expose myself to all of the various unique methods of programming for the purposes of eventually designing one of my own also for purely theoretical and curiosity-based reasons. In order of abstraction, starting at the lowest is obviously assembler. I know that for both x86 up through Pentium as well as the basics of motorola assembler. Above that I have C. Above that I have C++, Objective-C, Pascal, Basic as well as more visual languages such as Visual BASIC, Visual C++, Java and TCL and FoxPro. Above that I have Perl, Python. Above that I have Prolog, Lisp. Also, more miscellaneously, HTML, Javascript, VBScript, SQL and Shell scripting and a little of postscript and smalltalk. I"ll dive into Haskell/Forth/Miranda/APL and see what I like. I also want to do a little Scheme and Eiffel at some point. Thanks a lot for the suggestions. Do I appear to be missing any categories of languages? I have the basic OO, Functional, Scripting languages covered, I think. Thanks again guys, Justin Dubs From loewis at informatik.hu-berlin.de Tue Sep 18 13:31:16 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 18 Sep 2001 19:31:16 +0200 Subject: nntplib and xover References: Message-ID: rickp at telocity.com (Rick Pasotto) writes: > Some news servers return the Xref: line in response to the XOVER > command. Currently the nntplib does not include this line. > > 1) Will this be included in future versions? > 2) What is the best way to get this line now? I'd recommend to use the .xover method of the NNTP class. Guido's time machine at work? Regards, Martin From slgrph at icehouse.net Fri Sep 14 16:01:29 2001 From: slgrph at icehouse.net (Shirley) Date: Fri, 14 Sep 2001 13:01:29 -0700 Subject: DataComPro Needs Typists/Compilers Message-ID: <130280-22001951420129780@icehouse.net> Home Typists Needed!!!! We are looking for a few dependable people who desire an earning of substantial income right in the comfort of their homes. We need local compilers to secure and type our exclusive mailing lists in nearly every city of the country and we are not about to open thousands of offices nationwide. That is why we need YOU! We appreciate your assistance, so we do our very best to make it easy for you. Simply follow our instruction kit and hand written names and addresses come to you every day and all you have to do is submit them for your pay of $3.00 for each and every name and address you compile and type! Paychecks are mailed on the 1st and 15th each month! NEW BONUS SYSTEM NOW ADDED! After submitting 100 names to BestBizUsa, you will now be paid $4 per name! Also, we now have weekly bonuses set up !! Do not confuse this one of a kind offer with any unwanted commissioned mailing programs, envelope stuffing, or any other such deceptive nonsense. This is legitimate home employment that is not a get rich quick job, but you can make a part time income fairly easily. Working with BESTBIZUSA Typing Resource Centers gives you the freedom to stay at home and create your own hours. If you are a parent with children, this type of work is very beneficial because it allows you to be a stay at home parent. These are only a couple of the perks, let's not forget the money. The more time you put into this job, the more you will get out of it. Because we need local typists immediately, we will hold your position open for the next 10 working days. So if you would like to begin working and making money, email me at slgrph at icehouse.net for more information Your email address was part of a purchased list and I believe you are someone interested in Internet Business Opportunities. If I received your e-mail in error, or you are no longer interested, click here to be removed. Be sure REMOVE is in the Subject Title and you will not be contacted again: From gerson.kurz at t-online.de Fri Sep 7 02:55:40 2001 From: gerson.kurz at t-online.de (Gerson Kurz) Date: Fri, 07 Sep 2001 06:55:40 GMT Subject: py2dll ? Message-ID: <3b986e2c.72980718@news.isar.de> Is there something like py2exe, that generates DLLs ? I've embedded the best programming language in the world, Python, to my existing C application. Actually, I start up a python-powered webserver, with fixed scripts. Currently, I use PyRun_SimpleFile() for this; it would be great if it were possible to generate a DLL from the scripts and call this instead. In my rather simpleminded viewpoint, this should more or less only mean changing main.exe to main.dll, and exporting a standard function from it, right ? From boyd at insultant.net Tue Sep 25 00:08:46 2001 From: boyd at insultant.net (Boyd Roberts) Date: Tue, 25 Sep 2001 06:08:46 +0200 Subject: Why so few Python jobs? References: <3BAF5062.FC4F00D3@hotmail.com> Message-ID: <9op06b$shl$1@neon.noos.net> "David B Terrell" a ?crit dans le message news: slrn9qvh1s.lfl.dbt at pianosa.catch22.org... > David Terrell | "Instead of plodding through the equivalent of > Prime Minister, NebCorp | literary Xanax, nah, xanax's name is alprazolam :) From rickf at glacier.jpl.nasa.gov Wed Sep 26 19:31:07 2001 From: rickf at glacier.jpl.nasa.gov (Rick Forrister) Date: Wed, 26 Sep 2001 16:31:07 -0700 Subject: timegm() equivalent function in Python? Message-ID: <3BB2653B.A5A2DE10@glacier.jpl.nasa.gov> Working on converting a collection of perl utilities I've written for projects to Python. Am encountering a problem in time conversions; we need to process date strings from a YYYY-MM-DDTHH:MM:SS.SSSSSZ format (Zulu time = GMT = UTC) into unix epoch date format. time module does not list function which takes as input a time tuple and returns UTC based epoch time. Is there such a module out there somewhere? Parsing the string from the ascii format mentioned above into date & time chunks is no problem of course, split handles that quite nicely. It's the conversion from a UTC based tuple set -> epoch time value that I need. Appreciate rickf -- "The best we can hope for concerning the people at large is that they be properly armed." -- Alexander Hamilton, The Federalist Papers at 184-188 From jblazi at hotmail.com Thu Sep 20 14:22:57 2001 From: jblazi at hotmail.com (Janos Blazi) Date: Thu, 20 Sep 2001 20:22:57 +0200 Subject: Best book on Python? References: <9oasom$pit$1@plutonium.btinternet.com> Message-ID: <3baa3411_3@news.newsgroups.com> I have read "Learning Python" by Mark Lutz and after glancing through it for an afternoon I could start working in the evening. I still think that the material is very well chosen and the presentation is precise and enjoyable. So in my opinion it is the best book on Python. My other Python book is "Python and Tkinter Programming" by John Grayson and though it contains a lot of information, virtually everything you need to use Tkinter, I wish he would give more explanations instead of examples. J.B. -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! Check out our new Unlimited Server. No Download or Time Limits! -----== Over 80,000 Newsgroups - 19 Different Servers! ==----- From s713221 at student.gu.edu.au Tue Sep 18 22:00:31 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Wed, 19 Sep 2001 12:00:31 +1000 Subject: Direct TK interface References: <2764949.5mLc6kNg2l@lunix.schabi.de> Message-ID: <3BA7FC3F.D21E3A95@student.gu.edu.au> Markus Schaber wrote: > > Hi, > > I was just wondering whether it is possible (and worth in sense of > speed etc.) to directly interface TK into python (without using the TCL > interpreter inbetween). > > markus Don't know if this is what you want, but you can look up Rivet in the Vaults. -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From logiplexsoftware at earthlink.net Fri Sep 7 17:21:02 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 7 Sep 2001 14:21:02 -0700 Subject: Creating Excel files on Linux In-Reply-To: References: <3B97A39C.6A5234D7@olen.to> Message-ID: <01090714210205.02565@logiplex1.logiplex.net> On Friday 07 September 2001 13:16, you wrote: > > > Yes, poor little innocent IBM. The same company that till recently was > known for a monnolithic culture stangling in neckties and suits. The fact > that Gates took them for a ride is a reflection of their own idiocy and > their stunning lack of vision. > have a good wekend all, > Maan Yep, they have been/are a lot of suits. Nevertheless, they have _always_ had a tradition of being extremely fair with their business partners and Gates & Co took advantage of _that_. Had IBM dealt with Gates the way Gates deals with his business "partners", IBM would have owned DOS and Microsoft would be but a small footnote in PC history. It's more like the idiocy and stunning lack of vision of the average PC user, who choose MS on a daily basis. The vision of MS provided us with 16-bit OS's for a decade after the introduction of the 386. It also provided us with the petri dish for hundreds of VBA macro viruses. Wasn't part of their vision also to "replace" the Internet with MSN? Besides, I never suggested anything about "poor little" IBM. Since you missed the point, I will expound: I was referring the fact that they are 10 times the size of Microsoft (I'm not referring to the nonsense of the stock market, but actual employees/revenue, etc) and are investing 1 billion this year to Linux development and promotion. Have a very nice weekend. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From SBrunning at trisystems.co.uk Fri Sep 21 04:47:39 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Fri, 21 Sep 2001 09:47:39 +0100 Subject: Converting tuples to dictionaries? Message-ID: <31575A892FF6D1118F5800600846864D78C1C1@intrepid> > From: Mart van de Wege [SMTP:mvdwege.usenet at drebbelstraat20.dyndns.org] > Apologies if this turns out to be a FAQ, but I couldn't find it in the > standard > docs and the books I own on how to do it. So without further ado, I'll > state > the question: > > I have some data in an SQL database. Now AFAICT psycopg (aka pythonDB 2.0 > for > PostgreSQL) returns the query results as a list of tuples. The data that > returns from my query would fit very well in a dictionary, ie. tuple[0] > would > be the key, and the rest would make the value (or list of values), in fact > the > conceptual model I have for my program would *need* a dictionary to > process. > > Now the obvious way to turn a list of tuples into a dictionary would be to > loop > over the list and convert them by assigning tuple[0] to be the key and the > rest > of the tuple the value. Slightly more efficient would be to define a > function > that does that with one tuple and then map the function on the list. > > The question is, is this really the only way to go about that, or am I > barking > up the wrong tree entirely? It really seems like a brute force approach to > me. > Is there an alternative? Marc-Andr? Lemburg's mxTools () includes a dict function which does *almost* what you want... 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 dalke at dalkescientific.com Fri Sep 21 22:33:49 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Fri, 21 Sep 2001 20:33:49 -0600 Subject: To re or not to re ... ( word wrap function?) References: <3BABBDFA.456B4B45@home.net> Message-ID: <9ogt5n$tjp$1@slb6.atl.mindspring.net> Skip Montanaro: >I've been using this to format text for a long time. It runs on a 1.5.2 >system so it doesn't use string methods or any 2.0+ syntax. Another Python implementation I've seen (not tested) is Andrew Kuchling's 'tex_wrap', which implements the line break method used by TeX. http://www.amk.ca/python/code/tex_wrap.html Andrew dalke at dalkescientific.com From duncan at NOSPAMrcp.co.uk Tue Sep 25 09:37:58 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Tue, 25 Sep 2001 13:37:58 +0000 (UTC) Subject: Why so few Python jobs? References: <200109250603.f8P63W014851@hera.cuci.nl> Message-ID: "Carlos Gaston Alvarez" wrote in news:mailman.1001409027.8458.python-list at python.org: > ?Python? Arguments againts it (from the boss himself) was that it > was an > internet language and that he was told that it was going to disapear in > a few years. So I toll him that it was not true. And even if he had to > rewrite it in some years he would have saved money (because of > prototiping). There is a very good point here. The last few times I have had to write something in C/C++ I have written it first in Python to get it all working and then (when necessary) written a C/C++ version based on the Python code. My experience is that this results in a shorter development time, and better code, than writing in straight C/C++. Of course usually you can get the time even shorter by skipping the conversion to C/C++ and just shipping the Python version. -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? From breakfast at 10.am Thu Sep 27 14:07:11 2001 From: breakfast at 10.am (mallum) Date: Thu, 27 Sep 2001 19:07:11 +0100 Subject: file find module In-Reply-To: <20010927203054.N25063@phd.pp.ru> References: <20010927172051.B1120@10.am> <20010927203054.N25063@phd.pp.ru> Message-ID: <20010927190711.B364@10.am> on Thu, Sep 27, 2001 at 08:30:54PM +0400, Oleg Broytmann wrote: > ...you can easily write your own using os.path.walk(), anf glob (or > fnmatch). aha ! This looks like just whats needed - thanks :) -- mallum From mr.murray at mindspring.com Tue Sep 4 00:04:52 2001 From: mr.murray at mindspring.com (Andrew Murray) Date: Mon, 3 Sep 2001 21:04:52 -0700 Subject: Quick Correction References: <9n1jdn$ads$1@slb3.atl.mindspring.net> Message-ID: <9n1jn7$ps$1@slb3.atl.mindspring.net> Grrrr.... Please read: dataMembers = append(myOtherClass("hello from # " + str(i)) As: dataMembers.append(myOtherClass("hello from # " + str(i)) "Andrew Murray" wrote in message news:9n1jdn$ads$1 at slb3.atl.mindspring.net... > Hi, > > I'm looking into writing some types in C for use in a Python program > I'm working on. I've been reading and it looks really easy (especially > with SWIG) to create a simple type in C for use in python, but does anybody > know > how (or can point me to a good reasource on how) to create a type in C > whose data members would be other types written in C? For instance, if I > wanted to recreate this (ficticious) type: > > Class myClass(): > dataMembers = [] > def __init__(self, integer_input): > i=0 > while(i < integer_input): > dataMembers = append(myOtherClass("hello from # " + str(i)) > def printMessages(self): > for member in self.dataMembers: > member.printMessage() > > Class myOtherClass(): > message = '' > def __init__(self, string_input): > self.message = string_input > def printMessage(self): > print self.message > > I hope this example is clear... Please advise > > Thanks, > > Andrew Murray > > From johnroth at ameritech.net Sun Sep 30 08:39:20 2001 From: johnroth at ameritech.net (John Roth) Date: Sun, 30 Sep 2001 05:39:20 -0700 Subject: Justifying text. References: <3BB55DEC.67F78190@yahoo.com> <9p4hjr$h2v$1@neon.noos.net> <9p54ga$loj$1@tyfon.itea.ntnu.no> <9p5fib$q7r$1@hadron.noos.net> <9p5uln$4o9$1@tyfon.itea.ntnu.no> <9p69ah$daf$1@neon.noos.net> <3BB6D7EE.D87FAF00@yahoo.com> Message-ID: "A.A" wrote in message news:3BB6D7EE.D87FAF00 at yahoo.com... > I've really messed up: IN short, I just wanted to write a program in > python that justified plain text in a .txt to a specified margin. Justification is not difficult. There are a number of approaches, depending on what you want to do. If the text is already properly split into lines, see the .ljust, .rjust and .center string methods. If it isn't, then you need to break it into lines. There may be easier methods, but I use a simple loop, scanning backwards from the maximum line length until I hit white space. The following may do what you want: # translate MS Word text format with no line breaks to 80 character # line output. Each paragraph is presumed to be a single input line. import sys def ltDriver(fnIn, fnOut): inFile = open(fnIn, "r") outFile = open(fnOut, "w") for line in inFile.readlines(): i = 0 if line[-1] == '\n': line = line[:-1] + " " while i < len(line): j = min(i + 80, len(line) - 1) while j > i and not line[j].isspace(): j -= 1 while j > i and line[j].isspace(): j -= 1 outFile.write(line[i:j+1] + "\n") i = j + 1 while i < len(line) and line[i].isspace(): i += 1 if __name__ == "__main__": ltDriver("B1I14Attack.txt", "B1I14Attack2.txt") John Roth From rnd at onego.ru Thu Sep 20 00:48:45 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 20 Sep 2001 08:48:45 +0400 (MSD) Subject: New Python WebMail app In-Reply-To: Message-ID: On Thu, 20 Sep 2001, Aaron Fransen wrote: >The scuttlebutt is that some future version of Mozilla (near? far?) will >support some kind of rich-text editing function, and whether that will be >IFRAME or not is anyone's guess...except the developers of Mozilla of course >:) If I understand Mozilla team, they are sticking to standards, not to what Microsoft add. So, if IFRAME has the semantics you mention, it will be done. If it will not be in the standard, then it most probably will not be. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Thursday, September 20, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "A big enough hammer fixes anything" _/ From qrczak at knm.org.pl Mon Sep 10 09:42:03 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 10 Sep 2001 13:42:03 GMT Subject: functional vs procedural list comprehension References: <3B9954A7.12E97C21@home.net> Message-ID: Mon, 10 Sep 2001 10:15:14 GMT, Peter Dobcsanyi pisze: > The current semantics can be described (using the last example) as: [...] > In contrast, a functional listcomp's semantics would be: [...] It's the same. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From qrczak at knm.org.pl Sun Sep 9 12:17:47 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 9 Sep 2001 16:17:47 GMT Subject: Proposed PEP for a Conditional Expression References: Message-ID: Sun, 09 Sep 2001 09:42:49 -0500, Michael Chermside pisze: > Included in this email is a PEP which I am putting together dealing with > the idea of introducing a conditional expression into Python. I would > welcome any discussion, suggestions, and/or help, sent either to this > newsgroup under this topic, or emailed to me at . IMHO very well done! > I prefer the syntax of SPEC_2, but am certainly open to other ideas. Me too. > SPEC_4: Use "if c: a else: b". > The following production would be added to Python syntax: > expression: "if" expression ":" expression "else" ":" > expression > The famous "dangling-else" problem would NOT arise because > the "else:" part would be mandatory. > > PRO - [might allow "if c1: a elif c2: b else: c"] > CON - [elif thing would re-introduce dangling else problem] It would not introduce dangling else. You can replace 'elif' with 'else: if', it's unambiguous. You couldn't do that in 'if' statement without introducing an indentation level, which is why 'elif' exists in the first place. 'if' expression doesn't use indentation so having 'elif' there is not that important. The fact that there is always an 'else' makes it possible to distinguish between 'if' statement and 'if' expression if somebody cares (there shouldn't be any need for distinguising these). The 'if' statement really looks like two statements, split before 'else', so there is no overlap in syntax. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From jknapka at earthlink.net Wed Sep 5 06:01:48 2001 From: jknapka at earthlink.net (Joseph Andrew Knapka) Date: Wed, 05 Sep 2001 10:01:48 +0000 Subject: overriding tks text insert method References: <3B936093.929DEA42@earthlink.net> <01090512113900.22018@pmm19> Message-ID: <3B95F80C.E5641D2C@earthlink.net> Christof Ecker wrote: > > Hi Joseph, > > thanks for your comments. I have been playing with your code yesterday and I > discoverd an additional problem: > what I need is to execute a cleanup procedure AFTER text has been inserted or > deleted. If you override Tks default binding by an input handler routine, the > handler will be executed BEFORE the default binding. > > This is because, the default bindings are bound to the text class, whereas the > "user"-bindings are bound to the class instrance and have therefore higher > priority and are therefore executed first. > > Any idea ? If you bind to instead of you should get the release events after the insert has occurred. Cheers, -- # Joe Knapka # "You know how many remote castles there are along the # gorges? You can't MOVE for remote castles!" - Lu Tze re. Uberwald # Linux MM docs: http://home.earthlink.net/~jknapka/linux-mm/vmoutline.html From tim.one at home.com Sat Sep 8 23:23:11 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 8 Sep 2001 23:23:11 -0400 Subject: PyArg_ParseTuple O format semantics In-Reply-To: Message-ID: [Tim] > News to me, and I see nothing about that in the CVS log. The only 2.0.1 > patch to getargs.c plugged a memory leak in vgetargskeywords(); it was > leaving the refcounts on names of keyword arguments too high, > when iterating over a keyword dict. [Robin Becker] > I guess that might be it. I suppose if anyone had taken action to correct > the memory leak then when it was fixed --> 2.0.1 then their extra DECREF > would be wrong. Yes, that would cause problems indeed. BTW, the Subject line was misleading, because this really has to do with PyArg_ParseTupleAndKeywords, and is specific to the "keywords" part of that. And I was incorrect in saying it left the refcount on the name of the keyword arg too high -- it actually left the refcount on the returned object too high. If you believed the docs and treated the return value as a borrowed reference, then you used to have a memory leak and don't anymore. It's probably rarely a serious leak, else the bug wouldn't have gone undetected for so long (years). Here's the original patch that fixed it: http://mail.python.org/pipermail/python-checkins/2000-December/014550.html in response to this October 2000 bug report: http://sf.net/tracker/?group_id=5470&atid=105470&func=detail&aid=219862 From jbranthoover at yahoo.com.NOSPAM Fri Sep 14 15:00:59 2001 From: jbranthoover at yahoo.com.NOSPAM (John Branthoover) Date: Fri, 14 Sep 2001 19:00:59 GMT Subject: Newbie: Why Does This Work This Way...Global Variables And The Signal Module.... References: Message-ID: Hey thanks Ingacio, This works great. Pressing enter is much better than CTRL C. I don't know much about the select(), but I read in another article that it is a line orientated device. The articled told how to put it into a charter mode using TERMOIS and termios modules. Unfortunately I do not have access to the termios module. I would like to have an "any key" function. I am basically a hardware guy and I am in the process of writing checkout software for a board that I have designed. The Python installation that I am working with was ported over by one of our software engineers. I had him look into getting ncurses to compile but after a half of a day he gave up. He has more important issues to deal with than getting me access to pretty colors, windows and other curses goodies. Which he does. I have Linux installation at home and have played with the Python curses module and I know what I am missing. Any way thanks again for your help...... "Ignacio Vazquez-Abrams" wrote in message news:mailman.1000434075.23039.python-list at python.org... > On Fri, 14 Sep 2001, John Branthoover wrote: > > > OK, that makes sense. Is there not away to define a global variable > > once for all of the functions in the module? > > Nope. At least not that I know of. > > > Or better yet, is there a better way to break out of a endless loop. > > The loop will display some values continuously. I want to be able to get > > out of this loop and go back to a main menu. I am working on an Lynx box > > (not Linux) with no GUI or even curses support. > > The following will run until you press enter: > > --- > import sys, select > > def run(): > while 1: > e=select.select([sys.stdin], [], [], 0) > if not e==([], [], []): > c=sys.stdin.read(1) > if c=='\n': > break > print "You can't catch me, I'm the gingerbread man!" > > run() > print "D'oh! You caught me!" > --- > > There's no reason why it couldn't catch another character if the select() > function returns on any keypress, which it doesn't seem to on Linux :/ > > Also, if you can put a termcap/terminfo into the Lynx box, you may be able to > get (n)curses working. > > -- > Ignacio Vazquez-Abrams > > > > From loewis at informatik.hu-berlin.de Fri Sep 14 08:56:47 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 14 Sep 2001 14:56:47 +0200 Subject: Namespace confusion References: <9nssgi$oiv$1@news.netcologne.de> Message-ID: Luna Tic writes: > I get an error message certainly because of the interdependence of > those two modules, am I right? Indeed. Your problem slightly varies depending on whether you attempt to import foo or bar. Suppose your application does "import foo". Then you get the following sequence of events 1. import foo. an empty foo is added to sys.modules, which gets filled as execution of foo progress 2. foo executed import bar. bar is added to sys.modules, and execution of bar starts. 3. bar performs import foo, and gets a reference to the module whose initialization is in progress. 4. class bacon is defined; initialization of bar completes. 5. initialization of foo resumes, defining class foo 6. i = foo() is executed, but in substeps: first, the right-hand side is executed, then the assignment is performed, so: 6a) a foo.foo instance is created b) its __init__ is invoked, performing bar.bacon() c) a bar.bacon() instance is created d) its __init__ is invoked, performing foo.i.list.append At this time, neither foo.i is assigned, nor does the object that would be assigned have a list attribute yet. If your application starts with "import bar", it does not get that far: 1. import bar. Add bar to sys.modules. 2. performs import foo. Add foo to sys.modules 3. inside foo: import bar; obtain reference to bar 4. define class foo.foo 5. perform i = foo() 5a) create foo.foo instance b) call its __init__, referring to bar.bacon. Class bacon has not yet been defined. If your main program is "python foo.py", you are in more troubles: foo.py will define the module __main__, not the module foo. So the import foo will load a second copy of foo. If that is your problem, you should avoid having global variables in the __main__ module; write a separate application script instead. To avoid the problem in the second run, delay imports as much as possible: # foo.py class foo: def __init__(self): import bar self.attr = bar.bacon() self.list = [] i = foo() # bar.py class bacon: def __init__(self): import foo foo.i.list.append(1) Now, importing bar will do nothing but create a class bacon; foo will be imported only when a bacon instance is created. Importing foo will still run into the problem that i is not assigned. To avoid this, you have to rearrange the constructors. Here are a couple of options: A. Delay setting of attr # foo.py class foo: def __init__(self): self.list = [] i = foo() import bar self.attr = bar.bacon() # bar.py class bacon: def __init__(self): import foo foo.i.list.append(1) B. Delay appending bacons # foo.py class foo: def __init__(self): import bar self.list = [] self.attr = bar.bacon() i = foo() i.attr.register() # bar.py class bacon: def register(self): import foo foo.i.list.append(1) C. register into different variable # foo.py class foo: def __init__(self): import bar self.attr = bar.bacon() self.list = [] i_list = [] i = foo() i.list = i_list # bar.py class bacon: def __init__(self): import foo foo.i_list.append(1) I don't know what you problem you are really trying to solve; it seems you'd be better of with less cyclic structures. Regards, Martin From peter at engcorp.com Wed Sep 12 23:43:48 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 12 Sep 2001 23:43:48 -0400 Subject: Locating Relative Resource Files References: <3B9FC419.42BADEE4@bgb.cc> Message-ID: <3BA02B74.AE351A0D@engcorp.com> Gordon McMillan wrote: > > Don Garrett wrote: > > > Is there some way to determine the location of the file from which > > the currently executing source was loaded? Or the file/directory of > > the initial python script? > > os.path.dirname(sys.argv[0]) should do it (although it may be '', > meaning os.getcwd() is the script's directory). I think this is close to being a FAQ. The last time it came up, I think we settled on: os.path.abspath(sys.argv[0]) Looking at abspath() in the module index, it says on most platforms it is equivalent to os.path.normpath(os.path.join(os.getcwd(), <>)) If sys.argv[0] specifies an absolute path, that expression just returns sys.argv[0]. If it is relative, it is converted to absolute by joining with the current directory. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From jh at web.de Mon Sep 17 13:05:42 2001 From: jh at web.de (Jürgen Hermann) Date: Mon, 17 Sep 2001 19:05:42 +0200 Subject: [ANN] PIRXX 1.1 Message-ID: <9o5afl$d06$03$1@news.t-online.com> This is the first release of PIRXX, a wrapper of Xerces and Xalan for Python. Currently, it contains a working SAX2 driver for the Xerces parser. What's missing is the locator mechanism, and the DTDHandler and EntityResolver interfaces. Homepage: http://pirxx.sourceforge.net/ Download: http://sourceforge.net/project/showfiles.php?group_id=25711 Mailing list: http://mail.python.org/mailman/listinfo/xml-sig From cprinos at foliage.com Thu Sep 6 09:09:40 2001 From: cprinos at foliage.com (Chris Prinos) Date: 6 Sep 2001 06:09:40 -0700 Subject: Change in IE COM behavior Message-ID: I had for some time been using the win32com.client package to control MS Internet Explorer, but recently have seen a change in it's behavior. What used to happen is that each time I called win32com.client.Dispatch('InternetExplorer.Application') I would get a new instance of the browser. Now when I do it, I get attached to the topmost _existing_ browser window (could be an IE window, or an explorer window). Subsequent calls attach to the same instance, rather than creating new ones. It is probably some recent installation/update that caused this, but I'm not sure where to start looking... has anyone seen this before? I'm running Python 2.1 (ActiveState build 211) with win2k (latest service pak applied) and IE 5.5. Chris From comments at cygnus-software.com Thu Sep 27 02:34:08 2001 From: comments at cygnus-software.com (Bruce Dawson) Date: Thu, 27 Sep 2001 06:34:08 GMT Subject: scanf style parsing References: <3BB16A50.BAE082FE@cygnus-software.com> Message-ID: <3BB2C7DA.F63EEAA7@cygnus-software.com> Wow! Great answers. And incredibly fast. Thanks to all. Rather than the long and complicated PEP route of adding scanf style functionality to Python it would probably be enough to just add some more examples to the Python regexp documentation. I searched the Python documentation for scanf() and I looked at the regexp documentation, so if it had contained the examples in this reply or others I would have done my parsing properly long ago. For Perl hackers it is easy to figure out regexp, but for us old C/C++ types, it's *tough* Then again, I *always* say that the documentation is the problem... Thanks again. Richard Jones wrote: > On Wednesday 26 September 2001 15:42, Bruce Dawson wrote: > > I love programming in Python, but there are some things I have not found > > the easy way to do. > > That's what we're here for :) > > > I understand that Python is supposed to be good at > > text parsing, but I am having trouble with this simple task. Given this > > text (the output from VisualC++) I want to find out how many errors and > > warnings there were: > > > > smtpmail.exe - 0 error(s), 0 warning(s) > > > > In C/C++ that would be something like: > > sscanf(buffer, "smtpmail.exe - %d error(s), %d warning(s)", &errors, > > &warnings); > > > > It's not that I think the sscanf syntax is particularly elegant, but it > > sure is compact! I saw the discussion about adding scanf to Python > > > > http://mail.python.org/pipermail/python-dev/2001-April/014027.html > > > > but I need to know what people do right now when faced with this task. > > Right now, people use regular expressions, which are more flexible that > sscanf, but don't do the type conversions (everything comes out as a string) > and are a little more verbose, code-wise. > > [richard at ike ~]% python > Python 2.1.1 (#1, Jul 20 2001, 22:37:24) > [GCC 2.96 20000731 (Mandrake Linux 8.1 2.96-0.58mdk)] on linux-i386 > Type "copyright", "credits" or "license" for more information. > >>> import re > >>> scan = re.compile(r'smtpmail.exe - (\d+) error\(s\), (\d+) warning\(s\)') > >>> result = scan.match("smtpmail.exe - 0 error(s), 0 warning(s)") > >>> errors, warnings = map(int, result.groups()) > >>> errors > 0 > >>> warnings > 0 > >>> > > ... or something similar. The RE can be made more flexible to allow, eg. the > non-existence of the ", %d warning(s)" part: > > >>> scan = re.compile(r'foo.exe - (\d+) error\(s\)(, (\d+) warning\(s\))?') > >>> result = scan.match("foo.exe - 0 error(s)") > >>> result.groups() > ('0', None, None) > >>> result = scan.match("foo.exe - 0 error(s), 0 warning(s)") > >>> result.groups() > ('0', ', 0 warning(s)', '0') > > ... and so on... > > Richard From thomas.heller at ion-tof.com Tue Sep 25 15:53:23 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Tue, 25 Sep 2001 21:53:23 +0200 Subject: COMServer thru Py2Exe question !! References: <8f8ffe67.0109251142.43246129@posting.google.com> Message-ID: <9oqnbk$egujt$1@ID-59885.news.dfncis.de> "Sunit Joshi" wrote in message news:8f8ffe67.0109251142.43246129 at posting.google.com... > Hello COM Gurus: > > I have a small problem: I can get VB6 to instantiate a PyCom object > created thru py2exe. However each time I try to create the COM Server, > a DOS window flashes for a second, I guess because of the line > D:\PROGRA~1\TestCom\testCom.exe {3882ECFF-3B74-4444-BB47-BDC2285CEB95} > where the testCom.exe is run. > > Is there any way of getting rid/minimizing the DOS window ?? > > thanks > Sunit Simply build with the -w (or --windows) command line flag to suppress the DOS box: python setup.py py2exe -w Regards, Thomas From aleaxit at yahoo.com Sun Sep 9 04:19:04 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 9 Sep 2001 10:19:04 +0200 Subject: Very elementary help in using Python on Windows 98 References: <3b98e582.0@news.acay.com.au> Message-ID: <9nf8kr02jam@enews4.newsguy.com> Jeff Melvaine wrote: > I have begun to experiment with Python on Win98 on my personal laptop. > When I set up a script xxx.py and double click the icon to run it, I get a > window (presumably some kind of debugging console)which lasts for a few > seconds, > flashes a message and dies instantly so I can't read it. There is > evidently a problem in my script somewhere, but how can I get the window > to hang around long enough to see what it is? Suppose your script is very well organized: only def and class statements first, including a def main statement creating a function named main, then at the end a statement such as: if __name__=='__main__': main() If so, then the only thing you need is to turn this last statement into: if __name__=='__main__': try: main() finally: raw_input("Press Enter to terminate") try/finally is a precious statement: the finally clause is executed no matter how the try clause terminates -- be it "normally", or because of an exception. It's normally used to ensure some needed finalization. In an environment which makes your console window disappear on termination, such as running a Windows program by double-clicking on an icon, you can look at this explicit "wait half a sec before closing the console" as a needed finalization. On some Windows platforms you can set a console's properties to "no auto-closing" depending on the shortcut reached to open it, but I'm not sure this is available on Win98 nor how exactly to go about it -- it's not a Python question anyway, but a Windows one. If your code is not as well organized as this, you can still use try/finally (all you have at top level now can be indented 4 spaces and go inside the try clause), although it would be worth taking the occasion to enhance program organization as well. > When I start up the Python interpreter in its own window, it doesn't seem > to > know where my script is. Do I need to set a path variable somewhere to > tell Not the way python.exe works today, alas: rather you have to give python.exe the complete path to your script (followed by arguments to the script, if any). The SUBST command of COMMAND.COM, while old and rusty, sometimes comes in handy for that sort of stuff. > I would probably find this much easier in Linux (given my experience on > Unix stations at work, where writing much more complex scripts (even in > Perl :) poses no real problems), but for an application running on this > machine and reading data dumped from Excel and other Windows based > applications, that is not an easy way for me to go. You could consider Cygwin -- it's a good bash shell and a faithful imitation of as many aspects of Linux as Cygnus/RedHat could possibly fit into it -- you can also get an XFree86 port for Cygwin (comes with a lousy old window manager, twm, but once you have Cygwin and X read it's a snap to download tgz's, e.g. for WindowMaker, building it on Cygwin is no harder than ./configure, make, make install -- very much as it would be on Linux). Cygwin comes with a Python 2.1.1 port in the contrib directory, but I'm not sure if the latter does COM or can use win32all (I'd guess not) -- no problem, you can run Windows-native Python under Cygwin anyway, and still get the advantages of bash & good commandline tools. Alex From adina_levin at mindspring.com Sat Sep 22 12:42:26 2001 From: adina_levin at mindspring.com (adina_levin at mindspring.com) Date: Sat, 22 Sep 2001 11:42:26 -0500 Subject: newbie question: converting integer to string Message-ID: <9oifr8$and$1@slb5.atl.mindspring.net> I would like to convert a variable, which represents an integer, to a string. To convert an integer to a string, one simply encloses the string in quotes. e.g. >>> '42' '42' But how do you do this if the integer is represented by a variable? >>> num=42 how can I generate a string representation of num? Thank you very much, - Adina From samschul at pacbell.net Tue Sep 18 20:16:47 2001 From: samschul at pacbell.net (Samuel Schulenburg) Date: 18 Sep 2001 17:16:47 -0700 Subject: bitwsie operator help please References: Message-ID: grante at visi.com (Grant Edwards) wrote in message news:... > In article , David In VA wrote: > > I am not sure how to properly write the bitwise operator but I think it > > will be useful for some thing I need to do. If I want to print "Hello" > > if the value 2^2 (4) is in a given value (lets say testvalue) how would > > I do this? I have been trying this > > > > if 4 & testvalue: > > print "hello" > > It works for me. How exactly is it not working? Works for me also. I let testvalue = 8, and if failed, I then let testvalue = 12, and it printed "hello" Sam Schulenburg From woodm at equire.com Thu Sep 6 15:02:30 2001 From: woodm at equire.com (Matthew D. Wood) Date: Thu, 06 Sep 2001 13:02:30 -0600 Subject: Function to merge sorted lists References: <3B8F1BE0.6060108@erols.com> <87r8tkb51x.fsf@complete.org> Message-ID: <3B97C846.10101@equire.com> Would it be faster to use the list.pop command? I doubt it, but then again, I'm always surprised. John Goerzen wrote: > "Edward C. Jones" writes: > >> Here is a Python program that does the same thing: > > > There's a more straightforward way to do it: > > def merge(l1, l2): > ret = [] > l2c = 0 > for item in l1: > while l2c < len(l2) and l2[l2c] < item: > ret.append(l2[l2c]) > l2c += 1 > ret.append(item) > return ret + l2[l2c:] > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aleax at aleax.it Mon Sep 17 07:27:29 2001 From: aleax at aleax.it (Alex Martelli) Date: Mon, 17 Sep 2001 13:27:29 +0200 Subject: Getting all possible combinations of list items References: <3ba594dd$0$330$6e49188b@news.goldengate.net> Message-ID: <9o4mn102mdn@enews4.newsguy.com> "Martin von Loewis" wrote in message news:j4g09mdvvt.fsf at informatik.hu-berlin.de... > "Greg Krohn" writes: > > > scratching my head over 'magic' code, > > I prefer explicit loops over map and lambdas: So do I, but building up a large string (here, the one in the variable called number) by +'ing small ones in a loop is a disaster. So, I'd make a small mod here: > def magic_algorithm(another_list, count): > length = len(another_list) > result = [] > for i in xrange(length**count): > number = '' change this line to: number = [] > for pos in range(count): > # prepend the next digit > number = another_list[i % length] + number change this line to: number.append(another_list[i % length]) > i = i / length > result.append(number) change this line to: number.reverse() result.append(''.join(number)) > return result The number.reverse() line may not be needed if the SET of strings returned, rather than their order, is what one is after, as is typically the case. I think it would be even clearer if we avoided the inner loop in favour of a clearer one, i.e., rewriting the whole thing for clarity: def magic_algorithm(another_list, count): length = len(another_list) result = [] for i in xrange(length**count): number = [] for dig in digits_in_base(i, length, count): number.append(another_list[dig]) result.append(''.join(number)) return result where, e.g. and still emphasizing clarity: def digits_in_base(value, base, ndigits): result = ndigits*[0] i = ndigits-1 while value and i>=0: result[i] = value%base value /= base i -= 1 return result With this auxiliary function at hand we may also rewrite magic_algorithm using list comprehension, e.g. for the inner loop only: def magic_algorithm(another_list, count): length = len(another_list) result = [] for i in xrange(length**count): result.append(''.join([another_list[dig] for dig in digits_in_base(i, length, count)])) return result or for both loops: def magic_algorithm(another_list, count): length = len(another_list) return [''.join([another_list[dig] for dig in digits_in_base(i, length, count)]) for i in xrange(length**count)] but either or both of these might be considered as over-application of the list comprehension form, depending of course on one's attitude to list comprehension form itself. Personally, I prefer the penultimate one, because it seems to me that the last one is hard to follow -- it's unusual to have a list comprehension inside another list comprehension, after all. But there's not much to choose among them except personal taste issues:-). Alex From chrishbarker at home.net Wed Sep 12 18:17:52 2001 From: chrishbarker at home.net (Chris Barker) Date: Wed, 12 Sep 2001 15:17:52 -0700 Subject: references/pointers in Python? References: <20010912194833.B30374@simba> <20010912210927.A30757@simba> <01091212060600.09769@logiplex1.logiplex.net> Message-ID: <3B9FDF10.9BF06240@home.net> Anton Lavrik wrote: > You are right! I'v already found one wonderfull solution for the > problem. Actually references were not the only way for making it. > But anyway, I can't understend why such powerfull Perl-like references > haven't been implemented in Python. Maybe becasue they aren't neccesary, as your example shows! What was you application, anyway...enquiring minds want to know! -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From t at chabry.caltech.edu Thu Sep 27 01:51:33 2001 From: t at chabry.caltech.edu (Titus Brown) Date: 26 Sep 2001 22:51:33 -0700 Subject: Are there 'Interfaces' in Python?? References: <9orb19$ba6$1@slb6.atl.mindspring.net> <9ot405$3bo$1@chabry.caltech.edu> Message-ID: <9ouep5$8qc$1@chabry.caltech.edu> In article , Tim Hammerquist wrote: >Me parece que Titus Brown dijo: >> >> [ munch of my claim "lack of interfaces sometimes bad, ==> >> "interfaces sometimes good" ] >> >> I would rather regard this as neutral & a convenience for people writing >> code that uses file-object-like-things. It's certainly not a convenience >> for people writing new classes that attempt to emulate the behavior of >> already-existing objects with unclear definitions, and it sure would be >> nice to have the option of some type checking built into the language, >> but I understand why it's not there and appreciate the convenience. But >> there are downsides too... > >This sounds like one of the many threads in c.l.smalltalk. :) > >If you want to use interface-style type checking, the following might >work for you: > >class MyInterface: > # define > >class MyIFClass1(MyInterface): > # implement > >class MyIFClass2(MyInterface): > # implement > >class MyIFException(Exception, MyInterface): > # implement and extend > >and use isinstance(obj, MyInterface) to see if it implements it. Well heeeeck, I can write an inheritance based type checker any hour of the day, but if the language libraries don't support it, then you're half pissin' into the wind, aren't you... >It doesn't survive someone deleting keys from the o.__dict__ attribute, >but Python's run-time nature precluded that long ago, didn't it? ;) --titus, who loves programming in Python but wishes that there were even MORE nice, simple solutions to complex problems. From jockmack at hotmail.com Sun Sep 2 05:57:46 2001 From: jockmack at hotmail.com (Jock Mackenzie) Date: 2 Sep 2001 02:57:46 -0700 Subject: wxpython Message-ID: <7592d940.0109020157.5e3212e7@posting.google.com> I have been learning python/wxpython & have written a small program in wxpython that asks for input from the user [using the function wxGetNumberFromUser()] then applies a formula and produces a long integer as a result. I want to display the resulting number from the calculation on the wxFrame or wxPanel or in a dialogbox. I cannot find a function for doing this. Most message boxes only want to return a string not a long integer as I want. How do you do this?? thanks in advance regards Jock. From massmail at lb.bcentral.com Sun Sep 9 17:50:46 2001 From: massmail at lb.bcentral.com (Anonymouse) Date: 9 Sep 2001 21:50:46 -0000 Subject: Ïðîäàæà,ïîêóïêà ïðîäóêöèè,ïîèñê ïàðòíåðîâ. Message-ID: <1000072246.60987.qmail@ech> ????????? ???????! ??? ????? ?????????? ? ?????????? ? ??? ??????, ?????????, ?????, ???????????. ??? ??????? ???????????, ??? ?????????. ??? ??????-?? ?????????? ??? ??????????????? ????? ??????????? ? ????? ?? ???? ???????? ?????? ???????????? ??? ????????????, ?????, ????????, ?????????? ? ?. ?., ?????? ????? ????, ??? ???? ?? ????? ???????????? ???? ????????????, ??????? ?????????? ??? ??????. ????????? ???????? ?????? ? ???????? ??????????????? ? ???????????? ?? ?????? ? ??????, ?? ? ?? ???????, ?? ????? ??????????? ????????? ???? ?????? ???????? ????? ? ? ?????????? ?????. ?????? ????? ???????????? ???????? ?????. ??? ??????? ???????????, ?????? ?? ?????? ???????? ????????, ??????????, ?? ? ????????? ????????????? ??? ?????????????, ??? ? ?????????? ?????????????? ??????????? ???????. ??? ????? ????? ??? International Rectifier, Epcos, Bourns, Metex, unit-t ? ??. ??? ??????? ??????????????- ????????? ?????????, ??????-????, ??????, ???????, ?????, ????? ? ?.?. ??? ???????? ???????, ???????????? ??? ????????????, ???????? ???????, ??????????? ??? ?????? ? ???????????? ???????????, ??????, ????????? ???????????? ? ?.?. ??? ??????? ????????- ? ????????? ????? ?? ???????????? ?????????? ??????????? ???????? ???????-?????? ??????????. ? ?????? ???????? ?????????, ???????????? ????? ??????,?? ??????? ???????????? ?? ????? ????? ? ????????: vielm.narod.ru ?????????? ?? ?????? ????? ????? ????????? ??????????? ? ??????????????????. ?? ?? ?????? ????????????? ??????????, ??? ????? ??????? ?????? ??? ?????????, ?? ???? ???????? ??? ?????????? ????? ?? ???????? ??? ??? ????? ? ? ?????????? ???????? ?????. ???? ??????????? ? ????????? ?????????????? ?? ????? ?????, ?? ?????? ????????? ?? ??? ????: (095) 275-89-94, ??? ?? ??????????? ?????: tandiv at mail.ru . ?? ???? ??? ? ???????? ??????????? ? ???, ??? ??????????? ? ???, ?? ???????? ????????????????? ??????, ???????????? ????????? ? ????? ????????????, ??????????? ????????? ?????? ??????. ?? ???? ???????? ?? ?????? ?????????? ?? ?????????: 275-89-94, 746-68-78. _______________________________________________________________________ Powered by List Builder To unsubscribe follow the link: http://lb.bcentral.com/ex/manage/subscriberprefs?customerid=15131&subid=AB5CC38F93F6C3AA&msgnum=1 From frandebo at latt.if.usp.br Sat Sep 22 16:09:21 2001 From: frandebo at latt.if.usp.br (Francisco Borges) Date: Sat, 22 Sep 2001 17:09:21 -0300 Subject: google and Python ;-) In-Reply-To: <3BACEB9B.5341552E@engcorp.com>; from peter@engcorp.com on Sat, Sep 22, 2001 at 03:50:51PM -0400 References: <3BACEB9B.5341552E@engcorp.com> Message-ID: <20010922170921.A8018@latt.if.usp.br> ? Peter Hansen wrote: > > We all know that Python could be characterised as > > readable, powerful, dynamic programming language > > > > Guess, which languages google user will find by > > using those keywords ;-) > > > > And how many hits will contain "Python". > > I get 11700 hits from > http://www.google.com/search?hl=en&q=readable+powerful+dynamic+programming+language > and 1580 hits from > http://www.google.com/search?hl=en&q=readable+powerful+dynamic+programming+language+python http://www.google.com/search?hl=en&q=readable+powerful+dynamic+programming+language+perl Will give you 3550 hits... http://www.google.com/search?hl=en&q=readable+powerful+dynamic+programming+language+tcl 1,970 hits http://www.google.com/search?hl=en&q=readable+powerful+dynamic+programming+language+Smalltalk 1.300 hits http://www.google.com/search?hl=en&q=readable+powerful+dynamic+programming+language+ruby 258 hits > Not sure what that means... that Python constitutes only 13.5% of > readable, powerful, dynamic programming languages? No, that probably has more to do with the amount of people that are marketing python this way, which is indirectly connected with the amount of people using Python, but there should be (?are?) better ways to estimate that. Peace. -- Francisco. S?o Paulo, Brasil. From brian.smith at thr.ca Fri Sep 21 12:01:51 2001 From: brian.smith at thr.ca (Brian) Date: 21 Sep 2001 09:01:51 -0700 Subject: tkFileDialog and Multiple Filetypes Message-ID: <1984df93.0109210801.8c00851@posting.google.com> I haven't been able to turn up an example of specifying more than one file type per line.e.g n=askopenfilename(filetypes=[("Image Files","*.jpg;*.gif"), ("JPEG",'*.jpg'), ("GIF",'*.gif'), ('All','*')]) This results in a TCL error. I don't want to select multiple files, I just want to display multiple types. Is there a way of doing this? Thanks in advance. From charles at a3a.com.br Wed Sep 5 16:29:30 2001 From: charles at a3a.com.br (Charles) Date: Wed, 5 Sep 2001 16:29:30 -0400 Subject: SocketServer Message-ID: <01090516293000.23511@magneto> Hello Anybody know where ca i find a good tutorial or examples to create a Socket Server ? Regards Charles From rnd at onego.ru Thu Sep 6 07:06:53 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 6 Sep 2001 15:06:53 +0400 (MSD) Subject: out of memory In-Reply-To: <008d01c136c2$84fcf450$a500a8c0@GASTON> Message-ID: On Thu, 6 Sep 2001, Carlos Gaston Alvarez wrote: > What happens when python runs out of memory? > Is there an exception? >>> a=range(10000000) Traceback (most recent call last): File "", line 1, in ? MemoryError > Where are exceptions documented? In the Python Documentation, of course. > Chau & tia, > > Gaston Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From rnd at onego.ru Sat Sep 8 08:47:55 2001 From: rnd at onego.ru (Roman Suzi) Date: Sat, 8 Sep 2001 16:47:55 +0400 (MSD) Subject: Creating Excel files on Linux In-Reply-To: <20010908133602.M18172@phd.pp.ru> Message-ID: On Sat, 8 Sep 2001, Oleg Broytmann wrote: >Hello! > > Completely offtopic. Sorry, I cannot resist. Well... > >On Fri, Sep 07, 2001 at 11:04:37AM -0500, Maan M. Hamze wrote: >> living in. I am not defending Microsoft here, but I am being realistic. > > In you realism you said many bad words about people and companies. I >don't want to be that kind of "realist". I want to be an idealist. Only >idealists can change the world. Realists seems to be slaves of the status >quo. (I am not flaming you, don't take it personnaly.) Probably, the better word is "conformist". It is always easier to be conformists (unless revolution happens ;-) And being non-conformist requires personal sacrifices: I can't apply for grants because they require me to fill Word & Excel forms. (And it turned out that Word documents created by StarOffice crush/hung MS Office 2002 mercilessly.) So, if MIcrosoft monopoly will last, my non-conformistic views will make me non-conformic with the whole society, because I will not be able to interface with state using free systems. For example, if I had a firm, I *MUST* pay for at least MSDOS under which works the program to prepare tax-reports! While such programs are probably just several screens of Python code + database of classificators, etc. The only hope is to convince gov's to use free software as happens in the West. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Saturday, September 08, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Aren't cats just widdle furry balls of love?" _/ From tim.one at home.com Wed Sep 26 00:36:29 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 26 Sep 2001 00:36:29 -0400 Subject: Cygwin Python -- Thread or not to thread... In-Reply-To: <1001462689.4303.8.camel@lifelesswks> Message-ID: [posted & mailed] [Tim] > 2. See Include/thread_nt.h in the Python source distribution for the > native Windows "Python lock" support. It uses the Win32 > InterlockedXXX APIs, not Mutex or even CriticalSection. It's very > efficient (but it's not trying to emulate pthreads, just Python > locks), has been used in high-stress contexts for years on all > flavors of Windows, and has no known (or even suspected) bugs. [Robert Collins] > Sounds to me like that is the appropriate mechanism to use under cygwin > as well. The caveats about not using win32 direct functions only apply > where other unix semantics and behaviour are still expected. The > Interlocked calls cannot block, and therefore will not interfere with > signals. They access process address space memory and will therefore > work with fork(). I expect you'd have to examine the source for compatibility with what you're doing to emulate signals and fork (which the native Win32 port ignores entirely, for the obvious reason). The InterlockedXXX stuff is a layer around Win32 CreateEvent + WaitForSingleObject + (auto-reset) SetEvent, avoiding calls to the latter two when there's no actual contention. InterlockedCompareExchange is simulated with a kind of spin loop on Win95, which lacks that function. That's about all there is to it. > You may well need to reset the value after fork() manually, as cygwin > cannot do that for native win32 calls. The Python C API defines a PyOS_AfterFork() function, which platforms can fill with whatever crud they need to do after a fork. On all platforms to date, it calls (in both parent and child) PyEval_ReInitThreads(), and resets the Python signal module's notion of what the current pid is. However, mixing threads with fork is a frigging mess on the best of platforms, and it generally takes a bona fide platform expert to guess what happens in the end. > This is taking your assertion as face value :}... InterlockedXXX are > faster still than Criticalsections+win32 events (which is how condition > variables are emulated). > > BTW: I am assuming that under linux condition variables are used - is > that correct? Yes, a Python lock under pthreads is implemented via a combination of a flag, a pthread_mutex_t and pthread_cond_t. From heikowu at ceosg.de Wed Sep 5 20:17:03 2001 From: heikowu at ceosg.de (Heiko Wundram) Date: Thu, 6 Sep 2001 02:17:03 +0200 Subject: ANN: CGIgen 0.1-alpha-1 Message-ID: <01090602170300.27146@phoenix> Hello fellow Pythoneers, I have just finished installing CGIgen on SourceForge, and have released an early alpha-version of the code. CGIgen is basically a library that aims at extending what Zope calls a namespace: Contrary to Zope it doesn't offer a "flat" namespace, but rather a namespace that can be arbitrarily deep, and at each level has a namespace in the Zope sense. Making the long statement short: it implements a tree-structure. Each item in the tree is accessed through a name, whereby names that are added later override names that were placed earlier, thus creating polymorphism. The basic classes that organize just this (Container, Data and Callback) are finished. Two demo-classes that use these classes as bases and implement real functionality are also included in the current version: SessionData implements a session data handler that integrates smoothly into the tree, and VariableData is a handler that integrates a text-file with a special formatting into the tree. What is also finished is an exception-handling scheme especially adapted to CGI-developers: Exceptions that are raised somewhere in the program can be logged to a file, and each exception has a certain severity which specifies when to log it (the lower the severity, the more severe the exception is, thus this is basically a log-level). CGIgen will be extended to cover much more tasks that are frequent in CGI-development (such as user-databases, document templating, etc.), but this should be enough announcement for tonight. The project is under the Python License (although the source doesn't state that... yet ;)). If anyone is interested in joining the effort, don't hesitate to mail me. :) Project URL: http://sourceforge.net/projects/cgigen/. Don't rely on the CVS, the data in there is older than the release; I still have some problems with getting the data from my local CVS into the sourceforge.net CVS (I don't have a permanent Internet connection, and thus can't use the sourceforge.net CVS for all checkin-operations). -- Yours sincerely, Heiko Wundram Head of the Celle Open Source Community (CEOSG - Celler Open Source Gemeinde) PS: The current release still contains .pyc files; I forgot to remove them before tarring the archive... Please forgive me! ;) From aleax at aleax.it Fri Sep 7 12:57:39 2001 From: aleax at aleax.it (Alex Martelli) Date: Fri, 7 Sep 2001 18:57:39 +0200 Subject: Nested scopes: why is it weird? References: <3B98F3B0.53AC2524@swiftview.com> Message-ID: <9nauag01nj2@enews2.newsguy.com> "Scott Long" wrote in message news:3B98F3B0.53AC2524 at swiftview.com... > Nested scopes seem like a nice addition (of course!) but there are some > weird things about it. Take a look: Not really, just a typical misunderstanding (which also existed wrt global variables before nested scopes). > Right, this is what you would expect. But how about this? > > >>> from __future__ import nested_scopes > >>> def a(): > ... def b(): > ... k = x > ... x = 0 The x name in procedure b is LOCAL -- the compiler knows it, because x is re-bound in b's scope. (Incidentally, you can never rebind a name from a lexically-nested local scope in your scope; you CAN rebind a global name, if you use the global statement at the start of a function). > My first beef here is, why is the exception called UnboundLocalError? Because x is a local name, and it is not yet bound when it is first used in b's first instruction. > The variable is certainly bound (into the local scope), it simply has Nope. x is a local name, but not bound to any value, as yet. Only the assignment statement (if it was executed) would bind name x (to the value 0). > not been assigned. Why not call it UninitializedLocalError? I know it > isn't going to change, I'm just asking. > > But my main concern is that this way of selecting a binding seems very > unintuitive. Shouldn't the first statement referencing x be the > statement that specifies the binding of x? In this case, shouldn't "k = *In general*, how could the compiler tell what the first statement IS, that _references_ name x within a given scope? Assuming you mean, "first to execute". The compiler _might_ assign some arbitrary ordering, of course. But having: if a>b: y=x else: x=y have *TOTALLY* different semantics from: if b>=a: x=y else: y=x when it SEEMS they're totally equivalent, would be truly weird, so I don't think you mean "first in some arbitrary order (such as, longest-first, or lower-line-number-first, or whatever)". > x" cause x to get bound as a free variable, not a local to b()? I'm not > claiming that this is a bug. I am curious as to why it was decided that > things are going to work this way. It makes assignment to a variable in > an enclosing scope impossible! Yes, the latter is exactly Guido's decision: he has always maintained that the right (aka obvious) way for something to keep and update state is to define a class, rather than stretch closures to let code in them re-bind things "partways up" -- or so I hear, and I sure see his point. But it's not any kind of necessary consequence of Python's long-standing rules that all variables re-bound in a scope are local to that scope unless explicitly mentioned in a global statement -- it would have been trivial to say, for example, that "global x in a" was THE way for b to inform the compiler that the x name b uses and re-binds is the one in a, not one local to b itself (somebody wanting to make closures really powerful/handy might have stretched that to "global x in a as z":-). Java just doesn't let a local variable 'shadow' one with the same name from a lexically-outer scope, and that might have been a nice choice too -- just forbid b to have a local variable named x if a lexically-outer scope of b had a similarly named local variable. Unfortunately, this restriction, which I have always liked, and proposed when nested scope were PEP'd, was not accepted (though it did get a mention in the PEP), so we'll live forevermore with misunderstandings on this point. Alex From nicolas at otelnet.com Wed Sep 19 17:13:15 2001 From: nicolas at otelnet.com (Nicolas Duchastel) Date: 19 Sep 2001 14:13:15 -0700 Subject: Embeded Multi-Threaded Python: PyEval_InitThread(), PyEval_SaveThread(),... References: Message-ID: <8e0ac4fb.0109191313.5fef1454@posting.google.com> Thanks for the quick response.... but..... I actually RTFM-ed it; that's why my question is so detailed. The doc seem to be conflicting in some areas and lacks some important information. For example, Chapter 8 states that Py_Initialized() can be called before or after PyEval_InitThreads(); so which is best ? what are the implications ? any nuance between these two ways ? any examples ? Also, chapter 8.1 does indicated 4 different ways to do locking: C_Function_ToCallPythonCode() { PyThreadState* save = PyEval_SaveThread(); // LOCK PyImport_ImportModule( ...); // load another module PyRun_SimpleString(...); // execute a 1 line of Python code PyPObject_CallMethod(....); // execute a full Python method PyEval_RestoreThread(save); // UNLOCK } OR C_Function_ToCallPythonCode() { PyEval_AcquireLock(); // LOCK PyImport_ImportModule( ...); // load another module PyRun_SimpleString(...); // execute a 1 line of Python code PyPObject_CallMethod(....); // execute a full Python method PyEval_ReleaseLock(); // UNLOCK } OR C_Function_ToCallPythonCode() { PyEval_AcquireThread(??); // LOCK PyImport_ImportModule( ...); // load another module PyRun_SimpleString(...); // execute a 1 line of Python code PyPObject_CallMethod(....); // execute a full Python method PyEval_ReleaseThread(??); // UNLOCK } OR C_Function_ToCallPythonCode() { Py_BEGIN_ALLOW_THREADS PyImport_ImportModule( ...); // load another module PyRun_SimpleString(...); // execute a 1 line of Python code PyPObject_CallMethod(....); // execute a full Python method Py_END_ALLOW_THREADS } So which one should I use ? Also, image my 2 distinct thread B and C executing the 1st snipplet of code above, if the call to PyObject_CallMethod() is VERY long and takes ages,... chapter 8 says "In order to support multi-threaded Python programs, the interpreter regularly releases and reacquires the lock -- by default, every ten bytecode instructions." Does that thus mean that a 2nd thread running this 1st snipplet above will be interupted in the middle of its work in PyObject_CallMethod() and another thread will have a go at it. If so, what happens to the ThreadState object when the 2nd thread calls PyEval_SaveThread() ? if it doesn't swap it, it will run with the 1st thread's ThreadState object. If it does swap it, when this 2nd thread will also get interupted, won't the 1st thread get back to run and thus it will run with the 2nd thread's object !? I mean, I must be missing someting !? Also, what about the things I was asking with regards to the actual OS thread's ID ? i.e. does it matter that my code starts in one thread and then works from another thread ? do I need to create ThreadState objects for each threads ? Thus,.. please RTFP (where P is for Posting rather than Manual) Thanks, Nicolas Ignacio Vazquez-Abrams wrote in message news:... > On 19 Sep 2001, Nicolas Duchastel wrote: > > > I am trying to use the Python/C API function to get an embeded Interpreter > > into a multi-threaded C++ application. We are using Pthreads on Solaris 7. > > My application works fine, but only with 1 thread; and then, when I stop it, > > it core dumps. > > I am using Python 2.1.1 built on Solaris 7 with the SUN's C++ 5.2 compiler. > > http://www.python.org/doc/current/api/initialization.html > http://www.python.org/doc/current/api/threads.html From wqh-2 at 263.net Tue Sep 4 04:50:52 2001 From: wqh-2 at 263.net (sdf) Date: Tue, 4 Sep 2001 16:50:52 +0800 (CST) Subject: =?gb2312?B?d2hhdCB0aGUgZGlmZmVyZW5jZSBiZXR3ZWVuIGFyYW5nZSgxMS4pIGFuZCBhcmFuZ2UoMTEp Message-ID: <3B9495EC.06400@smtp> An HTML attachment was scrubbed... URL: -------------- next part -------------- >>> x=arange(11) >>> x array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) >>> x=arange(11.) >>> x array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.]) >>> what is the function of dot follow the number. such as 0. 1. 2. ___________________________________________IP????????????????????????????????????? From fredrik at pythonware.com Tue Sep 4 03:29:46 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 04 Sep 2001 07:29:46 GMT Subject: 3-arg float pow() References: Message-ID: Tim Peters wrote: > I'm sure David knows all that. yeah, but what about everyone else on this list? am I the only one here that didn't know this (okay, okay, I could've looked it up somewhere if I really needed the info ;-) From amuys at shortech.com.au Sun Sep 9 21:03:37 2001 From: amuys at shortech.com.au (Andrae Muys) Date: 9 Sep 2001 18:03:37 -0700 Subject: large class hierarchies in python References: <9ner16$sbt$1@uni00nw.unity.ncsu.edu> Message-ID: <7934d084.0109091703.6414e22a@posting.google.com> "Justin Dubs" wrote in message news:<9ner16$sbt$1 at uni00nw.unity.ncsu.edu>... > Also, can you suggest some other good OO languages to learn? I know > Objective-C, C++, Java, some Smalltalk and now Python. What do you think of > Eiffel, if anything? I personally only ever have two reasons for learning another programming language. The first is naturally need, when my boss needed me to do some "web-programming", I spent two days and learnt Javascript. The second is for what I refer to as mental hysterisis. The #1 trait I look for, and recommend in a new language, is "Will this language permanantly change the way I think and program in the other languages I use?". So if you already know Obj-C, C++, Java, Smalltalk, and Python, I would suggest it's probably time to experiment with something that isn't imperitive-OO. Prolog, Haskell, Miranda, Forth, Postscript, APL, would all suggest themselves to me as possibles, but there are others in this group better qualified to make suggestions. Andrae Muys (and then one day you finish a small 15kloc C program, grep it and realise that you forgot to use any explicit loops, without trying. ;). From richard at bizarsoftware.com.au Tue Sep 18 03:01:53 2001 From: richard at bizarsoftware.com.au (Richard Jones) Date: Tue, 18 Sep 2001 17:01:53 +1000 Subject: python 3D? In-Reply-To: <3BA6EC29.43D2DDC7@club-internet.fr> References: <20010915135120.19016.00000755@mb-mo.aol.com> <3BA6EC29.43D2DDC7@club-internet.fr> Message-ID: <01091817015323.01597@ike> On Tuesday 18 September 2001 16:39, LAMY Bertrand wrote: > > Is it going to be based on the existing work of PyOpenGL, Numeric, pygame > > and PIL? They're the technologies I'm working with at the moment, and the > > only problem I'm having is to try an understand the sheer scale of the > > facilities at my disposal when they're combined :) > > Yes it will use PyOpenGL, PyGame and maybe the PIL. I don't think we > will use Numeric since I have written the math functions we need in a C > module. In fact actually I am working more on the C extensions to Python > I need for Py3D Excellent! Can't wait! (Numeric is a bit daunting... As I mentioned, I'm only just trying to come to terms with the sheer scale of the stuff available and how they can interact :) Richard From greg at cosc.canterbury.ac.nz Wed Sep 12 20:47:53 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 13 Sep 2001 12:47:53 +1200 Subject: Proposed PEP for a Conditional Expression References: <6qvgire4bk.fsf@abnoba.intevation.de> <9nk3jd$4lc$1@glue.ucr.edu> <9nnsa3$bjl$1@news.mathworks.com> Message-ID: <3BA00239.DECE6412@cosc.canterbury.ac.nz> Bernhard Herzog wrote: > if else I find myself liking this. To me, x = a if something else b reads much more smoothly than x = if something then a else b Rainer Deyke wrote: > > However, it would not fit well with list comprehensions that have a 'for': > > [ if for i in range(5)] # Syntax error > [ for i in range(5) if else ] # Syntax error > # and ambiguous intent This can be remedied: give the conditional expression a precedence lower than any existing operator (which I think is a good idea anyway), and exclude this level of precedence from the iterated-over expression of a for loop. "Terry Reedy" : > I agree that the above is backwards. > if else No! That sounds way too much like Forth! -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From peter at engcorp.com Thu Sep 6 12:32:12 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 06 Sep 2001 12:32:12 -0400 Subject: Simple Newbie Question - (slightly OT) References: Message-ID: <3B97A50C.7E20A2D9@engcorp.com> Scott Long wrote: > > Marcin 'Qrczak' Kowalczyk wrote: > > >> What is the proper pronunciation for "Tuple"? > > > This question has been asked here 6 weeks ago. It seems that there > > is no simple answer, various people pronounce "tuple" differently. > > > > Quite true. Consider quadruple (quad-roo-pul) and quintuple (quin-tuh-pul). > I say that as long as this difference exists, no one has any reason to > argue about "tuple". Heh heh! Considering that I've always pronounced both quadruple and quintuple with "oo" not "uh", I'd have to agree with the conclusion you reach, if not the reason for it. :-) (Note on dictionary.com the three ways of pronouncing quadruple and the four for quintuple. Hmmm... triple only has one pronunciation, so there goes my nascent theory about there being N-1 ways to pronounce these words. Dang. ;-) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From yelled at yahoo.com Sat Sep 29 20:13:14 2001 From: yelled at yahoo.com (Hoon) Date: 29 Sep 2001 17:13:14 -0700 Subject: COM Question: VB cDate equivalent i Pythonwin Message-ID: Hi, I am working with ActiveX control from Bloomberg. This control has cDate, which is an optional argument. I attempted to use both mxDateTime and pywintypes.Time(time.time()), the first give me back wrong type msg and later actually crashes pythonwin with usual memory+unintelligible win error msg. I included Gen_py output as well as VB code and my attempt with Pythonwin. Thanks for just reading it, X2 if anyone can really figure this out, Hoon, Gen_Py output:--------------------- def Subscribe(self, Security=defaultNamedNotOptArg, cookie=defaultNamedNotOptArg, Fields=defaultNamedNotOptArg, OverrideFields=defaultNamedOptArg, Overrides=defaultNamedOptArg, Results=defaultNamedOptArg, Monitor=defaultNamedOptArg): """method Subscribe""" return self._ApplyTypes_(0x1, 1, (24, 0), ((12, 1), (3, 1), (12, 1), (12, 17), (12, 17), (16396, 18), (12, 17)), 'Subscribe', None,Security, cookie, Fields, OverrideFields, Overrides, Results, Monitor) VB Prog:--------------------- dtStart = CDate((Year(Date) - 1) & "/" & Month(Date) & "," & Day(Date)) dtEnd = Date aryFields(0) = 1376 For i = 0 To UBound(vSyms) sym$ = vSyms(i) & " Index" 'sym$ = "IBM Equity" BlpData1.GetHistoricalData sym, _ i + 1, _ aryFields, _ dtStart, _ dtEnd Next i Python:--------------------- #BLP.Subscribe(vSyms[i], i, aryFields, ) #BLP.GetHistoricalData(vSyms[i], i, aryFields, D.DateTime(2000,12,12).COMDate(), D.DateTime(2000,12,22).COMDate()) #bt = pythoncom.MakeTime(time.time()-3000000) #et = pythoncom.MakeTime(time.time()) bt = pywintypes.Time(time.time()-3000000) et = pywintypes.Time(time.time()) print bt,et BLP.Subscribe(vSyms[i], i, aryFields, bt, et) BLP.Flush() From sholden at holdenweb.com Thu Sep 20 13:56:06 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 20 Sep 2001 13:56:06 -0400 Subject: .NET and Python References: <9nettc$ce1$1@slb7.atl.mindspring.net> <8nMm7.133116$n75.31959718@news4.rdc1.on.home.com> <9ni0fi0vq0@enews1.newsguy.com> <9nidl201j12@enews1.newsguy.com> Message-ID: "Alex Martelli" wrote in message news:9nidl201j12 at enews1.newsguy.com... > "Van Gale" wrote in message > news:l02n7.226503$%a.8841628 at news1.rdc1.sdca.home.com... > > > > "Alex Martelli" wrote in message > > news:9ni0fi0vq0 at enews1.newsguy.com... > > > "Van Gale" wrote in message > > > news:g7%m7.226487$%a.8840828 at news1.rdc1.sdca.home.com... > > > ... > > > > > I've looked into .NET and I hate to admit it, MS is > > > > > become more right lately. > > > > > > > > Microsoft marketing literature and hype has *always* been right. For > > the > > > > > > I disagree: I find Microsoft's marketing abysmal in its field. One > > > > Yeah, I didn't really express that well :) I was really trying to say > > something like with .NET, Microsoft is doing a good job of seeming right. > > That doesn't mean they actually are right (at this point). > > Oh, I see! Well, I was surprised by the quality of the betas of > the .NET Framework and Visual Studio .NET, considering they're > betas -- the *rest* of the .NET "vision" strikes me as _very_ > dubious (no matter how well Passport is implemented, for example, > the idea of a closed-source, single-point-of-failure service > becoming crucial to the functioning of most or all of eCommerce > strikes me as VERY bad from a technical viewpoint). > > Yes, but it concurs well with Microsoft's approach to other technologies where they missed the boat, the Internet being simply the largest and most visible of those. In the past Microsoft have used their size and wealth to buy technologies they can't compete with, sometimes to integrate it with their own products (e.g. FrontPage), sometimes to kill what would otherwise have been a competitor. Since they can't "buy" the Internet, they are proposing an entirely new net-centric architecture which will ostensibly play with other platforms. If the cross-platform support for .NET is as good as that for Internet Explorer then I'll believe .NET is cross-platform when I see it. Combine this with the usual smoke-and-mirrors injection from the marketing depertments and you get the classic Microsoft FUD campaign. Those who are heavily dependent on Microsoft architectures have to follow along as their backwards compatibility is cut out from under them (Visual Basic, for example, is being completely redefined as you know. This will make it a better language, but as far as existing code is concerned it's as difficult to port to some other language as it is from VB 6 to VB.NET). I somehow doubt that all this is going to change the minds of the many shops who *are* committed to Microsoft architectures. The fact that open source products are more stable and better supported simply doesn't give them the same warm fuzzy glow as being able to sign over huge chunks of their corporate revenue stream for the dubious privilege of being able to call Microsoft and have them say "fixed in next release". Which, in the case of ODBC for example, turned out to be blatantly not true: to miss some bugs in ODBC you have to migrate to OLEDB, which of course turns out to be far less well supported cross-platform. This in turn is because OLEDB was a set of marketing principles before it was ever a technology. So, having missed the emergence of the Internet as a crucial infrastructure change, they are now trying to use their marketing muscle to surround it with (in some cases) ill-thought-out proprietary technology. This will come as no surprise to anybody who seriously read the Halloween documents, where it was presaged as a strategy by suggestions that Microsoft make proprietary extensions to open protocols as a way of retaining market share in the face of the threat from Linux. Would-be flamers please note: I am NOT saying that Microsoft have done something they shouldn't from a business or a legal point of view: those are different arguments. I'm simply saying that they have beaten even IBM at the fear, uncertainty and doubt game. Were I a Microsoft stockholder I'd probably be pleased. In the long term, though, I think that Microsoft threaten their own survival by failing to embrace open systems rather than seeing them as a threat to their markets. I doubt the DoJ anti-trust action will be the last unless they change their ways, and nothing seems likey to make them. I sincerely doubt my, or anyone else's, ability to persuade Microsoft that this is wisdom, and that they should listen to it! regards Steve -- http://www.holdenweb.com/ From ignacio at openservices.net Mon Sep 10 17:44:36 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Mon, 10 Sep 2001 17:44:36 -0400 (EDT) Subject: timing?? In-Reply-To: Message-ID: On Mon, 10 Sep 2001, NJM wrote: > Would some one please give me an example of how to schedule an event for > given times of a day; any day. > > For instance; if I wanted to launch a wave file at 2:00 a.m. Use crond, atd, or the Scheduler service, depending on what operating system you're using. -- Ignacio Vazquez-Abrams From doy20 at telcel.net.ve Fri Sep 28 15:40:24 2001 From: doy20 at telcel.net.ve (Doy) Date: Fri, 28 Sep 2001 15:40:24 -0400 Subject: Subscribe Message-ID: <001301c14855$6c5340e0$0100a8c0@uhuihh> ------------------------------------ Make Unlimited phone calls from your PC to ANY phone in the World! http://www.eboom.com/free/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From aleax at aleax.it Tue Sep 4 04:13:47 2001 From: aleax at aleax.it (Alex Martelli) Date: Tue, 4 Sep 2001 10:13:47 +0200 Subject: 3-arg float pow() References: Message-ID: <9n22fs01dt3@enews3.newsguy.com> "Tim Peters" wrote in message news:mailman.999576723.20844.python-list at python.org... > [Paul Rubi] > > That doesn't seem so bad. 2**-5 is already not allowed. > > [Greg Ewing] > > When new division comes into force, shouldn't this be allowed too? > > It's already allowed in current CVS Python. > > C:\Code\python\PCbuild>python > Python 2.2a2+ (#22, Sep 3 2001, 14:31:58) [MSC 32 bit (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> 2**-5 > 0.03125 > >>> AND in plain 2.2alpha2, for those of us not quite adventurous enough to track cvs: C:\Python22>python Python 2.2a2 (#22, Aug 22 2001, 01:24:03) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> 2**-5 0.03125 >>> Alex From fredrik at pythonware.com Tue Sep 18 17:09:07 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 18 Sep 2001 21:09:07 GMT Subject: PIL 1.1.2 for Python 2.1.1 References: Message-ID: Anders Eriksson wrote: > Why doesn't import Image work anymore? what did you change? what does "doesn't work" mean? if you get an ImportError, check that you have the PIL directory in your path. if it's not there, make sure you have a PIL.pth file in your python main directory (windows) or under site-packages (unix). > Why do I have to use import PIL.Image? you don't, if you install it the right way. From polopunk209 at hotmail.com Mon Sep 3 23:13:29 2001 From: polopunk209 at hotmail.com (Josh) Date: 3 Sep 2001 20:13:29 -0700 Subject: pygame rpg Message-ID: i'm working on a top down rpg using pygame. does anyone have any ideas on making graphics for games like this? it will not scroll in real time. there will be a "level" on the screen, and when you walk off the screen, a new "level" is blitted. also, do you have any ideas on where i could look for some source code on a project similar to this? any suggestions are appreciated, and thanks in advance. josh From qrczak at knm.org.pl Mon Sep 17 13:35:53 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 17 Sep 2001 17:35:53 GMT Subject: newbie - Scoping question References: <3281a460.0109170759.63ede66@posting.google.com> Message-ID: 17 Sep 2001 08:59:13 -0700, P Adhia pisze: > I am confused as to why "x", when not qualified with module name, does > not refer to "x" in "test", even though I did "from test import *". "from test import *" imports a module and injects a snapshot of the module's namespace into the current namespace. Names in the current namespace are then ordinary variables, bound to the same objects to which the module has bound its variables at the time of the import, but independent from the module. Further changes to the module's namespace don't affect the current namespace, nor vice versa. It's the same as if you did import test x = test.x get_x = test.x set_x = test.x del test Now x and test.x are different variables referring to the same object. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From zptang at hotmail.com Fri Sep 21 21:55:24 2001 From: zptang at hotmail.com (Janet) Date: 21 Sep 2001 18:55:24 -0700 Subject: Problem using new Python type: "cannot add type to string" Message-ID: Hi, I created a new Python type (extension in C), and tried to call a function with an object of the new type as the argument: PyObject *arglist = PyTuple_New(1); PyTuple_SetItem(arglist, 0, myObj); /* myObj is an object of the new type */ PyObject_CallObject(funcObj, arglist);... However, the PyObject_CallObject() failed with the error message saying that: "cannot add type to string". It seems that the error was generated when string_concat() in Objects/stringobject.c is invoked. The function tested on the type of the second argument and outputted error whenever the argument is not a PyStringObject. I would like to know why does this problem appear. Is there any methods in the new type that I forgot to implement? (BTW, I did implemented the tp_str, tp_repr, and tp_print in my new type). Thanks From donn at u.washington.edu Tue Sep 4 12:47:52 2001 From: donn at u.washington.edu (Donn Cave) Date: 4 Sep 2001 16:47:52 GMT Subject: Conditional operator in Python? References: <3AC68CB8.22AAF7B8@alcyone.com> <9a631k$3s8qb$1@ID-11957.news.dfncis.de> <3AC6BB2E.1E09B5AA@alcyone.com> <9n1hr7$7op$1@glue.ucr.edu> <3B947E32.C5604328@el_simpatico.be> <3B94B3B3.6775EE3C@el_simpatico.be> Message-ID: <9n30jo$18ls$1@nntp6.u.washington.edu> Quoth Weet Vanniks : | Your counter-example seems contorted to me. | I would never use: | whatever = cond_choose(cond, format_disk(), leave_it_as_is()) | for the mere reason that I have been taught that: | 1. when there is room for confusion, people get confused | 2. arguments in a function call should NEVER have side-effects. | 3. obfuscated one-liners with lambda functions bring more confusion | than anything else | (the alledged efficiency is still to be demonstrated as you | correctly state) | 4. The spirit of Python is : "If it ain't obvious, it ain't Python" | and contorted syntax does not help support that spirit /F is notorious for his elliptical replies, but not for contorted syntax, and I think the former is the problem here. The way I read it, the usage he was promoting was the most obvious possible, "if cond ..." I might add, one of the reasons it's so much more obvious than the pseudolisp alternatives is that the "if" is clearly directed at the "cond" variable, whereas in the post that someone forged your name to that suggested "whatever= cond_choose(x,a,b)", it's not so clear where the condition is. Donn Cave, donn at u.washington.edu ---------------------------------------- | Fredrik Lundh wrote: | |> Weet Vanniks wrote: |> > What about : |> > |> > def cond_choose(cond,first_choice,second_choice): |> > if cond: |> > return first_choice |> > return second_choice |> > |> > whatever= cond_choose(x,a,b) |> |> well, compare |> |> whatever = cond_choose(cond, format_disk(), leave_it_as_is()) |> |> with |> |> if cond: |> whatever = format_disk() |> else: |> whatever = leave_it_as_is() |> |> > This seems much cleaner to me than all those contorsions with |> > the syntax. |> |> of course, the best way to avoid those contorsions is to fix the |> Return and Tab keys on your keyboard, and learn how and when |> to use them... |> |> (it also helps to know that lambdas and list constructors are |> expensive, and assignments to temporary locals are cheap. |> And contrary to common belief, the Python interpreter can |> skip over linefeeds in almost no time at all...) |> |> From wolfgang.grafen at marconi.com Wed Sep 26 14:32:16 2001 From: wolfgang.grafen at marconi.com (Wolfgang Grafen) Date: Wed, 26 Sep 2001 20:32:16 +0200 Subject: Idea about method parameters References: <2728946.ogB4TqSGss@lunix.schabi.de> <3BAF6D67.ADA04E71@marconi.com> <5594719.3gRfpFWEtP@lunix.schabi.de> Message-ID: <3BB21F30.4FE0F893@marconi.com> Well, Python is flexible to do it anyway and although I missed to give an example for that I hoped you could develop by yourself: >>> class A: ... def __init__(self,a,b,c=333,d=444): ... self.__dict__.update(vars()) ... del self.__dict__['self'] # remove cyclic self reference ... def __call__(self): ... print self.a, self.b, self.c, self.d >>> a=A(a=1,b=2,c=3) # qualified and default parameters >>> a() 1 2 3 444 >>> >>> a=A(1,2,3,4) # positional parameters >>> a() 1 2 3 4 >>> a=A(1,2) #positional and default parameters >>> a >>> a() 1 2 333 444 >>> a=A(1,c=3,b=22) # positional, qualified and default parameters >>> a() 1 22 3 444 Answers to your objections (below): 1. Now the parameter list is under the programmer's control 2. Using self.__dict__ is *not* a dirty hack as already many code does use self.__dict__ 3. Positional parameters are possible as well 4. There are default values 5. No need for an extra documentation of valid parameters For me this is good enough and there is no need for a new syntax. Wolfgang Markus Schaber wrote: > > Wolfgang Grafen schrub: > > > Don't think you cannot do it already! > > > >>>> class Autoinit: > > ... def __init__(self,**a): > > ... self.__dict__.update(a) > > ... > >>>> a=Autoinit(a=1,b=2,c=3) > >>>> a.a > > 1 > >>>> a.b > > 2 > >>>> a.c > > 3 > > > >>>> class A(Autoinit): > > ... def __call__(self): > > ... print self.a,self.b,self.c > > ... > >>>> a=A(a=1,b=2,c=3) > >>>> a() > > 1 2 3 > > Nice idea, especially when your classes mainly work as Attribute > Containers, but I have some objections: > > 1. This way you don't have any control what the caller sets - he just > might set anything. Okay, in Python, he really can do anything he wants > with your object, but sometimes it is helpful to have some hints by the > compiler or interpreter, especially to find typos (useful when you have > lots of long-named parameters). And if you have to test the contents of > **a "by hand", you don't save any work, and it gets less readable. > > Assume you have more than one place in your program where that > constructor/method gets called, one of them has a typo in one parameter > name, and so you occasionally corrupt parts of your database. Or the > misspelled parameter sets an attribute that is never looked at again, > and all the following code uses the old value from the correctly > spelled attribute that was created before (only applies to > non-constructor methods) > > 2. Messing with __dict__ seems to be a "dirty hack" in my eyes, and > doesn't produce readable code (you cannot exactly guess what gets > changed in the object, especially when it isn't the constructor, but > another method.) > > 3. You kick the possibility to give positional parameters > > 4. You kick the possibility to give default value > > 5. You have to explicitly document what your caller can give you - a > "normal" parameter list in a def: with sensible parameter names (and > maybe useful default values) usually is a very useful bit of > documentation, especially when you know the main idea and just forgot > some specific spelling detail or so. > > markus > -- > "The strength of the Constitution lies entirely in the determination of > each citizen to defend it. Only if every single citizen feels duty > bound to do his share in this defense are the constitutional rights > secure." -- Albert Einstein From tim.one at home.com Thu Sep 6 01:42:27 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 6 Sep 2001 01:42:27 -0400 Subject: 3-arg float pow() In-Reply-To: Message-ID: [Tim] > I'm sure David knows all that. [Fredrik Lundh] > yeah, but what about everyone else on this list? am I the > only one here that didn't know this (okay, okay, I could've > looked it up somewhere if I really needed the info ;-) Far be it from me to complain about off-topic posts -- and the writeup was a good one. My purpose was to spare David the need to explain himself, and especially to spare "everyone else on this list" the explanation . six-words-were-really-all-that-needed-ly y'rs - tim From jknapka at earthlink.net Sun Sep 2 20:46:44 2001 From: jknapka at earthlink.net (Joseph Andrew Knapka) Date: Mon, 03 Sep 2001 00:46:44 GMT Subject: Tkinter design problem References: <3b92af17_8@news.newsgroups.com> <3b92c2cf$0$326$6e49188b@news.goldengate.net> Message-ID: <3B927DEE.2347A972@earthlink.net> Greg Krohn wrote: > > If you bind your callback it sends back an event argument that has > the 'widget' attribute. That is the widget that called it. And if you want to just use the "command" option, pass it a curried function. There have been several recent threads on this matter; see for example Oh well, that URL got chopped to bits, but googlegrouping for "curry Tkinter" will get you there. Cheers, -- # Joe Knapka # "You know how many remote castles there are along the # gorges? You can't MOVE for remote castles!" - Lu Tze re. Uberwald # Linux MM docs: http://home.earthlink.net/~jknapka/linux-mm/vmoutline.html From mmhamze at pleiades.net Tue Sep 4 09:46:53 2001 From: mmhamze at pleiades.net (Maan M. Hamze) Date: Tue, 4 Sep 2001 08:46:53 -0500 Subject: how do i make a grapical thingie? References: Message-ID: Hi Jeroen Ok! 1. Do you have the directory: c:\python22\Lib\lib-tk? 2. type the following in Python: >>> import sys >>> sys.path You'll get a string. What string are you getting? Maan "jeroen paul goudsmit" wrote in message news:LV1l7.24$3M6.646 at castor.casema.net... > Ok. Python is instal;led in : C:\Python22. The name of the executable is = > C:\Python22\python.exe. The dll files are in the map C:\Python22\DLLs. The > tkinter file is C:\Python22\DLLs\_tkinter.pyd. > "Maan Hamze" schreef in bericht > news:HQOk7.217122$g_3.41849242 at typhoon.austin.rr.com... > > Tim > > The guy had not even answered on how he has Python installed to start > with. > > To recommend Jython for him at this stage along with the use of AWT or > swing > > is an overkill :) > > Maan > > > > "Delaney, Timothy" wrote in message > > news:mailman.999478982.9172.python-list at python.org... > > > I suspect the simplest thing here would be to use Jython and AWT or > Swing. > > > > > > http://www.jython.org > > > > > > Probably the easiest way for a beginner to get a GUI up and running in > > > Python. Once they have a bit more experience they can move onto other > > > things. > > > > > > Tim Delaney > > > > > > > > > > > From BrianQ at ActiveState.com Thu Sep 13 20:56:43 2001 From: BrianQ at ActiveState.com (Brian Quinlan) Date: Thu, 13 Sep 2001 17:56:43 -0700 Subject: Python on OSX In-Reply-To: <4a249347.0109131633.5eb04510@posting.google.com> Message-ID: <002101c13cb8$1f6e83f0$b503a8c0@activestate.ca> > Are there any "gotchas" when compiling Python on OSX? Is > there a how-to someplace? Read the README file that comes with the Python source/cvs. There are a few switches that you have to pass explicitly to autoconf but other than that everything works fine. From BPettersen at NAREX.com Wed Sep 12 19:32:13 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Wed, 12 Sep 2001 17:32:13 -0600 Subject: Reading variable length records... Message-ID: <6957F6A694B49A4096F7CFD0D900042F6C9E32@admin56.narex.com> > From: Brian Quinlan [mailto:BrianQ at ActiveState.com] > > > I'm trying to read records from a 2 GB datafile, but my brain has > > stopped working, so I was wondering if someone has allready > > solved this problem. The records are variable length and are > > separated by a five character delimiter. I was trying to use > > file.read(n) with a blocksize of ~1Mb, but got a serious > > brainfart when trying to think of how to handle the case where > > only part of the delimiter was read in the current block. > > Here is some pseudo-code to get you started: > Thanks, that helps alot :-) -- bjorn From James_Althoff at i2.com Tue Sep 4 13:13:03 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Tue, 4 Sep 2001 10:13:03 -0700 Subject: how to distinguish a python expression from a statement? Message-ID: Thanks for your suggestion, Fredrik. I must be doing something wrong, though, because I don't seem to be getting the expected behaviour. The magic "_" variable works when I type directly into the Python interpreter (interactive mode). But when I run your example code using either Python or Jython, "_" is not defined (as part of the exec statement). Python 2.2a1 (#21, Jul 18 2001, 04:25:46) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> mysource = '3+4' >>> dict = {} >>> code = compile(mysource,"","single") >>> exec code in dict 7 >>> result = dict.get("_") >>> if result is not None: ... print result ... >>> print result None >>> >>> >>> 3+5 8 >>> _ 8 >>> Do I need to do something special to enable the magic "_" to be included in an exec statement? Thanks, Jim Fredrik Lundh wrote: >sure: >James_Althoff at i2.com wrote: >> I have all of this working except that I don't know how to distinguish >> between expressions and statements (without making the end user push one of >> two different buttons in order to tell me -- yuk). I am using Jython and >> so the parser module is not available (so I can't use parser.isexpr). >> >> Is there any means to accomplish this what-I-had-thought-would-be-routine >> task short of writing a Python parser? > > > dict = {} > code = compile(mysource, "", "single") > exec code in dict > result = dict.get("_") > if result is not None: > print result > >(use dict.has_key("_") to check if it really was an expression) > >> I am trying to mimick the Python interpreter in a GUI. > >the "code" module contains a framework for this; just instantiate >an InteractiveConsole, and use the "push" method to add lines as >they arrive from the GUI. > > -- http://mail.python.org/mailman/listinfo/python-list From aleax at aleax.it Tue Sep 4 11:00:09 2001 From: aleax at aleax.it (Alex Martelli) Date: Tue, 4 Sep 2001 17:00:09 +0200 Subject: Use of GMPY References: <9n03in$c6o$1@pegasus.tiscalinet.it> Message-ID: <9n2qa00dj3@enews3.newsguy.com> "Maan Hamze" wrote in message news:ilPk7.217241$g_3.41893539 at typhoon.austin.rr.com... > I have never used GMPY, but it is not always the case that *.pyd files > should go into the DLL subdirectory. It may be the way that GMPY is being > imported where the problem lies. > Does GMPY have a setup script? Maybe you are copying the PYD's into places > where GMPY can not find them. A setup.py is part of the *source* distribution of GMPY. The windows-binaries package, provided as a convenience to Windows users, is made up of just two .PYD's which, if one wishes, may well be "installed" by copying them anywhere Python will find them. HOWEVER, the 0.9 version is built for Python 2.0; in response to the original post, I've released a 0.9a21 that is basically identical BUT built for Python 2.1. Note that one needs the source distribution anyway, because that's where the docs are (just a large textfile, at present), as well as the unit-tests &c. Yep, I _do_ need to come up with slicker packaging at some point (presumably when I redo the docs in a slicker format than plain text:-). Alex From wayne at tbnets.com Sun Sep 9 19:58:19 2001 From: wayne at tbnets.com (Wayne Ringling) Date: Sun, 9 Sep 2001 19:58:19 -0400 Subject: Interesting problem with running a python script in a c wrapper. Message-ID: I have been progressing on my project and ran into this little problem. I have a script that is wrapped with the c wrapper from the python /Misc dir and when I run it from my web server I get the error below: I show my script first and then the error. login.py-------------------------------------------------------------- #!/usr/bin/python import config, keys, misc, shelve, anydbm config = config.Confload() encrypt_key = keys.generate_shortkey() remote_ip = misc.grab_remoteip() session_key_dbm = shelve.open(config.files.session_key_dbm, 'c') session_key_dbm.close() session_key_dbm = shelve.open(config.files.session_key_dbm) session_key_dbm[encrypt_key] = remote_ip print "Content-type: html/text\n\n" print "Test Page" print "" for key in session_key_dbm.keys(): print key, " -> ", session_key_dbm[key],"\n
    " print "" session_key_dbm.close() login.py-------------------------------------------------------------------- /var/log/httpd/error_log---------------------------------------------------- Traceback (most recent call last): File "/freesite-cgi/login.py", line 13, in ? session_key_dbm = shelve.open(config.files.session_key_dbm) File "/usr/lib/python2.0/shelve.py", line 157, in open return DbfilenameShelf(filename, flag) File "/usr/lib/python2.0/shelve.py", line 147, in __init__ Shelf.__init__(self, anydbm.open(filename, flag)) File "/usr/lib/python2.0/anydbm.py", line 86, in open return mod.open(file, flag, mode) File "/usr/lib/python2.0/dbhash.py", line 8, in open return bsddb.hashopen(file, flag, mode) bsddb.error: (21, 'Is a directory') [Sun Sep 9 21:42:35 2001] [error] [client 216.181.182.140] Premature end of script headers: /usr/local/httpd/cgi-bin/login /var/log/httpd/error_log---------------------------------------------------- Now I know that "config.files.session_key_dbm" does = "/usr/local/freesite/sessionkey_dbm" It creates the dbm in the correct dir and then when it goes to read it. I get the above error in my http server log. And the server sends a 500 error to the web browser. My server is a Suse 7.2 running Apache and mod_python. Not sure if this info helps but you never know. Btw the script works fine from the command line. Any Ideas? Wayne From rdsteph at earthlink.net Mon Sep 10 21:12:30 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Tue, 11 Sep 2001 01:12:30 GMT Subject: Pythonwin and .NET References: <3B997A5E.6010801@bigpond.net.au> Message-ID: <3B9D6654.FA287BA5@earthlink.net> I have a question that I hope someone can partially answer. ActiveState has a beta of Visual Python for .Net on their web site. I can not use it because I do not have access to a beta of Microsoft's Visual Studio. However, the ActiveState beta of Visual Python must have at least basic functionality. How basic is that functionality? How much is left out? Are there big differences between the language supported as Visual Python and c-Python as we know it? Mr. Mark Hammond said """And on the more pragmatic side, there is still *significant* work remaining to be done before Python on .NET is really viable, and I know of no commercial effort underway to implement this. From memory, JPython took a number of years to be considered viable and to transform into Jython.""" Mr. Hammond, why is Python on .NET not currently viable? Also, do you think ActiveState will stick with it until it is viable? Look, I like many on this list would love to see you, Mr. Hammond, champion Python on .NET to the n'th degree. I would say just about anything to try to persuade you to do so ;-)) But, I know you are a very busy person and will certainly make up your own mind on important matters. And I think it must be discouraging sometimes to work so hard for so long and not see all the progress you would like to see. This is a burden you must bear alone and most of us can't participate with you at all nor understand it at all. But we can continue to say thank you, regardless of any and all decisions and outcomes. Now, I hope Alex Martelli decides to volunteer to help Mark Hammond do a PythoNet. I hope Alex volunteers to lead an open source effort himself, should Mr. Hammond decide to not do so. I am sure it would help the Python community immensely of they did so. But even if they don't, Python has a great future. Why? 1. Microsoft rules. VB and C# will therefore rule. Most of all, Visual Studio .NET will truly rule. Java will not go away and will be very important. Perl and even JavaScript and other scripting and glue languages have roles for quite a while. Other great but boutique languages will make some very happy, like Oberon, Haskell, Eiffel, etc. etc. etc. Lisp will have its own very efficient and productive advocates until they all die. ;-))) But other than the greater C family of C, C++, C#, and Java, only Python exists today as a claimant to more than a token stance as an important general purpose language that is still growing, at least significantly. Perl could be considered, but is it really a general purpose language? Ruby has aspirations, and is probably a fine language, and could be as general purpose as Python, maybe, in time, but it doesn't have the time, nor does it have enough critical mass. The window is closing. Only a language that has at least as much presence, tool availability and maturity as Python has time, to my way of thinking , to survive the onslaught of .NET and Java both and have the opportunity to evolve and grow into a *major* general purpose language. So, on one side you have Visual Studio, C# and VB (and also managed code C++), pushed by the most powerful corporation the earth has ever seen; and on the other side you have Java, with at least a five year head start and supported by IBM, Sun and other major corporations. In the middle, you have one open source language named after a troupe of comedians, saddled with a snake's name that has sensitive and negative connotations to some ;-)), and a BDFL who believes in it and in its community. 2. Python occupies a middle ground. Neither fish nor foul, neither Sun nor Microsoft, but friendly to both companies and to open source advocates, used by Windows developers (thanks to Mark Hammond!!!) and by Linux developers and by Mac and BSD and other UNIX developers, Python is no one's enemy and everyone's friend. To both the Microsoft camp and to the Java camp, one who is not my enemy is maybe my friend, and at least can be tolerated and allowed to live. 3. Python is as widely usable as any language, if not wider. If successfully integrated into .NET in the early days, even if not with 100% perfection, Python will be *the* most widely cross platform, cross development environment, programming language on earth. Java will not be so early and well integrated into .NET, and even if it is, the Java community will not support Java.NET enthusiastically, for obvious reasons. Python will move ahead of even Java in open, cross platform support. And when will VB and C# be running on JVM's? 4. The Python community nurtures what is arguably one of the five most important concentrations of software development going on today: A. Microsoft .NET B. Java C. Linux D. Mono (and what about PythoNet for Mono?) E. Python i. The core Python language led by Guido ii. Jython iii. Python.Net iiii. Web App Servers like Zope, Webware, Skunkworks etc. etc. etc. iiii. Commercial IDE's PythonWare, Black Adder, and Komodo iiii. Open source Python GUI RAD tools and application frameworks like: a. wxPython and similar for GTK, QT, Tkinter, etc. b. Boa Constructor c. anygui d. PythonCard 5. By continuing to grow as a friendly flower in the midst of the two giants (Java and Microsoft), Python garners good will; and offers a neutral alternative for the future. But most of all, there is another reason, more important than any of the above and all of the above reasons combined. When we ask ourselves, honestly, what will still be around in the year 2010, or even in 2020, what comes to mind, and how do we predict such things? Well, Microsoft and its preferred offerings, whatever they are, will certainly not only be around but will be hugely important, for the foreseeable future, due to their corporate might and will. Java will still be around, because it has so much momentum. The C family in general will be around; C is too important to ever be completely replaced in the foreseeable future. But surely there is a place for a more productive, higher level language? OS/2 was loved by many and will not be around in 2020 or even in 2010 to any appreciable degree. So love of a technology alone is not enough to ensure survival. But I am quite sure that Python will be around, and important, in 2010; and I believe it will also be so in 2020. Why? Because so many people truly love it, in a meaningful way (they love to use it, they use it deeply, it is a tool that helps them be significantly more productive and yes, fulfilled in their careers and in their passions); and because so many people will continue to love it and use it in 2010, and enough people to make a difference; and because Python is an open source community that can not be killed in the way IBM and Microsoft killed OS/2. Python will survive because it is open source and loved. Python will matter because loved tools that are free, if they are loved and used by enough people, grow and thrive. Think about it; do you believe that Python is loved enough, by enough people, in a useful and not just sentimental way, so that it will be used by a significant enough number of people in 2010 to be meaningful? And if still sufficiently used and meaningful in 2010, would not Python be situated to possibly become important, in the middle ground of computer languages? I actually believe this; I hope you do too. I humbly salute and honor Guido and Mark and Alex and all of the other heroes of the Python community. I hope some of these heroes propel Python .Net forward. But under any circumstances, I have a sober faith that Python will do well, and I will continue to use Python and cherish its community lovingly.. Ron Stephens From Tobias_Unruh at FRM2.TU-Muenchen.DE Wed Sep 5 08:00:18 2001 From: Tobias_Unruh at FRM2.TU-Muenchen.DE (Tobias Unruh) Date: Wed, 5 Sep 2001 14:00:18 +0200 (CEST) Subject: (no subject) Message-ID: Hi, I am looking for something like a trap/resume functionallity for python. Does anyone know if there exists a solution? Or is it possible to install a timer, which interrupts the current program and calls a subroutine, say 5 times per second. Tobias -- Tobias Unruh TU Muenchen, FRM-II 85747 Garching, Germany From jan_mothers at hotmail.com Sun Sep 16 18:30:15 2001 From: jan_mothers at hotmail.com (jan_mothers at hotmail.com) Date: 16 Sep 2001 22:30:15 GMT Subject: A PERFECT TAN WITHOUT THE SUN Or Your Money Back Message-ID: <9o395n$6c6$1223@plutonium.btinternet.com> Hi, I think you will be extremely interested in DEEPTAN tanning pills. I have been using them for just under a year to provide me with a suntan without the sun. They work perfectly. Infact because I was so satisfied with the product I recently decided to join the companies affiliate program. The following is some brief information on the product for detailed information please click the link at the bottom. I am certain you will be as satisfied with the product as I have been. Jan Mothers ======================================================= Do You Want A Perfect Tan Safely And Easily? THE SECRET OF TANNING SAFELY AND EASILY WITHOUT THE SUN As Seen On TV And The National Media ======================================================= DEEPTAN enables you to obtain a beautiful dark golden tan, without exposing yourself to damaging UV rays. No more burning, premature aging and even skin cancer. Not a dyed, fake orange tan usually associated with other tanning tablets and messy creams, but a natural golden tan. Find out how DEEPTAN will give you the perfect summer tan within the comfort of your own home today, visit: http://home-shop.net/cgi-bin/cart/redeem.pl?aff=memb852 From loewis at informatik.hu-berlin.de Fri Sep 28 03:50:29 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 28 Sep 2001 09:50:29 +0200 Subject: Secure embedding of Python References: <605d9ec1.0109270117.4bb31eb4@posting.google.com> Message-ID: tordj at scalado.com (Tord Jansson) writes: > 2. Lock out the use of any other modules. If not possible in any other > way I can always scan through the script before execution for any > inclusion of other modules. It is easily possible. The only danger comes from C modules; Python modules cause no security risk, since they eventually have to perform all their actions through C modules. By restricting the list of C modules (and builtins), you effectively and reliably limit what Python code can do. If you look for several levels of access, you need the rexec module, which allows to further limit the set of available functions. To limit the list of available C modules, you best link every module that you want to offer into your application, and remove the possibility for dynamically loading extension modules. To do that, make sure that HAVE_DYNAMIC_LOADING is not defined. > 1. Will this approach effectively lock out access to file-functions > etc or are some dangerous functionality built into the interpreter > itself? Yes, you need to disable the open function. That may require changes to builtinsmodule. > 2. Is some necessary functionality (memory allocation for > example)placed in modules which I therefore will have to include? Yes. You cannot disable the sysmodule and the builtins module. If you need gc, you must include the gcmodule, and if you need threads, you must include the threadmodule. It is also advisable to include the strings module and the _sre module. > 3. Is there any way to access (read and/or write) raw memory in > Python which might be hard to lock out? Something similar to just > giving a pointer a value and reading from there in C/C++? Writing > outside its own array structures? That is not possible. With the mmap module, you can write to raw memory, but not with random access to the address space. Regards, Martin From jtdubs at eos.ncsu.edu Tue Sep 11 19:07:13 2001 From: jtdubs at eos.ncsu.edu (Justin Dubs) Date: Tue, 11 Sep 2001 19:07:13 -0400 Subject: multi-dispatch (was Re: large class hierarchies in python) References: <9ner16$sbt$1@uni00nw.unity.ncsu.edu> <7934d084.0109091703.6414e22a@posting.google.com> <9nhhn5$g1o$1@uni00nw.unity.ncsu.edu> <9nhugd0s4f@enews1.newsguy.com> <9ni3p0$rkn$1@uni00nw.unity.ncsu.edu> <9nieii01k24@enews1.newsguy.com> <9nismr$fve$1@uni00nw.unity.ncsu.edu> <9nksof021p1@enews3.newsguy.com> Message-ID: <9nm5ev$pfr$1@uni00nw.unity.ncsu.edu> "Alex Martelli" wrote in message news:9nksof021p1 at enews3.newsguy.com... > "Justin Dubs" wrote in message > news:9nismr$fve$1 at uni00nw.unity.ncsu.edu... ... > A brief tirade in favour of multi-dispatching...: > > It's runtime-polymorphism over an unlimited number of objects, rather > than over one object at a time. In any language that doesn't offer ... > And the Dylan implementation looks fine to me in as far > as I've dug into it. What do you find wrong with it...? Ahhhhhh..... Thank you. I didn't spend enough time letting the concepts sink in. Thanks for the great explanation. It makes sense now. That is very useful. I still hate the dylan syntax, but the multi-dispatching makes sense now. Thank you for the help. Justin Dubs From skip at pobox.com Fri Sep 21 09:37:36 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 21 Sep 2001 08:37:36 -0500 Subject: How to derive import dependency structure In-Reply-To: References: Message-ID: <15275.17056.897781.994423@beluga.mojam.com> Harald> Let B.py be imported by A.py which generates --- in a very time Harald> consuming process --- some data structure A.dat. Harald> import generate Harald> B.py --------> A.py ----------> A.data Harald> Currently A.dat is only generated if A.py is newer, but this is Harald> not enough since A.dat must also be generated, if B.py is Harald> changed. Sounds like make dependencies to me: A.data : B.py A.py python B.py # writes A.data by side effect If make isn't an option, perhaps distutils will do the trick. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From weeks at vitus.scs.agilent.com Sun Sep 9 21:23:35 2001 From: weeks at vitus.scs.agilent.com (Greg Weeks) Date: Mon, 10 Sep 2001 01:23:35 +0000 (UTC) Subject: language growth Message-ID: <1000085015.952637@cswreg.cos.agilent.com> I just happened to notice a PEP stating that a certain additional construct would be "a good idea". I imagine that there are lots of good ideas out there, genuine and perhaps even significant language improvements. But I'm move convinced of this: If every significant language improvement were added to the language, it wouldn't be an improvement at all. All those good things would add up to a bad thing. The optimal size for a language is not enormous. So, it seems to me that at some point it is desirable to reject good ideas. The bar needs to be raised to allow only great ideas, and then at some later point to allow only insanely great ideas. At that point the language will change glacially, if at all. If that is correct, how do you raise the bar? How do you decide that an idea that would have been desirable five years ago is no longer good enough for inclusion? How do you decide how big/complex a language should be? I don't know, but this seems relevant to Python. (And I need to get a small number of potentially puerile and undergraduate postings out of my system.) Regards, Greg From max at alcyone.com Thu Sep 13 01:53:54 2001 From: max at alcyone.com (Erik Max Francis) Date: Wed, 12 Sep 2001 22:53:54 -0700 Subject: Proposed PEP for a Conditional Expression References: <6qvgire4bk.fsf@abnoba.intevation.de> <9nk3jd$4lc$1@glue.ucr.edu> <9nnsa3$bjl$1@news.mathworks.com> <3BA00239.DECE6412@cosc.canterbury.ac.nz> <5xXn7.2447$w62.1612177@news1.denver1.co.home.com> <9nphfq$ph3$2@glue.ucr.edu> Message-ID: <3BA049F2.B3895DDE@alcyone.com> thp at cs.ucr.edu wrote: > C syntax does overload the already heavily used colon. The colon isn't used all that much in C. It's used in labels and switch...case statements, the conditional operator, and bitfields. > Perhaps it > would be better to use semicolon instead of colon. The colon is too overloaded in C, but the semicolon isn't? At least one semicolon appears in every C statement. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ There are countless planets, like many island Earths ... \__/ Konstantin Tsiolkovsky REALpolitik / http://www.realpolitik.com/ Get your own customized newsfeed online in realtime ... for free! From ullrich at math.okstate.edu Mon Sep 3 10:31:04 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Mon, 03 Sep 2001 14:31:04 GMT Subject: typechecks: just say no! (was Re: Determining Types) References: <9mvo0u04o8@enews2.newsguy.com> Message-ID: <3b938f31.2123170@nntp.sprynet.com> On Mon, 3 Sep 2001 13:02:54 +0200, "Alex Martelli" wrote: >"Adonis Vargas" wrote in message >news:fe9k7.1835$ix.446807 at newsrump.sjc.telocity.net... >> how am i able to determine types of variables? i have come up with the > >Be aware that, MOST times you THINK you need to typecheck, you >really *don't*. Type-checks break the wonderful signature based >polymorphism that is the key to so much of Python's power and >simplicity. Check out the Cookbook recipe: >http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52291 >for a way to avoid type-checking (in favour of signature >checking) even when you might think it's indispensable. Just the other day I did something that involves type checking. I felt guilty about it, but it gives me what I want. How do I do the following without type-checking? (Or how do I do something other than the following that retains the keenness of it?) I have records. Rec has (almost) no user-defined attributes except for __getitem__; fields are assigned dynamically from field names in the database, using settattr() when a record is read. So I can use rec.thisfield and rec.thatfield even though the Rec class doesn't know about "thisfield" and "thatfield", keen. But in other places it's good to be able to refer to fields with non-literal names, so I add a __getitem__ so that rec['thisfield'] returns rec.thisfield. (Actually the main reason I want this is so that I can use a Rec as a mapping in a string format thing: 'Your name is %(Name)s' % rec) In yet other places I want to iterate over the fields of a record, as in for key, value in rec: So in __getitem__ I check the type of index, returning getattr(self, index) if index is a string and saying fieldname=self.__fieldnames__[index] return (fieldname, getattr(self, fieldname)) if index is an integer. Seems utterly keen to be able to use them as both lists and as mappings, as needed. David C. Ullrich From tolot at solar-system.dynodns.net Thu Sep 13 16:10:39 2001 From: tolot at solar-system.dynodns.net (Marc Christiansen) Date: Thu, 13 Sep 2001 22:10:39 +0200 Subject: unicode strings and such References: <3BA0CC8E.1050705@hp.com> Message-ID: Garth Grimm wrote: One thing apparently nobody noticed until now, this line > patternRegex = re.compile(pattern,re.UNICODE or re.IGNORECASE) should probably read patternRegex = re.compile(pattern,re.UNICODE | re.IGNORECASE) (or use '+' instead of '|', in this case it doesn't matter). 'or' is the logical or, not the binary (or however it is called). To see the difference, do a print re.UNICODE, re.IGNORECASE print re.UNICODE or re.IGNORECASE, re.UNICODE | re.IGNORECASE from the python prompt. HTH Marc From aleax at aleax.it Mon Sep 3 05:39:07 2001 From: aleax at aleax.it (Alex Martelli) Date: Mon, 3 Sep 2001 11:39:07 +0200 Subject: Unicode -> UTF-8 References: Message-ID: <9mvj3t03044@enews2.newsguy.com> "Ignacio Vazquez-Abrams" wrote in message news:mailman.999477366.3290.python-list at python.org... > What's the easiest way in C to get the contents of a PyUnicodeObject (or a > PyStringObject for that matter) as UTF-8? What about (warning, untested code): void treat_as_utf8(PyObject* pSomeUnicode) { char* buffer; int length; int rc; PyObject* pAstring = PyObject_CallMethod(pSomeUnicode,"encode","s","utf8"); if(!pAstring) return; rc = PyString_AsStringAndSize(pAstring, &buffer, &length); if(rc==0) { /* snipped: use buffer (READ-ONLY!) & length as you wish */ } Py_DECREF(pAstring); } Is this what you had in mind? There are also "es" and "es#" formats which I think you should be able to use directly with PyArg_Parse, a la (I think): buffer = 0; rc = PyArg_Parse(pSomeUnicode, "es#", "utf8", &buffer, &length); /* check rc & use buffer/length, read/write now */ PyMem_Free(buffer); but I'm unclear on the status/usability of PyArg_Parse -- the current docs say it's all right to use it to analyze other object (not arguments), but I've seen people "in the know" just flat out advise against using it and claiming it is in fact deprecated (without qualifying that warning with "for argument parsing only"). Maybe this thread can lead to some useful clarification in this regard...? Alex From aleaxit at yahoo.com Sun Sep 9 14:00:05 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 9 Sep 2001 20:00:05 +0200 Subject: Proposed PEP for a Conditional Expression References: Message-ID: <9nganb0t8f@enews1.newsguy.com> Michael Chermside wrote: [excellent work snipped, as I just want to snipe on one point...] > using it may require creating a temporary variable and > splitting a formula into two lines, or replacing a lambda > expression with a named function. I consider that replacing lambda forms with named functions, in Python, is an *excellent* practice, which should be encouraged by all means necessary. If the lack of a conditional operator does indeed encourage people to write more local def's and fewer lambdas, then (to me) that is the "killer argument" for not introducing conditional operators. Maybe (it's been hotly and often debated, but never PEP'd) Python would benefit from having some more general way to insert an unnamed code block on the fly. But Python's lambda, as it stands, is so limited and unwieldy that encouraging more use of it makes no sense to me. If we get more powerful lambda-like/unnamed-block-like constructs, then the issue may go away (I don't think such an introduction would greatly benefit Python, as it only introduces more ways to do the same things, and the extra complication, I think, outweighs the extra expressiveness -- but I understand how somebody coming from Ruby, Smalltalk, or FP languages can miss such a feature terribly), and I would then have no substantial objection to conditionals (the pro's and con's have been well presented -- to me, apart from this lambda-related point, the weighted sum is very slightly against introducing conditionals, but not enough to make a big difference to me either way). In PEP terms, I think you could summarize this tirade by s/function./function (which some would argue is a good think, given the current pitiful state of lambda in Python)./ and have done justice to us all adversaries of using Python's current lambdas, while staying even-handed (as your whole pre-PEP is so admirably) even on this side issue of potential relevance. Alex From teg at redhat.com Sun Sep 30 15:13:36 2001 From: teg at redhat.com (Trond Eivind =?iso-8859-1?q?Glomsr=F8d?=) Date: 30 Sep 2001 15:13:36 -0400 Subject: GNU wars again (was Re: Proposal: add vector arithmetic to array module) References: <7x3d5bxhan.fsf@ruckus.brouhaha.com> <7xzo7jnkjv.fsf@ruckus.brouhaha.com> <9p7kq3$kiu$1@panix3.panix.com> Message-ID: aahz at panix.com (Aahz Maruch) writes: > In article <7xzo7jnkjv.fsf at ruckus.brouhaha.com>, > Paul Rubin wrote: > >"DeepBlue" writes: > >> > >> This is new to me - if you can not redistribute a distribution in a > >> modified form, does it mean it is not free? > > > >Correct. See www.gnu.org/philosophy/free-sw.html for explanation. > > Lots of people disagree with this, which is why the phrase "open source" > has become so much more popular than the GNU view. Haven't seen that happening - they're both popular. Of course, "free" means that you have and can modify the source and I haven't seen anyone claim that using the term "open source" doesn't include this. The GPL restricts your freedom to restrict the software as released by you and is thus "less free" than eg. the XFree86 license. However, that a product has been made with such source (containing BSD code) does not mean that the end product is free as they can choose other licenses for the final product. -- Trond Eivind Glomsr?d Red Hat, Inc. From emile at fenx.com Thu Sep 13 07:58:54 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 13 Sep 2001 04:58:54 -0700 Subject: Type conversion mysteries ? References: Message-ID: <9nq81t$95bjk$1@ID-11957.news.dfncis.de> "Georg Hoermann" wrote in message news:qa71qtg73mtf7sb404qnh84r3kbjaf6olp at 4ax.com... > Hello World, > > can someone please explain these results: It's the order the calculations are done in. > > print 100.0*1200/2450 is 48 here you create a float 120000.0 then divide by 2450 to get 48 > print 1200/2450*100.0 gives 0 (zero ?!) here you integer divide 1200/2450 to get 0 then multiply by 100.0 This will (very likely) change in a futuure release. > > Thanks, > Georg -- Emile van Sebille emile at fenx.com --------- From dgallion1 at yahoo.com Tue Sep 18 13:53:21 2001 From: dgallion1 at yahoo.com (Darrell) Date: 18 Sep 2001 10:53:21 -0700 Subject: re source code References: Message-ID: Go to https://sourceforge.net/tracker/?atid=105470&group_id=5470&func=browse Search for Request ID: 456742 A full explanation of how this works is beyond me right now. The work around tries to avoid recursion in favor of a loop. The problem is that even a loop must make sure that the next char matches whatever is defined before the '*'. In the case of '.' this isn't real hard. In the case of "[^\n].*?", recursion is more attractive. --Darrell "Carlos Gaston Alvarez" wrote in message news:... > I want to read re source code. > I want to know why it is more tolerant to .* than to .*? and so on. The > final documentation is the source. I want that. > > Chau, > > Gaston > > "Use the source, Luke" From logiplexsoftware at earthlink.net Mon Sep 24 17:39:42 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Mon, 24 Sep 2001 14:39:42 -0700 Subject: Why so few Python jobs? In-Reply-To: <00d001c14540$76107ca0$6501a8c0@pacbell.net> References: <9oltnk$vv3$1@nntp9.atl.mindspring.net> <00d001c14540$76107ca0$6501a8c0@pacbell.net> Message-ID: <01092414394200.04862@logiplex1.logiplex.net> > It's a bit more reasonable to say: > "Once it's written in Python it's easy to fix." True, but if I were reasonable, we wouldn't be converting our entire product line from SCO/C to Linux/Python ;-) -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From joost_jacob at hotmail.com Thu Sep 6 15:22:19 2001 From: joost_jacob at hotmail.com (J.Jacob) Date: 6 Sep 2001 12:22:19 -0700 Subject: Question regarding commenting code References: <3B977CA6.4040000@alum.mit.edu> Message-ID: <13285ea2.0109061122.3d556c9a@posting.google.com> A very simple rule we found useful is this: "only comment variables" Meaning you only explain the "nouns" in your code. The other code (the "verbs") should speak for themselves. If you have a really complex function you can also put an "algorithm" comment block after the function header, or a "usage" block after a complex class header. Other than that it should be enough to describe what a variable does in your code, and maybe also what it means and why it is used. We had good experiences using this comment-style-rule in a team. From nhodgson at bigpond.net.au Mon Sep 10 21:30:06 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Tue, 11 Sep 2001 01:30:06 GMT Subject: Pythonwin and .NET References: <3B997A5E.6010801@bigpond.net.au> <3B9D6654.FA287BA5@earthlink.net> Message-ID: Ron Stephens: > Mr. Hammond, why is Python on .NET not currently viable? Also, do you think > ActiveState will stick with it until it is viable? I can't speak for Mark, but my main problem with Python.NET is speed. The .NET EULA does not allow posting benchmarks but Python.NET is seriously slow unlike Jython which is comparable to CPython. Currently, if you want to use Python in a .NET application you may be better off linking to the CPython interpreter over COM interop. Neil From tim.one at home.com Wed Sep 26 00:39:41 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 26 Sep 2001 00:39:41 -0400 Subject: WeakValueDictionary In-Reply-To: <001501c145fe$0cca9fa0$6401a8c0@pacbell.net> Message-ID: [Ken Seehof] | >>> sys.version | '2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit (Intel)]' | >>> import weakref | >>> d = weakref.WeakValueDictionary() | >>> d['z'] | Traceback (most recent call last): | File "", line 1, in ? | File "C:\PYTHON21\lib\weakref.py", line 35, in __getitem__ | o = self.data.get(key)() | TypeError: object of type 'None' is not callable | | Shouldn't this be raising KeyError instead of TypeError? It does in current CVS Python: C:\Code\python\PCbuild>python Python 2.2a3+ (#23, Sep 20 2001, 19:43:51) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import weakref >>> d = weakref.WeakValueDictionary() >>> d['z'] Traceback (most recent call last): File "", line 1, in ? File "C:\CODE\PYTHON\lib\weakref.py", line 44, in __getitem__ o = self.data[key]() KeyError: z >>> I guess that's what the extra 9 lines of code do . From mlh at idi.ntnu.no Fri Sep 28 18:18:26 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Sat, 29 Sep 2001 00:18:26 +0200 Subject: Sorry!!!!!!! References: Message-ID: <9p2svi$i5l$1@tyfon.itea.ntnu.no> wrote in message news:mailman.1001533132.13660.python-list at python.org... > The Python collective forgives you! ROTFLMAO! :) -- Magnus Lie Hetland http://www.hetland.org "Reality is that which, when you stop believing in it, doesn't go away." -- Philip K. Dick From printers at sendme.cz Sat Sep 29 15:10:54 2001 From: printers at sendme.cz (A) Date: Sat, 29 Sep 2001 21:10:54 +0200 Subject: How can I access a variable outside a class definition? Message-ID: <3BB638DE.20838.53CAAE@localhost> Hi, How can I access a variable defined in one class outside this class ? For example I have two classes like below ############################# class Complex: def __init__(self, realpart1,imagpart1,realpart2,imagpart2): self.r1 = realpart1 self.i1 = imagpart1 self.r2 = realpart2 self.i2 = imagpart2 def Add(self,r1,i1,r2,i2): self.sum=self.i1+self.i2 ImSum=self.sum return ImSum ########################### ########################### class Outside def MyFunction(self,ImSum) ... ... ######################## Is it possible to access,in the Outside class, a value of the ImSum that was return by Add function in that Complex class? Thank you for help. Ladislav From xavier at perceval.net Wed Sep 19 08:36:31 2001 From: xavier at perceval.net (Xavier Defrang) Date: Wed, 19 Sep 2001 14:36:31 +0200 (CEST) Subject: Size in bytes of a dictionary Message-ID: Dear Pythoneers, I haven't been able to find a way to get the total size in bytes of a dictionary object. I'm writing an application that deals with a large hashtable (a string-string mapping) and I'd like to be able to monitor its size in memory. Is there any heuristic formula I may use depending on the number of keys and the way the interpreters allocates memory for the data structure? Regards, Xavier Defrang Perceval R&D Team xavier at perceval.net ------------------------------------------------- Perceval Technologies SA/NV Tel: +32-2-6409194 Rue Tenbosch, 9 Fax: +32-2-6403154 B-1000 Brussels http://www.perceval.net BELGIUM info at perceval.net ------------------------------------------------- From thomas.heller at ion-tof.com Wed Sep 26 15:01:03 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Wed, 26 Sep 2001 21:01:03 +0200 Subject: Packaging problem[py2exe, Inno setup] - pywintypes.com_error References: Message-ID: <9ot8lm$fbstf$1@ID-59885.news.dfncis.de> "Radhika Bodapatla" wrote in message news:a1d2cfb3.0109261009.183099fc at posting.google.com... > My application[eclient.py, on winNT4.0] uses > win32com.client[win32com.client.Dispatch('MSXML2.XMLHTTP'), > win32com.client.dynamic.Dispatch("Excel.Application")] and also > xml.sax for xml parsing. > I create a setup.py file: > ;-----setup.py----------- > from distutils.core import setup > import py2exe > setup(name="eclient", > scripts=["eclient.py"], > data_files=[("template",["expenseform.xls"])],) > ;------------------------ > I run it using py2exe: > python setup.py py2exe -p _xmlplus,win32com > This creates 2folders build and dist. In the dist folder it creates > eclient folder in which it has the eclient.exe and other .dlls. Also > creates a folder tcl with 2more folders in it- tcl8.3 and tk8.3. > Then I use Inno setup[I only include the files in the dist folder] to > create my .exe so that I can install it on a machine that doesn't have > python installed on it. > But this is the error I get when I try to run it from another machine: > Traceback : > File "", line 332, in ? > File "", line 12, in __init__ > File "win32com\client\__init__.pyc, line 94, in Dispatch > File "win32com\client\dynamic.pyc, line 81, in > _GetGoodDispatchandUserName > File "win32com\client\dynamic.pyc, line 72, in _GetGoodDispatch > pywintypes.com_error: (-2147221005, 'Invalid class string', None, > None) win32com\client\dynamic, line 72 is IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) I could be wrong, but doesn't this error say that CoCreateInstance fails because the COM object you are trying to use is not registered on the other machine? Thomas From tim.one at home.com Tue Sep 18 02:00:09 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 18 Sep 2001 02:00:09 -0400 Subject: Request for example of state machine using generators In-Reply-To: Message-ID: [MikeK] > I'm trying to learn how to best use Python2.2 generators, and would > appreciate someone posting an example of a simple state machine using > generators. The appeal of generators wrt state machines usually lies in not having to maintain an explicit state machine at all, so yours is a paradoxical request. In 2.2a3 (or CVS), you can look at Tools/scripts/cleanfuture.py for an extended example of using generators to avoid state machines, there in a parsing context. Lib/test/test_generators.py also has many examples of generator techniques. From andy.elvey at paradise.net.nz Wed Sep 26 02:27:15 2001 From: andy.elvey at paradise.net.nz (Andy Elvey) Date: Wed, 26 Sep 2001 18:27:15 +1200 Subject: lexical closures and python References: Message-ID: <%yes7.10727$ww1.956492@news02.tsnz.net> John Beppu wrote in message news:mailman.999755048.7248.python-list at python.org... > Hi, > > My understanding is that Python does not support lexical closures. > I've also heard that it should not be expected to appear any time > in the near future. Can anyone confirm or deny this? > > I want to know, because I'm writing a piece that talks a lot > about Scheme, and I was comparing it to a lot of scripting languages > that are out there -- Perl, Python, Ruby, and even JavaScript... > It seemed strange to me that of all these languages, Python was the > one that didn't support lexical closures. (On the other hand, I was > surpised to find out that JavaScript _did_ support lexical closures). > It *is* indeed possible to do closures in Python ! See this article - http://www-106.ibm.com/developerworks/library/l-prog.html and - http://www-106.ibm.com/developerworks/library/l-prog2.html . ( This is a 2-part article - the second part of it (the 2nd URL given) shows how to do closures.) This article gives an *excellent* intro to functional programming using Python . The code in these articles uses the "Xoltar toolkit" - http://sourceforge.net/projects/xoltar-toolkit - which is itself written in Python. From -$Paul$- at verence.demon.co.uk Sat Sep 15 09:16:06 2001 From: -$Paul$- at verence.demon.co.uk (Paul Wright) Date: 15 Sep 2001 13:16:06 -0000 Subject: idea: Robocode for Python References: <9nq2db$3gda$1@mail1.wg.waii.com> <9ntldd$tie$1@mail1.wg.waii.com> Message-ID: <9nvkam$khr$1@verence.demon.co.uk> In article , Andrew Henshaw wrote: > >"Martin Franklin" wrote in message >news:9ntldd$tie$1 at mail1.wg.waii.com... >> No, it is: |(java.util.PropertyPermission * read,write)| >> Preventing Robot Loader from access: (java.util.PropertyPermission * >> read,write) >> No, it is: |(java.util.PropertyPermission user.dir read)| >> Preventing Robot Loader from access: (java.util.PropertyPermission >user.dir >> read) >...snip... > >This is a similar results to my efforts. Interestingly, the permission >errors seemed to disappear upon reordering the classpath - no idea why. But >then, my robot failed as my (your) pyrobot classs wasn't a subclass of >Robot. Ooops, I wasn't linking in the robocode.jar. When I changed that >back, I could no longer 'jythonc' my code. Frustrating. I'll try again >with a more controlled approach. Good luck to you. I'm able to jythonc my code but I get similar errors to those above. I'm using IBM's JDK 1.3 under Linux. You can tell whether you've got the classpath right for jythonc as it prints out whether the robot you've created is a subclass of robocode.Robot or java.lang.Object. I think the permissions errors are coming from the Java security manager: robots are probably not allowed to access the filesystem but Jython is attempting to access its own cache directory. Knowing very little about Java or Jython, I don't know whether there's anything we can do about this. Did you find an ordering of the classpath which would enable you to run jythonc correctly and avoid the permission errors? On the licence issue, the author notes that there is nothing in the licence preventing you from downloading again after the 90 days are up (hint, hint). He also states that as the thing is in quite rapid development, you'll want to get updates anyway. -- ----- Paul Wright ------| This may seem a bit weird, but that's okay, because -paul.wright at pobox.com--| it is weird. - Perl 5 manpages http://pobox.com/~pw201 | From barry at zope.com Mon Sep 17 01:28:33 2001 From: barry at zope.com (Barry A. Warsaw) Date: Mon, 17 Sep 2001 01:28:33 -0400 Subject: ANNOUNCE mimelib 0.5 Message-ID: <15269.35329.201238.946022@anthem.wooz.org> I've just released mimelib 0.5, a package for handling email messages, including MIME documents. This version contains lots of new features, bug fixes, and unit tests. See below for a NEWS file excerpt. This will likely be the last independent release of mimelib. I intend to merge it into the Python standard library for Python 2.2 alpha 4. There will be changes due to the merge, including a new name for the package (`email' It Shall Be Called), and some shuffling of modules and method names. The current Mailman 2.1 alpha and CVS snapshot has not been tested with this release, and there are likely some breakages. The next Mailman alpha release /will/ be made compatible, and if any bugs crop up at that point, there may have to be an 0.6 release. I hope not though. The mimelib projects page at SourceForge (includes links for downloading): http://sf.net/projects/mimelib The online manual: http://mimelib.sf.net Cheers, -Barry -------------------- snip snip -------------------- 0.5 (17-Sep-2001) - New methods in the top-level mimelib package namespace: + messageFromString() to create an object tree from a string. + messageFromFile() to create an object tree from an open file. - New methods in the address.py module: + encode() for encoding to RFC 2047 headers + decode() for decoding from RFC 2047 headers - New methods in the Message class: + asString() to get a flat text representation of the object tree. + __str__() same as asString() but includes the Unix-From envelope header in the output. + __contains__() for use with the `in' operator. + attach() is a synonym for add_payload() + getcharsets() + getfilename() + getboundary() + setboundary() + getdecodedpayload() + getpayloadastext() + getbodyastext() - Message.preamble and Message.epilogue default to None (they used to not exist by default). - Changes to the Generator class: + New optional argument `maxheaderlen' for __init__() controls the maximum length in characters of any header line. + write() isn't the entry point for doing the text generation any more. This lets us make this method compatible with file-like objects. Use __call__() semantics instead. + Calling a Generator instance creates the plain text message. This is the same as the old write() interface except that the optional `unixfrom' argument now defaults to 0. + There is a new, undocumented semi-private interface for extending the MIME types Generator can handle. UTSL. - New Encoders.py module contains some useful encoders for Image and Text instances. - Text.__init__() has a new _encoder optional argument, which has the same semantics as _encoder for Image.__init__(). - StringableMixin.py module has been removed, and its functionality merged back into the Message class. - MessageParseError doesn't contain line numbers any more. - Lots of bug fixes; lots more unit tests. From ignacio at openservices.net Thu Sep 20 17:52:24 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Thu, 20 Sep 2001 17:52:24 -0400 (EDT) Subject: Ksh-ish functionality on Unix systems In-Reply-To: <1001022297.843756@cswreg.cos.agilent.com> Message-ID: On Thu, 20 Sep 2001, Greg Weeks wrote: > The low-level support is far too verbose for casual use. The higher-level > stuff seems incomplete. However, the higher-level stuff becomes a lot more > complete if the command arguments are passed to, say, /bin/sh on Unix > systems. In that case, os.system and getstatusoutput capture the above Ksh > functionality, and os.popen and popen2.* are bonuses. > > So: Is it a reasonable approach as a Unix user to rely on the fact that the > os.system and getstatusoutput commands are passed to a shell? > > Or is that tacky? If that *is* tacky, is there a *convenient* alternative? Yeah, that's tacky. No, there are no convenient alternatives. Looks like you're stuck with popen*(), fork(), and the threading module. -- Ignacio Vazquez-Abrams From logiplexsoftware at earthlink.net Fri Sep 7 15:02:47 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 7 Sep 2001 12:02:47 -0700 Subject: Creating Excel files on Linux In-Reply-To: References: <3B97A39C.6A5234D7@olen.to> <873d5ygbzx.fsf@lumen.med.iupui.edu> Message-ID: <01090712024702.02565@logiplex1.logiplex.net> On Friday 07 September 2001 10:30, you wrote: > This is fine. But in my experience, the average user can create a Macro > and be trained to create useful forms in Excel in a much shorter time than > it will take to get a Computer Science degree in order to be able to step > through a JAVA function. No, the _above_ average user can do this. The average user doesn't know that Excel isn't Windows. > The issue here Michael, in my opinion, is that many attack Microsoft on the > premise of the MYTH of an open platform that is being called on by many > sides including companies that would not give a dime about this concept if > they have the same market share as Microsoft. > Maan Yes, when IBM gets as big as Microsoft, they'll want their billion dollars back. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From sill at optonline.net Wed Sep 26 18:21:05 2001 From: sill at optonline.net (Andrei Kulakov) Date: Wed, 26 Sep 2001 22:21:05 GMT Subject: scanf style parsing References: <3BB16A50.BAE082FE@cygnus-software.com> Message-ID: On Wed, 26 Sep 2001 05:42:45 GMT, Bruce Dawson wrote: > I love programming in Python, but there are some things I have not found > the easy way to do. I understand that Python is supposed to be good at > text parsing, but I am having trouble with this simple task. Given this > text (the output from VisualC++) I want to find out how many errors and > warnings there were: > > smtpmail.exe - 0 error(s), 0 warning(s) Seeing that there should only be 2 words here that are numbers, you can do this: my_str # that's where the result is words = my_str.split() lst = [] for word in words: try: result = int(word) lst.append(result) except: pass errors = lst[0] warnings = lst[1] I'm not sure how can this format vary, but if these numbers are always at the same place, you could have just done: errors, warnings = int(words[2]), int(words[4]) - Andrei -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: cy.silmarill.org From peter at engcorp.com Tue Sep 25 00:26:14 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 25 Sep 2001 00:26:14 -0400 Subject: Using glob (was Re: Remove files of same type (extension)) References: <9on1mq$pj8$04$1@news.t-online.com> <3BAF3754.68BDA949@yahoo.com> Message-ID: <3BB00766.CC23290C@engcorp.com> Marcin 'Qrczak' Kowalczyk wrote: > > Mon, 24 Sep 2001 17:38:28 +0400, A.A pisze: > > > You can use the fnmatch module to match using dos/unix like patterns: > > Or the glob module. I used to think glob was a good choice, and simpler than os.listdir plus os.path.walk etc because it would handle things like */*.txt and returned the full path. I just got caught, however, by my apparent lack of understanding of the phrase "according to the rules used by the Unix shell" from the library reference info on glob. glob.glob('*') returns all files *except* those that start with a period glob.glob('.*') returns all files which do start with a period. To use glob to get *all* files, one must do something like glob.glob('*') + glob.glob('.*') I'd be happy to learn otherwise, but that's what reading the source confirmed for me... Still easier than os.listdir sometimes, but I wonder if it should be considered rather specialized. Or was that already the general consensus? -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From phr-n2001 at nightsong.com Thu Sep 13 00:46:53 2001 From: phr-n2001 at nightsong.com (Paul Rubin) Date: 12 Sep 2001 21:46:53 -0700 Subject: What is Python good for? References: <6f8cb8c9.0109120541.132432d4@posting.google.com> <3BA0293F.F558764A@engcorp.com> Message-ID: <7xbskfitoi.fsf@ruckus.brouhaha.com> Peter Hansen writes: > I wonder whether Python is hands down the best "glue" language. > ... > Does anything else come even close? The main competition is Perl, which has a much deeper component library (cpan.org) and more slick little shorthand devices. Perl is of course much clumsier for writing large maintainable programs. From aleax at aleax.it Fri Sep 21 14:59:00 2001 From: aleax at aleax.it (Alex Martelli) Date: Fri, 21 Sep 2001 20:59:00 +0200 Subject: python version References: Message-ID: <9og2lk$o1k$1@lancelot.camelot> Bob Roberts wrote: > How can a python program find out what version of python it is running? >>> import sys >>> print sys.version 2.2a3 (#1, Sep 11 2001, 23:11:58) [GCC 2.96 20000731 (Linux-Mandrake 8.0 2.96-0.48mdk)] >>> print sys.version_info (2, 2, 0, 'alpha', 3) >>> print sys.hexversion 33685667 >>> print hex(sys.hexversion) 0x20200a3 >>> Alex From aleax at aleax.it Mon Sep 3 11:22:13 2001 From: aleax at aleax.it (Alex Martelli) Date: Mon, 3 Sep 2001 17:22:13 +0200 Subject: typechecks: just say no! (was Re: Determining Types) References: <9mvo0u04o8@enews2.newsguy.com> <3b938f31.2123170@nntp.sprynet.com> Message-ID: <9n077501por@enews1.newsguy.com> "David C. Ullrich" wrote in message news:3b938f31.2123170 at nntp.sprynet.com... ... > But in other places it's good to be able to refer to > fields with non-literal names, so I add a __getitem__ > so that rec['thisfield'] returns rec.thisfield. ... > In yet other places I want to iterate over the fields > of a record, as in > > for key, value in rec: > > So in __getitem__ I check the type of index, returning > getattr(self, index) if index is a string and saying > > fieldname=self.__fieldnames__[index] > return (fieldname, getattr(self, fieldname)) > > if index is an integer. > > Seems utterly keen to be able to use them as both > lists and as mappings, as needed. Matter of taste (I personally don't much like any confusion between attributes and items), and in Python 2.2 a far better solution is provided (the for statement will first attempt to use the __iter__ method -- just implement *that* one to return the iterator you want, and note that for a built-in dictionary for x in dict only iterates on KEYS, *not* key-value pairs, so, take care to avoid any confusion...). Admittedly, being able to index a Collection on EITHER item name or item number IS a typical Visual Basic feechur, but that still doesn't much recommend it to my personal taste. Anyway...: If I had to implement this in Python 2.1 or earlier, I'd use either variant of "it's easier to get forgiveness than permission", which after all IS the typical idiom to use where the unenlightened would typetest: i.e., either: def __getitem__(self, index): try: return getattr(self, index) except AttributeError: fieldname=self.__fieldnames[index] return fieldname, getattr(self, fieldname) or: def __getitem__(self, index): try: fieldname=self.__fieldnames[index] except TypeError: return getattr(self, index) else: return fieldname, getattr(self, fieldname) This would let client-code use any "index" that is string'ish enough to please getattr, or int'ish enough to please the [] indexing on __fieldnames (don't use double leading AND trailing __ for your own purposes, they're all "reserved to Python"!-). Alex From mikael at isy.liu.se Tue Sep 4 03:48:13 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Tue, 04 Sep 2001 09:48:13 +0200 (MET DST) Subject: Conditional operator in Python? In-Reply-To: <9n1vir$chl$1@glue.ucr.edu> Message-ID: On 04-Sep-2001 thp at cs.ucr.edu wrote: > Okay, factorial is a somewhat simplistic example. Consider the > following function, which counts the k-way partitions of n: > > p = lambda k, n : ( > ( k < 1 or k > n ) and [0] or > ( n == 1 or n == k ) and [1] or > [p(k-1,n-1)+p(k,n-k)] > )[0] > > Using, say, ?: notation this would be written: > > p = lambda k, n : > k < 1 or k > n ? 0 : > n == 1 or n == k ? 1 : > p( k-1, n-1 ) + p (k, n-k ) > > which seems much more concise and readable. Well, both are just as hard to read to me, but then I have never used C. I (almost) always use if-then-else, since that fits my small brain best. Sure, it needs more rows, but I prefer that to both variations of line noise above. /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: 04-Sep-2001 Time: 09:38:44 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- Link?pings kammark?r: www.kammarkoren.com From logiplexsoftware at earthlink.net Wed Sep 19 15:31:43 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Wed, 19 Sep 2001 12:31:43 -0700 Subject: optional arguments In-Reply-To: References: Message-ID: <01091912314300.03077@logiplex1.logiplex.net> On Monday 17 September 2001 02:52, Martin von Loewis wrote: > Silvio Arcangeli writes: > > class Connection: > > def __init__(self, ip=def_ip, port=def_port) > > ... > > [...] > > > how can I tell wheter no arguments were passed from the user or whether > > they were passed but they were just like the default values? > > Another possibility is mxTools which provides a NotGiven singleton similar to None: (from the mxTools page): import mx.Tools.NewBuiltins def f(a,b=4,c=NotGiven,d=''): if c is NotGiven: return a / b, d else: return a*b + c, d http://www.lemburg.com/files/python/mxTools.html -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From skip at pobox.com Wed Sep 12 17:06:12 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 12 Sep 2001 16:06:12 -0500 Subject: math.frexp - what's it mean? In-Reply-To: References: Message-ID: <15263.52804.991188.533242@beluga.mojam.com> >>> mantissa, exponent = math.frexp(5e40) Not being a numeric type person, "frexp" conjured up absolutely no mnemonic significance for me. The library reference manual was no help either. Finally, I tried "man frexp" and got "convert floating-point number to fractional and integral components". Now I know what it means mnemonically ("FRaction EXPonent", I guess), but the name is still perplexing. Why not "manexp"? Does its use predate its appearance in C? Skip From qrczak at knm.org.pl Tue Sep 4 12:50:48 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 4 Sep 2001 16:50:48 GMT Subject: Conditional operator in Python? References: <9n1vir$chl$1@glue.ucr.edu> <3B94F000.64D06161@alcyone.com> <3B94FF7B.53B929BE@alcyone.com> Message-ID: Tue, 04 Sep 2001 09:21:15 -0700, Erik Max Francis pisze: > Maybe something like > > if X return Y else Z Or if (X) Y else Z which looks like statement if without colons (but parens are required). > I wouldn't be averse to introducing a new keyword for this purpose, > but if that's the stumbling block, it seems that a preexisting > keyword can be used in this context that will work just as well. At least I don't see other problems (and other than "it's unnecessary feature bloat"). -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From Tobias_Unruh at FRM2.TU-Muenchen.DE Wed Sep 5 11:18:20 2001 From: Tobias_Unruh at FRM2.TU-Muenchen.DE (Tobias Unruh) Date: Wed, 5 Sep 2001 17:18:20 +0200 (CEST) Subject: no parallel threading? Message-ID: Hi, I tried to execute two threads in parallel (linux 2.4.9, python 2.0): import time import threading def test_thread_func1(): print "Hallo1" time.sleep(3.0) print "Hallo1" def test_thread_func2(): print "Hallo2" time.sleep(3.0) print "Hallo2" printlock = threading.Lock() test_thread1 = threading.Thread(None,test_thread_func1()) test_thread2 = threading.Thread(None,test_thread_func2()) print "number of active threads: %d" % threading.activeCount() test_thread1.start() test_thread2.start() print "number of active threads: %d" % threading.activeCount() while test_thread1.isAlive()==1: continue print "number of active threads: %d" % threading.activeCount() The output of the program is: Hallo1 Hallo1 Hallo2 Hallo2 number of active threads: 1 number of active threads: 3 number of active threads: 1 Why this result? From the first four lines I concluded that the threads are executed one after the other (which is not intended). In this case, however, the number of active threads should be 1 in any case. But these values are ok. Is there something wrong with the output? sys.stdout.flush() does not help. Any suggestions? Tobias -- Tobias Unruh TU Muenchen, FRM-II 85747 Garching, Germany From martin.franklin at westgeo.com Fri Sep 14 04:43:50 2001 From: martin.franklin at westgeo.com (Martin Franklin) Date: Fri, 14 Sep 2001 09:43:50 +0100 Subject: create documentation with the comments present in the source code References: <9nsdkl$s3q$1@s1.read.news.oleane.net> Message-ID: <9nsfsb$2ctu$1@mail1.wg.waii.com> Dietmar Lang wrote: > Hi! > >> As it is possible to put comment in 'python' code just after a function, >> a class as following : >> >> def Function(): >> """ >> My comment >> """ >> if ... >> >> As it is possible to get this comment in the python command with an >> simple instruction... > > Yes, here's a little interactive session: > >>>> def Voila(): > """This is documentation for Voila()""" > pass > >>>> print Voila.__doc__ > This is documentation for Voila() >>>> > > There you go... If more details are needed, maybe someone here will jump > in... > >> Is there an utility which realize a pretty documentation with these >> comments ? > > There propably is, else why don't you make one? ;) > > Kudos, Dietmar > Take a look at HappyDoc this will create static HTML documentation from doc strings search the vaults http://www.vex.net/parnassus/ From qrczak at knm.org.pl Tue Sep 4 04:27:09 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 4 Sep 2001 08:27:09 GMT Subject: Conditional operator in Python? References: <9n1vir$chl$1@glue.ucr.edu> Message-ID: Tue, 4 Sep 2001 07:24:13 +0000 (UTC), thp at cs.ucr.edu pisze: > Using, say, ?: notation this would be written: > > p = lambda k, n : > k < 1 or k > n ? 0 : > n == 1 or n == k ? 1 : > p( k-1, n-1 ) + p (k, n-k ) > > which seems much more concise and readable. IMHO this would look more clearly: p = lambda k, n: if k < 1 or k > n then 0 else if n == 1 or n == k then 1 else p( k-1, n-1 ) + p (k, n-k ) -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From rnd at onego.ru Wed Sep 5 15:00:18 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 5 Sep 2001 23:00:18 +0400 (MSD) Subject: no parallel threading? In-Reply-To: Message-ID: On Wed, 5 Sep 2001, Tobias Unruh wrote: >> On Wed, 5 Sep 2001, Tobias Unruh wrote: > >def test_thread_func1(): > k=0L > print "hello1" > for i in range(1000000): > k=k+1 > print "hello1" Put hello into the loop and another delay loop. for i in range(20): print "hello1" for i in range(100000): k=k+1 >but nothing changed. > >I installed now Python 2.2.a2. But again the same problem... > >Do I have it to write in C++? > >> >> BTW, this is what intrigued Linus most and was supported from the very >> first version of Linux ;-) (in processes, of course, not threads) Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Wednesday, September 05, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "... Clinton sandwich: $5 of baloney and $20 in taxes" _/ From g.haering at ___skynamics.com.invalid Wed Sep 5 12:01:06 2001 From: g.haering at ___skynamics.com.invalid (Gerhard =?ISO-8859-1?Q?H=E4ring?=) Date: Wed, 05 Sep 2001 18:01:06 +0200 Subject: Where does my output go? References: Message-ID: <3B964C42.9020407@___skynamics.com.invalid> Michael Abbott wrote: > "Maan M. Hamze" wrote in > news:tpcfiohb7crq2c at corp.supernews.com: > >>"Michael Abbott" wrote in message >>news:Xns91139DA18A194michaelrcpcouk at 194.238.50.13... >> >>>So, I write a small bit of Python (one line): >>> >>>write.py >>>-------- >>> print 'hello' >>>-------- >>> >>>I then run it from the command line: >>> >>> C:\TEMP>write >>> Hello >>> >>> >>I do not understand this step here. How are you running write as an >>executable? and why is it printing Hello not hello? >> > > Oops. My mistake. I cut and pasted the output, but unfortunately, I > didn't cut and paste the source code! The source code should, of course, > be > > print 'Hello' > > As to why running it from the command line (with or without a .py > extension) works? Indeed, that is a mystery, one of the many mysteries of > this marvellous operating system we use. > It's something to do with how the .py extension is registered, I know > that much. > C:\temp\e>copy con: write.py print "Hello." ^Z 1 Datei(en) kopiert. C:\temp\e>write.py Hello. C:\temp\e>write.py >out.txt C:\temp\e>type out.txt Hello. C:\temp\e>echo %OS% Windows_NT Actually version 5 SP2 aka Windows 2000. Windows 9x/ME console is known to be buggy. Gerhard -- Gerhard H?ring skynamics AG g.haering at skynamics.com http://www.skynamics.com From jeff at ccvcorp.com Fri Sep 28 16:20:23 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Fri, 28 Sep 2001 13:20:23 -0700 Subject: Why so few Python jobs? References: <9oltnk$vv3$1@nntp9.atl.mindspring.net> Message-ID: <3BB4DB87.8600869E@ccvcorp.com> tszeto wrote: > > Any ideas on why so few Python jobs are available? > My take, in addition to the many good reasons already mentioned, is that Python is so easy to learn, that when it *is* appropriate to use, it's usually simpler for the existing staff to learn Python as well (or for an otherwise qualified recruit to be taught Python), than to specifically hunt for someone already skilled in Python. Of course, if the company has a need for a *very* skilled Python programmer, then hiring specifically for that skill becomes reasonable. Jeff Shannon Technician/Programmer Credit International From parker at gol.com Mon Sep 17 17:46:01 2001 From: parker at gol.com (Ian Parker) Date: Mon, 17 Sep 2001 21:46:01 GMT Subject: COM and printing an Acrobat References: Message-ID: In article , Ignacio Vazquez-Abrams writes >On Sat, 15 Sep 2001, Ian Parker wrote: > >> Unfortunately, I'm a bit stuck on how to print Acrobat files. Acrobat 4 >> provides an ActiveX control intended for use in IE, but I'm stumped how >> to make use of it to print. >> >> Any ideas? > >Sucks to be you: > > http://www.adobe.com/support/techdocs/cd16.htm > It does indeed. That URL does point out that the ActiveX control is of restricted functionality. Currently, I remain stumped and almost out of time! Regards Ian -- Ian Parker From fredrik at pythonware.com Wed Sep 5 04:25:38 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 05 Sep 2001 08:25:38 GMT Subject: string.split References: Message-ID: <6kll7.895$sn6.205073@newsc.telia.net> Tom Harris wrote: > How do I split on any or all occurrences of (for example) > whitespace and a comma, without using regexes. are you interested in results, or are you just trying to make python fit your mental model? if the former, this does what you want: L = re.split("[\s,]+", S) or faster, in the current version: L = re.findall("[^\s,]+", S) if you're going to do lot of splitting, create a splitter object: mysplit = re.compile("[^\s,]+").findall L = mysplit(S) > I mean string.split() must be able to do it anyway to achieve > the default behaviour. split uses different algorithms depending on the second argument (the unicode type has three different implementations) From dalke at dalkescientific.com Thu Sep 20 23:20:36 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Thu, 20 Sep 2001 21:20:36 -0600 Subject: bsddb3 vs zodb References: <3BA9A72A.1D5A6067@yahoo.com> <3BA9EBFD.3F7ABFFA@engcorp.com> Message-ID: <9oebkq$8k6$1@slb4.atl.mindspring.net> Peter Hansen: >Isn't DB3 a relational database? Since ZODB is clearly not, >we're going to end up just comparing the "pros and cons" of >relational versus object-oriented databases, I think. DB2 is a relational database from IBM. dbm/ndbm/gdbm/Berkeley DBM/Sleepcat BSDDB are all associative databases. (I just made up that term. :) They associate a key (a string) to a value (another string). For example, a mail server needs to know how to expand an email alias into a set of addresses. So it needs the mapping alias -> list,of,email,addresses and a fast way to look it up. It doesn't need a full relational database, nor SQL. Just simple key/value storage and lookup. BSDDB3 is the 3'rd major release of BSDDB, the Berkely DBM being developed by Sleepycat. It offers a lot of functionality. Andrew dalke at dalkescientific.com From weeks at vitus.scs.agilent.com Tue Sep 25 22:31:22 2001 From: weeks at vitus.scs.agilent.com (Greg Weeks) Date: Wed, 26 Sep 2001 02:31:22 +0000 (UTC) Subject: Simple process IO capture (Was: "shell-commands" and python!) - process.py (0/1) References: <9ogit0$e7c$1@newshost.accu.uu.nl> <1001306463.868543@yabetcha.drizzle.com> Message-ID: <1001471482.175819@cswreg.cos.agilent.com> I guess there isn't a lot of interest in this. Still, I'm interested. Donn Cave (donn at drizzle.com) wrote: : Are you thinking about reading stderr for use in the exception? stderr is a messy issue, because there is no agreement on what stderr is for. Some people use stderr only for fatal error messages. Othere use stderr -- now renamed "diagnostic output" -- for any messages whatsoever intended for human readers. The first group is like to want exceptions to include stderr text; the second group isn't. I'm in the first group, and I'm content to write a private utility that handles stderr as if it were used only for fatal error messages (even though I know this will get me into trouble with certain programs). But I'd be hard-pressed to come up with a general solution. Look at the evolution of the popen2 module, for instance. And if you have a pipeline with multiple processes, it just gets that much worse. Greg From beppu at binq.org Wed Sep 12 17:49:36 2001 From: beppu at binq.org (John Beppu) Date: Wed, 12 Sep 2001 14:49:36 -0700 Subject: What is Python good for? In-Reply-To: <9nnsck02uat@enews1.newsguy.com> References: <6f8cb8c9.0109120541.132432d4@posting.google.com> <9nnsck02uat@enews1.newsguy.com> Message-ID: <20010912144936.D18903@BinQ.org> [ date ] 2001/09/12 | Wednesday | 04:44 PM [ author ] Alex Martelli > If you think Perl is easy to master, then you're a very unusual > sort of person. Not necessarily unusual -- just different from you. My background in /bin/sh and C programming made perl really easy, because it just felt like perl fit right in the middle. I can't say perl was very hard for me to learn ...and I'm not /that/ unusual... I think. ;-) From markus at schabi.de Thu Sep 27 04:54:29 2001 From: markus at schabi.de (Markus Schaber) Date: Thu, 27 Sep 2001 10:54:29 +0200 Subject: Are there 'Interfaces' in Python?? References: Message-ID: <1960596.2OnDr8pfo1@lunix.schabi.de> Hi, Lee Morgan schrub: > I don't understand what runtime interfaces get you at all. From my > distant memory of Java a class implements an interface, and therefore > guarantees its existence. > > Ah haa - maybe I get it now, do you mean python interface's would > supply the base interface which you could override? And if so wouldn't > the type/class unification provide a cleaner way of doing it? Or would > an interface just guarantee some base class's __init__ is called? > > Hmm, I should really read the Interface PEP! I would agree. As far as I remember, you ask the object in question to give you a specific interface, and the object returns an instance that is guaranteed to implement the interface (could be the object itsself or a wrapper). When this fails, maybe the interface itsself knows how to wrap around the object and can create such one. markus -- "The strength of the Constitution lies entirely in the determination of each citizen to defend it. Only if every single citizen feels duty bound to do his share in this defense are the constitutional rights secure." -- Albert Einstein From padhia at yahoo.com Tue Sep 18 10:55:23 2001 From: padhia at yahoo.com (P Adhia) Date: 18 Sep 2001 07:55:23 -0700 Subject: newbie - Scoping question References: <3281a460.0109170759.63ede66@posting.google.com> Message-ID: <3281a460.0109180655.6a9c21f5@posting.google.com> Thanks everyone for your help. Now it makes perfect sense. Indeed, it has nothing to do with scoping. (Though I wish it had :) - it's probably more intuitive to me). P. Adhia From loewis at informatik.hu-berlin.de Tue Sep 18 13:30:09 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 18 Sep 2001 19:30:09 +0200 Subject: The nntplib module References: <9o7qqd03vm@enews1.newsguy.com> Message-ID: "Travers Naran" writes: > I'm working on a newsgroup binaries extractor (which works well under > Windows and LINUX), and I'm finding the nntplib doesn't have that nice > feature the Perl NNTP module has of downloading an article body to a file. > I've modified my local copy of nntplib to handle this, but I can't find any > reference to who is maintaining this module so I can make this suggestion. > Who should I contact? Thanks in advance! It's part of the standard Python library, so patches should go to sf.net/projects/python. If you feel that your changes might be controversial, write a PEP. > On a side note, I've found running my script under Linux (same wintel box) > much faster than running under Windows 98. I suspect it's the difference in > Virtual Memory performance, but I can't prove this. Discuss amongst > yourselves. :-) My guess is that it is more likely the efficiency of the TCP stack. Regards, Martin From pete at visionart.com Thu Sep 13 18:58:24 2001 From: pete at visionart.com (Pete Shinners) Date: Thu, 13 Sep 2001 15:58:24 -0700 Subject: Proposed PEP for a Conditional Expression References: Message-ID: <3BA13A10.8080108@visionart.com> >> if else > > But that appears to NOT scan like English. > "one if by land two if by sea" num_rings = 1 if enemy.onland() else 2 not the most graceful english, heh. and i suppose it works if they are nested.. num_rings = 1 if onland() else 2 if onsea() else 3 From aahz at panix.com Thu Sep 6 22:43:57 2001 From: aahz at panix.com (Aahz Maruch) Date: 6 Sep 2001 19:43:57 -0700 Subject: Performance of list comprehensions vs. map References: <3B966B1C.120D0AF6@home.net> <3B96C062.99E36B04@home.net> <3B97EB8D.D64CE8F0@home.net> Message-ID: <9n9c9d$cl1$1@panix2.panix.com> In article <3B97EB8D.D64CE8F0 at home.net>, Chris Barker wrote: >Skip Montanaro wrote: >> >> You're more than welcome to write a PEP. > >The reason I havn't is that I am in no position to impliment even a >prototype of the idea (both time and skills), and unless someone who is >in that position takes some interest, there really isn't any point. It >also may be a just plain bad idea, so I would like more feedback before >I went that far. Thanks for your input, I have certainly learned from >this discussion. You may want to bring this up on python-dev; most of the core developers (except for Tim) pay little attention to c.l.py these days. Also, the whole point of a PEP is to formalize the feedback process; you do *not* need to be in a position to implement it. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Plus ca change, plus c'est la meme chose." From on_the_net at clear.net.nz Wed Sep 5 16:37:11 2001 From: on_the_net at clear.net.nz (Rob Brown-Bayliss) Date: Thu, 06 Sep 2001 08:37:11 +1200 Subject: appropriate graphics Lib? References: Message-ID: <20010906.083658.1671294892.25599@clear.net.nz> In article , "Pete Shinners" wrote: > if you decide to go with pygame, i'd be glad to help out :] but don't > let that rule out pyopengl first, especially the higher level object > stuff that mike mentioned in an earlier post. Has anyone used pygame embeded in a pygnome window (prefer glade setup)? I am just starting on a project, and thought about useing the gnome canvas widget, but as the project evolves (it's not a game as such) the mixing of sound to the actions in the window could be useful. -- Rob Brown-Bayliss ---======o======--- From martin.franklin at westgeo.com Fri Sep 28 10:50:01 2001 From: martin.franklin at westgeo.com (Martin Franklin) Date: Fri, 28 Sep 2001 15:50:01 +0100 Subject: Problem with os.system() References: <3bb480af_1@news.newsgroups.com> Message-ID: <9p22io$5jbi$1@mail1.wg.waii.com> Terry Reedy wrote: > > "Janos Blazi" wrote in message > news:3bb480af_1 at news.newsgroups.com... >> I have the following code: >> >> prog=r'"C:\Programme\Windows Media Player\mplayer2"' >> f=r'c:\WINNT\Media\Microsoft Office 2000\APPLAUSE.WAV' >> os.system(prog+' /Play '+f) >> >> Now first it seems as though it worked and the wav file is played. > The >> problem is that after the wav file has ben played my program does > not regain >> the control i.e. the next statement is not executed. If I close the > Media >> Player window manually, my program resumes. I use Win2000 but my > program >> should work under MS-DOS. > > Your 'problem' is not with your Python program, but with mplayer not > closing itself by itself after playing one song. Perhaps there is a > command line option that would tell it to do so. Perhaps you should > find a wav-file player that behaves better for your purpose. I > believe that pygame may give you access to some such. > > Terry J. Reedy > > > You could also try winsound (part of the standard lib) import winsound fil='c:/WINNT/Media/Microsoft Office 2000/APPLAUSE.WAV' winsound.PlaySound (file, winsound. SND_FILENAME) From lunatic at beyond.net Fri Sep 14 17:59:24 2001 From: lunatic at beyond.net (LunaTic) Date: Fri, 14 Sep 2001 23:59:24 +0200 Subject: Namespace confusion References: <9nssgi$oiv$1@news.netcologne.de> Message-ID: <9ntukf$i0j$07$1@news.t-online.com> Thank you all for your insightful comments, in particular thanks to Martin von Loewis for his detailed explanations! Regards From stevena at neosynapse.net Thu Sep 20 04:07:03 2001 From: stevena at neosynapse.net (Steven D. Arnold) Date: Thu, 20 Sep 2001 04:07:03 -0400 Subject: problems with re in binary files Message-ID: <43103304954.20010920040703@neosynapse.net> Hi, I'm trying to parse a binary file using the re module. At one point I use '<<(.*)>>' with the r.DOTALL option. I expect this to find a '<<' string, find the last '>>' string in the string (which contains the whole document; it's small), and everything between would go in the group. However, in practice, re seems to stop well before the end of the string, and well before the last instance of '>>'. In other words, the group doesn't seem to contain everything it should. I'm manipulating a binary file (and therefore a string with 8-bit binary characters), so I thought perhaps the `.' was not matching the NULL character. So I changed the expression above to '<<((.|\000)*)>>'. My understanding is that this should match either the normal dot regular expression, or a literal zero (NULL) character, and this pattern would then be matched zero or more times. However, the behavior is basically the same. Anyone have any idea what I should do? I'm thinking of translating the whole string to hexadecimal, then converting any numbers less than or equal to 0x7F back to 7-bit ASCII, but that sounds like it'd be really slow. What am I missing? Is there a canonical way to handle this? ----------------------------------------------------- Steven D. Arnold stevena at nospam.neosynapse.net ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From garth_grimm at hp.com Thu Sep 13 15:32:00 2001 From: garth_grimm at hp.com (Garth Grimm) Date: Thu, 13 Sep 2001 12:32:00 -0700 Subject: unicode strings and such References: <3BA0CC8E.1050705@hp.com> <9nqmju02eu8@enews2.newsguy.com> Message-ID: <3BA109B0.2050809@hp.com> Slick. Thanks. Alex Martelli wrote: > "Garth Grimm" wrote in message > news:3BA0CC8E.1050705 at hp.com... > ... > >>encodings? Now that I think of it, I don't recall any file open methods >> > that took encoding > > The codecs standard module has that. > > > Alex > > > > From db3l at fitlinxx.com Mon Sep 3 20:21:11 2001 From: db3l at fitlinxx.com (David Bolen) Date: 03 Sep 2001 20:21:11 -0400 Subject: char** to {'':('',)} References: <9mocc301q7f@drn.newsguy.com> Message-ID: Grant Griffin writes: > I can't say I use them much, but I _am_ a big fan of the > "almost-goto" constructs like return, break, and continue. In > particular, I like to do early returns to avoid needless nesting. While I do use them at times, of the various control interruption constructs, early returns are probably the least preferable for me of the bunch, mostly because they increase the risk of missing some needed cleanup - either when initially written or later when maintained. They can also complicate the maintenance of code since there are many exits from a function complicating analysis. > Coincidentally, I thought I'd seen everything there was to see about > gotos until just yesterday, when I saw a new form that I had never > ever seen (or even thought of) before. It goes to this: > > bool foo() > { > bool flag = false; > for (;;) > { > if (x) > { > flag = true; > break; > } > > do_stuff; > > if (y) > { > flag = true; > break; > } > > do_more_stuff; > > break; > } > > return flag; > } > > whereas any sensible person would have done: > > bool foo() > { > if (x) > return true; > > do_stuff; > > if (y) > return true; > > do_more_stuff; > > return false; > } > > or maybe even used gotos . This construct occurred repeatedly > throughout the code. The author considered it to be a "feature". While using the loop construct instead of more straight-forward gotos is a little strange, I'm not sure it's worse (nor less "sensible") than the the multi-return format, which to my mind complicates maintenance down the road by having multiple exit points without a major benefit. I'd rather burn the flag variable and know that there was a consistent exit path that used that variable. -- -- 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 skip at pobox.com Mon Sep 3 10:47:29 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 3 Sep 2001 09:47:29 -0500 Subject: typechecks: just say no! (was Re: Determining Types) In-Reply-To: <3b938f31.2123170@nntp.sprynet.com> References: <9mvo0u04o8@enews2.newsguy.com> <3b938f31.2123170@nntp.sprynet.com> Message-ID: <15251.38913.163695.524974@localhost.localdomain> One place that I've actually found typechecking useful is at the boundary of my XML-RPC server. If I'm expecting a string input (say, the name of a band) and someone on the other side inputs "311" to a Perl-based website which then passes the query to my server, I get an integer that I have to coerce back to a string. In my comments I call it a "Perl guard". ;-) -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From garry at sage.att.com Mon Sep 10 15:55:12 2001 From: garry at sage.att.com (Garry Hodgson) Date: Mon, 10 Sep 2001 19:55:12 GMT Subject: [Edu-sig] assigning homework References: <9ne6ai$fqm$1@news.service.uci.edu> Message-ID: <3B9D1AA0.5D0C6773@sage.att.com> Danyel Fisher wrote: > > I've had good experiences with MOSS > (http://www.cs.berkeley.edu/~aiken/moss.html), although it takes a (gasp!) > Perl script to submit requests. In general, it seems to do a pretty good job > of picking out duplicate code. The times I used it, as a TA for a class of > several hundred, I was able to pull out a few unamiguous cases of > plagiarism. > > (Cheaters don't seem to be terribly subtle about it). snicker...i remember one night working at the help desk a few millennia ago, a member of our football team presented me with a listing and asked "if i wanted to make this look like i wrote it, what would i have to change?" he had zero clue what any of of the symbols on the page meant. it may as well have been written in klingon. i mumbled something unhelpful about different variable names, and he wandered off, no doubt wondering what a variable was. -- Garry Hodgson sometimes we ride on your horses Senior Hacker sometimes we walk alone Software Innovation Services sometimes the songs that we hear AT&T Labs are just songs of our own garry at sage.att.com From cgaston at moonqzie.com Fri Sep 14 05:37:41 2001 From: cgaston at moonqzie.com (Carlos Gaston Alvarez) Date: Fri, 14 Sep 2001 11:37:41 +0200 Subject: Python parsers that parse Java? Message-ID: <013101c13d00$e69d3000$a500a8c0@moonqzie> Hi Kevin, If you want to do it right you should not execute java source. OK, may be you can but if they call an api how will you handle it? Also you can insert parser bugs. What you should do is to execute the java program (its bytecodes) in a java virtual machine. You have two options. Number one is Jython www.jython.org which is python in java, it runs in a jvm and it intercases in a really easy way with java. Take a look and see if it works for you. If so it is the easiest and best way to do it. The second, but less recomendable is to instanciate a jvm from a C program (interfaced with java). Download the java jdk and you will see some source that lets you intancitate and call it from a C program. Chau, Gaston ----- Original Message ----- From: "Kevin Dahlhausen" Newsgroups: comp.lang.python To: Sent: Friday, September 14, 2001 2:36 AM Subject: Python parsers that parse Java? > Is there a readily availble parser written in Python that can parse > java code? I'm forced to use java for a project, and would like to > automate some code generation with Python. I don't have a lot of time > to devote to this, so something ready to go would be best. > > Thanks > -- > http://mail.python.org/mailman/listinfo/python-list > From michael at rcp.co.uk Fri Sep 7 03:43:26 2001 From: michael at rcp.co.uk (Michael Abbott) Date: Fri, 7 Sep 2001 07:43:26 +0000 (UTC) Subject: Recursion and Variable Scope References: Message-ID: mudpyr8 at yahoo.com (mudpyr8) wrote in news:d9f7d05e.0109061911.6bdcda3f at posting.google.com: > I'm writing a simple function. It is recursive. Here's the code: > > ########################## > def generate(sides, dice, roll): > if dice > 0: > for x in range(sides): > roll.append(x+1) > generate(sides, dice - 1, roll) > roll.pop() > else: > print roll > ########################## > > When calling it: generate(4, 2, []) > will generate output of 16 pairs of values, 1-4 each. However, I > cannot get that result stored in an object; I can only print it. > > The last line is the tricky part. Where it says # print roll # I > want it to do something like: # rolls.append(roll) # . > Unfortunately, creating a variable # rolls = [] # outside of the > function definition, and even stating # global rolls # on the > first line of the block doesn't seem to matter. > > I've tried to wrap my mind around this but am stuck. I need to perform > further manipulation on the results, but have no object with which to > do so. I know I could write to a file (maybe, if the file handle works > within the recursion) and then read it but that seems like a waste of > time. > > I hope I'm just missing something obvious. Please, any help would be > appreciated. > It would have helped if you'd been a bit more explicit about the problem you're seeing, but one answer is quite straightforward. If you replace "print roll" with global rolls rolls.append(roll) then the result you get is a list of empty lists, not quite what you had in mind, and at first somewhat unexpected. The problem is that when you append roll to the accummulating result list, it is still mutable, and you carry on working with roll in subsequent processing. You need, therefore, to put a *copy* of roll on the list. The following works: global rolls rolls.append(roll[:]) However, using a global like this isn't a good idea. You should look instead to get generate() to return the list you're after. Also note that this problem is nothing to do with variable scope: it is simply a consequence of the fact that roll is the same (mutable) list throughout. From loewis at informatik.hu-berlin.de Fri Sep 14 08:36:27 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 14 Sep 2001 14:36:27 +0200 Subject: no math module References: <3BA1F38E.ECD86D90@ncsa.uiuc.edu> Message-ID: Randy Heiland writes: > Can someone point me in the right direction? As the starting point, you should find out whether a math.so has been build by setup.py; it should live in build/lib. of the source tree. If yes, you'll have to find out whether it was properly installed, looks like a shared library (file(1), nm(1)), and lives in a location that is in sys.path. If not, re-run the build process to find out whether there are any errors reported when attempting to build math.so. Regards, Martin From mmhamze at pleiades.net Fri Sep 7 10:07:08 2001 From: mmhamze at pleiades.net (Maan M. Hamze) Date: Fri, 7 Sep 2001 09:07:08 -0500 Subject: Creating Excel files on Linux References: <3B97A39C.6A5234D7@olen.to> Message-ID: Cool it down guys. You take things so personal. When I say that the world speaks the XLS language I mean that is what your average Joe Blow and Jane Doe understand behind their desks in their offices. I did not not mean it as a computer programming language. However, on another front VBA as an overarching paradigm remains quite an achievement that actually works in windows. Maan "Oleg Broytmann" wrote in message news:mailman.999869469.17318.python-list at python.org... > On Fri, Sep 07, 2001 at 08:04:47AM -0500, Maan M. Hamze wrote: > > But the question is: Can Staroffice create XLS files? If not, then it is a > > major waste of time to create spreadsheets using Staroffice. It is a world > > that speaks the XLS language. > > If it is true, why are wasting your time with Python? It is a world that > speaks Java, Perl, PHP and C++. > > Thanks heavens you are completely wrong in this aspect. In my world > there is enough room for many different langauges and dialects. I pity you > if you live in such a narrow world. If you have any chance - go to a world > that allows more freedom! The world of Free Software!!! > > Oleg. > ---- > Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru > Programmers don't die, they just GOSUB without RETURN. > From ignacio at openservices.net Tue Sep 11 01:55:28 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Tue, 11 Sep 2001 01:55:28 -0400 (EDT) Subject: form - mail - smtp using Python 1.5. In-Reply-To: Message-ID: On Tue, 11 Sep 2001, Jerry Cashman wrote: > All the example code I've found appears to call a module called smtplib.py > which doesn't appear to exist in Python 1.5 Then your installation of Python is probably broken. Python 1.5.2 has it for certain. -- Ignacio Vazquez-Abrams From vdkamp at inter.nl.net Wed Sep 5 14:59:39 2001 From: vdkamp at inter.nl.net (Peter van der Kamp) Date: 05 Sep 2001 18:59:39 GMT Subject: Size of tuples Message-ID: Hello, Does anyone anyone know what the maximum size of a tuple can be? Examples in documentation only contains a small amount of data, but I like to know if they can contain e.g. >100000 integers. Furthermore I would like to know the consequences for performance. Does the 'x in tuple' statement perform much worse with the amounts of data I have in mind? Thanks. Peter van der Kamp From dsh8290 at rit.edu Sat Sep 15 20:32:41 2001 From: dsh8290 at rit.edu (dman) Date: Sat, 15 Sep 2001 20:32:41 -0400 Subject: [Tutor] SMTPLIB module - how to add subject ? In-Reply-To: <5FEF7E62AE5@kserver.org> References: <3BA3D9FE.30092.76C3D5@localhost> <5FEF7E62AE5@kserver.org> Message-ID: <20010915203241.B2641@hudson> On Sat, Sep 15, 2001 at 02:05:40PM -0700, Sheila King wrote: | On Sat, 15 Sep 2001 22:45:18 +0200, "A" wrote | about [Tutor] SMTPLIB module - how to add subject ?: | | :Hi, | :I tried | :11.11.2 SMTP Example from Python docs. | :Does anyone know how I can add subject to an email send by this example? | :Thank you very much for help | :Ladislav | | I've pasted the example below. Actually, I really dislike this example. | They are using | "\r\n" | as a character for newlines. Whose idea was that??? | It should be just | "\n" Well, in RFC2821 the SMTP protocol states that \r\n is used as the line delimiter. (RFC821 was the original SMTP definition but has been superceded by RFC2821) However, the Subject: of a message is part of the message itself which is defined by RFC822, but I haven't read that RFC. | I still don't like the "\r\n" in this example. Bad. :( See above -- the RFC actually states that being lenient and allowing \n as a line separator (mainly for Unix servers) is highly un-recommended (if I can make up that word). -D From logiplexsoftware at earthlink.net Mon Sep 10 16:09:36 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Mon, 10 Sep 2001 13:09:36 -0700 Subject: newbie: cannot import name error In-Reply-To: <3B9D11B9.D665D36A@engcorp.com> References: <3B9D11B9.D665D36A@engcorp.com> Message-ID: <01091013093602.10843@logiplex1.logiplex.net> On Monday 10 September 2001 12:17, Peter Hansen wrote: > David Bolen wrote: > Meanwhile, is it really the case that "extension" refers > exclusively to code not written in Python? If so, please > refer me to where the official definition has been made > so I can set my mind at ease. Semantically, you may be correct. However, for the sake of clarity, I think most people think of extensions as being written in C (probably because the process of integrating with C is referred to as "Extending and Embedding" in the documentation). -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From donn at u.washington.edu Tue Sep 4 13:04:59 2001 From: donn at u.washington.edu (Donn Cave) Date: 4 Sep 2001 17:04:59 GMT Subject: Conditional operator in Python? References: <9n1vir$chl$1@glue.ucr.edu> Message-ID: <9n31jr$16j0$1@nntp6.u.washington.edu> Quoth thp at cs.ucr.edu: ... | Okay, factorial is a somewhat simplistic example. Consider the | following function, which counts the k-way partitions of n: | | p = lambda k, n : ( | ( k < 1 or k > n ) and [0] or | ( n == 1 or n == k ) and [1] or | [p(k-1,n-1)+p(k,n-k)] | )[0] | | Using, say, ?: notation this would be written: | | p = lambda k, n : | k < 1 or k > n ? 0 : | n == 1 or n == k ? 1 : | p( k-1, n-1 ) + p (k, n-k ) | | which seems much more concise and readable. I am working intermittently on a modification to some code that was written in C by someone with a compulsion for syntax like that. I spent many hours on a trivial rewrite of a module of his like the one I want to write, just so I could read it. Though the second example may be more concise and readable than the first, it's much less readable than a normal procedural solution. The first on the other hand has the advantage that only the most obtuse author could argue that it's readable at all, while the second sort of legitimizes this kind of obfuscation in Python. Donn Cave, donn at u.washington.edu From loewis at informatik.hu-berlin.de Sun Sep 30 18:14:37 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 01 Oct 2001 00:14:37 +0200 Subject: How do Java interfaces translate to Python? References: Message-ID: Gordon Tyler writes: > My question is this: Java being my primary language, I'm very used to > using interfaces and I was wondering if there was an equivalent construct > or idiom in Python? How does one do in Python what one would do with > interfaces in Java? What exactly is it that you do with interfaces in Java? Regards, Martin From sholden at holdenweb.com Thu Sep 27 14:01:48 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 27 Sep 2001 14:01:48 -0400 Subject: Is Python fit for multi-tiEred apps? References: <9o7lvv$170$01$1@news.t-online.com><9oup0t$7tf$00$1@news.t-online.com> Message-ID: In distributed computing applications, the original architecture was client/server. Typically the client was the desktop machine, which handled the GUI and usually most of the process logic and some of the application logic. The client would communicate across the network to a server, which would handle the remainder of the application logic and all the data management tasks. Conceptually, applications therefore have four components: Presentation (user interface) logic Process logic Application logic ("business rules") Data Management Nowadays the logic can be distributed between more than two machines, so you might see the GUI running on the desktop along with the process logic, the business rules being enforced by a "middle tier" server, and the data management handled by an enterprise RDBMS. This is the "classic" three-tier structure. Another three-tier example is when a browser (presentation layer) is used to drive a web server (process logic, application logic) which transacts against an RDBMS (data management). The advantage of these architectures is that you can centralise or distribute the business rules as you see fit, but that you don't have to do what traditional C/S applications did, which was to include business rule handling on the desktop. This became a maintenance nightmare for large organizations with hundreds or thousands of desktops: when the business rules changed, new client software had to be rolled out to all the desktops. regards Steve -- http://www.holdenweb.com/ "Fran?ois Pinard" wrote in message news:mailman.1001606015.16060.python-list at python.org... > [Eike Kock] > > > [...] scaleable enterprise systems (multi-tiered [...] > > Hi. Would someone be kind enough for presenting to me what `tiered' means? > I never read that word, before the recent threads about it. What is it? > > -- > Fran?ois Pinard http://www.iro.umontreal.ca/~pinard > From jknapka at earthlink.net Wed Sep 5 12:13:29 2001 From: jknapka at earthlink.net (Joseph Andrew Knapka) Date: Wed, 05 Sep 2001 16:13:29 GMT Subject: deiconify is just plain f*ucked in windows References: Message-ID: <3B95FA1B.FE50AF5C@earthlink.net> gcash wrote: > I'd write it in tcl if I had an XML library for it. How about Cheers, -- # Joe Knapka # "You know how many remote castles there are along the # gorges? You can't MOVE for remote castles!" - Lu Tze re. Uberwald # Linux MM docs: http://home.earthlink.net/~jknapka/linux-mm/vmoutline.html From kseehof at neuralintegrator.com Thu Sep 27 19:35:00 2001 From: kseehof at neuralintegrator.com (Ken Seehof) Date: Thu, 27 Sep 2001 16:35:00 -0700 Subject: WeakValueDictionary References: <3BB11793.7040201@ActiveState.com> Message-ID: <004c01c147ad$08c30f40$239ab23f@kens> > Ken Seehof wrote: > > > >>> sys.version > > '2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit (Intel)]' > > >>> import weakref > > >>> d = weakref.WeakValueDictionary() > > >>> d['z'] > > Traceback (most recent call last): > > File "", line 1, in ? > > File "C:\PYTHON21\lib\weakref.py", line 35, in __getitem__ > > o = self.data.get(key)() > > TypeError: object of type 'None' is not callable > > > > Shouldn't this be raising KeyError instead of TypeError? > > Probably :) > > While we are at it, I would like to see the ability to have a weak-ref > to None - this would allow me to remove special casing for None in the > places I have used weakrefs to date. > > But-that-is-a-different-problem ly, > > Mark. Well here's how I got around the weak None thing: def NoneRef(): return None Then you can say x=NoneRef and x will act like a weak-ref to None. (yeah, I know return None is the same as pass, but I like being explicit) Whaddya-think-should-I-patent-it-ly yrs, - Ken From lud at sogetek.fr Wed Sep 5 10:04:26 2001 From: lud at sogetek.fr (lud) Date: Wed, 5 Sep 2001 16:04:26 +0200 Subject: a simple question for writtting module References: <9n59fk01upf@enews1.newsguy.com> Message-ID: i must do it, but don't be afraid, i writting this module for vxWorks and for a personnal use ! so i think that you probably never use it !! Thanks a lot for your quick answer !!! Ludo "Alex Martelli" a ?crit dans le message news: 9n59fk01upf at enews1.newsguy.com... > "lud" wrote in message > news:Hhpl7.530$mg1.11523 at tengri.easynet.fr... > > Hi !! > > > > my problem : > > > > first i write in python : > > import mymodule > > data="is a test" > > mymodule.show() > > > > ################### > > now in c : > > static PyObject * > > mymodule_show(PyObject * self, PyObject *args) > > { > > /*bla bla bla ....*/ > > } > > so i want get the value of data without transmit her in the call of the > > function show > > > > any idea ? > > Yes, several. > > The first and main one: don't do it -- it's silly. It's > counter-productive. It's unPythonic. It's the style of > programming that gives programming a bad name. > > The second one: if you MUST do it at any cost, look into > sys._getframe, the frame-objects type it returns, and > how from a frame-object you can get at your caller's > local and global variables -- this will let you do this > silliness pretty easily in Python, and the extra mile to > do it from C is really only 800 meters, as it's so easy > for C code to do the equivalent of "import sys", call > the _getframe function of module sys, and so on. > > At least, when you're done, you'll have learned a lot > about some of Python's internals and the use of them > from C extension code -- also, this will give you the > time to reflect on whether you really truly want to > do this at all, and hopefully reconsider:-). > > > Alex > > > From alberto at mindspring.com Sun Sep 2 20:49:00 2001 From: alberto at mindspring.com (Al Gonzalez) Date: Sun, 2 Sep 2001 20:49:00 -0400 Subject: calling __init__ more than once? References: <9muijb$47a46$1@ID-11957.news.dfncis.de> Message-ID: <9muk1q01o21@enews3.newsguy.com> There doesn't seem to be a reason why you can't. I prefer to move things into a method that can be called from multiple places including __init__. This keeps me from accidentally doing things again that I only want to happen when the class is created - such as gathering resources.. class myParser: def __init__(self): self._prepareEnvironment() def parse(self, fileName): self._prepareEnvironment() # do stuff with fileName def _prepareEnvironment(self): # utility method to clear up variables self._fileName = None self._buffer = [] "Emile van Sebille" wrote in message news:9muijb$47a46$1 at ID-11957.news.dfncis.de... > One thing you could try is to restructure slightly, passing the filename on > initialization: > > stuff1 = myParser(fileName1) > stuff1.parse() > stuff2 = myParser(fileName2) > stuff2.parse() > > HTH, > > -- > > Emile van Sebille > emile at fenx.com > > --------- > "Roy Smith" wrote in message > news:roy-5FC394.18555502092001 at news1.panix.com... > > I've got a file parsing class which in which I call a single parser object > > repeatedly to parse additional files. Something like: > > > > p = myParser() > > stuff1 = p.parse (fileName1) > > stuff2 = p.parse (fileName2) > > > > Is there any reason why my parse method couldn't call __init__() to reset > > things back to the start state? It feels kind of creepy, but I don't see > > any reason why it should be a problem. Is there something I'm missing > > here, or is it really OK to call __init__() again? > From ignacio at openservices.net Tue Sep 4 11:20:38 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Tue, 4 Sep 2001 11:20:38 -0400 (EDT) Subject: Hi, there In-Reply-To: <3B94EFD3.3360D44B@zumnet.com.br> Message-ID: On Tue, 4 Sep 2001, Rafael Mentz Aquino wrote: > Hi, everybody! I'm new on this list and a begginer with Python, > with special interests in Tkinter. > > I hope I can help and get help from here ;-) > > Let me start with a little problem...? > > I'm making an experience, but I can't put the result of an os.system > to a variable.... just the exit status.... > > How can I read the stdout to solve that..? > > Thanks already!!!! > > Rafael Mentz Aquino > Porto Alegre - Brazil Look at os.popen(). -- Ignacio Vazquez-Abrams From ignacio at openservices.net Sun Sep 16 23:37:39 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Sun, 16 Sep 2001 23:37:39 -0400 (EDT) Subject: SWIG: ImportError: dynamic module does not define init function In-Reply-To: <3BA56CB6.5786D4C2@northwestern.edu> Message-ID: On Sun, 16 Sep 2001, Louis Luangkesorn wrote: > I'm trying to run the example from the SWIG User's Guide (V 1.1 June 23, > 1997) When I try to load the example I get the following: > > PythonWin 2.1 (#15, Apr 19 2001, 10:28:27) [MSC 32 bit (Intel)] on > win32. > Portions Copyright 1994-2001 Mark Hammond (MarkH at ActiveState.com) - see > 'Help/About PythonWin' for further copyright information. > >>> import sys > >>> sys.path.append('c:\lluang\gmcode\cnumint\debug') > >>> import cnumint > Traceback (most recent call last): > File "", line 1, in ? > ImportError: dynamic module does not define init function (initcnumint) > >>> > > I've noticed on various mailing lists several people have asked this > same question, but I have not seen anyone respond to this. Is there > something I'm missing? Thanks. It's really quite simple. Your C code is missing the init() function which is responsible for actually setting up the module for use. Take a look at the modules that come with Python for examples on how it should be implemented. -- Ignacio Vazquez-Abrams From Gareth.McCaughan at pobox.com Tue Sep 11 18:56:06 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Tue, 11 Sep 2001 23:56:06 +0100 Subject: Proposed PEP for a Conditional Expression References: Message-ID: Terry Reedy wrote: [Christian Tanzer:] > > Conditional expressions provide some nice benefits totally > > unrelated to lambdas. > > One example: with a trivial class, one can put expressions into > > format directives, like > > "Found %(number)d error%(if number == 1 : '' else : 's')s" % trivial > > Python does not evaluate expressions inside strings and I do not > expect it ever will. class Trivial: def __getitem__(self, key): return eval(key, globals(), locals()) "foo %(1+2+3)s bar" % Trivial() ===> "foo 6 bar" Giving it access to the caller's local variables isn't quite so easy. -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From phr-n2001 at nightsong.com Tue Sep 25 12:08:10 2001 From: phr-n2001 at nightsong.com (Paul Rubin) Date: 25 Sep 2001 09:08:10 -0700 Subject: Proposal: add vector arithmetic to array module References: <7x3d5d2ca7.fsf_-_@ruckus.brouhaha.com> <3BAFA038.FB17C2D7@home.net> Message-ID: <7xzo7jqmmt.fsf@ruckus.brouhaha.com> Chris Barker writes: > > Please suppress the urge to reply "use NumPy". > > I'm sorry, but I can't suppress it. NumPy is so clearly what you want > here. No, NumPy is NOT what I want: 1) doesn't come with Python 2) not maintained by Python maintainers 3) Only handles floating point data, not integer. For example it doesn't provide vector boolean operations (I just remembered this-- so earlier when I said I'd use it if it was part of standard Python, I was in error). > > Numpy is a big package > > It's not that big. If it takes more than 1 minute to download over a modem, it's "big". It imposes extra hassle and delay on a user who wants to run an app that requires it. Anyway, NumPy is ridiculous overkill if all I want to be able to do is quickly xor two strings together, something like a = array.array('b', str1) array.xor(a, a, array.array('b', str2)) > > that's not part of standard Python > > It should be. That would make it mostly ok for what I'm doing, modulo the xor issue. > with a lot of PDF documentation > > Since when is lots of good documentation a BAD thing??????? Documentation good. PDF documentation bad. I see there's an HTML version of the docs on pfdubois' site (it's not in the Sourceforge site) but it's not clear where the doc sources are. Any idea? > > That makes it > > a lot harder to distribute applications to non-technical users. It's > > bad enough that they already have to install Python to run Python apps. > > Sort of. As you say, Python has to be installed, and the correct > version, and all that. Given that, many folks have chosen to use Py2exe > or McMillan's Istaller for distributing Python apps. with these tools, > youcan just give them NumPy along with the rest. Py2exe is a windows-only thing. What's McMillan's installer? Anyway if there's a way I can easily include NumPy with an application, then maybe it's ok. But it's bizarre to have to make multiple OS-specific distributions of an app written entirely in Python and that uses no complicated system calls. I think what's really needed is something like JAR files, for packaging Python apps. Maybe they could be called CAN files (snakes in a can) . There was some discussion of this earlier so maybe something will happen. > For that matter, there is something of a push to create a "batteries > and accessories included" approach to installing Python. ActiveState > has made a start of this with their distribution and pyppm. I have > started a project alnong these lines as well, but havn't gotten far > because no one else seems to think it's worth it. I still, do, but I > lost a lot of motivation. I thought "batteries included" was already supposed to be part of Python's philosophy, not something that there needed to be a push to create. > Which is easier: > > Adding a bunch of functionality to a standard module. > > Making a widely used, robust, and powerfull module standard. Generally, adding functionality to an existing module is easier. Especially when, as in the particular functionality we're discussing, it's not really "a bunch". I don't know if that's the answer you wanted . > Personally, I think we should go beyond making NumPy a standard module, > and make NumPy Arrays a built-in type. That sounds reasonable to me. From aleax at aleax.it Fri Sep 7 10:02:50 2001 From: aleax at aleax.it (Alex Martelli) Date: Fri, 7 Sep 2001 16:02:50 +0200 Subject: newbie: cannot import name error References: Message-ID: <9nak2a0t9n@enews1.newsguy.com> "rjberman at NOSPAMrodessaNOSPAM.com" wrote in message news:rb999869338 at rodessa.com... > I am brand new to Python, but have been writing Perl scripts for > the last 10 yrs. or so. I want to see how Python compares to Perl > and if it lives up to its hype. > > Anyway, I installed Python version "1.6a2 (#1, Jun 1 2000, 13:24:17) > [GCC 2.96 20000306 (experimental)] on sunos5" on Sparc Solaris 8. It Note that the version code indicates an *alpha* version (albeit alpha-2), as well as a pretty old version (1.6) which was NOT long-lived (it was a "contractual obligation" version the Python team had to do before changing employers) *and* an experimental C compiler too -- what an explosive mix! > It seems like the module distutils.core is found, just not the > name "Extension". Maybe the distutils didn't yet have Extension back in the time of 1.6 alpha 2. Wouldn't surprise me. > Can someone help me? I can't believe that on my second encounter > with Python I've already been stumped! This is not a good first > impression. Any help would be appreciated or even pointers to help! Do you generally try to gain a "first impression" of any software by installing an 18-months-old alpha release?-) I wouldn't be surprised to "be stumped" if I did that:). I would suggest you start by installing a solid, current, stable release, such as: http://aspn.activestate.com/ASPN/Downloads/ActivePython/Download?OS=Solaris& version=2.1.1&build=212&download=/ActivePython/solaris/2.1/ActivePython-2.1. 1-212.tar.gz Apparently, this ActivePython 2.1.1 release supports Solaris 2.6 -- I don't know if that may give problems with 2.8, as it's been a long time since I did Solaris. If the 2.8-vs-2.6 IS a problem, then build and install from the source release: http://prdownloads.sourceforge.net/python/Python-2.1.1.tgz (I would also suggest using a recent, stable C compiler, such as gcc 3.0.1, of course -- http://gcc.gnu.org/gcc-3.0/ -- but I guess the key thing is using the same C compiler to build Python as to build extensions, just in case any incompatibility in generated binaries or libraries used may have appeared between C compilers and/or versions). Alex From richard at bizarsoftware.com.au Mon Sep 10 20:25:40 2001 From: richard at bizarsoftware.com.au (Richard Jones) Date: Tue, 11 Sep 2001 10:25:40 +1000 Subject: idea: Robocode for Python - (redux :) In-Reply-To: References: Message-ID: <0109111025400Q.01597@ike> Anyone remember the python robots effort we had a few years ago? We had a mailing list and all called "bots-list" - I have no archives, and amk's archive is no longer either... I seem to recall that we all got busy with our Real Jobs at the time and never got back to it... Let's see... I think the most progress that came out of it was Greg Stein's code: http://www.pythonpros.com/gstein/war/ Greg also has a bunch of links for bot-stuff. It's probably really old (was updated in October, year unknown :) Haven't tested any of the links: http://www.pythonpros.com/gstein/bots.html John Eikenberry produced some code too (though his website has vanished): ftp://ftp.coe.uga.edu/users/jae/PyBots/ Toby Sargeant and I went several steps in another direction - we believed that "processor-level" control was the only way to go to have a level playing field, and we'd actually designed the basis of a new language with all sorts of bot-specific stuff in it like event handling with inheritance and other fun :) Richard From BrianQ at ActiveState.com Wed Sep 12 18:36:16 2001 From: BrianQ at ActiveState.com (Brian Quinlan) Date: Wed, 12 Sep 2001 15:36:16 -0700 Subject: Reading variable length records... In-Reply-To: <6957F6A694B49A4096F7CFD0D900042F27DBC2@admin56.narex.com> Message-ID: <002701c13bdb$562fbbd0$b503a8c0@activestate.ca> > I'm trying to read records from a 2 GB datafile, but my brain has > stopped working, so I was wondering if someone has allready > solved this problem. The records are variable length and are > separated by a five character delimiter. I was trying to use > file.read(n) with a blocksize of ~1Mb, but got a serious > brainfart when trying to think of how to handle the case where > only part of the delimiter was read in the current block. Here is some pseudo-code to get you started: data = '' records = [] while 1: readData = datafile.read(size) if not readData: break data += readData partialRecords = data.split('12345') records += partialRecords[:-1] # Last record is incomplete data = records[-1] if data: # Hmmm, there is still data left over, probably bad The basic idea is that you use split to collect as many records as possible and just keep the left-over partial record for the next round. Let me know if you need clarification. Cheers, Brian -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 2220 bytes Desc: not available URL: From ignacio at openservices.net Fri Sep 21 03:47:30 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Fri, 21 Sep 2001 03:47:30 -0400 (EDT) Subject: "shell-commands" and python! In-Reply-To: <9oeqks$8t0$1@zingo.tninet.se> Message-ID: On Fri, 21 Sep 2001, Mike S wrote: > how do I execute "shellcommands" in python??? > do I need to use the os module and the system command? Yes, or you could use popen*(). > Is there any simplier way to do it?? What, os.system('mycmd') isn't simple enough? Yeesh! Programmers these days... -- Ignacio Vazquez-Abrams From dale at riverhall.NOSPAMco.uk Mon Sep 17 15:30:40 2001 From: dale at riverhall.NOSPAMco.uk (Dale Strickland-Clark) Date: Mon, 17 Sep 2001 20:30:40 +0100 Subject: How to get a directory size with win32 api ? References: <85e27928.0109170448.693d122b@posting.google.com> Message-ID: francois-regis.chalaoux at sanofi-synthelabo.com (copter24) wrote: >Hi, > >How to get a directory size with win32 api ? >Any code exemple ? > >FR If you mean in terms of total kbytes occuplied, I don't think you can. You can, however, use the FileSystemObject COM object which is part of VBScript/JScript but I think can be used anywhere COM is accessible. >>> from win32com.client import Dispatch >>> fso = Dispatch("Scripting.FileSystemObject") >>> fldr = fso.GetFolder("C:\\WINNT") >>> fldr.Size 892129383 >>> If you mean in terms of number of files, os.listdir() will probably do the job. -- Dale Strickland-Clark Riverhall Systems Ltd From russomf at hotmail.com Thu Sep 13 12:20:47 2001 From: russomf at hotmail.com (Mark) Date: 13 Sep 2001 09:20:47 -0700 Subject: Commercial Web Hosting w/ Python CGI Scripts? Message-ID: Does anyone know of a commercial web hosting firm that supports CGI scripting using Python? I'd be interested in any flavor, such as mod-python, Zope, etc. Thanks. From loewis at informatik.hu-berlin.de Tue Sep 25 08:46:31 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 25 Sep 2001 14:46:31 +0200 Subject: dismantling code objects References: <998474b8.0109240713.6070692e@posting.google.com> Message-ID: dean.hall at computer.org (Dean Hall) writes: > I'd appreciate any feedback on the doc (I consider it a rough draft > and won't be offended by constructive criticism). I find your text well-written, and I'd encourage you to keep it up-to-date (e.g. Python 2.2 will add a few byte codes). I think the type setting could use some improvements, e.g. the figure numbers are never printed, and the tables with empty fields look ugly (e.g. opcodes 93,94). I'd spend a few more words on marshal, so that the reader atleast gets an idea of what it does - you may leave out the information of how exactly it does that(*). Regards, Martin (*) Of course, there would be a value in elaborating the format of marshal (and thus .pyc files) as well - I believe it would be the first documentation of this kind. From skip at pobox.com Thu Sep 27 12:42:22 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 27 Sep 2001 11:42:22 -0500 Subject: Is xmlrpclib slow? In-Reply-To: <20010927154054.A2999@aeka.lysator.liu.se> References: <9ov48m$eao$1@tyfon.itea.ntnu.no> <20010927154054.A2999@aeka.lysator.liu.se> Message-ID: <15283.22254.460275.660829@beluga.mojam.com> Kalle> [Magnus Lie Hetland about xmlrpclib] >> Is it just the machine I'm using that's really slow, or is the >> xmlrpclib module a big bottleneck here? Kalle> Skip Montanaro about performance problems with xmlrpclib: Kalle> http://groups.google.com/groups?threadm=mailman.1001257584.1441.python-list%40python.org&rnum=1 I'm still working on that problem. I've stabilized everything I can so far. My next step will be to try upgrading kernels on the slower machine. Magnus, your problem may just be that you are using a pure Python XML parser. I use Fredrik Lundh's sgmlop parser which xmlrpclib will use automatically if it's available. I suspect there are other ways to speed up XML parsing as well. The other thing to note is that xmlrpclib 1.0b3 (what is delivered with 2.1.1 I think) seems to be much slower than xmlrpclib 0.9.8. If I modify sys.path to force import of one or the other, the dump speed changes markedly: % python testxmlrpc.py testing with xmlrpclib 0.9.8 using FastParser 410 dumps per second 106 loads per second % PYTHONPATH=/home/skip/misc/python/python2 python testxmlrpc.py testing with xmlrpclib 1.0b3 using SgmlopParser 229 dumps per second 94 loads per second SgmlopParser under 1.0b3 is the same as FastParser under 0.9.8. There's another parser available from Pythonware for 1.0b3 that is now called FastParser. Presumably it's faster or more robust than the SgmlopParser. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From skip at pobox.com Sat Sep 29 00:57:22 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 28 Sep 2001 23:57:22 -0500 Subject: Off-topic: hiding your email address - don't bother... Message-ID: <15285.21682.353195.729661@beluga.mojam.com> (My apologies for the off-topic post. Python-list at python.org is the only large mailing list/newsgroup I read with any regularity, so this subject is only germane to me in this context.) More and more people are resorting to various schemes to try and hide their email addresses from email address harvesters. It's frustrating to me to get mail bounces when I reply to posts and forget to un-doctor your email address. I think it's a fruitless exercise for a few reasons: * If I reply-to-all to a message of yours I will get an address like skipNO at SPAMmojam.com in the To: or CC: headers. If I notice it and remove "NO" and "SPAM", I've just screwed you, because your email address is now going to show up in mailing list archives or Usenet headers. If I don't notice, I get a bounce. No great loss perhaps, though I'm a bit frustrated because my response to perhaps your request won't reach you, and you might miss the response to your message when skimming c.l.py (or have it expire when you're out of town on a business trip). What are the chances that I will realize I should move your email address to the BCC field? Slim, at best. If I remember to do all the right things, what about Alex or Guido, one of the Tims or one of the bots? * Your email address probably appears in plenty of other places accessible to the harvesters, including: your personal or corporate websites, friends' or associates' websites, your soccer club website, the archives of this and other mailing lists or newsgroups (none of the hypermail/pipermail/etc archives use particularly complex schemes to hide addresses and once upon a time you posted messages *without* doctoring your email address), SourceForge, or source code you wrote that happens to be available on the net. * Other people have probably given it out. That might be your dimwitted ISP who thinks that filthy lucre from a direct marketing company is more valuable than your good will, or the guy in the next cubicle who just CC'd you on a post to alt.binaries.britney-spears. Try though you might, you probably still get lots of spam. They find you, no matter what. Case in point. I switched ISPs from MediaOne Express to AT&T @Home just a couple weeks ago (because the latter bought the former). I had to select a user id and I wound up with an email address quite a bit unlike anything else I had ever had before. I didn't care, because I didn't intend to ever use it. *I* certainly never publicized it. Lo and behold, during a service call a few days ago the tech said I should check my @Home email once in awhile because they use it to communicate with their customers. I checked and found a "welcome to @Home" message and two spams. I bet you know the conclusion of this missive: Don't bother trying to protect your email address. Resistance is futile. If you want to filter out spam, find a service you like that filters email (like SpamCop or your ISP), learn how to use procmail, or learn to write sendmail milters in Python or get Jason Mastaler's TMDA system that works with QMail (there - I snuck in *two* Python code references into my message so it's not off-topic!). In short, do something that stands a real chance of helping. Doctoring up your email address isn't going to cut it. You're just sticking your head in the sand... NsOk-iSpP at ApMo-bLoYx .Yc'oRmS, -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From brian at sweetapp.com Sat Sep 15 15:51:20 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Sat, 15 Sep 2001 12:51:20 -0700 Subject: Python is better than free (was Re: GNU wars again) In-Reply-To: <3BBF2751.3010309@sneakemail.com> Message-ID: <005201c13e1f$cb1824f0$445d4540@Dell2> > and-if-it's-good-enough-for-Moses-it's-good-enough-for-Tim-Peters- - Bite your tongue! What has Moses done for me lately? From loewis at informatik.hu-berlin.de Thu Sep 27 10:28:17 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 27 Sep 2001 16:28:17 +0200 Subject: Does there exist a Python-to-Perl translator ? References: <3BB2D226.3C260A2C@Spam.Please> Message-ID: Weet Vanniks writes: > This would help me produce Perl code after developing it in Python. There are the beginning of a Python-to-Parrot (aka Perl 6?) compiler. See the recent posting of Andrew for details: http://mail.python.org/pipermail/python-dev/2001-September/017617.html Regards, Martin From sheila at spamcop.net Mon Sep 17 23:43:16 2001 From: sheila at spamcop.net (Sheila King) Date: Tue, 18 Sep 2001 03:43:16 GMT Subject: Converting Strings to UPPERCASE ? References: <3ba6bd0e@news.iprimus.com.au> Message-ID: <9o5n78.3vv2gu5.1@kserver.org> On Tue, 18 Sep 2001 13:15:58 +1000, "Peter Moscatt" wrote in comp.lang.python in article <3ba6bd0e at news.iprimus.com.au>: :I am having difficulty in converting a string to Upercase - how is this best :achieved ?? mystring = 'cat' mystring = mystring.upper() print mystring The above will work in Python 2.0+ If you are using an older version: import sting mystring = 'cat' mystring = string.upper(mystring) print mystring The above will work in all version of Python since 1.5 at least (and probably before that, too, but you shouldn't be running anything older than that). -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From grahamd at dscpl.com.au Fri Sep 21 20:34:05 2001 From: grahamd at dscpl.com.au (Graham Dumpleton) Date: 21 Sep 2001 17:34:05 -0700 Subject: Python interface for MOM? (No, not the family-friendly person ...) References: Message-ID: wrote in message news:... > Hi > > Anyone know of a python interface to IBM's MQSeries - or any > message-oriented middleware? Depending on what aspects of MOM you are interested in, you might want to look at OSE. http://ose.sourceforge.net It doesn't have persistent message queues or transactions, but does support message oriented request/reply and publish/subscribe functionality. Check out the python manual on the web site. From zope at thewebsons.com Thu Sep 6 20:55:56 2001 From: zope at thewebsons.com (Ben Ocean) Date: Thu, 06 Sep 2001 17:55:56 -0700 Subject: Upgrading Message-ID: <5.0.2.1.0.20010906175256.00a03e80@thewebsons.com> Hi; I get this error message when I try to upgrade to 2-2.1.13 with an rpm on RH62: error: failed dependencies: libcrypto.so.1 is needed by python2-2.1.1-3 libexpat.so.0 is needed by python2-2.1.1-3 libgmp.so.3 is needed by python2-2.1.1-3 libncurses.so.5 is needed by python2-2.1.1-3 libpanel.so.5 is needed by python2-2.1.1-3 libreadline.so.4.1 is needed by python2-2.1.1-3 libssl.so.1 is needed by python2-2.1.1-3 I'm surprised there's any problem at all, which makes me a little worried. Before I chase all of these files down (and suggestions about where to find them would be nice), I'm equally concerned about going on a mad goose chase looking for the files *these* files might need. Any ideas? TIA, BenO From mcfletch at home.com Tue Sep 25 13:26:03 2001 From: mcfletch at home.com (Mike C. Fletcher) Date: Tue, 25 Sep 2001 13:26:03 -0400 Subject: Proposal: add vector arithmetic to array module In-Reply-To: <7xelovql5y.fsf@ruckus.brouhaha.com> Message-ID: <003201c145e7$288a51c0$0202a8c0@MikeySpace> Py2Exe and the McMillan installer both do exactly that (package python scripts as exes with all dependencies). BTW: I think ActiveState Python is Win32, Linux and Solaris Numeric is becoming a very widely used module, so if there is something going into the core, it would be my vote. However, I'd still like to see a better mechanism for distributing extensions (e.g. auto-downloading signed packages from a Zope server somewhere) so that the list of "included" modules can _shrink_, rather than grow. But then everyone wants that, Mike -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Paul Rubin Sent: September 25, 2001 12:40 To: python-list at python.org Subject: Re: Proposal: add vector arithmetic to array module ... > BTW, MacPython includes Numeric, and it is part of the extended module > support of ActiveState Python, so it's really not hard for your users to > download. What if they're not using Macintoshes? Actually, if we're discussing OS-specific distributions, it would be good to be able to distribute Windows apps WITHOUT needing the user to install Python. That is, I'd like to release a single .exe that includes my .pyc files, the Python interpreter core, and the minimal set of libraries needed to make my app run. Is that feasible with the stuff you're describing? I'm a near-total Windows ignoramus. -- http://mail.python.org/mailman/listinfo/python-list From maxm at normik.dk Fri Sep 14 10:29:38 2001 From: maxm at normik.dk (maxm) Date: Fri, 14 Sep 2001 16:29:38 +0200 Subject: Proposed PEP for a Conditional Expression References: <6qvgire4bk.fsf@abnoba.intevation.de> <9nidrm01j7q@enews1.newsguy.com> <23891c90.0109130146.60a98909@posting.google.com> Message-ID: <3ba21452$0$51376$edfadb0f@dspool01.news.tele.dk> > In Python, one can use the following instead in this case: > > outputString = otherString or "" > > Personally, I find complicated uses of ?: difficult to scan and > understand rapidly, contrary to spurious arguments about its supposed > similarity to English language constructs. Besides ... what could be simpler than using the fact that booleans in Python is either 1 or 0: ################################# >>> a=3 >>> b=4 >>> print ('number two', 'number one')[a < b] >>> number one or if you want to get the result of a functionwith only the choosen function evaluated: ################################# >>> def n1(): >>> return 'Number one' >>> def n2(): >>> return 'Number two' >>> print (n2, n1)[a < b]() >>> Number one Any sane Python programmer will grasp those IMMEDIATELY! ;-) Regards Max M From richard at bizarsoftware.com.au Mon Sep 10 00:48:34 2001 From: richard at bizarsoftware.com.au (Richard Jones) Date: Mon, 10 Sep 2001 14:48:34 +1000 Subject: Python by RPM -> bad idea? In-Reply-To: <3b9c40dc_1@news.nwlink.com> References: <3b9c40dc_1@news.nwlink.com> Message-ID: <0109101448050G.01597@ike> On Monday 10 September 2001 14:33, Paul wrote: > I'm having problems, and I think they stem from my installing Python > originally through the use of an RPM. > > By using an RPM, I get not /config directory with a Makefile, which sounds > reasonable enough, as I didn't compile anything. You probably need to install a python-devel RPM. I generally work only from RPM on linux (Mandrake) and have had no problems whatsoever. Richard From nas at python.ca Wed Sep 19 12:41:02 2001 From: nas at python.ca (Neil Schemenauer) Date: Wed, 19 Sep 2001 09:41:02 -0700 Subject: Code Coverage support for unittest? In-Reply-To: <3BA8BCD1.3060700@destiny.com>; from mcherm@destiny.com on Wed, Sep 19, 2001 at 10:42:09AM -0500 References: <3BA8BCD1.3060700@destiny.com> Message-ID: <20010919094102.A21427@glacier.arctrix.com> Michael Chermside wrote: > I was reading this: > > http://www.amk.ca/python/writing/mx-architecture/#SECTION000800000000000000000 > > and the author referred to using a modified version of Skip Montanaro's > trace.py to get CODE COVERAGE reporting for unit tests written using the > unittest module. > > Really? How? I must have missed this in the docs! It sounds great... > does anyone know the details, or where (if at all) it's documented? The unittest included with Quixote is not that same as the one released with 2.1. Neil From mlh at idi.ntnu.no Thu Sep 27 03:09:50 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Thu, 27 Sep 2001 09:09:50 +0200 Subject: The status of xmllib Message-ID: <9oujbu$4pp$1@tyfon.itea.ntnu.no> What exactly does the following statement from the documentation (section 13.12, xmllib) mean? Deprecated since release 2.0. Use xml.sax instead. I understand that it encourages people not to use xmllib, and to use xml.sax... But does it mean that xmllib will be phased out in the long run? In that case, is a pure-Python plug-in for xml.sax planned? If xmllib is here to stay (although not as good as the xml package), perhaps deprecated is a bit strong? Or am I just being nervous about it? And, if no pure-Python handler for xml.sax (or xml.anything) exists -- would a submitted module stand a chance of being included? (Not that I have one, but if it would be used, I might write one...) - Magnus (who wants an xml package which doesn't strain the poor users with compiling and installing expat) -- Magnus Lie Hetland http://www.hetland.org "Reality is that which, when you stop believing in it, doesn't go away." -- Philip K. Dick From cgale1 at _remove_home.com Mon Sep 10 08:05:37 2001 From: cgale1 at _remove_home.com (Van Gale) Date: Mon, 10 Sep 2001 12:05:37 GMT Subject: .NET and Python References: <9nettc$ce1$1@slb7.atl.mindspring.net> <8nMm7.133116$n75.31959718@news4.rdc1.on.home.com> <9ni0fi0vq0@enews1.newsguy.com> Message-ID: "Alex Martelli" wrote in message news:9ni0fi0vq0 at enews1.newsguy.com... > "Van Gale" wrote in message > news:g7%m7.226487$%a.8840828 at news1.rdc1.sdca.home.com... > ... > > > I've looked into .NET and I hate to admit it, MS is > > > become more right lately. > > > > Microsoft marketing literature and hype has *always* been right. For the > > I disagree: I find Microsoft's marketing abysmal in its field. One Yeah, I didn't really express that well :) I was really trying to say something like with .NET, Microsoft is doing a good job of seeming right. That doesn't mean they actually are right (at this point). From rnd at onego.ru Thu Sep 27 09:41:21 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 27 Sep 2001 17:41:21 +0400 (MSD) Subject: What happened to Python for BeOS? Message-ID: Can't find Python for BeOS any more... Any ideas? Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From hcj.goudsmit at wanadoo.nl Tue Sep 4 06:20:27 2001 From: hcj.goudsmit at wanadoo.nl (jeroen paul goudsmit) Date: Tue, 04 Sep 2001 10:20:27 GMT Subject: how do i make a grapical thingie? References: Message-ID: Ok. Python is instal;led in : C:\Python22. The name of the executable is = C:\Python22\python.exe. The dll files are in the map C:\Python22\DLLs. The tkinter file is C:\Python22\DLLs\_tkinter.pyd. "Maan Hamze" schreef in bericht news:HQOk7.217122$g_3.41849242 at typhoon.austin.rr.com... > Tim > The guy had not even answered on how he has Python installed to start with. > To recommend Jython for him at this stage along with the use of AWT or swing > is an overkill :) > Maan > > "Delaney, Timothy" wrote in message > news:mailman.999478982.9172.python-list at python.org... > > I suspect the simplest thing here would be to use Jython and AWT or Swing. > > > > http://www.jython.org > > > > Probably the easiest way for a beginner to get a GUI up and running in > > Python. Once they have a bit more experience they can move onto other > > things. > > > > Tim Delaney > > > > From gh_pythonlist at gmx.de Sun Sep 30 01:56:40 2001 From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Sun, 30 Sep 2001 07:56:40 +0200 Subject: Error keeps coming up In-Reply-To: <9p6ba8$8qf$1@ins22.netins.net>; from rwhite@netins.net on Sun, Sep 30, 2001 at 12:41:54AM -0500 References: <9p6ba8$8qf$1@ins22.netins.net> Message-ID: <20010930075639.C1967@lilith.hqd-internal> On Sun, Sep 30, 2001 at 12:41:54AM -0500, Ron White wrote: > I installed 2.1.1 Python on a win me machine and when I run a program that > has an error (like a syntax error) I continue to get that same error even > when I try to run another program. How do I get rid of the first program > so it's error doesn't keep coming up? Sounds very strange and unlikely. Can you send us the sources of the two programs? And also how you invoked them. Double-clicking from Explorer or how you invoked them from the commandline. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 240 bytes Desc: not available URL: From mmhamze at pleiades.net Sun Sep 2 10:03:25 2001 From: mmhamze at pleiades.net (Maan Hamze) Date: Sun, 02 Sep 2001 14:03:25 GMT Subject: COM MakePy utility in PythonWin References: <3b91e631.1383281@news.t-online.de> Message-ID: "Gerson Kurz" wrote in message news:3b91e631.1383281 at news.t-online.de... > On Sun, 02 Sep 2001 05:09:43 GMT, "Maan Hamze" > wrote: > >2. I have a povray modelling program that offers a COM interface. I was > >able to connect to it through Hammond's Python win32com. But the interface > >itself is not listed in the COM browser in PythonWin. I looked for it in > >the registry and found it and tried it in PythonWin and it worked. I am > >just wondering why the object did not appear in the COM Broswer? > > - do you implement IDispatch ? COM alone (eg. IUnknown + custom > derived interface) isn't enough to be usable in Python (or VB). > I just went by the default installation of the povray program (Breeze Designer). It implements the COM object Breeze.Scene which is in the registry but does not appear in the COM browser. I tired it with: >>> import win32com.client >>> scene=win32com.client.Dispatch("Breeze.Scene") and it worked. I was able to control the program. > - Do you have the .tlb properly registered ? > No it is not (Breeze20.tlb) and it would not register. I contacted the developer of Breeze about this and about other issues connected with running Python also in Breeze internal macro engine that allows for Python ActiveScripting. Maan > From grante at visi.com Mon Sep 24 11:47:05 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 24 Sep 2001 15:47:05 GMT Subject: Outlook COM access warning dialog? Message-ID: In an (IMO futile) effort to plug one of the many gaping security holes designed into MS produts, BOFH has installed an Outlook security update. Now anytime a Python program uses Outlook's COM interface, a warning dialog pops up that has to be clicked on 3 times to make it go away and allow the COM access. Does anybody know how to disable that warning? -- Grant Edwards grante Yow! -- I can do at ANYTHING... I can visi.com even... SHOPLIFT!! From aahz at panix.com Thu Sep 6 14:54:12 2001 From: aahz at panix.com (Aahz Maruch) Date: 6 Sep 2001 11:54:12 -0700 Subject: Generators and exceptions (was Re: Stackless Python and Python 2.x) References: Message-ID: <9n8gok$mum$1@panix2.panix.com> In article , Tim Peters wrote: >[Aahz] >> >> The part I don't understand (though if I had access to 2.2a2, I could >> probably test it easily enough) is what happens when you re-enter a >> generator and trigger an exception (an exception that isn't >> StopIteration, for any smartasses out there). > >Nothing special: the exception is caught by the frame or not, and if not >propagates out of the frame. Generators do nothing special at all here, and >since they always return to their immediate invoker, there are no debatable >issues about *which* frame *to* propagate an uncaught exception (general >coroutines are muddier in this respect, and general continuations even >worse). Okay, I've re-read PEP 255, and I'm still not clear on what happens with the following code: def a(): yield 1 raise "foo" yield 2 return def b(): return a() g = b() g.next() g.next() (If I've messed up the syntax, please feel free to correct it before answering; I *think* my intent is clear enough.) -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Plus ca change, plus c'est la meme chose." From rnd at onego.ru Sun Sep 16 08:36:16 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 16 Sep 2001 16:36:16 +0400 (MSD) Subject: Flatfile update? In-Reply-To: <20010916.125521.1909002904.11525@mailandnews.com> Message-ID: On Sun, 16 Sep 2001, pwgk wrote: >Hi, >I am trying to find out if it is possible to open a flat (ascii) file for >update in python, so I can change it's contents directly, without having >to copy the entire contents. It depends on the format of flat file. If you have fixed length lines, you can change text file inplace using positioning by seek() method. (But open file as binary for that, if your platfrom distinguishes text/binary file modes). >Is this possible, and if yes, does anyone know how? >Or do I have to start digging into MySQL for that? It depends on what you want to achieve. If your application has 1-2-3 flatfile dbs and there is no relational db readily running, flat files are fine. (I could dare to say, they are much more secure than say MySQL.) However, if you envision that your system will grow, you are better off with RDBMS as soon in the development, as possible, or you will end with numerous flat files scattered accross your system. If you want simultaneous write access, consider locking file (or record of file) you are accessing. (look at the fcntl module) >Regards >Paul Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Sunday, September 16, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Phobia: what's left after drinking 2 out of a 6 pack" _/ From slinkp23 at yahoo.com Tue Sep 18 23:23:12 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Wed, 19 Sep 2001 03:23:12 GMT Subject: LoD questions References: <3BA7B1B2.E8874ED5@accessforall.nl> Message-ID: On Tue, 18 Sep 2001 21:42:46 +0100, Ype Kingma wrote: >When you find yourself writing foo.bar.bat a lot of times in the >methods of the class of foo, it >is reasonable to consider foo.bar.bat a "close friend" of foo, >so you introduce: > foo.bat = foo.bar.bat >at an appropriate place, possibly in the __init__() method. >This is more concise, and more efficient. >It also reduces the need for get_bar_bat_baz() methods considerably. Hmm, yes, I've been overlooking that. Looks like it might be a useful technique in some parts of my current project. Thanks! --PW From nospam at bigfoot.com Thu Sep 27 13:06:10 2001 From: nospam at bigfoot.com (Gillou) Date: Thu, 27 Sep 2001 19:06:10 +0200 Subject: Is xmlrpclib slow? References: <9ov48m$eao$1@tyfon.itea.ntnu.no> Message-ID: <9ovlv0$1aaq$1@norfair.nerim.net> Its strongly recommanded to install "sgmlop" as indicated in the comments of xmlrpclib.py. # # Notes: # this version uses the sgmlop XML parser, if installed. this is # typically 10-15x faster than using Python's standard XML parser. # # you can get the sgmlop distribution from: # # http://www.pythonware.com/madscientist Hope the future xmlrpclib will use the new PyXML package in place of the _nearly deprecated_ xmllib. --Gillou From jdhunter at nitace.bsd.uchicago.edu Mon Sep 10 12:50:32 2001 From: jdhunter at nitace.bsd.uchicago.edu (John Hunter) Date: 10 Sep 2001 11:50:32 -0500 Subject: CrossProductSweeper References: <1rn1439eux.fsf@video.bsd.uchicago.edu> Message-ID: <1rheub9ehz.fsf@video.bsd.uchicago.edu> Oops: there was as indentation problem in one of the examples in the docs above. The 'just finished y' example should read: for x in (1,2,3,4): for y in (5,6): for z in (7,8,9,10): pars = (x,y,z) print 'Just finished y' Not: for x in (1,2,3,4): for y in (5,6): for z in (7,8,9,10): pars = (x,y,z) print 'Just finished y' JDH From nas at python.ca Fri Sep 21 16:46:15 2001 From: nas at python.ca (Neil Schemenauer) Date: Fri, 21 Sep 2001 13:46:15 -0700 Subject: mkstemp vs. tmpnam , tempnam In-Reply-To: ; from zptang@hotmail.com on Fri, Sep 21, 2001 at 01:21:22PM -0700 References: Message-ID: <20010921134615.A25437@glacier.arctrix.com> Janet wrote: > I am running it on Linux, Mandrake 8.0. Both tmpnam and tempnam are > considered unsafe. Is there a patch for this problem or I can just > modified the Modules/posixmodule.c to use msktemp instead? Don't worry about it. Python doesn't use those functions unless you do. If you're really paranoid you could remove those functions from posixmodule. Neil From skip at pobox.com Thu Sep 27 19:51:01 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 27 Sep 2001 18:51:01 -0500 Subject: scanf style parsing In-Reply-To: References: <3BB16A50.BAE082FE@cygnus-software.com> <3BB2C7DA.F63EEAA7@cygnus-software.com> Message-ID: <15283.47973.96356.551360@beluga.mojam.com> >> maybe-the-best-argument-against-vi-ly, yr's Tim> This I don't understand. Where was the argument against vi? I guess you didn't see the implied smiley. Skip From slhath at home.com Tue Sep 25 22:05:59 2001 From: slhath at home.com (Scott Hathaway) Date: Wed, 26 Sep 2001 02:05:59 GMT Subject: Win32 / IIS: Creating virtual directories References: <3bb0393d.87609896@news.mch.sni.de> Message-ID: Look at many sample scripts in the inetpub\AdminScripts directory under IIS. Scott "Nikolai Kirsebom" wrote in message news:3bb0393d.87609896 at news.mch.sni.de... > I have IIS running on NT 4 - where I have some ASP pages with Python > code. The whole thing had to be reinstalled lately because of Nimda. > The process of reinstalling everything (virtual web-servers, > ftp-account, users, user-groups) is a tedious task - so now I would > like to make some scripts to make it easier next time (hopefully > never) I have to do the job again. I'll use the win32net module for > manageing users / groups. However, does anyone know where I can find > information / hint on how to programatically configure IIS (both web > and ftp part) including creating virtual directories. > > Thanks for any help > Nikolai Kirsebom > From nas at python.ca Mon Sep 24 16:42:22 2001 From: nas at python.ca (Neil Schemenauer) Date: Mon, 24 Sep 2001 13:42:22 -0700 Subject: Simple process IO capture (Was: "shell-commands" and python!) - process.py (0/1) In-Reply-To: <4u4vqts8urqfa5n6t2ih3n38il5fm5ats3@4ax.com>; from gustav@morpheus.demon.co.uk on Mon, Sep 24, 2001 at 09:14:42PM +0100 References: <4u4vqts8urqfa5n6t2ih3n38il5fm5ats3@4ax.com> Message-ID: <20010924134222.A1597@glacier.arctrix.com> Here's my humble attempt at a popen replacement. Note that it doesn't use the shell (a feature IMHO) and it only works on Unix systems. Suggestions for the module name are welcome. I would like to get something like this in the standard library. Neil ########################################################################### # child_process.py ########################################################################### import os # created 2001/09/04, nas class _ChildProcess: """ Instance attributes: pid : int the process id of the child process stdin : file open file connected to file descriptor 0 of the child process stdout : file open file connected to file descriptor 1 of the child process stderr : file open file connected to file descriptor 2 of the child process """ MAXFD = 256 def __init__(self, argv, bufsize=-1): child_stdin, stdin = os.pipe() stdout, child_stdout = os.pipe() stderr, child_stderr = os.pipe() self.stdin = os.fdopen(stdin, 'w', bufsize) self.stdout = os.fdopen(stdout, 'r', bufsize) self.stderr = os.fdopen(stderr, 'r', bufsize) self.pid = os.fork() if self.pid == 0: os.dup2(child_stdin, 0) os.dup2(child_stdout, 1) os.dup2(child_stderr, 2) for i in range(3, self.MAXFD): try: os.close(i) except: pass try: os.execvp(argv[0], argv) finally: os._exit(1) os.close(child_stdin) os.close(child_stdout) os.close(child_stderr) def read(self, n=-1): """Read from child stdout""" return self.stdout.read(n) def readline(self): """Readline from child stdout""" return self.stdout.readline() def readlines(self): """Readlines from child stdout""" return self.stdout.readlines() def write(self, s): """Write data to child stdin""" self.stdin.write(s) def flush(self): """Flush stdin pipe to child""" self.stdin.flush() def close(self): """Close stdin, stdout and stderr pipes to child process. Wait for the exit status of the child and return it.""" for fd in (self.stdin, self.stdout, self.stderr): if not fd.closed: fd.close() status = self.wait() if status == 0: return None # matches behavior of popen(...).close() else: return status def wait(self, flags=0): pid, status = os.waitpid(self.pid, flags) return status def execute(argv, bufsize=-1): r"""execute(argv : (string*), bufsize=-1) -> _ChildProcess Create a child process with pipes connected to its stdout, stdin and stderr file descriptors. The child is created using fork() and execvp() in order to avoid the argument quoting problems presented by using system() or popen(). The bufsize argument has the same meaning as for the open() builtin and applies to stdin, stdout, and stderr. Examples: >>> p = execute(("ls", "/")) >>> p.readline() 'bin\n' >>> p.readline() 'boot\n' >>> p.close() >>> >>> p = execute(("cat",)) >>> p.write("hello world\n") >>> p.stdin.close() >>> p.read() 'hello world\n' >>> p.close() >>> """ return _ChildProcess(argv, bufsize) From comments at cygnus-software.com Thu Sep 27 22:39:47 2001 From: comments at cygnus-software.com (Bruce Dawson) Date: Fri, 28 Sep 2001 02:39:47 GMT Subject: scanf style parsing References: <3BB16A50.BAE082FE@cygnus-software.com> <8351bb33.0109270648.75af3371@posting.google.com> Message-ID: <3BB3E270.8D10F86B@cygnus-software.com> And a good thing to - otherwise the scanf/regexp job would be a bit more complicated. Jon Nicoll wrote: > trivial followup: isn't it ... amazing ... the number of programs > which still have this kind of output? > > > > > > > smtpmail.exe - 0 error(s), 0 warning(s) > ___ ___ > > jon N From ignacio at openservices.net Wed Sep 19 15:11:59 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Wed, 19 Sep 2001 15:11:59 -0400 (EDT) Subject: SWIG: MSVC++ [LINK : fatal error LNK1104: cannot open file "python21_d.lib"] In-Reply-To: <3BA8E9CE.638D69D5@northwestern.edu> Message-ID: On Wed, 19 Sep 2001, Louis Luangkesorn wrote: > I searched my Python installation and I don't see a 'python21_d.lib' file > anywhere. I've already located the 'python21.lib' as a required library. > Where should "python21_d.lib" be located, or is this something I need to > download/write? Thanks. The _d library should only be required if you're doing a debug build. If you change to a release build you should be fine. -- Ignacio Vazquez-Abrams From des.small at bristol.ac.uk Thu Sep 13 10:21:48 2001 From: des.small at bristol.ac.uk (Des Small) Date: Thu, 13 Sep 2001 14:21:48 GMT Subject: time module error. Message-ID: Yow! I want to have a time class, with instances I can add to in hours. Rather than reinvent the wheel, I want to use the standard time module, but as the transcript below shows, I have trouble. ==========8<============================================== Python 2.1 (#1, May 3 2001, 12:58:02) [GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-81)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import time >>> t = time.strptime( '2',"%H") >>> t (1900, 1, 0, 2, 0, 0, 6, 1, 0) >>> time.mktime(t) Traceback (most recent call last): File "", line 1, in ? OverflowError: mktime argument out of range ===========8<============================================== Now, I can easily enough convert hours to seconds in my own code, but I don't understand why the above fails. Any pointers? Des. -- Dr Des Small, Scientific Programmer, School of Mathematics, University of Bristol, Tel: 0117 9287984 From ralph at inputplus.demon.co.uk Mon Sep 10 06:41:30 2001 From: ralph at inputplus.demon.co.uk (Ralph Corderoy) Date: 10 Sep 2001 11:41:30 +0100 Subject: How come tuples don't have an index method? References: Message-ID: <9ni5cq$90v$1@inputplus.demon.co.uk> Hi Tim, > > Would be nice to be consistent, espcecially within a single > > module. > > It's unusually common in the operator module: countOf, indexOf, > isCallable, isMappingType, isNumberType, isSequenceType, > sequenceIncludes. It's very much a minority in the operator module, and for two of those... isCallable deprecated since 2.0, use callable instead sequenceIncludes deprecated since 2.0, use contains instead (contains added by Guido) > > getitem isn't getItem so why not countof? > > If you really believe there's an objective reason, and that you can > convince the author they were wrong, feel encouraged to find the > author via CVS and engage them in productive debate . CVS only goes back to 2.1? From that it looks like Guido did most of it with Fred Drake making minor changes more recently. But I can't tell if many hands were involved before 2.1 leading to the mixture of naming styles. http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/Modules/operator.c Consistency is a nice attribute to have. Not just in naming conventions but also the interface a module presents. Is effort needed to improve the standard library so it's more consistent? If so, would that be welcomed? Ralph. From cb921 at voice.co.za Tue Sep 25 04:47:13 2001 From: cb921 at voice.co.za (Campbell) Date: Tue, 25 Sep 2001 10:47:13 +0200 Subject: exposing #defines in an extension module Message-ID: Hi, I am trying (without SWIG which is a very nice program) to create an extension module working on xxmodule.c from the distribution. All my functions are groovy, and now I have several thousand lines of #define .... to deal with. I've thought of setting them using Object_setattr(), and I've thought of just setting them in the .py which will wrap this module. But is there any commonly used mechanism to get them in automatically? There really is an astonishing (to me) amount of them. Thanks again, Campbell From brianmce at crosswinds.net Wed Sep 12 10:54:11 2001 From: brianmce at crosswinds.net (Brian McErlean) Date: 12 Sep 2001 07:54:11 -0700 Subject: Some ideas for Pymacs References: Message-ID: <6e0ad3b1.0109120654.421332a5@posting.google.com> pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) wrote in message news:... > Hi, people. > > > I guess the most important improvement we could think to Pymacs would > be some machinery by which Python programs, started outside Emacs, could > access Pymacs, once it started. That could be useful at least for testing > or debugging, and maybe for more serious work as well. These are mere > thoughts, I do not plan working at this soon, unless I have an actual need. > But if the challenge interests someone, please go ahead! This would raise the almost blasphemous possibility of driving Vim (with python scripting) in emacs. I'm not sure if that's possible without the universe exploding in a storm of antimatter - but the idea does have a certain appeal :-) > Here is how it could go. Pymacs has a Python interpreter running as a > sub-process of Emacs. In fact, Emacs loads `pymacs.el', which in turn > gets Python to execute `pymacs.py', and both communicate afterwards. > `pymacs.py' is only active whenever `pymacs.el' calls it, otherwise it > is blocked. `pymacs.py' could, under some option, start another thread > within itself. The initial thread would block waiting for Emacs, as usual. > The second thread would block waiting to serve any Python client wanting to > access Emacs. When this occurs, the second thread would queue a request > for the first thread, and then send a signal to Emacs so it triggers a > Pymacs communication. At each communication opportunity, the first thread > on the Python side might fully service the queue from the second thread. > I think this should be possible, but some of the details may be very tricky. Probably the trickiest part is signalling emacs to deal with pending python requests - this could maybe be done with a timeout, or some kind of external signal, but in either case there needs to be a check that you are not in the middle of processing other requests! This could be a very cool feature though - remotely drive emacs using python. -- Brian McErlean From aahz at panix.com Thu Sep 6 20:35:20 2001 From: aahz at panix.com (Aahz Maruch) Date: 6 Sep 2001 17:35:20 -0700 Subject: Editing a file 'In Place' References: <3b97ed74.472037594@news.demon.co.uk> Message-ID: <9n94o8$pb3$1@panix2.panix.com> In article <3b97ed74.472037594 at news.demon.co.uk>, Simon Foster wrote: > >I'm trying to write a simple piece of code to perform some batch edits >on a text file. So far I have: import fileinput -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Plus ca change, plus c'est la meme chose." From loewis at informatik.hu-berlin.de Fri Sep 21 11:44:21 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 21 Sep 2001 17:44:21 +0200 Subject: validating xml parser? References: Message-ID: "Narayan Desai" writes: > Hi. I have been looking for a validating XML parser for python that > includes schema support. It looks like there is a xerces based parser > module. It seems to support schemas. Can parser backends be > coerced into looking like either sax or dom, or will a module only be > implimented for one? Usually, you'd create a parser module that offers a SAX parser only; it can then be used to build DOM trees. If the parser has its own DOM implementation, you could also expose that - but that's quite some work to wrap all the classes. > I have found a number of validating parsers that implement at least > SAX support, but I would really like to use one that does dom as > well. Is there some comprehensive documentation I should be reading > someplace? I can find specific examples, but no generic info about > how the whole subsystem works... Not sure what "the whole subsystem" is. If you have a SAX parser, and you want to create a DOM tree, you can use pulldom to create a minidom tree, and xml.dom.ext.reader.Sax2 to create a 4DOM tree. Regards, Martin From armin.samide at avl.com Thu Sep 6 06:57:01 2001 From: armin.samide at avl.com (Armin Samide) Date: 6 Sep 2001 03:57:01 -0700 Subject: PyRun_SimpleFile ? Message-ID: <21691e22.0109060257.6237bfec@posting.google.com> Hi, i'am trying to start a python file out of c++ program by PyRun_SimpleFile(). Looks like this: #include #include "Python.h" void main (int argc, char **argv) { Py_Initialize (); FILE *fp = fopen ("test.py", "r+"); FILE *foxfile = fopen ("gltest.py", "r+"); PyRun_SimpleFile (fp, "test.py"); PyRun_SimpleFile (foxfile, "gltest.py"); Py_Exit(0); } The file test.py is executed without problem ( simply contains one print statement ) but the file gltest makes use of the fox - python binding. If i start the file gltest.py from the command line ( python gltest.py ) everything is fine but out of that program i get: Traceback (most recent call last): File "gltest.py", line 3, in ? from FXPy.fox import * File "E:\Programme\Python21\FXPy\__init__.py", line 4, in ? from fox import setErrorObject File "E:\Programme\Python21\FXPy\fox.py", line 2, in ? import foxc ImportError: No module named foxc Do I have to set up something extra, but the other file ( fox.py, __init__.py ) are found and foxc.pyd also exists. Is it possible to staticly include the fox part in thew python interpreter and can you give me some tipps who to do that ? thank a lot, armin From aaronf at NOSPAMtelusplanet.net Sun Sep 23 22:12:18 2001 From: aaronf at NOSPAMtelusplanet.net (Aaron Fransen) Date: Mon, 24 Sep 2001 02:12:18 GMT Subject: New Python WebMail app References: <9oc646$dmd$1@serv1.iunet.it> Message-ID: <6Ewr7.17203$9j.3347364@news1.telusplanet.net> I don't see any restriction on the src attribute itself, but what I should probably investigate is the "designmode" attribute that IE uses for IFRAME. This is the attribute that can turn an IFRAME window into an edit region. "Alex Martelli" wrote in message news:9oc646$dmd$1 at serv1.iunet.it... > > See: http://www.w3.org/TR/REC-html40/present/frames.html#edef-IFRAME > Do you see any constraints there on what can go to the src attribute > of an iframe...? > > > Alex From heikowu at ceosg.de Thu Sep 20 18:23:19 2001 From: heikowu at ceosg.de (Heiko Wundram) Date: Fri, 21 Sep 2001 00:23:19 +0200 Subject: How to do * and & C-lang. operations in Python? In-Reply-To: References: Message-ID: <01092100225700.00319@phoenix> On Thursday 20 September 2001 19:00, you wrote: > On 20 Sep 2001, Toni Gaya wrote: > > Assignaments are done by 'value', not by 'reference'. Function calls > > are done by 'reference'. How to do assignaments by reference?. In C > > Check Google Groups for the answer. > > > Another question: > > > > module1: > > import module2 > > > > module2: > > import module1 This shouldn't work, as cyclic imports can't be resolved at runtime (at least in my projects it always failed...)! Just put the import module2 at the end of module1 (when you run/import module1 from an external program as the first item). What this does is that all code in module1 has already been parsed when module2 is imported, which imports back module1, which has already been parsed, and Python doesn't complain anymore. If you do any kind of cyclic imports, be sure to check this, as it gives rise to all kinds of quirky errors that may actually seem like resulting from somewhere else. And be sure to obey the order! Code Example: module1: import module2 module2: import module1 mainprog: import module1 import module2 -- Yours sincerely, Heiko Wundram From info at djslim.com Sun Sep 2 02:18:32 2001 From: info at djslim.com (Seung Chan Lim) Date: Sun, 2 Sep 2001 02:18:32 -0400 Subject: pyDox 0.5a - first Alpha release References: Message-ID: <000b01c13377$1b828d30$0e1dc997@djslim> pyDox v0.5a Download URL: http://www.djslim.com/djslim3/files/pyDox.tar.gz What is it? Using the inspect module it grabs all the information needed from a python module and generates an XML-based documentation. The enclosed XSL and CSS file can transforms the XML file into an XHTML document for viewing. Requirements: Should run under python 1.5.2 and above assuming that the inspect module works under it License: LGPL Contact: dev at djslim.com slim From boyd at insultant.net Tue Sep 25 00:11:21 2001 From: boyd at insultant.net (Boyd Roberts) Date: Tue, 25 Sep 2001 06:11:21 +0200 Subject: Best way to learn Python? References: <_qir7.7082$Ck.1324782@news6-win.server.ntlworld.com> <20010923182907.28933.00000349@mb-cl.aol.com> Message-ID: <9op0b6$d9i$1@quark.noos.net> read, write, learn, loop. From aleax at aleax.it Mon Sep 3 07:21:10 2001 From: aleax at aleax.it (Alex Martelli) Date: Mon, 3 Sep 2001 13:21:10 +0200 Subject: COM/CORBA/DCOP (was: Hello people. I have some questions) References: <7xsne7en0r.fsf@ruckus.brouhaha.com> Message-ID: <9mvp3505rt@enews2.newsguy.com> "Paul Rubin" wrote in message news:7xsne7en0r.fsf at ruckus.brouhaha.com... > Bruce Sass writes: ... > > I'm hoping Alex M. gets his Linux systems setup soon and starts > > delving into the matter. > > Yes, that will be interesting. Alex M. has determined he needs a *solid*, _minimalistic_ router/firewall/proxy setup first, and so he has (for the moment) turned to OpenBSD, where he's reveling in the sheer purity of implementing a light-maintenance-load, *secure*, high-performance firewall-etc setup on a Pentium-90, 64-MB, 2GB-disk, 2-ISA-NIC's found lying around in a dustbin somewhere (the only concession to featuritis being, obviously, a Python 2 installation!-). A.M.'s expected to be back to the features-rich, GUI-rich, Athlon-1.33GHz-at-a-minimum world of Windows-XYZ, Linux Mandrake/RedHat/SUSE, etc, reasonably soon (don't be surprised if XPCOM is what he ends up exploring in that realm, though:-). But, boy, the *joys* of ipf and ipnat versus IPTables (and let's not even mention ipchains, ipfwadm, etc, nor, of course, the utter lack of any such indispensable tools as part of Win32 protocol stacks!-)... Alex From chrishbarker at home.net Mon Sep 17 16:03:52 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 17 Sep 2001 13:03:52 -0700 Subject: Mac python and Carbon References: Message-ID: <3BA65728.C5C8FC8F@home.net> Richard Jones wrote: > Just curious about where Carbon stands in the Grand Scheme of Mac Python. > > Ideally, I'd love to see it available to "regular" python (not the special > one distributed as MacPython) just like other GUIs. That allowing it to then > be available to anygui, which in turn allows us to develop kick-ass > cross-platform win32/mfc and osx/carbon applications with ease :) > > Pipe dream? Nope. I'm pretty sure Jack is planning on merging MacPython and Unix Python on OS-X, so that the Mac stuff will just be extra modules... he's making a lot of progress, check out the MacPython mailing list for more info. Personally, I think AnyGUI is a pipe dream anyway... Why you would want a wrapper around a wrapper around a wrapper around a tool kit is beyond me: AnyGUI->wxPython->wxWindows->Win32|GTK|Carbon All you are going to get is a more limited subset of GUI functionality, and probably worse performance. I really don't see the point. I you want a more Pythonic, cleaner interface for GUI programming, I do see the point, but targeting ALL GUI toolkits seems like a difficult and limiting idea. I would love to see a thicker wrapper around wxWindows, for instance (wxWindows because it has the broadest support for various platforms, including macOS and OS-X). The PythonCard project seems to be making a nice start on this. A Native Python GUI would be even better, but that is a monsterous project. Anyway, clearly the AnyGUI contirbuters do think it's a good idea, so maybe once it reaches some maturity, I will see the point. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From junkster at rochester.rr.com Thu Sep 13 05:49:36 2001 From: junkster at rochester.rr.com (Benjamin Schollnick) Date: Thu, 13 Sep 2001 09:49:36 GMT Subject: McMillan Installer or Py2Exe? References: <270c68fe.0109051808.600a9a82@posting.google.com> Message-ID: In article , David Bolen wrote: > web.mail at lycos.com (Alan Green) writes: > > > We've used the McMillan Installer very successfully, but we're just > > starting a new project and there also seems to be quite a buzz around > > py2exe. > > > > Has anybody experience of both the McMillan Installer and Py2Exe and > > care to comment on their relative strengths? > > My suggestion is to grab each, and then try to use it for the > application in question. My impression has been that they are both > very functional, but that sometimes one does better than the other for > a particular scenario, or that they sometimes leapfrog each other in > handling strange and interesting import cases. > > For my personal use, I've tried each and have stuck with installer, > since it's always worked for me, and on my last attempt at a > comparison it built an application of mine without any problems while > I had difficulties with py2exe. But others on this group have > reported exactly the opposite results, and it's not much effort to > give each a shot, so getting direct experience may be the best. > > And if one seems more complicated or less understandable to you than > the other, that's another metric for your own comparison :-) I've got to vote for Gordon's Installer... As people have said, try both and see what results you end up with.... But as I've said, Gordon's package can look intimidating due to all the customizable features but 90-95% of the time, you'll never need to touch them. - Benjamin From garth_grimm at hp.com Thu Sep 13 15:46:50 2001 From: garth_grimm at hp.com (Garth Grimm) Date: Thu, 13 Sep 2001 12:46:50 -0700 Subject: unicode strings and such References: Message-ID: <3BA10D2A.30503@hp.com> Ignacio Vazquez-Abrams wrote: >>Any idea of what the str() is actually doing here? If I remove the str() statements from the >>following code, I get different resuts (i.e. no substitutions will take place in qt). So either >>pattern and patch (after the assignment at the beginning of the loop) aren't actually string >>objects, or str() is doing something more than the API docs state -- "For strings, this returns the >>string itself." >> > > I still can't read the UTF-8 properly. Do the following and show me what your > results are: > > --- > >>>>a='?f~?f??f--' >>>>a >>>> > '\xe3f~\xe3f\xab\xe3f--' > >>>>str(a) >>>> > '\xe3f~\xe3f\xab\xe3f--' > >>>>unicode(str(a), 'utf-8') >>>> > Traceback (most recent call last): > File "", line 1, in ? > UnicodeError: UTF-8 decoding error: invalid data > > --- Not sure if any of this will be helpful. In both cases, I'm cutting and pasting from a Unicode text editor. With an NT console command line, I get... Python 2.0.1 (#18, Jun 22 2001, 02:26:03) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> a='(???)(\d{3})' >>> a '(???)(\\d{3})' >>> str(a) '(???)(\\d{3})' >>> unicode(str(a), 'utf-8') u'(???)(\\d{3})' Using IDLE 0.6, the characters from the cut-n-paste to initialize a look perfect (still Japanese glyphs), but when I hit ENTER, I get the following dump... >>> Exception in Tkinter callback Traceback (most recent call last): File "e:\python20\lib\lib-tk\Tkinter.py", line 1287, in __call__ return apply(self.func, args) File "E:\PYTHON20\Tools\idle\PyShell.py", line 579, in enter_callback self.runit() File "E:\PYTHON20\Tools\idle\PyShell.py", line 598, in runit more = self.interp.runsource(line) File "E:\PYTHON20\Tools\idle\PyShell.py", line 183, in runsource return InteractiveInterpreter.runsource(self, source, filename) File "e:\python20\lib\code.py", line 61, in runsource code = compile_command(source, filename, symbol) File "e:\python20\lib\codeop.py", line 61, in compile_command code = compile(source, filename, symbol) UnicodeError: ASCII encoding error: ordinal not in range(128) a='(???)(\d{3})' Garth From thp at cs.ucr.edu Fri Sep 14 13:39:14 2001 From: thp at cs.ucr.edu (thp at cs.ucr.edu) Date: Fri, 14 Sep 2001 17:39:14 +0000 (UTC) Subject: Proposed PEP for a Conditional Expression References: <3BA13A10.8080108@visionart.com> Message-ID: <9ntfc2$347$1@glue.ucr.edu> Pete Shinners wrote: :>> if else :> :> But that appears to NOT scan like English. :> "one if by land two if by sea" : num_rings = 1 if enemy.onland() else 2 : not the most graceful english, heh. and i suppose : it works if they are nested.. : num_rings = 1 if onland() else 2 if onsea() else 3 To fully reflect the "one if by land, two if by sea" construct of English, we need to adopt the implicit "else None" idea. Then 1 if by_land() else 2 if by_sea() means 1 if by_land() else 2 if by_sea() else None which is what the corresponding english means. Tom Payne From kdahlhaus at yahoo.com Fri Sep 14 09:32:53 2001 From: kdahlhaus at yahoo.com (Kevin Dahlhausen) Date: 14 Sep 2001 06:32:53 -0700 Subject: Python parsers that parse Java? References: Message-ID: <283adf56.0109140532.24a76e08@posting.google.com> Thanks, but I think there was a misunderstanding. I want to parse a java file with a python module, not to execute it, but to reformat and add some member functions (maybe javadoc too), then spit the java source back out. The end goal is to do things like add get/setters from Vim based on a list of attibutes. BTW - as of tonight I'll be away from the net for a week or so, so I won't be replying to anything. From rnd at onego.ru Tue Sep 4 13:48:13 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 4 Sep 2001 21:48:13 +0400 (MSD) Subject: Question regarding commenting code In-Reply-To: <682EFA0F37A1D511868700B0D0D1AB7A31BBDD@ISTECH4> Message-ID: On Tue, 4 Sep 2001, Andrew Gould wrote: >When adding comments to scripts, can I insert lines of comments inside a >loop block? For example: > >for n in a_list: ># separate values using spaces as delimiters > a_line = string.split(n) ># get the first value > a_value = a_line[0] ># print the first value > print a_value This is not good. Look at http://www.python.org/doc/essays/styleguide.html IIRC, it has a discussion of good comment style. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, September 04, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Useless Invention: Fine glass-crystal castanets." _/ From johngrayson at home.com Tue Sep 4 12:25:03 2001 From: johngrayson at home.com (johngrayson at home.com) Date: Tue, 04 Sep 2001 16:25:03 -0000 Subject: python GUI without windowhandle Message-ID: <9n2v8v+5v6l@eGroups.com> If you're using Tkinter, then set the overrideredirect flag... e.g. shell = Tkinter.Toplevel(root) ....... shell.overrideredirect(1) ....... John From timr at probo.com Wed Sep 19 01:54:06 2001 From: timr at probo.com (Tim Roberts) Date: Tue, 18 Sep 2001 22:54:06 -0700 Subject: How to sort a list? NOT a newbie question. References: <9o4i4h$2ql@ascc.artsci.wustl.edu> Message-ID: <4jcgqtsvc9dc7or96alisr6rhcv776qhd1@4ax.com> mjbarber at ascc.artsci.wustl.edu (Michael James Barber) wrote: >All in Python 2.1.1: > >>>> l1 = [1, '1j', [1,'1j']] >>>> l1.sort() >>>> print l1 >[1, [1, '1j'], '1j'] > >>>> l2 = [1, 1j, [1,'1j']] >>>> l2.sort() >Traceback (most recent call last): > File "", line 1, in ? >TypeError: cannot compare complex numbers using <, <=, >, >= > > >This came up in the context of building the coefficients of polynomials >from a list of roots. If complex roots occur in complex conjugate pairs, >then the resulting coefficients must be real, so I decided to cast the >coefficients to floats in this case. A straightforward test is to take >the complex conjugate of each element of the list, then sort both lists >and see if they are the same. As is clear from the above, that definitely >didn't work! You can make this work if you can answer a couple of simple questions. Which is greater: 3 or 3j? Put these numbers in order: 3+0j 1+1j 1+2j 2+1j 2+2j 1+0j 0+3j -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From peter at engcorp.com Fri Sep 28 23:28:52 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 28 Sep 2001 23:28:52 -0400 Subject: return command in a function. References: <9oudgb0vnk@enews2.newsguy.com> <9ov418$gs8$1@neon.noos.net> Message-ID: <3BB53FF4.764BA8C6@engcorp.com> Duncan Booth wrote: > > My rule of thumb for using return is that it is alright at or near the top > of a function, and it is alright at or near the bottom of the function, and > anywhere else the function is too long and should be split up anyway. It's always nice to see a clear definition of something one has been doing instinctively without a clue why and without even realizing (until now) that one has been doing it! :-) Thanks... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From timhoffman at cams.wa.gov.au Tue Sep 4 03:53:15 2001 From: timhoffman at cams.wa.gov.au (Tim) Date: 4 Sep 2001 00:53:15 -0700 Subject: Strangeness with basic math Message-ID: <1f3e18d3.0109032353.422b97ed@posting.google.com> Hi I have been racking my brains trying to RTFM to explain the following bash-2.03$ python Python 2.1 (#1, Jul 3 2001, 10:26:19) [GCC 2.95.2 19991024 (release)] on sunos5 Type "copyright", "credits" or "license" for more information. >>> 1923.23 + 17023.34 18946.57 >>> 1923.23 - 17023.34 -15100.110000000001 >>> print 1923.23 - 17023.34 -15100.11 >>> Why when I do 1923.23 - 17023.34 am I getting -15100.110000000001 on NT I get the same thing. Under Python 1.5.2 I get the same and result as the print 1923.23 - 17023.34 (ie -15100.11) Regards Tim From vesselinpeev at hotmail.com Sun Sep 16 09:17:08 2001 From: vesselinpeev at hotmail.com (Vesselin Peev) Date: Sun, 16 Sep 2001 16:17:08 +0300 Subject: Python errors messages in Windows Message-ID: Dear Colleagues, Does anyone know about a straightforward way of capturing the Python error messages in a Windows application embedding Python? That is, is there are version of PyErr_Print not using stdout? Thank you in advance for your consideration. _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp From rnd at onego.ru Fri Sep 14 15:52:02 2001 From: rnd at onego.ru (Roman Suzi) Date: Fri, 14 Sep 2001 23:52:02 +0400 (MSD) Subject: What's wrong with my script? In-Reply-To: <9nti6o$g96$06$1@news.t-online.com> Message-ID: On Fri, 14 Sep 2001, Michael Landmann wrote: >Hi, I wrote this script and saved it as index.cgi, but it doesn't work. Oh, yes, have you done chmod a+x index.cgi ? Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Friday, September 14, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "URA Redneck if you own a homemade fur coat." _/ From peter at engcorp.com Thu Sep 20 09:15:41 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 20 Sep 2001 09:15:41 -0400 Subject: bsddb3 vs zodb References: <3BA9A72A.1D5A6067@yahoo.com> Message-ID: <3BA9EBFD.3F7ABFFA@engcorp.com> vincent delft wrote: > > does any one as analyze the pro and cons (functionalities, performances, > ...) between Berkley DB3 (bsddb3) and ZODB ? Isn't DB3 a relational database? Since ZODB is clearly not, we're going to end up just comparing the "pros and cons" of relational versus object-oriented databases, I think. In any case, you should specify what your requirements are before asking for such a comparison. Without an idea what the context is (what is your particular application area?) the answers will be largely meaningless. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From unknown at lee-morgan.net Fri Sep 28 00:18:02 2001 From: unknown at lee-morgan.net (Lee Morgan) Date: Fri, 28 Sep 2001 04:18:02 GMT Subject: Why so few Python jobs? References: <9oltnk$vv3$1@nntp9.atl.mindspring.net> Message-ID: "Warren Postma" writes: > > Any ideas on why so few Python jobs are available? > > In my job, I use Python, but it is because I know Python and felt it was > the best tool for the job. But seldom is it the "defining" characteristic > of a position. In particular, my job calls for C/C++ skills. I have ported > python to embedded system platforms we use, and so my job is more entitled > "Embedded C/C++ Developer" than "Python Developer". > My position is similar, with python being a good 'glue' language, you're often gluing! -- Lee Morgan From double_letter at room33.com Thu Sep 6 00:01:08 2001 From: double_letter at room33.com (A.A) Date: Thu, 06 Sep 2001 08:01:08 +0400 Subject: Python Install-Installed Python 2 on top of python 1.5 Message-ID: <3B96F504.1416D109@room33.com> Hello, I installed an rpm of Python 2.1.1, by right-clicking on it, and clicking upgrade. But my python1.5 installation still exists. And If I try to uninstallpython 1.5 from the RPM Manager, it raises an error saying, dependency problems with so-and-so programs. IS there a way to unistall Python 1.5 cleanly ?? Thanks, Best Regards, Ahsan From phd at phd.pp.ru Mon Sep 3 04:41:17 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Mon, 3 Sep 2001 12:41:17 +0400 (MSD) Subject: Something like Perl's -c flag? In-Reply-To: <9mrnod$p4k$1@tyfon.itea.ntnu.no> Message-ID: Hi! On Sun, 2 Sep 2001, Magnus Lie Hetland wrote: MLH> "Oleg Broytmann" wrote in message MLH> news:mailman.999326826.29300.python-list at python.org... MLH> > On 31 Aug 2001, Mark Atwood wrote: MLH> > MA> Does the Python interpreter have anything like Perl's -c flag, which MLH> > MA> does a static syntax and sanity check without actually running the MLH> > MA> script? MLH> > MLH> > Just compile the script. Like this: MLH> > MLH> > import sys MLH> > from py_compile import compile MLH> > MLH> > if len(sys.argv) <= 1: MLH> > sys.exit(1) MLH> > MLH> > for file in sys.argv[1:]: MLH> > compile(file) MLH> MLH> You could also use pythonc, of course. What is "pythonc"? The only pythonc I know is PythonC - current CPython implementation. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From phd at phd.pp.ru Wed Sep 26 15:36:26 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 26 Sep 2001 23:36:26 +0400 Subject: pyc files on 2.0 and 2.1 compatible? In-Reply-To: <3bb3f5ef.1023489@news.newsguy.com>; from ransen_spam_me_not@nemo.it on Wed, Sep 26, 2001 at 04:29:06PM +0000 References: <3bb3f5ef.1023489@news.newsguy.com> Message-ID: <20010926233626.C16757@phd.pp.ru> On Wed, Sep 26, 2001 at 04:29:06PM +0000, Owen F. Ransen wrote: > Are compiled Python files compatible between version? > Upwards? Backwards? No, they are not. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From howard at eegsoftware.com Wed Sep 5 01:57:04 2001 From: howard at eegsoftware.com (Howard Lightstone) Date: Wed, 05 Sep 2001 05:57:04 GMT Subject: python.exe/Tkinter hang on exit Message-ID: <3B95BE7C.F4C7482F@eegsoftware.com> About 1 out of 3 times I run my python.exe apps that use Tkinter windows (Windows98SE), the application becomes a zombie if I close the app using the x-box to kill the Tkinter window. If I remember to do it (which seems to be tough lately), a Ctrl-C in the dos box seems to ALWAYS kill the app. It seems the application is hanging on OLESCELOCKMUTEX during termination, thus leaving a zombie task (which...typically... means I cannot shut Windows down gracefully, if such a thing were possible). I am assuming that some win32 thingey is not being called by the Tkinter task temination logic, BUT, using pythonw.exe, termination ALWAYS works correctly. (I am using Python 2.0) Any clues? I haven't tried to take apart my apps and see which imports do it (but Pmw looks like just a wrapper) . Thanks Howard From not.this at seebelow.org Fri Sep 28 17:21:53 2001 From: not.this at seebelow.org (Grant Griffin) Date: 28 Sep 2001 14:21:53 -0700 Subject: Why so few Python jobs? References: <9oltnk$vv3$1@nntp9.atl.mindspring.net> <3BB4DB87.8600869E@ccvcorp.com> Message-ID: <9p2plh025sm@drn.newsguy.com> In article <3BB4DB87.8600869E at ccvcorp.com>, Jeff says... >tszeto wrote: > >> >> Any ideas on why so few Python jobs are available? >> > >My take, in addition to the many good reasons already mentioned, is that >Python is so easy to learn, that when it *is* appropriate to use, it's usually >simpler for the existing staff to learn Python as well (or for an otherwise >qualified recruit to be taught Python), than to specifically hunt for someone >already skilled in Python. > >Of course, if the company has a need for a *very* skilled Python programmer, >then hiring specifically for that skill becomes reasonable. Yeah. But I hope I never have to maintain the code written by somebody like that--doesn't the world have too many maps and lambdas as it is ? Although Python is quite easy to learn (for a C/C++ programmer), truly "mastering" it takes awhile. I've been writing Python for two years now, and there still are many fine points I haven't mastered yet. When I started with it (with version 1.5.2), Python already had several fairly advanced constructs that the garden-variety programmer doesn't really need or use. But to make things worse, new constructs are coming along at a rate faster than tiny-brained folks like me can master them. For example, I haven't yet taken the time and energy to really figure out what weak references are: I just studied them long enough to determine that I can easily live withouth them. Of course, since Python long ago had all the constructs you really need, and since new syntactic sugar is specifically disallowed, the only category for new constructs to fall into is "advanced". (I resisted the temptation to use "obscure" here ). In fact, the only two things added since Python 1.5.2 that are genuinely useful to me are augmented assignments and string methods. But I guess all this is a compliment to Python in a way: a really good toy is one whose mastery seems attainable, yet isn't. (There's gotta be _some_ reason people pay good money just to play golf .) But apart from the "advanced", we have the "Pythonic". This is perhaps of more use, but seems to come only from time and experience. somebody-oughtta-write-a-book--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 aleax at aleax.it Mon Sep 17 09:12:22 2001 From: aleax at aleax.it (Alex Martelli) Date: Mon, 17 Sep 2001 15:12:22 +0200 Subject: How to parse XHTML with xml.parsers.xmlproc? References: <873d5mo5cz.fsf@zazu.vip.fi> <9o4bqs0251k@enews4.newsguy.com> <87r8t6m6bj.fsf@zazu.vip.fi> Message-ID: <9o4srq03r@enews4.newsguy.com> "Paavo Hartikainen" wrote in message news:87r8t6m6bj.fsf at zazu.vip.fi... ... > I was under the impression that well-formedness is also defined > somehow in DTD. Well... there *IS* that abomination which is called CDATA, which can indeed make well formedness dependent on DTD's, for an otherwise constant "stream of characters". *Shudder*. I think you need that in XHTML for such things as
     
    No I do not have a clue what the message is and I'm sure I am not the only one who doesn't. Here is the message I intended for dongkui (and to be seen by the list): It has come to me pretty obvious that you are a windows user. Yet I have no idea on your abilities or knowledge about other operating systems, and therefore I will not make judgements. But in case you didn't know there ARE other people out there using different systems. Now even though we use many different systems and os's and all we can still communicate. You want to know why, well because we ALL use the standard world wide, text. Yes plain text, so no-one needs to worry about a new virus being spread, so everyone even thoose sitting in front of some unix system using only command line e-mail can understand you, no text doesn't have flashy graffics and neon lights and so on, but when e-mail started it wasn't intended for that, it was intended to connect people through a common source of communication that all with a simple computer and connection to the internet could access. Now Microsoft has changed the direction into a community where only thoose who want their software can communicate with thoose that do, but you still have a choice you can communicate with the standard of the rest of the world, or just keep on using whatever Microsoft spoon-feeds you. If you really want your questions to be viewed by as many of the intelligent minds on this list as possible please use the standard that is not only the standard for a few, but the standard for all. Dan -- John 11:25 "Jesus said to her, I am the resurrection and the life. He who believes in me will live, even though he dies;" -- Daniel Hammond-[ x = 'fleltltl at ltlrlaldlelrlsldlaltlal.lclolml' emailaddress = string.replace(x, 'l', '')] From tripie at cpan.org Sun Sep 2 21:16:42 2001 From: tripie at cpan.org (Tomas Styblo) Date: 2 Sep 2001 18:16:42 -0700 Subject: [ANN] htmltmpl and easydoc Message-ID: htmltmpl is a templating engine for separation of code and HTML, targeted mainly at web applications. It's similar and compatible with HTML::Template, which is an templating engine that is very popular in Perl world. easydoc is an example application similar to Javadoc using htmltmpl to generate XHTML-Strict compliant documentation from docstrings embedded in Python source files. Webpage of the project is at: http://htmltmpl.sourceforge.net/ Example output of easydoc (API documentation of htmltmpl itself) is available at: http://htmltmpl.sourceforge.net/python-api.html This is first public announcement. More detailed information follows. ---- The purpose of the templating engine is to provide web application developers, who need to separate program code and design (HTML code) of their web application projects, with a templating tool that can be easily used by cooperating webdesigners who have no programming skills. Templating language provided by the engine is inspired by Perl templating module HTML::Template. Templates created for HTML::Template can be used with this engine. The engine is currently available for Python. Java version is coming soon. The Python package includes easydoc, a module which uses the templating engine to generate HTML documentation from docstrings embedded in source files of Python modules. The primary goal of the templating engine is to keep things simple for a webdesigner who creates the templates. Therefore, neither Python nor Java code can be used in the templates. Instead, the templating engine provides its own simple templating language that supports basic programming operations like for example loops, conditionals and substitution of variables. These operations are controlled from within the templates by statements that look like HTML tags and integrate nicely with regular HTML code. The secondary goal is good performance. High speed template processing is necessary when the engine is used by web applications. I am aware that other templating solutions for Python and Java exist. But none of them is similar to HTML::Template. I love its enforcement of strict separation of code and HTML and the style and syntax of its template language. I find it much more cleaner and maintainable than the other solutions. Also, I need to move some projects from Perl to Python and Java and I want to reuse my old HTML::Template templates. These are the reasons why I created the templating engine. ---- Tomas Styblo, tripie at cpan.org "too cynic for love, too ugly for sex" From drek at smashpow.net Sun Sep 9 17:17:24 2001 From: drek at smashpow.net (Agent Drek) Date: Sun, 9 Sep 2001 17:17:24 -0400 (EDT) Subject: os.stat() ? Message-ID: Am I wrong in thinking that this should return a value that chmod(1) would expect? $ touch myfile $ ls -l myfile -rw-r--r-- 1 drek pow 0 Sep 9 17:07 myfile import os, stat print os.stat('myfile')[stat.ST_MODE] & 0777 I get '420' from os.stat python2.1.1 on FreeBSD I'm looking for the best way to get a list of the full attributes of a file. thanks, -- Derek Marshall Smash and Pow Inc > 'digital plumber' http://www.smashpow.net From tim.one at home.com Sat Sep 1 22:27:49 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 1 Sep 2001 22:27:49 -0400 Subject: Stackless Python and Python 2.x In-Reply-To: <7xd75azev0.fsf@ruckus.brouhaha.com> Message-ID: [Paul Rubin] > How is it possible to implement resumable generators without using > coroutines, continuations, or something equivalent? Have you read the PEP? http://python.sourceforge.net/peps/pep-0255.html This flavor of generator is formally a semi-coroutine, and it's the asymmetry that makes impementation easier; a PEP 255 generator can suspend only to the routine that invoked it, and only to the point of invocation, which implies that nothing more than the generator's local state needs to be preserved between resumptions. In Python terms, since execution frames were already heap-allocated, it?s not much of an exaggeration to say that the primary trick to implementing generators was simply to refrain from decrementing a frame?s refcount upon yielding. BTW, the book ?Advanced Programming Language Design? is available online: http://cseng.aw.com/book/related/0,3833,0805311912+20,00.html and chapter 2 shows in excruciatingly detail how to implement CLU iterators (also semi-coroutines) using almost-standard C, abusing the C stack via setjmp/longjmp tricks. From tim.one at home.com Mon Sep 10 18:37:37 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 10 Sep 2001 18:37:37 -0400 Subject: installation fails ? In-Reply-To: <9njbdj$ml$1@fstgss02.tu-graz.ac.at> Message-ID: [Armin Samide] > I'have downloaded the Python 2.1.1 source code package and wanted to > buildit on Windows with the Microsoft Visual C Compiler but a few > headers are missing, as there are: zlib.h, xmlparse.h, db.h, tcl.h > Are these headers included somewhere else or what else is wrong ? If you want to build the non-core 3rd-party components, you need to follow the instructions for obtaining and installing them too. The instructions are in PCbuild\readme.txt. From richard at bizarsoftware.com.au Tue Sep 18 00:50:12 2001 From: richard at bizarsoftware.com.au (Richard Jones) Date: Tue, 18 Sep 2001 14:50:12 +1000 Subject: Problems with pythonw.exe/embdedding Zope terminating In-Reply-To: <0109181438521Y.01597@ike> References: <0109181438521Y.01597@ike> Message-ID: <0109181450121Z.01597@ike> On Tuesday 18 September 2001 14:38, Richard Jones wrote: > On Win2000 & 98, running: > > python z2s.py Python version 2.1.1 Richard From mats at laplaza.org Sun Sep 2 11:32:32 2001 From: mats at laplaza.org (Mats Wichmann) Date: Sun, 02 Sep 2001 15:32:32 GMT Subject: Freezing Jython PY scripts References: Message-ID: <3b924e9e.187040339@news.laplaza.org> On Sun, 02 Sep 2001 04:43:17 GMT, "Maan Hamze" wrote: :I need to be able to create a Jython compiled JAR file that can be run on a :PC without Jython on it. :With Test.py I am compiling with : jythonc -j Test.py :to create Test.jar :I have the classpath set correctly to '.' and jython.jar is included in the :classpath through jythonc. And jython is using jave.exe from the Sun JRE. :However when I run Test.jar: :java -jar Test.jar :I am getting the error message due to a class not found: :org.python.core.PyObject :what am I doing wrong? There's a freeze utility in the Jython tools directory that may help with the question you started this message with. I have no experience with it. As a tip, if you head over to the jython-users mailing list, you'll find lots of folks willing and able to help, and I know this topic comes up from time to time. You can sign up by following the Jython project page at jython.sourceforge.net. Mats Wichmann From James_Althoff at i2.com Thu Sep 20 13:58:07 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Thu, 20 Sep 2001 10:58:07 -0700 Subject: Proposed PEP for a Conditional Expression Message-ID: Tom Payne wrote: >To me, > > count = 1 if by_land() else > 2 if by_sea() else > 0 > >is clearer than > > if by_land(): > count = 1 > elif by_sea(): > count = 2 > else: > count = 0 On the other hand, it's hard to make the case that the latter is *unclear*. And it's already there, just waiting to be used. ;-) Jim From emile at fenx.com Tue Sep 18 15:05:07 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 18 Sep 2001 12:05:07 -0700 Subject: voodoo: modifying class methods a posteriori References: Message-ID: <9o8664$bhp7t$1@ID-11957.news.dfncis.de> class A's f can be invoked from within new method g(). Does this help? class A: def f(self): print 'hello' def g(self): print 'bye' A.f(self) a = A() a.f() import new a.f = new.instancemethod(g, a, A) print a.f() -- Emile van Sebille emile at fenx.com --------- wrote in message news:mailman.1000836080.3205.python-list at python.org... > Hi, > > This is a problem that has bugged me for a while, now. (Related topic > might be "function closure", which I don't understand much.) > > What follows is pure Python voodoo. But when voodoo is used properly, > it does wonders. :) > > Say, you have a class "A" with method "f(self)" (which potentially > could be the constructor __init__() or destructor __del__(), by the > way.) > > Instance-bound methods can be overriden easily. (I am not interested > in derived subclass, see the reason a bit later.) > > class A: > def f(self): > print 'hello' > def g(self): > print 'bye' > a = A() > a.f() > import new > a.f = new.instancemethod(g, a, A) > a.f() > > The class-bound method f() can be overriden, easily, too: > > class A: > def f(self): > print 'Hello' > def g(self): > print 'Bye' > a = A() > a.f() > A.f.im_func.func_code = g.func_code > a.f() > > Now, all that is nice. BUT, usually, when you override a method, you > probably want to do just a bit more than what the old method was > doing. Say, you may only want to add a print statement when the > method is called, or you may want to insert a statement to the > constructor/destructor so object instances can automatically > register/deregister to a particular event handler. > > When you have many subclasses derived from subclasses of other > classes, especially when you don't have access to the source code for > one reason or another, or when you don't want to or you can't modify > the source code of the superclass, is there a way of inserting > statements into the class methods? > > In derived class, what you would do is something like: > > class A: > def f(self): > print 'Hello' > class AA(A): > def f(self): > print 'before saying Hello' > A.f(self) > print 'after saying Hello' > a = AA() > a.f() > > Notice you are able to insert statements before and after the base > class method call. > > Is there a way of doing the same thing without subclassing? > > ============= > > hmm.... I think I just answered myself, I'll post it to the mailing > list anyway: > > class A: > def f(self): > print 'Hello' > def g(self): > print 'before saying Hello' > self.f_old() > print 'after saying Hello' > a = A() > a.f() > import new > A.f_old = A.f > A.f = new.instancemethod(g, None, A) > a.f() > > ===================== > > Wow! It's fun! I wonder why people are still using Java. :) > > Hung Jung > > > From hungjunglu at yahoo.com Wed Sep 19 08:49:24 2001 From: hungjunglu at yahoo.com (Hung Jung Lu) Date: 19 Sep 2001 05:49:24 -0700 Subject: voodoo: modifying class methods a posteriori References: Message-ID: <8ef9bea6.0109190449.475c713@posting.google.com> slinkp23 at yahoo.com (Paul Winkler) wrote in message news:... > This is exactly what the Decorator design pattern is for. I don't think so. :) (1) In real-life programming, what I have explained is a real need. In an actual commercial software development, you typically have many people collaborating, and you use third-party modules. Everything is moving at the same time, and some modules are not under your control. So, very often, it's best practice not to touch other people's codes. Now, the other people have a whole package of many modules and classes and subclasses, and you want to modify the behavior of a superclass, at some branch of the complicated class hierarchy structure. What you have described is nothing but a more elaborate way of class derivation, and it does not help, because you'll have to copy and re-do the whole class hierarchy tree, when all what you wanted was to modify one single method in the superclass. In other words, you cannot modify the behavior of existing objects in your approach: you are only introducing new classes, new objects. In C++ and in Java, you simply cannot modify the behavior of a superclass's methods, no way Jose, that's part of the corporate security concerns inherent to those languages. In Python, you can. You can insert hooks almost at will. (2) Beware of the word "pattern". It's fad, I know. But "pattern programming" is nothing but a rephrasing of "give me an example, please". I've seen fads come and gone, and "pattern" seems to be one of them. :) regards, Hung Jung From marknenadov at winningteam.com Fri Sep 28 09:10:15 2001 From: marknenadov at winningteam.com (Mark Nenadov) Date: Fri, 28 Sep 2001 13:10:15 GMT Subject: Does there exist a Python-to-Perl translator ? References: <3BB2D226.3C260A2C@Spam.Please> <3BB31597.96BFE8B7@Spam.Please> <9p1ccu$pfr$1@neon.noos.net> Message-ID: <20010928.092734.1351797369.1132@d150-171-215.home.cgocable.net> In article <9p1ccu$pfr$1 at neon.noos.net>, "Boyd Roberts" wrote: > "Weet Vanniks" a ?crit dans le message news: > 3BB31597.96BFE8B7 at Spam.Please... >> You don't get my point. Managers do want to see Perl code. What I want >> is benefit from the productivity of Python, get something working and >> then satisfy my manageer with a Perl solution. > you're thinking about it the wrong way. you'd be better off _training_ > your manager to get a grip. usually works for me :) Hmm... for some reason this manager likes messy code :) From aleax at aleax.it Tue Sep 11 05:47:30 2001 From: aleax at aleax.it (Alex Martelli) Date: Tue, 11 Sep 2001 11:47:30 +0200 Subject: Proposed PEP for a Conditional Expression References: <6qvgire4bk.fsf@abnoba.intevation.de> <9nidrm01j7q@enews1.newsguy.com> <9nk4t8$4qq$1@glue.ucr.edu> Message-ID: <9nkmjj01rha@enews3.newsguy.com> wrote in message news:9nk4t8$4qq$1 at glue.ucr.edu... > Alex Martelli wrote: > : "Bernhard Herzog" wrote in message > : news:6qvgire4bk.fsf at abnoba.intevation.de... > : ... > :> > What's wrong with just satisfying people? > :> > :> Lots of people asking for it is a reason to write the PEP, but not > :> necessarily a reason to actually adopt the PEP. > > : Seconded on both scores. Specifically, adding to Python all the > : features that "lots of people" ask for would ensure Python's > : transformation into a huge, bloated language. *THIS* is "what's > : wrong with just satisfying people", as here rhetorically asked: > : trying to make everybody happy will ensure nobody's happy:-). > > The above non-sequitur applies equally well to every proposal that > "lots of people ask for". Exactly, except it's not a non-sequitur. "Just satisfying people" (by meeting every popular feature request) is NO way to design a language (or, as it happens, any other large software system:-). Alex From jkn at nicorp.f9.co.uk Thu Sep 27 10:48:14 2001 From: jkn at nicorp.f9.co.uk (Jon Nicoll) Date: 27 Sep 2001 07:48:14 -0700 Subject: scanf style parsing References: <3BB16A50.BAE082FE@cygnus-software.com> Message-ID: <8351bb33.0109270648.75af3371@posting.google.com> trivial followup: isn't it ... amazing ... the number of programs which still have this kind of output? > > > > smtpmail.exe - 0 error(s), 0 warning(s) ___ ___ jon N From jtdubs at eos.ncsu.edu Sat Sep 8 21:38:04 2001 From: jtdubs at eos.ncsu.edu (Justin Dubs) Date: Sat, 8 Sep 2001 21:38:04 -0400 Subject: large class hierarchies in python Message-ID: <9neh5p$gi2$1@uni00nw.unity.ncsu.edu> Hey guys, I'm new to python, as of last week. I know several other OO langauges though. Anyway, I am having trouble getting a hierarchy of "modules" to behave as I would like them to. I guess I have several questions, or maybe just one long one. I love python's syntax and functionality. I'm not sure, however, if I am the least bit pleased with the way it deals with "modules". I probably just don't understand what I'm doing. I'm trying to pretty much do Java style package hierarchies with python modules and I'm not sure if it is possible/appropriate. I want the directory structure to be the module (package?) structure of the program. And I want each class to exist in a file of the same name. I haven't yet gotten this concept to mesh well with the python module/import paradigm. For example: / /agent /agent/Agent.py /agent/Environment.py /agent/grid /agent/grid/GridAgent.py /agent/grid/GridEnvironment.py Here, GridAgent and GridEnvironment inherit from Agent and Environment, respectively. I assume each directory will need a __init__.py file, but I really don't understand what to put in it to have it behave the way I'd like. Any suggestions? Also, as a maybe simpler question: Is this entire method of programming just not going to work out with Python? Is Python not suitable for this type of problem? If not, what languages do you know of that are syntactially similar to Python and WOULD be appropriate? Thanks a lot guys, Justin Dubs From m.1.robinson at herts.ac.uk Mon Sep 3 12:06:04 2001 From: m.1.robinson at herts.ac.uk (Mark Robinson) Date: Mon, 03 Sep 2001 17:06:04 +0100 Subject: namespaces getting confusing Message-ID: <3B93AA6C.10209@herts.ac.uk> can anyone explain why I get the following attribute error. I know it is something to do with me misusing namespaces and imports but I dunno what. %Motif.py import param def readSeq(filename) #bla bla bla #some other def's ################# %param.py import os, Motif #various variable initialised seq = Motif.readSeq ############### %Camel.py import os, Motif, param #and others #other non relevant code ########### I get the following error: Traceback (most recent call last): File "D:\blobby\param.py", line 1, in ? import os, Motif File "D:\blobby\Motif.py", line 1, in ? import string, math, pickle, param File "D:\blobby\param.py", line 30, in ? seq = Motif.readSeq(filename) AttributeError: 'Motif' module has no attribute 'readSeq' From peter at engcorp.com Fri Sep 7 10:08:54 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 07 Sep 2001 10:08:54 -0400 Subject: newbie: cannot import name error References: Message-ID: <3B98D4F6.445C1525@engcorp.com> "rjberman at NOSPAMrodessaNOSPAM.com" wrote: > > import distutils, os, sys, stat > from distutils.core import setup, Extension > > The error I get is: > > 131> python test1.py > > Traceback (most recent call last): > File "test1.py", line 7, in ? > from distutils.core import setup, Extension > ImportError: cannot import name Extension I don't know anything about distutils, but I can do 'from distutils import extension'. Was that what you needed? Python is case-sensitive. > Can someone help me? I can't believe that on my second encounter > with Python I've already been stumped! This is not a good first > impression. Any help would be appreciated or even pointers to help! On the other hand, you're trying to do something I've _never_ needed to do yet, after almost two years with Python. Any time (to date) I've needed to install an extension, I've been okay with just copying it to the python/lib folder, or with adding an entry to a .pth file (see the docs in site.py) to point it to the folder in which I keep my own extensions. By the way, why are you running (a) an old version, and (b) an _alpha_ version! -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From boud at rempt.xs4all.nl Thu Sep 13 14:31:24 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 13 Sep 2001 18:31:24 GMT Subject: [PyQt] Confused by this class hierachie ... References: <9nqgdb$h2i$1@news.netcologne.de> Message-ID: <9nqu1s$6hl$1@news1.xs4all.nl> Well, without some actual code it's difficult to tell exactly what your problem is. What I mostly do is create the dialogs in the constructor of my main window class - that makes it available everywhere. You create the dialog with the main window instance as parent, and that means you can get at the main window from the dialog with self.parent(). You can take a look at http://stage.linuxports.com/pyqt/x1771.htm or http://stage.linuxports.com/pyqt/c3816.htm - the first is about the standard dialogs PyQt offers, the second about creating real, complex dialogs. If those chapters don't clear away your confusion, please tell me - then I can adapt the text and make it clearer! -- Boudewijn Rempt | http://www.valdyas.org From aleax at aleax.it Mon Sep 3 07:02:54 2001 From: aleax at aleax.it (Alex Martelli) Date: Mon, 3 Sep 2001 13:02:54 +0200 Subject: typechecks: just say no! (was Re: Determining Types) References: Message-ID: <9mvo0u04o8@enews2.newsguy.com> "Adonis Vargas" wrote in message news:fe9k7.1835$ix.446807 at newsrump.sjc.telocity.net... > how am i able to determine types of variables? i have come up with the Be aware that, MOST times you THINK you need to typecheck, you really *don't*. Type-checks break the wonderful signature based polymorphism that is the key to so much of Python's power and simplicity. Check out the Cookbook recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52291 for a way to avoid type-checking (in favour of signature checking) even when you might think it's indispensable. That much being said, the built-in function isinstance is the least painfully horrible way to do typechecking anyway: def sometypechecking(anobject): if isinstance(anobject, type('')): print "it's a string" elif isinstance(anobject, type(0)): print "it's an int" elif isinstance(anobject, type(0.0)): print "it's a float" else: print "it's something else" You can do it in other ways, such as testing if type(anobject) is type('') and so on, but there is really no advantage to those other ways -- they just damage polymorphic behavior even worse than isinstance-based checks do (no observable difference in Python 2.1, but in Python 2.2 it will be possible to inherit from built-in types: such inheriting objects will pass an isinstance-based check, but fail a type-is-type based check, which only checks *identity of types* and NOT subclassing-relationships). To summarize: don't type check. If you think you must, use "accurate look-before-you-leap" instead. If you STILL think you must, use isinstance. *AND* lobby for the "protocol-adaptation PEP", the "Object Adaptation" PEP 246, http://python.sourceforge.net/peps/pep-0246.html, which, if it's ever adopted in Python, would offer "one obviously right way" to handle most situations in which people tend to erroneously think type-checks are the best solution. Alex From aleaxit at yahoo.com Sat Sep 8 16:32:29 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 8 Sep 2001 22:32:29 +0200 Subject: troubles with list.append() References: <4f374853.0109081133.74969472@posting.google.com> Message-ID: <9ndv8502ion@enews2.newsguy.com> Joe wrote: > I'm having some difficulties with appending > a list to a list. The code works how I want > it to if used within the the interpreter. You're probably doing something slightly different in that case. > patch_listing.append(patch) > > Printing patch_listing after the while loop > shows it filled with all of the same entries. Right, because you ARE appending references that are all to the same object, patch. Append *copies* of that obiect instead, e.g.: patch_listing.append(patch[:]) or, after an import copy, patch_listing.append(copy.copy(patch)) Python never implicitly takes a copy -- you have to request one when you want one. That doesn't matter for immutable objects, but lists are mutable, so there IS a difference between having a copy (a "snapshot" taken at some point, and fixed unless and until you choose to mutate it) and a reference to the original (since the "original" object keeps changing). Alex From eppstein at ics.uci.edu Thu Sep 6 16:16:50 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Thu, 06 Sep 2001 13:16:50 -0700 Subject: Image file comments and/or EXIF-info References: <9n8lau$66q2g$1@ID-59332.news.dfncis.de> Message-ID: In article <9n8lau$66q2g$1 at ID-59332.news.dfncis.de>, "Bror Johansson" wrote: > Are there any modules that can be used for reading/writing comments and/or > EXIF-info from/to imagefiles (capable of) holding such info? > > PythonMagick seems to be competent with comments. Is PythonMagick compatible > to Python 2.1? exifdump by Thierry Bousch can at least read EXIF data, I haven't looked for code that will write it. http://topo.math.u-psud.fr/~bousch/exifdump.py -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From cpr at emsoftware.com Thu Sep 6 10:14:59 2001 From: cpr at emsoftware.com (Chris Ryland) Date: 6 Sep 2001 07:14:59 -0700 Subject: dictionary and __getattr__ References: Message-ID: <8827e15d.0109060614.59036c18@posting.google.com> Michael Abbott wrote in message news:... > Harald Kirsch wrote in > news:yv28zfsr6e8.fsf at lionsp093.lion-ag.de: > > > > > > > Wouldn't it be nice if this would work: > > > > d = {'x': 1} > > print d.x > > > > i.e. every entry in a dictionary is also an attribute of the > > dictionary itself. > > > > Is there a class wrapper for that somewhere available? > > I expect this would work: > > class Wrap: > def __init__(self, dict): > self.__dict__.update(dict) > > d = {'x': 1} > dd = Wrap(d) > print dd.x > > Of course, this may not be exactly what you want, because dd won't follow > updates to d. Hey, won't the new 2.2 support for extending built-in classes such as dictionaries make this both easy and complete? --Chris Ryland, Em Software From daniel.dittmar at sap.com Thu Sep 6 07:29:49 2001 From: daniel.dittmar at sap.com (Daniel Dittmar) Date: Thu, 6 Sep 2001 13:29:49 +0200 Subject: dictionary and __getattr__ References: Message-ID: <9n7mna$e4m$1@news1.wdf.sap-ag.de> > Wouldn't it be nice if this would work: > > d = {'x': 1} > print d.x > >i.e. every entry in a dictionary is also an attribute of the >dictionary itself. class AttributeDict (UserDict): __getattr__ = UserDict.__getitem__ Daniel From tim at vegeta.ath.cx Tue Sep 25 01:22:26 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Tue, 25 Sep 2001 05:22:26 GMT Subject: Why so few Python jobs? References: <3BB00345.4F1237B5@engcorp.com> Message-ID: Me parece que Peter Hansen dijo: > Tim Hammerquist wrote: > > > > A good argument. One of my favorite things about Python is that I never > > run the risk of having to maintain code like this: > > > > sub myfunc { > > do_stuff(); > > do_some_more_stuff(); > > $screw = with @some_variables; > > for $item (@some_variables){ > > do_stuff(); > > and_some_more(); } > > do_a_bit_more(); > > blah; > > } > > What's so bad about this?! Heh. Good thing you didn't ask me when I had to maintain this code. I would've bitten your head off...so to speak...I hope. > It's just indentation with a tabsize of zero... ;-) > > -is-that-really--perl?-ly yr's, It parses, yes. But C code of the same format would parse as well. However, no instructor I've ever had would have accepted it. They'd have said, "Rewrite the code structure, turn it back in, and accept a 10% deduction from the final score for late work. No Perl module from CPAN has this form, nor any code posted to c.l.p.m (other than from newbies). Larry Wall suggests a 4-wide tabs with open and closing braces in corresponding columns. The above code would result in: sub myfunc { do_stuff(); do_some_more_stuff(); $screw = with @some_variables; for $item (@some_variables) { do_stuff(); and_some_more(); } do_a_bit_more(); blah; } (at which point the Python side of my brain kicks in and says, "Well, there's two perfectly good screen lines wasted with one character...") -ly yr's, Tim -- I'm already not yet convinced. -- Larry Wall From quinn at yak.ugcs.caltech.edu Mon Sep 24 10:20:45 2001 From: quinn at yak.ugcs.caltech.edu (Quinn Dunkan) Date: 24 Sep 2001 09:20:45 -0500 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Sep 24) Message-ID: QOTW: "Is Python fit for multi-tiered apps?--Yes, especially as an alternative to Java!" The context for this was the observation that Python appears to do a bunch of Three (and four!) Letter Acronyms just as well as Java (the original poster actually wanted to know about multi-tierd apps, which sounds much more rugged and industrial). AMK mentions an article about such an app, which well documents the design of a mid-sized python project (it also mentions his Cervantic web application framework, Quixote). http://groups.google.com/groups?threadm=9o7lvv%24170%2401%241%40news.t-online.com http://www.amk.ca/python/writing/mx-architecture/ The Ottawa Python Authors Group goes live at http://www.opag.ca Sam is apparently having trouble with instance and class attributes. It turns out the problem was a bug in other code (importing the wrong module), but in the meantime there's a lot of discussion about scoping, binding, and Alex's new "Borg" pattern: http://groups.google.com/groups?threadm=ii7k7yvqi87.fsf%40central.sun.com The Law of Demeter says that objects shouldn't have (or need) deep knowledge of the structure of other objects. If that was unclear or you don't agree or you think "well, that's obvious, but not very specific", the following thread explains things much better: http://groups.google.com/groups?threadm=slrn9qf4r5.p9.slinkp23%40roaddog.armsnet Tim demonstrates what fun can be had with Python 2.2 generators when finding permutations. It's also a good example of a recursive generator: http://groups.google.com/groups?threadm=mailman.1000707871.18101.python-list%40python.org For a journalistic treatment of generators and other 2.2 goodies, see http://www.unixreview.com/articles/2001/0109/0109h/0109h.htm Chris wants to bundle python modules similar to Java's JARs. It's possible with the __import__ hook, as Installer and py2exe demonstrate: http://groups.google.com/groups?threadm=rsHrsJAP5op7Ew7L%40jessikat.fsnet.co.uk ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the daily python url http://www.pythonware.com/daily comp.lang.python.announce announces new Python software. Be sure to scan this newly-revitalized newsgroup at least weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Michael Hudson continues Andrew Kuchling's marvelous tradition of summarizing action on the python-dev mailing list once every other week. http://starship.python.net/crew/mwh/summaries/ http://www.amk.ca/python/dev The Vaults of Parnassus ambitiously collect Python resources http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ The Python Software Foundation has replaced the Python Consortium as an independent nexus of activity http://www.python.org/psf/ Cetus does much of the same http://www.cetus-links.de/oo_python.html Python FAQTS http://python.faqts.com/ The old Python "To-Do List" now lives principally in a SourceForge reincarnation. http://sourceforge.net/tracker/?atid=355470&group_id=5470&func=browse http://python.sourceforge.net/peps/pep-0042.html Python Journal is at work on its second issue http://www.pythonjournal.com Links2Go is a new semi-automated link collection; it's impressive what AI can generate http://www.links2go.com/search?search=python Archive probing tricks of the trade: http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python&num=100 http://groups.google.com/groups?meta=site%3Dgroups%26group%3Dcomp.lang.python.* Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://www.ddj.com/topics/pythonurl/ http://purl.org/thecliff/python/url.html (dormant) or http://groups.google.com/groups?oi=djq&as_q=+Python-URL!&as_ugroup=comp.lang.python Suggestions/corrections for next week's posting are always welcome. [http://www.egroups.com/list/python-url-leads/ is hibernating. Just e-mail us ideas directly.] To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. Mention "Python-URL!". -- The Python-URL! Team-- Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and sponsor the "Python-URL!" project. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From ignacio at openservices.net Fri Sep 14 19:42:33 2001 From: ignacio at openservices.net (Ignacio Vazquez-Abrams) Date: Fri, 14 Sep 2001 19:42:33 -0400 (EDT) Subject: What's wrong with my script? In-Reply-To: <9nu2t0$of3$00$1@news.t-online.com> Message-ID: On Sat, 15 Sep 2001, Michael Landmann wrote: > > > > print "Content-type: text/html\n\n" # add this line here > > > > > > Doesn't work > > > > You need to give us more information than "Doesn't work" if you want to > > get it working. Is it executable? Is it in a place where the Web > > server can get at it? Is the Web server configured to execute CGI > > scripts for that area? > > Error 500 > > The Server is ready to work with CGI, PHP3, PHP4, Python, Perl Once you have tried the other change that has been suggested, you have to set the Options directive for the directory that the CGI program is in to have +ExecCGI. -- Ignacio Vazquez-Abrams From drek at smashpow.net Wed Sep 5 18:57:06 2001 From: drek at smashpow.net (Agent Drek) Date: Wed, 5 Sep 2001 18:57:06 -0400 (EDT) Subject: debugging a c module? Message-ID: I've made a loadable module to speed up a portion of a python program that I'm working on. Once in awhile (1 time out of 10) I get a core dump on exit from the interpreter "Abort (core dumped)". I'm pretty sure that this is because I've screwed up a reference count somewhere in the module. How do I go about debugging this? I'm using Python-2.1.1 on FreeBSD4.x. Recompile python and the module with debugging? gdb? This small problem aside, the C/API is great to work with! There are lots of useful docs explaining how to write the modules I just haven't found any that talk about the debugging process. cheers, -- Derek Marshall Smash and Pow Inc > 'digital plumber' http://www.smashpow.net From ht_xu at hotrmail.com Mon Sep 10 16:44:22 2001 From: ht_xu at hotrmail.com (Henry) Date: Mon, 10 Sep 2001 15:44:22 -0500 Subject: How to know it is a list? Message-ID: Hi guys, I have a newbie question. How do check if a variable is a list? Thanks in advance, Henry From dlharris at mail.usyd.edu.au Wed Sep 12 12:08:58 2001 From: dlharris at mail.usyd.edu.au (Dave Harrison) Date: Thu, 13 Sep 2001 02:08:58 +1000 Subject: waste of life In-Reply-To: <01091216462900.03157@phoenix>; from heikowu@ceosg.de on Wed, Sep 12, 2001 at 04:46:29PM +0200 References: <01091216462900.03157@phoenix> Message-ID: <20010913020858.A6804@isetroc.com> I'll second that. We can only hope that one day such senseless acts of indiscriminate violence will just be a memory. Dave Thus spake Heiko Wundram (heikowu at ceosg.de): > Hello to all fellow list members! > > As I have not heard a single word about it on the list so far, I thought that > I might as well take the initiative and express my grievance at seeing the > pictures that were broadcast for all day today (and yesterday too) about the > suicide bombings (or whatever you might call it) of the two twin towers in > New York and also the Pentagon in Washington. > > Let us all mourn the great loss of lives (only comparable to a natural > catastrophe) that occured in just one hour due to such a cowardly act of > terrorism against civilians. Let us hope that all those innocent people who > died during these acts of crime are now in a better place. > > And let us think greatfully of all rescue workers, the medical staff of the > hospitals and all those individuals who came out to help or donate blood in > New York and Washington, and of course of all those who endangered or lost > their lives trying to help the people who were caught up in the debris of the > buildings. > > On a last note to myself, although the need for revenge that many Americans > feel at the moment is justifiedly huge, I sincerely hope that this act of war > of an as yet unknown agressor against America will not lead to a scenario > that was discussed in a late night show yesterday evening on German TV: > > "World War 3". > > -- > Yours sincerely, > > Heiko Wundram > > -- > http://mail.python.org/mailman/listinfo/python-list From nas at python.ca Thu Sep 6 11:17:09 2001 From: nas at python.ca (Neil Schemenauer) Date: Thu, 6 Sep 2001 08:17:09 -0700 Subject: Performance of list comprehensions vs. map In-Reply-To: <9n7n6u02leo@enews1.newsguy.com>; from aleax@aleax.it on Thu, Sep 06, 2001 at 01:38:07PM +0200 References: <3B966B1C.120D0AF6@home.net> <9n7n6u02leo@enews1.newsguy.com> Message-ID: <20010906081708.A18176@glacier.arctrix.com> Alex Martelli wrote: > I think one key issue is: map requires its sequence arguments to > support len() It won't in 2.2. Any object that supports the iteration protocol will do (thanks to Tim). Neil From beppu at binq.org Thu Sep 6 04:55:57 2001 From: beppu at binq.org (John Beppu) Date: Thu, 6 Sep 2001 01:55:57 -0700 Subject: lexical closures and python In-Reply-To: References: <20010905225609.A18903@BinQ.org> Message-ID: <20010906015557.B18903@BinQ.org> [ date ] 2001/09/06 | Thursday | 02:45 AM [ author ] Ignacio Vazquez-Abrams > (which, BTW, to begin to understand I had to go through LISP 101, > Beginning LISP, LISP for Dummies, LISP for Idiots, and > LISP for Complete F*cking Morons... ;) ) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ My favorite! ;-) > Other than lambdas, you can also mention the map(), reduce(), and filter() > functions, which as I may have heard somewhere do FP-like operations. Those functions would definitely be good to mention. > Also, I gotta ask: How the hell does JavaScript support them? ^^^^^^^^^^^^ hehe. Surprisingly, it's not very contrived. Here's a simple example you can save as an HTML file and try out in a JavaScript-enabled browser. js closure example Notice how grande and pequeno remember the value of current, but also notice that they each remember their own current variable. Because current is lexically bound to a new closure each time sequence_iterator() is invoked, grande and pequeno do not interfere with each other. Interesting, no? From aleax at aleax.it Mon Sep 3 11:10:24 2001 From: aleax at aleax.it (Alex Martelli) Date: Mon, 3 Sep 2001 17:10:24 +0200 Subject: Use of GMPY References: <9n03in$c6o$1@pegasus.tiscalinet.it> Message-ID: <9n06h001orh@enews1.newsguy.com> "Patrick" wrote in message news:9n03in$c6o$1 at pegasus.tiscalinet.it... > Hi, > > I'm trying to use GMPY module but it does not seem to work !? When I import > the GMPY module into Python IDE, I get an error message telling me that one > DLL is missing, but does not give the name of this missing DLL. I had last updated the file you downloaded: http://prdownloads.sourceforge.net/gmpy/gmpy-win32-binary-09.zip on Jan 24, and Python 2.1 was not released then -- only Python 2.0. So, the windows-binary version of GMPY could only run with Python 2.0. I've just uploaded a release that runs with Python 2.1 instead: http://prdownloads.sourceforge.net/gmpy/gmpy-win32-binary-09a21.zip No other changes, except rebuilding it with Python 2.1. I've also made a 09a21 release of the sources package, taking the occasion to fix the doctest (which relied on the error message format from Python 2.0 -- now it expects the message format of 2.1:-) and add the setes.py (to be used just like setup.py:-) to build the "pysymbolicext" sample C-extension to gmpy kindly supplied by Pearu back in January. > Can someone help ? Who better than the author/maintainer, i.e., me?-) (P.S.: I wonder why you didn't mail me directly -- isn't my email in evidence somewhere on the project page...? Gotta fix that, if so...!). > * I use a 2.1 AtiveState version of python 'as it comes from thes > ActiveState' site, > > * I have downloaded the 0.9 version of GMPY and copied the GMPY.PYD and > PYSYMBOLICEXT.PYD files in my \Python21\lib directory... Thanks for the details, which immediately enabled me to pinpoint the problem -- and thanks for your interest in GMPY, too. Alex From rnd at onego.ru Wed Sep 19 08:10:35 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 19 Sep 2001 16:10:35 +0400 (MSD) Subject: Using MySQLdb Newbie In-Reply-To: <01091912543507.01260@jordan.utopia.net> Message-ID: On Wed, 19 Sep 2001, Jordan Elver wrote: > Sorry. More details coming. > I'm using Linux Mandrake 8.0 with Python version 2.0. > I downloaded the tarball uncompressed it and read the README. It says to run > python setup.py build then python setup.py install. But, when i try either of > these they both give the same error? Install newer Distutils. Probably, that MySQLdb distro was prepared for newer Distutils. I had no problem on RedHat 6.2 With Python 2.1 apart from MySQLdb (and PyGreSQL) both core-dumped Python until I recompiled it with pth (GNU threads) instead of pthreads. Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From heikowu at ceosg.de Thu Sep 6 07:07:47 2001 From: heikowu at ceosg.de (Heiko Wundram) Date: Thu, 6 Sep 2001 13:07:47 +0200 Subject: dictionary and __getattr__ In-Reply-To: References: Message-ID: <01090612512400.00324@phoenix> On Thursday 06 September 2001 11:54, you wrote: > Wouldn't it be nice if this would work: > > d = {'x': 1} > print d.x > > i.e. every entry in a dictionary is also an attribute of the > dictionary itself. > > Is there a class wrapper for that somewhere available? # Works with Python 2.2a2. from __future__ import generators class AttributeDictionary: def __init__(self): self.dict = {} self.default = None def __getitem__(self, key): return self.dict[key] def __setitem__(self, key, value): self.dict[key] = value def __delitem__(self, key): del self.dict[key] def __getattr__(self, key): if not key in self.dict: raise AttributeError return self.dict[key] def __setattr__(self, key, value): self.dict[key] = value def __delattr__(self, key): del self.dict[key] def get(self, key, default=None): try: return self[key] except: if default == None: return self.default else: return default def setdefault(self, default): self.default = default def has_key(self, key): try: self[key] return 1 except: return 0 def __iter__(self): for i in self.dict: yield i raise StopIteration > > Harald Kirsch Works (almost like a dictionary). I've left out the more exotic dictionary functions like update, etc, for demonstration purposes only. The rest works as is. -- Yours sincerely, Heiko Wundram From jbranthoover at yahoo.com.NOSPAM Mon Sep 17 16:39:18 2001 From: jbranthoover at yahoo.com.NOSPAM (John Branthoover) Date: Mon, 17 Sep 2001 20:39:18 GMT Subject: Newbie: How to download a JPG file from the internet....? Message-ID: Hello All, Can anyone tell me how to download an image from a web site? An example: that is located at www.somewhere.org I have already found the urllib module and have used the urlopen function to create a string from a web page, but I don't know how to proceed from here. I can isolate the string - , but then what? I would like to eventually write it to a file on my local drive. Any information will be greatly appreciated. Thank you for your time. From fredp at mygale.org.nospam Mon Sep 3 04:37:36 2001 From: fredp at mygale.org.nospam (Fred Pacquier) Date: 3 Sep 2001 08:37:36 GMT Subject: Formatting question : printing numbers with thousands separators ? References: <5699ebda.0108310933.1646ac@posting.google.com> Message-ID: juneaftn at orgio.net (June Kim) said : > * and the most(or more or less) obfuscated way as a one-liner is: > > def sep(s): return > re.sub(r"([-+]?\d{1,3}(\.\d*)?)(?=(\d{3})*(\.|$))",r",\1",s)[1:] tanzer at swing.co.at (Christian Tanzer) said : > How about: >>>> import re >>>> sep_1000_pat = re.compile("(\d{1,3}) (?= (?: \d\d\d)+ (?! \d) )", >>>> re.X) sep_1000_pat.sub(r"\g<1>,", "2342342342344567") > '2,342,342,342,344,567' > Short, but then you need Friedl's masterpiece on regular expression to > understand it... Ouch. Didn't know you could also write Perl in Python... :-)))))) -- YAFAP : http://www.multimania.com/fredp/ From aleax at aleax.it Wed Sep 12 08:26:04 2001 From: aleax at aleax.it (Alex Martelli) Date: Wed, 12 Sep 2001 14:26:04 +0200 Subject: question with embeding python in C References: <3B9EFC71.A90FD092@club-internet.fr> Message-ID: <9nnk8s02igh@enews1.newsguy.com> "LAMY Bertrand" wrote in message news:3B9EFC71.A90FD092 at club-internet.fr... > here is my question : > when I create a Python object in a C function with PyObject_New and the > C function return that object to python, do I have to Py_INCREF the > object before ? No, PyObject_New returns an object with one reference to it already, and you can just pass that reference on. > In the help examples, for all 'new' functions that create in C an > instance of a new type, the object is returned without Py_INCREF. that > works. Right. > the 2 bugs were corrected by Py_INCREF the object before returning it. So you have some OTHER refcount-related bug in these cases -- you have one decref somewhere that you shouldn't have, so adding one incref balances things out. But you should really find out where the stray decref comes from. Since they're C objects of a type you control, why not just add some printf calls in their destructors to let you know the instant the dtor is running, and run the simplest failing-case Python script you can imagine with tracing turned on -- that should let you help narrow things down (you can also use a C-level debugger to put a breakpoint in the destructor and check the stack trace for more information, if that's feasible on your specific platform). Alex From sholden at holdenweb.com Fri Sep 28 21:35:15 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 28 Sep 2001 21:35:15 -0400 Subject: Repost: execfile() confusion References: <9p2iuk$1au@gap.cco.caltech.edu> Message-ID: <%v9t7.1727$mg1.21543@atlpnn01.usenetserver.com> "Nathaniel Gray" wrote in message news:9p2iuk$1au at gap.cco.caltech.edu... > Sorry for the repost but I didn't get any responses. > So once again, execfile() isn't doing what I thought it did. > Please accept my aplogies, I was getting on with my life under the confident assumption that the many fine brains who read this newsgroup would assist you with lightning speed. Since they've *all* let you down (shame on you, you know who you are), I'll have to resort to my standard strategy of providing an incorrect explanation and then letting the rest of c.l.py tell you exactly why I am wrong. > For example, with these two files: > > ############## > #### test2.py #### > x = 'spam' > > #### test.py #### > def doit(): > execfile( 'test2.py' ) # x = 'spam' > print x > > doit() > ############## > > I get the following when I run 'python test.py': > """ > Traceback (most recent call last): > File "test.py", line 5, in ? > doit() > File "test.py", line 3, in doit > print x > NameError: global name 'x' is not defined > """ > > I though that execfile was supposed to act on the locals() of the scope > from which it was called. I also tried adding x=None to the top of doit() > but execfile still doesn't change its value to 'spam'. Can somebody please > explain what's going on? > You have made a mistaken assumption, mistrusting the documentation when in fact everything is perfectly explicable as documented. Your assumption is that inside doit() the interpreter will check for x as a local before it checks for x as a global. Unfortunately this is NOT the case, and the error mesage explicitly informs you of that fact. When it compiles a function, the interpreter statically examines the code for assignments to (or more accurately, bindings of) names. If any are found then it compiles code to access those names as locals. The situation is slightly complicated if you have imported nested_ascopes from future, as it then statically examines each lexically surrounding function before defaulting to module global, but that need not concern us here. The error message is explicitly telling you that the global x has no value. So, Watson, the only theory that fits the facts is that execfile() has behaved exactly as its documentation describes, and bound the value 'spam' to the name x in the local scope of function doit(). Because there are no bindings to x in doit() to be found by static examination, however, the interpreter has decided that x will be in the module's global scope, and compiled bytecode which attempts to access it form there. Which, you will now realise, is why the error message complains that global x has not been defined. So now, Watson, if you will be good enough to hand me my violin and my cocaine, you can return to your scratchings, and I shall return to mine. Kindly insert a print of the dir() function inside doit(), and return only if no x is to be found therein. never-seen-a-case-for-a-local-statement-before-ly y'rs - steve -- http://www.holdenweb.com/ From sheila at spamcop.net Mon Sep 10 18:34:13 2001 From: sheila at spamcop.net (Sheila King) Date: Mon, 10 Sep 2001 22:34:13 GMT Subject: smtp.sendmail read receipt? References: Message-ID: <9nim4k.3vvcfe1.1@kserver.org> On 11 Sep 2001 00:44:27 +0300, Erno Kuusela wrote in comp.lang.python in article : :i don't know of any mail user agents that support rfc 2298 though (not :that i know that many). Well, some of them must. When I occasionally send out e-mail in Pegasus (a Windows client) and mark the receipt notification options, I do get receipts for some of the people I send to (not all of them, of course). -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From richard at bizarsoftware.com.au Fri Sep 21 04:02:03 2001 From: richard at bizarsoftware.com.au (Richard Jones) Date: Fri, 21 Sep 2001 18:02:03 +1000 Subject: "shell-commands" and python! In-Reply-To: <9oeqks$8t0$1@zingo.tninet.se> References: <9oeqks$8t0$1@zingo.tninet.se> Message-ID: <01092118020305.32742@ike> On Saturday 22 September 2001 02:40, Mike S wrote: > how do I execute "shellcommands" in python??? > do I need to use the os module and the system command? > > Is there any simplier way to do it?? Yes, http://www.python.org/doc/current/lib/module-commands.html Described as "8.18 commands -- Utilities for running commands" in the table of contents of the library reference. Richard From nobody at nexus.sourcedns.com Sun Sep 23 00:37:35 2001 From: nobody at nexus.sourcedns.com (nobody at nexus.sourcedns.com) Date: Sat, 22 Sep 2001 22:37:35 -0600 (GMT) Subject: !!Burn DVD using your CDRW!! Message-ID: Hi! Yes it sounds too good to be true but it IS true! You can burn your very own DVD with a regular CD burner! You can make BIG money selling this incredible software too! This is NOT a scheme or hype! It's the most advanced technology! To burn: http://www.dvdcopy.tv To sell: http://resell.dvdcopy.tv ***************************************** This is a one-time mailing only for those who are interested. No removal is required. We applogize if this email disturbed you. ***************************************** From roy at panix.com Sun Sep 2 18:55:55 2001 From: roy at panix.com (Roy Smith) Date: Sun, 02 Sep 2001 18:55:55 -0400 Subject: calling __init__ more than once? Message-ID: I've got a file parsing class which in which I call a single parser object repeatedly to parse additional files. Something like: p = myParser() stuff1 = p.parse (fileName1) stuff2 = p.parse (fileName2) Is there any reason why my parse method couldn't call __init__() to reset things back to the start state? It feels kind of creepy, but I don't see any reason why it should be a problem. Is there something I'm missing here, or is it really OK to call __init__() again? From boyd at insultant.net Mon Sep 24 03:18:34 2001 From: boyd at insultant.net (Boyd Roberts) Date: Mon, 24 Sep 2001 09:18:34 +0200 Subject: time.timezone gives strange results on cygwin References: Message-ID: <9ommtq$7mm$1@neon.noos.net> "Andy Todd" a ?crit dans le message news: Xns91268760EEA31andytoddspamfreeyaho at 203.109.250.24... > time.timezone is returning an incorrect value on cygwin python. > From the documentation; > > """ > timezone > The offset of the local (non-DST) timezone, in seconds west of UTC > (i.e. negative in most of Western Europe, positive in the US, zero in > the UK). > """ seems like they followed the unix stupidity. rfc822 Date: headers OTOH get it right. From tim at vegeta.ath.cx Thu Sep 20 00:55:18 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Thu, 20 Sep 2001 04:55:18 GMT Subject: Best book on Python? References: <9oasom$pit$1@plutonium.btinternet.com> Message-ID: Me parece que Ian Bolton dijo: [ snip ] > I am based in the UK and have read about a quarter of a borrowed copy of > Programming Python 1st edition. Now that I am back at uni and no longer > have access to the other book, I am gonna have to buy one. I've looked at > Programming Python 2nd edition and it looks good, but is it the best one out > for an beginner-intermediate programmer? (My Python experience is limited > to about 10 weeks worth of programming.) Also, where's the cheapest place > to get hold of PP2, or whatever you recommend? Excellent learning text: Learning Python, Mark Lutz, ORA Excellent reference: Python Essential Reference, Beazley?, New Riders (2nd Ed. recommended) I wouldn't waste money on Prog. Python (ORA). It's a diluted "Learning Perl" that doesn't really do anything with Python except Tkinter...unless this is really what you want. HTH -- Emacs is a nice OS - but it lacks a good text editor. That's why I am using Vim. -- Anonymous From dcinege at psychosis.com Thu Sep 6 22:51:43 2001 From: dcinege at psychosis.com (David Cinege) Date: Thu, 6 Sep 2001 22:51:43 -0400 Subject: how to run python script from Unix Shell? In-Reply-To: References: Message-ID: On Thursday 06 September 2001 22:41, Ignacio Vazquez-Abrams wrote: > On 6 Sep 2001, David wrote: > > Hi there, > > > > Can you help to advise how to run python script from Unix Shell? > > What I am doing is: > > 1)chmod +x script name > > 2)put #!/usr/bin/python at first line > > 3)when I type the script name under Shell, > > the message is: > > bash: Script name command not found. > > > > Actually, it works if I type: > > python "script name" > > > > But the problem is I want run it by typing "script name" > > > > Thanks for your help. > > You have to call it as follows: > > ./