From dalke at bioreason.com Tue Jun 22 21:19:29 1999 From: dalke at bioreason.com (Andrew Dalke) Date: Tue, 22 Jun 1999 19:19:29 -0600 Subject: It's just magic, and I hate it ... References: <14190.35530.772547.166720@buffalo.fnal.gov> Message-ID: <37703621.B29B72CB@bioreason.com> Mitchell Morris asked: > Are you [Charles G Waldman] saying that this worked for you? Or > was this a guess? I'm going to guess that that was a guess because I was guessing the same thing... I guess. What you described is a classic indication of buffered output. There are three places I can think of where your output could be buffered: 1) in python stdout can be buffered, unbuffered, or line buffered, depending on the situation, eg, if output is a tty or a pipe. That's why you would want to start python with -u since running from the command line is running from a tty while the program talks to the web server using a pipe. To be on the safe side, try calling flush(). 2) in the web server. From the Apache FAQ http://www.apache.org/docs/misc/FAQ.html#nph-scripts that's likely not the case because versions 1.3 and later don't do an intermediate buffer, but you didn't say what web server you are using nor the version number. That documentation may describe what to do. 3) in the client. I don't recall if you have to give a special header to specify that the data should be read and parsed straight up. I've never done this so I don't know what to do next. Andrew dalke at acm.org From jeff at ollie.clive.ia.us Wed Jun 16 10:21:11 1999 From: jeff at ollie.clive.ia.us (Jeffrey C. Ollie) Date: Wed, 16 Jun 1999 09:21:11 -0500 Subject: Python and Netware References: <3764D7EE.4C87@sightline.nl> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- On 14 Jun 1999 10:34:30 GMT, Marc R. Poppenk wrote: > >I'm looking for some one who can give me the answers to these questions: >- Is a Python version for Novell Netware available? By "a Python version for Novell Netware" do you mean a version of Python that will run on the NetWare server itself or do you just mean a version of Python that runs on a workstation running Windows and can access information stored in NDS? In either case, using JPython to access the Novell Java interfaces is likely to be the closest you'll get right now. NetWare 5 includes an implementation of Java that runs on the server, so JPython should theoretically run there since JPython is 100% Pure Java, although I don't know of anyone that has tried it. However the Novell Java interfaces are rather baroque and I found them difficult to use, although I suppose that with JPython you could create some Python wrapper classes. - - Can it be downloaded somewhere? You can find JPython at You can find information on Novell's Java interfaces at . >- Do I have to port Python for Netware myself? I would love to see a module for Python that can access information stored in NDS without using JPython to go through the Novell Java interfaces. Python running natively on NetWare would be cool too, but using JPython with a better interface to NDS would be acceptable to me. I don't have the time or experience to tackle these projects myself, but I'd be more than willing to participate in a group project. >- Does any one have experience with this? I have no experience whatsoever with this, I'm just speculating. [A copy of the headers and the PGP signature follow.] Date: Wed, 16 Jun 1999 09:21:11 -0500 Newsgroups: comp.lang.python Organization: netINS, Des Moines, IA, USA References: <3764D7EE.4C87 at sightline.nl> Subject: Re: Python and Netware -----BEGIN PGP SIGNATURE----- Version: 2.6.2 Comment: AnySign 1.4 - A Python tool for PGP signing e-mail and news. iQCVAwUBN2ey25wkOQz8sbZFAQGf2wP8Cwy9adBsUL+y1j9VqkYLHs9PD9+9EiqF SZAqbR5cxnFIdLlCIvz0gR5hEBq/0UO0F0fsvH6Y6sTBt8NRrP1/6nyDShFbXLL8 HhR9M3eGFH4ffMc14pVjEQHuCNLBbyp3dabAdUouo/ds1cDNuWMgVVMLuKnekLAr VD2eUWVBlpA= =iLgu -----END PGP SIGNATURE----- -- Jeffrey C. Ollie | Should Work Now (TM) From ke at gnu.franken.de Wed Jun 23 15:23:15 1999 From: ke at gnu.franken.de (Karl Eichwalder) Date: Wed, 23 Jun 1999 19:23:15 GMT Subject: glint? References: <376F48B9.133D37C6@phoenix-edv.netzservice.de> Message-ID: Holger Jannsen writes: | I'm working on an installation-tool for linux/win without any | graphical interface but file-controlled. How do you define "installation-tool"? There's "xrpm" that's able to (de)install RPM packages nicely, and more. But "xrpm" has a GUI, too. It comes with SuSE Linux. -- Karl Eichwalder From jam at newimage.com Thu Jun 3 09:55:14 1999 From: jam at newimage.com (jam) Date: Thu, 3 Jun 1999 09:55:14 -0400 Subject: Python & IRC? In-Reply-To: <7j4frp$4e9@journal.concentric.net>; from Christopher Petrilli on Wed, Jun 02, 1999 at 04:48:09PM -0700 References: <7U853.1589$nn.478377@news.shore.net> <7j4frp$4e9@journal.concentric.net> Message-ID: <19990603095514.D21168@toast.internal> On Wed, Jun 02, 1999 at 04:48:09PM -0700, Christopher Petrilli wrote: > > I'll throw in my two cents which is that at some point I hacked out a quick > implementation of the protocol using asynchat, and probably could do so > again, but would rather just say use it :-) It's really a great way to > do this, since IRC has no pipelining, there's really not a concern there, > and async sockets are REALLY low overhead---at least on any real OS :-) > > Chris > ok.. how about a python and asycchat based implementation of a *server* as well? I'd be interested in the client you mentioned.. could you mail it to me, or send along a url? regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From skip at mojam.com Sun Jun 6 15:57:29 1999 From: skip at mojam.com (Skip Montanaro) Date: Sun, 06 Jun 1999 19:57:29 GMT Subject: Deleting characters from a string References: <87n1ye3g4v.fsf@pc-hrvoje.srce.hr> Message-ID: <375AD334.6E45A6C3@mojam.com> > What I would really like to be able to do is write: > > host = string.translate(host, None, ' "') > > Am I missing a more elegant solution? Probably less elegant, but you can use string.replace. You'll have to call it twice to get the spaces and the double quotes: host = string.replace(string.replace(host, '"', ""), " ", "") -- Skip Montanaro | Mojam: "Uniting the World of Music" http://www.mojam.com/ skip at mojam.com | Musi-Cal: http://www.musi-cal.com/ 518-372-5583 From alltube at netscape.net Thu Jun 24 15:33:59 1999 From: alltube at netscape.net (alltube at netscape.net) Date: Thu, 24 Jun 1999 19:33:59 GMT Subject: Python & Tkinter problems... Message-ID: <7ku177$f42$1@nnrp1.deja.com> Hi there, I am trying to run Tkinter (tcl/tk 8.1 I compiled and installed it..) on Solaris 2.6. Python version 1.5.2. The tcl/tk seems to work fine, I was able to run a couple of demos, the TCL_LIBRARY is also set ok, my environment stuff: /usr/local/lib/tcl8.1 $ls auto.tcl http2.0 msgcat1.0 safe.tcl encoding init.tcl opt0.4 tclAppInit.c history.tcl ldAix package.tcl tclIndex http1.0 ldAout.tcl parray.tcl word.tcl /usr/local/lib/tcl8.1 $echo $TCL_LIBRARY /usr/local/lib/tcl8.1 /usr/local/lib/tcl8.1 $ The error I get from Python is: /usr/local/lib/tcl8.1 $python Python 1.5.2 (#5, Jun 24 1999, 14:52:16) [GCC 2.8.1] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import Tkinter >>> Tkinter._test() Traceback (innermost last): File "", line 1, in ? File "/usr/local/lib/python1.5/lib-tk/Tkinter.py", line 1947, in _test root = Tk() File "/usr/local/lib/python1.5/lib-tk/Tkinter.py", line 886, in __init__ self.tk = _tkinter.create(screenName, baseName, className) TclError: Can't find a usable init.tcl in the following directories: This probably means that Tcl wasn't installed properly. >>> The init.tcl is in fact in /usr/local/lib/tcl8.1 and it appears to be ok, I have run a number of tk demo programs... Thanks for any help... Alex. Toronto Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From pduffin at mailserver.hursley.ibm.com Mon Jun 28 08:52:10 1999 From: pduffin at mailserver.hursley.ibm.com (Paul Duffin) Date: Mon, 28 Jun 1999 13:52:10 +0100 Subject: Why is tcl broken? References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> <37682DD3.43923243@compaq.com> <7ka2be$qja$1@nntp6.u.washington.edu> Message-ID: <37776FFA.2D85@mailserver.hursley.ibm.com> Donn Cave wrote: > > Greg Ewing writes: > ... > | In my experience, I find that I can do with Python everything > | that Tcl was designed for, do it more easily, do a lot > | more besides, and have more fun in the process. I believe > | the reason for this is rooted in some fundamental design > | features of these languages, which I have sketched above. > | I think that's about as close as one can get to providing > | an objective argument as to whether one language is better > | than another for a given purpose. > Actually you find that you can do everything that YOU want to in Python and YOU find it easier than doing it in Tcl. I do not believe that you can do everything in Python that you can do in Tcl (at least as regards extending the language itself). > How about Expect as an example? I don't mean to criticize the > existing Python Expect implementation(s), have no idea where the > state of the art is on that. I just remember trying to think of > a natural Python idiom that would replace the "expect" verb's case > switch flow of control. > > My experience is more or less the same as yours - rewrote Tcl > software in Python and was henceforth a convert. But I think > Tcl is syntactically more adaptable, where Python kind of makes > a virtue of its fixed ways. > Correct. With Tcl you can create new control structures which are indistinguishable from the built in ones, you cannot do that in Python. Python is much more rigid in its syntax although it does have a lot of nice hooks to allow objects to behave in different ways. -- Paul Duffin DT/6000 Development Email: pduffin at hursley.ibm.com IBM UK Laboratories Ltd., Hursley Park nr. Winchester Internal: 7-246880 International: +44 1962-816880 From matz at netlab.co.jp Wed Jun 2 21:19:09 1999 From: matz at netlab.co.jp (Yukihiro Matsumoto) Date: 03 Jun 1999 10:19:09 +0900 Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <87pv3iq6ss.fsf@ev.netlab.co.jp> <7iv86a$iud@news.dns.microsoft.com> <87so8bnsd6.fsf@ev.netlab.co.jp> <87pv3eorg4.fsf@ev.netlab.co.jp> Message-ID: <87n1yinks2.fsf@ev.netlab.co.jp> Hisao Suzuki writes: |In article <87pv3eorg4.fsf at ev.netlab.co.jp>, |Yukihiro Matsumoto wrote: |> BTW, did I say Ruby can invoke arbitrary destructors specified by |> arbitrary users? It can't. | |Is this your mental premise in your opinion about garbage |collection? Then, the unpredictability might not be matter at |all... I was talking about real GC in general. I was saying real GC does not fall into unpredictable automatically. As for Python, I agree with your statement in : |Even if Python has "real" GC someday, IMHO, the GC should be |used only to imitate infinite resources. For the sake of |conceptual simplicity, the future Python should still use |reference counting both to invoke __del__ methods and to free |storages; the GC routine should be used as the last resort. matz. From meowing at banet.net Mon Jun 14 23:03:32 1999 From: meowing at banet.net (greg andruk) Date: 14 Jun 1999 23:03:32 -0400 Subject: Created a Python module for ID3 MP3 tag manipulation References: <87g13vy05d.fsf@slip-32-100-55-159.ma.us.ibm.net> Message-ID: <87lndmrwqj.fsf@banet.net> Ben Gertzfield writes: {parsing MPEG audio} > Is there a simple way to do this? What kind of scanning does it > involve? Well, it's in that other P language, but here's an example: (About 3K) From aahz at netcom.com Thu Jun 3 14:14:23 1999 From: aahz at netcom.com (Aahz Maruch) Date: Thu, 3 Jun 1999 18:14:23 GMT Subject: Alien whitespace eating nanovirus strikes again! References: <375500C9.742DC539@pop.vet.uu.nl> <375536C2.DD917F99@prescod.net> <19990602132331.A281155@epa.gov> Message-ID: In article <19990602132331.A281155 at epa.gov>, Randall Hopper wrote: > >If I was still locked onto vi, it'd be a pain, and I can see that being an >issue with some editors. Though with emacs, there's rectangular kill >(^Xrk) and block indent/dedent (^X^I) -- key sequences I use without even >thinking anymore. I am still locked into vi. ;-) But even that aside, it'd still be annoying to make sure to [in|out]dent precisely the correct number of lines. -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het "NRE is a lot like cocaine. Feels great while you're on it, makes you feel very special and talented, and you become highly annoying to those who aren't on it." -- Stef From davecook at home.com Fri Jun 25 23:09:41 1999 From: davecook at home.com (David M. Cook) Date: Sat, 26 Jun 1999 03:09:41 GMT Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> Message-ID: On Fri, 25 Jun 1999 18:00:22 GMT, Mikael Lyngvig wrote: > [...] Unfortunately, TkInter appears to run sluggish [...] That and the widget selection just doesn't cut it anymore. I'm using pygtk these days, but it only runs on unix right now. Dave Cook From larsga at ifi.uio.no Thu Jun 10 12:17:19 1999 From: larsga at ifi.uio.no (Lars Marius Garshol) Date: 10 Jun 1999 18:17:19 +0200 Subject: Why is tcl broken? References: <375F82C7.CF0F0477@iname.com> Message-ID: * Fernando Mato Mira | | I'm trying to collect a list of all the _current_ issues making tcl | a bad language choice. You can find three interesting articles on this at --Lars M. From fdrake at cnri.reston.va.us Thu Jun 17 12:47:56 1999 From: fdrake at cnri.reston.va.us (Fred L. Drake) Date: Thu, 17 Jun 1999 16:47:56 GMT Subject: Python Webserver In-Reply-To: References: <3767A69D.50DC7FBF@serop.abb.se> Message-ID: <14185.9916.984708.453488@weyr.cnri.reston.va.us> Lars Marius Garshol writes: > There's a very simple one in the standard distribution (actually, more Thanks to Moshe Zadka, these will be documented in the next release of the documentation. Thanks, Moshe! -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From avv at quasar.ipa.nw.ru Wed Jun 30 20:03:12 1999 From: avv at quasar.ipa.nw.ru (Alexander V. Voinov) Date: Wed, 30 Jun 1999 17:03:12 -0700 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> <3773c3a0.102825445@news.oh.verio.com> <7laovo$c4s$1@Starbase.NeoSoft.COM> <377A24B7.AD6FAA1A@cfdrc.com> <377A9796.176DA97E@quasar.ipa.nw.ru> Message-ID: <377AB03F.B55DF35B@quasar.ipa.nw.ru> "Alexander V. Voinov" wrote: > I installed it on Red Hat 6.0. I failed to recompile it without Mesa, but > even with it, it complains as follows: > > [avoinov at dhcp101 tests]$ python window.py > Traceback (innermost last): > File "window.py", line 1, in ? > from FXPy import * > File "/usr/lib/python1.5/site-packages/FXPy/__init__.py", line 1, in ? > from fox import * > File "/usr/lib/python1.5/site-packages/FXPy/fox.py", line 2, in ? > import foxc > ImportError: /usr/lib/python1.5/site-packages/FXPy/foxcmodule.so: undefined > symbol: glXQueryExtension > > It happens both with Mesa-3.0 (Nov 98) and some Mesa-3.1beta, found in > RedHat contrib. Sorry, it was my fault. If you have Mesa installed it compiles out of box. Cross-platform transparency is fantastic: I have two windows on the same screen: 1. Native win32 FXPy example 2. The same run on a Linux box and displayed via eXceed. The only differences I see and feel are cosmetical: the icons in the left corner and the style of the default system font (medium/bold). Alexander From tim_one at email.msn.com Mon Jun 14 20:54:30 1999 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 14 Jun 1999 20:54:30 -0400 Subject: Solution to finalisation problem [Re: fork()] In-Reply-To: <7k3mtg$65t$1@cronkite.cc.uga.edu> Message-ID: <000301beb6c9$a01d2960$b2a22299@tim> [Greg Ewing] > Indeed, which leads me to believe that the idea of giving objects > a __del__ method is fundamentally flawed in the first place. [Tim] > Except it works so nice in "the usual" case (no cycle, no resurrection): > everyone agrees on what should be done then, and it's remarkably > surprise-free! [Graham Matthews] > The problem with this argument Thought of it as an observation; unless there's some argument about what to do in the absence of cycles that everyone has been too shy to make here . > Tim is that is is very difficult for the programmer to recognise when > they are in "the usual case", since circular references are easy to > create. Hence it is very difficult for the programmer to verify the > correctness of their code. "is" is too strong in both cases. "can be" I'll buy. In the majority of classes I've written or seen, it's obvious that instances can never be part of a cycle -- or, more rarely, obvious that they can be. Does get muddier over time with "big classes", though (e.g., the implementation of IDLE appears to be growing more cyclic relations over time, and that's not unusual). > ... > No cycles are not the problem. The problem is that finalisers are run in > "incomplete contexts". *A* problem I buy; not "the". > These incomplete contexts arise because implementations of GC delete > or partially delete collected objects before calling finalisers. > That is a mistake. Insert "some" after "because" & I agree. > If you run *all* finalisers of *all* collected objects before you > actually delete or partially delete any of those objects then all > finalisers run in well defined contexts and there are no problems > with finalisers. Sure there are: finalizers in cycles remain largely useless in practice without a way to specify the order in which they're invoked. Go back to the Java part of the thread. The language can't know whether a cycle needs to be finalized in a particular order, or, if it does, what that order may be. In Java this has nothing to do with partial deletion: the spec is very clear that the implementation must guarantee that all objects reachable from a finalizer are wholly intact when the finalizer is run. What it doesn't say-- because it can't --is that all objects reachable from a finalizer will be in a "useful" state. That's left on the programmer's head, and when e.g. child and parent can be finalized in either order or even simultaneously, correct non-trivial finalizers are jokingly difficult to write. The Scheme guardian gimmick at least attempts to address this, by never finalizing anything by magic, leaving it up to the programmer to explicity ask for an enumeration of the currently-finalizable objects and nuking them or not however the programmer sees fit. If a cycle needs special treatment, it's up to the programmer to realize that a cycle exists and "do the right thing" by their own lights. The language doesn't help, but at least it doesn't get in the way by doing a wrong thing either; it simply doesn't do anything at all. > That is the point of two pass collection. Understood the first time; but if finalizers are to be invoked on cycle members, that's just necessary, not sufficient. a-problem-isn't-solved-until-the-users-agree-ly y'rs - tim From harryt at gte.net Fri Jun 4 10:41:59 1999 From: harryt at gte.net (Harry Tanovich) Date: Fri, 04 Jun 1999 14:41:59 GMT Subject: pyGTK on Windows References: <3757D453.A302E757@interar.com.ar> <037b01beadf5$8b5d1a80$f29b12c2@pythonware.com> Message-ID: <3757E7A4.F89DE04E@gte.net> Fredrik Lundh wrote: > Nahuel wrote: > > Hi, im about to do a cross-plataform GUI application in Linux and > > Windoze... i must > > choose the GUI toolkit.. my question is .. can i use pyGTK under > > Windows??? > > > > (I need a gui that can display a table with about 4000 lines without > > crashing (not like Tk :)) > > you do mean 4,000,000 lines, don't you? > > or did you use a seriously broken version of Tk(inter)? > > after all, if it's a bug in your program, changing the UI > toolkit won't help... > > What grid widget is in question? From news at dorb.com Fri Jun 25 17:31:15 1999 From: news at dorb.com (Darrell) Date: Fri, 25 Jun 1999 17:31:15 -0400 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> <3773EE44.F231F1E4@otenet.gr> Message-ID: <_ASc3.2630$U6.11110@newsr2.twcny.rr.com> Is this more trouble than learning tkinter and or wxPython ? I just installed and gave the jpi thing a try. It's not ready for prime time yet. -- --Darrell From sjoshi at ingr.com Thu Jun 24 09:27:07 1999 From: sjoshi at ingr.com (sjoshi at ingr.com) Date: Thu, 24 Jun 1999 13:27:07 GMT Subject: Question - Returning exit codes Message-ID: <7ktbmu$5os$1@nnrp1.deja.com> Hello All I'm calling my python program from a perl script using the system command. I was wondering what would be the best way to return exit codes from my python script so that they can be intercepted in the perl program. thanks Sunit Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From tim_one at email.msn.com Thu Jun 3 01:30:17 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 3 Jun 1999 01:30:17 -0400 Subject: Idle comments In-Reply-To: <7j3u7h$45j$2@hub.org> Message-ID: <000d01bead82$2a2564c0$309e2299@tim> [Ragica, zzz at NO-MAIL.com, which means he'll probably never see this since the mail->news gateway is down] > I too have posted before asking about how to change the blinding > (to me) IDLE background colour... and have seen your previous post > also (and watched avidly for a response to it, as my message got no > responses... but neither did yours). > > So hopefully someone anwsers this mystery this time! Just to let > you know that there are others with the same problem who want to > use IDLE but can't figure out how to change the background colour > to something tolerable.... Well, it's *Python* code: you look in the source, find where it sets the colors, and change 'em to whatever you want. If you grab the development IDLE off the CVS repository at python.org, you'll find that it now has a IdlePrefs.py file containing a ColorPrefs class you can fiddle more directly (but nothing in the development tree is ready for general use -- that's why it's a development tree ). start-changing-one-color-and-you'll-end-changing-'em-all-ly y'rs - tim From graham at sloth.math.uga.edu Tue Jun 1 11:37:05 1999 From: graham at sloth.math.uga.edu (Graham Matthews) Date: 1 Jun 1999 15:37:05 GMT Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7iqhkb$d7s@wiscnews.wiscnet.net> <7iu7ma$d33$1@cronkite.cc.uga.edu> <007901beac05$5c964b00$f29b12c2@pythonware.com> Message-ID: <7j0un1$2dm$2@cronkite.cc.uga.edu> Gang Li (gangli at msn.com) wrote: : Python is a real programming language. We should not turn it in to a Java : extension. I hate someone just want to take Python to Java mass and say 'me : too'. Perl, Tcl/Tk, and Smalltalk have no plan to turn themselves in to a : Java extension. Why Python? If you love Jave to death, spent all your : time to help sun conquer the world. Don't mess with Python. Graham Matthews wrote: > You are envangelising (a not uncommon response when someone remotely > criticises Python). Fredrik Lundh (fredrik at pythonware.com) wrote: : read his message again. he's saying that Python : shouldn't be tied to Java. sure looks like a tech- : nical argument to me. I suggest you read his post again Fredrik. The only "reasons" he offers for why Python shouldn't be "tied to Java" are all hyperbole and evangelism. No technical content whatsoever. Graham Matthews wrote: > Stop evangelising and start considering the technical > issues involve (read (!) other posts for what those issues > are). Fredrik Lundh (fredrik at pythonware.com) wrote: : exactly. and since you seem to imply that you have con- : sidered those issues, maybe you should follow up on some : of the "non-envangelising" posts instead of miscrediting : people who don't happen to agree with you? I have followed up Fredrik -- cf. posts on classes of references (some compactable, some not), colouring mark and sweep collectors, JNI, etc. But then again I should have known better than to start such a thread. graham -- This mountain is not visible from any inhabitable place. It has no name, and since it's discovery in 1856 by a British survey team, it has mysteriously resisted every attempt to name it. The mountain is known simply and starkly by it's original designation on the surveyor's map ... K2. From mnot at pobox.com Tue Jun 22 08:48:21 1999 From: mnot at pobox.com (Mark Nottingham) Date: Tue, 22 Jun 1999 12:48:21 GMT Subject: htmllib: CR in CDATA References: <00d201bebc5a$adb129a0$0301a8c0@mnot.net> <012601bebc91$f3ded760$0301a8c0@mnot.net> <014401bebc9a$1963a9e0$0301a8c0@mnot.net> <000b01bebca0$8a022c20$f29b12c2@pythonware.com> Message-ID: <017501bebcad$830a3180$0301a8c0@mnot.net> > well, htmllib doesn't claim to be HTML 4.0 compliant... But it does claim 2.0: """HTML 2.0 parser. See the HTML 2.0 specification: http://www.w3.org/hypertext/WWW/MarkUp/html-spec/html-spec_toc.html """ Fine. Now, if we have a look at http://www.w3.org/MarkUp/html-spec/html-spec_9.html#SEC9.1 we'll see that attributes are marked as CDATA. Unfortunately, I don't have a copy of the SGML specification, so I can't definatively say that this is the proper way to treat CDATA; all I have is the description in the HTML 4.0 docs, as previously referenced. So, it's probably not a good idea to patch this in sgmllib.py (as I did). However, it is IMHO reasonable to conclude that, since both 2.0 and 4.0 refer to SGML for the definition of CDATA, we can apply what we know about it from one to the other (SGML being a fairly stable spec AFAIK). I'm certainly willing to admit that this isn't directly specified behaviour for a 2.0 parser, but I still think it's the Right Thing. A a practical level, I'm parsing HTML with these constructs in it; if I pass off an HREF to httplib that has a newline in it, all sorts of bad things happen. I've ended up calling a cleaning function each time I parse attributes in my subclassed parser; this does the job nicely. However, IMHO this sort of lexical processing/second guessing shouldn't be necessary by the user of a parser. > ...and it doesn't claim to be a "user agent", either... *sigh* Do we _really_ want to take a trip down this semantic rabbit warren? In HTML 2.0-land, user agent is: A component of a distributed system that presents an interface and processes requests on behalf of a user; for example, a www browser or a mail user agent. Now, htmllib certainly: * is a component * part of a distributed system (i.e., the Web) * presents an interface (programmatic) * processes requests on behalf of a user I'm curious... if it's not a user agent in the quoted context, what is it? From pduffin at mailserver.hursley.ibm.com Fri Jun 11 07:59:27 1999 From: pduffin at mailserver.hursley.ibm.com (Paul Duffin) Date: Fri, 11 Jun 1999 12:59:27 +0100 Subject: Why is tcl broken? References: <375F82C7.CF0F0477@iname.com> <375FF969.C879B4CD@iname.com> <37601668.D9105225@mayo.edu> <3760E130.7456447@iname.com> Message-ID: <3760FA1F.7BCD@mailserver.hursley.ibm.com> Fernando Mato Mira wrote: > > Bob Techentin wrote: > > > These flame wars are more than five years old. Tcl has had namespaces > > and a byte-code compiler for years. > > I know that. But I see some serious things there (the `call by name' issue, > for example) that give me the impression must be still around unless > the semantics have gone through a major change. > > I would cut this thread right here before someone comes up > with some myth. There's enough work for debunkers there. > > Thanks, Tcl does not have 'call by name' semantics. In fact its calling semantics are remarkably like C's. C only supports call by value Tcl only supports call by value In C if you want to pass a "reference" you pass a pointer In Tcl if you want to pass a "reference" you pass a variable name "Call by name" has some very particular characteristics the main one being that you cannot implement "swap". I can assure you that you can write a swap function in Tcl. proc swap {&a &b} { upvar ${&a} a upvar ${&b} b set t $a set a $b set b $t } -- Paul Duffin DT/6000 Development Email: pduffin at hursley.ibm.com IBM UK Laboratories Ltd., Hursley Park nr. Winchester Internal: 7-246880 International: +44 1962-816880 From matz at netlab.co.jp Tue Jun 1 02:59:59 1999 From: matz at netlab.co.jp (Yukihiro Matsumoto) Date: 01 Jun 1999 15:59:59 +0900 Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <87pv3iq6ss.fsf@ev.netlab.co.jp> <3752C76D.604CD474@prescod.net> <87n1ykr0z9.fsf@ev.netlab.co.jp> <375372F6.A874554@prescod.net> Message-ID: <87hfosquc0.fsf@ev.netlab.co.jp> Hi. Paul Prescod writes: |> >As many people have noted before, you would not be able to use |> >destructors to free up resources like memory or file descriptors. |> |> which, as I understand, means destructors can not be used with real |> GC. That's just not true. | |Is there a language with real GC where destructors are called as |predictably as they are in Python? I said nothing about the destructor invocation predictability. I don't understand and really interested in why you guys require to predict destructor invocation so much, but it's another story. |> >From my experience with Scheme and Ruby, both with real GC, the real |> GC is mostly very fast. | |Speed wasn't my concern. I asked about references in C code. Do we use |PyObject **s instead of PyObject *s now? Sorry, I don't understand. Do we have to use PyObject **s instead of PyObject *s, if we choose real GC? |> Do you really mean Python the object-oriented programming language |> rarely treat complicated data structures? | |No, I said that Python is optimized for basic users, not for the experts. |The experts can figure out how to work around problems. The beginning |users cannot. "I'm opening all of the files in a directory in a loop and |in large directories I get out of file handle errors." First, it's not the straight result from real GC. For exapmle, Ruby uses real GC, and starts GC automatically on that situation. No problem arise. It's totally a implementation matter. Second, do you think that optimization for basic users compensates the risk of potential memory leak, by cyclic structures or missing DECREF in extension modules? Do you mean it's easy for experts to find cyclic structure and cut their reference to destruct? For me, it's not. I hate that. Is this because I'm not a Python expert? matz. From tim_one at email.msn.com Sat Jun 26 13:48:15 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 26 Jun 1999 13:48:15 -0400 Subject: total idiot question: +=, .=, etc... In-Reply-To: Message-ID: <000001bebffc$12060200$da9e2299@tim> [Tim] > ... any OO language with declarations has to allow local vars to > shadow instance vars, else method implementations can be broken by > trivial changes in far-removed superclasses [Reimer Behrends] > To the contrary; Eiffel, under no circumstances allows shadowing of > instance variables by formal parameters or by local variables. Let me ammend that, to "any OO language with declarations has to ..." . Eiffel allows inherited features to be accessed under local alias names as if the original name never existed (its "rename" clauses), so it has *a* way to recover locally from trivial superclass name changes. Java (& most other languages) take a different approach. > Yes, changing stuff in a superclass can thus break code in a subclass; but > this can always happen (like if you add a new method that also exists in > a subclass). Doing a major internal change to a superclass requires at > least rechecking subclasses, anyway. I did say "trivial". A purely local way of addressing this is vital: the subclass author may not be able to change the superclass code, or may not even have read access to its source code; in the other direction, a superclass author may have no idea who subclasses from them. Eiffel and Java both "work" in this respect, albeit thanks to different gimmicks. > (And I prefer compilers that are too picky rather than too lenient.) Excellent! Me too. So we're both strongly in favor of Python making you explicitly identify your instance vars with a "self." prefix . [Java shadowing] > Can you point me to the place in the Java language specification where > this is said? I'm asking, because I've heard that, too, but haven't ever > been able to find it and because the JDK happily allows to me shadow > instance variables left and right. I'm not sure what happened after the various forms of inner/nested classes were introduced. The full story in the original JLS is spread out all over the place, most of which can be tracked down by following the index's "hiding" entry. Curiously, that *doesn't* point you to section 14.3.2, which prohibits shadowing of locals by other locals or exception parameters. It does generally allow shadowing of class and instance names, but sometimes in the sense of allowing *potential* ambiguity provided that an ambiguous name isn't actually referenced. In the latter cases, Eiffel requires local renaming of ambiguous inherited names, while Java requires explicit qualification. You can probably guess which I generally prefer . >> Readability is more important to me over the long haul. > Huh? Where have I said otherwise? I just happen to think that these two > goals are not mutually exclusive. And there should be a better solution > than the language ordaining a strange kind of Hungarian notation. The C++ conventions I mentioned were a strange kind of Hungarian; "x.y" is just the way Python *always* spells "give me the value of attribute y in x's namespace", whether x is a module, class or instance object. Consistent, explicit & obvious, given Python's modeling of modules, classes and instances *as* namespaces. >> Say what you like, but which vars belong to the instance is screamingly >> obvious the instant you see >> >> self.x = self.y + k >> >> while in >> >> x = y + k >> >> it's at best a minor puzzle and at worst a long & tedious grep project. > I tell you what--I have this great idea for an addition to Python. You > know that you often can't tell what type a variable is? Well, we could > introduce the following convention: > > Require variables to be prefixed with "$" to denote scalar > values--strings and integers, "@" for lists, and "%" for > dictionaries. > > Given the precedent of having to use self to access instance variables, > this is entirely consistent with the current language, and is going to > eliminate all those nasty problems where you can't tell from the context > what the type of a variable or function is. :) > > Tongue-firmly-in-cheek-ly yours, Reimer Seriously, languages rarely start out doing things that are insane within their own worldview. Perl would be *much* harder to work with in the absence of those $@%& thingies! Array vs scalar is an ubiquitous magical distinction in Perl that affects semantics in crucial ways, and without the $@ decorations you'd be left with no way to determine the intent of a line; e.g., x = split; That does wildly different things depending on whether x is a scalar or an array, so "$x" vs "@x" is a crucial clue. Python doesn't have that kind of context sensitivity, and doesn't build up complex data structures out of explicit chains of scalar references either (and again you need the $%@ thingies to dope out what a chain of Perl *dereferences* is doing). So the decorations solve a problem in Perl that Python doesn't have, so they make good sense in Perl but not in Python. Python's object.attr notation solves Python's problem: with respect to which namespace is attr to be resolved? Christian Tismer once suggested that Python take that another step, and require that e.g. def f(x, y): global sum1, sum2, total sum1 = x sum2 = y total = x + y instead be written def f(x, y): global.sum1 = x global.sum2 = y global.total = x + y I think that's a fine idea too. I'd even go a step toward Perl and make mapping objects use "{}" for indexing instead of "[]". Stop me before I sin . not-eager-to-trade-instant-certainty-for-potential-confusion-unless- the-confusion-is-helpful-ly y'rs - tim From akuchlin at mems-exchange.org Thu Jun 10 10:10:22 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: Thu, 10 Jun 1999 10:10:22 -0400 (EDT) Subject: fork() In-Reply-To: <5laeu8zmza.fsf@eric.cnri.reston.va.us> References: <000601beb1c7$682c6220$559e2299@tim> <7jjghd$9il$1@cronkite.cc.uga.edu> <375D5826.23197692@inrialpes.fr> <375D6C60.FF9998DE@appliedbiometrics.com> <5laeu8zmza.fsf@eric.cnri.reston.va.us> Message-ID: <14175.51022.577016.265867@amarok.cnri.reston.va.us> Guido van Rossum writes: >(You can create a cycle using only lists, but I bet that happens only >for demonstration purposes, as in ``a = []; a.append(a)''. So I can >live with not freeing such cycles.) I'm doubtful of that argument; I've written classes which track all instances that get created, and this can be done with a class attribute containing a list, that gets mutated as instances are created. You reconsider this decision later in your post. In this solution, I don't understand how Python would keep track of all the dictionaries that get created, in order to determine which ones are left unreachable, and hence can be garbage collected. >From my memory of the Jones-Lins book, this is usually handling by doing all the allocation yourself by slicing memory into chunks, and then sweeping through it. It's not obvious (to me, at least) how you'd do this with objects created by malloc(). Perhaps lists and dictionaries could contain prev/next pointers that are used to maintain them in a doubly-linked list, and a linear-time traversal would be done to find unmarked objects, but there has to be a better way. -- A.M. Kuchling http://starship.python.net/crew/amk/ Should I not have changed either the day for carrying out my scheme, or the scheme itself -- but preferably only the day? -- Ovid, _The Metamorphoses_ From tismer at appliedbiometrics.com Sun Jun 27 19:41:41 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Sun, 27 Jun 1999 23:41:41 GMT Subject: GC In Python: YAS (Yet Another Summary) References: <000301bebffc$184fcf60$da9e2299@tim> <3776A025.53B35103@inrialpes.fr> Message-ID: <3776B6B5.D74616F8@appliedbiometrics.com> Vladimir Marangozov wrote: > > A not very modest plug > > Tim Peters wrote: > > > > [Andrew Dalke, worries about Boehm collection vs Fortran] > > ... > > Despite all that, it would probably work fine for you. I think it's a dead > > issue here regardless, though, because Guido isn't going to tell anyone they > > have to use a particular routine for memory allocation. Python could use > > its own malloc for its own objects (& Vladimir Marangozov has written a very > > nice PyMalloc, available from his Starship page), but > > Thanks for the compliment, but ... > > > that breaks down as soon as any extension has its own view of how to get memory. > > I can't let you say this (heh, it's too late ;-) because you seem to > overlook one of the nicest features of pymalloc. If the extension module > works in current Python + libc malloc, it will work with Python + > pymalloc > because of the dynamic block management. IOW, if one recompiles the core > with pymalloc instead of the usual libc malloc, everything should work > as before, even *without* recompiling any extension or 3rd party > modules. It is a great concept to catch just one aspect (as in you case, small blocks) and leave the rest as it was. > The concept is simple, but useful. I told you that pymalloc is tricky > ;-) Welcome in the club. You know what me thinks of tricky code ;-) ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF About to publish true continuations which are very tricky. Pah! From dkuhlman at netcom.com Sun Jun 13 16:36:58 1999 From: dkuhlman at netcom.com (G. David Kuhlman) Date: Sun, 13 Jun 1999 20:36:58 GMT Subject: Module magic methods References: Message-ID: Michael Hudson (mwh21 at cam.ac.uk) wrote: > > You know that, in general, modules aren't unloaded, except at > interpreter shutdown time? And then the execution state is so > unpredictable you can't really do anything? > > HTH > Michael > Witticisms by Dave: "Questions on comp.lang.python are like clothes hangers in your closet. You try to pull out one, and twenty come tangled to it." Maybe, in general, modules aren't unloaded. But what if I do: import mymodule # # Do some stuff with mymodule # mymodule = None Won't reference counting cause the space taken up by mymodule to be garbage collected? I hope so, because, where I work, this is what I'm going to tell them to do when they want to reclaim space in long running programs. [Pause for thought and experimentation with Python ... ] Oops. Wait a minute. What if I create an instance on of class defined in mymodule: anInstance = mymodule.MyClass() mymodule = None anInstance.show() Something must stay around so that I can call the methods defined MyClass. [Pause for more heavy thinking in a light-weight brain ...] OK, then what about after all the reference counts for instances of mymodule go to zero? anInstance = None - Dave From greg.ewing at compaq.com Thu Jun 24 18:25:55 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Fri, 25 Jun 1999 10:25:55 +1200 Subject: total idiot question: +=, .=, etc... References: <877lov62z1.fsf@pbl.ddns.org> <8L_b3.1213$4s.136166@typhoon-sf.snfc21.pbi.net> Message-ID: <3772B073.B0C637F6@compaq.com> Reimer Behrends wrote: > > To remind you, pretty much every single OO language other > than Python does not require you to add a self; And in some of those languages, some people have resorted to naming conventions to keep the various scopes under control. In the Object Pascal version of MacApp, for example, Apple adopted the convention of prefixing the names of all instance variables with "f" (for "field"). Mind you, Apple's Object Pascal is a somewhat pathological case, since it's scope rules for instance variables and local variables are, shall we say, rather unintuitive... Greg From cgw at fnal.gov Fri Jun 25 16:46:30 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Fri, 25 Jun 1999 20:46:30 GMT Subject: faking HAVE_LARGEFILE_SUPPORT Message-ID: <14195.60070.164177.1422@buffalo.fnal.gov> I am building and testing software on Linux which will eventually be deployed onto a variety of systems, including OS's with large filesystem support. I need to be sure that all of the code (some of which is C extension modules) is prepared to handle python Long integer objects as file sizes and offsets - for instance some of the C code naively does a PyArg_ParseTuple(args, "i", &file_size) which works fine as long as the file size is a plain int. For testing purposes, I've modified config.h after running ./configure, so that the symbol HAVE_LARGEFILE_SUPPORT is #defined. This allows me to continue testing on Linux, and be fairly sure that there will be no surprises when I run the code on an SGI or Solaris machine. Since this feature is useful, I've started building Python this way all the time. It seems to run fine, I haven't run into any trouble. I'm wondering if there's some hidden pitfall that I haven't thought of. From MHammond at skippinet.com.au Wed Jun 2 08:35:41 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Wed, 2 Jun 1999 22:35:41 +1000 Subject: need help checking for stack overflow in Win32 References: <5lk8to3su3.fsf@eric.cnri.reston.va.us> <7j1pcc$256$1@m2.c2.telstra-mm.net.au> <375502C7.39C4FD0E@appliedbiometrics.com> Message-ID: <7j4d2i$7jf$1@m2.c2.telstra-mm.net.au> Christian Tismer wrote in message <375502C7.39C4FD0E at appliedbiometrics.com>... >Nope. The trap is: >You compiled with VC++ 6.0 which has better register spilling. >Therefore, recusion costs only 100 bytes, not 104. >Not calculate 104 * 10000 and you see why 1 MB stack >lets it crash. Cool. Thanks. But doesnt the fact remain that counting the recursion depth is dangerous? Im thinking of embedded environments, where a) the stack size of the hosting .exe can't be known and b) the stack used by the app before Python is even called can't be determined. Add to this callbacks in GUI and COM type applications, and we seem to be applying more band-aids. The idea of counting space used seems better, but still assumes a known stack size. >I submitted a patch program for this kind of >problems, so I think there is no need to change >Python 1.5.2 at all. Huh? Are you suggesting people continue to build from sources, then run your script to get an "official" version? Wouldnt it be better to get Guido to apply these changes to the build process? You have provided an excellent interim fix, but IMO the problem remains. Mark. From fredrik at pythonware.com Mon Jun 14 06:04:46 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 14 Jun 1999 10:04:46 GMT Subject: broken References: <1282792849-95706075@hypernet.com> <3764D7C3.718E125E@iname.com> Message-ID: <002f01beb64d$58e7b5f0$f29b12c2@pythonware.com> (posted and mailed) > Don't go into a flame war. I don't know ANY language that > is not `broken' somehow, even my favorite ones or the ones > that are not my favorite but that are also `good'. as far as I can tell, you haven't even mentioned Python in any of your posts to comp.lang.python and the python language mailing list. sure looks like the usual cross-posting time-wasting usenet troll to me, but maybe someone is abusing your user account? ... if you really are interested in Python, why not read the news- group and language FAQ's, and come back when you have some- thing relevant to ask or say. you'll find the necessary resources at: http://www.deja.com/getdoc.xp?AN=488749782&fmt=text http://www.python.org/doc/FAQ.html you'll find Python source code, documentation, and lots of other community resources at: http://www.python.org why not give it a try? ... on the other hand, if you're not interested in Python, maybe you could stop wasting our time? From Nathan.Clegg at p98.f112.n480.z2.fidonet.org Tue Jun 29 21:24:51 1999 From: Nathan.Clegg at p98.f112.n480.z2.fidonet.org (Nathan Clegg) Date: Wed, 30 Jun 1999 02:24:51 +0100 Subject: printing with print Message-ID: <000015ba@bossar.com.pl> From: Nathan Clegg > Angus MacKay wrote: >> foo = 2 >> print "hi" + foo How about: print "hi" + `foo` ---------------------------------- Nathan Clegg nathan at islanddata.com From alex at monsoon.swcp.com Sun Jun 13 01:51:59 1999 From: alex at monsoon.swcp.com (alex at monsoon.swcp.com) Date: 12 Jun 1999 23:51:59 -0600 Subject: High performance Python on NT References: <000301beb3b7$4f973810$6eba0ac8@kuarajy.infosys.com.ar> Message-ID: "Bruno Mattarollo" writes: > I am about to start a project where I will need to do some high > performance Web CGI scripts on WinNT ... I have no choice ... I know > it's not the best combination. It's not my decision ;-) I am looking > for some advice. Is it better if I use some kind of Active Python > Scripting Page (ASP but with Python)? Or just doing CGI with threads > it will be fine... ? CGI is simply not high performance. If you throw enough hardware at it, I can be OK, but if you are getting a large amount of hits, the overhead of starting Python interpreter (or Perl or whatever) every time a script is head, is going to kill you. PHP as an Apache module is a speed demon. As was suggested already, look closely at Zope (www.zope.org) or the components Zope is built from. It uses a daemon for the python interpreter, thus elimiting the overhead of CGI. I was doing a test last night on Zope, and it easily handled several hits per second on my old P133 linux box. -- Alex Rice | alrice at swcp.com | http://www.swcp.com/~alrice Current Location: N. Rio Grande Bioregion, Southwestern USA From phd at emerald.netskate.ru Tue Jun 15 04:32:03 1999 From: phd at emerald.netskate.ru (Oleg Broytmann) Date: Tue, 15 Jun 1999 12:32:03 +0400 (MSD) Subject: Looking for modules? Config files? Ini files? in python.... In-Reply-To: Message-ID: Hello! On Tue, 15 Jun 1999, Benjamin Schollnick wrote: > I'm trying to find a simple method to deal with *.INI or other styles > of > configuration files.... > > I haven't seen anything, and would hate to re-invent the wheel.... > > Any suggestions? Goto http://memebers.xoom.com/phd2/Software/Python/ http://www.fortunecity.com/skyscraper/unix/797/Software/Python/ Look into "Flat ASCII Database and Config files modules". > Benjamin Oleg. ---- Oleg Broytmann Netskate/Inter.Net.Ru phd at emerald.netskate.ru Programmers don't die, they just GOSUB without RETURN. From greg.ewing at compaq.com Sun Jun 13 18:19:04 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Mon, 14 Jun 1999 10:19:04 +1200 Subject: Newbie class questions References: Message-ID: <37642E58.737D5A39@compaq.com> Toby Kelsey wrote: > > (1) Is there a reason why I cannot call MyClass.q()? Why require a > meaningless instance arg to a class-static method? There is no such thing as a class-static method in Python. (There used to be, but Guido noticed that we were using them and put some code in to stop them from working :-) There are workarounds, but most of the time it's simpler and clearer just to use a module-level function instead. Greg From gmcm at hypernet.com Thu Jun 10 09:54:22 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 10 Jun 1999 08:54:22 -0500 Subject: global vars? In-Reply-To: <375E4332.645E6BBF@phoenix-edv.netzservice.de> Message-ID: <1283099378-77267406@hypernet.com> Holger Jannsen writes: > Why do I have to declare that variable again as global in that > class-procedre (with : global PREDEFINED_PROGDIR)? > If I don't do that the value of that variable outside of that > procedure is the old one. > It seems that python takes a global variable inside a procedure in a > class but not outside. Without some code to demonstrate your confusion, it's difficult to guess exactly why you're feeling confused. In both cases, changing the binding of a global variable requires a "global" statement within the function / method. Without that statement, Python takes an assignment to the variable (a binding) to be local in scope (that is, it's a new variable that exists only within the function / method). This does not apply to reading a variable - Python will search first the locals, then the globals. So you can modify a mutable variable (eg, append a string to a global list of strings) without a "global" statement. The binding of the global variable (the name -> object binding) is not changed, so the rule doesn't apply. So in your case, the different behaviors are due to something else you're doing, not to the fact that one is in a function and the other in a method. - Gordon From clarence at silcom.com Thu Jun 24 10:28:30 1999 From: clarence at silcom.com (Clarence Gardner) Date: Thu, 24 Jun 1999 14:28:30 GMT Subject: It's just magic, and I hate it ... References: <14190.35530.772547.166720@buffalo.fnal.gov> <37703621.B29B72CB@bioreason.com> Message-ID: Mitchell Morris (mgm at unpkhswm04.bscc.bls.com) wrote: : As much as I hate to admit I'm an idiot, I got caught by the simplest of : things. When the child forks, it inherits all the open file descriptors of : the parent ... which includes sys.stdin and sys.stdout. Since these two (at : least) are attached to the socket from the browser, the browser doesn't : follow the redirect until *ALL* the fds close. : : My new question is how do I close all the connections to the browser after : the fork? The obvious: : sys.stdin.close() : sys.stdout.close() : sys.stderr.close() : didn't get them all, since the browser continues to wait. Is there a : mechanism to determine all opened files? I had the same problem a while ago, which resulted in FAQ #4.87: 4.87. Why doesn't closing sys.stdout (stdin, stderr) really close it? Python file objects are a high-level layer of abstraction on top of C streams, which in turn are a medium-level layer of abstraction on top of (among other things) low-level C file descriptors. For most file objects f you create in Python via the builtin "open" function, f.close() marks the Python file object as being closed from Python's point of view, and also arranges to close the underlying C stream. This happens automatically too, in f's destructor, when f becomes garbage. But stdin, stdout and stderr are treated specially by Python, because of the special status also given to them by C: doing sys.stdout.close() # ditto for stdin and stderr marks the Python-level file object as being closed, but does not close the associated C stream (provided sys.stdout is still bound to its default value, which is the stream C also calls "stdout"). To close the underlying C stream for one of these three, you should first be sure that's what you really want to do (e.g., you may confuse the heck out of extension modules trying to do I/O). If it is, use os.close: os.close(0) # close C's stdin stream os.close(1) # close C's stdout stream os.close(2) # close C's stderr stream -- -=-=-=-=-=-=-=-= Clarence Gardner AvTel Communications Software Products and Services Division clarence at avtel.com From jtravs at debian.org Mon Jun 21 02:53:00 1999 From: jtravs at debian.org (John Travers) Date: Mon, 21 Jun 1999 07:53:00 +0100 Subject: pyOpengl for Debian Message-ID: <99062107535200.03236@Vegus> Has anyone made Debian/GNU Linux packages of pyOpenGl? -- John Travers "Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us!" From gmcm at hypernet.com Sat Jun 12 00:23:54 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Fri, 11 Jun 1999 23:23:54 -0500 Subject: Broken 1.5.2 installation? Missing cw3215mt.dll In-Reply-To: <37611D32.47BED973@callware.com> Message-ID: <1282960807-85602620@hypernet.com> Ivan Van Laningham wrote: > [snort] > > I've just been installing Python/Tcl/PyWin/Win32All/blah blah on > several Win machines (95/98/NTW/NTS) over the past several days. > It's a long story (soon to be a major motion picture starring Mel > Gibson), but suffice it to say that in *every* case IDLE refused to > run out of the box. > ... I've also installed Python/Tcl on my three Linux > machines--RH5.2 and RH6.0-SMP--but I didn't have to fiddle with > anything at all in order to get IDLE to run just fine. Of course, > Python and Tcl etc. have been in my path permanently for a long time > on Linux;-) [double snort] A few months ago you were running some auto-port from a PDP-8. Did RH finally convince you no warm-blooded animals were used in user testing? - Gordon From graham at sloth.math.uga.edu Tue Jun 8 15:43:25 1999 From: graham at sloth.math.uga.edu (Graham Matthews) Date: 8 Jun 1999 19:43:25 GMT Subject: fork() References: <000601beb1c7$682c6220$559e2299@tim> <7jjghd$9il$1@cronkite.cc.uga.edu> <375D5826.23197692@inrialpes.fr> Message-ID: <7jjrot$h16$2@cronkite.cc.uga.edu> Graham Matthews wrote: > But the reality is that copying memory can in fact speed applications > up! Think about locality of reference after you have copied all live > blocks to the start of memory. Vladimir Marangozov (Vladimir.Marangozov at inrialpes.fr) wrote: : True enough. At least, it sounds true and promising ;-) : However, locality of reference (LOR) is something quite hard to measure : in practice. One has to tweak the kernel to collect some stats on this, : and even if one achieves LOR improvements on a partuclar system, say : Solaris, it could result in a LOR degradation on Linux or Windows. : Not to mention that nowadays nobody wants to play this game... Sure I agree with all this. I am just saying that it's quite simplistic nowdays to assume that copying objects when collecting is a bad idea. It used to be the case that copying was bad -- that's why mark and sweep collectors were invented before copying collectors. But on modern CPUs and modern OS's it's no longer uniformly true. Vladimir Marangozov (Vladimir.Marangozov at inrialpes.fr) wrote: : Graham, you said that you won't contribute a RC+GC scheme to Python, despite : your positive experience. If you change your mind and consider : devoting some spare time to give it a try, I'll devote some spare : time to help you with Python's internals and we'll see whether we : could come up with something viable, which could compete with the : actual RC scheme alone. Does this sound constructive enough? :-) Very constructive indeed! I am indeed sorry that I don't have the time to contribute code for a collector for Python. I think it would be greatly beneficial. But between working on a language of my own, and working on my PhD, well there is only a finite amount of time in a week (damn shame that!). I was actually wondering if anyone had done any work putting the Boehm collector under Python. The Boehm collector was designed to run in a C environment. graham -- As you grow up and leave the playground where you kissed your prince and found your frog Remember the jester that showed you tears the script for tears From greg.ewing at compaq.com Sun Jun 27 23:43:33 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Mon, 28 Jun 1999 15:43:33 +1200 Subject: Python for large projects? References: <3774b5d1.690922@news.force9.net> <87n1xm85mf.fsf@lisboa.i-did-not-set--mail-host-address--so-shoot-me> Message-ID: <3776EF65.A07CBEFC@compaq.com> Darrell wrote: > > I'll give that a look, but they can always get to it if they want. Maybe > that's ok, just worries me. If you clearly warn them in the docs not to do it, and they do it anyway and get into trouble, it's not your fault. Greg From Vladimir.Marangozov at inrialpes.fr Sun Jun 27 18:05:25 1999 From: Vladimir.Marangozov at inrialpes.fr (Vladimir Marangozov) Date: Mon, 28 Jun 1999 00:05:25 +0200 Subject: GC In Python: YAS (Yet Another Summary) References: <000301bebffc$184fcf60$da9e2299@tim> Message-ID: <3776A025.53B35103@inrialpes.fr> A not very modest plug Tim Peters wrote: > > [Andrew Dalke, worries about Boehm collection vs Fortran] > ... > Despite all that, it would probably work fine for you. I think it's a dead > issue here regardless, though, because Guido isn't going to tell anyone they > have to use a particular routine for memory allocation. Python could use > its own malloc for its own objects (& Vladimir Marangozov has written a very > nice PyMalloc, available from his Starship page), but Thanks for the compliment, but ... > that breaks down as soon as any extension has its own view of how to get memory. I can't let you say this (heh, it's too late ;-) because you seem to overlook one of the nicest features of pymalloc. If the extension module works in current Python + libc malloc, it will work with Python + pymalloc because of the dynamic block management. IOW, if one recompiles the core with pymalloc instead of the usual libc malloc, everything should work as before, even *without* recompiling any extension or 3rd party modules. The concept is simple, but useful. I told you that pymalloc is tricky ;-) -- Vladimir MARANGOZOV | Vladimir.Marangozov at inrialpes.fr http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252 From gerrit at nl.linux.org Sun Jun 6 15:12:59 1999 From: gerrit at nl.linux.org (Gerrit Holl) Date: 6 Jun 1999 19:12:59 GMT Subject: Suggestion: Dutch Python mailinglist Message-ID: This e-mail is in two languages. Look below for the Dutch version. Deze e-mail is in twee talen. Kijk beneden voor de Nederlandse versie. Hello all, I'm a 13-years-old Dutch boy, and my English is not good. Now I have the chance to set up a Dutch python mailinglist. I know there are many Dutch python-users, but most of them know English very well. So will there be any users who'll subscribe to such a mailinglist, or will it remain very quiet? regards, Gerrit. Ik ben een Nederlandse jongen van 13 jaar, en mijn Engels is niet goed. Ik heb nu de mogelijkheid om een Nederlandse Python mailinglist op te zetten. Ik weet dat er veel Nederlandse Python-gebruikers zijn, maar de meeste van hen kennen genoeg Engels. Zullen er gebruikers zijn die zich zouden abboneren op zo'n mailinglist, of zal het doodstil blijven? groeten, Gerrit. -- The Dutch Linuxgames website. De Nederlandse Linuxgames pagina. Everything about games on Linux. Alles over spelletjes onder Linux. Site address: http://linuxgames.nl.linux.org Personal homepage: http://nl.linux.org/~gerrit/ From gmcm at hypernet.com Wed Jun 2 23:27:23 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 2 Jun 1999 22:27:23 -0500 Subject: Newbie seeks help with COM? DLLs? In-Reply-To: <7j4iiv$l1r$1@autumn.news.rcn.net> Message-ID: <1283741805-38623148@hypernet.com> Sam Hunting writes: > Background: I'm operating in a VB/NT shop, but I want to introduce a > Python solution for the sake of doing *extremely* rapid development > of GUI widgets. > We need to incorporate the widgets into an existing software product > so that, for example, a Python-developed dialog will appear, into > which the user will enter data, which is then passed back to the > application. > > Now here is where my newbie nature takes over, since I am very new > to Python, and even newer to the VB/NT/Windows worlds -- how > "incorporate"? > > The software product understands DLLs, and also understands COM. > I've had it suggested to me that the way to get where I need to do, > is to turn the dialogs into COM servers, and then call them from the > software application, which is the client. > > (1) I worked through the "Quick Start to Server Side COM and > Python", and registered the Hello World server successfully. Can > anyone point me to some VB code that would enable me to test the > test server? > > (2) If the COM approach is not the right approach, can someone > suggest a better one? And point me to some sample code that I can > test, run, and improve to help me solve the problem? You need http://www.robanal.demon.co.uk/demos/pyvb/index.html. (What you *really* need is Andy & Mark's book, but that'll take awhile.) Assuming your client is VB, this seems the natural way to go. If it were C or C++, it might be easier through the Python's C API. - Gordon From arcege at shore.net Sat Jun 19 19:34:32 1999 From: arcege at shore.net (Michael P. Reilly) Date: Sat, 19 Jun 1999 23:34:32 GMT Subject: Tkinter & socket question References: <19990618215411.23898.qmail@nwcst277.netaddress.usa.net> Message-ID: Gregory A. Landrum wrote: :>2) I need to poll the connection periodically, say, every second. This would :>not have been a problem in console mode... I don't know how to do this in a :>Tkinter environment though. So, how can I do something every second (or every :>n milliseconds, or whatever the time span may be)? Are threads the way to go? :>I haven't used them before. : Wow, a question I can answer.... amazing. : Obligatory-Mandatory-Necessary-Essential Disclaimer: I bear no : resemblance whatsoever to a python wizard, I just happen to have done : something like what you want to do. There's almost definitely a : better way of doing this, but my method seems to work. : I assume that you have already opened a nonblocking socket connection, : and that that is what you are polling. Your main Tkinter window has a : method called "after" which can be used to do the polling. : Documentation can be found at: : http://www.pythonware.com/library/tkinter/introduction/x8550-alarm-handlers-and-other.htm : An example, in my stupid little networked python game, I have the : following polling function: : def ListenForMessages(self): : msg = None : theConn = None : : # Check to see if we are the client or the server : if self.serverActive == 1: : if self.clientConn is None: : print "No Client!" : return : theConn = self.clientConn : elif self.clientActive == 1: : theConn = self.socket : if theConn is None: return : # see if there is anything there to read : try: : msg = theConn.recv(1024) : # Got it! Dispatch the message. : self.Dispatch(self.message.Type(msg),msg) : except error: : # nope... no one loves us. : pass : # re-register the after callback, with a 200msec delay : self.listenID = self.Game.rootWin.after(200,self.ListenForMessages) : The last line is important, because the after callback is removed : after being called. So it needs to be re-registered with Tk. : The callback is first registered immediately upon establishing the : socket connection. You can also deal directly with Tcl/Tk's filehandler: from Tkinter import tkinter self.root.tk.createfilehandler(socket, tkinter.READABLE, self.handle_msg ) ... self.root.tk.deletefilehandler(socket) The mainloop() method handles the rest for you. -Arcege From fysx at spots.ab.ca Mon Jun 14 21:54:53 1999 From: fysx at spots.ab.ca (Maxwell Sayles) Date: Tue, 15 Jun 1999 01:54:53 GMT Subject: OO (was: Why is tcl broken?) References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> <3762988E.C94AA252@iname.com> <3763C746.5CA8FE78@iname.com> <87pv2zjhhl.fsf@home.ivm.de> <3764F3FE.F7CBE6BA@acm.org> <0Sgs3BA5FPZ3Ew6E@jessikat.demon.co.uk> Message-ID: <3765B3B8.E45F373B@spots.ab.ca> Robin Becker wrote: > postfix, prefix, infix etc etc are isosemantic for myself and the others who might not know... can we get an example of each? and i remember someone mentioned parenthesized vs non-parenthesized... Maxwell Sayles From jefftc at leland.Stanford.EDU Fri Jun 25 20:59:12 1999 From: jefftc at leland.Stanford.EDU (Jeffrey Chang) Date: Fri, 25 Jun 1999 17:59:12 -0700 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? In-Reply-To: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> Message-ID: On Fri, 25 Jun 1999, Mikael Lyngvig wrote: > I'd like some discussion on whether or not it is a good idea to > abandon TkInter, before it gets too widely used, and instead adopt > wxPython as the primary GUI framework for Python. Abandoning Tkinter seems a little bit extreme, since there are some applications for which its event model is well-suited. A few weeks ago I needed to build a viewer that displays binary trees whose branches have variable lengths (actually, phylogenetic trees for biological data). Since the trees are large, I need to be able to slide it around the window. In addition, I needed each node to be clickable so that the user can query for more data. Tkinter is very good for that type of thing. All I needed to do was create a Canvas and then for each node, create an Oval with a callback to a function that handles node clicks. Tk keeps track of the coordinates of each Item so that I don't have to. Also, whenever I wanted to move the tree, all I had to do was: for widget in self._canvas.find_all(): self._canvas.move(widget, xoff, yoff) Of course, Tk incurrs an overhead by making everything you draw on the canvas its own object, but for this case, it made thigns a lot easier. Although I haven't used wxWindows before, but the documentation suggests that it would be a lot more difficult for this kind of application. In wxWindows, I would need to draw each of my nodes into a window using a device context. Then, I'd have to write a function that would handle mouse clicks in the window. That function would need to get the coordinates and then figure out whether it intersects with any of my nodes, which Tk would've handled for me. In addition, whenever I wanted to move the tree, I'd have to erase the window and redraw each node. If I wanted that optimized, I'd need to write routines that would only redraw the uncovered parts of the tree, which means figuring out which nodes are newly revealed. >From what other people have said about wxPython, it seems like it may be appropriate for other types of applications. However, I'd hate to see Tkinter dumped because it's not appropriate for everything! Jeff From paul at digicool.com Wed Jun 2 20:19:50 1999 From: paul at digicool.com (Paul Everitt) Date: Wed, 02 Jun 1999 20:19:50 -0400 Subject: Is pcgi usable without Zope? References: Message-ID: <3755CA26.BCB7828A@digicool.com> Lloyd Zusman wrote: > > I have to admit that I'm a bit confused about pcgi these days. The > most recent documentation for it was last updated in August, 1998, and > it still refers to Bobo and Principia. We're certainly not helping -- I agree that stuff is strewn around all over the place. > Now that we have Zope, is pcgi now intimately bundled with it, never > to emerge on its own again? Or is there a way to run pcgi without > Zope? I don't think PCGI is intimately bundled with Zope. Neither is the object publisher, object database, the template system, etc. All can be used independently. --Paul From phd at emerald.netskate.ru Thu Jun 10 04:40:29 1999 From: phd at emerald.netskate.ru (Oleg Broytmann) Date: Thu, 10 Jun 1999 12:40:29 +0400 (MSD) Subject: os.mkdir() In-Reply-To: <375E5DCE.7005D71A@phoenix-edv.netzservice.de> Message-ID: On Wed, 9 Jun 1999, Holger Jannsen wrote: > Look: > >>>os.mkdir("c:\\blabla") > OSError: [Errno 17] File exists: 'C:\\blabla' > > or > >>>os.makedirs("c:\blabla\nana\gugu") > produces > OSError: [Errno 2] No such file or directory: 'c:\blabla\nana' os.makedirs("c:\\blabla\\nana\\gugu") ^^ ^^ ^^ Double your backslashes. Oleg. ---- Oleg Broytmann Netskate/Inter.Net.Ru phd at emerald.netskate.ru Programmers don't die, they just GOSUB without RETURN. From zigron at jps.net Fri Jun 25 14:23:32 1999 From: zigron at jps.net (Zigron) Date: Fri, 25 Jun 1999 11:23:32 -0700 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> <3773c3a0.102825445@news.oh.verio.com> Message-ID: Kevin Dahlhausen wrote in message news:3773c3a0.102825445 at news.oh.verio.com... > m > >I'd like some discussion on whether or not it is a good idea to > >abandon TkInter, before it gets too widely used, and instead adopt > >wxPython as the primary GUI framework for Python. I'm thinking this is too late, actually. :) From my understanding, its the de-facto standard or whatever, and plenty of people use it already. Not that that's a good thing.. I find it rather unpleasant that the de-facto GUI for Python requires you to install a /different/ scripting language just to run,.. and, does seem to be rather slower then wxPython from the uses i've had for both... which doesn't surprise me, since Tkinter /does/ have to run through a second scripting-interpreter and all. > >Having said this, I have to say that I'm in no way a TkInter or a > >wxPython expert. I've evaluated both of them and found wxPython to be > >the winner - and TkInter without a real chance of getting used by me. Awhile back I was using Tkinter for a program i'm doing, and was so incredibly frustrated with it, and my inability to get it to make apps that look like I want to -- /native/ and still functional. ( I tried to make a wxListCtrl, ugh!)... Then I ran into wxPython, and have been happy ever since :) > I agree with your observations on TK. I looked at wxPython and some other > GUIs. I liked the Fast Light Toolkit API the best. At least Python allows us > to use the best GUI, with 'best' being defined by people according to their own > preferences. True, 'tis a good thing that people can pick and choose beween GUI's, but I still think TK is unsavory. .. to make an app that you want to distribute, you'd not only have to install Python on their machine, but TCL too. Yuck. :) > >P.S. Let's not make a war out of this; I just want to know if there's > >anybody else who feels wxPython is performing better than TkInter. > > As long as we don't talk about politics,tabs, spaces, and indentation, we should > be fine. Do'nt forget garbage collection and perl in those lists of disallowed topics. :) --S From erenouf at opticominc.com Wed Jun 9 11:30:42 1999 From: erenouf at opticominc.com (Eric Renouf) Date: Wed, 09 Jun 1999 11:30:42 -0400 Subject: getting memory information under NT References: <002201beab54$66218d30$f29b12c2@pythonware.com> <003301beab56$88cb3af0$f29b12c2@pythonware.com> Message-ID: <375E88A2.68C1F118@opticominc.com> Does anyone know of an easy way to get the the total physical memory and/or available memory on an NT system using Python 1.5.2? Is there a module that has functions for things like this already? Thanks, Eric Renouf From zeitlin at seth.lpthe.jussieu.fr Tue Jun 29 10:23:45 1999 From: zeitlin at seth.lpthe.jussieu.fr (Vadim Zeitlin) Date: 29 Jun 1999 14:23:45 GMT Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> <7l4nht$jl7$1@nnrp1.deja.com> <9DDBCC52A7B26002.649D772F7232D418.CE2709D4B08E7401@lp.airnews.net> Message-ID: On 29 Jun 1999 15:02:40 +0200, Ernst-Udo Wallenborn wrote: >Would this be any different with a different GUI kit? Hi, doing GUI calls from more than one thread is a recipe for disaster IMHO. I don't say that it's impossible (in fact, the threads sample in wxWindows distribution which I (co)wrote does just this), but it's not a good idea. OTOH, there is no problem in having as many of worker threads as you wish and one "main" GUI thread. This design is much more robust and easier to implement too... Regards, VZ From amackay at starvision.com Mon Jun 21 17:08:52 1999 From: amackay at starvision.com (Angus MacKay) Date: Mon, 21 Jun 1999 14:08:52 -0700 Subject: chomp() Message-ID: <376EA9E4.5B3D38EC@starvision.com> is there an equivilent of perl's chomp() in python or do I have to write the function myself? cheers, Angus. From ronERASEjeffries at ERASEacm.org Fri Jun 18 21:27:58 1999 From: ronERASEjeffries at ERASEacm.org (Ronald E Jeffries) Date: Sat, 19 Jun 1999 01:27:58 GMT Subject: Extreme Python Testing References: <375C99FE.E61E511@pdq.net> Message-ID: <8D1E40EBACC2A6F5.29A2B8B9FA3EDD18.CD1734958179DCBB@lp.airnews.net> On Mon, 07 Jun 1999 23:20:14 -0500, John Dell'Aquila wrote: >I admire the Smalltalk "Extreme Programming" methodology enough that >I'm applying it in my Python development. XP is impossible without an >automated test framework, so the first thing I did was write a Python >version of Kent Beck's Testing Framework. Way ta go John! Glad to see another entry in the Testing Framework collection. Would you mind if I post it on the armaties XP site? I'm trying to get JPython going, as soon as that happens, I'll try out your framework. Regards, Ron Jeffries Extreme Programmer http://www.armaties.com From alex at somewhere.round.here Fri Jun 4 13:51:44 1999 From: alex at somewhere.round.here (Alex) Date: 04 Jun 1999 13:51:44 -0400 Subject: Alien whitespace eating nanovirus strikes again! References: <375500C9.742DC539@pop.vet.uu.nl> <375536C2.DD917F99@prescod.net> <7j4e2u$8rh$1@m2.c2.telstra-mm.net.au> <37564132.2D01B7C3@pop.vet.uu.nl> <3756BAFC.2066A636@home.com> <3756F071.E717D0FA@pop.vet.uu.nl> <37573C16.D0233810@home.com> Message-ID: > I'm rambling about Python these days. Yesterday I read a paper from > Guido about how he was thinking about bringing Python (or some > successor language) to *billions* of users. :) Could someone point me at this paper? Alex. From MHammond at skippinet.com.au Wed Jun 16 03:01:06 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Wed, 16 Jun 1999 17:01:06 +1000 Subject: do anonymous pipes normally work on NT? References: <7juatc$fef$1@nnrp1.deja.com> <7k43sk$6vd$1@nnrp1.deja.com> Message-ID: <7k7i1g$87d$1@m2.c2.telstra-mm.net.au> Im afraid I can't be of much help here. I have had a good play, and nothing seems obvious. Interestingly, if you change cat.py to: f.write("Stdin fileno is %s\n" % (sys.stdin.fileno(), )) f.write("Stdin handle is %s\n" % (msvcrt.get_osfhandle(sys.stdin.fileno()), ) ) You will notice that when run "normally", stdin has a fileno of 0, and a valid handle. However, when run by runproc.py, the fileno is -1, and attempting to get back the handle fails. If I had more time I would dig into where fileno() gets its value from, and see if this points to why we are failing. Adding except: traceback.print_exc(file=f) Also helps see this stuff. I am afraid I am all out of time with this stuff. If you are really keen, the next step would probably be to recode this small sample in C, and see if that works. If it does, Python (or the win32 extensions) has a problem we should fix as a matter of priority. If not, then we need to find the magic words to chant to make it work from C, and move that back to Python... Mark. From gmcm at hypernet.com Tue Jun 8 11:38:39 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 8 Jun 1999 10:38:39 -0500 Subject: fork() In-Reply-To: Message-ID: <1283265923-67249193@hypernet.com> Stephan Houben wrote: ... > Don't know if anyone wrote a Python wrapper around the POSIX shared > memory stuff. However, you probably don't want/need to do that. The > reason is that there's basically no (portable) way to get malloc() > to allocate new objects in the shared memory, so you can't create > Python objects in the shared memory. So you can probably only access > the shared memory as a special array a la the "array" module. Vladimir Marangozov has a SysV shared memory / semphore module at http://sirac.inrialpes.fr/~marangoz/python/shm/. Like Mark Hammond's Win32 shared memory extension it uses a file like API. Probably not what's needed in the context of this thread, but handy nonetheless. - Gordon From behrends at cse.msu.edu Wed Jun 30 08:30:49 1999 From: behrends at cse.msu.edu (Reimer Behrends) Date: 30 Jun 1999 12:30:49 GMT Subject: Typing [Re: total idiot question: +=, .=, etc...] References: <000d01bebeda$1b7430a0$d29e2299@tim> <3778C2C7.3B101FD0@geekspace.com> Message-ID: Joshua Rosen (rozzin at geekspace.com) wrote: > Reimer Behrends wrote: > > Require variables to be prefixed with "$" to denote scalar > > values--strings and integers, "@" for lists, and "%" for > > dictionaries. > > > > Given the precedent of having to use self to access instance variables, > > this is entirely consistent with the current language, and is going to > > eliminate all those nasty problems where you can't tell from the context > > what the type of a variable or function is. :) > +There is no difficulty in getting the program to know what type > some piece of data is, which lessens the need for the > type-declaring prefixes--use type(), and then check > obj.__class__ if obj is a class-instance, and you need to -know- > what class it is (if you want to -force- it to be a certain > type, keep reading). Ahem. I happen to know Python fairly intimately after I don't know how many years of constant use. What I wrote above was mostly a tongue in cheek comment (heck, I even said so). The point I was making was that the very same argument that justifies a self prefix can also be used to justify type prefixes--in fact, I pretty much paraphrased it from an old posting by Tom Christiansen on 10/26/98 (the message id is <710kg1$mr0$1 at csnews.cs.colorado.edu>) > +Requiring variables to bear a prefix denoting type sortof makes > Python into a statically-typed language, where one of the big > reasons for using it is that it's a dynamically-typed language. I never said otherwise. But the same argument can be used mutatis mutandum to support a "self"-less notation. :) > +There is no such thing as a `scalare', in Python--strings and > numbers are different data-types, numeric data can actually be > one of many different classes. I know. It was a facetious argument. > +Forcing data to be of a specific type is already possible--see > documentation on int(), str(), list(), tuple(), float(), long(), > complex(), string.atoi(), et al. This functionality also > lessens, if not completely eliminates the need for typing > prefixes; the program knows what type the data is being coered > into, and so does the programmer. In fact, all of the > functionality that you're proposing (and then some) is already > there--it just looks different. And I just happen to be aware of that, too. > +If you really want a feature that -really- isn't offered by a > language, the best decision may be to just use another language > that -does- offer it. Try Pike, for one (I suggest it because it > has nifty typing which you may like: you can declare a variable > to be one or -more- types, or use a mixed type). Choose your > languages based upon what you need them to do. And I know Pike, too. In fact, I'm pretty familiar with it. By the way, would you mind using shorter lines next time? Reimer Behrends From matz at netlab.co.jp Mon Jun 7 01:57:17 1999 From: matz at netlab.co.jp (Yukihiro Matsumoto) Date: 07 Jun 1999 14:57:17 +0900 Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7j90va$6lk$1@cronkite.cc.uga.edu> Message-ID: <87pv384koy.fsf@ev.netlab.co.jp> Hisao Suzuki writes: |In article <7j90va$6lk$1 at cronkite.cc.uga.edu>, |graham at sloth.math.uga.edu (Graham Matthews) wrote: |> I am completely confused by this statement. The two people that have |> been advocating GC the hardest are myself and the author of Ruby. Since |> Ruby has GC the author has clearly implemented a collector. ... | |Regrettably, I'd have to say that Ruby is (was?) suffering from |its insufficient portability. Once I have used a certain i860 |SVR4 box. On that box, Ruby did not run but dumped immediately |with its twiddling the machine stack, while Python ran perfectly |with no difficulty. As far as I know, the collector of Ruby has |not changed so much since then. It's because conservative-ness of Ruby's GC, you know. There should be no portability problem with Graham's proposal, mark and sweep GC with ref counting, unless implementor try to make it conservative. I've never claimed Ruby is as portable as Python. Definitely Python runs on the machines where Ruby cannot run, say on small devices. |(I have before told this to the author of Ruby on a Japanese |Pythoneers' mailing-list against his advocacy of Ruby, and now |he appeared here again with just the same opinion before...) What opinion of mine do you have in mind? I claimed in summary: * I don't like mere ref counting; it cannot reclaim cyclic data, and easy to forget INCREF/DECREF. * Many among Python users misunderstood about real GC. (slow, hangs, non portable, etc.) * ref counting with GC may be good for Python 2.0. Did I do any advocacy on Ruby? I was trying constructive discussion. matz. From dkhchan at my-deja.com Sun Jun 13 21:25:06 1999 From: dkhchan at my-deja.com (dkhchan at my-deja.com) Date: Mon, 14 Jun 1999 01:25:06 GMT Subject: Serial programming References: <7jp1jt$8hg$1@imsp009a.netvigator.com> Message-ID: <7k1llb$cae$1@nnrp1.deja.com> I try but not success. Modem receive my command (I try to dail out) but I have not get any respone. Anything I missed?? My program: #!/usr/bin/python modem = open('/dev/ttyS0', 'w+') modem.write('ATZ\r') print modem.read() # no respone here modem.close() DORAEMON.HK In article , "Michael P. Reilly" wrote: > DORAEMON.HK wrote: > : I am looking for some example in python about send and receive data from > : serial port. Like send "ATZ" and receive "OK". Any help?? Thanks a lot!! > > You can open the device file directly and handle the information > yourself. UNIX devices are handle just like files. You can change > device attributes (speed, parity, etc.) with the termios module or > fcntl.ioctl function. > > modem = open('/dev/cua0', 'r+') > modem.write('AT\r') > f = modem.read() > if f[:2] != 'OK': > raise ValueError, "modem not okay" > ... > > There are some Expect modules/extensions around that could help you as > well; my ExpectPy extention is at > http://starship.python.net/~arcege/ExpectPy/. You can find others > through the Python website. > > import ExpectPy > modem = ExpectPy.spawnfile(open('/dev/cua0', 'r+')) > modem.send("AT\r") > try: > f = modem.expect( > (ExpectPy.EXACT, "OK\r\n", "OK"), > (ExpectPy.GLOB, "*\r\n", "Not OK") > ) > if f == "Not OK": > raise ValueError, "modem not okay" > except (ValueError, ExpectPy.TimeoutError), value: > raise ValueError, value > > I hope this helps. > > -Arcege > > Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From paul at prescod.net Mon Jun 7 09:23:52 1999 From: paul at prescod.net (Paul Prescod) Date: Mon, 7 Jun 1999 13:23:52 GMT Subject: Suggestion: Dutch Python mailinglist References: Message-ID: <375BC7E8.BC53EFD@prescod.net> Gerrit Holl wrote: > > I know there are many Dutch > python-users, but most of them know English very well. Dutch people use Python? Since when? > Ik ben een Nederlandse jongen van 13 jaar, en mijn Engels is niet goed. Actually, I can pretty much read that without learning Dutch. It looks like English with some spelling mistakes. And no more typing mistakes than is typical for mailing lists. -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco "Silence," wrote Melville, "is the only Voice of God." The assertion, like its subject, cuts both ways, negating and affirming, implying both absence and presence, offering us a choice; it's a line that the Society of American Atheists could put on its letterhead and the Society of Friends could silently endorse while waiting to be moved by the spirit to speak. - Listening for Silence by Mark Slouka, Apr. 1999, Harper's From Timothy.R.Evans at p98.f112.n480.z2.fidonet.org Wed Jun 30 19:05:42 1999 From: Timothy.R.Evans at p98.f112.n480.z2.fidonet.org (Timothy R Evans) Date: Thu, 01 Jul 1999 00:05:42 +0100 Subject: Arbitrary precision calculations Message-ID: <0000159e@bossar.com.pl> From: Timothy R Evans catlee at my-deja.com writes: > Hi, > > I'm looking for a package that will let me do arbitrary precision > arithmatic in python. I've come across the real.py module written by > Jurjen N.E. Bos, and it seems like a really nice module except for the > fact that you can't compare two numbers for equality,inequality,etc. > > Cheers, > Chris > > P.S. I found the real.py package by doing a search on www.deja.com for > arbirary precision in comp.land.python > > > Sent via Deja.com http://www.deja.com/ > Share what you know. Learn what you don't. If I'm reading this right you want arbitrary precision integers right? Just use the Python `Long' integer, created using the `long' function or by placing an L after a literal number (e.g. 10L). All standard numerical operators ork on long intergers (if you're doing crypto stuff then don't forget that `pow(X,Y,Z)' calucates X to the power of Y, modulo Z efficiently. -- Tim Evans From kiki at pixar.com Thu Jun 24 22:52:19 1999 From: kiki at pixar.com (kiki) Date: Thu, 24 Jun 1999 19:52:19 -0700 Subject: Tkinter: radiobutton References: <3771B52E.80F3FA46@pixar.com> Message-ID: <3772EEE3.2DCCE7C0@pixar.com> "Michael P. Reilly" wrote: > > No, it's not an obvious question at all. Unfortunately, you need to > track the index when you create the menu. By default, the first call > starts at 1, because the "tear-off" is 0. If the menu is created with > the -tearoff=0 option, then the index starts at 0 > Bleh. Oh well. Kind of a shame, since I'd rather just have the color value put into the color variable, not an index with my own list I have to maintain myself. Well, cool, at least I have a solution. Thanx so much for your help! Kiki From doughellmann at mindspring.com Fri Jun 18 14:16:58 1999 From: doughellmann at mindspring.com (Doug Hellmann) Date: Fri, 18 Jun 1999 18:16:58 GMT Subject: error? inconsistent dedent References: <376A6796.814CBA24@phoenix-edv.netzservice.de> Message-ID: <376A8DB5.3B008C8C@mindspring.com> Holger Jannsen wrote: > > What does 'inconsistent dedent' mean? > Why does that error occur? You could post the code for a more specific answer, but usually when I see that error it means that I'm mixing tabs and spaces for indention and the count of "whitespace" on the line in question is off. I'd check that, first. Doug From aa8vb at ipass.net Fri Jun 25 13:32:08 1999 From: aa8vb at ipass.net (Randall Hopper) Date: Fri, 25 Jun 1999 13:32:08 -0400 Subject: Python / VTK problem In-Reply-To: <37738721.E2B17705@nevex.com>; from Greg Wilson on Fri, Jun 25, 1999 at 09:41:53AM -0400 References: <37738721.E2B17705@nevex.com> Message-ID: <19990625133208.A755922@epa.gov> Greg Wilson: |Hi, folks. I've just downloaded, compiled, and installed VTK 2.3, and |for the first time, I've built with Python extensions enabled. |Unfortunately, while I can run the Tcl examples, I can't get the Python |examples to run. The command 'python mace.py' (or similar) produces: | | Traceback (innermost last): | File "./mace.py", line 2, in ? | from libVTKGraphicsPython import * |ImportError: /home/gvwilson/lib/libVTKGraphicsPython.so: undefined |symbol: XtStrings | |The symbols XtStrings is defined in /usr/X11R6/lib/libXt.so (I'm on Red |Hat Linux). The directory /usr/X11R6/lib is in my LD_LIBRARY_PATH and in |my PYTHONPATH, as is /home/gvwilson/lib (which contains symbolic links to |the VTK .so's). I'd be grateful to anyone who can tell me what I'm doing |wrong. It sounds like libVTKGraphicsPython.so wasn't implicitly linked with libXt.so when you compiled VTK. No problems here on IRIX; it appears that the linker pulled it in automatically. To check: > cd vtk/graphics > ldd libVTKGraphicsPython.so [you should see libXt.so in the list; but I'd wager that you won't] > rm libVTKGraphicsPython.so > make [VTK doesn't explicitly link in Xt, but it probably should] A quick nm of the source files linked into libVTKGraphicsPython reveals that vtkXRenderWindowInteractor.o depends on Xt calls. Try adding a: X_EXTRA_LIBS = -lXt -rpath /usr/X11R6/lib to your user.make file. Randall From pduffin at mailserver.hursley.ibm.com Fri Jun 11 08:36:25 1999 From: pduffin at mailserver.hursley.ibm.com (Paul Duffin) Date: Fri, 11 Jun 1999 13:36:25 +0100 Subject: Python as a shared library on Unix Message-ID: <376102C9.5648@mailserver.hursley.ibm.com> Is it possible to build Python itself as a small executable and a shared library, rather than an archive library which of course results in a monolithic executable. I know how to get the modules built as shared libraries but cannot get Python built as a shared library. -- Paul Duffin DT/6000 Development Email: pduffin at hursley.ibm.com IBM UK Laboratories Ltd., Hursley Park nr. Winchester Internal: 7-246880 International: +44 1962-816880 From bwinton at tor.dhs.org Thu Jun 17 00:07:44 1999 From: bwinton at tor.dhs.org (Blake Winton) Date: Thu, 17 Jun 1999 04:07:44 GMT Subject: Why is tcl broken? References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> <37682DD3.43923243@compaq.com> <37684B76.AA8D0CD5@hex.net> Message-ID: On Wed, 16 Jun, Peter A. Koren wrote: snip >In the spirit of abductio ad absurdum, I can do everything you can do >in python or Tcl with a Turing machine. I don't. I am also not into >whips and chains. And, since there is a Turing machine implementation for vi, it can do anything Python can do. Hmmm... Perhaps I'll switch from using vi to write Python code to using Python to write vi code...[0] Later, Blake. [0] Of course, I'm using vim with Python support, so I've already used Python to write vi code, but that's beside the point. -- One Will. One Dream. One Truth. One Destiny. One Love. From phd at emerald.netskate.ru Wed Jun 23 06:54:00 1999 From: phd at emerald.netskate.ru (Oleg Broytmann) Date: Wed, 23 Jun 1999 14:54:00 +0400 (MSD) Subject: PIL and cgi link problem In-Reply-To: <7kqcd3$3at$1@nnrp1.deja.com> Message-ID: Hi! On Wed, 23 Jun 1999 entree at my-deja.com wrote: > We want to use the library from a python cgi Can you use it from command-line programs? > script. Here we encounter a strange problem with > the Image module. The cgi script tries to import > it in response to a web-query. but it failes with > an ImportError Exception: _imaging C module is > not installed. further investigation of the > exception showed the following (link) error: > undefined symbol PyExc_IOError What OS? Compiler? For Linux, sometimes it need to export symbols from main module (-Wl,-E compiler option)... > Does anybody has an idea?. > > We are using Python 1.5.1 and LibImaging 1.0b1 > > Thanx in advance, > > Robbert > Entree Oleg. ---- Oleg Broytmann Netskate/Inter.Net.Ru phd at emerald.netskate.ru Programmers don't die, they just GOSUB without RETURN. From greg.ewing at compaq.com Sun Jun 27 22:27:00 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Mon, 28 Jun 1999 14:27:00 +1200 Subject: RuntimeError? References: <19990627112432.A29097@optiplex.palga.uucp> Message-ID: <3776DD74.4C1B2342@compaq.com> Gerrit Holl wrote: > > can someone please give me an example when a RuntimeError is raised? At a guess I'd say it's a base class from which other runtime error classes are derived, and isn't actually raised itself. Greg From larsga at ifi.uio.no Wed Jun 16 03:41:34 1999 From: larsga at ifi.uio.no (Lars Marius Garshol) Date: 16 Jun 1999 09:41:34 +0200 Subject: XML-toolkit for Windows - binaries available? References: <376701a3.72288277@newssrv> Message-ID: * Lee Borkman | | Can anyone help me out in installing from the standard distribution? | I don't have a C-compiler on my system, but I do have nmake/dmake. I think the web page is out of date, since the /xml/windows directory in the CVS does contain the .dll files for pyexpat and sgmlop (and has done for quite a while). So just download the ZIP file and they should be there. If not, send me an email and I'll send them to you. --Lars M. From rceci at my-deja.com Mon Jun 7 15:50:07 1999 From: rceci at my-deja.com (rceci at my-deja.com) Date: Mon, 07 Jun 1999 19:50:07 GMT Subject: Question about envvars References: <7jgl9n$p13$1@nnrp1.deja.com> <375BFE38.3FB3E83C@ix.netcom.com> Message-ID: <7jh7pc$as$1@nnrp1.deja.com> Stephen, Boy I was excited to get a reasonable explaination so quickly, but alas, it still does not work. Here is my test script: #!/usr/local/bin/python import MDIreg reg = MDIreg.FileRegistry(1,1) reg.exportEnvVars() import os print "child has it : " os.system("env | grep MDI_REG_VERSION") print "but do I have it? :" print os.environ['MDI_REG_VERSION'] --- I am interested in this "MDI_REG_VERSION" envvar which gets exported by my library. Here is the output: child has it : MDI_REG_VERSION=10.0 but do I have it? : Traceback (innermost last): File "regtest.py", line 12, in ? print os.environ['MDI_REG_VERSION'] File "/usr/local/lib/python1.5/UserDict.py", line 12, in __getitem__ def __getitem__(self, key): return self.data[key] KeyError: MDI_REG_VERSION Any other ideas? Any way to tell the os/posix module to "refresh"? By the way, thanks for the library implementation suggestion, but I must keep it the way it is, because other c, and c++ (at the class level) programs access this library. Thanks Rob In article <375BFE38.3FB3E83C at ix.netcom.com>, "Stephen J. Turner" wrote: > Hi Rob, > > > I have built a shared module that reads flat files for environment > > variable information, and makes subsequent putenv calls for those > > pertinent ones. This functionality is encapsulated in a c++ class, > > FileRegistry, which I think I have working correctly, using shadow > > classes under python. All I expose in the class is the ctor, the dtor, > > and the method called exportEnvVars(): > > > > %module MDIreg > > %{ > > #include "fileregistry.h" > > %} > > > > class FileRegistry > > { > > public: > > FileRegistry(bool, bool); > > ~FileRegistry(); > > void exportEnvVars(); > > }; > > > > ... > > > > However, I can't seem to get the envvars to persist into the current > > process space. If I fork off a child, then I can see the envvars that I > > expect. > > The problem is that, although putenv does indeed modify the current > process's environment, Python only reads the environment when the posix > module (imported by os) is first imported, so as to create the environ > dictionary. (Try confirming this behavior by postponing "import os" > until after your call to MDIreg.exportEnvVars. You should see your > environment changes reflected in os.environ.) > > The proper solution is, I think, to avoid the direct use of the putenv > function, and instead to use the Python C API to modify the os.environ > mapping (which calls putenv as a side effect). Here is a crude C module > to do just such a thing: > > -------------------- START modenv.c -------------------- > #include > > #include > #include > > static PyObject *modenv_load(PyObject *self, PyObject *args) > { > FILE *fp; > PyObject *os, *environ, *v; > char buf[256]; > char *file; > char *value; > > if (!PyArg_ParseTuple(args, "s", &file)) > return NULL; > > os = PyImport_ImportModule("os"); > environ = PyObject_GetAttrString(os, "environ"); > > if (fp = fopen(file, "r")) { > while (fgets(buf, sizeof(buf), fp), !feof(fp)) { > /* skip lines that do not contain equals sign */ > if (!(value = strchr(buf, '='))) > continue; > > /* remove trailing newline */ > buf[strlen(buf)-1] = '\0'; > > *value++ = '\0'; > v = PyString_FromString(value); > PyMapping_SetItemString(environ, buf, v); > Py_DECREF(v); > } > fclose(fp); > } > > Py_DECREF(environ); > Py_DECREF(os); > > Py_INCREF(Py_None); > return Py_None; > } > > static struct PyMethodDef modenv_methods[] = { > {"load", (PyCFunction)modenv_load, METH_VARARGS}, > {NULL, (PyCFunction)NULL, 0, NULL} > }; > > void initmodenv() > { > if (!Py_InitModule4("modenv", modenv_methods, NULL, NULL, > PYTHON_API_VERSION)) > Py_FatalError("can't initialize module modenv"); > } > -------------------- END modenv.c -------------------- > > Hope it helps. > > Regards, > Stephen > > -- > Stephen J. Turner > Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From donn at u.washington.edu Thu Jun 17 01:50:38 1999 From: donn at u.washington.edu (Donn Cave) Date: 17 Jun 1999 05:50:38 GMT Subject: Why is tcl broken? References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> <37682DD3.43923243@compaq.com> Message-ID: <7ka2be$qja$1@nntp6.u.washington.edu> Greg Ewing writes: ... | In my experience, I find that I can do with Python everything | that Tcl was designed for, do it more easily, do a lot | more besides, and have more fun in the process. I believe | the reason for this is rooted in some fundamental design | features of these languages, which I have sketched above. | I think that's about as close as one can get to providing | an objective argument as to whether one language is better | than another for a given purpose. How about Expect as an example? I don't mean to criticize the existing Python Expect implementation(s), have no idea where the state of the art is on that. I just remember trying to think of a natural Python idiom that would replace the "expect" verb's case switch flow of control. My experience is more or less the same as yours - rewrote Tcl software in Python and was henceforth a convert. But I think Tcl is syntactically more adaptable, where Python kind of makes a virtue of its fixed ways. Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From john at micrsoft.com Fri Jun 11 01:53:16 1999 From: john at micrsoft.com (John) Date: Thu, 10 Jun 1999 22:53:16 -0700 Subject: WinNT: Corrupt installation detected References: <7joq9h$qd2$1@schbbs.mot.com> Message-ID: <7jq8b6$fa4@dfw-ixnews4.ix.netcom.com> Check for a virus, it could be the CIH virus. From tacitus at home.com Sun Jun 20 17:05:51 1999 From: tacitus at home.com (TREVOR HUGHES) Date: Sun, 20 Jun 1999 21:05:51 GMT Subject: Python programming / Medford NJ Message-ID: <376D5880.BD548A0F@home.com> Programming positions available Full time and part time Full time position: Project leader/programmer Skills: Highly skilled in Python/JPython Experience with PostgreSQL, Informix or Oracle, etc. Database design and normalization, pattern and workflow modeling GUI design experience Documentation stickler Familiarity with Linux Part time positions: Programmer Python, Java and HTML programmers with the following backgrounds are needed. GUI Database Application/Module 'Glueing' Accounting Please send your resume and portfolio to mailto:tacitus at home.com Include a method to view sample applications you have written (URL, executable, etc.) and excerpts of documented python code of which you are particularly proud. The positions are based in Medford, New Jersey. Contact: Trevor Hughes 609.714.8900 x 251 tacitus at home.com From proteus at cloud9.net Tue Jun 1 13:09:44 1999 From: proteus at cloud9.net (Michael Muller) Date: Tue, 01 Jun 1999 13:09:44 -0400 Subject: Windows Stack Size References: <3752C225.65C98B52@cloud9.net> <3752F154.6C444928@ricochet.net> Message-ID: <375413D8.C3B02D2@cloud9.net> Guido van Rossum wrote: [snip] > > I've experienced some traps creating some deeply nested Tkinter controls > > under windows and I'm wondering if it could be due to a stack overflow. > > If it is indeed a stack overflow, the cause is more likely infinite > recursion on > your part. > > --Guido van Rossum AFAIK, the code is not recursive (sometimes with GUI callbacks, you can get a lot deeper into the stack than you might expect :-). It's been running fine under Linux for months, but under Win 95 it traps consistantly in some windows, _but not in all of them_, which is why I thought there might be a tiny-stack issue. 1 meg should be plenty of room. Here is the control in question: class ScrollingText(Frame): def __init__(self, parent = None, **kw): self.text = None if parent: Frame.__init__(self, parent) else: Frame.__init__(self) self.text = apply(Text, (self,), kw) self.text.grid(sticky = N+S+E+W) self.vsb = Scrollbar(self, command = self.text.yview) self.vsb.grid(row = 0, column = 1, sticky = N+S) self.hsb = Scrollbar(self, command = self.text.xview, orient = 'horizontal' ) self.hsb.grid(sticky = W+E) self.text.config(yscrollcommand = self.vsb.set, xscrollcommand = self.hsb.set, wrap = 'none' ) self.rowconfigure(0, weight = 1) self.columnconfigure(0, weight = 1) def __getattr__(self, attr): if self.text: return getattr(self.text, attr) else: raise AttributeError(attr) Upon further consideration, I wonder if the getattr could have something to do with this. I'd debug it myself except that I'm happily Windows-free (only creates problems when I have to write code for Windows users). If there is no obvious answer, I have a work-around. ============================================================================= michaelMuller = proteus at cloud9.net | http://www.cloud9.net/~proteus ----------------------------------------------------------------------------- In this book it is spoken of the Sephiroth, and the Paths, of Spirits and Conjurations; of Gods, Spheres, Planes and many other things which may or may not exist. It is immaterial whether they exist or not. By doing certain things certain results follow. - Aleister Crowley ============================================================================= From jbauer at rubic.com Wed Jun 2 09:14:27 1999 From: jbauer at rubic.com (Jeff Bauer) Date: Wed, 2 Jun 1999 13:14:27 GMT Subject: Is pcgi usable without Zope? References: <3755CA26.BCB7828A@digicool.com> Message-ID: <37552E33.C3CA673B@rubic.com> Paul Everitt wrote: > > Lloyd Zusman wrote: > > > > I have to admit that I'm a bit confused about pcgi these days. The > > most recent documentation for it was last updated in August, 1998, and > > it still refers to Bobo and Principia. > > We're certainly not helping -- I agree that stuff is strewn around all > over the place. > > > Now that we have Zope, is pcgi now intimately bundled with it, never > > to emerge on its own again? Or is there a way to run pcgi without > > Zope? > > I don't think PCGI is intimately bundled with Zope. Neither is the > object publisher, object database, the template system, etc. All can be > used independently. > > --Paul Argh. I responded to Lloyd and CC'd the Zope list, but neglected to include the Python list. My reply follows. -Jeff ---------------- Lloyd, PCGI is a tiny, yet integral part of Zope for some set of Zope applications, esp. where a web server front-end (e.g. Apache) is desired. It is possible to run Zope without PCGI (e.g. internal network, a.k.a. buzzword: 'intranet'). It is also possible to use PCGI without Zope. The pcgitest example is provided to test and demonstrate a free-standing PCGI application. And yet another alternative is to use PCGI with Zope components (ZPublisher, DocumentTemplate, BoboPOS) to build custom solutions. the-tyranny-of-choice-prevails-ly yr's Jeff Bauer Rubicon, Inc. P.S. A couple weeks ago I posted a message describing a new version of pcgi_publisher that would include an inactivity timer, i.e. would shutdown the LRP automatically after a specified period of inactivity. I think some people may find such a feature useful for custom PCGI apps. -JB From tre17 at pc142.cosc.canterbury.ac.nz Tue Jun 29 19:10:51 1999 From: tre17 at pc142.cosc.canterbury.ac.nz (Timothy R Evans) Date: 30 Jun 1999 11:10:51 +1200 Subject: printing with print References: <377925EF.1CBB640F@starvision.com> Message-ID: Angus MacKay writes: > is there any other way to print that with print? > perhaps with a real function. > > I want to print two things without a space being added between them: > foo = "there" > print "hi" + foo > > works fine but: > foo = 2 > print "hi" + foo > > does not. I like the printing of any object ability of "print" so I > do not want to use "" % style printing, I just want to be able to > govern the whitespace that gets output. > > cheers, Angus. import string def print_without_space(*args): print string.join(map(str, args), '') >>> foo = 2 >>> print_without_space('foo', '2', foo) foo22 This does what you want, but wouldn't the % operator be easier? -- Tim Evans From Lyle.Johnson at p98.f112.n480.z2.fidonet.org Wed Jun 30 00:07:51 1999 From: Lyle.Johnson at p98.f112.n480.z2.fidonet.org (Lyle Johnson) Date: Wed, 30 Jun 1999 05:07:51 +0100 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? Message-ID: <000015b6@bossar.com.pl> From: Lyle Johnson Just to add fuel to the fire, we now have a Python interface to FOX, a cross-platform GUI toolkit: http://www.cfdrc.com/pub/FOX/fox.html The latest version of the Python wrappers can be picked up at: ftp://ftp.cfdrc.com/pub/FOX/FXPy-0.99.42.tar.gz I don't know how the speed of FXPy would compare with some of the others mentioned (Tk, wxWindows, Qt, GTK, ...) but it would be worthwhile for some independent opinions. Lyle Cameron Laird wrote: > In article , > Michael P. Reilly wrote: > . > . > . > >There are other graphical packages for Python out there too, it would > >be appropriate to contrast them as well. > . > . > . > I occasionally work on such a comparison, currently available at http://starbase.neosoft.com/~claird/comp.lang.python/python_GUI.html>. > I welcome updates from readers. > -- > > Cameron Laird http://starbase.neosoft.com/~claird/home.html > claird at NeoSoft.com +1 281 996 8546 FAX From doughellmann at mindspring.com Fri Jun 11 10:11:41 1999 From: doughellmann at mindspring.com (Doug Hellmann) Date: Fri, 11 Jun 1999 14:11:41 GMT Subject: tkinter and events References: <7oX73.898$q3.114540@news21b.ispnews.com> Message-ID: <376119F3.F13759C9@mindspring.com> Paul Stillwell wrote: > > So, when I run the code and double click on o1, I get: > > >>> Clicked on domain 20 > > which is the last object I created even though I double clicked on the first > object. What am I doing wrong? The reason you're always seeing the same value is that the call in MyTestObject.__init__ to bind on the canvas always changes the existing binding on the *canvas*, but what you want is to bind events on the *rectangle*. Try changing these two lines: self.Box = Rectangle(Parent, self.Begx, self.Begy, self.Endx, self.Endy) ... self.Canvas.bind('', self.DoubleClickHandler) to: self.Box = Rectangle(Parent, self.Begx, self.Begy, self.Endx, self.Endy, fill='white') ... self.Box.bind('', self.DoubleClickHandler) I added the fill to the Rectangle so that I could double click on it more easily. Then, the important change is to use the bind method of the Rectangle object, instead of the Canvas. Doug From skip at mojam.com Tue Jun 15 22:54:53 1999 From: skip at mojam.com (Skip Montanaro) Date: Wed, 16 Jun 1999 02:54:53 GMT Subject: Cut down on writing repetitive code References: <3766f6a8.19474000@news2.mainnet.net> Message-ID: <3767128E.E049636C@mojam.com> Tim Gallati wrote: > If you do a lot of repetitive typing, check out Perfect Keyboard Lite. > I use it everyday and consider it my most useful program. Gee, I thought the usual OO way to cut down on repetitive typing was to abstract common code into base classes. I guess the original OO folks (Simula? Smalltalk?) got it all wrong 20- to 30-odd years ago. They should have invested in Mavis whats-her-name instead! No disclaimers in the original post. I guess it was an off-charter advertisement. Another company hits my bit bucket. -- Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/~skip/ 518-372-5583 From mgm at unpkhswm04.bscc.bls.com Mon Jun 21 13:04:44 1999 From: mgm at unpkhswm04.bscc.bls.com (Mitchell Morris) Date: 21 Jun 1999 17:04:44 GMT Subject: It's just magic, and I hate it ... Message-ID: Following is a piece of Python that is making me pull out my hair. The idea was to have a long-running process started by the user (via browser), and have the results trickle back in without timing out the request. My strategy was to define a per-connection file to hold results, fork off a child to generate results and put them into the file, and have the parent return a redirect to the results file. That way everyone is satisfied. It works if I run it from the command line as myself. It works if I run it from the command line as user 'WWW' group 'WWW' which is how the server will see it. The results file is created, the redirect is printed and a shell prompt returns, and the child has forked off and in fact updates the file every so often until it finishes at which time it replaces the contents with the simulated results. When run from the browser, however, the redirect doesn't happen until the child finishes. To recap, this is exactly the situation I need to avoid. Please help. +Mitchell #! /usr/bin/env python import sys import cgi import time import os import string import socket form = cgi.FieldStorage() if form.has_key("title"): hostname = socket.gethostbyaddr(socket.gethostname())[0] uniq = hex(os.getpid())[2:] + hex(int(time.time()))[2:] addr = "http://%s/~mgm/results/%s.html" % (hostname, uniq) fn = "/home/mgm/public_html/results/%s.html" % uniq # Generate the results file open(fn, "w").write(""" Results for [%s]

Beginning search at %s: """ % (form["title"].value, time.asctime(time.localtime(time.time())))) # Parent returns a redirect, child pretends to work for a while # accumulating results if os.fork() == 0: for i in (1, 2, 3): txt = open(fn, 'r').readlines() txt.insert(len(txt)-2, "

Still searching\n") open(fn, 'w').write(string.join(txt, '')) time.sleep(10) open(fn, 'w').write(""" Finished

Finished

If you had results, they'd be here """) else: print "Status: 302 Moved" print "Location:", addr else: print """Content-type: text/html Sample Form

Sample Form

Title:

""" -- Mitchell Morris A man said his credit card was stolen but he decided not to report it because the thief was spending less than his wife did. From dalke at bioreason.com Sun Jun 27 20:41:33 1999 From: dalke at bioreason.com (Andrew Dalke) Date: Sun, 27 Jun 1999 18:41:33 -0600 Subject: GC In Python: YAS (Yet Another Summary) References: <000301bebffc$184fcf60$da9e2299@tim> <3776A025.53B35103@inrialpes.fr> Message-ID: <3776C4BD.F266EC1@bioreason.com> Vladimir Marangozov said: > you seem to overlook one of the nicest features of pymalloc. If > the extension module works in current Python + libc malloc, it > will work with Python + pymalloc because of the dynamic block > management. Ahh, but as I found out trying 1.5.2beta, the library we use requires libmalloc, and not the libc malloc; it wants mallopt. To make things worse, it doesn't actually *use* that function. It contains an internal function which references mallopt but the header files don't list the internal function so none of our code uses it. We only need the -lmalloc for creating shared libs with 1.5.2. I believe their current version removed this requirement. Andrew dalke at bioreason.com From marilena_kolia at my-deja.com Sun Jun 27 06:13:58 1999 From: marilena_kolia at my-deja.com (marilena_kolia at my-deja.com) Date: Sun, 27 Jun 1999 10:13:58 GMT Subject: sms tests Message-ID: <7l4th5$kub$1@nnrp1.deja.com> Hi, I am trying to test the SMS performance and get some results about the time it takes a message to be transfered, but also the delays of each part of this procedure. I am planning to use Tcl programming. Does anybody know how to do it or have some suggestions about it? Thank you Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From johann at physics.berkeley.edu Fri Jun 11 17:47:25 1999 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 11 Jun 1999 14:47:25 -0700 Subject: Problem with Lists & Index command References: Message-ID: Benjamin Schollnick writes: > It appears that INDEX doesn't work on a multiple > dimension list???? Yes, index won't work. Why? Because the list is a list of tuples, lst = [("key1", "val1"), ("key2", "val2")...] so "key1" isn't an element of the list. The tuple ("key1", "val1") is, however, but to find that you'd need to know the value, which defeats the purpose. Basically, the list could have been lst = [("key1", "val1"), ("key2", "val2"), "key1"] Here, it seems much more plausible that lst.index("key1") will return 2, not 0. Since list can contain any type, it doesn't automatically know that it should look inside sublists to find elements. -- Johann Hibschman johann at physics.berkeley.edu From kontiki3136 at my-deja.com Sat Jun 26 01:07:55 1999 From: kontiki3136 at my-deja.com (kontiki3136 at my-deja.com) Date: Sat, 26 Jun 1999 05:07:55 GMT Subject: is there a Gantt chart toolkit? References: <7in1y2imtt.fsf@betty.artisan.com> Message-ID: <7l1n76$o9g$1@nnrp1.deja.com> In article <7in1y2imtt.fsf at betty.artisan.com>, alt at artisan.com wrote: > > subject says it all. > > Thanks! > Albert Try PlanBee (http://www.guysoftware.com/planbee.htm) Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From bb296_nospam_ at ecs.soton.ac.uk Tue Jun 8 17:03:26 1999 From: bb296_nospam_ at ecs.soton.ac.uk (Ben) Date: Tue, 8 Jun 1999 22:03:26 +0100 Subject: Problem with embedded python Message-ID: <7jk0cm$4hk@wapping.ecs.soton.ac.uk> Greetings, I have embedded python into a win32 c++ application using PyRun_SimpleFile. This executes a python script at regular (25 times a second-ish) intervals. Also included in this C++ application is a procedure which handles the window messages, which I have also tried to script. Unfortunately, running any script in this function crashes windows with a nasty protection fault. Do I need to run my scripts on seperate threads... or in different interpreters. or is this genuinely a bug.. Yours confusedly Sean (srd196 at ecs.soton.ac.uk) From pduffin at mailserver.hursley.ibm.com Fri Jun 11 08:02:41 1999 From: pduffin at mailserver.hursley.ibm.com (Paul Duffin) Date: Fri, 11 Jun 1999 13:02:41 +0100 Subject: Why is tcl broken? References: <375F82C7.CF0F0477@iname.com> <375FD703.C6D@mailserver.hursley.ibm.com> <375FEC11.FD20EDE6@iname.com> Message-ID: <3760FAE1.373B@mailserver.hursley.ibm.com> Fernando Mato Mira wrote: > > Paul Duffin wrote: > > > Whether the choice of language is a good or bad idea depends entirely on > > the context. i.e. environment and job to be done. > > > > You cannot avoid taking into account the context even if you only look > > at the language from a semantic / syntactic view point. > > OK. Let's drop the word `choice'. Why do people think tcl is a bad > language then, strictly from a _design_ viewpoint? Let's assume > imperative languages are OK (responses like "it's not declarative" > are obvious and uninteresting and do not help comparing it to other > imperative languages). Obviously I don't it has a few holes in it and some things could be improved but I don't consider it a "bad" language. -- Paul Duffin DT/6000 Development Email: pduffin at hursley.ibm.com IBM UK Laboratories Ltd., Hursley Park nr. Winchester Internal: 7-246880 International: +44 1962-816880 From akuchlin at mems-exchange.org Tue Jun 1 16:13:12 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: Tue, 1 Jun 1999 16:13:12 -0400 (EDT) Subject: Browsers In-Reply-To: References: <37530E1B.CAC2991C@cwcom.net> Message-ID: <14164.16088.585496.742187@amarok.cnri.reston.va.us> >Daniel Faulkner wrote: >> Is there a basic browser some where that I can look at to see how it >> works? (not grail) >> As I can't understand much of the python internet software and don't >> understand how to parse the HTML once I've got it. G. David Kuhlman writes: >Lynx is a text mode browser: > http://lynx.browser.org/ >For fancier stuff, look at Mozilla: > http://www.mozilla.org/ Note, however, that an HTML parser capable of coping with all the invalid HTML on the Web is a complicated beast. For example, Lynx currently has an SGMLish style parser that has been brain damaged in various ways to cope with invalid HTML. I don't know how much error correction Grail includes, but it might actually be a simpler parser if it hasn't been complicated with various error recovery hacks. Another good option might be to look at the test code in htmllib.py,, which does simple HTML-to-text formatting. (When trying to figure out a module, always look in the module's code first, since authors will often include simple examples or test scripts inside an 'if __name__=='__main__'" block. -- A.M. Kuchling http://starship.python.net/crew/amk/ Time, place, and action may with pains be wrought, / But Genius must be born; and can never be taught. -- John Congreve From wtanksle at dolphin.openprojects.net Wed Jun 30 20:46:28 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Thu, 01 Jul 1999 00:46:28 GMT Subject: Language extensibility (was: Why is tcl broken?) References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> <37682DD3.43923243@compaq.com> <7ka2be$qja$1@nntp6.u.washington.edu> <37776FFA.2D85@mailserver.hursley.ibm.com> <876748mcxg.fsf@home.ivm.de> <37788BB9.ABD@mailserver.hursley.ibm.com> <3779ED0F.2C67@mailserver.hursley.ibm.com> <377A3383.D453468@iname.com> <377aa228.31380423@news.jpl.nasa.gov> Message-ID: On Wed, 30 Jun 1999 23:07:23 GMT, William H. Duquette wrote: >On Wed, 30 Jun 1999 17:10:59 +0200, Fernando Mato Mira >>Tim Bradshaw wrote: >>> But the language of Lisp macros is Lisp, that's really the whole >>> point! Without knowing TCL, I find it hard to see how you can >>> introduce new constructs to the language *without* a macro language, >>> even if that language is TCL. >>Err.. What about Forth keywords? >Tcl is a lot like Forth, too. :-) That's how it initially stuck me -- Tcl looks like it was, at least in concept, designed by someone attempting to apply Forth's looseness to a language with a parser and a syntax. This is something I've always been curious about, and Tcl satisfied that curiosity -- I don't think it's a good mix. >You can do more interesting things in Lisp with readmacros, >from what I'm told, including making it look like an entirely >different language. Tcl code always looks like Tcl code. Now Lisp is a worthwhile improvement on Forth. ;-) (Yes, I know -- the ancestry goes the other way around: Lisp -> Scheme -> Forth.) >Will -- -William "Billy" Tanksley From news at dorb.com Tue Jun 22 13:23:22 1999 From: news at dorb.com (Darrell) Date: Tue, 22 Jun 1999 13:23:22 -0400 Subject: Python scope and parameter passing method References: Message-ID: What your asking is more than a five minute explanation. And looks like a home work assignment. Check out the python docs, search for these topics with dejanews and check out the FAQ at python.org Don't forget books like "Learning Python" and others from O'REILLY. Good luck. -- --Darrell From morse at harborcom.net Wed Jun 16 23:30:57 1999 From: morse at harborcom.net (Kevin Dahlhausen) Date: Wed, 16 Jun 1999 23:30:57 -0400 Subject: Undefined symbol when freezing? Message-ID: <37686BF0.942532CF@harborcom.net> I'm trying to freeze a simple app w/an extension created with Swig. Freeze generates the code and it compiles fine, but at runtime I get the following: Traceback (innermost last): File "./hello.py", line 4, in ? from fltk import * File "fltk.py", line 1, in ? File "fltk_pre.py", line 2, in ? ImportError: /usr/local/lib/libswigpy.so: undefined symbol: PyType_Type I'm not sure where to start looking to solve this. Does anyone have any ideas? From olipt at mayo.edu Wed Jun 16 16:41:06 1999 From: olipt at mayo.edu (Travis Oliphant) Date: Wed, 16 Jun 1999 15:41:06 -0500 Subject: extention modules. In-Reply-To: <99061620265802.00254@Vegus> References: <99061620265802.00254@Vegus> Message-ID: > Should I write it as two seperate modules (the compiled C one and > the native python one) or is there a way to combine them in one. I am > using the SWIG program to wrap my C library. It is often the practice to put make a Python module that imports a C module. That's what I'm doing with Multipack http://oliphant.netpedia.net/multipack.html You can construct C-modules that don't need a Python wrapping, however, it is easier to handle the user-end API in Python. If you are doing math intensive calculations, have you looked at the Numeric extensions? Good luck, Travis From bernhard at alpha1.csd.uwm.edu Sat Jun 19 19:37:12 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 19 Jun 1999 23:37:12 GMT Subject: BiBTeX module? References: <7k950a$hsb@cs.vu.nl> Message-ID: On 18 Jun 1999 16:58:49 +0200, Lars Marius Garshol wrote: >| I've also started such a project as free software. >BTW: an XML version of BibTeX would be very useful. What do you mean with XML version? > People keep asking >for it in XML/SGML newsgroups, and it just plain makes sense, since >XML is much better suited for this sort of thing than TeX is. I am not sure. Somebody has to write a good DTD first and then XML doesn't have TeX's typesetting capabilities. Often I find myself using them to really typeset the References precisely. If you want something like a .bib format in XML you might have to invent the needed typesetting rules, too. But, of course, if would be good, if the new program can handle different Bibliographic databases. Bernhard -- Research Assistant, Geog Dept UM-Milwaukee, USA. (www.uwm.edu/~bernhard) Funding/Promoting Association for a Free Informational Infrastructure (ffii.org) From robin at jessikat.demon.co.uk Thu Jun 3 07:04:17 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Thu, 3 Jun 1999 12:04:17 +0100 Subject: Threaded Tkinter References: Message-ID: <07u8dGAxEmV3EwoL@jessikat.demon.co.uk> In article , Gerald Gutierrez writes > >Hi all. > >I have two questions and I'd really appreciate it if someone could >help me sort it out. > >My first one -- I'm starting out with Tkinter. I wrote the code below, >which will supposedly create a button with an image, that image >changing every second. If I set the button to call swapIcons() when >pressed, the image changes fine, but using the SpinThread, the icons >don't change. Is this because Tkinter is not thread-safe and I cannot >safely change the button's image property from within a thread other >than the main one? > ... code & Q2 elided ... I tried this with 1.5.2 + win95 + local gifs and it worked fine for me. Should I leave it running for a while? -- Robin Becker From andreas.schoerk at sap-ag.de Mon Jun 7 07:43:46 1999 From: andreas.schoerk at sap-ag.de (Andreas Schoerk) Date: Mon, 7 Jun 1999 13:43:46 +0200 Subject: Newbie-q: Debugging tkinter(and other GUI)-Programs Message-ID: <7jgbd4$sse$1@mailusr.wdf.sap-ag.de> Hello, I have have problems using idle, pydebug.py or pythonwin-debugger for the debugging of programs which use tkinter-widgets in NT. Sometimes python hangs, sometimes it doesn`t show any widgets of the debugged program. Is it right, that using pdb.py is the only suitable way to debug GUI-Progs ? Perhaps, I encountered only configuration problems. Does anybody know how to solve this. I tried to solve this by myself by controling pdb like xxgdb controls gdb, but I don?t want to create a new debugger on my own. Andreas From bwarsaw at cnri.reston.va.us Fri Jun 4 11:01:54 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Fri, 4 Jun 1999 11:01:54 -0400 (EDT) Subject: "The Python Way" References: <14167.3323.707498.300295@anthem.cnri.reston.va.us> <99060320192502.01312@quadra.teleo.net> Message-ID: <14167.60002.783156.583193@anthem.cnri.reston.va.us> >>>>> "PP" == Patrick Phalen writes: PP> For that matter, what makes me think that Guido and Timbot are PP> two different entities? Well, the one time I was in Boston and had the chance to meet Timbot, "he" feigned illness. Guido and Gordon both claim to have met him, but somehow I think they have vested interests in maintaining the illusion of Tim-as-not-bot. Way I see it, making the Timbot code Open Source is the only moral thing to do. Besides, wouldn't it be cool to check out the Python translation of the old Emacs Lisp RMS AI code? -Barry From eugene.leitl at lrz.uni-muenchen.de Fri Jun 11 04:07:40 1999 From: eugene.leitl at lrz.uni-muenchen.de (eugene.leitl at lrz.uni-muenchen.de) Date: Fri, 11 Jun 1999 02:07:40 -0600 Subject: CCL:Announcing PyDaylight 0.5 Message-ID: <3760C3CC.9FF7A619@bioreason.com> From: Andrew Dalke PyDaylight 0.5 Bioreason , a leading provider of chemoinformatics knowledge discovery services. has developed an interface between the Daylight toolkit and the Python programming language and is making this package freely available under the LGPL license. Additional information is available from: http://starship.python.net/crew/dalke/PyDaylight/ and from my MUG'99 presentation at: http://www.daylight.com/meetings/mug99/ The end result is that new chemical analysis algorithms can be developed in a much shorter time and with fewer programming errors. Python is an interpreted, interactive, object-oriented programming language with modules, classes, exceptions, very high level dynamic data types, and dynamic typing. It is a superb tool for rapid application prototyping and development. For more information, see http://www.python.org/ . The Daylight toolkit is sold by Daylight Information Systems (see http://www.daylight.com/). The toolkit includes C/FORTRAN libraries for manipulating molecular topologies, depicting the results, conducting subgraph searches, and more. (We don't get any money from them for promoting their software :) The PyDaylight interface builds on Roger E. Critchlow Jr.'s DaySWIG package but adds a true object-oriented interface layer above the underlying C libraries as well as iterators, automatic garbage collection, and exception handling. We develop all of our applications using PyDaylight and it has been very stable and useful. Since it has been an in-house project there is very little end-user documentation or tutorials, which is why it is labeled 0.5 instead of 1.0. Thus, this release shouldn't be used by someone who doesn't like reading source code to figure out what's going on. However, I would like to know who might be interested in introductory material, so if you plan on using the Daylight toolkit and would like to try out the PyDaylight interface, please drop me a message so I can better gauge what to work on next. Andrew Dalke dalke at bioreason.com -= This is automatically added to each message by mailing script =- CHEMISTRY at ccl.net -- To Everybody | CHEMISTRY-REQUEST at ccl.net -- To Admins MAILSERV at ccl.net -- HELP CHEMISTRY or HELP SEARCH CHEMISTRY-SEARCH at ccl.net -- archive search | Gopher: gopher.ccl.net 70 Ftp: ftp.ccl.net | WWW: http://www.ccl.net/chemistry/ | Jan: jkl at osc.edu From jhouchin at texoma.net Mon Jun 21 15:22:34 1999 From: jhouchin at texoma.net (Jimmie Houchin) Date: Mon, 21 Jun 1999 19:22:34 GMT Subject: IPwP books available, 99cents References: <376a479b.131911984@news.texoma.net> <376e7e32.727764@news.demon.co.uk> Message-ID: <376e8fa9.161102353@news.texoma.net> I don't think you've misread Python's direction. This bookstore is not normal bookstore. I don't know what there sources are, but all of their books are 75% off minimally and none over $4.99 regardless of original price. I would suspect the average consumer in this bookstore has never heard of Python so they end up on the 99 cent shelf simply because they aren't moving. Most of their computer books aren't worth buying. "Using Netscape 1.0", etc.... :) However, IPwP has maintained it's value much better than most computer books. :) Jimmie On Mon, 21 Jun 1999 18:03:53 GMT, andy at robanal.demon.co.uk (Andy Robinson) wrote: >jhouchin at texoma.net (Jimmie Houchin) wrote: > >>Hello, >> >>I was visiting a bookstore in Plano, TX yesterday and saw two new >>copies of Internet Programming with Python on their shelves for $.99, >>yes 99 cents. >> >Well, here in the U.K. they are appearing back on the shelves in the >good bookstores after a long absence, and still at full price. I >really hope your bookstore has misread Python's direction and not >mine! > >- Andy Robinson > From chalaoux at cybercable.fr Sat Jun 5 17:42:23 1999 From: chalaoux at cybercable.fr (FR chalaoux) Date: Sat, 05 Jun 1999 23:42:23 +0200 Subject: Looking for help to compile Python Message-ID: <375999BE.38F30059@cybercable.fr> Hi All, I'm trying to compile Python 152 on a Intel machine with the standard RH51 and I obtain this error (cf error make below). I joined the config.log file in attachement. Some explanation about failed in config.log are welcome ... Thanks for help. FR error from make: ============= gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c ./timemodule.c ./timemodule.c: In function `time_strptime': ./timemodule.c:429: warning: assignment makes pointer from integer without a cast gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c ./operator.c gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c ./fcntlmodule.c gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c ./pwdmodule.c gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c ./grpmodule.c gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c ./selectmodule.c gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c ./socketmodule.c ./socketmodule.c: In function `initsocket': ./socketmodule.c:2212: `uint32_t' undeclared (first use this function) ./socketmodule.c:2212: (Each undeclared identifier is reported only once ./socketmodule.c:2212: for each function it appears in.) ./socketmodule.c:2212: parse error before `0xe0000000U' ./socketmodule.c:2217: parse error before `0xe0000001U' ./socketmodule.c:2222: parse error before `0xe00000ffU' make[1]: *** [socketmodule.o] Error 1 make[1]: Leaving directory `/usr/local/Python-1.5.2/Modules' make: *** [Modules] Error 2 -- FR Chalaoux ADVL (Au Del? de Vos Limites) chalaoux at cybercable.fr http://www.advl.org/ -------------- next part -------------- This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. configure:608: checking MACHDEP configure:653: checking CCC configure:669: checking for --without-gcc configure:746: checking for gcc configure:859: checking whether the C compiler (gcc ) works configure:875: gcc -o conftest conftest.c 1>&5 configure:901: checking whether the C compiler (gcc ) is a cross-compiler configure:906: checking whether we are using GNU C configure:915: gcc -E conftest.c configure:934: checking whether gcc accepts -g configure:997: checking LINKCC configure:1014: checking LDLIBRARY configure:1043: checking for ranlib configure:1076: checking for ar configure:1150: checking how to run the C preprocessor configure:1171: gcc -E conftest.c >/dev/null 2>conftest.out configure:1230: checking for AIX configure:1255: checking for minix/config.h configure:1265: gcc -E conftest.c >/dev/null 2>conftest.out configure:1261: minix/config.h: No such file or directory configure: failed program was: #line 1260 "configure" #include "confdefs.h" #include configure:1304: checking whether gcc accepts -OPT:Olimit=0 configure:1318: gcc -OPT:Olimit=0 -o conftest -g -O2 conftest.c 1>&5 cc1: Invalid option `-OPT:Olimit=0' configure: failed program was: #line 1314 "configure" #include "confdefs.h" int main() { return 0; } configure:1338: checking whether gcc accepts -Olimit 1500 configure:1352: gcc -Olimit 1500 -o conftest -g -O2 conftest.c 1>&5 gcc: 1500: No such file or directory cc1: Invalid option `-Olimit' configure: failed program was: #line 1348 "configure" #include "confdefs.h" int main() { return 0; } configure:1375: checking for C preprocessor type configure:1388: gcc -c -g -O2 conftest.c 1>&5 configure:1405: checking for ANSI C header files configure:1418: gcc -E conftest.c >/dev/null 2>conftest.out configure:1485: gcc -o conftest -g -O2 conftest.c 1>&5 configure:1516: checking for dlfcn.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for fcntl.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for limits.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for locale.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for ncurses.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for pthread.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for signal.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for stdarg.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for stddef.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for stdlib.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for thread.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1522: thread.h: No such file or directory configure: failed program was: #line 1521 "configure" #include "confdefs.h" #include configure:1516: checking for unistd.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for utime.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for sys/audioio.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1522: sys/audioio.h: No such file or directory configure: failed program was: #line 1521 "configure" #include "confdefs.h" #include configure:1516: checking for sys/file.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for sys/lock.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1522: sys/lock.h: No such file or directory configure: failed program was: #line 1521 "configure" #include "confdefs.h" #include configure:1516: checking for sys/param.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for sys/select.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for sys/time.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for sys/times.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for sys/un.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for sys/utsname.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for sys/wait.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1557: checking for dirent.h that defines DIR configure:1570: gcc -c -g -O2 conftest.c 1>&5 configure:1595: checking for opendir in -ldir configure:1614: gcc -o conftest -g -O2 conftest.c -ldir 1>&5 ld: cannot open -ldir: No such file or directory configure: failed program was: #line 1603 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char opendir(); int main() { opendir() ; return 0; } configure:1681: checking for clock_t in time.h configure:1710: checking for mode_t configure:1743: checking for off_t configure:1776: checking for pid_t configure:1809: checking return type of signal handlers configure:1831: gcc -c -g -O2 conftest.c 1>&5 configure:1850: checking for size_t configure:1883: checking for uid_t in sys/types.h configure:1918: checking size of int configure:1937: gcc -o conftest -g -O2 conftest.c 1>&5 configure:1957: checking size of long configure:1976: gcc -o conftest -g -O2 conftest.c 1>&5 configure:1996: checking size of void * configure:2015: gcc -o conftest -g -O2 conftest.c 1>&5 configure:2036: checking for long long support configure:2046: gcc -c -g -O2 conftest.c 1>&5 configure:2060: checking size of long long configure:2079: gcc -o conftest -g -O2 conftest.c 1>&5 configure:2102: checking size of off_t configure:2122: gcc -o conftest -g -O2 conftest.c 1>&5 configure:2144: checking whether to enable large file support configure:2170: checking for --with-next-framework configure:2187: checking for --with-dyld configure:2213: checking SO configure:2227: checking LDSHARED configure:2267: checking CCSHARED configure:2289: checking LINKFORSHARED configure:2324: checking for dlopen in -ldl configure:2343: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:2371: checking for shl_load in -ldld configure:2390: gcc -o conftest -g -O2 conftest.c -ldld -ldl 1>&5 ld: cannot open -ldld: No such file or directory configure: failed program was: #line 2379 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char shl_load(); int main() { shl_load() ; return 0; } configure:2424: checking for t_open in -lnsl configure:2443: gcc -o conftest -g -O2 conftest.c -lnsl -ldl 1>&5 /tmp/cca058591.o: In function `main': /usr/local/Python-1.5.2/configure:2439: undefined reference to `t_open' configure: failed program was: #line 2432 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char t_open(); int main() { t_open() ; return 0; } configure:2464: checking for socket in -lsocket configure:2483: gcc -o conftest -g -O2 conftest.c -lsocket -ldl -ldl 1>&5 ld: cannot open -lsocket: No such file or directory configure: failed program was: #line 2472 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char socket(); int main() { socket() ; return 0; } configure:2504: checking for socket in -lnet configure:2523: gcc -o conftest -g -O2 conftest.c -lnet -ldl -ldl 1>&5 ld: cannot open -lnet: No such file or directory configure: failed program was: #line 2512 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char socket(); int main() { socket() ; return 0; } configure:2547: checking for --with-libs configure:2561: checking for --with(out)-readline configure:2576: checking for --with-dec-threads configure:2592: checking for --with-threads configure:2606: checking for --with-thread configure:3113: checking for --with-sgi-dl configure:3136: checking for --with-dl-dld configure:3169: checking for alarm configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for chown configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for clock configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for dlopen configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for execv configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for flock configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for fork configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for fsync configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for fdatasync configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for ftime configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for ftruncate configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for getpeername configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for getpgrp configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for getpid configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for getpwent configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for gettimeofday configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for getwd configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 /tmp/cca061601.o: In function `main': /usr/local/Python-1.5.2/configure:3191: the `getwd' function is dangerous and should not be used. configure:3169: checking for kill configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for link configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for lstat configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for mkfifo configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for mktime configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for nice configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for pause configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for plock configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 /tmp/cca062881.o: In function `main': /usr/local/Python-1.5.2/configure:3191: undefined reference to `plock' configure: failed program was: #line 3174 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char plock(); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char plock(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_plock) || defined (__stub___plock) choke me #else plock(); #endif ; return 0; } configure:3169: checking for pthread_init configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 /tmp/cca063011.o: In function `main': /usr/local/Python-1.5.2/configure:3191: undefined reference to `pthread_init' configure: failed program was: #line 3174 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char pthread_init(); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char pthread_init(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_pthread_init) || defined (__stub___pthread_init) choke me #else pthread_init(); #endif ; return 0; } configure:3169: checking for putenv configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for readlink configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for select configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for setgid configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for setlocale configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for setuid configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for setsid configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for setpgid configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for setpgrp configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for setvbuf configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for sigaction configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for siginterrupt configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for sigrelse configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 /tmp/cca065061.o: In function `main': /usr/local/Python-1.5.2/configure:3191: undefined reference to `sigrelse' configure: failed program was: #line 3174 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char sigrelse(); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sigrelse(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_sigrelse) || defined (__stub___sigrelse) choke me #else sigrelse(); #endif ; return 0; } configure:3169: checking for strftime configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for strptime configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for symlink configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for tcgetpgrp configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for tcsetpgrp configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for timegm configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for times configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for truncate configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for uname configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for waitpid configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3226: checking for fseek64 configure:3254: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 /tmp/cca066791.o: In function `main': /usr/local/Python-1.5.2/configure:3248: undefined reference to `fseek64' configure: failed program was: #line 3231 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char fseek64(); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char fseek64(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_fseek64) || defined (__stub___fseek64) choke me #else fseek64(); #endif ; return 0; } configure:3226: checking for fseeko configure:3254: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 /tmp/cca066921.o: In function `main': /usr/local/Python-1.5.2/configure:3248: undefined reference to `fseeko' configure: failed program was: #line 3231 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char fseeko(); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char fseeko(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_fseeko) || defined (__stub___fseeko) choke me #else fseeko(); #endif ; return 0; } configure:3226: checking for fstatvfs configure:3254: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 /tmp/cca067051.o: In function `main': /usr/local/Python-1.5.2/configure:3248: undefined reference to `fstatvfs' configure: failed program was: #line 3231 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char fstatvfs(); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char fstatvfs(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_fstatvfs) || defined (__stub___fstatvfs) choke me #else fstatvfs(); #endif ; return 0; } configure:3226: checking for ftell64 configure:3254: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 /tmp/cca067181.o: In function `main': /usr/local/Python-1.5.2/configure:3248: undefined reference to `ftell64' configure: failed program was: #line 3231 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char ftell64(); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char ftell64(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_ftell64) || defined (__stub___ftell64) choke me #else ftell64(); #endif ; return 0; } configure:3226: checking for ftello configure:3254: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 /tmp/cca067311.o: In function `main': /usr/local/Python-1.5.2/configure:3248: undefined reference to `ftello' configure: failed program was: #line 3231 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char ftello(); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char ftello(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_ftello) || defined (__stub___ftello) choke me #else ftello(); #endif ; return 0; } configure:3226: checking for statvfs configure:3254: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 /tmp/cca067441.o: In function `main': /usr/local/Python-1.5.2/configure:3248: undefined reference to `statvfs' configure: failed program was: #line 3231 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char statvfs(); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char statvfs(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_statvfs) || defined (__stub___statvfs) choke me #else statvfs(); #endif ; return 0; } configure:3282: checking for dup2 configure:3310: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3282: checking for getcwd configure:3310: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3282: checking for strdup configure:3310: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3282: checking for strerror configure:3310: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3282: checking for memmove configure:3310: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3337: checking for getpgrp configure:3387: gcc -c -g -O2 conftest.c 1>&5 configure: In function `main': configure:3383: too many arguments to function `getpgrp' configure: failed program was: #line 3380 "configure" #include "confdefs.h" #include int main() { getpgrp(0); ; return 0; } configure:3403: checking for setpgrp configure:3453: gcc -c -g -O2 conftest.c 1>&5 configure: In function `main': configure:3449: too many arguments to function `setpgrp' configure: failed program was: #line 3446 "configure" #include "confdefs.h" #include int main() { setpgrp(0,0); ; return 0; } configure:3469: checking for gettimeofday configure:3519: gcc -c -g -O2 conftest.c 1>&5 configure:3538: checking whether time.h and sys/time.h may both be included configure:3552: gcc -c -g -O2 conftest.c 1>&5 configure:3573: checking whether struct tm is in sys/time.h or time.h configure:3586: gcc -c -g -O2 conftest.c 1>&5 configure:3607: checking for tm_zone in struct tm configure:3620: gcc -c -g -O2 conftest.c 1>&5 configure:3678: checking for time.h that defines altzone configure:3690: gcc -c -g -O2 conftest.c 1>&5 configure: In function `main': configure:3686: `altzone' undeclared (first use this function) configure:3686: (Each undeclared identifier is reported only once configure:3686: for each function it appears in.) configure: failed program was: #line 3683 "configure" #include "confdefs.h" #include int main() { return altzone; ; return 0; } configure:3712: checking whether sys/select.h and sys/time.h may both be included configure:3725: gcc -c -g -O2 conftest.c 1>&5 configure:3741: checking whether char is unsigned configure:3805: checking for working const configure:3859: gcc -c -g -O2 conftest.c 1>&5 configure:3882: checking for working volatile configure:3891: gcc -c -g -O2 conftest.c 1>&5 configure:3908: checking for working signed char configure:3917: gcc -c -g -O2 conftest.c 1>&5 configure:3934: checking for prototypes configure:3943: gcc -c -g -O2 conftest.c 1>&5 configure:3958: checking for variable length prototypes and stdarg.h configure:3977: gcc -c -g -O2 conftest.c 1>&5 configure:3993: checking for bad exec* prototypes configure:4002: gcc -c -g -O2 conftest.c 1>&5 configure:4019: checking for bad static forward configure:4040: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:4059: checking whether va_list is an array configure:4074: gcc -c -g -O2 conftest.c 1>&5 configure:4090: checking for gethostbyname_r configure:4118: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:4138: checking gethostbyname_r with 6 args configure:4159: gcc -c -g -O2 conftest.c 1>&5 configure:4333: checking for __fpu_control in -lieee configure:4352: gcc -o conftest -g -O2 conftest.c -lieee -ldl 1>&5 configure:4382: checking for --with-fpectl configure:4405: checking for --with-libm=STRING configure:4426: checking for --with-libc=STRING configure:4450: checking for hypot configure:4478: gcc -o conftest -g -O2 conftest.c -lieee -ldl -lm 1>&5 configure:4505: checking for hypot configure:4563: checking for genuine getopt configure:4583: gcc -o conftest -g -O2 conftest.c -lieee -ldl 1>&5 configure: failed program was: #line 4571 "configure" #include "confdefs.h" #include extern int optind, opterr, getopt(); extern char* optarg; int main() { char* av[] = { "testprog", "parameter", "-fFlag", NULL }; opterr = 0; if (getopt(3, av, "f:") == 'f') { exit(1); } exit(0); } configure:4601: checking what malloc(0) returns configure:4628: gcc -o conftest -g -O2 conftest.c -lieee -ldl 1>&5 From mark_removethis_ at _removethis_btweng.krakow.pl Thu Jun 10 13:59:39 1999 From: mark_removethis_ at _removethis_btweng.krakow.pl (MK) Date: Thu, 10 Jun 1999 17:59:39 GMT Subject: dict vs kjBuckets vs ??? References: <000e01beb21f$a4c5a860$2fa22299@tim> Message-ID: <375ffb1d.26189164@news.cyf-kr.edu.pl> On Tue, 8 Jun 1999 22:27:39 -0400, "Tim Peters" wrote: >> A million? >No. >It all depends on how much memory you have and how well the hash function is >working. Note that dicts work hard to "randomize" the addresses at which >they store keys, so memory locality can be terrible. But if there's no >pattern to customer ID accesses, locality would be terrible in a 1M array >too. In some book on algorithms I've read that after inserting limited number of items performance of operating on hash tables drops dramatically. I plan to write a program that would store lots (in range of 10M or even more) of relatively small objects (a few hundred bytes at most), so what do you think I should use? I thought about dictionaries, kjBuckets, or maybe even library called Metakit for Python (http://www.equi4.com/metakit/info/README-Python.html). what-do-you-think-ly y'rs -------------------------------------------------- Reality is something that does not disappear after you cease believing in it - VALIS, Philip K. Dick -------------------------------------------------- Delete _removethis_ from address to email me From MHammond at skippinet.com.au Sat Jun 19 05:07:56 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Sat, 19 Jun 1999 19:07:56 +1000 Subject: NT References: <376A6D64.DF881D27@phoenix-edv.netzservice.de> Message-ID: <7kfmj5$ksm$1@m2.c2.telstra-mm.net.au> Holger Jannsen wrote in message <376A6D64.DF881D27 at phoenix-edv.netzservice.de>... >C:\myPython>installation15.py /? |more >Traceback (innermost last): ... >If I start with 'C:\myPython>python installation15.py /? |more' >there's no problem and it works allright. This is a known bug with the NT command processor. Every application has this problem, not just Python. Mark. From schorsch at schorsch.com Thu Jun 17 17:44:11 1999 From: schorsch at schorsch.com (Georg Mischler) Date: Thu, 17 Jun 1999 21:44:11 GMT Subject: do anonymous pipes normally work on NT? References: <4D0A23B3F74DD111ACCD00805F31D8100DB90DE4@RED-MSG-50> Message-ID: <7kbq78$vgm$1@nnrp1.deja.com> Bill Tutt wrote: > > Patch info: > > Alter the PyHANDLE_Check() branch of win32processmodule_win32.cpp:sethandle > to: > *pobHandle = v; > if (PyWinObject_AsHANDLE(v, ph)) > { > Py_INCREF(v); > } > else > { > rc = -1; > } > The cast that was there before was setting *ph equal to the > Python reference count on v. Ok, I'll have to build this stuff myself some day anyway... But then, I just downloaded win32_src.zip and Pythonwin_src.zip and didn't find anything resembling a win32processmodule in there. Guess I am looking in the wrong place. Where is this module defined? Thanks a lot -schorsch -- Georg Mischler -- simulation developper -- schorsch at schorsch.com +schorsch.com+ -- lighting design tools -- http://www.schorsch.com/ Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From paul at prescod.net Tue Jun 1 10:41:37 1999 From: paul at prescod.net (Paul Prescod) Date: Tue, 1 Jun 1999 14:41:37 GMT Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <87pv3iq6ss.fsf@ev.netlab.co.jp> <3752C76D.604CD474@prescod.net> <87n1ykr0z9.fsf@ev.netlab.co.jp> <375372F6.A874554@prescod.net> <87hfosquc0.fsf@ev.netlab.co.jp> Message-ID: <3753F121.E4A9BE8B@prescod.net> Yukihiro Matsumoto wrote: > > |Is there a language with real GC where destructors are called as > |predictably as they are in Python? > > I said nothing about the destructor invocation predictability. I consider that a part of the definition of destructor. > I don't understand and really interested in why you guys require > to predict destructor invocation so much, but it's another story. What if I am holding GUI "device context" objects and the GUI has a limited number of them. I don't think that there is a way to tell the GC that there is a limited number of them. It doesn't know that device contexts are a limited resource, just as memory is. > |Speed wasn't my concern. I asked about references in C code. Do we use > |PyObject **s instead of PyObject *s now? > > Sorry, I don't understand. Do we have to use PyObject **s instead of > PyObject *s, if we choose real GC? Imagine I have some C code. It stores away a pointer to a Python object: PyObject *myObject=someObject; Now a compacting GC moves someObject. My pointer is out of date, right? If I want to be able to move someObject around in a mark and sweep style operation then I need the pointer I hold to be static. What GC algorithm does Ruby use and how much overhead does it add? > Second, do you think that optimization for basic users compensates the > risk of potential memory leak, by cyclic structures or missing DECREF > in extension modules? Do you mean it's easy for experts to find > cyclic structure and cut their reference to destruct? For me, it's > not. I hate that. Is this because I'm not a Python expert? It's pretty much a toss-up for me. In general I prefer optimizations that make the language easy for new users to those that are for complex, long running programs but full garbage collection would make complex programs a fair bit easier. -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco "Silence," wrote Melville, "is the only Voice of God." The assertion, like its subject, cuts both ways, negating and affirming, implying both absence and presence, offering us a choice; it's a line that the Society of American Atheists could put on its letterhead and the Society of Friends could silently endorse while waiting to be moved by the spirit to speak. - Listening for Silence by Mark Slouka, Apr. 1999, Harper's From shunting at goSPS.com Wed Jun 2 20:39:43 1999 From: shunting at goSPS.com (Sam Hunting) Date: Wed, 2 Jun 1999 20:39:43 -0400 Subject: Newbie seeks help with COM? DLLs? Message-ID: <7j4iiv$l1r$1@autumn.news.rcn.net> Background: I'm operating in a VB/NT shop, but I want to introduce a Python solution for the sake of doing *extremely* rapid development of GUI widgets. (When you have a layout manager as in Tkinter, you don't spend a lot of time manually tweaking layouts in VB's IDE. In fact, you don't even need to worry about entering coordinate points, so it would be very easy to create a data-(XML) driven widget factory.) We need to incorporate the widgets into an existing software product so that, for example, a Python-developed dialog will appear, into which the user will enter data, which is then passed back to the application. Now here is where my newbie nature takes over, since I am very new to Python, and even newer to the VB/NT/Windows worlds -- how "incorporate"? The software product understands DLLs, and also understands COM. I've had it suggested to me that the way to get where I need to do, is to turn the dialogs into COM servers, and then call them from the software application, which is the client. (1) I worked through the "Quick Start to Server Side COM and Python", and registered the Hello World server successfully. Can anyone point me to some VB code that would enable me to test the test server? (2) If the COM approach is not the right approach, can someone suggest a better one? And point me to some sample code that I can test, run, and improve to help me solve the problem? I thought the hard part would be learning enough of Python to construct the widgets -- and now the widgets are constructed, and even some factory machinery. But the hard part turned out to be the easy part. Thanks in advance for any help you can give. Sam Hunting From faria at ppgia.pucpr.br Tue Jun 22 14:31:31 1999 From: faria at ppgia.pucpr.br (faria) Date: Tue, 22 Jun 1999 15:31:31 -0300 Subject: Unbound method Message-ID: <001701bebcdd$73d3b080$656211c8@miro.lami.pucpr.br> Hi everyone!!! I'm new in Python and in Brasil we don't wave any book of Python (and it's very expensive to import!), so I have to ask you all this boring questions! Why it doens't work ? --- test.py | |class A: | a = 'Greetings from Brasil!!!' | def pa(self): | print self.a Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> from test import * >>> x = A >>> x.a 'Greetings from Brasil!!!' >>> x.pa >>> Henrique Faria Desenvolvedor Multim?dia LAMI - Laborat?rio de M?dias Interativas Puc-PR faria at ppgia.pucpr.br -------------- next part -------------- A non-text attachment was scrubbed... Name: Henrique Faria.vcf Type: text/x-vcard Size: 436 bytes Desc: not available URL: From claird at Starbase.NeoSoft.COM Thu Jun 10 16:03:05 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 10 Jun 1999 15:03:05 -0500 Subject: Why is tcl broken? References: <375F82C7.CF0F0477@iname.com> Message-ID: <7jp5lp$jo1$1@Starbase.NeoSoft.COM> In article , Michael P. Reilly wrote: . . . >I believe that current releases of Tcl can handle null bytes, but I >have not verified that. Yes. Tcl8.0 and after handle null bytes. . . . -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From wtanksle at dolphin.openprojects.net Wed Jun 30 13:51:57 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Wed, 30 Jun 1999 17:51:57 GMT Subject: Language extensibility (was: Why is tcl broken?) References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> <37682DD3.43923243@compaq.com> <7ka2be$qja$1@nntp6.u.washington.edu> <37776FFA.2D85@mailserver.hursley.ibm.com> <876748mcxg.fsf@home.ivm.de> <37788BB9.ABD@mailserver.hursley.ibm.com> <3779ED0F.2C67@mailserver.hursley.ibm.com> <377A3383.D453468@iname.com> Message-ID: On Wed, 30 Jun 1999 17:10:59 +0200, Fernando Mato Mira wrote: >Tim Bradshaw wrote: >> But the language of Lisp macros is Lisp, that's really the whole >> point! Without knowing TCL, I find it hard to see how you can >> introduce new constructs to the language *without* a macro language, >> even if that language is TCL. >Err.. What about Forth keywords? Forth doesn't have keywords, so I'm guessing you mean immediate words. They're written in the same language, but they tend to use words that wouldn't be used otherwise (source access and such). So they really are a seperate language; after all, Forth is all about building new languages. Another possible meaning of 'keyword' might be creating words. Those are cool, and don't require or generally use new vocabulary, but do require grasping some pretty new concepts -- compile-time and runtime take on new meanings. -- -William "Billy" Tanksley From mwh21 at cam.ac.uk Tue Jun 15 21:21:51 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 16 Jun 1999 02:21:51 +0100 Subject: ANN: Stackless Python 0.2 References: <37628EAA.C682F16C@appliedbiometrics.com> <7k4fd4$c04$1@brick.cswv.com> <376636EA.84240129@appliedbiometrics.com> <7k6ttr$i5g$1@brick.cswv.com> Message-ID: neelk at brick.cswv.com (Neel Krishnaswami) writes: > In article <376636EA.84240129 at appliedbiometrics.com>, > Christian Tismer wrote: > > > > > >Neel Krishnaswami wrote: > > > >[Stackless Python 0.2] > > > >> This is very neat, and you are completely deranged. I know just > >> enough to know that I should cheer you on, mind, but I'll try to > >> cheer loudly. Feel free to make an announce when you add coroutine > >> support. Please? :) > > > >Thanks :-) > > > >Sure I will. I'd like to know wether my binary works ok for you. > >You might also try a recursive function, it should raise an > >exception after 29999 recursions (just to have *a* limit). > > Unfortunately, I couldn't get it to build (I'm on a Linux machine). > I tried copying the files from the stackless distribution into the > appropriate places in the Python source distribution, but I get > the following error: > > $ gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c myreadline.c -o myreadline.o > In file included from ../Include/Python.h:38, > from myreadline.c:42: > ../Include/patchlevel.h:69: parse error before `5' > ../Include/patchlevel.h:69: stray '\' in program > ../Include/patchlevel.h:70: stray '\' in program > ../Include/patchlevel.h:71: stray '\' in program > > [plus more cascading errors as a result of this] > > Apparently gcc is not liking this: > > /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. > Use this for numeric comparisons, e.g. #if PY_VERSION_HEX >= ... */ > #define PY_VERSION_HEX ((PY_MAJOR_VERSION << 24) | \ > (PY_MINOR_VERSION << 16) | \ > (PY_MICRO_VERSION << 8) | \ > (PY_RELEASE_LEVEL << 4) | \ > (PY_RELEASE_SERIAL << 0)) > > The '5' in the "parse error before '5'" is the PY_MICRO_VERSION; the > macro looks ok to me, but I haven't used C to any great extent in > literally years. Am I making some very naive mistake? Ah, got this one; Naughty Chris's archive contains files with CRLF line endings. This doesn't bother gcc in most places, except where a backslash is used to continue a line, when it gets the screaming heebie-jeebies. Eliminate the nasty ^M's and it all gets better. Also diff stops reporting that every single line in the file as changed, which was confusing me. It doesn't seem to link yet. Oh well, it's late and I'm going to bed. I can send you a diff against cvs's latest if that would help. Yours, Michael > >I'm just undecided on the design. There are a couple of > >different coroutine interfaces. You find them for instance in > >Scheme, in Modula II, some Oberons, Icon, and in Tim Peter's > >example which I added to my stackless archive. > >Do you have a proposal? > > Not really; all I know is a little Scheme, and that part of my brain > is telling me that "coroutines are just closures over continuations." > Fortunately, I'm still able to realize that that's probably the > wrong interface. :) > > > Neel From thstr at serop.abb.se Thu Jun 17 02:50:42 1999 From: thstr at serop.abb.se (Thomas S. Strinnhed) Date: Thu, 17 Jun 1999 08:50:42 +0200 Subject: GNU python? (GNUbe question) References: <3765B8B4.18DE0257@spots.ab.ca> <37667309.F9BBAE9A@mojam.com> <022c01beb7ec$f9617070$f29b12c2@pythonware.com> Message-ID: <37689AC2.B8F6579A@serop.abb.se> Hi Fredrik Lundh wrote: > > Skip Montanaro wrote: > > > Looking to try out python... is there a GNU python for Win9x? and a > > > tutorial maybe? > > > > Not sure just how a GNU Python would differ from the real thing. > > a bit more like GNUscript, I suppose: > > http://art.net/Studios/Hackers/Hopkins/Don/text/gnuscript.html > > Sounds like a good thing this GNUscript, it'll do almost anything. Is there a download site ;-) / The GNUbe From tuna at delirious.fsnnet Mon Jun 21 03:12:28 1999 From: tuna at delirious.fsnnet (Lloyd Weehuizen) Date: 21 Jun 1999 07:12:28 GMT Subject: Linking an Interpreter dynamically Message-ID: Hi! I was just wondering if it is possible to create a dynamically linkable python interpreter? I've looked in the docs, but can't seem to find anything, and "make sharedinstall" doesn't seem to give me any linkable libraries?? Any help appreciated. Thanks Lloyd Lloyd From dave_kirby at eur.3com.com Mon Jun 21 11:51:12 1999 From: dave_kirby at eur.3com.com (Dave Kirby) Date: Mon, 21 Jun 1999 15:51:12 GMT Subject: wierdness with pythonwin dialogs, threads & refcounts References: <1282457297-115891134@hypernet.com> Message-ID: <376e53a0.24292290@nnrp.uk.insnet.net> On Thu, 17 Jun 1999 19:15:42 -0500, "Gordon McMillan" > >I played with this enough to find that he's onto something. Without >any threading, the dialog gets a WM_DESTROY and goes thru __del__. >When executed from a threading.Thread, it never goes thru OnDestroy. >I tried doing DoModal myself, then un-hooking the messages myself. >No luck. Perhaps because there's no parent window, and the trhead >does not have a Windows message queue? Yep, I have got it to work correctly by replacing the thread.start_new_thread function with my own version using the WinThread class: #------- 8< ----------------------------- from pywin.mfc.thread import WinThread class MyThread(WinThread): def __init__(self, fn, args ): WinThread.__init__(self) self.fn = fn self.args = args def InitInstance(self): apply( self.fn, self.args ) self.PumpIdle() self.close() def start_win_thread( fn, args ): thread = MyThread( fn, args ) thread.CreateThread() #------- 8< ----------------------------- I am still climbing the learning cliff of Win32 threads so I dont know if it is the approved way of doing it, but it seems to work well enough for my purposes. Dave K From tim_one at email.msn.com Fri Jun 25 03:12:38 1999 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 25 Jun 1999 03:12:38 -0400 Subject: total idiot question: +=, .=, etc... In-Reply-To: Message-ID: <000d01bebeda$1b7430a0$d29e2299@tim> [Reimer Behrends] > While I'd be the first to agree that C++ is not exactly the epitome of > language design, I would think that at least the local variables should > be easy to identify. The only real problem is to distinguish global > variables from instance variables. And this is made worse in C++ by > spreading all the information related to a class over more than one > file. It should be noted that other languages do not necessarily have > the same problem and that careful design can easily avoid it. But even with declarations up the wazoo, distinguishing local from instance vars is a major problem in real-life C++: any OO language with declarations has to allow local vars to shadow instance vars, else method implementations can be broken by trivial changes in far-removed superclasses (e.g., Java flatly prohibits shadowing in most cases -- but specifically allows this one). Any reasonably careful programmer will avoid such shadowing when the code is first written, but under time & modification that never lasts; perhaps just because the names most natural to a problem domain are limited. So I've never worked on a (successful <0.9 wink>) C++ project where coding conventions didn't require prefixing instance vars with some magical sequence reserved for that purpose. The one I'm working on now requires member var names to match the case-sensitive regexp ^m[A-Z]\w* and similarly starting with "g" for extern data and "s" for file-static data (local names are "anything else"). Other projects enforced other conventions -- it's a real relief to come back to Python and see it always spelled "self."! > But I do not think that the most basic operations of an OO language > should be complicated by cumbersome syntax (this includes instance > variable access and local method calls). The language should encourage > use of these elements, not get in your way. Readability is more important to me over the long haul. Say what you like, but which vars belong to the instance is screamingly obvious the instant you see self.x = self.y + k while in x = y + k it's at best a minor puzzle and at worst a long & tedious grep project. explicitly-favoring-explict-ly y'rs - tim From akuchlin at mems-exchange.org Thu Jun 17 11:36:42 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: Thu, 17 Jun 1999 11:36:42 -0400 (EDT) Subject: New release of mmapfile module Message-ID: <199906171536.LAA03274@amarok.cnri.reston.va.us> A new release of the mmapfile module is available from: ftp://starship.python.net/pub/crew/amk/new/mmapfilemodule.c A simple test program is at: ftp://starship.python.net/pub/crew/amk/new/mmapdemo.py The module is based on Sam Rushing's code for Win32, and has been hacked to work on Unix as well. It allows treating a chunk of a file as a sequence object that behaves mostly like a mutable string; for example, you can open a file, map a large chunk of it, and then use the string and re modules to search through it. It's been suggested that mmapfile be added to the distribution, and before doing that I'd like to get the portability kinks ironed out -- hence this new release. Please try it and let me know if there are compilation problems on your favorite Unix variant. If other OSes such as MacOS, BeOS, or whatever, also support memory-mapped files through another mechanism, patches would be welcome. -- A.M. Kuchling http://starship.python.net/crew/amk/ All I want is the answer to one simple question before I run screaming back to the bughouse. Is this real or isn't it? -- Cliff Steele in DOOM PATROL #21 From gmcm at hypernet.com Sat Jun 12 00:23:53 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Fri, 11 Jun 1999 23:23:53 -0500 Subject: Embedding Question from a Newbie In-Reply-To: <00b801beb43d$b3efe240$a515bfd1@EVILDEAD> Message-ID: <1282960805-85602773@hypernet.com> CyRiuS writes: > i have a question. i am new to python and am trying to use it as a > scripting language for a game i am working on. I have the > interpreter embedded and running scripts but i have a few questions. > > 1) can i return values from the python script to the C/C++ program? > for example say at the end of my script, it returned 'character' and > character was equal to say 'hi' now is there anyway my C/C++ program > could find out that the script just returned the value 'hi'? > > 2) is there anyway I can pass values from the C/C++ program into the > python script? > > and > > 3) say i had a python script that had several functions (defs). is > there anyway i could call just one of these defs from the C/C++ > program without calling the entire script? The answer to all 3 is yes. The details will be found in the embedding docs and the C API docs. I'd guess so far you've only used the Very High Level layer (PyRun_ etc). You want to start exploring the Abstract layer, where you work with PySequences and such. At that level it's still pretty straight forward. Drop down further only if you really have to. Almost anything you'll need to do is done somewhere in the Modules or Objects subdirectories. grep-is-your-best-friend-ly y'rs - Gordon From bmcd at es.co.nz Mon Jun 21 17:45:59 1999 From: bmcd at es.co.nz (Ben Caradoc-Davies) Date: 21 Jun 1999 21:45:59 GMT Subject: chomp() References: <376EA9E4.5B3D38EC@starvision.com> Message-ID: On Mon, 21 Jun 1999 14:08:52 -0700, Angus MacKay wrote: >is there an equivilent of perl's chomp() in python or >do I have to write the function myself? string.rstrip(s) strips all trailing whitespace characters from s. If you really, really, want your trailing whitespace, try if s[-1]=='\n': s = s[:-1] -- Ben Caradoc-Davies From gherman at my-deja.com Tue Jun 15 10:23:08 1999 From: gherman at my-deja.com (Dinu C. Gherman) Date: Tue, 15 Jun 1999 14:23:08 GMT Subject: Python Paterns Message-ID: <7k5nk0$nc0$1@nnrp1.deja.com> jblake at eskimo.com (Jonathon) posted the following about a week ago: > Subject: Python Paterns > Date: 9 Jun 1999 23:35:22 GMT > From: jblake at eskimo.com (Jonathon) > Organization: Pi Psi > Newsgroups: comp.lang.python > > > Searching Python.org, I didn't come across > anything _recent_ about > patterns in Python. Did that SIG die, get swallowed up > or did I miss their home? > > The only documentation I could find was > http://starship.python.net/crew/gandalf/DNET/classes/index.html > which was for Python 1.4 on an NT machine, last updated in > 1997 and a paper given at the sixth conference on Python. I tried to reply to this before using Deja.com, but somehow Deja.com was unable to locate this posting... Let me try again. Well, I guess the question can be answered like this: the SIG died as you correctly noticed, the reasons being a lack of contributions as well as an ill-defined (or at least vague) purpose of the SIG itself. Occasionally, there are pattern-related postings to c.l.p. but it's rather hard to locate them later, especially if the authors mis-spell crucial words inside... ;-) Cheers, Dinu --- Dinu C. Gherman : Women inspire us to great things and : prevent us from achieving them. (Dumas) ................................................................ LHS International AG : http://www.lhsgroup.com 8050 Zurich : http://www.zurich.ch Switzerland : http://pgp.ai.mit.edu : mobile://49.172.3060751 ......................:......................................... Vote against SPAM on http://www.politik-digital.de/spam Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From Klaus.Schilling at home.ivm.de Wed Jun 16 11:34:20 1999 From: Klaus.Schilling at home.ivm.de (Klaus Schilling) Date: 16 Jun 1999 17:34:20 +0200 Subject: OO (was: Why is tcl broken?) References: <000801beb745$02768220$979e2299@tim> <871zfdp73f.fsf@home.ivm.de> Message-ID: <873dzsma6b.fsf@home.ivm.de> Lars Marius Garshol writes: > * Klaus Schilling > | > | Steele just rediscovered Scheme. > > What, do you mean recently? No, in the sense `Steele merely rediscovered scheme, not bring it into being' Klaus Schilling From scott at chronis.pobox.com Wed Jun 2 21:15:49 1999 From: scott at chronis.pobox.com (scott cotton) Date: Wed, 2 Jun 1999 21:15:49 -0400 Subject: metaclasses and setting __class__ In-Reply-To: <1283761142-37459855@hypernet.com>; from Gordon McMillan on Wed, Jun 02, 1999 at 05:05:01PM -0500 References: <19990602133443.A3846@chronis.pobox.com> <1283761142-37459855@hypernet.com> Message-ID: <19990602211549.A5987@chronis.pobox.com> On Wed, Jun 02, 1999 at 05:05:01PM -0500, Gordon McMillan wrote: | scott cotton writes: | | > Last night i was playing with meta classes, and found out | > that we are not able to assign an instance's __class__ | > attribute to a metaclass instance. was just wondering if | > this is probably always going to be the case, or if there | > are any plans to make .__class__ assignable to such beasts. | | It wouldn't do any good. By the time you have an instance, it's too | late to add metaclass behaviors. All the magic happens at the time | the "class MyClass(MyMetaClassInstance):" is encountered. At this | point, MyMetaClassInstance can do all kinds of evil things to the way | MyClass works. It seems like all this could happen when __class__ is assigned to as well, provided the underlying mechanism knew what to do -- seems like somehow checking interface rather than type for that assignment would do the trick, but all that is conjecture - i don't even know if it's possible - or desirable but it did seem intuitive. | Assigning to an instance's __class__ will alter the instance's | behavior and appearance, but not to the same extent that using a | metaclass will. challenge: make a metaclass that mucks with it's own class hierarchy at run time on a per-instance basis. for example: class A(Meta): pass class B(A): pass class C(A): pass have instances of A become instances of C on instantiation, and instances of B become instances of C with B replaced for A in all the __bases__ (and all __bases__ of all __bases__ ...) of C. Never mind why it might be considered useful, or even worse why it could actually make things more clear. I think I found that metaclasses are the wrong tool for this, but only after hours of playing with the madness and nearing a state of raving lunacy. at one point early in the game, the following: class MyRealClass(MetaClassInstance): pass print MyRealClass, type(MyRealClass) yielded "__getitem__ <'string'>". I swear - and no I didn't redefine the builtin 'type'. needless to say, i gave up after a while, and used the following function instead: def rebuild(leaf_class, oldbase, newbase): if leaf_class == oldbase: return newbase class foo: pass oldbases = leaf_class.__bases__ newbases = [] for base in oldbases: newbases.append(rebuild(base, oldbase, newbase)) foo.__bases__ = tuple(newbases) for k, v in leaf_class.__dict__.items(): if k != '__bases__': foo.__dict__[k] = v return foo It was used sortof like this: class A: def __init__(self): if self.__class__ != A: self.__class__ = rebuild(C, A, B) else: self.__class__ = C class B(A): def extrastuff(self): ... class C(A): def other_type_of_extrastuff(self): ... scott From michaelb at gold.net.au Fri Jun 11 06:39:53 1999 From: michaelb at gold.net.au (Michael Bell) Date: Fri, 11 Jun 1999 10:39:53 GMT Subject: Scripting Telnet References: <37606A0D.6332A9C2@horvath.com> <7jpv0q$90v$1@Starbase.NeoSoft.COM> Message-ID: <19990611.10395300@belfry> Once upon a time there was a Python solution called PIPE (for Python Interactive Process Enabler), put together by John Croix. I've got version 0.1, but it's dated 1997. Did this project go anywhere? I did a quick search of python.org but didn't find anything. On 6/11/99, 11:15:38 AM, claird at Starbase.NeoSoft.COM (Cameron Laird) wrote regarding Re: Scripting Telnet: > Bob Horvath wrote: > . > >Well, the tcl based expect is probably the most appropriate tool for such a > >thing, but there is a pythonized version(s) of it as well. The one I can > >think of is ExpectPy, (http://www1.shore.net/~arcege/python/ExpectPy/), but > >I seem to remember seeing at least one other one. > > > You're probably thinking of . From rceci at adams.com Mon Jun 7 10:34:31 1999 From: rceci at adams.com (rceci at adams.com) Date: Mon, 07 Jun 1999 14:34:31 GMT Subject: Question about envvars Message-ID: <7jgl9n$p13$1@nnrp1.deja.com> swig 1.1p5 Python 1.5.1 SGI-Irix 6.5/MIPspro 7.2.1 Hello, I have built a shared module that reads flat files for environment variable information, and makes subsequent putenv calls for those pertinent ones. This functionality is encapsulated in a c++ class, FileRegistry, which I think I have working correctly, using shadow classes under python. All I expose in the class is the ctor, the dtor, and the method called exportEnvVars(): %module MDIreg %{ #include "fileregistry.h" %} class FileRegistry { public: FileRegistry(bool, bool); ~FileRegistry(); void exportEnvVars(); }; ... However, I can't seem to get the envvars to persist into the current process space. If I fork off a child, then I can see the envvars that I expect. Here is a pretty explanatory log: [rceci_latest]{rcecil}/vobs/srg/src/registry> python Python 1.5.1 (#3, May 21 1999, 16:24:24) [C] on irix646-32-mips2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import os >>> import MDIreg >>> m = MDIreg.FileRegistry(1,1) >>> m.exportEnvVars() >>> os.system("env | grep MDI_REG_VERSION") MDI_REG_VERSION=10.0 0 >>> os.environ['MDI_REG_VERSION'] Traceback (innermost last): File "", line 1, in ? File "/usr/local/lib/python1.5/UserDict.py", line 12, in __getitem__ def __getitem__(self, key): return self.data[key] KeyError: MDI_REG_VERSION >>> os.environ.keys() ['WINEDITOR', 'TS', 'MAIL', 'NOMSGLABEL', 'PWD', 'MU', 'MDI_PRINT_UCO_SIZ', 'topdir', 'MDI_ACAR_SITE', 'VOB_ROOT', 'QTDIR', 'LM_LICE NSE_FILE', 'NPX_PLUGIN_PATH', 'PRINTER', 'HOST', 'PYTHONPATH', 'CLASSPATH', 'MOZILLA_HOME', 'REMOTEUSER', 'NOMSGSEVERITY', 'LIB_TOOL S', 'CVSROOT', 'SHELL', 'TCLLIBPATH', 'LIB_VAR', 'MANPATH', 'EDITOR', 'CLEARCASE_BLD_UMASK', 'HZ', 'HOME', 'CLEARCASE_ROOT', 'SHLVL' , 'LIBRARY_PATH', 'TZ', 'BUILDMEISTER', 'TERM', 'LANG', 'VOB_TOP', 'LD_LIBRARY_PATH', 'MSGVERB', 'MAGIC_PATH', 'CVINSTRLIB', 'PATH', 'T', 'USER', 'LOGNAME', 'CPLUS_INCLUDE_PATH', 'SCRIPTS_DIR', 'HOSTTYPE', 'REMOTEHOST', 'BL', 'CLEARCASE_CMDLINE', 'LIB_ARCH'] >>> >>> os.system("/usr/local/bin/python") Python 1.5.1 (#3, May 21 1999, 16:24:24) [C] on irix646-32-mips2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import os >>> os.environ['MDI_REG_VERSION'] '10.0' >>> ^D 0 >>> ^D --- As you can see I can fork of either a simple csh command, or a completely new python interpreter, and either way, the children can see the result of the exportEnvVars() method call. By the way, when I build my module in debug mode, I can see my "destroyed" messages I specifically coded in the dtor of the class, to verify that my FileRegistry object is being destroyed when I expect it. Any ideas or suggestions? Thanks Rob Cecil Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From john.michelsen at gte.net Tue Jun 29 17:23:40 1999 From: john.michelsen at gte.net (John Michelsen) Date: Tue, 29 Jun 1999 21:23:40 GMT Subject: Python GUIs: Summary and Conclusion References: <99FA4A1A1280BEBD.0A1ABA62CC989479.4C2C6022F695BEAC@lp.airnews.net> <377805C8.C6BBD4C1@unifix-online.com> Message-ID: Philippe, they look very nice. How did you use them with Python and Tkinter? Any Python code that you would like to share demonstrating BWidgets? I would be especially interested to see use of the tree widget. Thanks, John Philippe Chassany wrote in message <377805C8.C6BBD4C1 at unifix-online.com>... >> .... >> More widgets should be added to Tk(Inter). >> .... > >Our company has made a 100% Tcl/Tk Toolkit named "BWidget". >BWidgets are "well known" in the Tcl community because >they are free, flexible, powerful and completly interpreted (no C). >More than 25 widgets are available. > >We have tested BWidget with Tkinter the result is quite fine : >Quick and good looking. It's a good alternative to GTk or Qt >compiled programming to have professional application GUIs. > >Try it to make your own idea (free download, screenshots, >full HTML manuals) > >http://www.unifix-online.com/BWidget > >-- >Philippe Chassany >UNIFIX - http://www.unifix-online.com >-- > > From herzog at online.de Sat Jun 19 14:05:16 1999 From: herzog at online.de (Bernhard Herzog) Date: 19 Jun 1999 20:05:16 +0200 Subject: An Un-optimization anecdote with text-processing References: <376B1AAC.19FE8BCE@mysolution.com> <376B8C51.5D59C774@vision.arc.nasa.gov> Message-ID: Chad Netzer writes: > Well, I was in the process of starting to write a Perl program > for a simple text processing task I have to do, when this post > steered me back to my language of choice. As I wrote my script, > which is called by the Unix "find" command, I got to thinking > about how it was anti-optimized... Here is what I wrote: > > import string > import sys > > # Way stupid algorithm, but I'm running it overnight :) > filename = sys.argv[1] > f = open(filename, 'r') > text = f.read() > while 1: > i = string.find(text, r'/"') > if i == -1: break > text = text[:i+1] + "index.html" + text[i+1:] > > f.close() > f = open(filename, 'w') > f.write(text) > f.close() > > > > As you can see, the core loop scans the entire file for a string > match, builds a new string by concatenation, then starts scanning from > the beginning yet again. It almost doesn't seem like it could be made > much worse, unless one deliberately tried. > > Which brings me to my new game... Rather than finding a nice hack > that would speed things up and use less lines of code, how about > finding the hack that uses the least amount of code to make this as > slow as possible? Adding pointless operations, or other obfuscations > don't count. Try to make this operation as elegantly short, and as > painfully slow as possible... > > For example: > > I had originally coded this with string.index() using a try/except > pair to break out of the loop, which took more lines of code but is > probably faster than my loop (it avoids the 'if' statement in the > loop, for the overhead of one exception). So I changed it to be > shorter and (possibly) slower. Can anyone think of other elegant > unoptimizations? My first attempt at a shortest implementation for the string replacement part is this: Python 1.5.2 (#3, Apr 21 1999, 16:51:54) [GCC 2.7.2.3] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> from string import * >>> s = ' "www.python.org/" xyzzy/plugh "fee/fie/foe/foo/" ' >>> join(split(s, '/"'), '/index.html"') ' "www.python.org/index.html" xyzzy/plugh "fee/fie/foe/foo/index.html" ' >>> But I fear it's also one of the fastest... Or how about: >>> reduce(lambda x,y: x[-1] == '/' and y == '"' and x+'index.html"' or x+y, s) ' "www.python.org/index.html" xyzzy/plugh "fee/fie/foe/foo/index.html" ' you don't even need the string module. This is veerrryyyy sssssllllllooooooowwwwwwww because the result string is copied over and over again and you call a python function for every char. To give you an impression of the speed difference: >>> def test1(s): .. reduce(lambda x,y: x[-1] == '/' and y == '"' and x+'index.html"' or x+y, s) .. >>> def test2(s): .. join(split(s, '/"'), '/index.html"') .. >>> import time >>> from string import * >>> s = open("data.html").read() >>> t = time.clock(); test1(s); print time.clock() - t 69.49 >>> t = time.clock(); test2(s); print time.clock() - t 0.01 >>> -- Bernhard Herzog | Sketch, a python based drawing program herzog at online.de | http://www.online.de/home/sketch/ From aahz at netcom.com Thu Jun 24 14:37:37 1999 From: aahz at netcom.com (Aahz Maruch) Date: Thu, 24 Jun 1999 18:37:37 GMT Subject: Thanks for Python... References: <376ead64@anonymous.newsfeeds.com> <7ktfn0$5q$1@aurwww.aur.alcatel.com> <14194.18324.582362.94739@amarok.cnri.reston.va.us> <37726458.C8CC9623@zipzap.ch> Message-ID: In article <37726458.C8CC9623 at zipzap.ch>, Boris Borcic wrote: >Andrew M. Kuchling wrote: >> >> Once you accept that the world is a giant computer run by white mice, all >> other movies fade into insignificance. >> -- Mutsumi Takahashi, on _The Hitch-hiker's Guide to the Galaxy_ > >Should this be taken as a rebuttal of "Matrix" ? _THHGttG_ was written so long before _Matrix_ that if anything it's the other way 'round. -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Javascript: The 90s incarnation of the Commodore 64 Sprite -- SJM From Klaus.Schilling at home.ivm.de Fri Jun 18 07:05:48 1999 From: Klaus.Schilling at home.ivm.de (Klaus Schilling) Date: 18 Jun 1999 13:05:48 +0200 Subject: Problem with Curses References: Message-ID: <87ogidzs37.fsf@home.ivm.de> kjwolf at online.de (Klaus-Juergen Wolf) writes: > It depends on when the executable is linked to libmytinfo, which only > takes place on platforms that don't know the terminfo database, like > BSD and Solaris; there are two competing declarations of tputs(). Why doesn't Freebsd know the terminfo database? Can't the one that is integrated into ncurses be used on FreeBSD? Klaus Schilling From davecook at home.com Fri Jun 4 01:13:44 1999 From: davecook at home.com (David M. Cook) Date: Fri, 04 Jun 1999 05:13:44 GMT Subject: pyGTK on Windows References: <3757D453.A302E757@interar.com.ar> Message-ID: On Fri, 04 Jun 1999 10:27:48 -0300, Nahuel wrote: >Hi, im about to do a cross-plataform GUI application in Linux and >Windoze... i must >choose the GUI toolkit.. my question is .. can i use pyGTK under >Windows??? As someone has mentioned, even if it is made to work under windows, pygtk would not have a windows look and feel. wxPython is probably your best bet if tkinter is not acceptable. Dave Cook From k_mcdermott at my-deja.com Fri Jun 11 05:37:05 1999 From: k_mcdermott at my-deja.com (k_mcdermott at my-deja.com) Date: Fri, 11 Jun 1999 09:37:05 GMT Subject: Help: MIME Attachments Message-ID: <7jqlc1$bk0$1@nnrp1.deja.com> Hi, I am trying to send a plain text file, as an attachment through e-mail. This is a hacked version of my test code below, basically the program interprets a dump from a diary system, and then writes Lotus Notes importable Calendar entries. I want to then mail them to users with an accompanying instruction header to allow them to import them into their calendars... The only problem is the mailing them to users bit, I either get the plain text in the file (which I don't want, I just want them to detach the text file and then import) or I get the Base64 encoded text, either way there is no attachment... My Problem is that the MIME headers indicating Base64 encoding appears a line after the content type, and I believe that this blank line terminates the headers... So my question is, at what point should I be introducing these headers...? TIA Kevin ps Python has brought a project that was originally quoted at "tens of thousands of pounds and hundreds of man-hours" down to around 4 hours so far, and if I can crack this, ZERO outlay :-) import base64 import sys import StringIO import MimeWriter from smtplib import SMTP # Mails the Diary Import file to the user in MIME format # Based upon code by GVR def mailFileToUser(_userName, _fileName): outputfp = StringIO.StringIO() w = MimeWriter.MimeWriter(outputfp) w.addheader("subject", "Diary Entries from Mainframe") w.flushheaders() w.startmultipartbody("mixed") subwriter = w.nextpart() f = subwriter.startbody('application/octet-stream; name="DiaryFile.notes"') >>> This is the puzzling bit... subwriter.addheader("Content-Transfer-Encoding", "base64") subwriter.addheader("Content-Disposition", 'attachment; filename="DiaryFile.notes"') >>> subwriter.flushheaders() base64.encode(open('./DiaryFile.notes', 'r'), f) w.lastpart() # s = SMTP("localhost") # s.sendmail("diary at system.com", ["my at email.address.com"], outputfp.getvalue()) # s.close() print outputfp.getvalue() if __name__=='__main__': mailFileToUser('Kevin McDermott', 'TestFile.out') Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From arcege at shore.net Wed Jun 2 07:50:27 1999 From: arcege at shore.net (Michael P. Reilly) Date: Wed, 02 Jun 1999 11:50:27 GMT Subject: Python & IRC? References: Message-ID: <7U853.1589$nn.478377@news.shore.net> Benjamin Schollnick wrote: : Folks, : Has anyone done anything in regards to making a IRC : daemon/server in Python? : I'm thinking about sitting down and doing some socket : work with Python, and I wouldn't want to reproduce the wheel again... I don't think anyone has, but I could be wrong. There are some IRC client modules out there that might aid you (mine follows the protocol as close as I can get it: http://www.shore.net/~arcege/python/ Pyirc-1.5.1.tar.gz). You might also want to look at the SocketServer module (which includes ThreadingTCPServer and ThreadingUDPServer classes). -Arcege From bernhard at alpha1.csd.uwm.edu Wed Jun 2 19:56:48 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 2 Jun 1999 23:56:48 GMT Subject: Why won't this work??? References: <7j0rkr$1eeu$1@rtpnews.raleigh.ibm.com> <7j1qc5$3rj$1@m2.c2.telstra-mm.net.au> <7j3e5q$nrq$1@rtpnews.raleigh.ibm.com> Message-ID: On Wed, 2 Jun 1999 10:13:59 -0400, Jr. King wrote: >Uhhhh, excuse me but, I did point out the problem. The PyEval_CallObject >call is failing everytime. I have it commented in the code, I guess that >wasn't good enuff. I guess so, too. Some of the experts here have very limited time and nobody wants to waste it, because we all want them to produce more of the work only they can do fast and so good. ;-) So you are not only wasting Mark's, but also my time. He probably get's hunderets of email messages and newsgroup questions and still stays friendly. And he was still answering friendly. Note that I also try to be friendly and explain the situation for you. >Excuse me, but that is the way I have done and seen it >done on c.l.c and the questions are usually answered minus the attitude. What is c.l.c? comp.linux...? In my eyes Mark was very friendly, I would probably have ignored you. And I think you seem to believe in having a right to get an answer from someone, which is not the case. >And I will be doggoned if I give out my darn email address on newsgroups >again, I don't need all that trash about porno. Okay, then you probably don't need the answer to the question from Mark. It is IMO unfriendly to not include an email address. It is understandable, if you encode your email a bit, but still the chances of an answer are falling then. If you want an answer, try to raise your chances. Bernhard From ajung at sz-sb.de Wed Jun 23 02:08:22 1999 From: ajung at sz-sb.de (Andreas Jung) Date: Wed, 23 Jun 1999 06:08:22 GMT Subject: popen2/zlib bug in Python 1.5.2/Solaris ! Message-ID: <19990623080822.A15920@sz-sb.de> Subject: Some zlib/popen bugs in 1.5.2/Solaris ! After the change from 1.5.2b2 to 1.5.2 I encountered serveral problems in the official release. The test suite fails in the test_zlib and the test_popen2 module. Traceback from test_zlib: (gdb) run Starting program: /ojs/home/ojs/src/Python-1.5.2/python Lib/test/test_zlib.py warning: Unable to find dynamic linker breakpoint function. warning: GDB will be unable to debug shared library initializers warning: and track explicitly loaded dynamic code. 0xe5c1a120 0x43b6aa94 0xbd602f7 0xbd602f7 expecting Bad compression level expecting Invalid initialization option expecting Invalid initialization option normal compression/decompression succeeded compress/decompression obj succeeded decompress with init options succeeded decompressobj with init options succeeded Program received signal SIGBUS, Bus error. 0xef5c63bc in t_delete () (gdb) bt #0 0xef5c63bc in t_delete () #1 0xef5c6080 in realfree () #2 0xef5c687c in cleanfree () #3 0xef5c5ccc in realloc () #4 0x4b0b4 in _PyString_Resize (pv=0xeffff228, newsize=3850) at stringobject.c:607 #5 0x87268 in PyZlib_flush (self=0x104620, args=0x8000) at ./zlibmodule.c:618 #6 0x54700 in call_builtin (func=0x1129f8, arg=0xe6070, kw=0x0) at ceval.c:2359 #7 0x545cc in PyEval_CallObjectWithKeywords (func=0x1129f8, arg=0xe6070, kw=0x0) at ceval.c:2324 #8 0x53018 in eval_code2 (co=0x110520, globals=0x0, locals=0x70, args=0x0, argcount=1124856, kws=0xffffffff, kwcount=0, defs=0x0, defcount=0, owner=0x0) at ceval.c:1654 #9 0x50924 in PyEval_EvalCode (co=0x110520, globals=0xf1a98, locals=0xf1a98) at ceval.c:324 #10 0x3210c in run_node (n=0xf4fb0, filename=0x110520 "", globals=0xf1a98, locals=0xf1a98) at pythonrun.c:887 #11 0x320bc in run_err_node (n=0xf4fb0, filename=0x110520 "", globals=0xf1a98, locals=0xf1a98) at pythonrun.c:872 #12 0x32090 in PyRun_File (fp=0xe36e0, filename=0xeffffa0e "Lib/test/test_zlib.py", start=257, globals=0xf1a98, locals=0xf1a98) at pythonrun.c:860 #13 0x3159c in PyRun_SimpleFile (fp=0xe36e0, filename=0xeffffa0e "Lib/test/test_zlib.py") at pythonrun.c:570 #14 0x31178 in PyRun_AnyFile (fp=0xe36e0, filename=0xeffffa0e "Lib/test/test_zlib.py") at pythonrun.c:451 #15 0x21c9c in Py_Main (argc=2, argv=0xeffff8bc) at main.c:287 #16 0x216bc in main (argc=2, argv=0xeffff8bc) at python.c:12 (gdb) test_popen2: bonnie@/ojs/home/ojs/src/Python-1.5.2(90)% ./python Lib/test/test_popen2.py testing popen2... testing popen3... Traceback (innermost last): File "Lib/test/test_popen2.py", line 16, in ? main() File "Lib/test/test_popen2.py", line 14, in main popen2._test() File "./Lib/popen2.py", line 95, in _test assert not _active AssertionError All tests are reproduceable using egcs-1.1.2 and egcs-2.95 under Solaris 2.6. Any idea ? Thanks, Andreas -- _\\|//_ (' O-O ') ------------------------------ooO-(_)-Ooo-------------------------------------- Andreas Jung, Saarbr?cker Zeitung Verlag und Druckerei GmbH Saarbr?cker Daten-Innovations-Center Gutenbergstr. 11-23, D-66103 Saarbr?cken, Germany Phone: +49-(0)681-502-1528, Fax: +49-(0)681-502-1509 Email: ajung at sz-sb.de (PGP key available) ------------------------------------------------------------------------------- From chalaoux at cybercable.fr Mon Jun 7 12:15:07 1999 From: chalaoux at cybercable.fr (FR chalaoux) Date: Mon, 07 Jun 1999 18:15:07 +0200 Subject: Looking for C Guru to compile Python Message-ID: <375BF00B.B1E19B54@cybercable.fr> Hi All, I'm trying to compile Python 152 on a Intel machine with the standard RH51 ( configure and make ) and I obtain this error (see below make error ). I joined the config.log file in attachement. Some explanation about failed in config.log are welcome ... Thanks for help. error from make: ============= gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c ./timemodule.c ./timemodule.c: In function `time_strptime': ./timemodule.c:429: warning: assignment makes pointer from integer without a cast gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c ./operator.c gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c ./fcntlmodule.c gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c ./pwdmodule.c gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c ./grpmodule.c gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c ./selectmodule.c gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c ./socketmodule.c ./socketmodule.c: In function `initsocket': ./socketmodule.c:2212: `uint32_t' undeclared (first use this function) ./socketmodule.c:2212: (Each undeclared identifier is reported only once ./socketmodule.c:2212: for each function it appears in.) ./socketmodule.c:2212: parse error before `0xe0000000U' ./socketmodule.c:2217: parse error before `0xe0000001U' ./socketmodule.c:2222: parse error before `0xe00000ffU' make[1]: *** [socketmodule.o] Error 1 make[1]: Leaving directory `/usr/local/Python-1.5.2/Modules' make: *** [Modules] Error 2 -- FR Chalaoux ADVL (Au Del? de Vos Limites) chalaoux at cybercable.fr http://www.advl.org/ -------------- next part -------------- This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. configure:608: checking MACHDEP configure:653: checking CCC configure:669: checking for --without-gcc configure:746: checking for gcc configure:859: checking whether the C compiler (gcc ) works configure:875: gcc -o conftest conftest.c 1>&5 configure:901: checking whether the C compiler (gcc ) is a cross-compiler configure:906: checking whether we are using GNU C configure:915: gcc -E conftest.c configure:934: checking whether gcc accepts -g configure:997: checking LINKCC configure:1014: checking LDLIBRARY configure:1043: checking for ranlib configure:1076: checking for ar configure:1150: checking how to run the C preprocessor configure:1171: gcc -E conftest.c >/dev/null 2>conftest.out configure:1230: checking for AIX configure:1255: checking for minix/config.h configure:1265: gcc -E conftest.c >/dev/null 2>conftest.out configure:1261: minix/config.h: No such file or directory configure: failed program was: #line 1260 "configure" #include "confdefs.h" #include configure:1304: checking whether gcc accepts -OPT:Olimit=0 configure:1318: gcc -OPT:Olimit=0 -o conftest -g -O2 conftest.c 1>&5 cc1: Invalid option `-OPT:Olimit=0' configure: failed program was: #line 1314 "configure" #include "confdefs.h" int main() { return 0; } configure:1338: checking whether gcc accepts -Olimit 1500 configure:1352: gcc -Olimit 1500 -o conftest -g -O2 conftest.c 1>&5 gcc: 1500: No such file or directory cc1: Invalid option `-Olimit' configure: failed program was: #line 1348 "configure" #include "confdefs.h" int main() { return 0; } configure:1375: checking for C preprocessor type configure:1388: gcc -c -g -O2 conftest.c 1>&5 configure:1405: checking for ANSI C header files configure:1418: gcc -E conftest.c >/dev/null 2>conftest.out configure:1485: gcc -o conftest -g -O2 conftest.c 1>&5 configure:1516: checking for dlfcn.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for fcntl.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for limits.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for locale.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for ncurses.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for pthread.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for signal.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for stdarg.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for stddef.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for stdlib.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for thread.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1522: thread.h: No such file or directory configure: failed program was: #line 1521 "configure" #include "confdefs.h" #include configure:1516: checking for unistd.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for utime.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for sys/audioio.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1522: sys/audioio.h: No such file or directory configure: failed program was: #line 1521 "configure" #include "confdefs.h" #include configure:1516: checking for sys/file.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for sys/lock.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1522: sys/lock.h: No such file or directory configure: failed program was: #line 1521 "configure" #include "confdefs.h" #include configure:1516: checking for sys/param.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for sys/select.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for sys/time.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for sys/times.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for sys/un.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for sys/utsname.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1516: checking for sys/wait.h configure:1526: gcc -E conftest.c >/dev/null 2>conftest.out configure:1557: checking for dirent.h that defines DIR configure:1570: gcc -c -g -O2 conftest.c 1>&5 configure:1595: checking for opendir in -ldir configure:1614: gcc -o conftest -g -O2 conftest.c -ldir 1>&5 ld: cannot open -ldir: No such file or directory configure: failed program was: #line 1603 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char opendir(); int main() { opendir() ; return 0; } configure:1681: checking for clock_t in time.h configure:1710: checking for mode_t configure:1743: checking for off_t configure:1776: checking for pid_t configure:1809: checking return type of signal handlers configure:1831: gcc -c -g -O2 conftest.c 1>&5 configure:1850: checking for size_t configure:1883: checking for uid_t in sys/types.h configure:1918: checking size of int configure:1937: gcc -o conftest -g -O2 conftest.c 1>&5 configure:1957: checking size of long configure:1976: gcc -o conftest -g -O2 conftest.c 1>&5 configure:1996: checking size of void * configure:2015: gcc -o conftest -g -O2 conftest.c 1>&5 configure:2036: checking for long long support configure:2046: gcc -c -g -O2 conftest.c 1>&5 configure:2060: checking size of long long configure:2079: gcc -o conftest -g -O2 conftest.c 1>&5 configure:2102: checking size of off_t configure:2122: gcc -o conftest -g -O2 conftest.c 1>&5 configure:2144: checking whether to enable large file support configure:2170: checking for --with-next-framework configure:2187: checking for --with-dyld configure:2213: checking SO configure:2227: checking LDSHARED configure:2267: checking CCSHARED configure:2289: checking LINKFORSHARED configure:2324: checking for dlopen in -ldl configure:2343: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:2371: checking for shl_load in -ldld configure:2390: gcc -o conftest -g -O2 conftest.c -ldld -ldl 1>&5 ld: cannot open -ldld: No such file or directory configure: failed program was: #line 2379 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char shl_load(); int main() { shl_load() ; return 0; } configure:2424: checking for t_open in -lnsl configure:2443: gcc -o conftest -g -O2 conftest.c -lnsl -ldl 1>&5 /tmp/cca058591.o: In function `main': /usr/local/Python-1.5.2/configure:2439: undefined reference to `t_open' configure: failed program was: #line 2432 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char t_open(); int main() { t_open() ; return 0; } configure:2464: checking for socket in -lsocket configure:2483: gcc -o conftest -g -O2 conftest.c -lsocket -ldl -ldl 1>&5 ld: cannot open -lsocket: No such file or directory configure: failed program was: #line 2472 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char socket(); int main() { socket() ; return 0; } configure:2504: checking for socket in -lnet configure:2523: gcc -o conftest -g -O2 conftest.c -lnet -ldl -ldl 1>&5 ld: cannot open -lnet: No such file or directory configure: failed program was: #line 2512 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char socket(); int main() { socket() ; return 0; } configure:2547: checking for --with-libs configure:2561: checking for --with(out)-readline configure:2576: checking for --with-dec-threads configure:2592: checking for --with-threads configure:2606: checking for --with-thread configure:3113: checking for --with-sgi-dl configure:3136: checking for --with-dl-dld configure:3169: checking for alarm configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for chown configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for clock configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for dlopen configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for execv configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for flock configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for fork configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for fsync configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for fdatasync configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for ftime configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for ftruncate configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for getpeername configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for getpgrp configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for getpid configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for getpwent configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for gettimeofday configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for getwd configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 /tmp/cca061601.o: In function `main': /usr/local/Python-1.5.2/configure:3191: the `getwd' function is dangerous and should not be used. configure:3169: checking for kill configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for link configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for lstat configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for mkfifo configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for mktime configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for nice configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for pause configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for plock configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 /tmp/cca062881.o: In function `main': /usr/local/Python-1.5.2/configure:3191: undefined reference to `plock' configure: failed program was: #line 3174 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char plock(); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char plock(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_plock) || defined (__stub___plock) choke me #else plock(); #endif ; return 0; } configure:3169: checking for pthread_init configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 /tmp/cca063011.o: In function `main': /usr/local/Python-1.5.2/configure:3191: undefined reference to `pthread_init' configure: failed program was: #line 3174 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char pthread_init(); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char pthread_init(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_pthread_init) || defined (__stub___pthread_init) choke me #else pthread_init(); #endif ; return 0; } configure:3169: checking for putenv configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for readlink configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for select configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for setgid configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for setlocale configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for setuid configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for setsid configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for setpgid configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for setpgrp configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for setvbuf configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for sigaction configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for siginterrupt configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for sigrelse configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 /tmp/cca065061.o: In function `main': /usr/local/Python-1.5.2/configure:3191: undefined reference to `sigrelse' configure: failed program was: #line 3174 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char sigrelse(); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sigrelse(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_sigrelse) || defined (__stub___sigrelse) choke me #else sigrelse(); #endif ; return 0; } configure:3169: checking for strftime configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for strptime configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for symlink configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for tcgetpgrp configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for tcsetpgrp configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for timegm configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for times configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for truncate configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for uname configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3169: checking for waitpid configure:3197: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3226: checking for fseek64 configure:3254: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 /tmp/cca066791.o: In function `main': /usr/local/Python-1.5.2/configure:3248: undefined reference to `fseek64' configure: failed program was: #line 3231 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char fseek64(); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char fseek64(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_fseek64) || defined (__stub___fseek64) choke me #else fseek64(); #endif ; return 0; } configure:3226: checking for fseeko configure:3254: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 /tmp/cca066921.o: In function `main': /usr/local/Python-1.5.2/configure:3248: undefined reference to `fseeko' configure: failed program was: #line 3231 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char fseeko(); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char fseeko(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_fseeko) || defined (__stub___fseeko) choke me #else fseeko(); #endif ; return 0; } configure:3226: checking for fstatvfs configure:3254: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 /tmp/cca067051.o: In function `main': /usr/local/Python-1.5.2/configure:3248: undefined reference to `fstatvfs' configure: failed program was: #line 3231 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char fstatvfs(); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char fstatvfs(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_fstatvfs) || defined (__stub___fstatvfs) choke me #else fstatvfs(); #endif ; return 0; } configure:3226: checking for ftell64 configure:3254: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 /tmp/cca067181.o: In function `main': /usr/local/Python-1.5.2/configure:3248: undefined reference to `ftell64' configure: failed program was: #line 3231 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char ftell64(); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char ftell64(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_ftell64) || defined (__stub___ftell64) choke me #else ftell64(); #endif ; return 0; } configure:3226: checking for ftello configure:3254: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 /tmp/cca067311.o: In function `main': /usr/local/Python-1.5.2/configure:3248: undefined reference to `ftello' configure: failed program was: #line 3231 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char ftello(); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char ftello(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_ftello) || defined (__stub___ftello) choke me #else ftello(); #endif ; return 0; } configure:3226: checking for statvfs configure:3254: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 /tmp/cca067441.o: In function `main': /usr/local/Python-1.5.2/configure:3248: undefined reference to `statvfs' configure: failed program was: #line 3231 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char statvfs(); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char statvfs(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_statvfs) || defined (__stub___statvfs) choke me #else statvfs(); #endif ; return 0; } configure:3282: checking for dup2 configure:3310: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3282: checking for getcwd configure:3310: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3282: checking for strdup configure:3310: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3282: checking for strerror configure:3310: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3282: checking for memmove configure:3310: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:3337: checking for getpgrp configure:3387: gcc -c -g -O2 conftest.c 1>&5 configure: In function `main': configure:3383: too many arguments to function `getpgrp' configure: failed program was: #line 3380 "configure" #include "confdefs.h" #include int main() { getpgrp(0); ; return 0; } configure:3403: checking for setpgrp configure:3453: gcc -c -g -O2 conftest.c 1>&5 configure: In function `main': configure:3449: too many arguments to function `setpgrp' configure: failed program was: #line 3446 "configure" #include "confdefs.h" #include int main() { setpgrp(0,0); ; return 0; } configure:3469: checking for gettimeofday configure:3519: gcc -c -g -O2 conftest.c 1>&5 configure:3538: checking whether time.h and sys/time.h may both be included configure:3552: gcc -c -g -O2 conftest.c 1>&5 configure:3573: checking whether struct tm is in sys/time.h or time.h configure:3586: gcc -c -g -O2 conftest.c 1>&5 configure:3607: checking for tm_zone in struct tm configure:3620: gcc -c -g -O2 conftest.c 1>&5 configure:3678: checking for time.h that defines altzone configure:3690: gcc -c -g -O2 conftest.c 1>&5 configure: In function `main': configure:3686: `altzone' undeclared (first use this function) configure:3686: (Each undeclared identifier is reported only once configure:3686: for each function it appears in.) configure: failed program was: #line 3683 "configure" #include "confdefs.h" #include int main() { return altzone; ; return 0; } configure:3712: checking whether sys/select.h and sys/time.h may both be included configure:3725: gcc -c -g -O2 conftest.c 1>&5 configure:3741: checking whether char is unsigned configure:3805: checking for working const configure:3859: gcc -c -g -O2 conftest.c 1>&5 configure:3882: checking for working volatile configure:3891: gcc -c -g -O2 conftest.c 1>&5 configure:3908: checking for working signed char configure:3917: gcc -c -g -O2 conftest.c 1>&5 configure:3934: checking for prototypes configure:3943: gcc -c -g -O2 conftest.c 1>&5 configure:3958: checking for variable length prototypes and stdarg.h configure:3977: gcc -c -g -O2 conftest.c 1>&5 configure:3993: checking for bad exec* prototypes configure:4002: gcc -c -g -O2 conftest.c 1>&5 configure:4019: checking for bad static forward configure:4040: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:4059: checking whether va_list is an array configure:4074: gcc -c -g -O2 conftest.c 1>&5 configure:4090: checking for gethostbyname_r configure:4118: gcc -o conftest -g -O2 conftest.c -ldl 1>&5 configure:4138: checking gethostbyname_r with 6 args configure:4159: gcc -c -g -O2 conftest.c 1>&5 configure:4333: checking for __fpu_control in -lieee configure:4352: gcc -o conftest -g -O2 conftest.c -lieee -ldl 1>&5 configure:4382: checking for --with-fpectl configure:4405: checking for --with-libm=STRING configure:4426: checking for --with-libc=STRING configure:4450: checking for hypot configure:4478: gcc -o conftest -g -O2 conftest.c -lieee -ldl -lm 1>&5 configure:4505: checking for hypot configure:4563: checking for genuine getopt configure:4583: gcc -o conftest -g -O2 conftest.c -lieee -ldl 1>&5 configure: failed program was: #line 4571 "configure" #include "confdefs.h" #include extern int optind, opterr, getopt(); extern char* optarg; int main() { char* av[] = { "testprog", "parameter", "-fFlag", NULL }; opterr = 0; if (getopt(3, av, "f:") == 'f') { exit(1); } exit(0); } configure:4601: checking what malloc(0) returns configure:4628: gcc -o conftest -g -O2 conftest.c -lieee -ldl 1>&5 From parkw at better.net Sat Jun 12 01:27:58 1999 From: parkw at better.net (William Park) Date: Sat, 12 Jun 1999 01:27:58 -0400 Subject: force sequenz with only one item? In-Reply-To: <375FA9AE.6299E9DD@phoenix-edv.netzservice.de>; from Holger Jannsen on Thu, Jun 10, 1999 at 12:03:58PM +0000 References: <375FA9AE.6299E9DD@phoenix-edv.netzservice.de> Message-ID: <19990612012758.A1196@better.net> On Thu, Jun 10, 1999 at 12:03:58PM +0000, Holger Jannsen wrote: > High, > > I think it's easy to solve, but I couldn't get it right now. > Take a look at the command-line source below: > > >>> A = 0 > >>> B = 1 > >>> seq=raw_input("?") > ?A,B > >>> print seq > A,B > >>> print eval(seq) > (0, 1) > >>> seq=raw_input("?") > ?A > >>> print eval(seq) > 0 > >>> A in seq > Traceback (innermost last): > File "", line 1, in ? > TypeError: string member test needs char left operand > >>> A in eval(seq) > Traceback (innermost last): > File "", line 1, in ? > TypeError: 'in' or 'not in' needs sequence right argument > >>> > > Ok? Check it out? > That's what I want to do with it: > There's a file I'm parsing over special keywords per line, e.g.: > Action = CREATE, VERBOSE, APPEND > When read the line I put the right term to a variable, e.g: > anAction = eval(rightTerm) > Then I want to test for that keywords (global integer variables in > source, e.g.: CREATE = 0): > if CREATE in anAction: > pass #do something > > But how could I force python to accept one-item sequences (see below!)? > > Thanx for comin' with me... > > Ciao, > Holger One item list is '[A]' One item tuple is '(A,)' From jmaziarz at linus.mitre.org Mon Jun 14 15:56:24 1999 From: jmaziarz at linus.mitre.org (Jeremy Maziarz) Date: Mon, 14 Jun 1999 15:56:24 -0400 Subject: beginners Q: CGI and file paths References: <7ijcve$o4o$1@towncrier.cc.monash.edu.au> Message-ID: <37655E68.EA2BEAF6@linus.mitre.org> John, $ pwd /afs/rcf/user/jmaziarz $ python >>> outFile = '/tmp/temp.out' >>> output = open(outFile, 'w') >>> output.write('This is my first test...\n') >>> output.close() $ more /tmp/temp.out This is my first test... $ python >>> outFile = '/tmp/temp.out' >>> output = open(outFile, 'a') >>> output.write('This is my second test...\n') >>> output.close() $ more /tmp/temp.out This is my first test... This is my second test... $ python >>> outFile = '/tmp/temp.out' >>> output = open(outFile, 'w') >>> output.write('This is my third test') >>> output.close() $ more /tmp/temp.out This is my third test Try using single quotes? -Jer Mr J Littler wrote: > > Hi, > I've written a cgi script that outputs a couple of files. > The default placement is in the cgi-bin directory and > I want them to go elsewhere. I've tried ... > > filename = "/proper_path_here/c_list.html" > append = open(filename, 'a') > > but putting the path in front of the filename makes no > difference (and doesn't generate an error) > I read thro cgi.py but can't see what to do. > Any help appreciated... > Cheers > John > -- > jlittler at silas.cc.monash.edu.au > http://jlittler.cjb.net > http://linuxmusic.cjb.net From matomira at iname.com Thu Jun 17 04:28:03 1999 From: matomira at iname.com (Fernando Mato Mira) Date: Thu, 17 Jun 1999 10:28:03 +0200 Subject: OO (was: Why is tcl broken?) References: <000801beb745$02768220$979e2299@tim> <871zfdp73f.fsf@home.ivm.de> <873dzsma6b.fsf@home.ivm.de> <87lndkkmda.fsf@home.ivm.de> <87k8t3opm4.fsf@oak.treepeople.net> Message-ID: <3768B193.209464A4@iname.com> Graham Hughes wrote: > trivial things, *precisely* because the damn thing is so small. Fer > crissakes, you don't even have the ability to create an aggregate type > in R5RS! You can fake it; but it sucks, and it doesn't integrate well > with the built in type system... I have a somewhat similar opinion. I can understand the open philosophy of the standard, but the real problem is that almost every implementation goes with their favorite OO way (maybe sometimes because of a lack of a CLOS exposure. I didn't know about CLOS until I started to do CL, and many schemers are plainly _disgusted_ about CL [Disclaimer: my students called me "the Schemeboy" [oops, IYKWIM ;-)] back at UBA] ). Anyway, I find it strange that tinyclos is not more popular as a ready-to-go and optimized object system. So then, you're faced with the choice of STk `beign right', MzScheme having the best plan (IDE, static debugger (what about the dynamic debugger now?) but no compilation (is it there yet?). Of course I wouldn't choose STk just because it has a nativized tinyclos. I could have used the tinyclos source as it was, but I just went and integrated it into the whole type hierarchy of MzScheme (adding metaclasses for the original MzScheme object system (not for me, to give away), nativized primitives. Unfortunately, that stuff didn't get merged into the distribution, as it adds to support burden (and probably it's not interesting for them), and they have dev plans to get some better implementation. I even went and added a lot of CL stuff on top of that implementation (source code from CMUCL). It's possible to move around. This is very important when at some point you get stuck (thread-unsafe implementation, inefficiency, requirement to run on JVM, whatever). I now use a portable way of writing Lisp, at least until CLers and Schemers decide what can we do about #f and nil (err.. did I say `comet' before?) From emmanuel.viennet at lipn.univ-paris13.fr Sat Jun 26 10:14:57 1999 From: emmanuel.viennet at lipn.univ-paris13.fr (Emmanuel Viennet) Date: Sat, 26 Jun 1999 16:14:57 +0200 Subject: buffer API and pickle Message-ID: <3774E061.A15E060D@lipn.univ-paris13.fr> Hi, I saw the new "buffer" APi in the python 1.5.2 sources, but was unable to find much more information about it. It seems that the buffer mecanism would be ideal to avoid conversion to string (duplicating data in memory) when writing an object to a stream. - Is the next version of pickle supposed to make use of this buffer API ? - What types of objects will support it: strings, arrays, NumPy arrays, PIL images, ... Emmanuel -- Emmanuel Viennet: LIPN - Institut Galilee - Universite Paris-Nord 93430 Villetaneuse - France http://www-lipn.univ-paris13.fr/~viennet/ From frehe491 at student.liu.se Sun Jun 20 16:45:30 1999 From: frehe491 at student.liu.se (Fredrik Henbjörk) Date: Sun, 20 Jun 1999 22:45:30 +0200 Subject: nerdnews.py Message-ID: <376D52EA.41C6@student.liu.se> Creates a htmlpage with todays Dilbert strip and headlines from Linux Today and Slashdot. -- Fredrik Henbjork Email: frehe491 at student.liu.se WWW: http://o112.ryd.student.liu.se -------------- next part -------------- #! /usr/bin/python # # Fredrik Henbjork 1999 # License: GNU GPL # # Why not take a look at the PyApache homepage # import re import urllib # don't ask why it's done this way ... # return url to today's strip def get_dilbert(): url = '' tries = 1 while url == '' and tries < 10: try: dilbert = urllib.urlopen('http://www.dilbert.com/comics/dilbert/index.html') html = dilbert.read() dilbert.close() url = 'http://www.dilbert.com/comics/dilbert/archive/images/dilbert%s.gif' % (re.split('.gif\"> ' print ' ' print ' Nerd News' print ' ' print ' ' print '
' print '

' print ' ' # news from Linux Today linux_today_news = get_linux_today() if linux_today_news != []: print ' ' print ' ' for item in linux_today_news: print ' ' % (item[1], item[0]) print ' ' # news from Slashdot slashdot_news = get_slashdot() if slashdot_news != []: print ' ' print ' ' for item in slashdot_news: print ' ' % (item[1], item[0]) print ' ' # today's Dilbert strip dilbert_url = get_dilbert() if dilbert_url != '': print ' ' print ' ' print ' ' % (dilbert_url) print ' ' print '
Linux Today
(http://linuxtoday.com)
%s
 
Slashdot
(http://slashdot.org)
%s
 
Dilbert
(http://www.dilbert.com/comics/dilbert/)
 
' print '
' print ' ' print '' # main if __name__ == '__main__': # Uncomment the two lines below if you are going to use this as a cgi script # print "Content-type: text/html" # print nerd_news() From jordi.inglada at enst-bretagne.fr Fri Jun 11 14:01:42 1999 From: jordi.inglada at enst-bretagne.fr (Jordi Inglada) Date: Fri, 11 Jun 1999 20:01:42 +0200 Subject: Prolog module Message-ID: <99061120061800.01147@pruneta.titinet.enst-bretagne.fr> Hi, I am new to Python Programming (just did the tutorial and played a little with it). It is really a great language! I have seen that Python can interact with other languages. My question is: can Python access a Prolog kernel? Or even, is there a module that implements in Python a Prolog kernel? (in the same way one can use Java from Python). Thanks. -- --------------------------------------------- Jordi INGLADA Departement ITI - ENST Bretagne BP 832 - 29285 Brest Cedex - FRANCE Tel. +33 (0)2 98 00 13 55 / 10 62 http://www-iti.enst-bretagne.fr/~inglada/ "Computers are like air conditioners: they stop working properly when you open Windows" "Linux, parce que je le vaux bien..." From brainwav at hotmail.com Sun Jun 13 17:38:30 1999 From: brainwav at hotmail.com (Denis Lamarche) Date: Sun, 13 Jun 1999 21:38:30 GMT Subject: Python as script language? Message-ID: <37644DC7.DE422A3B@hotmail.com> How can I set up Python so that I can call the scripts from within an application (that I wrote) so that it will run and interface with the application (that I wrote)? Is this possible? Denis Lamarche From faassen at pop.vet.uu.nl Mon Jun 7 13:32:49 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Mon, 07 Jun 1999 19:32:49 +0200 Subject: Suggestion: Dutch Python mailinglist References: <375BC7E8.BC53EFD@prescod.net> Message-ID: <375C0240.AA0C9B2B@pop.vet.uu.nl> Paul Prescod wrote: > > Gerrit Holl wrote: > > > > I know there are many Dutch > > python-users, but most of them know English very well. > > Dutch people use Python? Since when? Me me me! Of course, there's this guy whose name starts with a G too. I forget.. Gedo..Guddo? something like that. :) > > Ik ben een Nederlandse jongen van 13 jaar, en mijn Engels is niet goed. > > Actually, I can pretty much read that without learning Dutch. It looks > like English with some spelling mistakes. And no more typing mistakes than > is typical for mailing lists. Ja, maar zonder handige vertaling erbij is het veel moeilijker te volgen. Yes, but without useful translation it-with is it much difficulter to follow. Still, Dutch is one of the languages closest to English, especially grammar-wise. Regards, Martijn From frankn=news at cs.vu.nl Wed Jun 23 10:35:49 1999 From: frankn=news at cs.vu.nl (Frank Niessink) Date: Wed, 23 Jun 1999 14:35:49 GMT Subject: How to obtain an instance's name at runtime? References: <7kqpu8$7u1$1@nnrp1.deja.com> Message-ID: <7kqrc5$9fs@cs.vu.nl> Dinu C. Gherman wrote: >>>> class C: > ... pass > ... >>>> >>>> c = C() >>>> C.__class__.__name__ # ok > 'C' >>>> c.__name__ # not ok > Traceback (innermost last): > File "", line 0, in ? > AttributeError: __name__ >>>> > Question: How to obtain an instance's name at runtime? That instance doesn't have a name. Take for example: >>> a = b = c = C() That creates one instance of C, with three references to it. Now what is the `real' name of the instance? Cheers, Frank -- The suit into which the man's body had been stuffed looked as if it's only purpose in life was to demonstrate how difficult it was to get this sort of body into a suit. -- Douglas Adams, 'The Restaurant at the End of the Universe' From air at apex.net Thu Jun 3 14:51:16 1999 From: air at apex.net (Todd Neal) Date: Thu, 3 Jun 1999 13:51:16 -0500 Subject: Re example Message-ID: <18A53.61$G2.553366@news.apex.net> Looking for some examples on how to use re, had a script made with sed ,awk, and lynx to download and parse webpages for viewing on a palmpilot, I would like to convert it to Python but I cant find any good examples of how to use the re modules. Thanks, Todd From tim_one at email.msn.com Mon Jun 21 00:02:43 1999 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 21 Jun 1999 00:02:43 -0400 Subject: fork() In-Reply-To: Message-ID: <000001bebb9a$eabc01a0$619e2299@tim> [Hisao Suzuki, still likes his anlaogy between explicitly delete'ing in C++, and explicitly removing all references in CPython] You say my position "sounds too particular about superficial differences", and I say yours reaches too far from superficial similarities. We're never going to agree on this one, so I'll leave it there. > ... > All in all, each idea is a valid model for the current Python. > The definitive difference lies in the semantics of language it > relies on. Regarding the favor of destruction predictability > such as seen in this newsgroup, the current actual semantics is > perhaps as important as the official one. Trying to nudge this in a useful direction , the "current actual semantics" don't suggest anything about what "should be" done in the presence of cycles with destructors in a GC world, except for the obvious "reclaim a cycle the instant it becomes unreachable". That is doable but-- I think --not cheaply enough to be practical. So what then? BTW, I'm told that most of the C++ committee disagrees with Stroustrup on this one -- the notion that an object can be destroyed without its destructor getting invoked is distasteful at first bite, and leaves a bad taste even after three helpings of creative rationalization . If there's a good argument to made for it, it should rest where Guido left it: the behavior falls out of the simplest implementation, and that's really all there is to it: you *put up* with the semantics that fall out, hoping they're not too bad in practice. Lots of things work like that (floating-point arithmetic is a particularly miserable example <0.3 wink>); sometimes it's just the best you can get. Let's not pretend it's a good thing for "deep reasons", though! >| Further the C++ 3rd Ed. says: >| "It is possible to design a garbage collector to invoke the >| destructors for objects that have been specifically >| registered' with the collector. However, there is no >| standard way of `registering' objects. Note that it is >| always important to destroy objects in an order that ensures >| that the destructor for one object doesn't refer to an >| object that has been previously destroyed. Such ordering >| isn't easily achieved by a garbage collector without help >| from the programmer." [Tim sez Java solved that one] [Hisao] > Even if the storage of such objects are not reclaimed yet, their > finalizer()s may have been already invoked. This may be a real > problem for aggregation objects (if you once rely on finalizers > in Java). Note that Stroustrup's "destroy" implies "call the > destructor". We don't have an argument about Java (at least none that I've been able to detect ), and Stroustrup wasn't writing about Java. His "destroy"-- being about C++ --*also* implies "nuke the memory", which isn't the case in Java. Java does guarantee that the memory of every object reachable from a finalizer is wholly intact, so-- again --Java addresses the point Stroustrup is making (which was in support of his view that GC not invoke destructors at all). GC simply doesn't need any help from the programmer to guarantee that much; although Stroustrup is right (Graham notwithstanding ) that it's not easily achieved. [quotes from the JLS, and a Java aggregation example where the order finalizers run in is important] > ... > You see, to implement such a class needs _help_ from the > programmer. Certainly. It's a different issue, though: GC doesn't need help to avoid referencing bogus memory, it needs help to implement the intent of the algorithm. If Stroustrup were concerned about the latter, he would not have said "such ordering isn't easily achieved ... without help", he would have said such ordering is *impossible* to achieve without programmer intervention. He's a careful writer. Even in the absence of cycles, CPython today doesn't (and can't!) guarantee to run finalizers in the order your code may need; e.g., if you run this today under 1.5.2: class Parent: def __init__(self): self.kids = [] def add_child(self, name): self.kids.append(Child(name)) def __del__(self): global estate estate = 1000000 print "parent died, leaving", estate, "dollars" for k in self.kids: print k.name, "wants a share of the cash!" class Child: def __init__(self, name): self.name = name def __del__(self): global estate me = estate / 2 estate = estate - me print self.name, "died of grief with", me, "of those bucks" p = Parent() p.add_child("Nancy") p.add_child("Tim") del p It prints: parent died, leaving 1000000 dollars Nancy wants a share of the cash! Tim wants a share of the cash! Nancy died of grief with 500000 of those bucks Tim died of grief with 250000 of those bucks But if you run it under the current CVS Python snapshot, Tim gets the half million and poor Nancy gets 250000 (lists get destroyed in reverse order in the development version). The order of finalizer invocation certainly matters a lot here (well, to me and my sister, or at least to the charities in our wills ), and it's impossible for Python-- or any other language --to guess the intent. All that can be said is that refcount rules *usually* avoid such surprises; in the end, though, it's still up to you to force ordering when you need it. BTW, that does suggest one "natural" extension of CPython semantics to cycles: since CPython today doesn't guarantee anything about the order in which finalizers are called when more than one object loses its last reference at the same time, it would be consistent to run finalizers for members of GC'ed cycles in an arbitrary order too; and if your program relies on a particular order, tough. One bad aspect is that it's a rule the compiler+runtime can't enforce, in the sense that violations can't be detected. Python tries (much harder than C++) to avoid rules like that. it's-a-good-game-that-can't-be-won-ly y'rs - tim From ivanlan at callware.com Tue Jun 1 11:17:01 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Tue, 1 Jun 1999 15:17:01 GMT Subject: proposal: new mailing list References: <37519172.55C86D95@acm.org> Message-ID: <3753F96D.9E784D90@callware.com> Hi All-- "Max M. Stalnaker" wrote: > > I have taught some programming classes. It seems to me python is a good > choice for an introductory CS class since it has minimal key words, a > clean syntax, and lots of CS structures available. It also has good > object orientation.. No texts, though. > > It is also starting to attract a little attention from non-programmers > who want to be programmers. It seems to me, in an evangelical mode, > that it is worthwhile addressing their needs, which are different than > the typical programmer who is discovering Python. The newsgroup may not > be appropriate for these people? Maybe python.org should start a > mailing list just for them? Python-eggs? > > Over time, this mailing list, if archived, would develop a good > reference set for the clientele. The clientele would be partially > self-servicing. > > Mandate: > > Discussion of programming issues and techniques in Python for people for > whom Python is a first programming language. > [N.B.: I've not finished reading all of my email this morning, so have undoubtedly missed some others' replies on this topic.] 1) We already have the Python Tutor mailing list, which really is aimed at people just getting started with Python. Too many Python lists would dilute our energies, I think. 2) Re ``no texts, though.'' That is a situation which I am attempting to remedy. I've just signed a contract with SAMS to write _Teach Yourself Python in 24 Hours_. I am deliberately aiming the book at people who do not know how to program, as I believe that Python is a very nearly ideal first programming language. The existing books are targetted at those who know at least something about programming, but mine will be for the true programming beginner. Naturally, I can't speak to SAMS' scheduling or production, so do not take what I say here as legally binding in any way (I disclaim everything!), but my feeling is that the book *might* be in the stores this year. -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From florent.heyworth at radbit.com Fri Jun 25 18:33:24 1999 From: florent.heyworth at radbit.com (Florent Heyworth) Date: Sat, 26 Jun 1999 00:33:24 +0200 Subject: mxCGIPython question (was: Build the Python library into the binary) References: <376F9518.D3252CEE@interet.com> <7kolnv$gp6$1@nnrp1.deja.com> <015e01bebe1f$202e9560$4500a8c0@thomasnotebook> Message-ID: <377403B4.21319894@radbit.com> Thomas Heller wrote: > > Hi > > > > did you have a look at mxCGIPython at > > http://starship.skyport.net/~lemburg/mxCGIPython.html ? > > This is a single executable not shared library with the > > standard Python library embedded. > > > > Cheers > > -- > > Florent Heyworth > > > Works great, except for one problem (under Windows): > you cannot use any extension modules, because they do > not find python15.dll (or, worse, they find the wrong > python15.dll). > > Is it possible to build a python15.dll containing the > standard library or is it only possible to freeze executables? > > Thomas Heller Hi Thomas yes it is possible to build a python15.dll containing the standard library. In fact it's easier than making an excutable out of it as the whole build process on Windows is geared to producing dlls. I haven't had time to make notes or automate the build process yet but email me if you want some info and I'll try to scrape something together. Marc Lemburg's mxCGIPython package is a good starting point. Cheers Florent Heyworth From ivnowa at hvision.nl Wed Jun 2 15:37:46 1999 From: ivnowa at hvision.nl (Hans Nowak) Date: Wed, 2 Jun 1999 19:37:46 GMT Subject: A newbie learns... [Part 1] In-Reply-To: References: Message-ID: <199906021936.VAA27111@axil.hvision.nl> On 2 Jun 99, Gregory A. Landrum wrote: > Howdy, > > I'm in the process of learning python, Tkinter and all that good > stuff. I'm doing this by writing an application which, hopefully, will > actually be useful. Along the way, I'm experimenting and playing and > trying to figure out how to make things go faster/better. > > What I figure is that as I find tricks which I think might be useful > to other people trying to learn python, I'll post them. Mabye other > newbies will also find them useful. > > If people find this a waste of time/space/electrons, let me know and I > won't continue. On the contrary, I think it's very useful. I'll try to extract pieces of it and put them on my snippets page. (http://www.hvision.nl/~ivnowa/snippets) Of course, if you happen to have little example scripts which run out of the box, it would be very nice if you'd like to send me some. ^_^ (The snippets site should be updated Real Soon Now; I have a new PC now, but everything (snippets, site, Python-DX, etc) is still on the old one. It might take a while before the updated site is up.) Veel liefs, --Hans Nowak (ivnowa at hvision.nl) Homepage: http://fly.to/zephyrfalcon From jeremy at cnri.reston.va.us Mon Jun 7 15:57:17 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Mon, 7 Jun 1999 15:57:17 -0400 (EDT) Subject: Python 2.0 In-Reply-To: References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7iqhkb$d7s@wiscnews.wiscnet.net> <7iu7ma$d33$1@cronkite.cc.uga.edu> <02hfonzsx2.fsf@rtp.ericsson.se> <02909zzou0.fsf@rtp.ericsson.se> <87zp2f4qrz.fsf@pc-hrvoje.srce.hr> Message-ID: <14172.6652.550882.854800@bitdiddle.cnri.reston.va.us> >>>>> "DS" == Dan Schmidt writes: DS> Hrvoje Niksic writes: | Kumar Balachandran DS> writes: | | > What you DS> said is quite wrong. Since Python provides closures, I can | > DS> change my programming style to be completely different from the DS> | > standard C or Fortran style and use a functional interface. DS> | | Since when does Python provide closures? DS> The bytecodehacks module allows the creation of closures as I DS> understand them. Yes and no. The bytecodehacks closures work right most of the time, but there some problems with them. Hence, I would guess, the name "hacks." A "BCH closure" does what you want most of the time, but it does not work for immutable types or for assignments to mutable types. The Scheme world view has a different world view, and a closure in Scheme works a bit differently. I suspect it may be a little confusing for people expect BCH to make Python's variable binding work like Scheme's variable binding. In Scheme, a variable is bound to a location that stores a value. You can store a new value in that location using set!. If two different functions share the same binding for a variable, a set! performed in one function is visible in the other. >>> (let ((sum 0)) (let ((add (lambda (x) (set! sum (+ sum x)))) (sub (lambda (x) (set! sum (- sum x))))) (add 2) (add 3) (sub 1) sum)) 4 The BCH model is different, because it doesn't allow two functions to share the same "location." It only allows them to share the same value. This is a limitation of the way BCH implements closures; non-local references are turned into references to constants when the bind call is made. This approach often works the constant is an object and you're referencing one of its attributes or calling a method. It doesn't work for assignment. The natural translation of the above Scheme code in Python+BCH would probably be: from bytecodehacks import closure def notQuite(): sum = 0 def add(x): sum = sum + x def sub(x): sum = sum - x cadd = closure.bind_locals(add) csub = closure.bind_locals(sub) cadd(2) cadd(3) csub(1) return sum But this doesn't work. You need to bind sum to a mutable object (not a string or tuple) and that operator on that object indirectly. The following works because it contains the value of interest inside a list (and list operations are methods on the list object). Effectively, you need to create the shared location that Scheme creates for free. def works(): sum = [0] def add(x): sum[0] = sum[0] + x def sub(x): sum[0] = sum[0] - x cadd = closure.bind_locals(add) csub = closure.bind_locals(sub) cadd(2) cadd(3) csub(1) return sum[0] Jeremy From jam at newimage.com Wed Jun 23 00:17:26 1999 From: jam at newimage.com (jam) Date: Wed, 23 Jun 1999 00:17:26 -0400 Subject: simple 'binfmtload' script in python Message-ID: <19990623001726.Q5115@toast.internal> greetings, in an effort to move forward with another project I've been working on, I wrote up a simple script that tells a linux 2.2.x kernel how to execute a java binary. I based this script on information in /usr/src/linux/Documentation/java.txt and experimentation. it seems to work for me. I'd like to know if anyone else finds it useful, or has ideas on how it can be improved. it's terribly simple, but it get's the job done. regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. -------------- next part -------------- #!/usr/bin/env python fp = open("/proc/sys/fs/binfmt_misc/register", "w+b") fp.write(":Java:M::\xca\xfe\xba\xbe::/usr/local/java/jdk1.2/bin/java:\n") fp.close() fp = open("/proc/sys/fs/binfmt_misc/register", "w+b") fp.write(":Applet:M::"BAW" == Barry A Warsaw writes: BAW> My model was gdb's attach feature where you can attach to, stop BAW> and trace through a running external C program. I would love BAW> to be able to do the same thing at the Python level. We BAW> started talking about remote pdb's with threads listening on BAW> sockets, etc. (still cool ideas but more work). on a (vaguely) related note, i was talking to Mark Hammond the other day (hi Mark) about MS's ActiveDebugging(TM) (sp?) stuff. as i understood it, each interpreter presents a set of COM APIs which provide an abstract view of stack frames, etc, suitable for use by a symbolic script debugger. you can thus debug across scripting languages using a single tool, watching calls between interpreters, etc etc. all very cool, and so i started thinking about doing the same thing for Unix via gdb (for C) and the Python interpreter (what other languages are there? oh -- ELisp, yeah -- we can do that!) of course, attaching to a running process should still be possible, and thus the round-about relationship to the thread. ahhhhh. now, where's that spare time again? d From Steve at HOSYS.com Mon Jun 14 11:44:48 1999 From: Steve at HOSYS.com (Steve Hunter) Date: Mon, 14 Jun 1999 11:44:48 -0400 Subject: Alg Problem (new to Python) Message-ID: <7k38gf$khr$1@holly.prod.itd.earthlink.net> Hello, The out put of a program is below....the problem is the tasks are being added to every project vs. to the specific project....it sees like an alg program but I can't see it....brand new to Python...have mercy. project key: z125 name: Project C task key: t1241 task key: t1231 project key: y124 name: Project B task key: t1241 task key: t1231 project key: x123 name: Project A task key: t1241 task key: t1231 the program below is in on .py file import sys projectDict = {} #MAPS PROJECT id string to PROJECT object taskDict = {} #MAPS TASK id string to TASK object class Project: _id = '' _name = '' _descr = '' _tasks = {} #list of Tasks I contain def __init__(self, projectID): self._id = projectID #setters def set_id(self, anID): self._id = anID def set_name(self, aName): self._name = aName def set_descr(self, aDescr): self._descr = aDescr def addTask(self, aTask): #require aTask not null self._tasks[aTask.id()] = aTask #getters def id(self): return self._id def name(self): return self._name #end class Project class Task: _id = '' _name = '' _descr = '' _owner = '' #Person responsible for the task _project = '' #the project that contains me def __init__(self,ID): self._id = ID def test(self): #dump internals print('in Task test') #setters def set_id(self,anID): self._id = anID def set_name(self, aName): self._name = aName def set_descr(self, aDescr): self._descr = aDescr def set_project(self, aProject): #aProject: PROJECT self._project = aProject #getters def id(self): return self._id def name(self): return self._name def descr(self): return self._descr #end class Task #---------------Call back functions for GUI------------------------ def addTaskToProject(aTaskID, aProjectID): #require valid id's and exist in the dictionaries prj = projectDict[aProjectID] task = taskDict[aTaskID] prj.addTask(task) #end addTaskToProject def createNewProject(anID,aName): p = Project(anID) p.set_name(aName) projectDict[p.id()] = p def createNewTask(anID,aName): t = Task(anID) t.set_name(aName) taskDict[t.id()]= t def dumpProjectDictContents(): for prjKey in projectDict.keys(): print 'project key: ' + prjKey + ' name: ' + projectDict[prjKey].name() def dumpTaskDictContents(): for key in taskDict.keys(): print 'task key: ' + key + ' name: ' + taskDict[key].name() def projectReport(): for prjKey in projectDict.keys(): print 'project key: ' + prjKey + ' name: ' + projectDict[prjKey].name() for taskKey in projectDict[prjKey]._tasks.keys(): print 'task key: ' + taskKey taskKey = '' #end createNewProject #-------------------------------------------------------------------- def testRun(): createNewProject('x123','Project A') createNewProject('y124','Project B') createNewProject('z125','Project C') # dumpProjectDictContents() createNewTask('t1231','Task A') createNewTask('t1232','Task B') createNewTask('t1233','Task C') createNewTask('t1241','Task D') createNewTask('t1242','Task E') createNewTask('t1251','Task F') createNewTask('t1252','Task G') # dumpTaskDictContents() addTaskToProject('t1231','x123') #some how all the tasks are added to all the projects addTaskToProject('t1241','y124') projectReport() #end testRun if __name__ == '__main__': testRun() From Cepl at fpm.cz Fri Jun 18 03:33:26 1999 From: Cepl at fpm.cz (Matej Cepl) Date: Fri, 18 Jun 1999 08:33:26 +0100 Subject: HTML bettering? Message-ID: <1318D78C9072D11195C9006094EA98A72C2164@ocesrv> > From: KAnton at gmx.de (Konrad Anton) > Date: Thu, 17 Jun 1999 18:53:36 +0159 > > Does it have to be a selfmade Python solution? If you just want to > number your headlines (and if you speak Perl), have a look at WML[1] > which combines embedded Perl, m4, MetaHTML, an HTML optimizer and five > other passes your input script is fed into. It's under GPL and fairly > well documented. > [MCepl] Well, it is not the biggest support of Python's goodwill, is it? But, to make Pythonians more happy, the story is as follows: I am writing some stuff in Amaya, which has beautiful heading numberings, but its priting abilities are rather questionable (it fails three times from four attempts -- on WinNT) so I would rather use html2ps which has much better output, but it numbers headings in different way (still unresolved issue, what it the top level -- H2 or H1?). So I needed some simple tool to make numbering in the text (BTW, it would be usefull for latter presentation in, say, widely spread browsers). I sent a notice to amaya list and I have got small script in Perl in about quarter of hour. It works, it is beautiful, but it is totally incomprehensible for me, how it works (my knowledge of Perl is fairly limited -- what is push and pop?). Therefore, I ask again, if there is some simple way, how to show power of Python's libraries system (htmllib.py, I guess). Have a nice day and sorry for slightly off-topic Matthew From stidolph at origin.ea.com Tue Jun 1 11:31:16 1999 From: stidolph at origin.ea.com (Stidolph, David) Date: Tue, 1 Jun 1999 15:31:16 GMT Subject: Python 2.0 Message-ID: <11A17AA2B9EAD111BCEA00A0C9B4179301E10ED9@forest.origin.ea.com> Py_TRACE_REFS seems to be defined if Py_DEBUG is defined. I cannot find a "getobjects" or any other similar function in the source code or docs. I am using the Win32 version 1.5.2. Any help would be appreciated, David Stidolph. -----Original Message----- From: Michael Hudson [mailto:mwh21 at cam.ac.uk] Sent: Tuesday, June 01, 1999 4:55 AM To: python-list at cwi.nl Subject: Re: Python 2.0 "Stidolph, David" writes: > >OK, I'll try to propose something constructive. Maybe we need an object > >protocol, that would enumerate > >all references held by an object ? Writing a portable GC would be then > much > >easier. > > Sounds good to me for debugging. A call that could return a list of > everything that holds a reference to an object - that would be cool! > > list = GetReferences(object) > print 'List of referencest to',object > for item in list: > print 'item:',item > > Anybody know of a current way to do this? If you recompile Python with Py_TRACE_REFS defined, then the sys module sprouts a "getobjects" function that returns a list of all objects in existence. This could probably be used to implement something like this. It would be veeeeery slow, I suspect. I've never resorted to this approach, tending always to make cyclic references go away be staring at them very, very hard. I'm not sure this is at all what is being asked for, but it seems kind of relavent. Yours, Michael From rhww at erols.com Sun Jun 6 22:57:41 1999 From: rhww at erols.com (R Wentworth) Date: Sun, 06 Jun 1999 22:57:41 -0400 Subject: Indentation and grouping proposal Message-ID: <375B3525.F67D424F@erols.com> I am reasonably fond of Python's grouping-via-indentation paradigm. Even so, it occurs to me that there may be legitimate reasons to consider adding a feature to allow non-indentation-based grouping. I might envision this being done via the introduction of two new tokens, e.g., "_{" and "}_". These would have the following significance: _{ if it is preceded by non-whitespace: ends the current logical line and begins a new one acts like an INDENT token, but the entry it pushes onto the indentation stack is not a positive integer disables interpretation of indentation until matching }_ is reached }_ ends the current logical line acts like a DEDENT token, and pops the top entry (which must not be a positive integer) off the indentation stack As a slight extension of the feature, it should be legal to use _{ }_ to enclose the outermost set of statements in an interpretation unit. This is in addition to using _{ }_ to enclose statements that constitute a "suite" that is part of an "if" or "def" or "class" statement. The intent behind adding this feature would be as follows: 1) Simplifies the task of dealing with Python code in non-standard contexts, e.g., when embedded in a free-form language like HTML. 2) Could help make Python more popular by providing an alternative for those many (arguably misguided) souls whose main pet peeve about Python is the grouping-via-indentation paradigm. 3) May make code generation marginally simpler. ############################################################ Here are some usage examples. Legal but pointless, with no new functionality: if good: _{ print "Spam!" print "Spam!" }_ print "Yum." Legal but with pointlessly irregular indentation: if good: _{ print "Spam!" print "Spam!" }_ print "Yum." Previously impossible, a one-line version: if good: _{ print "Spam!"; print "Spam!" }_ print "Yum." Prettier looking Python embedded in Python (indentation within string would previously have been illegal): statements = '''if good: _{ print "Spam!" print "Spam!" }_ print "Yum." ''' exec(statements) The last two examples are relevant to embedding in HTML as well (using a fictitious inclusion syntax): Tasty? Tasty? Or, using an even more speculative syntax, something which would be horrendously awkward without this new feature: Tasty? Spam! Spam! Yum. Up until now, I have not used the subfeature that would allow _{ }_ to surround the outermost level of code. Taking this into account, formatting improvements cited above become possible even if there is no "if" or the like involved, e.g.: statements = ''' _{ print "Spam!" print "Spam!" }_ ''' exec(statements) Here is a code generation example. Consider the following rather goofy code: n = 0 print "Computing ceiling(log_2(x))" if x <= 1: print "Got it!" print `n` else: n = n + 1 x = x/2 if x <= 1: print "Got it!" print `n` else: n = n + 1 x = x/2 if x <= 1: print "Got it!" print `n` else: n = n + 1 x = x/2 if x <= 1: print "Got it!" print `n` else: n = n + 1 x = x/2 print "I give up." This code contains four repeated blocks which are identical except for indentation level. If we were to try to generate this code verbatim, we would need to carefully adjust the indentation level each time we inserted the block. But with the _{ }_ feature we could do the following: start = '''_{ n = 0 print "Computing ceiling(log_2(x))" ''' atom = '''if x <= 1: _{ print "Got it!" print `n` }_ else: _{ n = n + 1 x = x/2 ''' end = '''print "I give up." }_ }_ }_ }_ }_''' code = start + atom + atom + atom + end exec(code) In this version, the indentation in the generated code is sloppy and meaningless -- but it does the right thing without as much effort as would have been required previously. ############################################################ A few comments on the choice of symbols used to implement this new functionality... Selection criteria would sensibly include: 1) Syntactically unambiguous; need to choose something that currently constitutes illegal syntax. 2) Should suggest grouping to folks who are used to C, Perl, etc. 3) Should be reasonably aesthetic. 4) Not excessively difficult to type. Here are a few options, and associated comments: { } Not available -- in use for dictionaries. \{ \} Gets ugly if code needs to be enclosed in a string (in Python or another language) (@ @) Could work, but arguably graceless and unfamiliar -{ }- Likely to be confusing even if technically unambiguous. {_ _} Syntactically confusing, as "_" is a legal identifier name, and an identifier could be the first or last thing in a dictionary expression. .{ }. Visually as close as possible to { } and perhaps easier to type than some alternatives? Perhaps viable? (Could be confusing to name these tokens in error messages or textual discussion?) _{ }_ Probably viable? ############################################################ I haven't looked at the Python parser, but naively, this sort of "enhancement" would seem to be relatively easy. If there were official blessing for the concept, I'd be willing to look into doing the necessary work. Robert Wentworth rhww at erols.com From larsga at ifi.uio.no Sun Jun 20 17:25:33 1999 From: larsga at ifi.uio.no (Lars Marius Garshol) Date: 20 Jun 1999 23:25:33 +0200 Subject: nerdnews.py References: <376D52EA.41C6@student.liu.se> Message-ID: * Fredrik Henbj?rk | | Creates a htmlpage with todays Dilbert strip and | headlines from Linux Today and Slashdot. Maybe you'll find this interesting: --Lars M. From arcege at shore.net Thu Jun 17 10:15:56 1999 From: arcege at shore.net (Michael P. Reilly) Date: Thu, 17 Jun 1999 14:15:56 GMT Subject: ref counting, access from python References: <7kad31$o7f$1@ns.mtu.ru> <3768C80B.14B245E6@appliedbiometrics.com> Message-ID: Christian Tismer wrote: : Oleg Orlov wrote: :> :> Hello. :> How can i get objects current ref count from my python code? :> Thanks. :>>> import sys :>>> sys.getrefcount(None) : 1583 :>>> print "ciao - chris" : ciao - chris :>>> Wow, 1583 seems a little high to me. ;) Python 1.5.2 (#14, Jun 11 1999, 16:31:09) [C] on aix4 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import sys >>> sys.getrefcount(None) 140 >>> Anyone wonder what chris has been doing? ;) -Arcege From cgw at fnal.gov Wed Jun 30 16:42:25 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Wed, 30 Jun 1999 20:42:25 GMT Subject: A Python problem? In-Reply-To: <377A765F.90367AC5@connection.com> References: <377A765F.90367AC5@connection.com> Message-ID: <14202.33073.919694.671354@buffalo.fnal.gov> Colin J. Williams writes: > def main(): > import sys > print 'Start:',dir() > s0= sys.modules > import plugins.rptlib > s1= sys.modules > if s0 == s1: > print 'sys.modules is unchanged' This will *always* print "sys.modules is unchanged"; sys.modules is a dictionary, which is a mutable type. If you want to see if sys.modules changed, try this: s0 = sys.modules.copy() import stuff if sys.modules == s0: print "it's unchanged" From amackay at starvision.com Tue Jun 29 16:00:47 1999 From: amackay at starvision.com (Angus MacKay) Date: Tue, 29 Jun 1999 13:00:47 -0700 Subject: printing with print Message-ID: <377925EF.1CBB640F@starvision.com> is there any other way to print that with print? perhaps with a real function. I want to print two things without a space being added between them: foo = "there" print "hi" + foo works fine but: foo = 2 print "hi" + foo does not. I like the printing of any object ability of "print" so I do not want to use "" % style printing, I just want to be able to govern the whitespace that gets output. cheers, Angus. From faassen at pop.vet.uu.nl Mon Jun 7 04:34:55 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Mon, 07 Jun 1999 10:34:55 +0200 Subject: Alien whitespace eating nanovirus strikes again! References: <375500C9.742DC539@pop.vet.uu.nl> <375536C2.DD917F99@prescod.net> <7j4e2u$8rh$1@m2.c2.telstra-mm.net.au> <37564132.2D01B7C3@pop.vet.uu.nl> <3756BAFC.2066A636@home.com> <3756F071.E717D0FA@pop.vet.uu.nl> <37573C16.D0233810@home.com> Message-ID: <375B842F.BD53DA63@pop.vet.uu.nl> Jim Meier wrote: > David Schere's python wrapper, available from the same place as mine. Where o where was this again. :) > > I'm rambling about Python these days. Yesterday I read a paper from > > Guido about how he was thinking about bringing Python (or some successor > > language) to *billions* of users. :) > > Just think of all the nasty code _that_ would generate... I can't > beleive some of the English that some people speak, and am horrified to think > that when I'm 30, I might end up teaching "Python Literacy" to a group of bored > and whiny (and by that point, negative-attention-spanned) high school students > and trying to explain the design philosophy of "The-Right-Way"... !! You have to do your Duty for the Cause.. :) Yeah, Guido also talks about the nasty code that would be produced. Apparently they have some ideas for a development environment to make this less of a problem, though not much appears to be known about that development environment yet. Regards, Martijn From faassen at pop.vet.uu.nl Thu Jun 10 05:36:42 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Thu, 10 Jun 1999 11:36:42 +0200 Subject: Grimoire [was: How do I defect?] References: Message-ID: <375F872A.C8C53B1A@pop.vet.uu.nl> David Ascher wrote: > Andrew Kuchling is too modest to advertise it, but his > Python Grimoire is a good document to get a feel for common tasks in > Python. It's at: > > http://starship.python.net/crew/amk/grimoire/ > > It's a good thing to read just after the tutorial. I second that! This looks like a really useful document indeed. Thanks Andrew! Me-too-ly, Martijn From sragsdale at my-deja.com Mon Jun 7 22:25:17 1999 From: sragsdale at my-deja.com (sragsdale at my-deja.com) Date: Tue, 08 Jun 1999 02:25:17 GMT Subject: where does 'del' come from? Message-ID: <7jhuu5$8d4$1@nnrp1.deja.com> A fairly academic question, but I'm curious nonetheless. Where is 'del' defined? Functions like 'join' are obviously in the string package, 'range' is a builtin, but I can't seem to find 'del' anywhere. Python 1.5.2 (#12, Jun 2 1999, 19:23:30) [C] on irix646 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> dir(__builtins__) ['ArithmeticError', 'AssertionError', 'AttributeError', 'EOFError', 'Ellipsis', 'EnvironmentError', 'Exception', 'FloatingPointError', 'IOError', 'ImportError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplementedError', 'OSError', 'OverflowError', 'RuntimeError', 'StandardError', 'SyntaxError', 'SystemError', 'SystemExit', 'TypeError', 'ValueError', 'ZeroDivisionError', '__debug__', '__doc__', '__import__', '__name__', 'abs', 'apply', 'buffer', 'callable', 'chr', 'cmp', 'coerce', 'compile', 'complex', 'delattr', 'dir', 'divmod', 'eval', 'execfile', 'exit', 'filter', 'float', 'getattr', 'globals', 'hasattr', 'hash', 'hex', 'id', 'input', 'int', 'intern', 'isinstance', 'issubclass', 'len', 'list', 'locals', 'long', 'map', 'max', 'min', 'oct', 'open', 'ord', 'pow', 'quit', 'range', 'raw_input', 'reduce', 'reload', 'repr', 'round', 'setattr', 'slice', 'str', 'tuple', 'type', 'vars', 'xrange'] >>> range >>> del File "", line 1 del ^ SyntaxError: invalid syntax Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From Paul.Prescod at p98.f112.n480.z2.fidonet.org Tue Jun 29 12:20:25 1999 From: Paul.Prescod at p98.f112.n480.z2.fidonet.org (Paul Prescod) Date: Tue, 29 Jun 1999 17:20:25 +0100 Subject: PySequence_Check Message-ID: <00001582@bossar.com.pl> From: Paul Prescod Reuben Sumner wrote: > > How can I do the equivalent of a PySequence_Check in Python? > GvR told me that the question was illdefined (if I explained it correctly) > and to ask here. >... > What am I missing? I have a nested structure of lists and tuple and I > just want to know when I have bottomed out. I can check for tuple or > list indivually but that is ugly and inflexible. I could just try > indexing and see if there was an exception but that is not much better. Hi, Reuben. This latter is probably our best bet. Python in general has no way of declaring that an object acts as a sequence or mapping. Therefore there can be no way of querying whether an object acts as a sequence or mapping. In general, Python has no way of declaring that an object "acts as" anything at all (other examples would include a set, a widget, a web browser). There is no concept of interface or protocol except in the C API. I think that the goal is to define the concept in general before applying it specifically to sequences, mappings, file objects and other "built-in" protocols. My discussion with Guido on this issue began here: or you can do a deja search with "IsMappingType" There are some tricky issues about what this interface stuff all means in a dynamically typed language. The constant re-occurence of discussions like this have lead to the development of a special interest group: http://www.python.org/sigs/types-sig/ -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco "The new revolutionaries believe the time has come for an aggressive move against our oppressors. We have established a solid beachhead on Friday. We now intend to fight vigorously for 'casual Thursdays.' -- who says America's revolutionary spirit is dead? From mwh21 at cam.ac.uk Wed Jun 2 17:02:32 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 02 Jun 1999 22:02:32 +0100 Subject: pickle vs .pyc References: <7j43pn$55l$1@mlv.mit.edu> Message-ID: Michael Hudson writes: > Michael Vezie writes: > > > I need to be able to read a couple very complex (dictionary of arrays > > of dictionaries, and array of dictionaries of array of dictionaries) > > data structures into python. To generate it by hand takes too long, > > so I want to generate it once, and read it each time (the data doesn't > > change). > > > > The obvious choice is, of course pickle, or some flavor thereof. > > But can someone tell me why this wouldn't be faster: > > > > In the code that does the "pickling", simply do: > > f = open("cache.py", "w") > > f.write("# cache file for fast,slow\n") > > f.write("fast = "+`fast`+'\n') > > f.write("slow = "+`slow'+'\n') > > f.close() > > import cache > > > > Then, later, when I want the data, I just do: > > > > from cache import fast,slow > > > > and it's right there. It's compiled, and seems really fast (loading a > > 50k file in .12 seconds). I just tried the same data using cPickle, and > > it took 1.4 seconds. It's also not as portable. There is a space savings > > with pickle, but it's only 5% (well, 56% if you count both the .py and > > .pyc files), but that doesn't really matter to me. > > > > Am I missing something here? This sounds like an obvious, and fast, > > way to do things. True, the caching part may take longer. But I > > really don't care about that, since it's done only once, and in the > > background. > > > > Michael > > Hmm, you're relying on all the data you're storing having faithful > __repr__ methods. This certainly isn't universally true. I'd regard > this method as too fragile. > > If you're only storing simple data (by which I mean simple types of > data, not that the data is simple) (and I think you must be for the > approach you're using to work) give the marshal module a whirl. > > I think it will be substantially faster than your repr-based method > (cryptic hint: if it wasn't, the marshal module probably wouldn't > exist). > > Eg: > > import marshal > > complex_data_structure = {'key1':['nested list'],9:"mixed types"} > > marshal.dump(complex_data_structure,open('/tmp/foo','w')) > > print marshal.load(open('/tmp/foo')) > > HTH > Michael Duh! Of course, once you've imported cache.py once, it's compiled to a .pyc file and all the literals within it will be marshalled anyway. Still using marshal directly is certainly more robust and probably faster... one-day-I'll-learn-to-read-thesubject-as-part-of-the-message-ly y'rs Michael From neelk at brick.cswv.com Mon Jun 14 22:56:36 1999 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 14 Jun 1999 21:56:36 -0500 Subject: ANN: Stackless Python 0.2 References: <37628EAA.C682F16C@appliedbiometrics.com> Message-ID: <7k4fd4$c04$1@brick.cswv.com> In article <37628EAA.C682F16C at appliedbiometrics.com>, Christian Tismer wrote: >ANNOUNCING: > > Stackless Python 0.2 > >The possibilities are for instance: > >Coroutines, Continuations, Generators > >Coroutines will be able to run at the speed of >a single C function call, which makes them a considerable >alternative in certain algorithms. This is very neat, and you are completely deranged. I know just enough to know that I should cheer you on, mind, but I'll try to cheer loudly. Feel free to make an announce when you add coroutine support. Please? :) Neel From bwarsaw at cnri.reston.va.us Thu Jun 3 14:45:56 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Thu, 3 Jun 1999 14:45:56 -0400 (EDT) Subject: mailing list to news gateway References: <7j4asp$v4a$1@nnrp1.deja.com> Message-ID: <14166.52580.600388.729849@anthem.cnri.reston.va.us> >>>>> "jeremy" == writes: jeremy> Since about last Thursday, messages I have sent to jeremy> python-list at python.org haven't been showing up at Deja jeremy> News. I would assume they also aren't showing up in the jeremy> newsgroup, but I'm not sure. For some miraculous reason, it appears as if CNRI's internal upstream feed has -- just today -- become unwedged. It looks like we may have lost[1] gatewayed messages posted to the mailing list between 5/27 and 5/31, but that anything posted 6/1 until today seems to have gotten out. Our sysadmins, and Jeremy and I looked at our dnews installation and none of us know why it broke, or why it suddenly got unjammed (tho' I suspect DNS problems might have caused the original breakage). Those of you who post to the list via python-list at python.org, please keep an eye out on Deja.com to make sure messages are making it off our news server. One good rule of thumb that Jeremy had: if you don't see a posting on Usenet from Tim for a couple of days, there might be a problem :) If WCTW, I'll point the gateway directly at our upstream UUnet news server, but I'd rather not do that since it'll probably cause duplicates in one direction or the other. -Barry [1] lost means the messages didn't get propagated to Usenet. They did make it to the Pipermail archive though: http://www.python.org/pipermail/python-list From Andreas.Jung at p98.f112.n480.z2.fidonet.org Wed Jun 30 11:32:49 1999 From: Andreas.Jung at p98.f112.n480.z2.fidonet.org (Andreas Jung) Date: Wed, 30 Jun 1999 16:32:49 +0100 Subject: looking for cookie.py Message-ID: <000015bc@bossar.com.pl> From: Andreas Jung On Wed, Jun 30, 1999 at 01:15:19PM +0200, Mathieu Lecarme wrote: > the link on python web site doesn't work! > where can i find it? > ftp://ftp.bbn.com/pub/timo/python/Cookie.py -- _\\|//_ (' O-O ') ------------------------------ooO-(_)-Ooo-------------------------------------- Andreas Jung, Saarbr?cker Zeitung Verlag und Druckerei GmbH Saarbr?cker Daten-Innovations-Center Gutenbergstr. 11-23, D-66103 Saarbr?cken, Germany Phone: +49-(0)681-502-1563, Fax: +49-(0)681-502-1509 Email: ajung at sz-sb.de (PGP key available) ------------------------------------------------------------------------------- From Barry.A..Warsaw at p98.f112.n480.z2.fidonet.org Wed Jun 30 03:12:56 1999 From: Barry.A..Warsaw at p98.f112.n480.z2.fidonet.org (Barry A. Warsaw) Date: Wed, 30 Jun 1999 08:12:56 +0100 Subject: A Certifiable Very Cool Trick Message-ID: <000015b8@bossar.com.pl> From: "Barry A. Warsaw" >>>>> "DA" == David Arnold writes: DA> as i understood it, each interpreter presents a set of COM DA> APIs which provide an abstract view of stack frames, etc, DA> suitable for use by a symbolic script debugger. you can thus DA> debug across scripting languages using a single tool, watching DA> calls between interpreters, etc etc. Another thing that would be really cool, would be a debugging tool that could cross the implementation language barrier. E.g. stepping through Python, I could then drop down into the C or Java at that point. Having the ability to move between even those two abstraction levels would be pretty useful. Really cool would be the ability to also drop into the bytecode level (either under the Java source in the case of JPython, or between the Python and C code in the case of CPython). DA> all very cool, and so i started thinking about doing the same DA> thing for Unix via gdb (for C) and the Python interpreter DA> (what other languages are there? oh -- ELisp, yeah -- we can DA> do that!) Ah, so our dream of scripting XEmacs with Python isn't so far away... DA> ahhhhh. now, where's that spare time again? ...or is it? :) Fun to think about at least. -Barry From skip at mojam.com Wed Jun 30 22:44:37 1999 From: skip at mojam.com (Skip Montanaro) Date: Thu, 01 Jul 1999 02:44:37 GMT Subject: coverage tool for Python? References: <377ABE31.249B1E51@cup.hp.com> Message-ID: <377AD6AE.56797BD2@mojam.com> Ovidiu Predescu wrote: > Are there any coverage tools for Python? Not terrific, but there's a knock-off of the profiler I wrote a few years ago available at: http://www.musi-cal.com/~skip/python/ Search for "coverage". Cheers, -- Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/~skip/ 518-372-5583 From mark.butterworth at cis.co.uk Wed Jun 23 08:35:14 1999 From: mark.butterworth at cis.co.uk (Mark Butterworth - U-Net) Date: Wed, 23 Jun 1999 13:35:14 +0100 Subject: Freeze? References: <7kqcj4$3bd$1@nnrp1.deja.com> Message-ID: Curtis Yanko wrote in message <7kqcj4$3bd$1 at nnrp1.deja.com>... >I have loaded 1.5.2 and the Win32All-125 but dont see the freeze tool >anywhere. Searching the FTP site I only see Freeze for older versions. I think the author's site is at www.nightmare.com From gmcm at hypernet.com Tue Jun 15 10:17:10 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 15 Jun 1999 09:17:10 -0500 Subject: Bug in `imp' module? In-Reply-To: <3765C3F8.D3F8A4CD@bioreason.com> Message-ID: <1282666010-103335885@hypernet.com> Andrew Dalke writes: > Summary: imp.find_file returns the .py file before the .pyc file > when I think it should be the other way around. Solution should be > to swap two lines in Python/importdl.c Not so simple. The .pyc file is trash if the .py file is newer. I suggest you follow the earlier lead to Greg's imputil.py. You will still have to write code, but you'll be fitting your code into a "sane" architecture. Greg's is at: http://www.lyra.org/greg/small/ If he hasn't yet patched it to properly pass on reload requests, you can get a patched version from: www.mcmillan-inc.com/dnld/archive.tar.gz - Gordon From matomira at iname.com Fri Jun 11 06:13:04 1999 From: matomira at iname.com (Fernando Mato Mira) Date: Fri, 11 Jun 1999 12:13:04 +0200 Subject: Why is tcl broken? References: <375F82C7.CF0F0477@iname.com> <375FF969.C879B4CD@iname.com> <37601668.D9105225@mayo.edu> Message-ID: <3760E130.7456447@iname.com> Bob Techentin wrote: > These flame wars are more than five years old. Tcl has had namespaces > and a byte-code compiler for years. I know that. But I see some serious things there (the `call by name' issue, for example) that give me the impression must be still around unless the semantics have gone through a major change. I would cut this thread right here before someone comes up with some myth. There's enough work for debunkers there. Thanks, From tgm at math.uni-bonn.de Sun Jun 6 09:46:27 1999 From: tgm at math.uni-bonn.de (Thomas Ackermann) Date: Sun, 6 Jun 1999 15:46:27 +0200 Subject: Designing Large Systems with Python References: <372599D6.C156C996@pop.vet.uu.nl> <7g4a3l$atk$1@news.worldonline.nl> <7g99pj$b1$1@news.worldonline.nl> <7g9eln$4eq$1@news.worldonline.nl> Message-ID: Ilja Heitlager wrote: > I would love too, but Windows doesn't leave any space on my HD ;-( Reorganize your disk (scandisk or ?) then use "fips" to make this partition small and create a new, free partion from the saved space, then install LINUX ... ;-) Byebye, -- Thomas Ackermann | Tel. +49-(0)228/631369|73-7773 | finger tgm at rhein.math.uni-bonn.de for public key GNU LINUX Python gtk pygtk MySQL FUDGE GURPS From wlfraed at ix.netcom.com Wed Jun 2 00:14:28 1999 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Wed, 02 Jun 1999 04:14:28 GMT Subject: Python 2.0 References: <11A17AA2B9EAD111BCEA00A0C9B4179301E10ED1@forest.origin.ea.com> <374F1F6D.F3338F56@prescod.net> <374F5001.1C850DC@Lugoj.Com> <374F4591.3E66FB0@prescod.net> <374FF31A.6E990179@prescod.net> <37512edf.3024969@news.demon.co.uk> <3752ddac.3812702@nntp.ix.netcom.com> <3753EC5B.4C70860@prescod.net> Message-ID: <3754ade0.2590819@nntp.ix.netcom.com> On Tue, 1 Jun 1999 14:21:15 GMT, Paul Prescod declaimed the following in comp.lang.python: > That's all cool, but on Windows you get to choose your scripting language > which, for Python users, is even cooler. Still, I take your point that > AREXX was years ahead of Windows. And AREXX was ripped off of mainframe > REXX which was, of course, even older. I've (unfortunately in one way) had to migrate to a W95 machine, but the last Amiga Python port I saw did incorporate an AREXX interface mechanism. -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From Aahz.Maruch at p98.f112.n480.z2.fidonet.org Wed Jun 30 12:39:32 1999 From: Aahz.Maruch at p98.f112.n480.z2.fidonet.org (Aahz Maruch) Date: Wed, 30 Jun 1999 17:39:32 +0100 Subject: Python Editor Message-ID: <000015bf@bossar.com.pl> From: aahz at netcom.com (Aahz Maruch) In article , Jose A. Antich wrote: > > Does anyone know if there's any Python Editor for the MAc? IDLE, a debugger/editor written in Python. You'll need Python 1.5.2 and Tcl/Tk 8.0 (*not* 8.1). -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het From arcege at shore.net Mon Jun 28 14:09:48 1999 From: arcege at shore.net (Michael P. Reilly) Date: Mon, 28 Jun 1999 18:09:48 GMT Subject: Python GUIs: Summary and Conclusion References: <99FA4A1A1280BEBD.0A1ABA62CC989479.4C2C6022F695BEAC@lp.airnews.net> Message-ID: Mikael Lyngvig wrote: : Hi, : I think there is a sufficient number of replies to my original "Python : GUIs: Abondining TkInter and welcoming wxPython" post that a : conclusion can be made. Thanks to all who replied; the replies did : exactly what I wanted - presented a lot of arguments for and against a : switch from TkInter to wxPython. [Summary of arguments snipped] : Conclusion (my conclusion, at least...): : TkInter should continue to be the de-facto standard Python GUI. : Primarily because of its matureness, some say better design : philosophy, its portability, and its popularity. : wxPython continues to be a good alternative, as does others, which may : be better in specific situations and to some developers. : The TkInter module(s) should be rewritten to employ the native Tk API, : instead of Tcl, which would probably eliminate all sluggishness in : client applications. : More widgets should be added to Tk(Inter). : Anyone disagree? : Any volunteers to start work on making a native Tk C API version of : TkInter, 100 percent backwards compatible of course? I've already rewritten _tkinter to use a new pytcl module, but the functionality is still the same, ie. executing Tk calls from within an interpreter. But I'd like to see it using the TK/C API (so much for my hard word on rewriting _tkinter *wink*). The main issue would be to make it extensible for adding the new widgets and other extensions (BTL, PIL, etc.). Also, the interface between Python and C would not be as "simple" as the existing module. It's doable tho. Note that using the "native" Tk API would still require linking with the Tcl library. I could scratch my _tkinter rewrite and work on a native solution. (I could still publish my pytcl module.) Any thoughts? We already know that Python 1.6 won't be until the new year, so any changes to Tkinter would be as a patch. -Arcege From behrends at cse.msu.edu Sat Jun 26 01:57:38 1999 From: behrends at cse.msu.edu (Reimer Behrends) Date: 26 Jun 1999 05:57:38 GMT Subject: GC In Python: YAS (Yet Another Summary) References: <930267199.139037@clint.waikato.ac.nz> <37730BAA.28A7C738@bioreason.com> <930340397.465868@clint.waikato.ac.nz> <3773EFF7.27D29899@bioreason.com> Message-ID: Andrew Dalke (dalke at bioreason.com) wrote: [...] > Yes, the library has a pointer table to the object. The problem > I see is, how does the Boehm collector (or other GC) know what to > collect from this vendor library? I can't see how, given that > my Python code stores it as an integer. The Boehm collector is conservative; it will treat any word in memory as a potential pointer until proven otherwise. It uses a number of sophisticated methods to avoid misidentifying integers as pointers. Surprisingly enough, this approach works pretty well in practice. I've used it more than once to reign in a misbehaving C program (which leaked memory or freed storage prematurely). > That's why I don't see how you say "It fully supports C and C++" > when this is a package which doesn't do "pointer XORing or other > crimes" but cannot be usable with a GC w/o modifications. The few practices that are unsafe should be avoided by programmers, anyway. Like xoring pointers together, or doing similar ugly things. Most programs are pretty well-behaved. [...] Reimer Behrends From 8499 at greenhead.ac.uk Wed Jun 30 05:31:49 1999 From: 8499 at greenhead.ac.uk (Newbie) Date: 30 Jun 1999 04:31:49 -0500 Subject: I am v. stupid, please help Message-ID: <3779d5f5@discussions> I have just downloaded Python 1.5 and I have had a brief look at the helpfiles and some source code and my stupid question is this : How do you define a string and then use it for input, e.g, name = input('What is your name : ') This works for integers but not for strings, Help Me Please!! --Posted from EarthWeb Discussions. http://discussions.earthweb.com From MHammond at skippinet.com.au Thu Jun 10 02:24:51 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Thu, 10 Jun 1999 16:24:51 +1000 Subject: Windows Printing Question References: <375EF682.CCAC69D1@west.boeing.com> Message-ID: <7jnlkj$r1v$1@m2.c2.telstra-mm.net.au> If you are using IE4, you should investigate the COM interfaces. The win32com\test directory has a COM sample that loads a page in explorer. Making it print this should be quite simple. Mark. Jeff P. wrote in message <375EF682.CCAC69D1 at west.boeing.com>... >I have a set of Internet shortcuts on a Windows 95 machine that I'd like >to print out. I know Windows can do this, after all, I can right-click >on a shortcut and select "Print" and it'll do it. The question is: How >to do this programaticaly? ... From ray at commsecure.com.au Wed Jun 9 18:43:56 1999 From: ray at commsecure.com.au (Ray Loyzaga) Date: Thu, 10 Jun 1999 08:43:56 +1000 Subject: [Thread-SIG] RE: tstate invalid crash with threads References: <000101beb237$88b71d80$999e2299@tim> <003201beb296$b9be7d60$d5a245ab@cisco.com> Message-ID: <375EEE2C.B7E7EF68@commsecure.com.au> Scott Cothrell wrote: > > I can confirm that we were seeing similar behavior under a highly threaded, > highly stressed situation. We backed off on the number of threads and > slowed things down as a workaround also. We couldn't trace it down to > Python, as we have a Java, C, Python mix that has too many suspects. > The locking code added to the create/destroy side of the threads has yielded good results. On my stripped down server, which was crashing after between 40,000 and 1.4M transactions managed 14.75M last night. I will kill this and attempt to run my real task for a day or so, but it seems to confirm a small race exists .... From bob at horvath.com Thu Jun 10 21:44:45 1999 From: bob at horvath.com (Bob Horvath) Date: Thu, 10 Jun 1999 20:44:45 -0500 Subject: Scripting Telnet References: Message-ID: <37606A0D.6332A9C2@horvath.com> Emile van Sebille wrote: > Hello all, > > I've accepted a project and I think I can use Python for part of it. > > The project is moving data collected in a warehouse management system > into a proprietary, legacy CHUI application. The information is to be > processed hourly by a cron job under HPUX. Most of the legacy app > source code is available, but there are some black boxes in there I > can't get at. The app doesn't like standard input redirection, but will > run in a telnet session. > > My choices appear to be 1) write a utility in the native app's > environment the mimics the result set of the current app (and I _really_ > don't want to wade through that crap to figure it out); or 2) script the > input requirements and feed the application while it runs (I've done > this for smaller projects using VB sendkeys). > > I feel that python ought to be good for this, and I'm hoping you'll > point me to the appropriate modules to look into or techniques to use. > I did a little browsing through dejanews and saw a reference to perl's > expect that looks like it does this kind of work,so maybe there's a > python tool too? > > Trying-to-get-paid-and-learn-more-python-at-it-ly y'rs, > Well, the tcl based expect is probably the most appropriate tool for such a thing, but there is a pythonized version(s) of it as well. The one I can think of is ExpectPy, (http://www1.shore.net/~arcege/python/ExpectPy/), but I seem to remember seeing at least one other one. From m01ymu00 at cwcom.net Fri Jun 4 11:36:44 1999 From: m01ymu00 at cwcom.net (Daniel Faulkner) Date: Fri, 04 Jun 1999 16:36:44 +0100 Subject: Alien whitespace eating nanovirus strikes again! References: <375500C9.742DC539@pop.vet.uu.nl> Message-ID: <3757F28B.BF6411FE@cwcom.net> How many messages are there about this white space stuff? Looks like millions whats it all about? Martijn Faassen wrote: > Hi there, > > I don't intend to start a flamewar or anything, and I'm sure Larry Wall > is a nice guy, and Perl is nice and all, and the postmodern > rationalisation of the confusion that Perl is to me is *fun* (but does > not work for me), but Larry Wall seems to be infected by the whitespace > eating nanovirus meme. From an interview at: > > http://www.linuxjournal.com/issue61/3394.html > > Interviewer: In what way is Perl better than other scripting languages > such as Python and Eiffel? > > [Eiffel a 'scripting language'? hm] > > [Larry Wall:] > [Perl is postmodern] > > That is, if something's worth doing, it's worth driving into the ground to the > > exclusion of all other approaches. Look at the use of parentheses in Lisp or > > the use of white space as syntax in Python. Or the mandatory use of objects in > > many languages, including Java. All of these are ways of taking freedom away > > from the end user ``for their own good''. They're just versions of Orwell's > > Newspeak, in which it's impossible to think bad thoughts. We escaped from the > > fashion police in the 1970s, but many programmers are still slaves of the cyber > > police. > [Perl is postmodern and therefore allows freedom] > > One could say the same about Perl and it requiring it curly braces > around blocks? In fact, I heard the claim that its requirement to use > curly braces around single line blocks (unlike C which allows you to > remove them) makes Perl less prone to errors. And Perl excludes the use > of meaningful whitespace indentation! (python does allow #{ and #} > blocks ;) > > Okay, I *will* say the same about Perl and its curly braces requirement: > > } That is, if something's worth doing, it's worth driving into the > ground to the > } exclusion of all other approaches. Look at the use of curly braces in > } Perl. > > *any* language makes it impossible to code in some ways, and encourages > other coding styles, Perl included. Python, for instance, allows > procedural and object oriented coding styles; and people keep trying for > functional styles as well. We've even started using 'assembler style' by > manipulating Python bytecodes! Silly, silly, whitespace meme. > > People think bad thoughts in Python all the time (see the 'evil hacks' > threads showing up regularly). It's just that we have the sense to > recognize the bad thoughts for what they are. I suppose that's why > 'advisory locking' of member data is good enough for Python. :) > > Okay, sorry for all this, it's out of line, I just needed to blow off > steam. :) > > Regards, > > Martijn From duncan at rcp.co.uk Mon Jun 28 04:44:31 1999 From: duncan at rcp.co.uk (Duncan Booth) Date: 28 Jun 1999 08:44:31 GMT Subject: [ANN] DejaGrabber 0.1 -- search Dejanews with Python References: <7kuu73$1ki$1@brick.cswv.com> Message-ID: <8DF363D15duncanrcpcouk@news.rmplc.co.uk> Neel Krishnaswami wrote in <7kuu73$1ki$1 at brick.cswv.com>: > >If you'd like a convenient way of searching the DejaNews archive using >Python, I'm happy to present the DejaGrabber module. This is a module >to make searching Dejanews easier. There are two classes, DejaGrabber >and Article. I've tried to add a reasonable number of useful >docstrings, too. > >Here's an example: >>>> from DejaGrabber import * >>>> d = DejaGrabber(group='comp.lang.python', author='Tim Peters') >>>> l = d.get_messages(4) >>>> print l >[99/06/23 30 comp.lang.python RE: Python Exes! Tim Peters >, 99/06/18 28 comp.lang.python RE: Newbie: Truth values (th Tim Peters >, 99/06/18 28 comp.lang.python RE: DATE ARITHMETIC Tim Peters >, 99/06/18 28 comp.lang.python RE: NameError Problem Tim Peters >, 99/05/18 25 comp.lang.python RE: while (a=b()) ... Tim Peters >] > Nice bit of work. Two comments though: Why does get_messages(4) return 5 messages? The doc string implies it should return only as many as its argument. It would be useful if a test example was included in a "if __name__=='__main__'" block at the end of the file. At the very least the example you give above, but perhaps more usefully a full command line driven grabber. -- Duncan Booth duncan at dales.rmplc.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? http://dales.rmplc.co.uk/Duncan From blipf at yahoo.com Tue Jun 8 22:34:38 1999 From: blipf at yahoo.com (Flbill Blipf) Date: Tue, 08 Jun 1999 19:34:38 -0700 Subject: makepy not war Message-ID: <375DD2BE.D918CCCE@yahoo.com> I hope this is not too general of a question. After running makepy.py on a type library, how do I use the resulting file? I know how to use win32com.client.Dispatch, and I kinda sort of know how to use CoCreateInstance, QueryInterface, etc. with C++. From paul at prescod.net Wed Jun 2 01:02:54 1999 From: paul at prescod.net (Paul Prescod) Date: Wed, 02 Jun 1999 00:02:54 -0500 Subject: Python 2.0 (perhaps off topic) References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <87pv3iq6ss.fsf@ev.netlab.co.jp> <3752C76D.604CD474@prescod.net> <87n1ykr0z9.fsf@ev.netlab.co.jp> <375372F6.A874554@prescod.net> <14164.7179.10346.998488@bitdiddle.cnri.reston.va.us> <375431E6.6BC64E80@prescod.net> <14164.43542.417731.361360@bitdiddle.cnri.reston.va.us> Message-ID: <3754BAFE.192D7648@prescod.net> Jeremy Hylton wrote: > > Perhaps this is what I get for jumping in in the middle of a > conversation without learning how it got started. The example I was > responding to depended on file object being immediately finalized to > avoid leaking file descriptors. This is a documented feature of Python (documented in the FAQ at least). New users do not currently need to learn otherwise unless they use JPython which is incompatible in this regard. In other words, this IS a demonstration of a flaw in GC, or at least in Java GC because it required a change in the Python language semantics. I think that that is all anyone has been saying. Many people like the current semantics and don't trust that a full GC would deterministically invoke finalizers for arbitrary resources. -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco "Silence," wrote Melville, "is the only Voice of God." The assertion, like its subject, cuts both ways, negating and affirming, implying both absence and presence, offering us a choice; it's a line that the Society of American Atheists could put on its letterhead and the Society of Friends could silently endorse while waiting to be moved by the spirit to speak. - Listening for Silence by Mark Slouka, Apr. 1999, Harper's From rdev at my-deja.com Wed Jun 30 13:59:45 1999 From: rdev at my-deja.com (rdev at my-deja.com) Date: Wed, 30 Jun 1999 17:59:45 GMT Subject: Reflection in Python? References: <7ldglr$ita$1@nnrp1.deja.com> Message-ID: <7ldlu8$lb7$1@nnrp1.deja.com> In article <7ldglr$ita$1 at nnrp1.deja.com>, anders777 at my-deja.com wrote: > ...How do I do the > equivalent of what Java calls reflection? I want > to do the following: > > test = MathTest("testAdd") > > where test.run() will run the "testAdd" method on > the MathTest object? I also want to be able to > tell the user the name of the object (MathTest) > and the method in case the method fails. Any > thoughts? > If I understand what you are trying to do, it's easy in Python. Assuming MathTest is an object instance: test = MathTest.testAdd will return you a bound method object which you can then call as: test() Getting the name of the object class and method is also easy. There are several ways to do this: 1) Define a doc string within the method by putting a quoted string as the first line under the def line. You can then refer to it as "test.__doc__". This could say, for example, "Method bar of class foo". 2) "test.__name__" will return the name of the method. "test.im_class.__name__" will return the name of the class that the method is defined within. Example: class MathTest: def testAdd(self, parm1, parm2): "Method testAdd of Class MathTest" result = parm1 + parm2 return result <<< mt = MathTest() <<< test = mt.testAdd <<< test.run(2,2) 4 <<< print test.__doc__ Method testAdd of Class MathTest <<< print test.__name__ testAdd <<< print test.im_class.__name__ MathTest I hope that helps. - Roger > Thanks, > Anders Schneiderman > National Journal Daily Briefings Group > > Sent via Deja.com http://www.deja.com/ > Share what you know. Learn what you don't. > Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From uzs59g at uni-bonn.de Wed Jun 30 02:43:06 1999 From: uzs59g at uni-bonn.de (Axel Schmitz-Tewes) Date: Wed, 30 Jun 1999 08:43:06 +0200 Subject: win32com.client -- beginner question Message-ID: <3779BC79.720C1281@uni-bonn.de> Hello, I ' ll try to use the comclient ability of python. In the Doku I have found the example: o = win32com.client.Dispatch("Excel.Application") o.Visible = 1 o.Workbooks.Add() # for office 97 ? 95 a bit different! o.Cells(1,1).Value = "Hello" Because I have installed Excel95 I have given it a try and that's the result: Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import win32com.client >>> o= win32com.client.Dispatch("Excel.Application") >>> o.Workbooks.Add() Traceback (innermost last): File "", line 1, in ? File "E:\Programme\Python\win32com\client\dynamic.py", line 400, in __getattr_ _ raise AttributeError, "%s.%s" % (self._username_, attr) AttributeError: Excel.Application.Workbooks But Workbooks.Add is a available method as I can test with VBScript. Is my installation corrupt or do I do some silly mistake or perhaps some more serious? Thanks for any answer. Regards, Axel From tim_one at email.msn.com Thu Jun 10 21:10:22 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 10 Jun 1999 21:10:22 -0400 Subject: Broken 1.5.2 installation? Missing cw3215mt.dll In-Reply-To: Message-ID: <000101beb3a7$2ea18440$329e2299@tim> [Mike C. Fletcher] > Just downloaded the latest 1.5.2 for installation. Did the > installation and got an error message telling me that the > above-mentioned file is not on the path. Indeed, it does not > seem to exist anywhere on the machine. I'm pretty sure this is > part of TCL (the cygnus TCL distribution has a file named > cw3215.dll). However, I have no idea where to get it. Very strange! I don't have a cw3215mt.dll, but do have a cw3215.dll. Presumably the former is a multi-threaded ("mt") version of the latter. The strings in the latter identify it as verion 1.5 of the runtime for Borland C++ 4.50. So bug Borland, or search the web for this name. Several packages out there appear to distribue *some* dll with this name. BTW, *when* did this error pop up? It's unclear. That is, did the installation complete (in which case what does the error have to do with the installation?), or did it occur during the install (in which case exactly when during the install)? There's no mention of cw*.dll in either the Tcl/Tk or Python install logs left behind by my 1.5.2 installation. Makes me wonder whether the installer itself needs this DLL. just-another-day-in-dll-hell-ly y'rs - tim From Barry.A..Warsaw at p98.f112.n480.z2.fidonet.org Tue Jun 29 12:52:46 1999 From: Barry.A..Warsaw at p98.f112.n480.z2.fidonet.org (Barry A. Warsaw) Date: Tue, 29 Jun 1999 17:52:46 +0100 Subject: A Certifiable Very Cool Trick Message-ID: <000015a3@bossar.com.pl> From: "Barry A. Warsaw" Just a quick note because this is way too cool not to share. When python.org came back up today, it almost immediately got cpu slammed (and has been for at least the last 3 hours). I know what's going on -- it has to do with performance problems in Mailman that in this case was triggered by a flood of incoming messages to all the mailing lists. This Mailman problem has been seen by a few other users, but it's dang hard to track down. Guido, Jeremy, and I got to talking about what tools we'd like to have to help debug this problem. My model was gdb's attach feature where you can attach to, stop and trace through a running external C program. I would love to be able to do the same thing at the Python level. We started talking about remote pdb's with threads listening on sockets, etc. (still cool ideas but more work). I mentioned that I'd love to be able to just get a traceback of where the program is currently stopped. Even if it hoses the interpreter afterwards, it would still be incredibly useful. Guido and I spent some fun after hours hacking time and came up with the following trick. [This is described in terms of gdb, but you might be able to do something similar with dbx or other Unix and non-Unix debuggers, I dunno] First, get the pid of the running Python process. Start up gdb on the python executable and at the gdb prompt type "attach XXX" where XXX is the pid. Now, at the gdb prompt, type the following: (gdb) call PyRun_SimpleString("import sys, traceback; sys.stderr=open('/tmp/tb','w',0); traceback.print_stack()") Sitting in /tmp/tb will be the stack trace of where the Python program was when you stopped it! There's reason to believe this will not always work, and it could seriously confuse your interpreter depending on where it stops. But every time I've tried it it /does/ work, and you can even detach the program and let it continue on! Chris Tismer, somehow I think your stackless Python might either make this trick harder or much easier :) makes-this-geek-quiver-with-joy-but-my-mom-would-just-scratch-her-head-ly y'rs, -Barry From dalke at bioreason.com Sat Jun 12 02:29:13 1999 From: dalke at bioreason.com (Andrew Dalke) Date: Sat, 12 Jun 1999 00:29:13 -0600 Subject: sneaky Python path Message-ID: <3761FE39.BF1C3461@bioreason.com> I have a problem understanding how Python knows which files to include in the default path. I get different results if the binary is run in its build directory as compared to outside of it: val> unsetenv PYTHONPATH val> pwd /var/tmp val> ~/Python-1.5.1/python 'import site' failed; use -v for traceback Python 1.5.1 (#23, Dec 8 1998, 05:12:14) [C] on irix6 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> val> cp ~/Python-1.5.1/python . val> ./python Python 1.5.1 (#23, Dec 8 1998, 05:12:14) [C] on irix6 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> When I do "~/Python-1.5.1/python -v" it says: 'import site' failed; traceback: Traceback (innermost last): File "/home/u03/dalke/Python-1.5.1/Lib/site.py", line 60, in ? import sys, os File "/home/u03/dalke/Python-1.5.1/Lib/os.py", line 35, in ? import posixpath SystemError: bad argument to internal function I think the problem arises from getpath.c in search_for_prefix where it appends "Lib" to the path if the code is in the build directory (as determined by looking for Modules/Setup). That's the only reason place I can find where "Lib" can be added to the path. To double check, if I move Setup to Setup.orig, then everything is okay val> pwd /home/u03/dalke/Python-1.5.1 val> cd Modules/ val> mv Setup Setup.orig val> pushd /usr/tmp /usr/tmp ~/Python-1.5.1/Modules val> ~/Python-1.5.1/python Python 1.5.1 (#26, Jun 11 1999, 23:54:47) [C] on irix6 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> I found this problem when I tried running a "make test" on the distribution, and it failed saying: % make test [...some lines omitted...] rm -f ./Lib/test/*.py[co] PYTHONPATH= ./python ./Lib/test/regrtest.py 'import site' failed; use -v for traceback Traceback (innermost last): File "./Lib/test/regrtest.py", line 193, in ? sys.exit(main()) File "./Lib/test/regrtest.py", line 60, in main tests = args or findtests() File "./Lib/test/regrtest.py", line 104, in findtests testdir = findtestdir() File "./Lib/test/regrtest.py", line 160, in findtestdir testdir = os.path.dirname(file) or os.curdir AttributeError: path I'm not sure what changed between then and now. All I can think of is that my home account got moved after a recent server crash, but I can't see any place in the code where that would cause a problem, and my home directory isn't even stored in the .o files anywhere. Also, I've found a workaround by copying a valid posixpath.pyc into the Lib directory. Watch this: val> rm Lib/*.py val> ./python 'import site' failed; use -v for traceback Python 1.5.1 (#26, Jun 11 1999, 23:54:47) [C] on irix6 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> val> cp /usr/local/lib/python1.5/posixpath.pyc Lib val> ./python Python 1.5.1 (#26, Jun 11 1999, 23:54:47) [C] on irix6 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam So I'm stumped, stymied and just plain old confused. Python is doing something sneaky and I can't figure it out :( Andrew dalke at bioreason.com From larsga at ifi.uio.no Mon Jun 21 02:59:58 1999 From: larsga at ifi.uio.no (Lars Marius Garshol) Date: 21 Jun 1999 08:59:58 +0200 Subject: XML-toolkit for Windows - binaries available? References: <376701a3.72288277@newssrv> <3767fc51.1547455@news.iol.ie> <37693395.731772@news.iol.ie> <376da59b.2034245@news> Message-ID: * Lee Borkman | | Now I have to edit __init__.py to include sgmlop and pyexpat in the | __all__ list, is that right? Now which __init__.py would that be? | I assume it's C:\Program Files\Python\Lib\xml-0.5.1\__init__.py I haven't done this, and I don't think you need to do it unless you care what the result of import xml dir(xml) is. | But none of the demos will work. I keep getting: | ImportError: No module named xml.sax | or: | ImportError: No module named pyversioncheck | | | I guess I still don't understand where Python (and PythonWin) look for | their modules, and I guess I don't understand quite a bit of other | stuff. It sounds like you haven't set your PYTHONPATH. This is an environment variable with a list of ';'-separated directories, but you can also set it in the registry under HKEY_LOCAL_MACHINE\Software\Python Make sure you include C:\Program Files\Python\Lib\xml-0.5.1\ in that list. --Lars M. From rgolden at x25.net Thu Jun 24 18:56:13 1999 From: rgolden at x25.net (Ryan Golden) Date: Thu, 24 Jun 1999 22:56:13 GMT Subject: python-mySQL module documentation other that python.org? Message-ID: <3772b3ee.27015456@news2.x25.net> Can anyone tell a beginner where one might find some example scripts for using the mySQL.py interface? I found the documentation on python.org to be confusing, and couldn't find any links to any example scripts. From pduffin at mailserver.hursley.ibm.com Mon Jun 28 08:52:50 1999 From: pduffin at mailserver.hursley.ibm.com (Paul Duffin) Date: Mon, 28 Jun 1999 13:52:50 +0100 Subject: Linking an Interpreter dynamically References: Message-ID: <37777022.19A1@mailserver.hursley.ibm.com> Lloyd Weehuizen wrote: > > Hi! > > I was just wondering if it is possible to create a dynamically linkable > python interpreter? I've looked in the docs, but can't seem to find > anything, and "make sharedinstall" doesn't seem to give me any linkable > libraries?? > On Windows Python is built as a DLL but on Unix Python is built as an archive library. Apparently Guido decided that he did not want to build Python as a shared library on Unix (or even support it in the standard installation) for some reason but I do not know why. The only reason why it is built as a DLL on Windows is that otherwise Python could not load dynamic extensions due to linking problems in Windows. -- Paul Duffin DT/6000 Development Email: pduffin at hursley.ibm.com IBM UK Laboratories Ltd., Hursley Park nr. Winchester Internal: 7-246880 International: +44 1962-816880 From mychoko at my-deja.com Thu Jun 10 21:30:40 1999 From: mychoko at my-deja.com (my) Date: Fri, 11 Jun 1999 01:30:40 GMT Subject: swig' example don't swig ! Message-ID: <7jpos1$2ki$1@nnrp1.deja.com> hi, i was trying to "swig" one of the examples available in the distribution under Examples/python/manual/pde1 running (almost) exactly the swig command given in the documentation and i get these errors: > swig1.2 -python -shadow pde.i Generating wrappers for Python pde.h : Line 17. Syntax error in input. pde.h : Line 21. Syntax error in input. pde.h : Line 23. Syntax error in input. pde.h : Line 29. Syntax error in input. Can anyone help me on that ? Thanks a lot, -- my. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From guido at CNRI.Reston.VA.US Mon Jun 21 16:26:34 1999 From: guido at CNRI.Reston.VA.US (Guido van Rossum) Date: Mon, 21 Jun 1999 16:26:34 -0400 Subject: mailman outage Message-ID: <199906212026.QAA15112@eric.cnri.reston.va.us> Two of our mailing lists, python-list at python.org and mailman at python.org, may have suffered a brief outage today (Jun 21st) between 3 and 4:30 pm EST. A disk volume filled up (ironically with mail syslog messages) and this caused some mailman processes to fail. I believe we've fixed the problem now, but if you sent something to either list during or shortly before the time of the outage, and did not see it come through, you might consider resending. --Guido van Rossum (home page: http://www.python.org/~guido/) [temporary webmaster :-( ] From kiki at pixar.com Fri Jun 4 02:06:26 1999 From: kiki at pixar.com (kiki) Date: Thu, 03 Jun 1999 23:06:26 -0700 Subject: More Tkinter menu problems References: <3755C714.526B7994@pixar.com> <%Zm53.899$S15.46310@dfiatx1-snr1.gtei.net> Message-ID: <37576CE1.133C4514@pixar.com> > Another possible way of implemented getting the same result, without > resorting to unreadable lambda expressions is to create a class > something like... > > class Command: > def __init__(self, func, *args, **kw): > self.func = func > self.args = args > self.kw = kw > > def __call__(self, *args, **kw): > args = self.args + args > kw.update(self.kw) > apply(self.func, args, kw) > > then... > > command = Command(self.select_color, new_color) > > This costs one extra function call when it is used, but I think the > decrease in complexity of the expression make it worth it. > > -- > Tim Evans Great! Thanx. That worked well. Kiki From paul at prescod.net Mon Jun 28 15:13:00 1999 From: paul at prescod.net (Paul Prescod) Date: Mon, 28 Jun 1999 19:13:00 GMT Subject: Pythonwin and Office 2000 References: <377648A7.9B9BE59F@prescod.net> <7l672r$5k0$1@m2.c2.telstra-mm.net.au> <3776D1E6.45E1AAF7@prescod.net> <7l7bbt$42u$1@m2.c2.telstra-mm.net.au> Message-ID: <3777C93C.F0B5E236@prescod.net> Mark Hammond wrote: > > I agree. Worse, as you found out, it breaks when upgrading the COM object. > However, the only way to do it textually would be to search the registry for > the name. Would that be the same speed as .Dispatch("..."), or ar you saying it would be slower? Anyhow, could we store the mapping from string names to UUIDs in the gencache directory so that the second time is fast? > However, it is worth noting that speed is no longer a good justification for > using makepy. Recent changes to dynamic dispatch mean that we are now > comparable speed wise to VB without makepy support. The reason you often > now need makepy support is to get decent parameter support, but the problem > is worse than that. In many non-trivial cases, the code you write is simply > not compatible between makepy supported and dynamic dispatch. So, if you > want to ensure your code will run when installed, you must _insist_ on > makepy support. (ie, silent failure of makepy is usually not a good option, > as you are simply delaying the inevitable error, but in a less obvious way). Okay, I don't understand what stuff works with makepy and what stuff doesn't. Let's put it this way: if we did everything dynamically the same stuff VBScript does dynamically would we slow down so much that makepy would be significantly faster again? Part of the reason I was using makepy was because I needed access to constants. How does JScript/VBscript handle this? Do you just have to use numbers? Even if makepy is 10 times faster than dynamic dispatch, if code at least behaved the same with and without it, then we could just try to do the makepy generation when possible and fallback to dynamic dispatch otherwise. Savvy programmers could manually force makepy generation if they really care about speed. > There is plenty of scope to rationalize some of this. As Python COM support > has grown from its humble beginnings, some of the existing code is no longer > appropriate. It is also big and scary enough that fiddling will not have > the desired effect - it needs a good, hard think and a revamp. > Compatibility shouldnt be an issue - there are only about 4 truly public > functions in the whole package - 99% of users will only care that > "win32com.client.Dispatch" does what they expect! You're suggesting a volunteer take your big, scary code and improve upon it? :) Is this just Python code that needs fixing or a mix of Python and C++? (i.e. are the C++ primatives you provide enough to build the cool new Python system on top?) -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco Those who profess to favor freedom and yet depreciate agitation, are men who want crops without plowing up the ground. They want rain without thunder and lightning. They want the ocean without the roar of its many waters. - Fredrick Douglass http://www.informamerica.com/Articles/Quotes.htm From gdd0 at gte.com Tue Jun 29 15:39:54 1999 From: gdd0 at gte.com (Gary D. Duzan) Date: Tue, 29 Jun 1999 19:39:54 GMT Subject: ANN: Stackless Python 0.2 Message-ID: <199906291939.PAA24426@lion.gte.com> In Message <37791B4D.43ADC401 at appliedbiometrics.com> , Christian Tismer wrote: =>Gary Duzan wrote: =>> =>> Toby J Sargeant wrote: =>> > =>... =>> This appears to be the conventional wisdom. The optimization class I =>> took used an ML-like language, and the first thing we did was to move =>> heap frames, which was the default, to the stack (i.e. closure =>> optimization.) => =>Loosing much of flexibility by doing that, btw. True. For example, (if I remember correctly; it has been a while) tail call optimization is defeated. In this particular case, however, we didn't break the language semantics (which didn't guarantee constant memory tail recursion) because we only did stack conversion after checking that it wouldn't break anything. Otherwise, the closure is left on the heap. I see that I wasn't clear about that in my original post; sorry 'bout that. =>> It might be less of an issue in an interpreted language if it already has =>> heap =>> allocation (or other sorts of) overhead to deal with when making calls. =>> There may be other allocation tricks which can be used, as well. =>> > It seems that this should affect Stackless Python equally as much. Does a nyone =>> > have anything to add on the subject? I would imagine that frames could be =>> > allocated and managed in chunks to alleviate a lot of the memory manageme nt =>> > load... =>> =>> I would think that as well (at least at first.) Maybe pools of different =>> sizes of frame to limit the space overhead. => =>Maybe you should really look into the sources. =>You are discussing things which are not Python =>related, since this simply does not apply. Freely conceeded. =>The Python "stacks" are so tiny that you can forget about them. =>Allocations always never occour, unless your program runs =>astray in recursion. => =>The cost of a call comes from the slightly complicated =>function setup which is done all the time. Frames belong =>to the fastest available Python objects already, =>like, say dictionaries. I thought that might be the case, which is the point I was making in my earlier paragraph. I was just briefly pondering possibilities for reducing frame memory management time, if it were necessary. Stackless Python certainly seems to me to be a Good Thing. Gary Duzan GTE Laboratories From air at apex.net Thu Jun 3 14:51:16 1999 From: air at apex.net (Todd Neal) Date: Thu, 3 Jun 1999 13:51:16 -0500 Subject: Re example Message-ID: Looking for some examples on how to use re, had a script made with sed ,awk, and lynx to download and parse webpages for viewing on a palmpilot, I would like to convert it to Python but I cant find any good examples of how to use the re modules. Thanks, Todd From jepler at inetnebr.com Fri Jun 4 12:33:30 1999 From: jepler at inetnebr.com (Jeff Epler) Date: Fri, 04 Jun 1999 16:33:30 GMT Subject: Alternative dictionary output format? References: <7j8pd8$f01$1@nnrp1.deja.com> Message-ID: On Fri, 04 Jun 1999 14:55:42 GMT, rael at my-deja.com wrote: >s = "%(href)s/foo/bar?x=%m&y=%n" (he wants to only substitute the %(href) and not the rest) s = "%(href)s/foo/bar?x=%%m&y=%%n" i.e., double the percents you want to have not interpolated at this stage of the game. A clever regular expression might be able to do this for you, but the way to write it 100% bulletproof escapes me. Jeff -- \/ http://www.slashdot.org/ Jeff Epler jepler at inetnebr.com I just forgot my whole philosophy of life!!! From def-p at usa.net Sun Jun 20 09:29:57 1999 From: def-p at usa.net (Def P) Date: Sun, 20 Jun 1999 13:29:57 GMT Subject: [Tkinter] Placing a ScrolledText on a Canvas? Message-ID: <19990620132958.27148.qmail@nwcst292.netaddress.usa.net> The subject says it all, really... I would like to have a window with some fancy background, yet full functionality. So I thought, I use a Canvas, put an image on it, then put additional components on it. So far it works reasonably... I put an Entry on it (== the Canvas with PhotoImage on it), with no problems at all. However, I cannot seem to manage to put a ScrolledText on the same Canvas. The following code demonstrates this: from Tkinter import * from ScrolledText import ScrolledText root = Tk() root.canvas = Canvas(root, width=400, height=580, background='gray',relief=SUNKEN) root.canvas.pack() photo = PhotoImage(file="c:/multimedia/pix/SmallerDragonBanner.gif") item = root.canvas.create_image(1, 1, anchor=NW, image=photo) entry = Entry(root, width=38) entry1 = root.canvas.create_window(60, 490, anchor=NW, window=entry) textBox = ScrolledText(root, width=15, height=30) textBox1 = root.canvas.create_window(50, 100, anchor=NW, window=textBox) root.mainloop() I cannot copy the exact error message but it says that it "can't use .8201376.text in a window item of this canvas"... Am I doing something wrong, or is a ScrolledText "just" an item that cannot be put on a canvas? Thanks, Def P ____________________________________________________________________ Get free e-mail and a permanent address at http://www.netaddress.com/?N=1 From ljz at asfast.com Wed Jun 2 00:38:36 1999 From: ljz at asfast.com (Lloyd Zusman) Date: 02 Jun 1999 00:38:36 -0400 Subject: Is pcgi usable without Zope? Message-ID: I have to admit that I'm a bit confused about pcgi these days. The most recent documentation for it was last updated in August, 1998, and it still refers to Bobo and Principia. Now that we have Zope, is pcgi now intimately bundled with it, never to emerge on its own again? Or is there a way to run pcgi without Zope? Don't get me wrong ... I like Zope. I'm just wondering if there's any way to make use of pcgi without Zope during those occasional times when Zope's full-blown functionality isn't necessary. Thanks in advance for any light that you folks could shed on this issue. -- Lloyd Zusman ljz at asfast.com From arcege at shore.net Thu Jun 10 14:56:15 1999 From: arcege at shore.net (Michael P. Reilly) Date: Thu, 10 Jun 1999 18:56:15 GMT Subject: Date formats References: <375FEA53.95E3D3BC@ausinfo.com> Message-ID: mike milliger wrote: : I read the documentation in the Python Reference Library (6.3) on time : access and conversions and chapter 8 in programming python, yet I can't : figure out if i need ( or how to use) a tuple to format the return from : localtime(). i get a string now (wed jun 10 1999 xx:xx:xx) but i need : to format it to yyyymmdd_hhmmss. Is there any switch ( %) or function : that can be useful? Any help is appreciated. "Here strftime comes to save the day!" (Okay, I won't do my bad impressions of Andy Kaufman anymore.) The time module has a handy function called strftime, which works like format strings, but on the time tuple. my_date = time.strftime("%Y%m%d_%H%M%S", time.localtime(time.time())) print my_date 19990610_145144 Or you can look at the less-standard, more versatile mxDateTime package (http://starship.python.net/~lemburg/mxExtensions.html). -Arcege From druid at princeton.crosswinds.net Fri Jun 4 20:26:15 1999 From: druid at princeton.crosswinds.net (The Well of Latis) Date: Sat, 05 Jun 1999 00:26:15 GMT Subject: newbie trouble with raw_input and idle References: <37581eb4.2704370@netnews.worldnet.att.net> <7j75f5$u49$1@nnrp1.deja.com> Message-ID: <37586cce.3298769@netnews.worldnet.att.net> On Fri, 04 Jun 1999 00:09:15 GMT, Sam Schulenburg wrote: >In article <37581eb4.2704370 at netnews.worldnet.att.net>, > druid at princeton.crosswinds.net wrote: >> If I enter the following code (or any other using raw_input for that >> matter) into idle's shell it works, when trying to run it from a file >> (new window, edit it, save it then run it, nada) >> >> def f(): >> x=raw_input("ladida:") >> print x >> >> f() >> >> systems involved are a win98 and an nt4 machines, tcl version 8.0.5, >> Python 1.5.2. The same code works under the plain Python interactive >> shell, and pythonwin, but not idle. Any ideas? >> >I just tried your sample under windows NT with IDLE 0.4 and it worked OK >Sam Schulenburg > > If typed or directly imported into idle it does work. When doing the following it did not work (specifically the print statement was never executed) Ctrl-N (New Window) type in the code Ctrl-S (Save) F5 (Run module) It does not work. I found a similar post back on deja about a few months back, but could not find a resolution for it posted. Sparrow (Alex) | /|\ brewing on the net http://www.crosswinds.net/~prin_druid | From arcege at shore.net Wed Jun 2 10:47:41 1999 From: arcege at shore.net (Michael P. Reilly) Date: Wed, 02 Jun 1999 14:47:41 GMT Subject: python extension problem (newbie) References: <37548FA5.526A8E48@crystal.uwa.edu.au> Message-ID: Douglas du Boulay wrote: : Hi , : I've been trying to write a python extension in C to interface to a : Fortran program : and a class wrapper for the extension using the following code loosely : adapted from Mark Lutz's Programming Python stackmodule example. : Unfortunately whereas his example works fine, mine goes into a recursive : loop whenever an : instance is instantiated. It seems that the __getattr__ method of the : wrapper class : cannot find the getattr method of the extension library and defaults to : trying to call itself, infinitely : recursively. : Having spent about 8 hours trying to figure out why, I still have no : idea. : Help! : Thanks : Doug :>>file oograsp.py : import p2fgraspint : class Grasp: : def __init__(self, start=None): : self._base = start or p2fgraspint.Grasp() : print "doing done" # which is never executed : def __getattr__(self, name): : print "called getattr" # executed endlessly : return getattr( self._base , name) : def __setattr__(self, name, value): : return setattr(self._base, name, value) ^^^^^^^^^^ This is the problem: inside your __setattr__ method, you are performing a __getattr__ on an attribute that does not exist yet. So your __init__ function is attempting to use a value that isn't set yet. (cf. section "3.3.2 Customizing attribute access" in the Python Reference Manual, http://www.python.org/doc/current/ref/attribute-access.html.) You either want to: a) assign to "self.__dict__['_base']" in the __init__ method, or def __init__(self, start): self.__dict__['_base'] = start or p2fgraspint.Grasp() print "doing done" b) check for the attribute being set in __setattr__ and perform the operation based on that: def __setattr__(self, name, value): if name == '_base': self.__dict__[name] = value else: setattr(self._base, name, value) I suggest (b) it is better for when you change or add localized attribute names later, and is better for subclasses (IMO). (Also, setattr returns None, so you do not need the "return".) -Arcege From andy at robanal.demon.co.uk Mon Jun 21 14:03:59 1999 From: andy at robanal.demon.co.uk (Andy Robinson) Date: Mon, 21 Jun 1999 18:03:59 GMT Subject: Newbie Q: How to call unmodified VB DLL from Python References: <3769bcd1.54492213@news.earthlink.net> Message-ID: <376f7e8c.817023@news.demon.co.uk> lull at acm.org (John Lull) wrote: >As a first Python project, I'd like to use Python (or JPython) to >automate some hardware testing under Win95/98/NT. The hardware in >question is run by a DLL written in VB, and to which I do not have >source. > >"Extending & Embedding the Python interpreter", ch. 3, has >instructions for building a DLL which will work, but assumes you're >working in VC++ and have the source. > >If anyone could point me toward instructions on how to make this work, >I'd be grateful. You need to use Sam Rushing's calldll/windll package at www.nightmare.com. This lets you load and call functions in DLLs dynamically (i.e. without needing a C compiler). It also provides python types to emulate C strings and arbitrary memory buffers, so can call anything. Needless to say, it is also possible to crash stuff if you get the arguments wrong, but once set up it works beautifully. I have been using it in production round the clock for months now... Regards, Andy From matomira at iname.com Thu Jun 10 11:23:00 1999 From: matomira at iname.com (Fernando Mato Mira) Date: Thu, 10 Jun 1999 17:23:00 +0200 Subject: Why is tcl broken? References: <375F82C7.CF0F0477@iname.com> <4.1.19990610150908.00d09790@exchsrv> <7jog8f$ljv$1@Starbase.NeoSoft.COM> Message-ID: <375FD854.2314D886@iname.com> Cameron Laird wrote: > In article <4.1.19990610150908.00d09790 at exchsrv>, > Fernando Mato Mira wrote: > > So I take it you're going to end up arguing > for Eiffel in favor of Scheme? Oh, no. The crossposting logic is that people in any comp.lang.whatever-is-unpopular-and-clean tend to know other things besides their favorite, because they are many times forced to touch other stuff as well. I'm not going to argue during the presentation. I just made sure to pass the message that people should look around before jumping eyes closed in some bandwagon (but obviously, I took care to mention things like Java and STk (Disclaimer: I'm not a Java pundit. And if I needed to to JVM-compatible stuff, I'd try to use Kawa first (duh))) My first objective in this research is to try to be honest. I only have fuzzy memories of the discussions about tcl of years ago, and as I promised myself never to read a book on it.. (and even if I did, just for this, then I would be commiting the popular gaffe of speaking about something in which you have little experience). > I'll ask a better question: is maintainability > to you a philosophically-accessible dimension? Yes. A sound software engineering philosophy requires that you think about maintainability for tools used to build things that will be more than prototypes. Of course, what different groups in `sound' differs, so we are indeed getting into philo-land here. > If you seriously want to debate syntax and > semantics in academic abstraction ... well, at > least we need to know that. Syntax ans semantics in the sense that affect a software engineering practice. > >If so, does speed ever become an issue? I assume that Tk works well > Rarely. Much less often than the uninitiated > suspect. That's the impression I have. But then, what are those `less often' cases? (Besides trying to do silly things, like writing a fast-paced video game in Tk) > >enough that you'd never have to look at the tcl code, and live happily > >inside your reflective Scheme world) > Some TkSchemers do. Some don't. It depends. Examples? From arcege at shore.net Thu Jun 3 08:21:30 1999 From: arcege at shore.net (Michael P. Reilly) Date: Thu, 03 Jun 1999 12:21:30 GMT Subject: Why won't this work??? References: <7j0rkr$1eeu$1@rtpnews.raleigh.ibm.com> Message-ID: Jr. King wrote: : I know you are getting tired of me, but I have tried repeatedly to solve : this on my own and I can't get it to work. : I am trying to do a python callback to call from a c/c++ program. : Here is the c/c++ code : // learnPyth.cpp : Defines the entry point for the console application. : // : #include "stdafx.h" : #include "python.h" : #include "stdio.h" : #include : #include : static PyObject *my_callback = NULL; : static PyObject* Test(PyObject *self, PyObject* args){ : cout<<"Test"< Message-ID: <3760c9d2.1106146@news.cyf-kr.edu.pl> On Thu, 10 Jun 1999 22:23:15 -0400, "Tim Peters" wrote: >[MK] >> In some book on algorithms I've read that after inserting limited >> number of items performance of operating on hash tables >> drops dramatically. >Depends on the details. What you read is true of some kinds of hash tables. >Python's dicts dynamically expand to keep the "load factor" under 2/3, so >what you read isn't applicable to Python in normal use. Great. >> I plan to write a program that would store lots (in range of 10M or even >> more) of relatively small objects (a few hundred bytes at most), so what >> do you think I should use? >Let's do a little math : 10M * 100 = ?, a lower bound on what you're >contemplating. Do you have gigabytes of RAM? I'm opening a boutique. >> I thought about dictionaries, kjBuckets, or maybe even library called >> Metakit for Python (http://www.equi4.com/metakit/info/README-Python.html). >> what-do-you-think-ly y'rs >You don't really want to know . Memory-based data structures aren't >going to work for the size of thing you have in mind. If you can make it >fly it all, you'll likely require a powerful database, so of those choices >Metakit is the only approach that's not dead on arrival. A few additional informations: items stored would be natural language text fragments (several sentences at most, several words typically) + binary descriptions, primary operation would be lots of searching. Is there anything else that would be better for this kind of program? Object database? >better-still-write-it-in-perl-ly y'rs - tim it's-a-stiff-ly yours -------------------------------------------------- Reality is something that does not disappear after you cease believing in it - VALIS, Philip K. Dick -------------------------------------------------- Delete _removethis_ from address to email me From peterh at sapros.com Mon Jun 7 02:57:35 1999 From: peterh at sapros.com (Peter Haight) Date: Sun, 06 Jun 1999 23:57:35 -0700 Subject: extracting contents from a text file Message-ID: <199906070657.XAA00519@wartch.sapros.com> >I would like to extract the text contents residing in another server and >display it as html format using python. Can anyone help me I am new to >python. Well, here's an example. I'm assuming that the 'text contents' you are talking about is on an HTTP (web) server. I'll grab the Python home page as an example at 'http://www.python.org/' but you could easily modify this for other kinds of servers and documents. It writes the html to stdout. You won't need the 'string.replace' lines if your 'text contents' are not formatted as html. -------------------- import string import sys import urllib file = urllib.urlopen('http://www.python.org/') header = \ """ Example
"""

footer = \
"""
""" out = sys.stdout out.write(header) for line in file.readlines(): # # This keeps a browser from parsing an html file. # line = string.replace(line, '<', '<') line = string.replace(line, '>', '>') out.write(line) out.write(footer) From janssen at parc.xerox.com Thu Jun 24 13:21:52 1999 From: janssen at parc.xerox.com (Bill Janssen) Date: Thu, 24 Jun 1999 10:21:52 PDT Subject: make clean bug in 1.5.2 Message-ID: <99Jun24.102155pdt."3693"@watson.parc.xerox.com> Running "make clean" seems to leave a couple of problematic files, SRC/libpython1.5.a, and getbuildinfo.o, which then cause problems when I try to "make" again. Bill From ovidiu at cup.hp.com Wed Jun 30 21:02:41 1999 From: ovidiu at cup.hp.com (Ovidiu Predescu) Date: Thu, 01 Jul 1999 01:02:41 +0000 Subject: coverage tool for Python? Message-ID: <377ABE31.249B1E51@cup.hp.com> Hi, Are there any coverage tools for Python? Thanks, -- Ovidiu Predescu http://www.geocities.com/SiliconValley/Monitor/7464/ From dalke at bioreason.com Mon Jun 14 13:33:29 1999 From: dalke at bioreason.com (Andrew Dalke) Date: Mon, 14 Jun 1999 11:33:29 -0600 Subject: Checking for Python modules in autoconf References: <199906031338.JAA28564@amarok.cnri.reston.va.us> Message-ID: <37653CE9.ADF884E1@bioreason.com> Michael Hudson > James Henstridge has written some extensions to automake/autoconf as > part of his Python GTK+ bindings. I'm going to finish up my work on Python support in automake, which will be included in the current development version of automake. I haven't seen any contributions in the automake tree from James Henstridge. Regardless, I will add a way to test for Python modules using automake. Given the way GNU works, please don't send me any code to be added unless you've sent the copyright disclaimer form to the FSF. Andrew Dalke dalke at bioreason.com From fatjim at home.com Thu Jun 3 13:25:17 1999 From: fatjim at home.com (Jim Meier) Date: Thu, 03 Jun 1999 17:25:17 GMT Subject: Alien whitespace eating nanovirus strikes again! References: <375500C9.742DC539@pop.vet.uu.nl> <375536C2.DD917F99@prescod.net> <7j4e2u$8rh$1@m2.c2.telstra-mm.net.au> <37564132.2D01B7C3@pop.vet.uu.nl> Message-ID: <3756BAFC.2066A636@home.com> Martijn Faassen wrote: > Mark Hammond wrote: > > [Aahz Maruch does not like block indenting a lot] > > > Of course, this is your HO. Many other people (including myself) found that > > a few weeks in, they thought "this is great", and many years later, can't > > believe that other language still hold on to the "old ways". When I take a > > quick look at some of the new little languages referenced on this newsgroup, > > believe it or not, my _first_ reaction is "God those block closers are > > stupid and ugly" :-) > > I never was much afraid of this indentation means block structure thing, > probably not having been spoiled by other languages that are horrid and > practice it, so it was mostly a neat discovery. Now, I am less than a > year in and I already have the same reaction to other languages. "Neat > language..but ick, what are those block closers for?" Just the other day > I was looking at some pseudocode in a book and my eyes kept stumbling > over the block closers. Ditto about not being afraid of the indentation. I've been rabidly happy about using indentation properly ever since I moved up from a commodore vic-20: in the vic's BASIC, you typed a line number and then just typed until you had trouble reading the line - it would just wrap around the 20-character wide screen. Moving up to a DOS machine with MS QBasic, I was very releived to be allowed to indent my programs properly. But QBasic has crazy block open/closures: each type of statement is different! C: if(cond) { foo(); } else { bar(); } while(1) { foo() } Python: if cond: foo() else: bar() while 1: foo() BASIC: if cond then foo else bar -or- if cond then foo() else barr() endif while(1) foo() wend > I must say that Emacs Python mode helps tremendously in this respect, > though. Without it or something similar block indentation wouldn't be as > easy (though I've found I can code in Windows Notepad too if I really > want to :). Oh, ditto. I just *love* (x)emacs now, though I would really like it to take far less memory and be extendable with python. Wow, talking about old H/W makes me sound old - I'm only 19! -Jim From eugene.leitl at lrz.uni-muenchen.de Mon Jun 14 23:24:06 1999 From: eugene.leitl at lrz.uni-muenchen.de (Eugene Leitl) Date: Mon, 14 Jun 1999 20:24:06 -0700 (PDT) Subject: NEWBIE: opaque error message Message-ID: <14181.50740.800169.537860@lrz.de> I've got this piece of code here, kindly donated as a point of departure. from MMTK import * from MMTK.Lattice import BravaisLattice a = 4.516*Units.Ang b = 4.516*Units.Ang c = 7.354*Units.Ang alpha = 90*Units.deg beta = 90*Units.deg gamma = 120*Units.deg ex = Vector(1., 0., 0.) ey = Vector(0., 1., 0.) ez = Vector(0., 0., 1.) # Caution: this works only for beta=90*Units.deg a1 = a*ex a2 = b*Rotation(ez, alpha)(ex) a3 = c*Rotation(ey, gamma)(ex) water = Molecule('water') water.O.setPosition(0.3333*a1 + 0.6667*a2 + 0.0629*a3) water.H1.setPosition(0.3333*a1 + 0.6667*a2 + 0.1989*a3) water.H2.setPosition(0.4551*a1 + 0.9102*a2 + 0.0182*a3) universe = InfiniteUniverse() for point in BravaisLattice((a1, a2, a3), (3, 3, 3)): molecule = copy(water) molecule.translateTo(point) universe.addObject(molecule) which produces the following error message: Traceback (innermost last): File "ice.py", line 27, in ? molecule = copy(water) File "/usr/lib/python1.5/copy.py", line 76, in copy y = copierfunction(x) File "/usr/lib/python1.5/copy.py", line 110, in _copy_inst return x.__copy__() File "/usr/lib/python1.5/site-packages/MMTK/ChemicalObjects.py", line 116, in __copy__ return copy.deepcopy(self, {id(self.parent): None}) File "/usr/lib/python1.5/copy.py", line 151, in deepcopy y = copierfunction(x, memo) File "/usr/lib/python1.5/copy.py", line 236, in _deepcopy_inst state = deepcopy(state, memo) File "/usr/lib/python1.5/copy.py", line 151, in deepcopy y = copierfunction(x, memo) File "/usr/lib/python1.5/copy.py", line 199, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(x[key], memo) File "/usr/lib/python1.5/copy.py", line 151, in deepcopy y = copierfunction(x, memo) File "/usr/lib/python1.5/copy.py", line 172, in _deepcopy_list y.append(deepcopy(a, memo)) File "/usr/lib/python1.5/copy.py", line 151, in deepcopy y = copierfunction(x, memo) File "/usr/lib/python1.5/copy.py", line 236, in _deepcopy_inst state = deepcopy(state, memo) File "/usr/lib/python1.5/copy.py", line 151, in deepcopy y = copierfunction(x, memo) File "/usr/lib/python1.5/copy.py", line 199, in _deepcopy_dict y[deepcopy(key, memo)] = deepcopy(x[key], memo) File "/usr/lib/python1.5/copy.py", line 151, in deepcopy y = copierfunction(x, memo) File "/usr/lib/python1.5/copy.py", line 221, in _deepcopy_inst return x.__deepcopy__(memo) TypeError: too many arguments; expected 1, got 2 Huh? Can somebody comment what it means? From bwarsaw at cnri.reston.va.us Fri Jun 4 19:07:01 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Fri, 4 Jun 1999 19:07:01 -0400 (EDT) Subject: [ANNOUNCE] JPython 1.1 beta 1 released Message-ID: <14168.23573.4173.886534@anthem.cnri.reston.va.us> I'm happy to announce the release of JPython 1.1beta1. JPython is the 100% Pure Java implementation of the Python language, which provides seamless integration with the Java platform. JPython 1.1beta1 is compatible with most Java 1.1 and 1.2 JDKs. JPython 1.1beta1 is much improved over the previous public release of version 1.0.3. Many bugs have been fixed, performance has been improved, and most new CPython 1.5.2 features have been implemented. See below for highlights of the changes between 1.1beta1 and 1.0.3. You can download JPython 1.1beta1 from the JPython home page. Please visit http://www.jpython.org/ Much thanks go to Jim Hugunin -- JPython's inventor, Finn Bock -- for his contribution of modules and test driving, Guido, and the rest of the folks at CNRI. Here's a summary of what's changed since 1.0.3: - New and improved jpythonc tool by Jim Hugunin - New modules contributed by Finn Bock: cStringIO, cPickle, struct, binascii - New module synchronize, equivalent to Java's synchronized keyword - Operator module now complete - sys.add_package() no longer necessary, "import java.lang" just works - Class-based standard exceptions (w/ support for -X option) - super__ methods are deprecated, use regular Python style - time.strftime() added - Java 1.2 style collections support - Multiple interpreter states - Most CPython 1.5.2 features have been implemented - String objects now have methods -- expected CPython 1.6 feature - Improved performance - Java inner class support - keywords are allowed in some locations (e.g. as attribute names) - New license - bug fixes Enjoy, -Barry Barry A. Warsaw Corp. for Nat'l Research Initiatives (CNRI) bwarsaw at cnri.reston.va.us 1895 Preston White Drive, Suite 100 bwarsaw at python.org Reston, VA USA 20191-5434 http://www.python.org/~bwarsaw 703.620.8990 / (fax) 703.620.0913 P.S. contrary to Python tradition, I will /not/ be going on vacation tomorrow :) From amackay at starvision.com Wed Jun 30 20:06:38 1999 From: amackay at starvision.com (Angus MacKay) Date: Wed, 30 Jun 1999 17:06:38 -0700 Subject: ioctl in python References: <377A71D7.470AF9DA@starvision.com> <377A7374.C6919FD3@starvision.com> <377AA64A.B4C63805@bigpond.NO.SPAM.com> Message-ID: <377AB10E.B0B85931@starvision.com> hun? why is this expecting a 4 byte buffer? my C version uses an int* and it works no problem. as for 80 being a input I think you have it backwards (for linux-i386 at least): 0x80046601 EXT2_IOC_GETFLAGS int * 0x40046602 EXT2_IOC_SETFLAGS const int * 0x80047601 EXT2_IOC_GETVERSION int * 0x40047602 EXT2_IOC_SETVERSION const int * cheers, Angus. Perry Faulkner wrote: > > Hi Angus, > > The ioctl cmd code (0x80047601) is expecting a 4 byte buffer to be > passed to it. The > simplest thing is something like : > > rec = pack('BBBB', 0,0,0,0) > or > rec = pack('L', 0) > > depending on what's expected, then > > ioctl(handle, 0x80047601, rec) > > By the way, the 80 part of the command also says this is an input > function, so you > are writing the data, rec in this case! For an output function you would > follow the > ioctl with an unpack of the data buffer, as well. But you still need to > supply the > packed input buffer in any case. > > Hope this helps! > > Regards, > Perry > > Angus MacKay wrote: > > > well it seems I have sort of solved my problem. if I use a > > string for the 3rd arg then it works properly: > > >>> fo=open('/tmp') > > >>> fcntl.ioctl(fo.fileno(), 0x80047601, "hi") > > '\001\000' > > >>> fo=open('/') > > >>> fcntl.ioctl(fo.fileno(), 0x80047601, "hi") > > '\000\000' > > >>> fo=open('/proc') > > >>> fcntl.ioctl(fo.fileno(), 0x80047601, "hi") > > Traceback (innermost last): > > File "", line 1, in ? > > IOError: (25, 'Inappropriate ioctl for device') > > > > the question is why? it will still fail with only 2 args or an int: > > >>> fcntl.ioctl(fo.fileno(), 0x80047601) > > Traceback (innermost last): > > File "", line 1, in ? > > IOError: (14, 'Bad address') > > >>> fcntl.ioctl(fo.fileno(), 0x80047601, 1) > > Traceback (innermost last): > > File "", line 1, in ? > > IOError: (14, 'Bad address') > > > > cheers, Angus. > > > > Angus MacKay wrote: > > > > > > is there some magic to the fcntl.ioctl() call? > > > > > > I can do these ioctl calls in C no problem (with a small wrapper): > > > (amackay at phat)~/tmp$ ./ioctltest /tmp 0x80047601 > > > 0x80047601: 1 > > > (amackay at phat)~/tmp$ ./ioctltest / 0x80047601 > > > 0x80047601: 0 > > > (amackay at phat)~/tmp$ ./ioctltest /proc 0x80047601 > > > /proc: Inappropriate ioctl for device > > > > > > that was the Linux ioctl for EXT2 version. > > > > > > but in python: > > > >>> a = 0 > > > >>> req = 0x80047601 > > > >>> import fcntl > > > >>> fo=open('/tmp') > > > >>> fcntl.ioctl(fo.fileno(), req, a) > > > Traceback (innermost last): > > > File "", line 1, in ? > > > IOError: (14, 'Bad address') > > > >>> From pduffin at mailserver.hursley.ibm.com Tue Jun 29 05:02:49 1999 From: pduffin at mailserver.hursley.ibm.com (Paul Duffin) Date: Tue, 29 Jun 1999 10:02:49 +0100 Subject: Why is tcl broken? References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> <37682DD3.43923243@compaq.com> <7ka2be$qja$1@nntp6.u.washington.edu> <37776FFA.2D85@mailserver.hursley.ibm.com> <876748mcxg.fsf@home.ivm.de> Message-ID: <37788BB9.ABD@mailserver.hursley.ibm.com> Klaus Schilling wrote: > > Marco Antoniotti writes: > > > Paul Duffin writes: > > > > ... > > > > > Correct. With Tcl you can create new control structures which > > > are indistinguishable from the built in ones, you cannot do > > > that in Python. Python is much more rigid in its syntax although > > > it does have a lot of nice hooks to allow objects to behave > > > in different ways. > > > > But you can do that much more easily and elegantly in the L-word > > language :) > > It can be done best in the Scheme, by means of the almighty > call-with-current-continuation, the best of all control structures, > and define-syntax on top of it. > Both Tcl and Scheme can do it, "best" is subjective. -- Paul Duffin DT/6000 Development Email: pduffin at hursley.ibm.com IBM UK Laboratories Ltd., Hursley Park nr. Winchester Internal: 7-246880 International: +44 1962-816880 From ivanlan at callware.com Thu Jun 3 13:47:34 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Thu, 3 Jun 1999 17:47:34 GMT Subject: Python 2.0 References: <1283872945-30734792@hypernet.com> Message-ID: <3756BFB6.90A1B9D1@callware.com> Hi All-- Gordon McMillan wrote: > > Michael Hudson writes: > > [re Py_TRACE_REFS] > > I've never resorted to this approach, tending always to make cyclic > > references go away be staring at them very, very hard. > > Ay. This is my approach. WIth the added advantage that now I find I > can hypnotize a brick, simply by starting at it. > > that-one's-already-asleep-ly y'rs > > - Gordon Yes, but the question we really want to know the answer to is ``Who is the brick? The starer or the staree?'' -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From alex at mindlube.com Tue Jun 22 01:35:21 1999 From: alex at mindlube.com (Alex Rice) Date: 21 Jun 1999 23:35:21 -0600 Subject: newbie idiom question Message-ID: Something I keep getting tripped up about is that objects being iterated in "for" statements cannot be modified. I keep trying to do this: >>> eggs = [1,2,3] >>> for spam in eggs: ... spam = 'cooked' ... >>> eggs [1, 2, 3] >>> The tutorial says this: If you need to modify the list you are iterating over, e.g., duplicate selected items, you must iterate over a copy. The slice notation makes this particularly convenient: >>> for x in a[:]: # make a slice copy of the entire list ... if len(x) > 6: a.insert(0, x) ... >>> a ['defenestrate', 'cat', 'window', 'defenestrate'] Understood, but what if you want to modify each element in a list? What's the best way to do this in terms of speed and elegance? I guess I just haven't seen a good example of this yet in Python What I'm unfortunately used to is this, in Perl: @eggs = (1,2,3); foreach $spam (@eggs) { $spam = 'cooked'; } print "@eggs"; >>> cooked cooked cooked Thanks, Alex Rice From thornley at visi.com Wed Jun 16 17:27:52 1999 From: thornley at visi.com (David Thornley) Date: Wed, 16 Jun 1999 21:27:52 GMT Subject: Why is tcl broken? References: <1283099377-77267484@hypernet.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> Message-ID: In article , Chris Ebenezer wrote: > >Fernando Mato Mira writes: >: of folks end up using one or another GNU tool. As a side effect, some >: newcomers to Tk that would have normally used tcl could end up going >: the STk way (unfortunately, STk is not publicized enough). Things like >: Kawa also increase the feel of security regarding code reusability. >: And some of those people will end up wanting to write full-fledged > >Why use TK at all ? Once you are using scheme anyway there are nicer >widget toolkits to use (from a point of view of more "normal" looking >toolkits that don't suffer from color allocation problems), there are >bindings for guile and gtk and guile and Qt. > The attraction, to me, would be that Tk is a free, open-source graphics environment that will run on Unix with X-Windows, the Macintosh, and Microsoft Windows. CLIM is commercial, Garnet last I looked didn't run on Microsoft Windows, and it looks to me like I should be able to get Macintosh Common Lisp communicating with Tk through Tcl without *that* much work. I know little of this Qt animal. Is it free? Is it open source? Does it run on the Macintosh? Is it easy to set up an interface with? -- David H. Thornley | If you want my opinion, ask. david at thornley.net | If you don't, flee. http://www.thornley.net/~thornley/david/ | O- From jam at newimage.com Sun Jun 13 20:14:29 1999 From: jam at newimage.com (jam) Date: Sun, 13 Jun 1999 20:14:29 -0400 Subject: Python as script language? In-Reply-To: <37644DC7.DE422A3B@hotmail.com>; from Denis Lamarche on Sun, Jun 13, 1999 at 09:38:30PM +0000 References: <37644DC7.DE422A3B@hotmail.com> Message-ID: <19990613201428.K723@toast.internal> On Sun, Jun 13, 1999 at 09:38:30PM +0000, Denis Lamarche wrote: > > How can I set up Python so that I can call the scripts from within an > application (that I wrote) so that it will run and interface with the > application (that I wrote)? Is this possible? > > Denis Lamarche > yes, it is possible, and it's relatively simple. check the python.org website (specifically, read through the extending and embedding manual) to get a feel for what is required. if you are familiar with C and object oriented programming concepts, you should have no trouble.. and if you do, feel free to post questons to the mailing list. regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From S.I.Reynolds at cs.bham.ac.uk Tue Jun 1 17:42:38 1999 From: S.I.Reynolds at cs.bham.ac.uk (Stuart I Reynolds) Date: Tue, 01 Jun 1999 22:42:38 +0100 Subject: Cannot store Sequences in Numeric arrays of Objects Message-ID: <375453CE.3192@cs.bham.ac.uk> Hi, I don't seem to be able to store a whole range of different type in Numeric's PyObject arrays: >>> from Numeric import * >>> a = array( [None,]*9 , PyObject) >>> b = array( [None,]*9 , PyObject) >>> a.shape = 3,3 >>> a array([[None , None , None ], [None , None , None ], [None , None , None ]],'O') >>> #Storing ints works fine >>> a[0,0] = 123 >>> a array([[123 , None , None ], [None , None , None ], [None , None , None ]],'O') >>>#Cannot store an array >>> a[0,0] = b Traceback (innermost last): File "", line 1, in ? ValueError: array too large for destination In fact, trying to store any sequence causes the error: a[0,0] = [] a[0,0] = (None, None) a[0,0] = UserList() ... whereas storing these works fine: a[0,0] = Pickler(file) a[0,0] = 'hello' #Also a sequence? What's going on? Cheers, Stuart From too at pk.highway.ne.jp Tue Jun 22 08:55:39 1999 From: too at pk.highway.ne.jp (Thooney Millennier) Date: Tue, 22 Jun 1999 21:55:39 +0900 Subject: signal handler Message-ID: <376F87CB.DC3802E6@pk.highway.ne.jp> Hi, I want to use "signal()" in my program. import signal; def func(arg1,arg2): DO_SOMETHING_GOOD; print "OK!"; signal.signal(SOME_SIGNAL,func); It seems "func()" is not called when the program gets signal "SOME_SIGNAL". Why? Any help welcome. (I have installed Python 1.5.2 on Linux 2.0.34 and running.) Thanks for reading. From mvanier at bbb.caltech.edu Thu Jun 3 17:51:58 1999 From: mvanier at bbb.caltech.edu (Michael Vanier) Date: 03 Jun 1999 14:51:58 -0700 Subject: Alien whitespace eating nanovirus strikes again! References: <375500C9.742DC539@pop.vet.uu.nl> <3756E3D9.E44D2B39@swcp.com> <3756E476.ACB50DF1@swcp.com> Message-ID: Alex Rice writes: > Therefore python is more post-modern than perl. > > :-) Post-post-modern? Ultra-post-modern? Magna-cum-post-modern? Attack-of-the-killer-buzzwords-ly y'rs, Mike ------------------------------------------------------------------------- Mike Vanier mvanier at bbb.caltech.edu Department of Computation and Neural Systems, Caltech 216-76 Will optimize nonlinear functions with complex parameter spaces for food. From arcege at shore.net Wed Jun 30 14:49:18 1999 From: arcege at shore.net (Michael P. Reilly) Date: Wed, 30 Jun 1999 18:49:18 GMT Subject: socket timeouts References: Message-ID: Nathan Clegg wrote: : Is there any way to set the timeout for a TCP/IP connection? : Specifically, I'm writing some apps meant to run on the same machine, so : if they can't connect *immediately* (i.e. the server app is not running), I : need to go to plan B. Any answers or alternate solutions? I'm also : interested in a similar issue across the internet, but I'm more generous : about timeouts in this circumstance. Thanks. Since you are using a TCP/IP connection (ie. a socket), using select() should be cross-platform enough. import select class TimeoutError(Exception): pass def wait_for_socket(sock, timeo): timeo = float(timeo) rdrs, wtrs, excs = select.select([sock], [], [], timeo) if not rdrs: raise TimeoutError, "no responce" If the exception is raised, then the connection did not complete. -Arcege From mark at _spamspamlovelyspam_btweng.krakow.pl Sat Jun 19 05:37:57 1999 From: mark at _spamspamlovelyspam_btweng.krakow.pl (MK) Date: Sat, 19 Jun 1999 09:37:57 GMT Subject: Crawling Python References: <000601beb91d$e1321ae0$839e2299@tim> <376a1ac1.10261180@news.tpnet.pl> <7ke6va$qa9$1@nnrp1.deja.com> Message-ID: <376b5b32.6312672@news.tpnet.pl> On Fri, 18 Jun 1999 19:34:03 GMT, Sam Schulenburg wrote: >> >>> len(s) >> 1178515 >I just tried both environments on a WindowsNT system and obtained >130000 for len(s) under IDLE and Console mode python. Win98. I tried the same several more times in DOS box and got different results every time: >>> for i in range(10000): ... s=s+`range(i,i+20)` ... >>> >>> >>> len(s) 1645360 >>> >>> >>> s='' >>> >>> for i in range(10000): ... s=s+`range(i,i+20)` ... >>> len(s) 1178515 >>> >>> for i in range(10000): ... s=s+`range(i,i+20)` ... >>> len(s) 2357030 >>> Now _that_ is weird. MK -------------------------------------------------- Reality is something that does not disappear after you cease believing in it - VALIS, Philip K. Dick -------------------------------------------------- Delete _spamspamlovelyspam_ from address to email me postmaster at 127.0.0.1 root at 127.0.0.1 webmaster at 127.0.0.1 From kiftdn at ffff.com Sat Jun 12 02:51:56 1999 From: kiftdn at ffff.com (kiftdn at ffff.com) Date: 12 Jun 1999 06:51:56 GMT Subject: Free Sex Links 7457 Message-ID: <7jt02c$2pe$4640@nclient1-gui.server.virgin.net> For the nastiest sex pictures visit: http://freespace.virgin.net/efrwer.werewrd/ From Klaus.Schilling at home.ivm.de Fri Jun 18 02:52:15 1999 From: Klaus.Schilling at home.ivm.de (Klaus Schilling) Date: 18 Jun 1999 08:52:15 +0200 Subject: Problem with Curses References: Message-ID: <87aety0zmo.fsf@home.ivm.de> kjwolf at online.de (Klaus-Juergen Wolf) writes: > Klaus-Juergen Wolf wrote: > > (Python 1.5.2 on FreeBSD 3.2-RELEASE (i386)) > > > I found that (after having compiled Python with cursesmodule.c - Andrich's curses support is more complete, particularly suited for x/openpg compliant curses. It turns to be very useful to replace it. > > testall.py succeeds) the following program gives a segmentation > > fault: > > As it appears, > > -*- > import curses > > curses.initscr() > curses.endwin() > -*- > > alone does exactly the same. I've tested it in debugging environment, > where it doesn't happen, and I've checked the cursesmodule code, and I > still have no idea why this happens. (Inconsistency? But where?) > > Stack trace says that it happens when the first actual write call to > libtermcap takes place. So curses on that platform still needs to be linked to libtermcap? > > The problem occurs under Solaris in the same way, while Linux doesn't > seem to know anything of it. Using libtermcap on those systems? Linux usually uses terminfo which is already burried in the ncurses stuff. Solaris might use sun curses. Btw why is there no direct termcap support for python? Perl has Term::Cap , which doesn't even require the termcap library, just the termcap data file (e.g. /etc/termcap). Would it be very hard to provide? Klaus Schilling From thomas.heller at ion-tof.com Wed Jun 23 10:45:04 1999 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Wed, 23 Jun 1999 16:45:04 +0200 Subject: How to obtain an instance's name at runtime? References: <7kqpu8$7u1$1@nnrp1.deja.com> Message-ID: <003f01bebd86$fb5631f0$4500a8c0@thomasnotebook> > I would like to do the following: > > >>> class C: > ... pass > ... > >>> > >>> c = C() > >>> C.__class__.__name__ # ok > 'C' > >>> c.__name__ # not ok > Traceback (innermost last): > File "", line 0, in ? > AttributeError: __name__ > >>> Huh? Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> class C: ... pass ... >>> c = C() >>> c.__class__.__name__ 'C' >>> C.__name__ 'C' >>> c.__name__ Traceback (innermost last): File "", line 1, in ? AttributeError: __name__ >>> C.__name__ 'C' >>> Use c.__class__.__name__! Thomas Heller ION-TOF GmbH From billtut at microsoft.com Fri Jun 18 11:03:22 1999 From: billtut at microsoft.com (Bill Tutt) Date: Fri, 18 Jun 1999 15:03:22 GMT Subject: do anonymous pipes normally work on NT? Message-ID: <4D0A23B3F74DD111ACCD00805F31D8100DB90DEF@RED-MSG-50> > From: Georg Mischler [mailto:schorsch at schorsch.com] > Do I need to swig this stuff myself? or... Nope, they already come pre-swigged. Download, load into VC++, tweak away so that it can find all of the necessary .h/.libs it needs and build away. Bill From kjwolf at online.de Sun Jun 20 20:54:23 1999 From: kjwolf at online.de (Klaus-Juergen Wolf) Date: Mon, 21 Jun 1999 02:54:23 +0200 Subject: Problem with Curses References: <87aety0zmo.fsf@home.ivm.de> Message-ID: Klaus Schilling wrote: >> Klaus-Juergen Wolf wrote: >> > (Python 1.5.2 on FreeBSD 3.2-RELEASE (i386)) >> >> > I found that (after having compiled Python with cursesmodule.c - > Andrich's curses support is more complete, particularly suited for > x/openpg compliant curses. It turns to be very useful to replace it. There are more Curses' and NCurses' in the world than I have fingers and toes. You can easily write a Curses module that makes _you_ happy. And the rest of the world... Why, do you think, do Oliver Andrich's approaches have a 'b' in the version number? It's simple: they won't work everywhere, here, for instance. cu k.j. -- Support Julia Hill - save the Redwood trees: http://www.lunatree.org/ From hniksic at srce.hr Mon Jun 7 17:11:50 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 07 Jun 1999 23:11:50 +0200 Subject: waste of resources ? References: <375C0F91.1C73E4E3@icrf.icnet.uk> <375C16A9.5ADC4990@icrf.icnet.uk> <375C2003.B01BEC3@arlut.utexas.edu> <87yahvzqz3.fsf@pc-hrvoje.srce.hr> Message-ID: <87pv37zpex.fsf@pc-hrvoje.srce.hr> Ben Gertzfield writes: > If I recall correctly, Perl has just about the exact same problem. > Is there a good way to fix it? I don't know about Perl, but a good fix would be to have the interpreter do the hard work for us. If a system call fails and errno is EINTR, then the signal handler should be called, *and* the syscall should be restarted. From dkuhlman at netcom.com Fri Jun 4 18:59:06 1999 From: dkuhlman at netcom.com (G. David Kuhlman) Date: Fri, 4 Jun 1999 22:59:06 GMT Subject: Alien whitespace eating nanovirus strikes again! References: <375500C9.742DC539@pop.vet.uu.nl> <375536C2.DD917F99@prescod.net> <7j4e2u$8rh$1@m2.c2.telstra-mm.net.au> <37564132.2D01B7C3@pop.vet.uu.nl> <3756BAFC.2066A636@home.com> <3756F071.E717D0FA@pop.vet.uu.nl> <37573C16.D0233810@home.com> Message-ID: Look at: http://www.python.org/doc/essays/everybody.html - Dave Alex (alex at somewhere.round.here) wrote: > > I'm rambling about Python these days. Yesterday I read a paper from > > Guido about how he was thinking about bringing Python (or some > > successor language) to *billions* of users. :) > Could someone point me at this paper? > Alex. From wlfraed at ix.netcom.com Wed Jun 9 22:43:13 1999 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Thu, 10 Jun 1999 02:43:13 GMT Subject: "Programming Python" still worthwhile? References: <1283218560-70098357@hypernet.com> <375E9943.F9FEA7BA@gssec.bt.co.uk> Message-ID: <375f23fe.1133449@nntp.ix.netcom.com> On Wed, 09 Jun 1999 17:41:39 +0100, Alan Gauld declaimed the following in comp.lang.python: > At work we have Python 1.3 (don't ask!) and at home I use Some system admin bought the book, and installed Python from the CD, then forgot about it? -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From hank at prosysplus.com Mon Jun 28 23:34:14 1999 From: hank at prosysplus.com (Hank Fay) Date: Mon, 28 Jun 1999 23:34:14 -0400 Subject: ActiveX, IDE References: <7cKd3.3449$lr3.133866@news2.jacksonville.net> <7l96c1$5hn$1@m2.c2.telstra-mm.net.au> Message-ID: Mark, actually, I want a command window just like pythonwin 1.52 or whatever, which I already have installed; but also want to be able to visually design forms, including drag-n-drop, visually size, etc., activex controls, also as I currently do. FWIW: I think the VB IDE is a straightjacket. thanks, Hank -- http://www.prosysplus.com Mark Hammond wrote in message news:7l96c1$5hn$1 at m2.c2.telstra-mm.net.au... > Hank Fay wrote in message <7cKd3.3449$lr3.133866 at news2.jacksonville.net>... > >I'd like to make Wintel apps using ActiveX controls under Python: is there > >an IDE for Python that will support this? > > Pythonwin supports hosting ActiveX controls, but if you are expecting an > ActiveX IDE similar to VB, you will be dissapointed. > > http://starship.python.net/crew/mhammond > > Mark. > > > From anders777 at my-deja.com Wed Jun 30 12:30:04 1999 From: anders777 at my-deja.com (anders777 at my-deja.com) Date: Wed, 30 Jun 1999 17:30:04 +0100 Subject: Reflection in Python? Message-ID: <000015c0@bossar.com.pl> From: anders777 at my-deja.com I've just started programming in Python, and I could really use some help figuring out something. I'd like to implement Kent Beck's unit tester in Python (someone posted a very nice alternative a few weeks ago, but Junit's approach works better for my project's needs). How do I do the equivalent of what Java calls reflection? I want to do the following: test = MathTest("testAdd") where test.run() will run the "testAdd" method on the MathTest object? I also want to be able to tell the user the name of the object (MathTest) and the method in case the method fails. Any thoughts? Thanks, Anders Schneiderman National Journal Daily Briefings Group Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From zorro at zipzap.ch Thu Jun 24 13:01:12 1999 From: zorro at zipzap.ch (Boris Borcic) Date: Thu, 24 Jun 1999 19:01:12 +0200 Subject: Thanks for Python... References: <376ead64@anonymous.newsfeeds.com> <37716901.43CB604@lockstar.com> <7ktfn0$5q$1@aurwww.aur.alcatel.com> <14194.18324.582362.94739@amarok.cnri.reston.va.us> Message-ID: <37726458.C8CC9623@zipzap.ch> Andrew M. Kuchling wrote: > Once you accept that the world is a giant computer run by white mice, all > other movies fade into insignificance. > -- Mutsumi Takahashi, on _The Hitch-hiker's Guide to the Galaxy_ Should this be taken as a rebuttal of "Matrix" ? BB From larsga at ifi.uio.no Fri Jun 18 12:56:31 1999 From: larsga at ifi.uio.no (Lars Marius Garshol) Date: 18 Jun 1999 18:56:31 +0200 Subject: Why don't my global variables work? References: Message-ID: * Nathan J. Froyd | | It's a program for turning a netscape bookmarks file into something | resembling XML. Hmmm. Maybe you'd like to have a look at this: :-) --Lars M. From hniksic at srce.hr Fri Jun 4 16:24:04 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 04 Jun 1999 22:24:04 +0200 Subject: threads References: <1283593620-47537497@hypernet.com> Message-ID: <87emjr67ff.fsf@pc-hrvoje.srce.hr> "Gordon McMillan" writes: > Hrvoje Niksic writes: > > > "Barry A. Warsaw" writes: > > > > > You might be interesting in digging around for Greg Stein's > > > free-threading patches. Greg did a lot of work, I think in the > > > Python 1.4 days, to remove the central interpreter lock and make all > > > the data structures and such thread safe. > > > > Why would I want to do that? > > See that other thread. Huh? What other thread? Maybe the question wasn't clear enough. What I mean is: at this time, my need for simultaneous thread execution in Python is not so urgent that to warrant forking off (no pun intended). Once I do need it, I'd prefer to be able to choose Python than to dismiss Python on the grounds of not properly supporting threading. > > If Greg's patches haven't been applied to the base, surely mine > > would not be either. > > As I recall, Greg's patches didn't make it because (1) they were late > and (2) they were slow. Interesting. What was the source of slowness? (If you _remove_ locks, I'd expect things to go faster, even in a single-threaded world.) Maybe the patches simply introduced a different set of problems? From janssen at parc.xerox.com Wed Jun 2 10:04:59 1999 From: janssen at parc.xerox.com (Bill Janssen) Date: Wed, 2 Jun 1999 14:04:59 GMT Subject: Inter-process communication In-Reply-To: <928118414snz@vision25.demon.co.uk> References: <928118414snz@vision25.demon.co.uk> Message-ID: A typical way to do it is to give one or both of the programs ILU interfaces, and use ILU to do the IPC. Information on ILU is available at ftp://ftp.parc.xerox.com/pub/ilu/ilu.html; a Python tutorial for ILU is at ftp://ftp.parc.xerox.com/pub/ilu/misc/tutpython.html. Bill From rdr_nl at my-deja.com Tue Jun 15 06:23:03 1999 From: rdr_nl at my-deja.com (Henk Jansen) Date: Tue, 15 Jun 1999 10:23:03 GMT Subject: extension called from embedded code Message-ID: <7k59i2$ijd$1@nnrp1.deja.com> Trying to get the most out off the C++/Python team I run into problems when I try to load extension modules (written in C, like kjbuckets or ranlib) from Python code that is embedded in a C++ application. The API I use is 'PyRun_SimpleString("import kjbuckets\n");' and causes unresolved symbol error messages from the Python interpreter (e.g. PyType_Type for kjbucketsmodule.so and PyExc_RuntimeError for ranlib.so). Loading these modules when Python is in control goes fine. Has anyone any idea how to do this? Thanks, Henk -- ===================================================================== Henk Jansen -- Delft University of Technology -- Dept. of Mathematics hjansen at math.tudelft.nl http://ta.twi.tudelft.nl/users/hjansen/H.Jansen.html Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From behrends at cse.msu.edu Wed Jun 23 01:22:49 1999 From: behrends at cse.msu.edu (Reimer Behrends) Date: 23 Jun 1999 05:22:49 GMT Subject: total idiot question: +=, .=, etc... References: <877lov62z1.fsf@pbl.ddns.org> Message-ID: Preston Landers (planders at mail.utexas.edu) wrote: > Can someone *please* give me a good reason why Python doesn't yet have > +=, -=, and .= and other such operators? I know it's just syntactic > sugar, but damn, it is such sweet sugar! Few people, I think, have ever tried to objectively count how often such a construct is used. The Python 1.5.2 source, for instance, has approximately one of ++, --, +=, -=, *=, /= every 40 lines. If you do not count the occurrences if ++ and -- in for loops, for which there's a construct in Python anyway, you can roughly double that number. Now, C is not Python, but it's a good first-order approximation of how often you need it--the Python source is one of the cleanest C programs I know of. Personally, I can easily live without a construct that I can use on average once every three screens of code or so. On the other hand, I _am_ getting pretty sick of having to type self.whatever countless times, where pretty much any other language allows me to discard the "self." part. Not only is it annoying to type, it also reduces the readability of OO code a lot, much like the gratuitious use of punctuation characters as variable prefixes in Perl does. Among all the suggestions for Python 2.0, removing the necessity of prefixing methods and instance variables with "self." (and not having to list it as an argument, either) would be my #1 wish. [...] Reimer Behrends From fredrik at pythonware.com Tue Jun 22 09:39:27 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 22 Jun 1999 13:39:27 GMT Subject: htmllib: CR in CDATA References: <00d201bebc5a$adb129a0$0301a8c0@mnot.net> <012601bebc91$f3ded760$0301a8c0@mnot.net> <014401bebc9a$1963a9e0$0301a8c0@mnot.net> <000b01bebca0$8a022c20$f29b12c2@pythonware.com> <017501bebcad$830a3180$0301a8c0@mnot.net> Message-ID: <003701bebcb4$a6d33fb0$f29b12c2@pythonware.com> > Now, htmllib certainly: > * is a component > * part of a distributed system (i.e., the Web) > * presents an interface (programmatic) > * processes requests on behalf of a user > I'm curious... if it's not a user agent in the quoted context, what is it? I'm pretty sure you know what I meant, but alright... htmllib is a parser, just like the documentation says. you have to add an application to get an HTML user agent (see section 1.2.3 of the 2.0 spec for more info on user agents). imho, it's pretty reasonable for an SGML parser to behave like an XML parser: split the document up into pieces, but pass them all to the application as untouched as possible. if you wish to implement additional behaviour, do that on the application level. otherwise, you'll end up in a situation where some users cannot use the standard library... (like I did only a few hours ago, trying to use sgmllib to parse SGML data with case-sensitive tags. sigh...) From greg.ewing at compaq.com Thu Jun 17 19:00:13 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Fri, 18 Jun 1999 11:00:13 +1200 Subject: Newbie: Truth values (three-valued logic) References: <000f01beb7b8$2722a540$2ca22299@tim> Message-ID: <37697DFD.91C2B8F6@compaq.com> Olaf Delgado wrote: > > Next time I'll want to redefine 'and' and 'or'. You could use '*' and '+', if you always know when you're dealing with a 3-valued boolean (troolean? trillian?). By the way, I think Python 2.0 should let you define new infix operators -- and design new characters to represent them! We all have bitmapped screens now -- there's no reason why we should be restricted to a fixed character set any more... Greg From xcvx at sdofi.com Mon Jun 21 19:06:58 1999 From: xcvx at sdofi.com (ATS Public Labs) Date: Mon, 21 Jun 1999 19:06:58 -0400 Subject: More Problems With Curses Message-ID: <376EC592.A97D117D@sdofi.com> Hello, I'm trying to write an IRC client in Python using the curses and threading modules. Basically one thread will read user input while the other threads print the messages received from the servers the user is connected to. This works fine if I use print() and input() instead of curses, but it's annoying because the other threads will print stuff to the screen in the middle of what you are typing. However, when I try to use curses instead, only the user-input thread seems to have control of the screen; the other threads will hang and not print anything until you press return. I wrote the following to try to figure out what's going on: import time import threading import curses def repd(): x=0 while 1: time.sleep(1) print 'x=%d' % x x=x+1 thr=threading.Thread(target=repd) thr.start() while 1: time.sleep(1) str=raw_input() print 'got %s' % str This prints out 'x=0', 'x=1' etc. at one second intervals, and in addition prints whatever you type as soon as you press return. However, if I add the following two lines: stdscr=curses.initscr() curses.endwin() right before I start the thread, then what happens is that 'x=0' gets printed, and then nothing will get printed again until you type something and press return, at which point all the 'x=n' messages which you should have seen get printed all at once. So, just the act of initializing curses causes this annoying blocking behavior which I don't want. So, what am I doing wrong? How can I get curses and threading to play nice with each other? now-I-know-why-it's-called-"curses"-ly yrs, Cliff From pduffin at mailserver.hursley.ibm.com Thu Jun 10 11:41:27 1999 From: pduffin at mailserver.hursley.ibm.com (Paul Duffin) Date: Thu, 10 Jun 1999 16:41:27 +0100 Subject: Why is tcl broken? References: <1283099377-77267484@hypernet.com> Message-ID: <375FDCA7.62FF@mailserver.hursley.ibm.com> John Mitchell wrote: > > On Thu, 10 Jun 1999, Gordon McMillan wrote: > > > Fernando Mato Mira writes: > > > I'm trying to collect a list of all the _current_ issues making tcl > > > a bad language choice. > > > > Why? Convincing your boss to use Python over TCL for your next > > project is one thing, but in general this is a zero-sum (or worse) > > game. > > > > The TCLers I know value its simplicity and accept its limitations. > > Telling them they're wrong will only piss them off. > > > > - Gordon > > For what it's worth, I've tried convincing a friend at AOL to start using > Python. They mostly use TCL with AOLServer[1] (webserver with TCL built > in at a very low level, quite fast); with a bit of Perl. > I was going to say "Sensible folk" until I read the Perl bit ;-). > He's not a trained programmer, and really likes TCL. Since they've more > or less standardized on *one* language across many developers, they have a > large library of code to steal from, which makes nearly all new projects > trivial to whip up. Switching to a "real" (OO, scripting) language really > wouldnt help them out. > "real", "REAL" !!!! > Ironically, TCL *does* have some object-oriented features. When I tried > it out many years ago, there was a [itcl] extension to basically add > C++-style object suppport. But, all the TCL types I've talked to since > have never heard of it. Odd. > Tcl has many OO features, you can have C++ like, Java like, SmallTalk like ... it is up to you. A lot of them are implemented in pure Tcl. > Has anyone messed with Guile, GNU's extension language? One specific > thing they want to do is be a "universal" back end, that is you can write > translators from language A to Guile, and their page[2] mentions Python > several times... > Nice idea but I doubt they will even manage one language completely, never mind 2, or 3, or 4 ... > > [1] http://www.aolserver.com/ > > [2] http://www.gnu.org/software/guile/guile.html > -- Paul Duffin DT/6000 Development Email: pduffin at hursley.ibm.com IBM UK Laboratories Ltd., Hursley Park nr. Winchester Internal: 7-246880 International: +44 1962-816880 From cfelling at iae.nl Thu Jun 24 15:41:25 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 24 Jun 1999 21:41:25 +0200 Subject: tkMessageBox returns 'can't invoke "frame" command:' error References: <7kktvv$550$1@nnrp1.deja.com> Message-ID: <7ku1l5$13q$1@vvs.superst.iae.nl> Hai Raymond, though I'm new to python and Tkinter myself, I think I know what the problem is. I tried it out at my site and it seems to work. And if there is any truth in what I am going to tell (please you higher gods, correct me if i'm wrong) I have finally fathomed the difference between quit and destroy whilst figuring out your bug:). The point is that you repeatedly try to initialise Tkinter without properly finishing up prior uses. You correctly call widget.quit(), but this doesn't destroy the widget, it merely exits the widget.mainloop(). This can easily be seen: after finishing the first import of your code in the interactive interpretor by pressing the 'quit' button, you will notice that the window doesn't disappear. Though this window is kind of dead in not reacting to clicking it is still there. And so is your invocation of Tkinter. If at this point you reload your script you might notice that the default window label now reads "Tk #2" to remind you of the fact that you now have a second invocation of Tkinter running at the same time. The way out is simple, you have to explicitly destroy your widgets. a simple "rootWindow.destroy()" after the call to mainloop will do. As for your error message complaining about the frame command not working because the application has been destroyed, that's a little trickier. Just where should I start... First, Tkinter keeps track of the current Tk invocation using the var Tkinter._default_root, initially this equals None, and upon invocing Tk() it gets initialised. Unfortunately Tkinter doesn't reset this var to None upon termination of Tk through an appropriate destroy()! (maybe this should be considered a bug? who should know about it?) Second, many (all?) widget commands have None as default for the master keyword-arg. And if you don't specify an explicit master for the widget the before mentioned Tkinter._default_root will be used. But elas, the second time around (reloading your script) this still refers to the now obsolete Tk instantiation. Hence the Tcl error: that Tk doesn't exist anymore. There are two ways to remedy this: 1) add something like "master=rootWindow" to constructor calls of MessageBox widgets. 2) do what Tkinter should have done, i.e. "Tkinter._default_root==None" but only do this after you have destroyed the root window with something like "rootWindow.destroy()", the latter is done automatically upon pressing the root-window-close-button, but has to be programmed otherwise. Hope this helps, and sure hope it's correct:} -- groetjes, carel From nikolai.kirsebom at siemens.no Tue Jun 15 09:36:49 1999 From: nikolai.kirsebom at siemens.no (Nikolai Kirsebom) Date: Tue, 15 Jun 1999 13:36:49 GMT Subject: TAPI and Pythonwin Message-ID: <376656be.101659969@news.mch.sni.de> Does anyone know if there is a module for the TAPI (telephone API) on NT ? Nikolai From tim_one at email.msn.com Tue Jun 29 04:12:07 1999 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 29 Jun 1999 04:12:07 -0400 Subject: ANN: Stackless Python 0.2 In-Reply-To: <7l8fut$es6@dfw-ixnews6.ix.netcom.com> Message-ID: <000801bec207$142b6360$719e2299@tim> [G. David Kuhlman] > I'll bite. How *does* a thread that calls out to C release the global > lock? This is covered in detail in the Python/C API manual (look in your Python doc distribution), chapter 8. You typically just use a pair of Python-supplied bracket macros: ... here you own the global lock Py_BEGIN_ALLOW_THREADS ... now you do not: other Python threads can run, and you can do ... C stuff here as long as you like, in parallel with them Py_END_ALLOW_THREADS ... now you own the global lock again, and can return to Python Many examples of these macros can be found in the distribution's C source code too. > Would it have to do this thingy that is at the beginning of the > interpreter loop in python/ceval.c? > > if (PyThreadState_Swap(NULL) != tstate) > Py_FatalError("ceval: tstate mix-up"); > PyThread_release_lock(interpreter_lock); > > Would this work? or would it screw up the interpreter? It won't even compile. interpreter_lock is not an extern symbol: you can't get at it directly. That's a feature, of course, to discourage chuckleheads from trying to subvert the published API . > Is there a way to do this in a Python script *before* it calls out > to C. No: Python-level code must never run unless the thread running it holds the global lock. Therefore no Python-level code can ever release the global lock (the instant it did so, it would be illegal code -- so no possibility for screwing up this way is provided). This is no real restriction, though. To run external C code at all you have to put it in a module known to Python (so that Python can resolve the name *from* Python), and in the typical case where you're calling some pre-existing thread-safe C function ThreadedSpam, you're not going to stick ThreadedSpam in a Python module anyway. Instead you'd write your Python C module with a trivial wrapper function and tell Python about *that*; its guts will consist of Py_BEGIN_ALLOW_THREADS ThreadedSpam(); Py_END_ALLOW_THREADS it's-only-confusing-if-you-think-about-it-too-much-ly y'rs - tim From gmcm at hypernet.com Wed Jun 16 12:25:57 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 16 Jun 1999 11:25:57 -0500 Subject: GNU python? In-Reply-To: <022c01beb7ec$f9617070$f29b12c2@pythonware.com> Message-ID: <1282571880-108998174@hypernet.com> /F wrote: > Skip Montanaro wrote: > > > Looking to try out python... is there a GNU python for Win9x? and a > > > tutorial maybe? > > > > Not sure just how a GNU Python would differ from the real thing. > > a bit more like GNUscript, I suppose: > > http://art.net/Studios/Hackers/Hopkins/Don/text/gnuscript.html There goes pythonware. Eaten by the TGPLV. - Gordon From hniksic at srce.hr Thu Jun 3 12:09:47 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 03 Jun 1999 18:09:47 +0200 Subject: Use of StringIO vs cStringIO in standard modules In-Reply-To: Guido van Rossum's message of "Thu, 03 Jun 1999 10:25:03 -0400" References: <8790a1620b.fsf@pc-hrvoje.srce.hr> <199906031425.KAA06935@eric.cnri.reston.va.us> Message-ID: <87aeuh5kqc.fsf@pc-hrvoje.srce.hr> Guido van Rossum writes: > Hrvoje Niksic : > > > I noticed that many standard modules use StringIO and not > > cStringIO, although they don't need subclassing. Is this > > intentional? > > > > For example, base64.py uses StringIO to implement encodestring() > > and decodestring(). Since both functions write to output line by > > line, I imagine the performance hit of StringIO vs cStringIO might > > be non-negligible. > > Have you noticed any speed difference? Yes, quite a bit. Trivially replacing StringIO with cStringIO in base64.py makes encoding 2.3 times and decoding 3.6 times faster. That's on my system (Ultra 2 under Solaris 2.6), measured repeatedly with time.clock() and an approx. 1M sample string. I can post the script if there is interest. Maybe the correct solution for base64.py would be to use something like this at top-level: try: from cStringIO import StringIO except: from StringIO import StringIO > cPickle, because calling it from C is much faster than calling > StringIO from C; however I believe that for calls from Python, > StringIO isn't that much slower. I've looked at the code, and to me it seems that the slowness comes from creating new strings on each write, where cStringIO just resizes its internal buffer and creates the string only at the end. > > Furthermore, is there a particular reason for maintaining two > > parallel StringIO implementations? If subclassing is the reason, > > I assume it would be trivial to rewrite StringIO to encapsulate > > cStringIO the same way that UserDict encapsulates dictionary > > objects. > > That's not the reason; it's got more to do with not requiring a C > extension where plain Python code will do. Also to have a reference > implementation. But then you have to maintain both, *and* you get much slower code. Is it worth it? From mwh21 at cam.ac.uk Thu Jun 3 02:21:00 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 03 Jun 1999 07:21:00 +0100 Subject: pickle vs .pyc References: <7j43pn$55l$1@mlv.mit.edu> <87vhd69tdm.fsf@pc-hrvoje.srce.hr> Message-ID: Hrvoje Niksic writes: > Michael Hudson writes: > > > Random aside: something fishy's going on when I try to try to marshal > > *arrays* (as opposed to mere lists): > > The documentation for marshal says: > > Not all Python object types are supported; in general, only > objects whose value is independent from a particular invocation of > Python can be written and read by this module. The following types > are supported: `None', integers, long integers, floating point > numbers, strings, tuples, lists, dictionaries, and code objects > (...) Yes, but usually you get an exception to show that somethings gone awry: >>> import md5 >>> marshal.loads(marshal.dumps(md5.md5())) Traceback (innermost last): File "", line 1, in ? ValueError: unmarshallable object >>> class F: ... pass ... >>> marshal.loads(marshal.dumps(F())) Traceback (innermost last): File "", line 1, in ? ValueError: unmarshallable object It's not that important I suppose, it's just odd. Michael From htrd90 at zepler.org Wed Jun 2 16:23:54 1999 From: htrd90 at zepler.org (Toby Dickenson) Date: Wed, 02 Jun 1999 20:23:54 GMT Subject: need help checking for stack overflow in Win32 References: <5lk8to3su3.fsf@eric.cnri.reston.va.us> <7j1pcc$256$1@m2.c2.telstra-mm.net.au> Message-ID: <375992b6.8610970@news.freeserve.net> Robin Becker wrote: >In article <7j1pcc$256$1 at m2.c2.telstra-mm.net.au>, Mark Hammond > writes >>Actually, I was about to post this yesterday, and to prove my point I wrote: >> >>def die(): >> die() >> >>Expecting to see the crash. I was then going to go into a rant about how >>win32api.Apply would actually let you catch this (and any other Win32) >>exception as a temporary solution. >> >>But it worked correctly - ie, Python raised a RuntimeError: Max Recursion. >> >... >I just tried this with my bog standard 1.5.2 under win95 osr2 and it >faults to the system. Strange :) It could be that Mark did actually exceed the 1MB stack, but windows was able to extend it since the relevent bit of his process's address space had not been reserved. Mark also wrote: >A better mechanism would be to use Win32 exception handlers. Then you dont >need artificial recursion checks at all - leave it to the OS. However, it >isnt clear to me where this exception handler should be placed, nor indeed >if setting up a Win32 exception handler inside the VM would have a >significant performance hit. A plus would be we could also catch Access >Violations (Im not sure what we would do with them - but a traceback would >be nicer than Dr Watson when dealing with buggy extensions!) Getting this to work could be tricky. The win32 exception could be generated when the VM or an extension was in an inconsistant state, and it may not be possible to continue processing after swallowing the RuntimeError. If we don't need to do that, then what is wrong with Dr Watson? >Thomas' solution is simple, and requires either a simple source file change, >or using the MSVC GUI to adjust the stack size. I don't think adjusting the stack size is a viable option. Python is used in some places where it is not in control of this parameter; in-process com servers being the obvious example. Toby Dickenson From jeffrey at Digicool.com Fri Jun 4 19:06:43 1999 From: jeffrey at Digicool.com (Jeffrey P Shell) Date: Fri, 04 Jun 1999 19:06:43 -0400 Subject: python active web pages References: <7j98g1$atj$1@autumn.news.rcn.net> Message-ID: <7j9m2n$6kr$1@autumn.news.rcn.net> > does anyone else use active web pages? surely all you python/web hackers > don't just use CGI scripts? No, that's why Gods created Bobo ;-) Actually, here's another alternative that's only gone non-updated since late november:: (Uses JPython and Servlets) http://www.dstc.edu.au/aspy/ A _long_ time ago (about three years methinks), I did something like all this based on the only web application server/platform (besides Zope) that I really respect, WebObjects, called Pummel. It had a syntax for putting code on the page, and then addressing it later. In that phase it was _fairly_ simple. But then it started trying to be a little bit like Bobo (mainly:: i wanted more powerful components that I could share). And once I actually figured out Bobo and DTML, I put the project away. I don't even know where the source is anymore. Basically, it looked like: .... import foobar import hti hello=hti.Input(type='text', name='uname', value=uname)
(hti was a very very very very simple HTMLGen-ish module without the smarts that HTMLGen has. Remember this was many many many moons ago). I'm about to unplug and go into a sooperfire weekend, but one quick question: is there any reason why Zope isn't an option for what you're doing? It seems like all these pseudo-ASP-ish projects get to about a 0.8 release functionality and then die off (my own PYML project included). HTMLGen and Bobo seem to be the most widely supported and up-to-date options from what I've seen over the past few years. There used to be something called "Boilerplate" (Broilerplate?) listed on the Python web site that did ASP-esque stuff too. Again, I don't know how current the development is on that one either. .jPS | jeffrey at digicool.com zope, through the web. www.zope.org From avv at quasar.ipa.nw.ru Thu Jun 3 13:21:05 1999 From: avv at quasar.ipa.nw.ru (Alexander V. Voinov) Date: Thu, 03 Jun 1999 10:21:05 -0700 Subject: pyGTK on Windows References: <3757D453.A302E757@interar.com.ar> Message-ID: <3756B981.AACF7F1@quasar.ipa.nw.ru> Nahuel wrote: > Hi, im about to do a cross-plataform GUI application in Linux and > Windoze... i must > choose the GUI toolkit.. my question is .. can i use pyGTK under > Windows??? > > (I need a gui that can display a table with about 4000 lines without > crashing (not like Tk :)) wxPython is mapped onto GTK under Linux, native API under Windows and has a 'grid' widget. If it crashes (suppose this) on 4000 lines, you will have a patch within a day (as I understand). Alexander From hniksic at srce.hr Mon Jun 7 12:06:43 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 07 Jun 1999 18:06:43 +0200 Subject: fork() References: <375BE64A.EB997F24@icrf.icnet.uk> Message-ID: <87so840zcc.fsf@pc-hrvoje.srce.hr> Arne Mueller writes: > All that woks fine now (after I spend a long time fiddling with the > pipe and select stuff to synchronize I/O). However the forking is a > waste of time and memory because all the children get their own > large dictionary! If you don't change the dictionary, the memory will not be copied. Most modern Unixes support COW (copy on write) which means that the actual fork()ing does surprisingly little. Only when the memory is written to, a new copy is spawned off. If the children are modifying the dictionary, that's well something different... From faassen at pop.vet.uu.nl Wed Jun 2 05:14:00 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Wed, 02 Jun 1999 11:14:00 +0200 Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <87pv3iq6ss.fsf@ev.netlab.co.jp> <7iv86a$iud@news.dns.microsoft.com> <87vhd7nsra.fsf@ev.netlab.co.jp> Message-ID: <3754F5D7.2B6E1954@pop.vet.uu.nl> Yukihiro Matsumoto wrote: > Some languages use both. Ref counting for usual basis, real GC for > full clean up. How about adding real GC to Python 2.0, co-working > with ref counting? This sounds like an interesting idea; I believe I saw references to garbage collecting schemes that help clean up circular references caused by referencing counting. I forget where, though. :) I agree with the general principle that for Python 2, garbage collecting should be taken a good look at. I suppose the two main issues are: * The predictability of reference counting is nice in the simple case. In the complex case, you get into a mess of circular references too easily, though. * In the complex case, garbage collecting is nice as it cleans up circular references. There are unwanted side-effects of its unpredictability, though; a possible leaking of resources (files which aren't closed), and some difficulties interfacing with C. In that light combining the two schemes might be very interesting. Repeatingly yours, Martijn From fleck at informatik.uni-bonn.de Tue Jun 8 21:01:56 1999 From: fleck at informatik.uni-bonn.de (Markus Fleck) Date: 9 Jun 1999 01:01:56 GMT Subject: GC SIG References: Message-ID: <7jkee4$qd8@news.rhrz.uni-bonn.de> Robert Meegan wrote: > Are there enough potential Sanitation Engineers to create a Garbage > Collection SIG? > ... > 2) The GC discussions would be moved out of the general mailing > list/newsgroup, freeing them of the constant debate. Hmmm... exactly which kind of "garbage collection" are you referring to? :-) Yours, Markus. -- If it ain't broken, better don't tempt to affix it. <0.5 broken wink> From matz at netlab.co.jp Tue Jun 1 23:24:13 1999 From: matz at netlab.co.jp (Yukihiro Matsumoto) Date: 02 Jun 1999 12:24:13 +0900 Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <87n1ykr0z9.fsf@ev.netlab.co.jp> <7ivs9q$dc5@news.dns.microsoft.com> <87k8toqv70.fsf@ev.netlab.co.jp> Message-ID: <871zfvp9nm.fsf@ev.netlab.co.jp> aahz at netcom.com (Aahz Maruch) writes: |In addition to Paul's excellent comments, if one is writing an |interactive process, one cannot afford the unpredictability of random |garbage collection. Garbage collection could run in a thread, but then |one is restricted to environments where threads are well-supported. Well, in <87n1ykr0z9.fsf at ev.netlab.co.jp> I said: |From my experience with Scheme and Ruby, both with real GC, the real |GC is mostly very fast. Fast enough no one notices its "hang" on most |cases. The legend was formed up by old GC implementation and slower |machines of the past, I guess. You can see STk (Scheme Tk, of cource with real GC) works just fine for interactive process. matz. From just at letterror.com Mon Jun 14 14:00:58 1999 From: just at letterror.com (Just van Rossum) Date: Mon, 14 Jun 1999 18:00:58 GMT Subject: Embedding Questions on the Macintosh In-Reply-To: References: Message-ID: At 9:01 AM -0700 6/14/99, Sean Hummel wrote: >Hi, I am writing a game which uses Python as the control language for a >bunch of sprites. I don't have any problems doing the embedding part. > >What I want to know is if it is easy to package the entire Python Library, >much like the "macfreeze" module does? I want to distributes as few >modifiable files as possible, and would prefer to distribute only two files: >the application, and the data file. That's indeed possible, you need to pack all modules as 'PYC ' resources into the app. Check out PackLibDir.py. Finally you have to add $(APPLICATION) to your app's path prefs. One way is to create a new resource file, drop it onto EditPythonPrefs and add it to your C project. Just From suzuki611 at okisoft.co.jp Wed Jun 2 21:08:42 1999 From: suzuki611 at okisoft.co.jp (Hisao Suzuki) Date: 03 Jun 1999 10:08:42 +0900 Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <87pv3iq6ss.fsf@ev.netlab.co.jp> <3752C76D.604CD474@prescod.net> <87n1ykr0z9.fsf@ev.netlab.co.jp> <375372F6.A874554@prescod.net> <87hfosquc0.fsf@ev.netlab.co.jp> <3753F121.E4A9BE8B@prescod.net> <87yai3ntdt.fsf@ev.netlab.co.jp> <7j3iif$134e$1@nntp6.u.washington.edu> <7j45iv$908$4@cronkite.cc.uga.edu> Message-ID: In article <7j45iv$908$4 at cronkite.cc.uga.edu>, graham at sloth.math.uga.edu (Graham Matthews) wrote: > You also seem to believe that with GC finalisation will disappear. Why > do you believe that (a lot of GC schemes have finalisation). You might misunderstand Donn's saying. As far as I understand, he says that explicit finalization (or close call, in your wording) disappears if reference counting is used; finalization will be done implicitly with destructor such as __del__(self) all at the expected time then. > Finally I > believe you are mis-using finalisation if you use it to close up files, > sockets, etc. That's what close calls are for. You are all right in some other languages. However, if we adopt such a manner as Pythonic style, we would have to write the code like this: a = SomeClass(....) try: ...do something with a... finally: a.close() instead of providing the __del__ method for SomeClass once and for all. --===-----========------------- Sana esprimo naskas sanan ideon. SUZUKI Hisao suzuki611 at okisoft.co.jp, suzuki at acm.org. From phd at emerald.netskate.ru Sat Jun 12 12:12:33 1999 From: phd at emerald.netskate.ru (Oleg Broytmann) Date: Sat, 12 Jun 1999 20:12:33 +0400 (MSD) Subject: regular expression question: last occurence In-Reply-To: <19990612180242.A6075@optiplex.palga.uucp> Message-ID: On Sat, 12 Jun 1999, Gerrit Holl wrote: > currentdir = os.getcwd() > mo = re.search('/linuxgames', currentdir) > eind = mo.end() > subdir = currentdir[eind:] + '/' > > But that doesn't solve my problem. print os.path.basename(currentdir) > kind regards, > Gerrit. > > -- > The Dutch Linuxgames website. De Nederlandse Linuxgames pagina. > Everything about games on Linux. Alles over spelletjes onder Linux. > Site address: http://linuxgames.nl.linux.org > Personal homepage: http://nl.linux.org/~gerrit/ Oleg. ---- Oleg Broytmann Netskate/Inter.Net.Ru phd at emerald.netskate.ru Programmers don't die, they just GOSUB without RETURN. From aahz at netcom.com Tue Jun 1 15:06:08 1999 From: aahz at netcom.com (Aahz Maruch) Date: Tue, 1 Jun 1999 19:06:08 GMT Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <87n1ykr0z9.fsf@ev.netlab.co.jp> <7ivs9q$dc5@news.dns.microsoft.com> <87k8toqv70.fsf@ev.netlab.co.jp> Message-ID: In article <87k8toqv70.fsf at ev.netlab.co.jp>, Yukihiro Matsumoto wrote: > >Well, OK. I understand now. Now only thing I can say is, why do you >emphasize so much on reclaiming object at the time you exepcted? >Because of your C++ background? In addition to Paul's excellent comments, if one is writing an interactive process, one cannot afford the unpredictability of random garbage collection. Garbage collection could run in a thread, but then one is restricted to environments where threads are well-supported. -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het "NRE is a lot like cocaine. Feels great while you're on it, makes you feel very special and talented, and you become highly annoying to those who aren't on it." -- Stef From fatjim at home.com Wed Jun 16 05:26:10 1999 From: fatjim at home.com (Jim Meier) Date: Wed, 16 Jun 1999 09:26:10 GMT Subject: Cut down on writing repetitive code References: <3766f6a8.19474000@news2.mainnet.net> <3767128E.E049636C@mojam.com> Message-ID: <37676DCA.3594C959@home.com> Skip Montanaro wrote: > Tim Gallati wrote: > > > If you do a lot of repetitive typing, check out Perfect Keyboard Lite. > > I use it everyday and consider it my most useful program. > > Gee, I thought the usual OO way to cut down on repetitive typing was to > abstract common code into base classes. I guess the original OO folks > (Simula? Smalltalk?) got it all wrong 20- to 30-odd years ago. They > should have invested in Mavis whats-her-name instead! :) ROTFLMAO - again, and again, and again, .. oh, wait.. class again: def __init__(self, num, arg): tmp=arg[:] tmp=tmp+", and " self.val=tmp*(num-1) self.val=self.val+arg def __str(self): return self.val print again(900, "again") :) > > No disclaimers in the original post. I guess it was an off-charter > advertisement. Another company hits my bit bucket. I wouldn't be _THAT_ hard on them. True, they didn't mention that they were actually the company in question, and for that they certainly deserve a smack upside the head. But they certainly posted a relevant pointer to something that may help a lot of people associated with this newsgroup. They may not be perfect, but they are certainly on my "good usenet advertisers" list for not randomly spamming, for spelling everything properly, for being short and direct, and for being reasonably on-topic. Better this than the recent porn postings!! > > -- > Skip Montanaro | http://www.mojam.com/ > skip at mojam.com | http://www.musi-cal.com/~skip/ > 518-372-5583 -Jim. From smjoshi at bellsouth.net Wed Jun 23 23:01:18 1999 From: smjoshi at bellsouth.net (SunitJoshi) Date: Wed, 23 Jun 1999 22:01:18 -0500 Subject: Python Exes! Message-ID: <%fhc3.2901$Lk4.35205@news4.mia> Could someone please point me to the URL where Gordon Mcmillians, installer is located. I had it but can't seem to locate it thanks Sunit From kernr at mail.ncifcrf.gov Wed Jun 9 17:33:17 1999 From: kernr at mail.ncifcrf.gov (Robert Kern) Date: Wed, 09 Jun 1999 21:33:17 GMT Subject: Unicode handling Wstring Win95/98 Binary References: <000801beb250$11cb0c40$b8e1fea9@computername> Message-ID: <375edb49.8685256@news.erols.com> On Wed, 9 Jun 1999 16:14:13 +0800, "Sin Hang Kin" wrote: [snip MIME] >Hello, > >Does any one have wstring package in winxx binary format? I do not have = >the necessary compiler to do it. I do. I can get wstrop.pyd to compile and work (I'm guessing on that last claim; test.py doesn't report any errors. I just downloaded the package, so I don't know how it is supposed to work). I still can't get intl.pyd to compile (I don't have libintl.h and whatever else is necessary). I can e-mail wstrop.pyd if you want. If there is more interest, I'll place the binary in my forthcoming Starship cabin. >Rgs, > >Kent Sin >kentsin at poboxes.com [snip MIME] From clarence at silcom.com Thu Jun 24 10:29:23 1999 From: clarence at silcom.com (Clarence Gardner) Date: Thu, 24 Jun 1999 14:29:23 GMT Subject: It's just magic, and I hate it ... References: <14190.35530.772547.166720@buffalo.fnal.gov> <37703621.B29B72CB@bioreason.com> <930181790.156.59@news.remarQ.com> Message-ID: <7hrc3.659$dR.56613@newsfeed.avtel.net> Mitchell Morris (mmorris at mindspring.com) wrote: : In article , : mmorris at mindspring.com wrote: : [snip] : : In a very polite private e-mail, Tim Peters pointed out that this is a FAQ, : number 4.87 in fact. That will teach me to not check *ALL* the docs before : opening my trap. : : Thanks to everyone ... I appreciate your time and efforts on my behalf, : +Mitchell I wonder if it will teach me to read the entire thread before following up to a message :) -- -=-=-=-=-=-=-=-= Clarence Gardner AvTel Communications Software Products and Services Division clarence at avtel.com From tim_one at email.msn.com Thu Jun 10 21:22:37 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 10 Jun 1999 21:22:37 -0400 Subject: None inconsistent In-Reply-To: <7jp51f$rci$1@nnrp1.deja.com> Message-ID: <000201beb3a8$e3e0f100$329e2299@tim> [mjhand at concentric.net] > Pardon the repetition (if this is repetitive). I have posted > this message three times but have yet to see it appear on the > newsgroup. First time I've seen it . > In 1.5.1, "None" was "less" than all numbers: > >>> 0 < None > 0 > >>> sys.maxint > None > 1 Yes, "incomparable" objects were compared first by the *string* name of their type in 1.5.1, and as strings "None" < "int". An accident, really. > In 1.5.2, "None" became "greater" than all numbers: > >>> 0 < None > 1 > >>> sys.maxint > None > 0 > > I have three questions about this: > (1) Was this change made intentionally? (I hope so.) What happened to None was pure accident, but the rules were deliberately changed to treat all builtin numeric types (int, long, float, complex) as having string name "", i.e. an empty string. Else e.g. because, as strings "int" < "list" < "long" we also had 42 < [42] < 42L return true while 42 < 42L returned false. Python is happy to let you create your own non-transitive comparisons, but didn't want to set a bad example <0.9 wink>. In 1.5.2 they both return false. > (2) Can we count on it staying this way forever? (I hope so.) The language doesn't define what happens when doing silly comparisons, beyond promising consistency involving comparisons of objects of builtin types. So, no, in theory you can't count on it. In practice, the change in 1.5.2 achieved the consistency it was aiming for, so as a practical matter it's unlikely to change again. > (3) When will the starship be updated to use 1.5.2 by default? > (/usr/bin/python == 1.5.1, /usr/local/bin/python == 1.5.2b2) Beats me -- bring it up on the starship crew mailing list. > I absolutely LOVE that "None" is accepted as a valid argument in > min(), max(), and cmp(), but I would like it to behave consistently. > The 1.5.2 way is best for my code. Please tell me it will stay > that way forever. I won't lie without better financial inducement than that. besides-only-guido-is-eternal-ly y'rs - tim From kernr at mail.ncifcrf.gov Tue Jun 22 19:13:53 1999 From: kernr at mail.ncifcrf.gov (Robert Kern) Date: Tue, 22 Jun 1999 23:13:53 GMT Subject: interactive-logging References: <376FF09A.8170CB@icrf.icnet.uk> Message-ID: <3770183d.84268602@news.erols.com> On Tue, 22 Jun 1999 21:22:50 +0100, Arne Mueller wrote: >Hi All, > >I'd like to add some logging to the interpreter's interactive modus so >that everything I type in and everything what's printed to the screen >(errors and 'normal' output) is copied to a log-file. [snip] >Is there already something like this written? I've no idea how how the >interactive modus works. For aprogram I've written that copies a >file-object, say everything that goes to 'sys.stderr' is also written to >a log-file, how to do that interactive modus? I'm not sure how many of your desired features are in it, but try out IPP (the Interactive Python Prompt) by Janko Hauser at (http://starship.python.net/crew/jhauser/IPP.tgz). > thanks very much, > > Arne Robert Kern | ----------------------|"In the fields of Hell where the grass grows high This space | Are the graves of dreams allowed to die." intentionally | - Richard Harter left blank. | From claird at Starbase.NeoSoft.COM Tue Jun 29 11:30:08 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 29 Jun 1999 10:30:08 -0500 Subject: Why is tcl broken? References: <1283099377-77267484@hypernet.com> <876748mcxg.fsf@home.ivm.de> <37788BB9.ABD@mailserver.hursley.ibm.com> Message-ID: <7laoq0$bvh$1@Starbase.NeoSoft.COM> In article , Marco Antoniotti wrote: . . . >spin. :) Finally, AFAIU, a Tcl "macro" must run as an interpreter of >the spec. A Common Lisp (Scheme) macro is compiled into regular code >by read-time expansion. . . . Are you making a semantic point, or arguing on the basis of implementation-specific per- formance? If the latter, please be aware that the Tcl community is actively investi- gating dramatic speedups of [eval]. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From l.a.apiolaza at massey.ac.nz Tue Jun 29 01:38:35 1999 From: l.a.apiolaza at massey.ac.nz (l.a.apiolaza at massey.ac.nz) Date: Tue, 29 Jun 1999 05:38:35 GMT Subject: reloading modules in idle Message-ID: <7l9m4q$6r1$1@nnrp1.deja.com> Hi Pythoneers, I'm writing my Python code using IDLE. When working with multiple files and making corrections to some of them IDLE doesn't use the latest version of the files, but the one previously interpreted. Is there any way (from inside IDLE) to reload the latest versions and run the code with all the corrections? Thanks, Luis ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Luis A. Apiolaza IVABS Massey University Palmerston North New Zealand l.a.apiolaza at massey.ac.nz ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From petrilli at trump.amber.org Mon Jun 28 12:17:31 1999 From: petrilli at trump.amber.org (Christopher Petrilli) Date: 28 Jun 1999 09:17:31 PDT Subject: ConfigParser.py? References: Message-ID: <7l876r$nrs@chronicle.concentric.net> Benjamin Schollnick wrote: > Folks, > I'm trying to use ConfigParser... And I believe I'm doing everything > write, except I don't see any documentation (including in the > configparser.py file) > telling my what function(s) to use to write the file out to disk??? That's simple... it doesn't exist :-) > Can someone give me a example or syntax on that? Would love ot, but you'll need to write the code to do this. This was designed to be "read only", although it's been talked about making it bi-directional. Chris -- | Christopher Petrilli ``Television is bubble-gum for | petrilli at amber.org the mind.''-Frank Lloyd Wright From toby at puckish.demon.co.uk Thu Jun 10 18:59:30 1999 From: toby at puckish.demon.co.uk (Toby Kelsey) Date: Thu, 10 Jun 1999 23:59:30 +0100 Subject: Newbie class questions Message-ID: I have just started to learn Python (v1.5.2), and have some questions about classes. Here is something I prepared earlier... --- cut --- def y(x): return 'a global function y(x)' def g0(): return 'some arbitrary function (no args)' def g1(x): return 'another arbitrary function (one arg)' i = 0 class MyClass: """A simple class demonstrating scope.""" i = 12345 def __init__(self): print '\n\tI output, therefore I am.\n' def y(x): return 'default class method y' def f(x): # i = 7 # hides global print 'Global variable:', i print 'Class variable:', MyClass.i print 'Instance variable:', x.i print 'Global function:', y(x) print 'Class method:', MyClass.y(x) # explicit instance arg. print 'Instance method:', x.y() # implicit instance arg. return def q(): """This method is inaccessible - should be a parse-time error""" return t = MyClass() print "Doc:", t.__doc__ t.f() print "\nModified:" i = 21 t.i = 169 #t.y = g1 t.y = g0 t.f() --- cut --- BTW I think an example class like this in the tutorial would help explain scope, but there are also a few things I don't understand here (probably my C++ background). (1) Is there a reason why I cannot call MyClass.q()? Why require a meaningless instance arg to a class-static method? Alternatively shouldn't it be an error at parse time? (2) Why doesn't t.y = g1 work? How am I meant to access instance attributes in g0 without an instance argument? (3) Some mention was made in the tutorial of the scope rules being in flux. Are any impending changes likely to affect the output of this class? Cheers, Toby -- Toby Kelsey From gmcm at hypernet.com Mon Jun 14 10:02:48 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Mon, 14 Jun 1999 09:02:48 -0500 Subject: Problem with embedded python In-Reply-To: <7jk0cm$4hk@wapping.ecs.soton.ac.uk> Message-ID: <1282753272-98086574@hypernet.com> Ben writes: > I have embedded python into a win32 c++ application using > PyRun_SimpleFile. This executes a python script at regular (25 times > a second-ish) intervals. Also included in this C++ application is a > procedure which handles the window messages, which I have also tried > to script. Unfortunately, running any script in this function > crashes windows with a nasty protection fault. Do I need to run my > scripts on seperate threads... or in different interpreters. or is > this genuinely a bug.. It seems likely that the procedure handling windows messages is being executed by a different thread than the one running PyRun_SimpleFile. In which case you will need to establish 2 thread states when you start up Python, and use one for each purpose. If the work they are doing is completely disjoint, you could use 2 different interpreter states. But Python needs to know that it is operating in a threaded environment, and has to build objects which shadow the OS threads. The hard part is getting it started; after that it should just work. And it's not actually hard to get it started, just confusing. Check out the pysvr demo. You should probably direct further questions to the Thread SIG. - Gordon From joe at strout.net Thu Jun 17 16:49:16 1999 From: joe at strout.net (Joe Strout) Date: Thu, 17 Jun 1999 13:49:16 -0700 Subject: [ANN] Graphite 0.1 Message-ID: [[ This message was both posted and mailed: see the "To," "Cc," and "Newsgroups" headers for details. ]] The Graphite development team is pleased to announce the first public release of Graphite, a 100% Python, open-source, cross-platform plotting/graphing library. http://www.strout.net/python/graphite/ Graphite will enable the easy creation of scientific, engineering, and business graphs. Some graph types to be included are line graphs, bar charts, function plots, polar plots, parametric plots, and mesh plots. Graphite will be able to produce output for formats such as postcript, pdf, gif, Windows, QuickDraw, Tk by using the PIDDLE drawing system. It will also have interactive capability (e.g., positioning labels and other overlays via the mouse or arrow keys), and should run on any platform that supports Python. This is the very first public release -- note the version number, 0.1. Many of the features mentioned above are not yet implemented. However, it does run, and the intrepid Python hacker should be able to produce some plots in short order. Documentation is sparse, so please refer to the web site for frequent updates. You may also wish to join the mailing list, at (click on "group info" to get to the subscription form). This is an open-source project; we are actively seeking input and contributions from the Python community. That's why we're releasing it now, in its current embryonic stage. Our hope is that with your input, Graphite will grow rapidly into a powerful, professional-quality yet easy-to-use plotting package. Cheers, -- Joe -- ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe at strout.net http://www.strout.net | `------------------------------------------------------------------' From mlh at idt.ntnu.no Wed Jun 23 09:44:52 1999 From: mlh at idt.ntnu.no (Magnus L. Hetland) Date: 23 Jun 1999 15:44:52 +0200 Subject: interactive-logging References: <376FF09A.8170CB@icrf.icnet.uk> Message-ID: Arne Mueller writes: > Hi All, > > I'd like to add some logging to the interpreter's interactive modus so > that everything I type in and everything what's printed to the screen > (errors and 'normal' output) is copied to a log-file. Hm. Isn't there a UN*X command that does that? (That logs everything going on in a terminal...) I'm damned if I can remember what it was, though... -- Magnus Making no sound / Yet smouldering with passion Lie The firefly is still sadder / Than the moaning insect Hetland : Minamoto Shigeyuki From jonathan at onegoodidea.com Fri Jun 4 11:40:39 1999 From: jonathan at onegoodidea.com (Jonathan Hogg) Date: Fri, 04 Jun 1999 16:40:39 +0100 Subject: python active web pages Message-ID: hi there, i'm looking to embed python into web pages in a similar way to ASP and PHP3 and so forth. i found a thing called Active Server Python, , but i note that it doesn't seem to have had any attention in the last year. i also looked at ZTemplates (a component of Zope), , and while it doesn't actually embed python, it has a limited embedding language of its own, DTML, which gets munged into python. i must say that DTML looks a bit hideous (if anyone from digicool is reading, sorry guys). anyone have any experience with active web pages using either of these or something else? thanks in advance, :-j -- jonathan hogg, one good idea limited, 25 clouston street, glasgow g20 8qr, uk jonathan at onegoodidea.com www.onegoodidea.com t:(0)976-614338 f:(0)7970-537451 From wware-nospam at world.std.com Fri Jun 25 17:40:41 1999 From: wware-nospam at world.std.com (Will Ware) Date: Fri, 25 Jun 1999 21:40:41 GMT Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> Message-ID: Mikael Lyngvig (mikael at pobox.com) wrote: : I'd like some discussion on whether or not it is a good idea to : abandon TkInter, before it gets too widely used, and instead adopt : wxPython as the primary GUI framework for Python. The last time I tried playing with wxWindows on a Linux box, it demanded some library I didn't have. I don't remember if it was Mesa, KDE, Gnome, or what, but a couple days' fooling around with it got me no progress. For all its performance problems, Tcl/Tk does work pretty much everwhere. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From bernhard at alpha1.csd.uwm.edu Sat Jun 19 19:33:48 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 19 Jun 1999 23:33:48 GMT Subject: BiBTeX module? References: <7k950a$hsb@cs.vu.nl> Message-ID: On 18 Jun 1999 13:04:51 +0100, Frederic Gobry wrote: >>Having a look at the current programs available for editing and entering >>BiBTeX files someone really ahs to write a good python/tk or >>python/wxpython program for this task, too. > >I've also started such a project as free software. The parser and the python >interface are working correctly now. My idea was to write something generic >for bibliographic databases, BibTeX being only the first module. A GNOME >interface is also in progress (does some display but no real edition yet) Great! >So I can make a snapshot for you or you can use an old version Please make snapshot and more infos available. I might be able to playtest a bit. Bernhard -- Research Assistant, Geog Dept UM-Milwaukee, USA. (www.uwm.edu/~bernhard) Funding/Promoting Association for a Free Informational Infrastructure (ffii.org) From suzuki611 at okisoft.co.jp Wed Jun 2 19:27:00 1999 From: suzuki611 at okisoft.co.jp (Hisao Suzuki) Date: 03 Jun 1999 08:27:00 +0900 Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <87pv3iq6ss.fsf@ev.netlab.co.jp> <7iv86a$iud@news.dns.microsoft.com> <87so8bnsd6.fsf@ev.netlab.co.jp> <87pv3eorg4.fsf@ev.netlab.co.jp> Message-ID: In article <87pv3eorg4.fsf at ev.netlab.co.jp>, Yukihiro Matsumoto wrote: > BTW, did I say Ruby can invoke arbitrary destructors specified by > arbitrary users? It can't. Is this your mental premise in your opinion about garbage collection? Then, the unpredictability might not be matter at all... I see that is the way of your own excellent Ruby, but it is not the manner of the present Python. --===-----========------------- Sana esprimo naskas sanan ideon. SUZUKI Hisao suzuki611 at okisoft.co.jp, suzuki at acm.org. From tismer at appliedbiometrics.com Thu Jun 3 07:09:45 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Thu, 3 Jun 1999 11:09:45 GMT Subject: need help checking for stack overflow in Win32 References: <5lk8to3su3.fsf@eric.cnri.reston.va.us> <7j1pcc$256$1@m2.c2.telstra-mm.net.au> <375502C7.39C4FD0E@appliedbiometrics.com> <7j38bs$ipe$1@m2.c2.telstra-mm.net.au> Message-ID: <37566279.15E62594@appliedbiometrics.com> Mark Hammond wrote: > > Christian Tismer wrote in message > <375502C7.39C4FD0E at appliedbiometrics.com>... > > >Nope. The trap is: > >You compiled with VC++ 6.0 which has better register spilling. > >Therefore, recusion costs only 100 bytes, not 104. > >Not calculate 104 * 10000 and you see why 1 MB stack > >lets it crash. > > Cool. Thanks. > > But doesnt the fact remain that counting the recursion depth is dangerous? > Im thinking of embedded environments, where a) the stack size of the hosting > .exe can't be known and b) the stack used by the app before Python is even > called can't be determined. Add to this callbacks in GUI and COM type > applications, and we seem to be applying more band-aids. > > The idea of counting space used seems better, but still assumes a known > stack size. Absolutely right. The shorthand solution is to either modify the stack size of the program, or to modify the recursion depth in python15.dll. The better solution is stackless Python which I'm working on. But I'm no sourcerer, it takes time. > > >I submitted a patch program for this kind of > >problems, so I think there is no need to change > >Python 1.5.2 at all. > > Huh? Are you suggesting people continue to build from sources, then run > your script to get an "official" version? Wouldnt it be better to get Guido > to apply these changes to the build process? No. People who build from sources migtht simply change their stack size or the recursion depth parameter. There is no reason to submit such a patch to Guido, since he can adjust his parameters alone. The reason why I provided a binary patch is, that this problem is not worth messing around with another python release. If someone cares, he just adjusts his max_recursion_depth with my little program, and he's done. This is even more powerful than changing the source, since this parameter can be patched whenever needed, without recompilation. Of course, such a parameter could be made visible and changeable through a variable like sys.max_recursion, but this is a change which Guido would not want to include into 1.5.2 . So well, my patch does it. Many people don't like binary patches. I don't care, it works and it's there. > You have provided an excellent interim fix, but IMO the problem remains. The interim fix is the final fix, since the problem is about to vanish completely. ciao - chris.stackless -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From ivnowa at hvision.nl Tue Jun 22 02:47:24 1999 From: ivnowa at hvision.nl (ivnowa at hvision.nl) Date: Tue, 22 Jun 1999 06:47:24 GMT Subject: newbie idiom question In-Reply-To: References: Message-ID: <199906220645.IAA15728@axil.hvision.nl> On 21 Jun 99, Alex Rice wrote: > Something I keep getting tripped up about is that objects being > iterated in "for" statements cannot be modified. > > I keep trying to do this: > > >>> eggs = [1,2,3] > >>> for spam in eggs: > ... spam = 'cooked' > ... > >>> eggs > [1, 2, 3] > >>> > > The tutorial says this: > > If you need to modify the list you are iterating over, e.g., duplicate > selected items, you must iterate over a copy. The slice notation makes > this particularly convenient: > Understood, but what if you want to modify each element in a list? > What's the best way to do this in terms of speed and elegance? I guess > I just haven't seen a good example of this yet in Python > What I'm unfortunately used to is this, in Perl: > > @eggs = (1,2,3); > foreach $spam (@eggs) { > $spam = 'cooked'; > } > print "@eggs"; > >>> cooked cooked cooked An unwelcome side effect, methinx. You can use range: for i in range(len(eggs)): eggs[i] = 'cooked' Since the list you're iterating over is the same as the list you're modifying, it may be wise to use a slice (not in this particular case, but in general): for i in range(len(mylist[:])): if mylist[i] == 'ham': mylist[i:i] = ['eggs'] # insert something You can also use map: eggs = map(lambda s: 'cooked', eggs) But this can get difficult for complex lambdas, and it doesn't change the list in place. Hans Nowak (ivnowa at hvision.nl) Homepage: http://fly.to/zephyrfalcon From faassen at pop.vet.uu.nl Thu Jun 3 17:18:13 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Thu, 03 Jun 1999 23:18:13 +0200 Subject: Alien whitespace eating nanovirus strikes again! References: <375500C9.742DC539@pop.vet.uu.nl> <3756E3D9.E44D2B39@swcp.com> Message-ID: <3756F115.CBBAC9D8@pop.vet.uu.nl> Alex Rice wrote: > > Martijn Faassen wrote: > ... > > > Okay, sorry for all this, it's out of line, I just needed to blow off > > steam. :) > > As the composer John Cage would have told you, silence is music as much > as tones and harmonies are music. silence == whitespace ? What did John Cage say about curly braces and dollar signs? :) Regards, Martijn From htrd90 at zepler.org Fri Jun 11 21:45:09 1999 From: htrd90 at zepler.org (Toby Dickenson) Date: Sat, 12 Jun 1999 01:45:09 GMT Subject: fork() References: <000901beb424$b2878200$a49e2299@tim> Message-ID: <3761b44e.1186639@news.freeserve.net> "Tim Peters" wrote: >Hard to weigh that against the probable increases in memory and runtime; >and, philosophically, you gotta admit it's a mess. OTOH, the combo of >finalizers, cycles and resurrection seems to be a philosophical mess even in >languages that take it all seriously. > >Don't know, Guido! I could live happily with it provided it didn't slow >things down much, and especially provided I don't think about the semantics >at all . But then I'm not a __del__-lover to begin with. Anyone >following this who is? All of my recent __del__ methods have been similar to a file object, where __del__ calls self.close and the close method must expect to be called more than once. I would be happy for a m&s to just call __close__, multiple times if necessary, trusting the user to manually break any cycles. >resurrection-should-be-reserved-to-gods-ly y'rs - tim Toby Dickenson From skott1870 at my-deja.com Tue Jun 1 14:53:54 1999 From: skott1870 at my-deja.com (skott1870 at my-deja.com) Date: Tue, 01 Jun 1999 18:53:54 GMT Subject: Capturing stderr from a call to os.popen Message-ID: <7j1a88$1vq$1@nnrp2.deja.com> Is it possible to redirect stderr from a call to os.popen? If so, will someone post an example. Thanks, TST Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From aahz at netcom.com Sat Jun 5 16:32:47 1999 From: aahz at netcom.com (Aahz Maruch) Date: Sat, 5 Jun 1999 20:32:47 GMT Subject: Deleting characters from a string References: <87n1ye3g4v.fsf@pc-hrvoje.srce.hr> Message-ID: In article , Magnus L. Hetland wrote: > >result = "" >for char in host: > if char not in ' "': > result = result+char > >host = result That's a bad way to do it. At the very least, that code should be something like: # There may be a couple of syntax errors below result = [] for char in host: if char not in ' "': result.append(char) host = string.join ( result, "" ) This has *much* better performance if host is at all long. -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het "Why do you like my boyfriend to tie you up and beat me.?" -- ELIZA generates a poly moment From skip at mojam.com Tue Jun 15 11:17:01 1999 From: skip at mojam.com (Skip Montanaro) Date: Tue, 15 Jun 1999 15:17:01 GMT Subject: Variations on a theme by "pound bang" References: <3763e75f.3265255@news.iol.ie> <3763F77E.6094AEE9@appliedbiometrics.com> <3764185B.7BCBC488@Lugoj.Com> Message-ID: <37666EFD.B31EBCAC@mojam.com> James Logajan wrote: > Christian Tismer wrote: > > Uses the env program which is allways there, to figure out > > from the environment settings which python to use. > Alas, this is a myth. Not all Unixen put env in /usr/bin, some put it in > /bin. I can't recall if it was Solaris (probably not) or LynxOS (probably) > that put env in /bin. Anyway, I got bit by it. I think it's a case of the 80/20 rule. *Most* Unix variants put env it in /usr/bin these days. (I think there was a thread about this when the topic came up in the past couple of years.) In fact, it appears that /bin is falling out of favor for most tools, at least on Linux: % ls /bin | wc -l 86 (18 are symlinks) % ls /usr/bin | wc -l 969 (97 are symlinks) I don't seem to recall that being the case in the "good old days". -- Skip Montanaro | Mojam: "Uniting the World of Music" http://www.mojam.com/ skip at mojam.com | Musi-Cal: http://www.musi-cal.com/ 518-372-5583 From thornley at visi.com Sat Jun 19 13:20:22 1999 From: thornley at visi.com (David Thornley) Date: Sat, 19 Jun 1999 17:20:22 GMT Subject: Why is tcl broken? References: <1283099377-77267484@hypernet.com> Message-ID: In article , Chris Ebenezer wrote: > >thornley at visi.com (David Thornley) writes: >: >Why use TK at all ? Once you are using scheme anyway there are nicer >: >widget toolkits to use (from a point of view of more "normal" looking >: >toolkits that don't suffer from color allocation problems), there are >: >bindings for guile and gtk and guile and Qt. >: > >: The attraction, to me, would be that Tk is a free, open-source >: graphics environment that will run on Unix with X-Windows, the >: Macintosh, and Microsoft Windows. CLIM is commercial, Garnet last > I haven't gotten any responses that indicate that there's anything besides Tk that meets the requirements I've specified: free (in some sense or another), open source (in some sense or another) and running on MacOS, Microsoft Windows and X Windows. Apparently Qt is free in a very restricted sense, and doesn't run on MacOS. >Hi David, > >If you want something that is completely free (in the GNU sense) go to >http://www.gtk.org/, scroll down until you reach the bit on the sidebar >that reads "Language Bindings". You should be able to get guile-gtk >from there. > I'm willing to consider free in the GNU sense, but GTK claims to be for X under Unix. I didn't see anything about GTK for the Macintosh (yes, I have heard RMS discuss Apple Corporation) or Microsoft Windows, aside from a note from somebody porting it in his spare time. Given that I have limited spare time, I'm interested in a toolkit that I can use on the Mac without doing my own port first. (Besides, the impression I get from the discussion on the MS Windows port is that GTK was designed for X Windows and Unix, and is unnecessarily hard to port compared to a toolkit designed with a wider focus to begin with.) It still looks like Tk is the best available graphics package for my purposes. -- David H. Thornley | If you want my opinion, ask. david at thornley.net | If you don't, flee. http://www.thornley.net/~thornley/david/ | O- From scarblac-spamtrap at pino.selwerd.cx Sun Jun 27 13:51:47 1999 From: scarblac-spamtrap at pino.selwerd.cx (Remco Gerlich) Date: 27 Jun 1999 17:51:47 GMT Subject: Questions; freeze, tkinter, internet connection... Message-ID: I need to make a few programs that will be given to our clients, with which they can periodically enter some information that will be mailed to us. I'd like to do it in Python, since I recently learned it and I'm in love with its readability, mainly. I also expect development to be very quick. Before I can decide to use it I need a few answers though, hopefully someone here can help :) I understand I can use Freeze and the compiled Python/Tk program will work on Win32 without needing anything else installed? The FAQ says that Freeze "maybe works with Visual C++ 6.0". Does it? (can't test, I don't own any version yet) Can I use the extensions to Tk like BLT or Tix? I'd like to use tab bars... I've seen the examples of how to send mail and so on, but how do I know if there is a connection to the Net at the moment? How do I start a dial-in if there isn't any yet? Now if I can get one thing to work well with Python, I'll convince my boss we should use it a lot more... -- Remco Gerlich, scarblac at pino.selwerd.cx From tim_one at email.msn.com Wed Jun 23 01:14:20 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 23 Jun 1999 01:14:20 -0400 Subject: It's just magic, and I hate it ... In-Reply-To: Message-ID: <000b01bebd37$3ff19340$cb9e2299@tim> [Charles G Waldman] > Try running Python in unbuffered mode - with a "-u" commandline flag, > or by setting the PYTHONUNUFFERED environment variable to a non-empty > string. [Mitchell Morris] > Are you saying that this worked for you? Or was this a guess? > > I ask because it makes no difference when I try it. Something like this popped up a while back, which made me write FAQ 4.87. Why doesn't closing sys.stdout (stdin, stderr) really close it? This solved the problem for the person who had it then. So read the FAQ and try what it says. If that doesn't work, I'll try to find the original thread in DejaNews. charles'-suggestion-was-worth-a-try-but-you're-getting-buffered- somewhere-else-ly y'rs - tim From news at dorb.com Wed Jun 30 17:40:17 1999 From: news at dorb.com (Darrell) Date: Wed, 30 Jun 1999 17:40:17 -0400 Subject: problem with Fnorb and module new References: <377A8D17.9B4D17C8@sr.hp.com> Message-ID: I don't think that "new" is part of the default build. It shows up in the Windows build. -- --Darrell Jim Kerr wrote in message news:377A8D17.9B4D17C8 at sr.hp.com... > I just tried installing Fnorb on HP-UX 10.20... the install went > smoothly, but when I tried stepping through the Hello World example, > python complained about not being able to find module new. The > complaint > is certainly valid -- I can't find new.py anywhere either. Anyone know > what's going on here? > > $ fnidl HelloWorld.idl > Traceback (innermost last): > File > "/users/jbkerr/python/Python-1.5.1/site-packages/Fnorb/script/fnidl", > line 2, in ? > import sys; from Fnorb.script import fnidl; > sys.exit(fnidl.main(sys.argv)) > File > "/users/jbkerr/python/Python-1.5.1/site-packages/Fnorb/script/fnidl.py", > line 41, in ? > from Fnorb.orb import CORBA, Util > File > "/users/jbkerr/python/Python-1.5.1/site-packages/Fnorb/orb/CORBA.py", > line 38, in ? > import fnorb_thread, TypeManager, Util > File > "/users/jbkerr/python/Python-1.5.1/site-packages/Fnorb/orb/Util.py", > line 38, in ? > import keyword, new, string, UserList > ImportError: No module named new > > -- > Jim Kerr > Hewlett-Packard > Santa Rosa Systems Division > 1400 Fountaingrove Pkwy, MS 3USZ > Santa Rosa, CA 95403 > Phone: 707-577-5575 > Telnet: 577-5575 From graham at sloth.math.uga.edu Fri Jun 4 10:32:38 1999 From: graham at sloth.math.uga.edu (Graham Matthews) Date: 4 Jun 1999 14:32:38 GMT Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> Message-ID: <7j8o26$55v$1@cronkite.cc.uga.edu> Hisao Suzuki (suzuki611 at okisoft.co.jp) wrote: : Me too. And I am afraid that some evangelists would do nothing : but _only_ point out Python's some so-called fault in order to : drive us into convert to their favorite or invented language... I am sorry Hisao but this is pure fantasy. This kind of "anyone suggesting improvement to Python is a critic" mentality pervades this thread and this newsgroup. Can you give even one example of where someone has tried to convert anyone to another language in this thread? The only other language mentioned in this thread is Ruby, and the author of the article about Ruby was very clear to point out that he was reporting his experience with GC in Ruby and not evangelising it. If you cannot give an example then what you write above is fantasy. Hisao Suzuki (suzuki611 at okisoft.co.jp) wrote: : Anyway, as you say, I'd think that we need an actual experience. But people do have experience with GC. Sure that experience is not in Python, but why do you believe that GC in Python will be radically different to GC in any other language? graham -- A cat named Easter He say "will you ever learn" Its just an empty cage girl If you kill the bird From bwarsaw at cnri.reston.va.us Tue Jun 1 10:34:38 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Tue, 1 Jun 1999 10:34:38 -0400 (EDT) Subject: File locking References: <199905301615.MAA00996@mira.erols.com> Message-ID: <14163.61310.936743.849211@anthem.cnri.reston.va.us> >>>>> "AMK" == A M Kuchling writes: AMK> What is the correct solution for doing file locking in Python AMK> programs? You might want to look at Mailman's flock.py module. The doc string says: Portable (?) file locking with timeouts. This code should work with all versions of NFS. The algorithm was suggested by the GNU/Linux open() man page. Make sure no malicious people have access to link() to the lock file. It's also been banged on quite a bit, although I'll make no guarantees that it's bug free. It's probably pretty close tho'. -Barry From zigron at jps.net Tue Jun 8 00:19:21 1999 From: zigron at jps.net (Zigron) Date: Mon, 7 Jun 1999 21:19:21 -0700 Subject: where does 'del' come from? References: <7jhuu5$8d4$1@nnrp1.deja.com> Message-ID: I *believe* that 'del' is a keyword, thus, isn't exactly /defined/ anywhere like functions and the likes are. Its like 'if', and 'while', and 'print'.. --Stephen wrote in message news:7jhuu5$8d4$1 at nnrp1.deja.com... > A fairly academic question, but I'm curious nonetheless. Where is 'del' > defined? Functions like 'join' are obviously in the string package, > 'range' is a builtin, but I can't seem to find 'del' anywhere. > > Python 1.5.2 (#12, Jun 2 1999, 19:23:30) [C] on irix646 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> dir(__builtins__) > ['ArithmeticError', 'AssertionError', 'AttributeError', 'EOFError', > 'Ellipsis', 'EnvironmentError', 'Exception', 'FloatingPointError', > 'IOError', 'ImportError', 'IndexError', 'KeyError', 'KeyboardInterrupt', > 'LookupError', 'MemoryError', 'NameError', 'None', > 'NotImplementedError', 'OSError', 'OverflowError', 'RuntimeError', > 'StandardError', 'SyntaxError', 'SystemError', 'SystemExit', > 'TypeError', 'ValueError', 'ZeroDivisionError', '__debug__', '__doc__', > '__import__', '__name__', 'abs', 'apply', 'buffer', 'callable', 'chr', > 'cmp', 'coerce', 'compile', 'complex', 'delattr', 'dir', 'divmod', > 'eval', 'execfile', 'exit', 'filter', 'float', 'getattr', 'globals', > 'hasattr', 'hash', 'hex', 'id', 'input', 'int', 'intern', 'isinstance', > 'issubclass', 'len', 'list', 'locals', 'long', 'map', 'max', 'min', > 'oct', 'open', 'ord', 'pow', 'quit', 'range', 'raw_input', 'reduce', > 'reload', 'repr', 'round', 'setattr', 'slice', 'str', 'tuple', 'type', > 'vars', 'xrange'] > >>> range > > >>> del > File "", line 1 > del > ^ > SyntaxError: invalid syntax > > > Sent via Deja.com http://www.deja.com/ > Share what you know. Learn what you don't. From jam at newimage.com Fri Jun 4 10:56:31 1999 From: jam at newimage.com (jam) Date: Fri, 4 Jun 1999 10:56:31 -0400 Subject: Competing algorithms... In-Reply-To: ; from Magnus L. Hetland on Fri, Jun 04, 1999 at 02:44:13PM +0200 References: Message-ID: <19990604105631.F24062@toast.internal> On Fri, Jun 04, 1999 at 02:44:13PM +0200, Magnus L. Hetland wrote: > > Yay! > > I have managed to get the course on algorithms here at the university > to use Python as its language! > woowoo! ;) > Now, I have to find some cool uses for it :) I am planning on setting > up some programming competitions as a part of the course; i.e. > students send their algorithms (in Python) to a (rexec-) server which > benchmarks them and ranks them. So... Have you got any good ideas for > fair benchmarking? > hmm.. well, not really. I didn't find computing big-oh an exciting part of school. ;) > The evaluation should preferrably be done automatically, so the only > thing I can think of is straight benchmarking baset on clocking and > test cases... But is this a good and fair measure of how good the > algorithm is? (Of course, a O(n) algorithm would probably out-perform > an O(n^2) algorithm...) > > It might also be possible to do manual evaluation of the best ones, or > something - or to have a separate prize for beautiful programs... > Anything is possible... > > eagerly-awaiting-several-exciting-suggestions-ly y'rs > > -M my idea would be to make a way to let the *students* rank themselves.. get them to come up with a way to evaluate their peers.. this way the ones that latch onto it quickly will end up teaching the ones that aren't as far along yet.. and they will learn a lot more by seeing sometimes completely different ways to solve the same problem. put the survey system up on the web.. you can make a form that will allow them to post their code.. make something that lets them authenticate to the system some how (simple password will do), then after the assignments have been turned in they rank the code of their peers based on some criteria (and have the students come up with that, too).. say, a ranking system. you (as the organizer) get to have the final call on what the grade is, so you can catch problems before they become a problem.. the goal is to stir discussion in class about *why* a certain algorithm is 'better'.. maybe one is way faster, but far less beautiful, but no less correct than someones elses beautiful-but-not-yet-fast-enough version-- they both deserve a passing grade, but for different reasons. setting-the-wheels-in-motion-ly y'rs, J ;) -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 210 bytes Desc: not available URL: From dank at deming.com Fri Jun 25 21:58:26 1999 From: dank at deming.com (dank at deming.com) Date: Sat, 26 Jun 1999 01:58:26 GMT Subject: getting memory information under NT References: <002201beab54$66218d30$f29b12c2@pythonware.com> <003301beab56$88cb3af0$f29b12c2@pythonware.com> <375E88A2.68C1F118@opticominc.com> Message-ID: <7l1c3v$l3o$1@nnrp1.deja.com> In article <375E88A2.68C1F118 at opticominc.com>, Eric Renouf wrote: > Does anyone know of an easy way to get the the total physical memory > and/or available memory on an NT system using Python 1.5.2? Is there a > module that has functions for things like this already? > > Thanks, > Eric Renouf > See function CeGlobalMemoryStatus() in module wincerapi, part of the Python Win32 Extensions by Mark Hammond. It is in the win32all download available from www.python.org. There is an example of usage in demos\cerapi.py. The win32 extensions also provide an interface to get performance monitor data, which has several additional measures of memory usage. Good luck, Dan Knierim Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From gherron at aw.sgi.com Tue Jun 15 12:46:23 1999 From: gherron at aw.sgi.com (Gary Herron) Date: Tue, 15 Jun 1999 16:46:23 GMT Subject: Tk Scrollbar References: <37663C34.2957622F@dlr.de> Message-ID: <3766835F.9C3DDB9C@aw.sgi.com> Sven Drescher wrote: > > Hi! > I have only an easy question. I think it is possible to bind a scrollbar > and an other widget e.g. a frame with buttons. But I have not found any > literature or programming examples. I want to bind the scrollbar to an > frame and I don't know how. Please help me. > Thanks for links and Python-code or other help. > > Sven The communication between a widget and a scrollbar is carried out by two procedures: 1. The scrollbar calls the widget's "yview" (or "xview") method to cause it to scroll to a new position. 2. The widget calls the scrollbar's "set" method to indicate to invoke a change in the sliders position or size. The only widgets which implement the "yview" method are "Canvas", "Listbox", and "Text". (And to be very clear here, this implementation and the connection between the two widgets is at the tcl/tk level.) So... To add scrolling capabilities to an arbitrary widget, you would need to implement the "yview" command (in its several versions) on the widget. I don't know if this would need to be implemented in tcl, or if you could rig things so that the scrollbar's call to "yview" would come all the way back into python so that you could implement it in python. -- Dr. Gary Herron 206-287-5616 Alias | Wavefront 1218 3rd Ave, Suite 800, Seattle WA 98101 From xhyuan at oe.fau.edu Fri Jun 4 09:29:12 1999 From: xhyuan at oe.fau.edu (Xiaohong Yuan) Date: Fri, 4 Jun 1999 06:29:12 -0700 (PDT) Subject: ask help for problem with static linking (fwd) Message-ID: I am trying to link my c extension module staticly with python interpreter. But in my c extension module, I have external variable declaration, which makes it fail to be linked with Python interpreter. There must be some way to solve this, could anybody help me with this? Thank you very much. Xiaohong Yuan -- http://www.python.org/mailman/listinfo/python-list From clarence at silcom.com Wed Jun 16 01:24:58 1999 From: clarence at silcom.com (Clarence Gardner) Date: Wed, 16 Jun 1999 05:24:58 GMT Subject: Compiled main program Message-ID: [Clarence, posting a request for help managed to find the solution before committing himself -- but he's posting it anyway (with his solution) just to see what people think...] One of the applications that I've written in Python (in fact, the first big one, a billing system for ISPs in operation for about two years now) consists of about 120 main programs, all running via CGI. There is one that is particularly larger than the rest (the main program is about 900 lines; all the rest are less than 400) and, unlike the others, is used in a very 'interactive' way; that is, you'll have hundreds or maybe thousands of http transactions between your browser and it over the course of a half hour or an hour. Today I finally got around to something that's bugged me for a long time, namely, the fact that Python is compiling that program every one of those hundreds of times. So I tried the obvious: $ cat nph-pmtbatch #!/usr/local/bin/python import PmtBatchGuts $ This worked fine (and with a noticeable speed increase) until the execution path happened to intersect with one of various spots in my various modules that reference a name in __main__ (it's an object that gives access to the context of a login session). Hoping against hope, I made sure nobody was looking and put this at the top of PmtBatchGuts.py: # Because this is really a main, but pre-compiled, program __name__ = '__main__' Didn't think it would work, and it didn't. I figured that what I really wanted to do was mess with sys.modules somehow, but I don't know how to get a reference to the current module. I assume that sys.modules['__main__'] = would do it. As distasteful as that is (do I hear retching in the back of the room?), I like it much more than changing S = Session.Session() to __main__.S = Session.Session() Remembering that people have on occasion mentioned attributes that seem to be invisible unless you know they're there, I've just been trying random things and came up with this: $ cat PmtBatchGuts.py import sys class MakeMeMain: def __init__(self): sys.modules['__main__'] = sys.modules[self.__module__] x = MakeMeMain() del x import Session S = Session.Session() ... This works, but I'm interested in the what the community thinks of it. TIA -- -=-=-=-=-=-=-=-= Clarence Gardner AvTel Communications Software Products and Services Division clarence at avtel.com From nathan at islanddata.com Tue Jun 22 13:31:49 1999 From: nathan at islanddata.com (Nathan Clegg) Date: Tue, 22 Jun 1999 10:31:49 -0700 (PDT) Subject: renegotiating socket connections Message-ID: I'm writing a server application in python. I understand that most servers fork off a process for every incoming connection and then renegotiate on a different port to free up the well-known server port. I would rather do a multithread model than a forked process model because of shared memory needs. I've heard that forking the process "automatically" renegotiates the port somehow, but that doesn't make much sense to me. More importantly, since I don't want to fork at all, how does one switch to a different port? Is this a manual process? It seems it would be slow to have so much round-trip communication before even establishing a connection, and none of my network manuals say anything more than this sort of thing "happens." Any tips? ---------------------------------- Nathan Clegg nathan at islanddata.com From csdayton+usenet at cs.uchicago.edu Thu Jun 17 18:39:43 1999 From: csdayton+usenet at cs.uchicago.edu (Soren Dayton) Date: Thu, 17 Jun 1999 22:39:43 GMT Subject: Why is tcl broken? References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> <37682DD3.43923243@compaq.com> Message-ID: Greg Ewing writes: > Fernando Mato Mira wrote: > > > > I wanted to find out whether the disgust for tcl I've seen many people > > express had some basis on some generally accepted principles. > > I think I can give some reasonably objective reasons why > I find that I enjoy using Python in a way that I don't > enjoy using Tcl. (I have used both, and in one case have > written versions of the same program in both languages.) > > 1. Syntax > > Tcl's syntax is based on the principle that an unadorned > sequence of alphanumeric characters represents a literal. > Anything else (such as referring to a variable) requires > extra syntax. > > Ousterhout's justification is that this is optimal > for entering commands interactively, which is probably true. > However, this seems to me the wrong thing to optimise for, > given that tcl is meant to be a *programming* language. > The case being optimised for -- typing in a command which > is to be used once and thrown away -- simply doesn't occur. > Programs, even tiny ones, get used more than once! but it occurs to me that this is a GOOD argument for the best uses of tcl, that is as an interactive style shell or scriptable configuration file language. tcl _IS_ too annoying to do real programming in, but it is not clear that it is not _by far_ the best tool for this kind of niche use. (Yes, I've heard about guile, but frankly, tcl looks like my ipfilter configuration files and we are _NOT_ after expressibility here but a sort of clarity) Soren From paul at prescod.net Wed Jun 2 09:50:58 1999 From: paul at prescod.net (Paul Prescod) Date: Wed, 2 Jun 1999 13:50:58 GMT Subject: Alien whitespace eating nanovirus strikes again! References: <375500C9.742DC539@pop.vet.uu.nl> Message-ID: <375536C2.DD917F99@prescod.net> Martijn Faassen wrote: > > Hi there, > > I don't intend to start a flamewar or anything, and I'm sure Larry Wall > is a nice guy, and Perl is nice and all, and the postmodern > rationalisation of the confusion that Perl is to me is *fun* (but does > not work for me), but Larry Wall seems to be infected by the whitespace > eating nanovirus meme. The first time he mentioned this I thought he was joking. He attached a "Hi Guido!" to indicate that he was. Now it seems he is serious. He thinks that whitespace usage somehow goes to the heart of the way Python programmers think about their craft -- as if in Python, whitespace is as central as object orientation is in Java. A language designer should have a better feeling for what is essential about a language and what is trivial -- especially since he whines that people judge Perl too quickly based on its dollar signs. If we were as fair to Perl as he is to Python we would call it "Perl: the curly bracket and dollar sign language." I consider it a compliment that he can't find anything real to point out as Python's contribution to language fascism but I also find it distressing that he feels the need to sow the seeds of fear, uncertainty and doubt in the minds of would-be Python users. The Python feature that most of us (in retrospect, unnecessarily) worry about before trying Python is the whitespace handling. Larry can only turn people off of Python by suggesting that that is Python's central feature or philosophy. This whole modern, postmodern distinction is bogus anyhow. Almost every language designer has a bone to pick with history and they are all pushing some meme. They are all "modern" in this sense. Perl's meme is that lexical flexibility overrides all other concerns. It is "classically modern" for the promoter of an ideology (in this case, TMTOWTDI) to disclaim adherence to an ideology and claim inspiration in the natural world: "Capitalism is just how things work. Perl works just like human languages!" It is also charmingly modern to ignore the unintended consequences of ideology: unreadable code, expensive maintenance, wasted money and wasted time. Just as with communism, the difficulty of truly measuring productivity will hide the problems for a while but eventually the house will topple. Now compare a Wall interview to one with Guido. Does Guido point to some overriding ideology that makes Python great? Object Orientation? TMTOWTDI? Whitespace? He promotes Python as a nice language that tries to incorporate many neat features from other languages, to remain easy for beginners and to scale nicely to complex problems. There is no single dominant philosophy similar to TMTOWTDI that drives Python's growth. Or one might say that Python's dominant philosophy is Aristotle's Golden Mean. Or perhaps Python's philosophy is that code is communication and readable code is clear communication. But even so, Python has many features that exchange readability for flexibility... I truly think that Perl is a unique and innovative language. Larry can promote it without playing on people's fears of whitespace and fascism. -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco "Silence," wrote Melville, "is the only Voice of God." The assertion, like its subject, cuts both ways, negating and affirming, implying both absence and presence, offering us a choice; it's a line that the Society of American Atheists could put on its letterhead and the Society of Friends could silently endorse while waiting to be moved by the spirit to speak. - Listening for Silence by Mark Slouka, Apr. 1999, Harper's From mwh21 at cam.ac.uk Mon Jun 21 19:17:54 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 22 Jun 1999 00:17:54 +0100 Subject: choosing random numbers with weights/probability? References: <929987267.6227@www.remarq.com> Message-ID: kevinsl writes: > I've been using the whrandom.choice routine and it's very > useful. But is there any way to add weights or > probabilities of being chosen to the items in the list? > > example: > > list=['one','two','three'] > item=whrandom.choice(list) > > Is there any way to say that 'one' and 'two' have a 25% > chance of being chosen, and 'three' has a 50% chance? One very obvious, not very extensible, way: list=['one','two','three','three'] item=whrandom.choice(list) (NB: list is a builtin; using list as a variable name can lead to confusion) A not very efficient but more general method: def weighted_choice(choices): tot = 0 for w,v in choices: tot = tot + w d = random.random()*tot tot = 0 for w,v in choices: tot = tot + w if tot > d: return v list=[(0.25,'one'),(0.25,'two'),(0.5,'three')] weighted_choice(list) seems to work. Haven't tested it much, so please don't rely on it... HTH Michael > I'm hoping there's already a module to do this... or else > I'll be writing my own.. > > thanks, > > Kevin From da at ski.org Tue Jun 29 14:50:35 1999 From: da at ski.org (David Ascher) Date: Tue, 29 Jun 1999 11:50:35 -0700 (Pacific Daylight Time) Subject: BOFs (Birds-Of-a-Feather) sessions at the Monterey Python conference Message-ID: As you may know, O'Reilly & Associates is organizing a Python Conference as part of its Open Source Convention in Monterey in August. (For more information, see http://conferences.oreilly.com). Early word from O'Reilly is that the Python conference is getting quite a few early registrants eager to get the discount & free t-shirts! In addition to the tutorials, talks and panels, there will be informal "Birds-Of-a-Feather" sessions in the tradition of Usenix BOFs. These meet at "off" times: Saturday and Sunday from 7pm to 10pm, and Monday from 8pm to 10pm -- meeting spaces will be made available by ORA. The format for these is deliberately left up to the birds -- however, one or more organizers are expected to show up and help lead discussions. I'd like to solicit discussion on what BOFs would be good to organize, and find some organizers. Topics that come to mind include field-specific BOFs such as a Zope BOF, an image-processing BOF, a database BOF, etc., tool-BOFs (Tkinter, wxPython, ...) or "market segment" BOFs such as "Python in Education", "Selling Python programs", etc. Other ideas are welcome. Anyone can register a BOF through ORA's website at http://conferences.oreilly.com/bof/, but it might make sense to talk about it on the mailing list first to minimize overlaps and work out scheduling. If a BOF is scheduled by July 15, it will be included in the conference program given to attendees. BOFs can be scheduled later, and will be available on the conference website (as well as onsite, I imagine). Looking forward to seeing many of you there, --David Ascher & the rest of the Python Conference Organizing Committee PS: If you have any questions about the Python conference, you can contact the conference staff at oscon at oreilly.com or you can contact me at da at python.net. In addition, the folks at oscon at oreilly.com can mail you a nifty glossy printed brochure showing the entire schedule of the convention, all the talk descriptions, etc. From kjwolf at online.de Sat Jun 19 15:32:30 1999 From: kjwolf at online.de (Klaus-Juergen Wolf) Date: Sat, 19 Jun 1999 21:32:30 +0200 Subject: Curses for MSDOS References: <376BD33B.5A6F54BB@erols.com> Message-ID: Swartz wrote: > Is there anything like curses for MS-DOS? Thanx. I know of PC-Curses. Written in the early 80s. Maybe someone has extended it, but in the state I had seen it had no NCurses extensions and wouldn't work with Python. Probably very few people used it, because that screen access mechanism was relatively slow on MS-DOS. cu k.j. From def-p at usa.net Fri Jun 18 17:54:11 1999 From: def-p at usa.net (Def P) Date: Fri, 18 Jun 1999 21:54:11 GMT Subject: Tkinter & socket question Message-ID: <19990618215411.23898.qmail@nwcst277.netaddress.usa.net> Hello, I am writing a little chat program in Python and Tkinter. I can't figure out two things though: 1) When there's no connection, I don't want people to use the Entry on the window (which is used to enter text and send it after pressing Enter). So, I want to disable it. I used entry.state = DISABLED, but I still can enter text. Is this normal? Is there a way to make it "unusable"? 2) I need to poll the connection periodically, say, every second. This would not have been a problem in console mode... I don't know how to do this in a Tkinter environment though. So, how can I do something every second (or every n milliseconds, or whatever the time span may be)? Are threads the way to go? I haven't used them before. Thanks, Def P ____________________________________________________________________ Get free e-mail and a permanent address at http://www.netaddress.com/?N=1 From rozzin at geekspace.com Fri Jun 25 19:27:19 1999 From: rozzin at geekspace.com (Joshua Rosen) Date: Fri, 25 Jun 1999 19:27:19 -0400 Subject: Could someone please give an example? References: <7kqpu8$7u1$1@nnrp1.deja.com> <3771127C.E40F9BF3@home.com> <7kvd8b$ueb$1@nnrp1.deja.com> Message-ID: <37741057.83741A41@geekspace.com> Emile van Sebille wrote: > > I'm new at this, but it seems I've read that the tracestack is > available. Might it be possible to read in the calling line number, > then parse the source code for your 'name'? Sure, but what'd be the point? Let's say that you define a function to tell you the name: def tn(inst): .... Now, if you can call that function, with an instance as an argument, then you already know what `name' you are calling it by. If you've got an instanced produced and `stored' by something like... class C: ... i = C() ... then you need to call `tn(i)'--there you go, "i" is the name of the class, eh? If you want the program to decide which variable to look at, then you need to use something like `eval(XXX)', where `XXX' is an expression that returns a string, so, if you want to know the `name' of the variable, there, then you can just turn to whatever `XXX' returned. I've yet to see a reason why this `finding the name of an instance' is needed, or what it accomplishes. Just by virtue of `the only name that an instance has is what you give it', there really /shouldn't/ be a problem--if you give it a name, you should be able to `remember' what the name is, or at least where you stored it. Would someone please give an example of the use of this, assuming that we have a function that does it (say..., `tn(xxx)')? -Rozzin. From quinn at auto.ugcs.caltech.edu Wed Jun 23 19:53:28 1999 From: quinn at auto.ugcs.caltech.edu (Quinn Dunkan) Date: 23 Jun 1999 23:53:28 GMT Subject: file system quotas References: Message-ID: On Mon, 21 Jun 1999 18:53:45 +0200, vmas wrote: >Hi, >I'm using Python for writing system administration scripts with a Unix >system and I'd like to set quota limits for a given user. Do you know how >to manipulate the file system quotas using Python? Or, is there a >Quota module in Python? >Thanks. Various unices all seem to have their own way to do quotas. Under Irix I use os.system() and os.popen() to run the apropriate commands. Generally, if you're doing shellish sorts of things, these two functions are your friends. From hniksic at srce.hr Sat Jun 5 14:30:40 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 05 Jun 1999 20:30:40 +0200 Subject: Deleting characters from a string References: <000101beaf74$646413e0$8c9e2299@tim> Message-ID: <87bteu1ovj.fsf@pc-hrvoje.srce.hr> "Tim Peters" writes: > It's (yours, not mine ...) a decent idea; in the meantime how about > writing a little wrapper > > def deletechars(s, todelete, id=string.maketrans('', '')): > return string.translate(s, id, todelete) I think I'd rather write a patch that allows None as the second argument to string.translate(), if that's OK with the developers. Thanks for the tip, though. From graham at sloth.math.uga.edu Thu Jun 3 18:07:00 1999 From: graham at sloth.math.uga.edu (Graham Matthews) Date: 3 Jun 1999 22:07:00 GMT Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7j66b7$il5$2@cronkite.cc.uga.edu> <3756C693.2C910B29@usa.net> <7j6jnl$58f$3@cronkite.cc.uga.edu> Message-ID: <7j6ua4$fp6$1@cronkite.cc.uga.edu> Graham Matthews wrote: >Why is it so hard for people to see that adding a mark sweep collector >*ON TOP OF* the existing ref count scheme essentially changes nothing. >All the current ref count behaviour that people love will stay. The >only additional behaviour will be that circular refs are mopped up >correctly. Aahz Maruch (aahz at netcom.com) wrote: : I don't disagree with this; I only claim that GC should only happen by : explicit call from the programmer. I also claim that there should be a : debug mode for GC that merely informs the programmer about cyclic : references so that zie can locate their source (and that this should be : the primary mode for GC). I don't understand why you want GC only by explict call and in "inform" mode only? graham -- The fool escaped from paradise will look over his shoulder and cry Sit and chew on daffodils and struggle to answer why? From graham at sloth.math.uga.edu Fri Jun 4 10:45:04 1999 From: graham at sloth.math.uga.edu (Graham Matthews) Date: 4 Jun 1999 14:45:04 GMT Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <87pv3iq6ss.fsf@ev.netlab.co.jp> <3752C76D.604CD474@prescod.net> <87n1ykr0z9.fsf@ev.netlab.co.jp> <375372F6.A874554@prescod.net> <7j34l3$hbj$1@nnrp1.deja.com> <7j66b7$il5$2@cronkite.cc.uga.edu> <3756C693.2C910B29@usa.net> <7j6jnl$58f$3@cronkite.cc.uga.edu> <3757C181.477E0BD5@inrialpes.fr> Message-ID: <7j8opg$55v$3@cronkite.cc.uga.edu> Graham Matthews wrote: > Why is it so hard for people to see that adding a mark sweep collector > *ON TOP OF* the existing ref count scheme essentially changes nothing. > All the current ref count behaviour that people love will stay. The > only additional behaviour will be that circular refs are mopped up > correctly. Vladimir Marangozov (Vladimir.Marangozov at inrialpes.fr) wrote: : Why don't you try implementing it? : There's nothing more convincing than good working code. : : If you try, I suspect that not we, but you'll realize that it's not so : immediate and that there would be other additional effects, either : inacceptable or undesirable. How does one respond to the above? The old "I suspect" line. Well I don't suspect because: a) many many languages have garbage collection outlined exactly as I have proposed and they all work just fine. b) I work on a product which pretty much does exaclty what I outlined for a collection scheme, and it works beautifully. Moreover it contains many similarites with Python (the need to interface to C, complex objects, etc). c) I have implemented 3 collectors in my "coding life", so I have some experience. You on the other hand just "suspect that I will realise that it's not so immediate"? Do you have any basis for these suspicions? For example have you ever implemented a reference counting mark sweep collector, maybe with colouring. I am sorry to sound sooo sarcastic, but what can I reply to "I suspect ...". I put up facts, and you put up "I suspect ..." : graham -- A cat named Easter He say "will you ever learn" Its just an empty cage girl If you kill the bird From tim_one at email.msn.com Wed Jun 23 23:43:37 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 23 Jun 1999 23:43:37 -0400 Subject: Python Exes! In-Reply-To: <%fhc3.2901$Lk4.35205@news4.mia> Message-ID: <000401bebdf3$be7e3f80$549e2299@tim> [SunitJoshi] > Could someone please point me to the URL where Gordon Mcmillians, > installer is located. Start at http://www.mcmillan-inc.com/python.html would-be-more-specific-but-the-server-appears-to-be-resting-ly y'rs - tim From chriseb at nortelnetworks.com Mon Jun 14 11:52:15 1999 From: chriseb at nortelnetworks.com (Chris Ebenezer) Date: 14 Jun 1999 16:52:15 +0100 Subject: Why is tcl broken? References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> Message-ID: Fernando Mato Mira writes: : of folks end up using one or another GNU tool. As a side effect, some : newcomers to Tk that would have normally used tcl could end up going : the STk way (unfortunately, STk is not publicized enough). Things like : Kawa also increase the feel of security regarding code reusability. : And some of those people will end up wanting to write full-fledged Why use TK at all ? Once you are using scheme anyway there are nicer widget toolkits to use (from a point of view of more "normal" looking toolkits that don't suffer from color allocation problems), there are bindings for guile and gtk and guile and Qt. -- chris From robin at alldunn.com Tue Jun 29 03:07:59 1999 From: robin at alldunn.com (Robin Dunn) Date: Tue, 29 Jun 1999 00:07:59 -0700 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> Message-ID: Jeffrey Chang wrote in message ... >On Fri, 25 Jun 1999, Mikael Lyngvig wrote: >> I'd like some discussion on whether or not it is a good idea to >> abandon TkInter, before it gets too widely used, and instead adopt >> wxPython as the primary GUI framework for Python. > >Abandoning Tkinter seems a little bit extreme, since there are some >applications for which its event model is well-suited. > >A few weeks ago I needed to build a viewer that displays binary trees >whose branches have variable lengths (actually, phylogenetic trees for >biological data). Since the trees are large, I need to be able to slide >it around the window. In addition, I needed each node to be clickable so >that the user can query for more data. > >Tkinter is very good for that type of thing. All I needed to do was >create a Canvas and then for each node, create an Oval with a callback to >a function that handles node clicks. Tk keeps track of the coordinates of >each Item so that I don't have to. Also, whenever I wanted to move the >tree, all I had to do was: >for widget in self._canvas.find_all(): > self._canvas.move(widget, xoff, yoff) > >Of course, Tk incurrs an overhead by making everything you draw on the >canvas its own object, but for this case, it made thigns a lot easier. > >Although I haven't used wxWindows before, but the documentation suggests >that it would be a lot more difficult for this kind of application. In >wxWindows, I would need to draw each of my nodes into a window using a >device context. Then, I'd have to write a function that would handle >mouse clicks in the window. That function would need to get the >coordinates and then figure out whether it intersects with any of my >nodes, which Tk would've handled for me. In addition, whenever I wanted >to move the tree, I'd have to erase the window and redraw each node. If I >wanted that optimized, I'd need to write routines that would only redraw >the uncovered parts of the tree, which means figuring out which nodes are >newly revealed. > >From what other people have said about wxPython, it seems like it may be >appropriate for other types of applications. However, I'd hate to see >Tkinter dumped because it's not appropriate for everything! > >Jeff > From lull at acm.org Thu Jun 17 23:34:29 1999 From: lull at acm.org (John Lull) Date: Fri, 18 Jun 1999 03:34:29 GMT Subject: Newbie Q: How to call unmodified VB DLL from Python Message-ID: <3769bcd1.54492213@news.earthlink.net> As a first Python project, I'd like to use Python (or JPython) to automate some hardware testing under Win95/98/NT. The hardware in question is run by a DLL written in VB, and to which I do not have source. "Extending & Embedding the Python interpreter", ch. 3, has instructions for building a DLL which will work, but assumes you're working in VC++ and have the source. If anyone could point me toward instructions on how to make this work, I'd be grateful. Thanks. Regards, John From nospam at bitbucket.com Wed Jun 23 19:07:28 1999 From: nospam at bitbucket.com (Phil Mayes) Date: Wed, 23 Jun 1999 16:07:28 -0700 Subject: Freeze? References: <7kqcj4$3bd$1@nnrp1.deja.com> Message-ID: <1Ndc3.648$dR.53682@newsfeed.avtel.net> Curtis Yanko wrote in message <7kqcj4$3bd$1 at nnrp1.deja.com>... >I have loaded 1.5.2 and the Win32All-125 but dont see the freeze tool >anywhere. Searching the FTP site I only see Freeze for older versions. >Hopefully I'm just confused but if somebody could give me a nudge I'd >appreciate it. It's not in the Python binaries - you need to get the Python source (you won't need to build it, though). -- Phil Mayes pmayes AT olivebr DOT com From bwarsaw at cnri.reston.va.us Tue Jun 8 11:01:48 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Tue, 8 Jun 1999 11:01:48 -0400 (EDT) Subject: waste of resources ? References: <375C0F91.1C73E4E3@icrf.icnet.uk> <375C16A9.5ADC4990@icrf.icnet.uk> <375C2003.B01BEC3@arlut.utexas.edu> <87yahvzqz3.fsf@pc-hrvoje.srce.hr> <14172.34081.978798.911000@anthem.cnri.reston.va.us> <87n1ybxj3c.fsf@pc-hrvoje.srce.hr> Message-ID: <14173.12380.479032.202036@anthem.cnri.reston.va.us> >>>>> "Hrvoje" == Hrvoje Niksic writes: Hrvoje> It probably didn't exist in Python 1.5.1, under which I Hrvoje> was writing the code in question. Oops, yes, EnvironmentError showed up in 1.5.2a1 -Barry From lutz at rmi.net Fri Jun 11 14:07:42 1999 From: lutz at rmi.net (Mark Lutz) Date: Fri, 11 Jun 1999 18:07:42 GMT Subject: "Programming Python" still worthwhile? Message-ID: <199906111807.MAA13401@shell.rmi.net> Curtis Yanko writes: > > Isn't PP due for 2nd edition soon? Frank Willison, O'Reilly's editor-in-chief, posted a few words on this subject at: http://www.oreilly.com/frank/python.html An update will happen, but we're not yet sure about the timing. Given the way publishing works, even if an update was started today, it probably wouldn't show up until early 2000 at best. Depending on 2.0's release, that could make the update out of date in a year or less. Given that, I doubt a 2nd edition will appear very soon. OTOH, I may move up the schedule if 2.0 turns out to be far away or mostly compatible with 1.6. I may also move it up if I get bored with between-books slacking, but that seems much less likely ;-). For the time being, I maintain a list of recent Python changes--which are mostly minor, in terms of the core language--at my web site: http://rmi.net/~lutz/errata-python-changes.html Consider it a new appendix. --Mark Lutz (http://rmi.net/~lutz) From gmcm at hypernet.com Wed Jun 16 12:25:57 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 16 Jun 1999 11:25:57 -0500 Subject: GC In Python: YAS (Yet Another Summary) In-Reply-To: Message-ID: <1282571877-108998356@hypernet.com> Darrell writes: > Guido's idea sounds least intrusive. > > Is there any merit to building a tool to tell me if I have cycles > and where they are ? Then I apply one of N strategies to kill them. > > How often does the normal Joe have or care that he has cycles ? I > find them hard to track down. Check out Lars's plumbo.py: - Gordon From falk.hueffner at student.uni-tuebingen.de Tue Jun 8 07:38:16 1999 From: falk.hueffner at student.uni-tuebingen.de (Falk Hueffner) Date: 08 Jun 1999 13:38:16 +0200 Subject: Higher level FTP lib? Message-ID: Hi, I wonder if there is a FTP module for python that allows for higher level operations than ftplib. With ftplib, I have to parse LIST lines myself (footnote: is there a module for *that* like perl's File::Listine?) if I want to know file size or date. Due to the OO nature of Python I was pretty sure the FTP library would make FTP sites look like local directories. Would be really nice. Falk From c.kotsokalis at noc.ntua.gr Sun Jun 6 13:33:50 1999 From: c.kotsokalis at noc.ntua.gr (Constantinos A. Kotsokalis) Date: 6 Jun 1999 17:33:50 GMT Subject: oh, python gurus, shall thy help a beginner? Message-ID: Heya, I've started with python and I've written the following script. It is supposed to use (a subclassed) ThreadedTCPServer and act like a little proxy server. It is working perfectly on linux where I am mainly developing it, but it denies to work properly under Solaris (at least 2.7 which I tried it on). I even recompiled Python, using gcc one time, SUN cc the other, trying with statically linked/shared modules, anything I could think of. It simply does not work. In both cases, it's threaded python 1.5.2. What happens under Solaris, is that the server starts all right, seems to be waiting for connections, but when I try to connect to that port it fails (connection refused). The 2 or 3 times that it _did_ connnect, the process was taking up to 95% of the CPU usage time right after (and then started not to accept connections again). I really can't find out anything, so if any of you might know what's wrong (or even speculate about it), please reply. Thanks! Costas PS: Any other suggestions are also welcomed, as well as code contributions :-) This software acts like a proxy server that will leave advertisment banners out of your sight, when browsing. If anyone is interested in using it, the full distribution is at http://www.softlab.ece.ntua.gr/~ckotso/CTC/ -----------------------START OF SCRIPT-------------------------- #!/usr/bin/env python import os, time, re, SocketServer, urlparse, string, os, sys try: import thread except: print "You do not have a thread-enabled Python version." print "Please download and (re)compile the latest Python" print "version -- 1.5.2 at the moment -- with thread support." print "You will need to use the --with-thread option when you" print "./configure it.\n" sys.exit(0) from socket import * def SocketErrorMsg(msg, rem_srv, rem_port): err_htm_file = open(ERROR_HTML_FILE, "r") err_msg = err_htm_file.read(ERROR_HTML_SIZE) err_htm_file.close() err_msg = string.replace(err_msg, '%SERVER', rem_srv) err_msg = string.replace(err_msg, '%PORT', `rem_port`) err_msg = string.replace(err_msg, '%ERROR', `msg`) err_msg_size = len(err_msg) return_buff = "HTTP/1.1 403 ERROR\nServer: Cut The Crap\nContent-Length: "+`err_msg_size`+"\nContent-Type: text/html\nProxy-Connection: close\n\n\n" return_buff = return_buff+err_msg return return_buff class MyTCPServer(SocketServer.ThreadingTCPServer): def server_bind(self): self.socket.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) self.socket.bind(self.server_address) class handle_con: def __init__(req, sock, remaddr, srv): rhost, rport = remaddr req.proc_req(sock) def w_configure(self): None # This will be used for web-based configuration def proc_req(self, sock): buff = sock.recv(BUFF_SIZE) if not len(buff): sys.exit(0) if string.find(buff, "POST ") == 0: time.sleep(1) # Sleep one sec to make sure all POST info has come sock.setblocking(0) try: while (1): buff = buff + sock.recv(BUFF_SIZE) except: None sock.setblocking(1) tokens = string.split(buff) if cre.search(tokens[1]): sock.send(ADV_RET_BUFF) sock.send(retgif) sys.exit(0) if ((tokens[1] == "http://ctc/") or (tokens[1] == "http://CTC/")): self.w_configure() # Not used yet sys.exit(0) server = socket(AF_INET, SOCK_STREAM, 0) if not len(PARENT_PROXY_HOST): url_tuple = urlparse.urlparse(tokens[1]) host_port = url_tuple[1] if (string.find(host_port, ':') != -1): rem_srv, rem_port = string.split(host_port, ':') rem_port = string.atoi(rem_port) else: rem_srv, rem_port = host_port, 80 if (len(url_tuple[4])): buff = string.replace(buff, tokens[1], url_tuple[2]+'?'+url_tuple[4]) else: buff = string.replace(buff, tokens[1], url_tuple[2]) else: rem_srv = PARENT_PROXY_HOST rem_port = PARENT_PROXY_PORT try: server.connect(rem_srv, rem_port) server.send(buff) retval = server.recv(BUFF_SIZE) while (retval): sock.send(retval) retval = server.recv(BUFF_SIZE) server.close() except error, msg: sock.send(SocketErrorMsg(msg[0], rem_srv, rem_port)) sock.close() sys.exit(0) VERSION = '0.2.4' BIND_PORT = 5050 PARENT_PROXY_HOST = '' PARENT_PROXY_PORT = 8080 WISH_FORK = 0 RETURN_GIF = "/usr/local/etc/white.gif" ERROR_HTML_FILE = "/usr/local/etc/ctc_error.html" cre_str = "\/ad\/|\/ads\/|\/ads2\/|\/ad\.|\/ads\.|\/ads2\.|\.ad\.|\.ads\.|\/ads1\.|\.ads1\.|\/adv\/|\/cadv\/|\/adserver\.|\/adlog\.|\.adbannercenter\.|\/nsads\.|adclick\.|\/banner\.|\/banner\/|\/adverts\/|\.linkexchange\.|\/acc_clickthru|\/adfinity|event\.ng|\/surfad|\/redirect\.|\/gen_addframe|\/m\=|\/ad\=|\/adclick\.|\/adfu\.|\?adnum\=|\.adzerver\.|\?advert\=|\/advert\/|\/SHOP\/|\/advertiser\/" if (len(sys.argv) > 1): try: cf = open(sys.argv[1], "r") except: sys.stderr.write("Cannot open configuration file "+conf+"\n") sys.exit(0) lines = cf.readlines() cf.close() for line in lines: line = string.strip(line) if (len(line) == 0) or re.search("\s*#", line): continue if string.find(line, '#'): ltmp = string.split(line, '#') line = ltmp[0] tokens = re.split('\s+', line) if (tokens[0] == 'BIND_PORT'): BIND_PORT = string.atoi(tokens[1]) elif (tokens[0] == 'PARENT_PROXY_HOST'): PARENT_PROXY_HOST = tokens[1] elif (tokens[0] == 'PARENT_PROXY_PORT'): PARENT_PROXY_PORT = string.atoi(tokens[1]) elif (tokens[0] == 'WISH_FORK'): WISH_FORK = string.atoi(tokens[1]) elif (tokens[0] == 'RETURN_GIF'): RETURN_GIF = tokens[1] elif (tokens[0] == 'ERROR_HTML_FILE'): ERROR_HTML_FILE = tokens[1] elif (tokens[0] == 'BLOCK'): re_add = re.escape(tokens[1]) if (string.find(line, re_add) >= 0): continue cre_str = cre_str + '|' + re_add else: sys.stderr.write("Unknown option: "+tokens[0]+"\n") BUFF_SIZE = 8192 MAX_COMMAND_BUFF = 1024 tmpval = os.stat(RETURN_GIF) RETURN_GIF_SIZE = tmpval[6] tmpval = os.stat(ERROR_HTML_FILE) ERROR_HTML_SIZE = tmpval[6] ADV_RET_BUFF = "HTTP/1.1 200 OK\nServer: Cut The Crap\nContent-Length: "+`RETURN_GIF_SIZE`+"\nProxy-Connection: close\nContent-Type: image/gif\n\n" locf = open(RETURN_GIF, 'r') retgif = locf.read(RETURN_GIF_SIZE) locf.close() addr = '127.0.0.1', BIND_PORT srv = MyTCPServer(addr, handle_con) cre = re.compile(cre_str, re.I) if (WISH_FORK == 1): try: fv = os.fork() except: sys.stderr.write("Fork failed, exiting\n") sys.exit(0) if (fv != 0): #Father process sys.exit(0) else: None print "Cut The Crap -- Version "+VERSION+" \"Goin' down\" launched..." srv.serve_forever() ----------------------------END OF SCRIPT------------------------- -- Constantinos A. Kotsokalis || c.kotsokalis at noc.ntua.gr National Technical University of Athens Network Management Center Tel. No: +30 1 7721861 From sjturner at ix.netcom.com Mon Jun 7 17:24:33 1999 From: sjturner at ix.netcom.com (Stephen J. Turner) Date: Mon, 07 Jun 1999 17:24:33 -0400 Subject: Question about envvars References: <7jgl9n$p13$1@nnrp1.deja.com> <375BFE38.3FB3E83C@ix.netcom.com> <7jh7pc$as$1@nnrp1.deja.com> Message-ID: <375C3891.1D11E1A4@ix.netcom.com> Hi Rob, > Boy I was excited to get a reasonable explaination so quickly, but alas, > it still does not work. Here is my test script: > > #!/usr/local/bin/python > > import MDIreg > > reg = MDIreg.FileRegistry(1,1) > reg.exportEnvVars() > > import os > print "child has it : " > os.system("env | grep MDI_REG_VERSION") > print "but do I have it? :" > print os.environ['MDI_REG_VERSION'] > > --- > > I am interested in this "MDI_REG_VERSION" envvar which gets exported by > my library. Here is the output: > > child has it : > MDI_REG_VERSION=10.0 > but do I have it? : > Traceback (innermost last): > File "regtest.py", line 12, in ? > print os.environ['MDI_REG_VERSION'] > File "/usr/local/lib/python1.5/UserDict.py", line 12, in __getitem__ > def __getitem__(self, key): return self.data[key] > KeyError: MDI_REG_VERSION Oops! I just realized that the site module, which is imported by default when the Python interpreter starts, imports the os module -- so by the time your script begins to execute, it's already too late. Just for grins, you could try disabling the site module by adding the '-S' option to the Python command line, as in: #!/usr/local/bin/python -S I'm not advocating this approach, since it's generally a good idea to import the site module. I'd just like to know if it works for you. > Any other ideas? Any way to tell the os/posix module to "refresh"? None that I can see from looking in Modules/posixmodule.c. Sorry. > By the way, thanks for the library implementation suggestion, but I must > keep it the way it is, because other c, and c++ (at the class level) > programs access this library. OK, how 'bout this? Suppose you added a virtual "putenv" method to your FileRegistry C++ class whose default implementation was to call the global putenv function. Then in your Python C extension, you could subclass FileRegistry and override the putenv method with one that modifies os.environ as described in the prior post. Regards, Stephen -- Stephen J. Turner From claird at Starbase.NeoSoft.COM Thu Jun 10 08:07:41 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 10 Jun 1999 07:07:41 -0500 Subject: Using perl in python References: <7jjoqh$t56$1@nnrp1.deja.com> <6cs73.2432$nn.739920@news.shore.net> Message-ID: <7jo9qd$hgi$1@Starbase.NeoSoft.COM> In article <6cs73.2432$nn.739920 at news.shore.net>, Michael P. Reilly wrote: >Brenda wrote: >: I have a bunch of perl libraries that I would like to call in my python >: scripts. Is this possible? > >It is possible; Tkinter utilizes an embedded Tk interpreter. You >would have to write a Perl interpreter. There may be some people >around who might help you with that. I'm in the middle of embedding >another interpreter myself. > >I've found that it is more efficient (and more fun) to convert the >libraries to Python. The code is invariably clearer. . . . There's an even grosser approach that I've semi-automated. I build Perl scripts as strings from within Python, and send them out to an external (Perl) process for execution. The automation part is that I have conventions for expressing variable references so I can get data to flow conveniently back and forth. It's only "semi-", 'cause I tinker with exception-handling and such most times I use it. When do I use it? Typically, when CPAN has something I want in Python. I do a cognate translation of the CPAN interface into Python, and steal the implementation from our Perl colleagues. When it becomes important enough, or I make time for fun, I rewrite the implementation in Python. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From MGoehmann at t-online.de Wed Jun 9 04:46:14 1999 From: MGoehmann at t-online.de (Monika Göhmann) Date: Wed, 9 Jun 1999 10:46:14 +0200 Subject: "Programming Python" still worthwhile? References: <7jki66$qam$1@news.gstis.net> Message-ID: <7jl9r8$i1j$1@news06.btx.dtag.de> "Learning Python" is just great!! I have only started reading but it already answered many of my newbie-questions. Some time ago I tried reading "Programming Python" but I find it quite hard to digest. LP seems much more readable for the beginner IMHO. Monika Rick Robino schrieb in im Newsbeitrag: 7jki66$qam$1 at news.gstis.net... > Greetings, > > I've been watching this group for some time and just now getting warm to > Python. Looking at source examples has been great, but for completeness' > sake I'd like to get more of the "why" maybe found in a book. Since Python > is at 1.5.2 and people are talking about 2.0 as if it's around the corner, > I was wondering if anyone here could give me some advice as to whether or > not "Programming Python" is useful, if the current edition is still > current, if I should wait for the "Learning Python", or if I should use > some other resources. > > I expect to come up to speed fairly quickly and I'm just looking for > those fundamental insights into OOP and Python that can build up the > kind of inuition and understanding one needs in order to "get > comfortable" connecting/creating the dots. Currently I only program > small - medium programs in C and shell (Korn). Any sage pointers to > resources? > > TIA, > > --Rick > ^^^^^^^^^^^^^^ > Rick Robino rrobino at wavedivision.com From matomira at iname.com Fri Jun 11 08:33:33 1999 From: matomira at iname.com (Fernando Mato Mira) Date: Fri, 11 Jun 1999 14:33:33 +0200 Subject: Why is tcl broken? References: <375F82C7.CF0F0477@iname.com> <375FF969.C879B4CD@iname.com> <37601668.D9105225@mayo.edu> <3760E130.7456447@iname.com> <3760FA1F.7BCD@mailserver.hursley.ibm.com> Message-ID: <3761021C.8C029142@iname.com> Paul Duffin wrote: > In Tcl if you want to pass a "reference" you pass a variable name I was refering to this, hence the quotes. From pereira at research.att.com Tue Jun 15 08:51:17 1999 From: pereira at research.att.com (Fernando Pereira) Date: Tue, 15 Jun 1999 12:51:17 GMT Subject: broken References: <1282792849-95706075@hypernet.com> <3764D7C3.718E125E@iname.com> <002f01beb64d$58e7b5f0$f29b12c2@pythonware.com> <37651951.ED54894E@acm.org> <005501beb674$c5575890$f29b12c2@pythonware.com> <376621CF.88C95B5E@iname.com> Message-ID: <150619990851173299%pereira@research.att.com> In article <376621CF.88C95B5E at iname.com>, Fernando Mato Mira wrote: > Fredrik Lundh wrote: > > > btw, while we're on this topic, here's an interesting > > article by kent pitman: > > > > http://world.std.com/~pitman/pfaq/cross-posting.html > Well, I have no time for reading that. Obviously crossposts > are useful. I'll tell you how it works: > No time? You do seem to have plenty of time to flood several language newsgroups with off-topic postings like the present one. Revealing priorities. -- -- F From Christian.Caremoli at der.edf.fr Wed Jun 23 02:07:27 1999 From: Christian.Caremoli at der.edf.fr (Christian Caremoli) Date: Wed, 23 Jun 1999 08:07:27 +0200 Subject: creating dictionnaries References: <376F82A6.82497D2B@der.edf.fr> <199906222048.WAA08720@axil.hvision.nl> Message-ID: <3770799F.BDAC8FC@der.edf.fr> Thanks for all the answers I know that it s invalid and what I use now is a function named _F to avoid name clashes def _F(**args): return args What I want is to have an uniform syntax to write : a=mycommand(x=1,y=2,z=(d=1,e=2),s=1) or alike instead of a=mycommand(x=1,y=2,z=_F(d=1,e=2),s=1) I wonder if it exists any syntactic sugar or any trick that could help me Hans Nowak wrote: > On 22 Jun 99, Christian Caremoli wrote: > > > Hi, > > Dictionnaries can be created like that : > > d={'a':1,'b':2} > > > > By calling a function you create a dictionnary like that : > > def f(**d): > > return d > > > > d=f(a=1,b=2) > > > > I would like to be able to create dictionnaries with some similar syntax > > like keyed tuples : > > d=(a=1,b=2) > > > > Is there a way to do that ? > > Nope. :-) I wonder why you would want this? As far as I'm concerned, > there's not screamingly much difference between > > d=f(a=1,b=2) # valid > > and > > d=(a=1,b=2) # invalid > > --Hans Nowak (ivnowa at hvision.nl) > Homepage: http://fly.to/zephyrfalcon From news at dorb.com Sun Jun 6 02:12:15 1999 From: news at dorb.com (Darrell) Date: Sun, 6 Jun 1999 02:12:15 -0400 Subject: pyscript help References: Message-ID: Life is good. After an evening of install reboot..... I got Aaron Watters Calculator Demo to work. D:\python\win32comext\axscript\demos\client\ie\demo.htm I just wanted to see an ASP something or other work. Replaced comcat.dll with an older one. NT4 SP5 IE5 And I'm afraid to install option pack 4. --Darrell From wtanksle at dolphin.openprojects.net Tue Jun 22 21:26:01 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Wed, 23 Jun 1999 01:26:01 GMT Subject: Help with String Manipulation References: <5650A1190E4FD111BC7E0000F8034D26A0EE67@HUINA> Message-ID: On Wed, 23 Jun 1999 01:06:25 GMT, Doug Stanfield wrote: >If you're new to Python it might seem like some magic in this: >>>> testring = "This is an example" >>>> testlist = map (ord, testring) >>>> testlist.reverse() >>>> import array >>>> finalstring = array.array('b', testlist).tostring() Whew! Is there any reason to not use: >>> x = list("This is an example.") >>> x.reverse() >>> import string >>> string.join(x,"") ?? In other words, since a string is immutable, just convert the string to a list explicitly. If you MUST be obscure, try this: >>> x = map(None, "This is an example.") >>> x.reverse() This way you don't have to play with ordinals. >-Doug- -- -William "Billy" Tanksley Utinam logica falsa tuam philosophiam totam suffodiant! :-: May faulty logic undermine your entire philosophy! From tismer at appliedbiometrics.com Tue Jun 29 05:41:56 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Tue, 29 Jun 1999 09:41:56 GMT Subject: ANN: Stackless Python 0.2 References: <000301bec1ff$22ac6fe0$719e2299@tim> Message-ID: <377894E4.4897D2E8@appliedbiometrics.com> Tim Peters wrote: > > [Tim sez Python stores space for each code object's "Python stack" in a > runtime frame object] > > [Toby J Sargeant wondering about frame allocs] ... > > It seems that this should affect Stackless Python equally as > > much. > > No more so than Stackful Python: Python has always worked this way; > Stackless Python doesn't change this aspect. And this was one of the temptations to start this at all. We pay already some amount of runtime for the frame thing. Then, we should make full use of it. Doing not so would be a waste and not optimum. > > > Does anyone have anything to add on the subject? I would imagine that > > frames could be allocated and managed in chunks to alleviate a lot of > > the memory management load... > > The code is in Objects/frameobject.c, and easy to follow. frameobjects are > recycled via their own free list. Typically the total number of > frame-associated mallocs is proportional to the maximum depth of the call > stack, not to the number of calls made. > > Setting up a Python frame remains expensive, but for other reasons. The last word on this isn't spoken yet, since I didn't try to optimize frames. But I will see what to do (later). There are two things, which at the moment are still too intermingled. I will try to break things apart more in the next stackless verison. Currently, a frame is constructed from a code object, by examining the code object's properties. This is done in frameobject.c. The engine then modifies the local registers in the frame object, according to parameters of the given function call. This is by far not optimum. If a function is called repeatedly in the same context, the frame could stay initialized and be reused. I believe there are very many contexts where just one or two arguments of a function call change, and the frame would only need to update these two fast locals! Maybe caching this a little, by code object and caller location would pay off. Will think more about it. tim-this-is-continuation-prediction - ly y'rs - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From jblake at eskimo.com Wed Jun 9 19:35:22 1999 From: jblake at eskimo.com (Jonathon) Date: 9 Jun 1999 23:35:22 GMT Subject: Python Paterns Message-ID: <7jmtnq$fc7$1@eskinews.eskimo.com> Searching Python.org, I didn't come across anything _recent_ about patterns in Python. Did that SIG die, get swallowed up or did I miss their home? The only documentation I could find was http://starship.python.net/crew/gandalf/DNET/classes/index.html which was for Python 1.4 on an NT machine, last updated in 1997 and a paper given at the sixth conference on Python. xan jonathon -- I'm still looking for a good book on 3: The Recent Unpleasantness 1: The War Of Northern Aggression. 2: The War of Southern Rebellion. From mfletch at vrtelecom.com Tue Jun 29 03:43:46 1999 From: mfletch at vrtelecom.com (Mike C. Fletcher) Date: Tue, 29 Jun 1999 07:43:46 GMT Subject: PythonWin VSS Integration Message-ID: <002a01bec203$1fc90230$a9807018@yec1.on.wave.home.com> I've just finished setting up visual source safe here, and thought that I would take the opportunity to see what PythonWin's integration was like. However, not knowing what it is supposed to do, I don't know what I am supposed to do, or whether it is working. I was assuming that the integration would be something similar to what visual studio does, i.e., when I attempt to edit a file in PythonWin, visual source safe would prompt me to checkout the file. That doesn't seem to be the case. So, any hints? What does visual source safe integration mean? Thanks, Mike From scott at chronis.pobox.com Wed Jun 2 13:34:43 1999 From: scott at chronis.pobox.com (scott cotton) Date: Wed, 2 Jun 1999 13:34:43 -0400 Subject: metaclasses and setting __class__ Message-ID: <19990602133443.A3846@chronis.pobox.com> Last night i was playing with meta classes, and found out that we are not able to assign an instance's __class__ attribute to a metaclass instance. was just wondering if this is probably always going to be the case, or if there are any plans to make .__class__ assignable to such beasts. scott From catlee at my-deja.com Tue Jun 29 15:15:36 1999 From: catlee at my-deja.com (catlee at my-deja.com) Date: Tue, 29 Jun 1999 20:15:36 +0100 Subject: Arbitrary precision calculations Message-ID: <0000158b@bossar.com.pl> From: catlee at my-deja.com Hi, I'm looking for a package that will let me do arbitrary precision arithmatic in python. I've come across the real.py module written by Jurjen N.E. Bos, and it seems like a really nice module except for the fact that you can't compare two numbers for equality,inequality,etc. Cheers, Chris P.S. I found the real.py package by doing a search on www.deja.com for arbirary precision in comp.land.python Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From mikael at pobox.com Wed Jun 30 20:48:11 1999 From: mikael at pobox.com (Mikael Lyngvig) Date: Thu, 01 Jul 1999 00:48:11 GMT Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> <3773c3a0.102825445@news.oh.verio.com> <7laovo$c4s$1@Starbase.NeoSoft.COM> <377A24B7.AD6FAA1A@cfdrc.com> Message-ID: <3A174E56AD89F7F6.47941772B9D545B9.852EB0CCFCA68614@lp.airnews.net> On Wed, 30 Jun 1999 09:07:51 -0500, Lyle Johnson wrote: >Just to add fuel to the fire, we now have a Python interface to FOX, a >cross-platform GUI toolkit: > > http://www.cfdrc.com/pub/FOX/fox.html > >The latest version of the Python wrappers can be picked up at: > > ftp://ftp.cfdrc.com/pub/FOX/FXPy-0.99.42.tar.gz > >I don't know how the speed of FXPy would compare with some of the others >mentioned (Tk, wxWindows, Qt, GTK, ...) but it would be worthwhile for >some independent opinions. I'm downloading it now. The http URL is wrong, it should be http://www.cfdrc.com/FOX/fox.html. The presentation seems promising, but I'd like to suggest a binary distribution for PC/Intel computers. I know this is not common for Unix distributions, but it's the norm for PCs. -- Mikael From eugene.leitl at lrz.uni-muenchen.de Mon Jun 28 14:32:14 1999 From: eugene.leitl at lrz.uni-muenchen.de (Eugene Leitl) Date: Mon, 28 Jun 1999 11:32:14 -0700 (PDT) Subject: SWIGging VolPack (voxel rendering library) Message-ID: <14199.48948.94150.900645@lrz.de> Has anybody SWIGed VolPack here yet? http://www-graphics.stanford.edu/software/volpack/ 'cause if nobody did, I'd like to give it a spin. From MHammond at skippinet.com.au Wed Jun 2 03:25:14 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Wed, 2 Jun 1999 17:25:14 +1000 Subject: IDLE Extension: CallTips Message-ID: <7j2m5m$kuf$1@m2.c2.telstra-mm.net.au> Humming the mantra "Release early and release often", I humbly submit my first attempt at an IDLE extension. Some of you may be wondering if I have a) seen the light, or b) lost my mind, depending on your viewpoint But fear not - Guido and I have been working on allowing IDLE extensions to exist in Pythonwin, so this extension will indeed be used by the next version of Pythonwin (in fact, was ported from the Pythonwin version) CallTips is an extension that uses a pop-up window similar to "Tool Tips" or "Balloon Help", and displays the parameter description for functions as you open a paren. The text for the description is derived from the function object itself if possible, and the function's docstring. It has the following problems: * It is not incredibly smart about determining the function to use to display the tips. Simple things like "string.split" and "os.path.split" work correctly, but many other function calls, such as "self.foo" will not invoke any help at all. * The tips may hang around longer than you expect. Specifically, back-spacing after the window is open, or moving to a new location with the mouse will not close the window. Almost all other cursor movement keys will, so it should not hang around too long. Any Tkinter experts with advice on how to fix this would be appreciated! * Only been tested on WinNT, but has absolutely no Windows specific code - should work fine on any IDLE platform. The CallTip window code is based on Guido's ToolTips.py, which is based on PySol - so it should work anywhere! * Doesn't handle nested calls correctly - eg, closing a nested function call will not re-display the help for the outer call. This is slowly being addressed. * No way to disable the CallTips or delay their display (other than to remove the extension, of course) For all this, I still find it incredibly useful. Plus the code is small enough to attach :-) The instructions are very simple: * Copy the attached files to your IDLE directory. * Open extend.py, and add "CallTips" to the list of extensions. See extend.txt for details * Restart IDLE. From the PyShell window type "string.split(" and see it do it's stuff! All comments and enhancements appreciated! Mark. begin 666 CallTipWindow.py M(R!!($-A;&Q4:7 @=VEN9&]W(&-L87-S(&9O2!T:&4 at 0V%L;%1I<', at 241,12!E>'1E M;G-I;VXN#0II;7!O"P@>2P at 8W@L(&-Y(#T@"@B:6YS97)T(BD-"B @(" @(" @>" ]('@@*R!S96QF+G=I9&=E="YW:6YF M;U]R;V]T>"@I("L@, at T*(" @(" @("!Y(#T@>2 K(&-Y("L@'0] M2!A;B!E M9&ET;W)?=VEN9&]W#0H@(" @9&5F(%]?:6YI=%]?*'-E;&8I. at T*(" @(" @ M("!R;V]T(#T at 5&LH*0T*(" @(" @("!T97AT(#T@'0N979E;G1?861D*"(\/&-A;&QT:7 M'0N8FEN9"@B/#QC86QL=&EP+6AI9&4^ M/B(L('-E;&8N8V%L;'1I<%]H:61E*0T*(" @(" @(" -"B @(" @(" @=&5X M="YF;V-U95]?/3TG7U]M86EN7U\G. at T*(" @(&UA:6XH*0T* ` end begin 666 CallTips.py M:6UP;W)T('-T2X-"E]C86YC96Q?:V5Y'0B+" B4')I;W(B+" B2&]M92)=#0I?8V%N8V5L7VME M>7-?;6]D:69I97)S(#T at 6R=+97DM)RP@)T-O;G1R;VPM)RP@)U-H:69T+261E9G,@/2![#0H@(" @(" @("<\ M/'!A2TH/B==+ T*(" @(" @(" G/#QP87)E M;BUC;&]S93X^)SH at 6R<\2V5Y+2D^)UTL#0H@(" @(" @("<\/&-H96-K+6-A M;&QT:7 M8V%N8V5L/CXG.B!M87 H;&%M8F1A(&ME>3H@(CQ+97DM)7,^(B E M(&ME>2P at 7V-H96-K7V-A;F-E;%]K97ES*2P-"B @(" @(" @)SP\8V%L;'1I M<"UC86YC96P^/BPT*(" @('T-"@T*(" @('5N:7A?:V5Y9&5F'0L(")M86ME7V-A;&QT:7!?=VEN9&]W(BDZ M#0H@(" @(" @(" @("!S96QF+E]M86ME7V-A;&QT:7!?=VEN9&]W(#T@'0I#0H-"B @("!D968 at 7W)E;6]V95]C86QL=&EP7W=I M;F1O=RAS96QF*3H-"B @(" @(" @:68@'0Z#0H@(" @(" @(" @("!S96QF+F-A;&QT:7!?'0N:6YD97 at H(FEN'0N M8V]M<&%R92 at B:6YS97)T(BP@(CP](BP@'0N8V]M<&%R92 at B:6YS97)T M(BP@(CXB+"!S96QF+F-A;&QT:7!?2X-"@T*(" @(&1E9B!G971?;V)J96-T7V%T7V-U7,N;6]D=6QE7!E*&]B*3T]='EP97,N365T:&]D5'EP93H-"B @(" @(" @(" @ M(&]B(#T@;V(N:6U?9G5N8PT*(" @(" @(" @(" @87)G3V9F2!A;F0 at 8G5I;&0@;VYE(&9O71H;VX at 9&5F:6YE M9"!F=6YC=&EO;G,-"B @(" @(" @:68@='EP92AO8BD@:6X at 6W1Y<&5S+D9U M;F-T:6]N5'EP92P@='EP97,N3&%M8F1A5'EP95TZ#0H@(" @(" @(" @("!T M'0@/2 B*"5S*2(@)2!A&-E<'0Z#0H@ M(" @(" @(" @(" @(" @<&%S No, you've got it right. When you use the file association for some unknown reason you can't use redirection. If you just do: "python blah.py < blah > blah2" everything works perfectly. My current theory is that there is a design point/bug in the file association code that we just don't understand at the momemnt. Bill > -----Original Message----- > From: Holger Jannsen [mailto:holger at phoenix-edv.netzservice.de] > Sent: Friday, June 18, 1999 9:02 AM > To: python-list at cwi.nl > Subject: NT > > > Hi, > > another problem under NT: I'd like to message the user a > longer description about the > programm with sys.stdout.write(usagetxt). > The user should have possibility to pipe the output like he > wants, e.g. with 'less' or 'more'. > But I get an error: > > C:\myPython>installation15.py /? |more > Traceback (innermost last): > File "C:\myPython\installation15.py", line 642, in ? > switcher() > File "C:\myPython\installation15.py", line 629, in switcher > __usage() > File "C:\myPython\installation15.py", line 189, in __usage > sys.stdout.write(usagetxt) > IOError: [Errno 9] Bad file descriptor > > If I start with 'C:\myPython>python installation15.py /? |more' > there's no problem and it works allright. > > I've read the messages about NT and piping in this group, but I think > it's something differnt, ouh?! > > hand (='have a nice day'!), > Holger > From da at ski.org Mon Jun 14 01:25:26 1999 From: da at ski.org (David Ascher) Date: Sun, 13 Jun 1999 22:25:26 -0700 (Pacific Daylight Time) Subject: New to threading. Right idea??? In-Reply-To: <37648cec.0@news.dbtech.net> Message-ID: On Sun, 13 Jun 1999, Karl Putland wrote: > I need some advise. Am I on the right track? Not quite. As you say, threads are independent paths of execution. The key word there is "path of execution" =). In other words, everything but the path of execution is shared, especially globals, and in Python, the state of the interpreter. The two threads share the same list of imported modules, etc. What you're thinking of is processes, not threads. On unix, that's done with a fork(). There is no simple equivalent on Windows, alas. Not that it would help (see below). > One of the functions in the dll is EXPENSIVE. It's not mine and I doubt > they will rework it so I have to live with it. the EXPENSIVE function must > be called at the begining and ties all activity in the dll to a specific > directory. If you want to change directories you must call unexpensive then > EXPENSIVE again with the new directory as an argument. If the dll is loaded > and EXPENSIVE has been called sucessive calls to EXPENSIVE return FALSE. If you must call EXPENSIVE for each directory, then you must -- I don't think there's any way around that. Loading the same DLL multiple times won't help if you have to call EXPENSIVE for each (especially if unexpensive is, well, unexpensive =). If EXPENSIVE is VERY_EXPENSIVE, where VERY_EXPENSIVE >> cost of loading the DLL, then even a fork() wouldn't help much, even if it were available on your OS. --david ascher From fredrik at pythonware.com Fri Jun 18 05:12:01 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 18 Jun 1999 09:12:01 GMT Subject: tkwait References: <3769FE25.6ECF09D4@dlr.de> Message-ID: <000701beb96a$a15d70c0$f29b12c2@pythonware.com> Sven Drescher wrote: > I know, that is a very simple question, but I didn't find a solution. > Please help me with the syntax of Tk's tkwait window. I found the Tk > Manual page and Deja-news entries, but no solution for my problem. http://www.pythonware.com/library/tkinter/introduction/basic-widget-methods.htm (look under event processing). btw, a PDF version of the current tkinter introduction draft is now available from: http://www.pythonware.com/library.htm From bwinton at tor.dhs.org Wed Jun 9 23:42:26 1999 From: bwinton at tor.dhs.org (Blake Winton) Date: Thu, 10 Jun 1999 03:42:26 GMT Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7j90va$6lk$1@cronkite.cc.uga.edu> <87pv384koy.fsf@ev.netlab.co.jp> Message-ID: On 10 Jun 1999 09:43:07 +0900, Hisao Suzuki wrote: >In article <87pv384koy.fsf at ev.netlab.co.jp>, >Yukihiro Matsumoto wrote: >| I claimed in summary: >| * I don't like mere ref counting; it cannot reclaim cyclic data, and >| easy to forget INCREF/DECREF. >| * Many among Python users misunderstood about real GC. >| (slow, hangs, non portable, etc.) >| * ref counting with GC may be good for Python 2.0. >| Did I do any advocacy on Ruby? I was trying constructive discussion. >I'm sorry to say, but your argument is too trivial (or rather >naive) to consider as a constructive discussion. Having almost >nothing to do with real problems on Python, your referrings to >your Ruby (surely in triumphant tones) sound evangelic. I'd be >glad if you would present a non-trivial viewpoint or propose a >practical solution _relevant_ to Python actually. I think this is a little harsh. I've been reading this entire thread (No, I don't know why), and Matz has seemed to me to be remarkably restrained in his evangelical attempts. Whenever he mentions Ruby, he makes the disclaimer that it's not particularly portable, and only seems to use it as a proof-of-concept, or demonstration that he has some skill in writing GCs. Ref counting with GC sounds to me like a good idea for Python 2.0, as it will eliminate a class of memory leaks that Python can currently fall prey to. As long as you don't move stuff around in memory, and only collect things where all the refcounts are accounted for, and can't be reached, you should be safe. Granted, this means that the people writing the extensions will have to be careful to INCREF/DECREF where they're supposed to, but I don't see that as a bad thing since they should already be careful about that sort of stuff. Later, Blake. -- One Will. One Dream. One Truth. One Destiny. One Love. From claird at Starbase.NeoSoft.COM Thu Jun 10 12:00:40 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 10 Jun 1999 11:00:40 -0500 Subject: Why is tcl broken? References: <375F82C7.CF0F0477@iname.com> <4.1.19990610150908.00d09790@exchsrv> <7jog8f$ljv$1@Starbase.NeoSoft.COM> <375FD854.2314D886@iname.com> Message-ID: <7jonf8$6n6$1@Starbase.NeoSoft.COM> In article <375FD854.2314D886 at iname.com>, Fernando Mato Mira wrote: . . . >> >If so, does speed ever become an issue? I assume that Tk works well >> Rarely. Much less often than the uninitiated >> suspect. > >That's the impression I have. But then, what are those `less often' cases? >(Besides trying to do silly things, like writing a fast-paced video game in Tk) . . . Tk's bad at pixel-oriented graphics; its [canvas] is designed for higher-order manipulations (and can be breathtakingly effective for many inter- esting tasks). People coming from other paradigms can usually find ways to misuse Tk into sluggish- ness. The Unicode stuff in 8.1 is still being shaken down; severe performance issues have turned up there, but plenty of fixes are available and are gradually being worked into the core. If you're doing things that fit well in [canvas]es and [text]s, you'll go far with Tk. Several widgets that moderns expect are *not* available in the standard core, and some of the extensions that provide them are not high in performance. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From news at dorb.com Sun Jun 27 12:24:52 1999 From: news at dorb.com (Darrell) Date: Sun, 27 Jun 1999 12:24:52 -0400 Subject: Python for large projects? References: <3774b5d1.690922@news.force9.net> <87n1xm85mf.fsf@lisboa.i-did-not-set--mail-host-address--so-shoot-me> Message-ID: > If it is only one object, one can try to wrap it in a class and > overwrite setattr, setitem etc. > This would inhibit that one changes the buffer data accidently. And > put the data into an immutable sequence type (string, tuple). > > __Janko > I'll give that a look, but they can always get to it if they want. Maybe that's ok, just worries me. --Darrell From tcropley at nospam.prodigy.net Fri Jun 11 20:55:10 1999 From: tcropley at nospam.prodigy.net (Phaedrus42) Date: Fri, 11 Jun 1999 20:55:10 -0400 Subject: Newbie question: DOS console commands? Message-ID: <7jsb5s$k7q$1@newssvr01-int.news.prodigy.com> I'm new to Python this week and was wondering if there are any console commands to use on a DOS screen (e.g. ClearScreen, GotoXY, Foreground and Background colors, etc.) I've got PythonWin running on Windows 95 and am having fun learning the language and Tkinter, but I have a need to write a simple DOS interface program. I could pull out my copy of TurboPascal, but I'd like to write it in Python to further my education. Any help? From scott at chronis.pobox.com Tue Jun 22 23:09:51 1999 From: scott at chronis.pobox.com (scott cotton) Date: Tue, 22 Jun 1999 23:09:51 -0400 Subject: help? strptime .... In-Reply-To: ; from Benjamin Schollnick on Wed, Jun 23, 1999 at 02:33:56AM +0000 References: Message-ID: <19990622230951.A11935@chronis.pobox.com> >>> import time >>> print time.strptime.__doc__ strptime(string, format) -> tuple Parse a string to a time tuple according to a format specification. See the library reference manual for formatting codes (same as strftime()). >>> >>> >>> time.strptime("19990822", "%Y%m%d") (1999, 8, 22, 0, 0, 0, 6, 1, 0) >>> time.mktime(time.strptime("19990822", "%Y%m%d")) 935294400.0 scott On Wed, Jun 23, 1999 at 02:33:56AM +0000, Benjamin Schollnick wrote: | Folks, | | I'm trying to use strptime (from the time module) and can't.... | | Could someone please post a example, so that I can try to figure out | what | I'm doing wrong? | | - Benjamin | | -- | http://www.python.org/mailman/listinfo/python-list From c.evans at clear.net.nz Sun Jun 6 01:52:00 1999 From: c.evans at clear.net.nz (Carey Evans) Date: 06 Jun 1999 17:52:00 +1200 Subject: Sockets and lemon curry References: Message-ID: <87d7z97u67.fsf@psyche.evansnet> "Ian King" writes: > I'm trying to implement an rshd server in Python. The problem seems to be > with establishing the secondary socket for stderr. [snip] > s2 = socket(AF_INET, SOCK_STREAM) > s2.connect(addr[0], port2) #addr tuple is host, port for conn > > ....and that's where the client says, "Pining for the fjords???" and gives > up. I think you've missed something. The OS will assign the local port for this socket from 1024 up. However, rsh requires that the remote port that connects to it for stderr is less than 1024, to prove that it's not just another user on the box pretending to be rshd, but a process running as root. You'll have to have the Python server bind() to a reserved port before trying to connect back to rsh. Something like the following code may be appropriate, and acts like the code the real rshd uses. ------------------------------------------------------------ import exceptions import socket import errno import types class RResvPortError(exceptions.Exception): def __str__(self): return 'No reserved ports available' def rresvport(): port = 1023 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) while port >= 1: try: s.bind('', port) except socket.error, detail: if type(detail) is not types.TupleType \ or detail[0] != errno.EADDRINUSE: raise else: return s port = port - 1 raise RResvPortError ------------------------------------------------------------ -- Carey Evans http://home.clear.net.nz/pages/c.evans/ "I'm not a god. I've just been misquoted." From holger at phoenix-edv.netzservice.de Tue Jun 15 10:02:48 1999 From: holger at phoenix-edv.netzservice.de (Holger Jannsen) Date: Tue, 15 Jun 1999 14:02:48 GMT Subject: Newbie: easy filecopy? References: <376531D3.7E42AC42@phoenix-edv.netzservice.de> Message-ID: <37665D08.267A697C@phoenix-edv.netzservice.de> Another ascpect to my question of yesterday: The problem with f=open(aFile) x=f.read() f.close f.open(toFile) f.write(x) f.close is, that some special ASCII-codes are not copied as usual under Windows-systems, so e.g. CarriageReturn (tested with normal Asccii-text). Hints? Ciao, Holger Holger Jannsen schrieb: > > Sorry, > it's me again.;-) > > I couldn't believe it. I think there must be an easy copy-function > in python (I only want to copy files under ext2- or FAT-FileSystems). > Call me "4 blind mice"-Joey, but I couldn't find it. > For sure, I could write a thing like open-read-write-close, but I > think, someone else has done already, hasn't he? > > Thanx again for patience with me...[snuff] > > Ciao, > Holger From mwh21 at cam.ac.uk Thu Jun 10 06:10:19 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 10 Jun 1999 11:10:19 +0100 Subject: Asserting object class References: <375F8986.73BA3C5@i-data.com> Message-ID: Adi writes: > In a method, I'd like to assert that a parameter is an object which is > of a specific class or has this class as it's base class. > > I can test on the __class__ and its __bases__ attributes, but its clumsy > and I'm wondering if there is an easier notation, like: > > def method(self, p) > assert class(p) == class(self) > > This is comparable to - in a strongly typed language - specifying a > required base class as the type of the parameter. I think that this will do what you want: def method(self,p): assert isinstance(p,self.__class__) the following also does the same: def method(self,p): assert issubclass(p.__class__,self.__class__) HTH Michael From aahz at netcom.com Wed Jun 30 16:39:30 1999 From: aahz at netcom.com (Aahz Maruch) Date: 30 Jun 1999 20:39:30 GMT Subject: Does the first argument of a method *has to be* self? References: <19990630222121.A1121@optiplex.palga.uucp> Message-ID: <7ldva2$mhq@dfw-ixnews21.ix.netcom.com> In article <19990630222121.A1121 at optiplex.palga.uucp>, Gerrit Holl wrote: > >I never saw code where the first argument of a method wasn't self. Is it >in theory possible? Yes and no. The first argument always *is* self, but it can be named something else. For example: class foo : def bar(s): s.bar() # recursive call -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het From chriseb at nortelnetworks.com Thu Jun 17 06:04:18 1999 From: chriseb at nortelnetworks.com (Chris Ebenezer) Date: 17 Jun 1999 11:04:18 +0100 Subject: Why is tcl broken? References: <1283099377-77267484@hypernet.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> Message-ID: thornley at visi.com (David Thornley) writes: : >Why use TK at all ? Once you are using scheme anyway there are nicer : >widget toolkits to use (from a point of view of more "normal" looking : >toolkits that don't suffer from color allocation problems), there are : >bindings for guile and gtk and guile and Qt. : > : The attraction, to me, would be that Tk is a free, open-source : graphics environment that will run on Unix with X-Windows, the : Macintosh, and Microsoft Windows. CLIM is commercial, Garnet last Hi David, If you want something that is completely free (in the GNU sense) go to http://www.gtk.org/, scroll down until you reach the bit on the sidebar that reads "Language Bindings". You should be able to get guile-gtk from there. -- chris From matomira at iname.com Tue Jun 15 10:37:46 1999 From: matomira at iname.com (Fernando Mato Mira) Date: Tue, 15 Jun 1999 16:37:46 +0200 Subject: broken References: <1282792849-95706075@hypernet.com> <3764D7C3.718E125E@iname.com> <002f01beb64d$58e7b5f0$f29b12c2@pythonware.com> <37651951.ED54894E@acm.org> <005501beb674$c5575890$f29b12c2@pythonware.com> <376621CF.88C95B5E@iname.com> <150619990851173299%pereira@research.att.com> Message-ID: <3766653A.D9F6E99B@iname.com> Fernando Pereira wrote: > In article <376621CF.88C95B5E at iname.com>, Fernando Mato Mira > > No time? You do seem to have plenty of time to flood several language No time to read a philosophy of `closed mindness' that I don't share. What is off-topic to you is not to everyone. For comp.lang, I rarely look outside of comp.lang.lisp. Even comp.object, which would be a natural environment for me was going unread. And if a comp.lang.misc exists, who said the `people that know' looks there? If all you do is code in your own favorite language, this kind of discussion will obviously not be intersting to you. And nobody still gave me a reason why I should look beyond the www.python.org front page (I'd already been there). I'm out of here. If one of the previous flamers wants to send me email regarding that question, you're welcome to do so. But I won't waste any more time defending myself and showing other points of view regarding crossposting to dogmatic people that think that when an authority puts up a web page, it must obviously be `the truth'. Actually, you should read that better. The first sentence says `generally'. Obviously, comp.lang.python falls into the generality. No one from any other group complained, even when I explicitly pointed out something that "they" (i.e. I'm part of them) might not like. What does that say about you? [The cool people around (including _every_single_one_ who stood up for tcl) please excuse me (specially Guido, since I have a hunch he must be a really cool guy). I'm not talking about you. But really, this infuriates me so much, if someone asks me what I think about Python I'll probably just answer "Don't go there"] You can cheer now. From dickey at shell.clark.net Mon Jun 21 05:26:14 1999 From: dickey at shell.clark.net (T.E.Dickey) Date: Mon, 21 Jun 1999 09:26:14 GMT Subject: Problem with Curses References: <87ogidzs37.fsf@home.ivm.de> <6Zeb3.526$4e1.32195@iad-read.news.verio.net> <5c5kk7.fn.ln@solling.seismic.de> Message-ID: Klaus-Juergen Wolf wrote: > T.E.Dickey wrote: > >>> It depends on when the executable is linked to libmytinfo, which only > >>> takes place on platforms that don't know the terminfo database, like > >>> BSD and Solaris; there are two competing declarations of tputs(). > >> Why doesn't Freebsd know the terminfo database? Can't the one that is > >> integrated into ncurses be used on FreeBSD? > > I've been told ncurses 4.2 is incorporated in the FreeBSD 3.1 - but that > > may still just be a port... > Yes, there is such a port. Do you think, one could release code that > works on several machines, while some of them must install a special > program first? I don't understand this comment (you seem to be saying that because there is some reluctance to install a working version of ncurses, that there's no reason to use packages which use it). > Curses now is a very old UI, very old, it was old when I first learned > it in the beginning of the 80's. Most people have forgotten that there not very old at that point (iirc, it dates to the late 70's, and was still considered "new" when I encountered it in 1983) > was a Curses before NCurses came up. cursesmodule now, it bases on > Curses with NCurses extensions. It is not acceptable to release a as I understand it, most of the "NCurses extensions" you refer to are standard in SVr4 curses (color, function keys). > cursesmodule that wouldn't work on all those platforms it formerly > worked on. If you intend that, you'll have to give it a new name. > Furthermore, you can't say, to make cursesmodule work, you have got to > download another one, it's beta, but maybe, it works on your desolated > site. But that's no solution. That's a cramp. > Anyway, that wouldn't have helped in my case, I think, since the name > conflict would have still existed - libtermcap would have been linked > before, since libreadline demands it, and, I'm afraid, since ncurses > originally defines tputs(), it would also been mis-linked. I don't > really know, I guess. I'm not so familiar with the dynamic linking > rules under ELF/BSD. that's a different problem (libreadline doesn't mix with curses on any system because it makes incompatible assumptions about terminal initalization). > cu > k.j. > -- > Support Julia Hill - save the Redwood trees: http://www.lunatree.org/ -- Thomas E. Dickey dickey at clark.net http://www.clark.net/pub/dickey From tim_one at email.msn.com Wed Jun 23 01:14:31 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 23 Jun 1999 01:14:31 -0400 Subject: W95 binary output from CGI script In-Reply-To: <930084286.377082@iris.nyx.net> Message-ID: <000c01bebd37$4639da00$cb9e2299@tim> [Tom Hall] > I'm working on a CGI script for Windows 95, and trying to send > binary data out stdout. Every time I try to send a \x0a it spits > out \x0d\x0a. Python opens the std file streams in text mode, and under all flavors of Windows that does horrible stuff to binary data. Quoting from a different thread, [Charles G Waldman] > Try running Python in unbuffered mode - with a "-u" commandline flag, > or by setting the PYTHONUNUFFERED environment variable to a non-empty > string. That disables buffering, but under Windows it also causes Python to open the std streams in binary mode. blame-niklaus-wirth-cuz-bill-gates-is-untouchable-ly y'rs - tim From joe at strout.net Thu Jun 17 14:20:28 1999 From: joe at strout.net (Joe Strout) Date: Thu, 17 Jun 1999 11:20:28 -0700 Subject: [ANN] PIDDLE v1.0a1 Message-ID: The PIDDLE development team is pleased to announce the first alpha release of PIDDLE -- Plug In Drawing, Does Little Else. PIDDLE is an easy-to-use drawing API with backends that do the actual drawing to a variety of formats, including PDF, Postscript, QuickDraw, Tk, PIL, and eventually OpenGL and Windows. This first alpha release is a little rough around the edges, and not for the faint of heart. But if you're up for some adventure, you may find it quite interesting. For more information and to get the distribution, go to: http://www.strout.net/python/piddle/ If you have any trouble, you can write to me directly, or post to the PIDDLE mailing list (http://www.egroups.com/group/pythonpiddle). Cheers, -- Joe -- ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe at strout.net http://www.strout.net | `------------------------------------------------------------------' From nikolai at micon.no Mon Jun 28 16:07:57 1999 From: nikolai at micon.no (Nikolai Kirsebom) Date: Mon, 28 Jun 1999 22:07:57 +0200 Subject: ASP and namespace Message-ID: <2BQd3.511$vv1.4827@news1.online.no> I'm trying to use Python as scripting language on the web-server, however - have problems to see how the namespace scope is handled. FILE - GenDb.py ============= class GenDb: def __init__(self): self.ConnStr = "" def SetDbAndTable(self, db, table): self.Db = db self.Table = table self.ConnStr = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=f:\\Databases\\%s" % db def Attr(self, attrName): if attrName == "abc": return(self.ConnStr) else: return("-non-") FILE - KSdebatt.py =============== from GenDb import * class KSdebatt(GenDb): def __init__(self): self.SetDbAndTable("KSdebatt.mdb", "BillMrk") FILE - SCRIPT1.ASP ================= <%@ LANGUAGE = Python %> <% import sys sys.path.append("f:\\PythonScripts") from KSdebatt import * o=KSdebatt() %> " SIZE=20> when I run the statements in the script1.asp file in an interactive window, I can create the KSdebatt object, however when I run the script on the server - I get the following message: Python ActiveX Scripting Engine error '80020009' Traceback (innermost last): File " If I run the supplied "foo2.htm" demo, I just get "Done - errors on page" displayed, with no indication of *what* error. None of the python scripted buttons work, but the VBScript one does. The initial bit of script does execute, though - I can see the results of the "document.write" calls. All in all, the whole thing looks very odd... Actually, I just noticed that the web page directs trace output to the "win32trace" destination. On starting the client I find that the trace output says Collecting Python Trace Output... ScriptEngine QI - unknown IID {4954E0D0-FBC7-11D1-8410-006008C3FBFC} Traceback (innermost last): File "E:\Applications\Python\win32com\client\dynamic.py", line 247, in _make_method_ fn = self._builtMethods_[name] = tempNameSpace[name] KeyError: print Redirecting output to win32trace remote collector Hello Location is file:///E:/Applications/Python/win32comext/axscript/demos/client/ie/ foo2.htm Hello from in the form X is 13 a is Hi there MyForm is X is 13 a is Hi there MyForm is Interesting - the IID it can't find is IActiveScriptProperty. What's that? It's not mentioned in MSDN (not even the online version on the MSDN web site, which I assume is fairly up to date...) Curiouser and curiouser... Paul. From tim_one at email.msn.com Mon Jun 7 00:53:50 1999 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 7 Jun 1999 00:53:50 -0400 Subject: Indentation and grouping proposal In-Reply-To: <375B3525.F67D424F@erols.com> Message-ID: <000001beb0a1$bc540a00$5b9e2299@tim> [R Wentworth, suggests "_(" and ")_" as alternative grouping constructs] Note that this won't fly, since "_(" already has a meaning in the grammar (call the function whose name is _). > [careful argument & analysis deleted] > ... > I haven't looked at the Python parser, but naively, this sort > of "enhancement" would seem to be relatively easy. If there were > official blessing for the concept, I'd be willing to look into > doing the necessary work. Guido's last public word on the subject is in Tools/Scripts/pindent.py. Go way back (pre-DejaNews; in python.org's archives, though), and you'll find some words, and even some patches to implement alternatives; e.g., see Donald Beaudry's http://www.python.org/search/hypermail/python-1994q2/0763.html The parser hasn't changed all that much since then, although it's likely changed a lot more than Guido's opinion . IIRC, Steven Majewski christened the alternatives "frowning Guidos", in honor of everyone's favorite some 5 years ago: if whatever :( print "no whitespace!" ): or-was-that-"(:"-and-":)"?-ly y'rs - tim From ray at commsecure.com.au Tue Jun 8 11:17:56 1999 From: ray at commsecure.com.au (Ray Loyzaga) Date: Wed, 09 Jun 1999 01:17:56 +1000 Subject: tstate invalid crash with threads References: <7jik35$esd$1@nntp6.atl.mindspring.net> Message-ID: <375D3424.6EF8E85F@commsecure.com.au> I have been playing with a multithreaded tcp based server for a while, and during some serious stress testing continually hit a problem involving the interpreter crashing with "Fatal Python error: PyThreadState_Delete: invalid tstate". I have stripped the server down to a pretty basic SocketServer based process which replies to a client request. It still shows the bug, and also crashes with a Segmentation fault sometimes. I have tested the same code on Linux 2.0.36/Python1.5.1, Linux 2.0.36/ Python1.5.2 and Solaris 2.6/python 1.5.2, all crash the same way. Unfortunately to produce the crash I need to run 12 clients on various other machines via 100Mbit Ethernet, the server usually dies between 150k and 1.4M transactions later (it could take an hour). Sometimes it crashes within 15 minutes. It appears to be a subtle race in PyThreadState_Delete .... interestingly, if I uncomment the small sleep in "handle" in the server, ie. make the server slower, it seems to work for ever ... 4m transactions before I gave up. I think the problem only comes if you are creating and destroying threads quickly in parallel. Any comments would be appreciated, note however that the following is seriously stripped down, it isn't supposed to do anything useful. The queue is used to make sure that I'm not keeling over due to thread exhaustion, it isn't required, I just wanted to know if the process goes thread crazy prior to crashing ... it doesn't. All this was done on an otherwise idle system with 384Mb memory, so resource exhaustion seems unlikely. I've seen this bug before but that particular application didn't really require threads so I converted to a synchronous server by using an ordinary TCPServer. The server is: from SocketServer import ThreadingTCPServer, StreamRequestHandler from socket import * import Queue import cPickle import time from threading import * server_address = ('', 8000) cnt = 0L threadq = Queue.Queue(200) for i in range(200): threadq.put(i) class BankHandler(StreamRequestHandler): def handle(self): global cnt val = self.connection.recv(1024) if (cnt % 10000) == 0: print time.ctime(time.time()), cnt cnt = cnt + 1 #time.sleep(0.01) self.connection.send('OK') class MyServer(ThreadingTCPServer): def process_request(self, request, client_address): """Start a new thread to process the request.""" import thread if threadq.empty(): self.handle_error(request, client_address) else: thread.start_new_thread(self.finish_request, (request, client_address)) def finish_request(self, request, client_address): """Finish one request by instantiating RequestHandlerClass.""" t = threadq.get() self.RequestHandlerClass(request, client_address, self) threadq.put(t) def server_bind(self): """Called by constructor to bind the socket. May be overridden. """ self.socket.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) self.socket.bind(self.server_address) s = MyServer(server_address, BankHandler) s.serve_forever() ********************************************************************************************* And the client is: (client_speed has a single line with .01 in it) from socket import * import string import cPickle import sys import time from select import select TIMEOUT=30 trans = 0L while 1: try: f = open('client_speed') delay = string.atof(f.readline()) f.close() sok = socket(AF_INET, SOCK_STREAM) sok.connect('bozo', 8000) sok.send('Hello') x = select([sok.fileno()], [], [], TIMEOUT) if x != ([],[],[]): data = sok.recv(2048) if (trans % 10240) == 0: print time.ctime(time.time()), trans, data else: print 'Recv timeout' sok.close() except: print 'failure %s'%(sys.exc_info()[1]) trans = trans + 1 time.sleep(0.01) From Sven.Drescher at dlr.de Fri Jun 18 04:07:01 1999 From: Sven.Drescher at dlr.de (Sven Drescher) Date: Fri, 18 Jun 1999 10:07:01 +0200 Subject: tkwait Message-ID: <3769FE25.6ECF09D4@dlr.de> Hi! I know, that is a very simple question, but I didn't find a solution. Please help me with the syntax of Tk's tkwait window. I found the Tk Manual page and Deja-news entries, but no solution for my problem. Thanks Sven From larsga at ifi.uio.no Tue Jun 29 18:55:03 1999 From: larsga at ifi.uio.no (Lars Marius Garshol) Date: 30 Jun 1999 00:55:03 +0200 Subject: Please help me to understand classes References: Message-ID: * Johann Spies | | Can somebody explain to me why the following program produces no | output: A good trick to learn in Python is that if you use the interpreter you can fool around and figure things out much more easily and quicker than if you use something that resembles the edit-compile-run loop of Pascal. | [...skipping class defs] | | a = A() | c = B() | c.druk | a.druk If you do this in the interpreter you get: >>> a = A() >>> c = B() >>> c.druk >>> a.druk This is a general rule in Python: if you mention a function or method by name you just get a reference to it. If you add parentheses it is called. >>> c.druk() Traceback (innermost last): File "", line 1, in ? TypeError: no arguments expected >>> a.druk() Traceback (innermost last): File "", line 1, in ? TypeError: no arguments expected In your example this failed, since you forgot the self argument. If you redeclare as: class A: def druk(self): print 'Jy is in Class A' To illustrate: >>> a=A() >>> a.druk >>> a.druk() Jy is in Class A >>> method=a.druk >>> method >>> method() Jy is in Class A --Lars M. From tom at spirit.gcrc.upenn.edu Tue Jun 8 09:44:03 1999 From: tom at spirit.gcrc.upenn.edu (Tom Fenn) Date: Tue, 08 Jun 1999 09:44:03 -0400 Subject: Humbug (was Re: Indentation and grouping proposal) References: <000b01beb14d$b502a480$aaa02299@tim> Message-ID: <375D1E23.9367A42C@spirit.gcrc.upenn.edu> The day Python has {'s, is the day I learn Dylan. :) Tom Fenn From c.evans at clear.net.nz Wed Jun 9 07:26:47 1999 From: c.evans at clear.net.nz (Carey Evans) Date: 09 Jun 1999 23:26:47 +1200 Subject: waste of resources ? Message-ID: Unix doesn't guarantee you'll get exactly one signal delivered per event. To be sure to get all the children, you need to loop over the processes with waitpid(). I think something like this should do it: ---------- def sigchld_handler(signum, frame): print "Checking for processes..." try: while 1: pid, sts = os.waitpid(-1, os.WNOHANG) if pid == 0: break print "Process %d ended with status %04x." % (pid, sts) except OSError, detail: if detail.args[0] != errno.ECHILD: raise else: print "No more children." else: print "Some children yet to finish." ---------- I can't actually see any way to keep count well enough and avoid race conditions, to get rid of the try/except. Sometimes I wish Python had POSIX signals, but not badly enough to actually write it. -- Carey Evans http://home.clear.net.nz/pages/c.evans/ "I'm not a god. I've just been misquoted." Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From phd at emerald.netskate.ru Sun Jun 20 05:07:49 1999 From: phd at emerald.netskate.ru (Oleg Broytmann) Date: Sun, 20 Jun 1999 13:07:49 +0400 (MSD) Subject: DATE ARITHMETIC In-Reply-To: <7kejrv$e57$1@violet.singnet.com.sg> Message-ID: On Sat, 19 Jun 1999, Ajith Prasad wrote: > I need to do some simple date arithmetic - finding the number of days > between any 2 days, the age of a person on a day given his birthday. The > mxDateTime module downloadable from the Python website is more complex than > what I need. Any other suggestions? http://members.xoom.com/phd2/Software/Python/ http://www.fortunecity.com/skyscraper/unix/797/Software/Python/ Download m_lib.tgz and look into opdate.py. Very simple, but powerful enough for many tasks. Oleg. ---- Oleg Broytmann Netskate/Inter.Net.Ru phd at emerald.netskate.ru Programmers don't die, they just GOSUB without RETURN. From avv at quasar.ipa.nw.ru Wed Jun 30 16:36:13 1999 From: avv at quasar.ipa.nw.ru (Alexander V. Voinov) Date: Wed, 30 Jun 1999 13:36:13 -0700 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> <3773c3a0.102825445@news.oh.verio.com> <7laovo$c4s$1@Starbase.NeoSoft.COM> <377A24B7.AD6FAA1A@cfdrc.com> Message-ID: <377A7FBD.DBC69FEB@quasar.ipa.nw.ru> Lyle Johnson wrote: > Just to add fuel to the fire, we now have a Python interface to FOX, a > cross-platform GUI toolkit: > > http://www.cfdrc.com/pub/FOX/fox.html > > The latest version of the Python wrappers can be picked up at: > > ftp://ftp.cfdrc.com/pub/FOX/FXPy-0.99.42.tar.gz > > I don't know how the speed of FXPy would compare with some of the others > mentioned (Tk, wxWindows, Qt, GTK, ...) but it would be worthwhile for > some independent opinions. It looks great. It seems "intuitively obvious" (for me, of course :-) both in programming and in using (I mean keyboard handling, at least under Windows). Yes, the principal question, I ask always when see a new GUI is: IS IT POSSIBLE TO DO EVERYTHING WITHOUT MOUSE? Gtk still fails to answer this positively. Qt-2.0 is very close to the ideal, as I can see. The only thing surprised me a bit: I failed to switch to a non-US keyboard layout while in text entry field (window.py example). I run Windows NT 4.0, SP4. I.e. the toolbar indicator said I'm in the required mode, but the letters I entered were just those ABC-xyz... I can proceed without this in getting started and evaluation, but it's necessary for any application I would deliver to users. Alexander From wtanksle at dolphin.openprojects.net Wed Jun 23 21:14:44 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Thu, 24 Jun 1999 01:14:44 GMT Subject: Why exceptions shouldn't be used for flow control [Re: YAS to the "Reading line-by-line" Problem] References: <376FDF70.4756AD38@mindspring.com> <377173F7.36BCFF6B@compaq.com> Message-ID: On Thu, 24 Jun 1999 11:55:35 +1200, Greg Ewing wrote: >William Tanksley wrote: >> Both should be handled by exception, not by returning a special >> value. >I don't agree with that. Reaching the end of a file while >reading it is not exceptional enough to warrant requiring >the use of an exception handler to catch it. "Not exceptional enough". What does that mean? (I ain't never had too much exception! ;-) It's an exception to the behavior of a function defined to return the next entity in a file. It's not an exception to a function which returns the next entity, or some reserved value otherwise. There's no such thing as a partial exception; it's a quality, not a quantity. >What bothers me about using exceptions for flow control Presumably you're talking about command flow. Okay, but exceptions do nothing BUT affect flow control. What else can they do? >in situations like this is that the effect of an exception >handler is *non-local*, whereas what you're trying to >catch is really only a local concern. Is it? Are they? The effects of an exception toss are as local as the user of the function want them to be. If EOF was truly local, then file.read would always be able to decide what to do with it -- print a message, abort(), pop up a window, or whatever else it takes. >When you write something like > while 1: > try: > line = read_me_a_line() > except EOFError: > break >what you really mean by the try-except is "if THIS >PARTICULAR reading operation reaches the end of >the file". But that's not what it does - it catches >any EOFError raised by any operation invoked by >read_me_a_line() that wasn't caught by something >else first. I see your problem, but it's pretty hard to sympathize with it, at least in this case (and it seems to me in any case). Consider that 'for' loops have been terminated by IndexError exceptions for a long time now, with no problems reported. If someone else's uncaught EOFError hits this function, something nasty is almost always going to happen, because of how far this is away from its correct target. This is robust by a definition of 'robust' with which some are not perfectly acquainted: if it fails, it does so loudly so that the tester notices and reports the problem. In addition, the complexity of the failure required to produce this is pretty high. How many files do you need to read to get the next line from this file? What would have happened if you'd ignored the EOF if it had been returned otherwise? >In my experience, that sort of behaviour tends to >mask bugs. I prefer results which are not errors to >be returned normally, so that I can be sure where >they came from. But reading data after EOF _is_ an error condition! A normal return is precisely what you don't want. A normal return offers permission for the program to keep going as usual. What you want is not a normal return, it's an _ab_normal return. Something like returning (int)-1 when the function's only expected to return char, or (in Python) returning None. The problem? These things are SO easy to ignore!!!! C is famous for noiselessly casting the -1 to a char (look at the old Bash security bug), and Python is even worse -- any return you can possibly make will almost certainly fit in noiselessly with anything you do with it. This is Python's ease of use. The only solution which works in each case is exceptions. This doesn't mean that using exceptions guerantees bug freedom; nothing can do that. It simply means that it catches the majority of the bugs the majority of the time. You ought to feel lucky. Some respected programming gurus recommend calling abort() on any odd results, to make misuse of their API as blatantly obvious as possible. >Greg -- -William "Billy" Tanksley Utinam logica falsa tuam philosophiam totam suffodiant! :-: May faulty logic undermine your entire philosophy! From delgado at Mathematik.Uni-Bielefeld.DE Fri Jun 18 11:55:39 1999 From: delgado at Mathematik.Uni-Bielefeld.DE (Olaf Delgado) Date: Fri, 18 Jun 1999 17:55:39 +0200 Subject: Newbie: Truth values (three-valued logic) In-Reply-To: <1282404372-119074879@hypernet.com> References: <7kd3ke$d1n$1@nnrp1.deja.com> <1282404372-119074879@hypernet.com> Message-ID: On Fri, 18 Jun 1999, Gordon McMillan wrote: > Note that, if you want to retain DeMorgan's Laws, you don't have > much choice. ANSI SQL defines a three valued logic which meets these > conditions, and comes up with > NOT maybe == maybe > (well, NOT unknown == unknown), which makes sense as long as you > rmember that NOT is an operator, and the result of a non-trivial > operation on an unknown operand is probably unknown. > > Which is why most DBA's won't allow NULL values in any column that > might be used in a WHERE clause - three valued logic is often > non-obvious. Well, NOT unknown == unknown seem perfectly obvious to me, but then I'm a Mathematician and everyone knows we're strange guys. Obviously yours, Olaf -- //// Olaf Delgado Friedrichs, Uni Bielefeld, Mathematik Olaf Postfach 100131 (room: V4-109) `=' D-33501 Bielefeld, Germany (phone: +49 521 106-4765) http://www.mathematik.uni-bielefeld.de/~delgado From " HPeter.Friedrichs" at alliedsignal.com Wed Jun 30 19:49:58 1999 From: " HPeter.Friedrichs" at alliedsignal.com (H. P. Friedrichs) Date: Wed, 30 Jun 1999 16:49:58 -0700 Subject: Help: Can you explain this error? (contains code snip) Message-ID: <377AAD25.96947EBA@alliedsignal.com> Hello: This is week 2 for me in python...What fun! I have stumbled across an interesting problem. When the code below is run under Win95 (python 1.5.2),it works without problems. If the same code is run under Linux (python 1.4) I get the error: Traceback (innermost last): File "socksrv3.py", line 100, in ? han=int(handle) #extract integer representation of handle TypeError: int() argument can't be converted to int The code section below is part of a larger program that receives ascii "link messages" through a TCPIP socket. The format for the message is as follows: an ascii "handle" followed by a tilde, followed by an ascii "verb", followed by a tilde, and concludes with an ascii "value" An example looks like this: "123~opensym~0" Anyhow, the code below uses splitfields to break the message into it's constituent parts. Later, at the line signified by the marker "====>" the program blows up when I attempt to convert the string "handle" into it's integer equivalent. What gives? Is the 1.4 version of python buggy, or am I overlooking something? Thanks for your help in advance. Pete #*** receive link msg **** cmd=conn.recv(1024) #try to get a message if not cmd: print"closing connection..." conn.close() #good housekeeping...close cnnctn break #*** extract components of link message *********** fieldlist=splitfields(cmd,"~") #break message to constituents handle=fieldlist[0] #extract handle verb=fieldlist[1] #extract verb value=fieldlist[2] #extract value #****** if command requested write to existing symbol, do this: if verb == "writesym": ====> han=int(handle) #extract integer representation of handle masterdict[han]=float(value) response=handle+"~"+verb+"~"+value #build response string print "tx'd response:",response print "dict status: ",masterdict conn.send(response) #send response continue -- ----------------------------------------------- | The opinions expressed here are my own, | | and not necessarily those of my employer. | ----------------------------------------------- From techentin.robert at mayo.edu Thu Jun 10 15:47:52 1999 From: techentin.robert at mayo.edu (Bob Techentin) Date: Thu, 10 Jun 1999 14:47:52 -0500 Subject: Why is tcl broken? References: <375F82C7.CF0F0477@iname.com> <375FF969.C879B4CD@iname.com> Message-ID: <37601668.D9105225@mayo.edu> These flame wars are more than five years old. Tcl has had namespaces and a byte-code compiler for years. If you want "current" issues, you might just read comp.lang.tcl, or the "frequently made mistakes" available from the FAQs at http://www.tclfaq.wservice.com/tcl-faq/ You'll find complaints about commenting out blocks of code and accidental conversions to octal. Fernando Mato Mira wrote: > > Lars Marius Garshol wrote: > > > * Fernando Mato Mira > > | > > | I'm trying to collect a list of all the _current_ issues making tcl > > | a bad language choice. > > > > You can find three interesting articles on this at > > > > > [snip] > > http://www.vanderburg.org/~glv/Tcl/war/ > http://www.vanderburg.org/~glv/Tcl/war2/ -- Bob Techentin techentin.robert at mayo.edu Mayo Foundation (507) 284-2702 Rochester MN, 55905 USA http://www.mayo.edu/sppdg/sppdg_home_page.html From dave_kirby at eur.3com.com Thu Jun 17 12:32:09 1999 From: dave_kirby at eur.3com.com (Dave Kirby) Date: Thu, 17 Jun 1999 16:32:09 GMT Subject: wierdness with pythonwin dialogs, threads & refcounts References: <1282492928-113747642@hypernet.com> Message-ID: <37690c3e.27197698@nnrp.uk.insnet.net> On Thu, 17 Jun 1999 09:21:51 -0500, "Gordon McMillan" wrote: >Dave Kirby writes: > >> I have found strange behaviour (strange to me at least) when >> creating a pythonwin dialog on a separate thread created using the >> standard python thread module. The dialog object is never deleted >> since the thread is keeping references to it. >> [example snipped] > >First, there's no incompatibility with the thread module in >Pythonwin. > >Second, you should use threading.py, not the low level thread module >(which is very, very primitive). Or you can use >win32process.beginthreadex which is a wrapper around MFC threads. >This lets you manipulate priorities. (As of a couple years ago, there >was a small memory leak involved with using MFC threads, however). I have just tried both the threading.py and beginthreadex with the same results - vis: [carrying on from the previous example] >>> import win32process >>> test() Edit text changed! refs: 2 >>> x = win32process.beginthreadex( None, 10000, test, (), 0 ) >>> refs: 6 >>> import threading >>> thread = threading.Thread(target = test) >>> thread.start() >>> refs: 6 Again the refcount is 6 when test is run from a separate thread, but 2 when run in the main thread. > >As for the source of your questions - without doing things in a debug >build of python / Pythonwin, it's almost impossible to tell what's >going on, or even if there really is a problem. > >Using sys.getrefcount increments the refcount. Printing something in >the interactive interp binds the thing to a var named "_" (to >optimize looking at it again). Printing to stdout in Pythonwin >involves all kinds of hidden manipulations. > >If you want to know whether you're leaking TestDialogs you could code >a loop that creates threading.Thread's that show a TestDialog and >then joins the Thread. Run it for as many iterations as you can >stand, and watch the process in TaskManager. I am pretty sure there is a real problem here. Whatever the hidden manipulations are it shouldnt make any difference which thread it is running in. I discovered this problem because the __del__ method was not being called for the dialog class in the program I am writing. When I moved it to the main thread it was destroyed ok. I will play around with this some more and try to narrow it down further, but I am not intimate with either the internals of pythonwin or Windows threads, so don't hold your breath. One thought that did occur to me is that the python thread/threading modules and win32process.beginthreadex are all creating worker threads so there is no message processing being done to clean up the dialog when it is closed. I will test this hypothesis as soon as I have figured out how to create GUI threads in pythonwin. Regards, Dave K From graham at sloth.math.uga.edu Wed Jun 9 14:17:43 1999 From: graham at sloth.math.uga.edu (Graham Matthews) Date: 9 Jun 1999 18:17:43 GMT Subject: Python 2.0 References: <000b01beb21f$a17ff340$2fa22299@tim> Message-ID: <7jmb47$r22$1@cronkite.cc.uga.edu> Tim Peters (tim_one at email.msn.com) wrote: : The caveats are explained well in the Java Language Spec, section 12.6. In : short, you can't know which thread a finalizer will run in; you can't be : sure that an object is unreachable at the time its finalizer is invoked; you : can't know *when* a finalizer will be invoked; even if it is unreachable at : the time its finalizer is invoked, you can't be sure that it won't become : reachable again *after* the finalizer returns; and in the case of cyclic : object structures nothing is specified about the order in which the objects' : finalizers will be called (indeed, they may all run simultaneously). There are two obvious answers to almost all the above problems in Python a) don't call finalisers for circularly referenced collected objects. Instead just collect their memory. This is not perfect but better than current Python which doesn't run finalisers on circularly referenced objects nor collect their memory. b) better still use a two pass collector. If you don't know what that is just think about what you need to do (or not do) in pass 1 to ensure that all the objects needed for a __del__ method to execute in a known environment are there. graham -- As you grow up and leave the playground where you kissed your prince and found your frog Remember the jester that showed you tears the script for tears From mlh at idt.ntnu.no Mon Jun 21 08:29:24 1999 From: mlh at idt.ntnu.no (Magnus L. Hetland) Date: 21 Jun 1999 14:29:24 +0200 Subject: simple text file 'parsing' question References: <376B1AAC.19FE8BCE@mysolution.com> Message-ID: Matt Gushee writes: > KP writes: > > > Here's my dilema: a directory filled (200+) with small emails. My goal > > is to strip all the headers and combine them into one file. I can read > > all the files just fine and write them all to one file, but I cannot > > discern how to strip the headers. Just remove everything up to and including the first blank line. That represents the end of the header. For instance: file = open(resultFileName,'w') # ... lines = open(name).readlines() lines = lines[lines.index("")+1:] file.writelines(lines) # ... file.close() -- Magnus Making no sound / Yet smouldering with passion Lie The firefly is still sadder / Than the moaning insect Hetland : Minamoto Shigeyuki From mukundd at my-deja.com Wed Jun 30 15:17:28 1999 From: mukundd at my-deja.com (mukundd at my-deja.com) Date: Wed, 30 Jun 1999 19:17:28 GMT Subject: Problem embedding C++ code Message-ID: <7ldqfs$nbj$1@nnrp1.deja.com> Hi, I am trying to write a wrapper around a library written in C++ and I am running into lots of problems. I am running Python 1.5.2 on SunOS 5.5.1 (compiled with SUN's cc and linked with Sun's CC) The wrapper is written in a file called link-wrap.c and currently it contains only one very simple function. CC -c -KPIC link-wrap.c -I/home/mdeshpan/SW/include/python1.5 "link-wrap.c", line 13: Warning: String literal converted to char* in formal argument 1 in call to Py_BuildValue(char*, ...). 1 Warning(s) detected. CC -G link-wrap.o -lapic -lpthread -o link.so libapic.so is the library which I am trying to write the wrapper for, it was compiled using Sun's CC compiler when I try to import link module in python I get the following error.. daffy:~/Swig$python Python 1.5.2 (#3, Jun 29 1999, 11:17:23) [C] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import link Traceback (innermost last): File "", line 1, in ? ImportError: ld.so.1: python: fatal: relocation error: file ./libapic.so: symbol _ex_rethrow_q: referenced symbol not found any help would be greatly appreciated.. Thanks in advance Mukund Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From tim_one at email.msn.com Fri Jun 4 21:42:17 1999 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 4 Jun 1999 21:42:17 -0400 Subject: threads In-Reply-To: <14168.18308.709890.544779@bitdiddle.cnri.reston.va.us> Message-ID: <000a01beaef4$a53dda20$f19e2299@tim> [Jeremy Hylton, on why free-threading may slow things down] > If I recall correctly, the problem is that taking away one big lock > usually requires introducing lots of little locks. (There's some kind > of conservation of concurrency going on.) Right now, there is no need > to have locks on access to builtin types like dictionaries, because > only a single thread can hold the interpreter lock anyway. When that > goes away, you need to add lots of fine-grained locking on the builtin > types. Refcount incref/decref are also unsafe without a lock, and one of those occurs even more often than it's suggested "real GC" would eliminate the need for them . the-guarantee-of-exclusion-simplifies-much-of-the-implementation-ly y'rs - tim From tismer at appliedbiometrics.com Wed Jun 2 06:09:11 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Wed, 2 Jun 1999 10:09:11 GMT Subject: need help checking for stack overflow in Win32 References: <5lk8to3su3.fsf@eric.cnri.reston.va.us> <7j1pcc$256$1@m2.c2.telstra-mm.net.au> Message-ID: <375502C7.39C4FD0E@appliedbiometrics.com> Mark Hammond wrote: > > Actually, I was about to post this yesterday, and to prove my point I wrote: > > def die(): > die() > > Expecting to see the crash. I was then going to go into a rant about how > win32api.Apply would actually let you catch this (and any other Win32) > exception as a temporary solution. > > But it worked correctly - ie, Python raised a RuntimeError: Max Recursion. > > So I guessed that 1.5.2 had fixed this, presumably by reducing the recursion > count for Win32. Apparently not! Nope. The trap is: You compiled with VC++ 6.0 which has better register spilling. Therefore, recusion costs only 100 bytes, not 104. Not calculate 104 * 10000 and you see why 1 MB stack lets it crash. I submitted a patch program for this kind of problems, so I think there is no need to change Python 1.5.2 at all. cheers - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From ivnowa at hvision.nl Fri Jun 4 12:42:15 1999 From: ivnowa at hvision.nl (Hans Nowak) Date: Fri, 4 Jun 1999 16:42:15 GMT Subject: Alien whitespace eating nanovirus strikes again! In-Reply-To: <3757F28B.BF6411FE@cwcom.net> References: <3757F28B.BF6411FE@cwcom.net> Message-ID: <199906041640.SAA05103@axil.hvision.nl> On 4 Jun 99, Daniel Faulkner wrote: > How many messages are there about this white space stuff? Looks like millions whats > it all about? Oh, this thread is only trivial compared to the one about the Python version that only exists in Guido's head so far. :o) You are new to Python? The short story is: in languages like C, you define blocks using block delimiters: void p() { int x; blahblah(); } or Pascal, procedure P; var x; begin blahblah; end; (OK, so these examples don't make much sense. :-) Anyway, you'll get the point. Python does not have such delimiters; rather than that, indentation (thus, use of whitespace) is used: def p(): x = 0 blahblah() Same thing for if-constructs, while, etc. Not everybody likes to use whitespace for indentation. This seems to be especially true for people coming from a C or Perl background. If you search DejaNews for old messages, you will find tons of messages dealing with this subject (usually people asking for block delimiters vs people defending the Python style). I dare say that many people like this Python feature a lot, since it improves readability greatly. But as said, not everyone does, and this fuels discussions greatly. Those are really a waste of bandwidth though, since (IMO) Guido is not going to change it. :-) Veel liefs, --Hans Nowak (ivnowa at hvision.nl) Homepage: http://fly.to/zephyrfalcon From tim_one at email.msn.com Wed Jun 16 01:21:57 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 16 Jun 1999 01:21:57 -0400 Subject: Newbie: Truth values (three-valued logic) In-Reply-To: Message-ID: <000f01beb7b8$2722a540$2ca22299@tim> [Olaf Delgado] > I am just starting to use python seriously. Currently, I am porting a > small class library from C++ to python, which is kind of fun. Everything's > much more simple and elegant now. Except for C++ . > There's one thing I could do in C++, though, which doesn't seem to work in > python: some methods need to return truth values, which can be 1 for > 'true', 0 for 'false' and x for 'frankly I don't know'. > ... [but 'not' only delivers true or false] ... > As far as I know, the logical negation operator can not be overloaded, > so I have no chance to change this, right? Right. I'd try overloading "~" instead (the unary prefix "complement" operator, special method name __invert__): >>> class uncertain: def __nonzero__(self): return 0 def __repr__(self): return 'dunno' def __invert__(self): return self >>> maybe = uncertain() >>> if maybe or ~maybe: print "maybe or not maybe!" else: print "we don't need no stinking excluded middle!" we don't need no stinking excluded middle! >>> Under this hack, may work best if you use 0 to represent false and -1 to represent true: >>> ~0 -1 >>> ~-1 0 >>> OTOH, overloading sucks when you have to fight the language -- and 90% of the time even when you don't <0.9 wink>. functions-spelled-as-functions-rarely-confuse-ly y'rs - tim From tim_one at email.msn.com Sun Jun 6 16:11:39 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 6 Jun 1999 16:11:39 -0400 Subject: Suggestion: Dutch Python mailinglist In-Reply-To: Message-ID: <000101beb058$c992bc00$e39e2299@tim> [Gerrit Holl] > This e-mail is in two languages. Look below for the Dutch version. > Deze e-mail is in twee talen. Kijk beneden voor de Nederlandse versie. > > Hello all, > I'm a 13-years-old Dutch boy, and my English is not good. Now I have the > chance to set up a Dutch python mailinglist. I know there are many Dutch > python-users, but most of them know English very well. So will there be > any users who'll subscribe to such a mailinglist, or will it > remain very quiet? > > regards, > Gerrit. Gerrit, rest assured that your English is better than that of most 13-year-old Americans! Don't know about young Englishmen, but they spell funny anyway . one-day-the-whole-world-will-speak-python-ly y'rs - tim From akuchlin at mems-exchange.org Tue Jun 22 17:24:26 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: Tue, 22 Jun 1999 17:24:26 -0400 (EDT) Subject: Unbound method In-Reply-To: <001701bebcdd$73d3b080$656211c8@miro.lami.pucpr.br> References: <001701bebcdd$73d3b080$656211c8@miro.lami.pucpr.br> Message-ID: <14191.65290.126498.62145@amarok.cnri.reston.va.us> faria writes: >Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 >Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>>> from test import * >>>> x = A >>>> x.a >'Greetings from Brasil!!!' >>>> x.pa > x is a class, not an instance. This can be made clearer with different variable names: >>> klass = A >>> instance = A() >>> klass >>> instance <__main__.A instance at f22c8> >>> klass.a 'Greetings from Brasil!!!' >>> instance.a 'Greetings from Brasil!!!' >>> klass.pa >>> instance.pa If you're expecting x = A to create an instance of the class A, that expection is incorrect; you have to do x = A() to create an instance. -- A.M. Kuchling http://starship.python.net/crew/amk/ In the design of fission reactors man was not an innovator but an unwitting imitator of nature. -- George A. Cowan, "A Natural Fission Reactor" From rozzin at hotmail.com Sat Jun 12 01:43:02 1999 From: rozzin at hotmail.com (Joshua Rosen) Date: Sat, 12 Jun 1999 01:43:02 -0400 Subject: import posixpath References: <199906100438.AAA16802@tor.dhs.org> Message-ID: <3761F366.5AA93D00@hotmail.com> Can't one import posixpath, regardless of what OS one is running on, and expect posixpath.split to give the proper result, here? From mwh21 at cam.ac.uk Wed Jun 16 17:16:58 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 16 Jun 1999 22:16:58 +0100 Subject: ANN: Stackless Python 0.2 References: <37628EAA.C682F16C@appliedbiometrics.com> <7k4fd4$c04$1@brick.cswv.com> <376636EA.84240129@appliedbiometrics.com> <7k6ttr$i5g$1@brick.cswv.com> <37679151.6C6B29DF@appliedbiometrics.com> Message-ID: Christian Tismer writes: > Michael Hudson wrote: > > > Got this one; PyEval_Frame_Dispatch is defined static in > > Python/ceval.c. Take the keyowrd static out, and it builds and runs > > fine (in my limited testing so far). > > Ah, thanks. Yes, this function was a local eval_frame_dispatch, > before I realized that it needs to be exposed as an API > function. Ahem, forgot to change the decl. > > Someone else told be that in frameobject.h, my forward > type declaration gives problems with some compilers. > What is the standard way to do this? The problem I had with this was that you had code like typedef struct _frame PyFrameObject; ... stuff ... typedef struct _frame { ... stuff ... } PyFrameObject; which egcs didn't like; I changed it to typedef struct _frame PyFrameObject; ... stuff ... struct _frame { ... stuff ... }; and everything went smoothly. > thanks - chris HTH Michael From zigron at jps.net Fri Jun 25 22:57:48 1999 From: zigron at jps.net (Zigron) Date: Fri, 25 Jun 1999 19:57:48 -0700 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> <3773c3a0.102825445@news.oh.verio.com> Message-ID: Michael P. Reilly wrote in message news:xJRc3.292$Of3.67094 at news.shore.net... > Zigron wrote: > : Kevin Dahlhausen wrote in message (snip) > I wouldn't care if wxPython was standard, I would still use Tkinter, > better design philosophy, IMTO (most anything is better than > MFC-oriented systems, even curses). > > There are other graphical packages for Python out there too, it would > be appropriate to contrast them as well. Exactly. There are plenty of GUI packages out there, why have a standard one? For me, for everything I want to do, wxPython is a very obvious and clear choice. For you, its Tkinter. What annoys me is that Tkinter *is* the de-facto standard, and is actually now shipped with python itself. If TCL wasn't involved, if they DID use the TK/C api, that wouldn't be such a problem.. but they do, so, the whole 'if they did.....' argument is moot. > Python is a good language, with good extension capabilities. I think > there is enough room for more than one GUI package. I think there will always be handfulls, regardless. No one will ever agree that one is the best. --S From ovidiu at cup.hp.com Thu Jun 10 22:25:19 1999 From: ovidiu at cup.hp.com (Ovidiu Predescu) Date: 10 Jun 1999 19:25:19 -0700 Subject: complete GNU readline support? References: <37445622.1EE18CFD@cup.hp.com> <374B8030.A29351CA@_nospam_ken.x13.com> <3754600B.F78CD96A@cup.hp.com> <87pv3ft7i0.fsf@ifm.uni-kiel.de> Message-ID: I need to figure out some copyright issues with my company, as it was written for a project here. I don't expect to have major problems with the last item but it may take a while (hopefully not too much). -- Ovidiu Predescu http://www.geocities.com/SiliconValley/Monitor/7464/ From sragsdale at my-deja.com Thu Jun 3 22:52:16 1999 From: sragsdale at my-deja.com (sragsdale at my-deja.com) Date: Fri, 04 Jun 1999 02:52:16 GMT Subject: Changing environment variables into python variables Message-ID: <7j7f0t$165$1@nnrp1.deja.com> I'm writing a script that needs to import environment variables into python as standard variables. I.E. if the environment variable USER is set to 'soren', after my program starts up and does its thing I want there to be a variable named USER with a value of 'soren'. I can write this program with little effort in perl: foreach my $var (keys(%ENV)) { my $cmd = "\$".$var." = '".$ENV{$var}."'"; print $cmd,"\n"; # just to see what I'm doing eval($cmd); } When I try to write this in python, I have this error: ------------------------------- import posix for var in posix.environ.keys(): command = var+" = \""+posix.environ[var]+"\"" print command eval(command) ------------------------------- > ./importer.py Traceback (innermost last): File "./importer.py", line 12, in ? eval(command) File "", line 1 WF_VC_PLUG_INS = "/usr/local/aw/userconfig/composer/plug-ins" ^ SyntaxError: invalid syntax ------------------------------- What am I doing wrong here? How can I, at runtime, define a variable and assign it a value? Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From never at matavnet.hu Wed Jun 23 17:51:20 1999 From: never at matavnet.hu (Zsolt Hever) Date: Wed, 23 Jun 1999 23:51:20 +0200 Subject: [ANN]: Article about Python in Hungary Message-ID: <199906232156.RAA20257@python.org> Hi there, I saw a discussion about "Is Python dying?" on the mailing list some months ago. That time I decided to write an article about Python in a paper. Now the article was published in the CHIP Magazine in Hungary yesterday. The title is The friendly snake. I made a HTML version of that < http://www.cab.u-szeged.hu/~h532851/cikk/index.htm >. It was written on the base of the FAQ, interviews, articles about Python and other languages (Perl, Rebol) and my experience. The content: ======== Shortly about Python What language is that? Installing of Python Documentation and examples Learning the language Writing and running of Python programs Life of Python Some interesting developments Summary Hungary is not a big country (10 million inhabitants), and not everybody is a programmer. I put a counter on the main page < http://www.cab.u-szeged.hu/~h532851/python.htm > to see the interest. I hope it helps Python to be known better. Zsolt From gduzan at gte.com Tue Jun 29 14:26:41 1999 From: gduzan at gte.com (Gary Duzan) Date: Tue, 29 Jun 1999 14:26:41 -0400 Subject: ANN: Stackless Python 0.2 References: <000c01bec11f$8dfbf800$e19e2299@tim> <19990629121441.A19011@longford.cs.monash.edu.au> Message-ID: <37790FE1.4F778B4C@gte.com> Toby J Sargeant wrote: > > On Mon, Jun 28, 1999 at 12:34:48AM -0400, Tim Peters wrote: > > Nope! It's a beauty of the implementation already that each code object > > knows exactly how much "Python stack space" it needs, and (just) that much > > is allocated directly into the code object's runtime frame object. IOW, > > there isn't "a Python stack" as such, so there's nothing to change here -- > > the stack is implicit in the way frames link up to each other. > > This might be completely irrelevant, but during the course of my masters, I > considered doing this kind of thing to java in order to allow asynchronous > threads to share stack frames (don't ask...). My supervisor complained bitterly > on the grounds that function invocations where orders of magnitude more > common than object creation, and hence associating memory > allocation/deallocation with every call was considered horrendously > inefficient. This appears to be the conventional wisdom. The optimization class I took used an ML-like language, and the first thing we did was to move heap frames, which was the default, to the stack (i.e. closure optimization.) It might be less of an issue in an interpreted language if it already has heap allocation (or other sorts of) overhead to deal with when making calls. There may be other allocation tricks which can be used, as well. > It seems that this should affect Stackless Python equally as much. Does anyone > have anything to add on the subject? I would imagine that frames could be > allocated and managed in chunks to alleviate a lot of the memory management > load... I would think that as well (at least at first.) Maybe pools of different sizes of frame to limit the space overhead. > Toby. Gary Duzan GTE Laboratories From graham at sloth.math.uga.edu Thu Jun 3 11:22:57 1999 From: graham at sloth.math.uga.edu (Graham Matthews) Date: 3 Jun 1999 15:22:57 GMT Subject: Python 2.0 (perhaps off topic) References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> Message-ID: <7j66kh$il5$5@cronkite.cc.uga.edu> Paul Prescod (paul at prescod.net) wrote: : I think that that is all anyone has been saying. Many people like the : current semantics and don't trust that a full GC would deterministically : invoke finalizers for arbitrary resources. Why do you think this? See my post about adding a mark and sweep collector *on top of* the existing ref count semantics. graham -- So I turned around And 40,000 headmen bit the dirt Firing twenty shotguns each And man it really hurt From news at dorb.com Tue Jun 22 20:25:04 1999 From: news at dorb.com (Darrell) Date: Tue, 22 Jun 1999 20:25:04 -0400 Subject: Help with String Manipulation References: <0UUb3.1337$el4.44932@ord-read.news.verio.net> Message-ID: <0SVb3.1951$U6.7016@newsr2.twcny.rr.com> >>> s='now is the time' >>> l=list(s) >>> l.reverse() >>> l ['e', 'm', 'i', 't', ' ', 'e', 'h', 't', ' ', 's', 'i', ' ', 'w', 'o', 'n'] >>> import string >>> string.join(l,'') 'emit eht si won' -- --Darrell Samuel G. Williams wrote in message news:0UUb3.1337$el4.44932 at ord-read.news.verio.net... > I know this is a very stupid question and one that has been addressed > within available documentation, however I need a quick hand. I am in need > of a routine to reverse the order of a string. I have tried several things > that have resulted in failures. It is really stupid, but I am just > learning python. I can do this readily in C, perl, tcl, but am at a loss. > I would appreciate any help I can get. > > Thanks in advance. > > -- > > > Sam Williams wb5yni samurai at acm.org > Senior IS Staff Specialist samw at wwa.com > -------------------------------------------------------------------------- - > > Thinking of running your critical apps on NT? > > Isn't there enough world suffering? From tjreedy at udel.edu Tue Jun 22 02:52:22 1999 From: tjreedy at udel.edu (Terry Reedy) Date: 22 Jun 1999 06:52:22 GMT Subject: newbie idiom question References: Message-ID: <7knbr6$kas$3@news.udel.edu> In article , alex at mindlube.com says... > >Something I keep getting tripped up about is that objects being >iterated in "for" statements cannot be modified. It depends on whether the objects are mutable or not. >I keep trying to do this: > > >>> eggs = [1,2,3] > >>> for spam in eggs: > ... spam = 'cooked' > ... > >>> eggs > [1, 2, 3] > >>> Modifying the list by replacement is relatively easy. eggs = [1,2,3] for i in range(len(eggs)): eggs[i] = 'cooked' >The tutorial says this: > > If you need to modify the list you are iterating over, e.g., duplicate > selected items, you must iterate over a copy. The slice notation makes > this particularly convenient: > > >>> for x in a[:]: # make a slice copy of the entire list > ... if len(x) > 6: a.insert(0, x) > ... > >>> a > ['defenestrate', 'cat', 'window', 'defenestrate'] This applies to insertions and deletions. Without making a copy, the result in difficult to predict. >Understood, but what if you want to modify each element in a list? Do you actually want to change the elements (leaving the list the same) or change the list? Terry J. Reedy From avv at quasar.ipa.nw.ru Fri Jun 25 14:28:55 1999 From: avv at quasar.ipa.nw.ru (Alexander V. Voinov) Date: Fri, 25 Jun 1999 11:28:55 -0700 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> Message-ID: <3773CA67.7057F797@quasar.ipa.nw.ru> Mikael Lyngvig wrote: > I'd like some discussion on whether or not it is a good idea to > abandon TkInter, Yes, it's a good idea, I vote. > before it gets too widely used, and instead adopt > wxPython as the primary GUI framework for Python. I trace the mailing lists for the wxWindows itself and wxPython. As I understand, Robin Dunn *alone* tries to keep in sync with the wxWindows, which is *very* intensively developed by a dozen or more of active contributors. It seems that if it were more possible to extend wxPython and let it do more collaboratively it would be best we can gain for a native Python GUI. (Probably I'm not absolutely correct in all of my observations, unfortunately I do not have enough spare time to participate in wxPython deeper). I'm also glad to observe that wxWindows community is *very* friendly to wxPython. It even extends its manual to describe in detail small deviations which wxPython imposes on the underlying toolkit to let it look and feel more Pythonically. Alexander From mlv at pobox.com Wed Jun 2 23:06:13 1999 From: mlv at pobox.com (Michael Vezie) Date: 2 Jun 1999 23:06:13 -0400 Subject: pickle vs .pyc References: <7j43pn$55l$1@mlv.mit.edu> Message-ID: <7j4rf5$5h0$1@mlv.mit.edu> In article , Michael Hudson wrote: > >Hmm, you're relying on all the data you're storing having faithful >__repr__ methods. This certainly isn't universally true. I'd regard >this method as too fragile. Granted. It wouldn't do for the file to contain: fast = <__main__.fast instance at 8137590> slow = <__main__.slow instance at 8137590> But the data I'm dealing with is all dictionaries of arrays of dictionaries, all containing strings. Pretty boring; no class at all. >If you're only storing simple data (by which I mean simple types of >data, not that the data is simple) (and I think you must be for the >approach you're using to work) give the marshal module a whirl. This is the first I've heard of marshal. I take it from various hints here and there that the .pyc files are handled internally by marshal, yes? Thanks for your (and everyone else's) help. One final asside, I've seen disagreements both online and in the web docs about the spelling of marshal. I did a search and found 12 hits for "marshall" (now granted, some are probably unrelated, I didn't trace them all). But there were enough to make me think that 'marshall' was the right spelling. But the fact that 'import marshal' worked while 'import marshall' failed convinced me otherwise. :) marshaling-up-the-courage-to-convert-working-code-to-marshal'ly yrs ... (hoping-this-'ly yrs-tag-isn't-trademarked-or-only-available- to-those-who've-achieved-some-level-of-pythondom'ly yrs) Michael From 8499 at greenhead.ac.uk Wed Jun 30 06:55:49 1999 From: 8499 at greenhead.ac.uk (Newbie) Date: 30 Jun 1999 05:55:49 -0500 Subject: Decent Tutorial References: <377925EF.1CBB640F@starvision.com> <011a01bec2d3$c215a900$f29b12c2@secret.pythonware.com> Message-ID: <3779e9a5@discussions> Where can I find a decent tutorial which is for beginners to Python, preferably including some documented source code and avaliable for download. Thanks. From wware-nospam at world.std.com Wed Jun 9 23:14:35 1999 From: wware-nospam at world.std.com (Will Ware) Date: Thu, 10 Jun 1999 03:14:35 GMT Subject: "Programming Python" still worthwhile? References: <1283218560-70098357@hypernet.com> <375E9943.F9FEA7BA@gssec.bt.co.uk> <375f23fe.1133449@nntp.ix.netcom.com> Message-ID: : > At work we have Python 1.3 (don't ask!) and at home I use Where I work, the publicly available version is 1.2. I maintain a private copy of 1.5.2 for my own use. As far as I'm aware, nobody else in the company is using Python at all. -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Will Ware email: wware[at]world[dot]std[dot]com PGP fp (new key 07/15/97) 67683AE2 173FE781 A0D99636 0EAE6117 From rdev at my-deja.com Wed Jun 30 13:59:45 1999 From: rdev at my-deja.com (rdev at my-deja.com) Date: Wed, 30 Jun 1999 18:59:45 +0100 Subject: Reflection in Python? Message-ID: <000015c6@bossar.com.pl> From: rdev at my-deja.com In article <7ldglr$ita$1 at nnrp1.deja.com>, anders777 at my-deja.com wrote: > ...How do I do the > equivalent of what Java calls reflection? I want > to do the following: > > test = MathTest("testAdd") > > where test.run() will run the "testAdd" method on > the MathTest object? I also want to be able to > tell the user the name of the object (MathTest) > and the method in case the method fails. Any > thoughts? > If I understand what you are trying to do, it's easy in Python. Assuming MathTest is an object instance: test = MathTest.testAdd will return you a bound method object which you can then call as: test() Getting the name of the object class and method is also easy. There are several ways to do this: 1) Define a doc string within the method by putting a quoted string as the first line under the def line. You can then refer to it as "test.__doc__". This could say, for example, "Method bar of class foo". 2) "test.__name__" will return the name of the method. "test.im_class.__name__" will return the name of the class that the method is defined within. Example: class MathTest: def testAdd(self, parm1, parm2): "Method testAdd of Class MathTest" result = parm1 + parm2 return result <<< mt = MathTest() <<< test = mt.testAdd <<< test.run(2,2) 4 <<< print test.__doc__ Method testAdd of Class MathTest <<< print test.__name__ testAdd <<< print test.im_class.__name__ MathTest I hope that helps. - Roger > Thanks, > Anders Schneiderman > National Journal Daily Briefings Group > > Sent via Deja.com http://www.deja.com/ > Share what you know. Learn what you don't. > Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From greg.ewing at compaq.com Thu Jun 24 18:19:05 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Fri, 25 Jun 1999 10:19:05 +1200 Subject: Why exceptions shouldn't be used for flow control [Re: YAS to the "Reading line-by-line" Problem] References: <376FDF70.4756AD38@mindspring.com> <377173F7.36BCFF6B@compaq.com> Message-ID: <3772AED9.D9E1110@compaq.com> William Tanksley wrote: > > "Not exceptional enough". What does that mean? (I ain't never had too > much exception! ;-) Sorry, I was using "exceptional" in a non-technical sense there. I meant "not abnormal enough". I don't agree that reaching EOF is necessarily "abnormal". If I want to read all the data in a file, and I don't know in advance how much there is, I write a loop that keeps reading until EOF. In that case, reaching EOF is not abnormal at all - it's bound to happen eventually! On the other hand, if I have reason to believe that there should be a certain amount of data left, and I hit EOF while trying to read it, then that is certainly an error, and raising an exception is a reasonable thing to do. The question, then, is what a general-purpose library routine should do on EOF, given that the "right thing" depends on the circumstances. You would have it always throw an exception, and require the programmer to catch it if it is an "expected" exception. Personally, I prefer it the way it is. If I want an exception thrown, I can always write a wrapper which does so. Doing it the other way around - wrapping exception-throwing code into something which doesn't - is trickier to get right; as I've shown, it's hard to make sure that it catches only what you want to catch. > In addition, the complexity of the failure required to produce this is > pretty high. How many files do you need to read to get the next line from > this file? It's perhaps not the best example of this kind of problem. A better one, which I actually have experienced, is from the days when it was common to catch KeyError as a way of telling when a key wasn't in a dictionary: try: v = d[the_key()] except KeyError: v = some_default_value The subtle problem with that piece of code is that if there is a bug which causes the_key() to raise a KeyError (which I think you'll agree is *not* an unlikely event) it gets incorrectly caught instead of triggering a traceback. To guard against that, you have to be very careful what you put inside the try: i = the_key() try: v = d[i] except KeyError: v = some_default_value This is one of the reasons that the get() method was added to dictionaries. Using it, you can write v = d.get(the_key(), some_default_value) which is not only less error-prone but shorter and clearer as well. > If someone else's uncaught EOFError hits this function, something nasty is > almost always going to happen... if it fails, it does so loudly so that > the tester notices and reports the problem. But that's exactly what *doesn't* happen! The misdirected exception silently terminates a loop that it wasn't meant to terminate, and later on the program fails with some set of symptoms that give little or no clue as to what the original cause was. I would much rather get a traceback pinpointing exactly what was thrown and where it was thrown from. > C is famous for noiselessly casting the -1 to a char (look at > the old Bash security bug), and Python is even worse -- any return you can > possibly make will almost certainly fit in noiselessly with anything you > do with it. The design of read() is perhaps not the best here -- it might be better to return None, which would cause most things expecting a string to blow up rather more quickly. > You ought to feel lucky. Some respected programming gurus recommend > calling abort() on any odd results Raising an exception is Python's equivalent of calling abort(). But it only works as such if you can be sure that your exception isn't going to be caught by something that makes unwarranted assumptions about its cause. The more you use exceptions for "normal" things, such as EOF or KeyError or IndexError when they aren't really errors, the more likely that is to happen. In my experience, anyway. Greg From scott at chronis.pobox.com Mon Jun 21 17:22:37 1999 From: scott at chronis.pobox.com (scott cotton) Date: Mon, 21 Jun 1999 17:22:37 -0400 Subject: Check for valid date In-Reply-To: <7klq51$etp$1@nnrp1.deja.com>; from Remi Delon on Mon, Jun 21, 1999 at 04:44:20PM +0000 References: <7klq51$etp$1@nnrp1.deja.com> Message-ID: <19990621172237.A4612@chronis.pobox.com> you could try making sure that strftime(your_format, strptime(date2check, your_format)) == date2check. and checking for OverflowError & ValueError in the process. scott On Mon, Jun 21, 1999 at 04:44:20PM +0000, Remi Delon wrote: | Hi, I'm trying to use the time module to check whether a date is | actually a valid day or not. | Unfortunately, it looks like the strptime function only performs a basic | range check. (for example, it will accept 02/30/199) | Here is a little test I did: | | >>> strptime('02/30/1999','%m/%d/%Y) | (1999, 2, 30, 0, 0, 0, 61, 0) | >>> mktime((1999, 2, 30, 0, 0, 0, 61, 0)) | 920361600.0 | >>> ctime(920361600.0) | 'Tue Mar 2 00:00:00 1999' | | Is there a way to check test whether the day actually exists or not ? | | | I also have a totally different problem : I'm trying to get python 1.5.2 | to run with Tcl/Tk 8.1. Has anyone been able to do that on AIX ? | I found 2 patches for tkinter that were supposed to fix the problems, | but unfortunately, they don't work for AIX. | | Thanks | | Remi. | | | Sent via Deja.com http://www.deja.com/ | Share what you know. Learn what you don't. | | -- | http://www.python.org/mailman/listinfo/python-list From mmorris at mindspring.com Wed Jun 23 19:52:11 1999 From: mmorris at mindspring.com (Mitchell Morris) Date: Wed, 23 Jun 1999 23:52:11 GMT Subject: It's just magic, and I hate it ... References: <14190.35530.772547.166720@buffalo.fnal.gov> <37703621.B29B72CB@bioreason.com> Message-ID: <930181790.156.59@news.remarQ.com> In article , mmorris at mindspring.com wrote: [snip] In a very polite private e-mail, Tim Peters pointed out that this is a FAQ, number 4.87 in fact. That will teach me to not check *ALL* the docs before opening my trap. Thanks to everyone ... I appreciate your time and efforts on my behalf, +Mitchell From srn at fn.com.au Wed Jun 9 02:23:45 1999 From: srn at fn.com.au (Stephen Robert Norris) Date: 9 Jun 1999 06:23:45 GMT Subject: tstate invalid crash with threads References: <000101beb237$88b71d80$999e2299@tim> Message-ID: <7jl19h$ofs$1@crux.cs.usyd.edu.au> In article <000101beb237$88b71d80$999e2299 at tim>, "Tim Peters" intoned: > Followups to the Thread-SIG, please. > > [Ray Loyzaga] >> I have been playing with a multithreaded tcp based server for a while, >> and during some serious stress testing continually hit a problem >> involving the interpreter crashing with "Fatal Python error: >> PyThreadState_Delete: invalid tstate". >> ... >> It appears to be a subtle race in PyThreadState_Delete .... >> interestingly, if I uncomment the small sleep in "handle" in the server, >> ie. make the server slower, it seems to work for ever ... 4m transactions >> before I gave up. I think the problem only comes if you are creating and >> destroying threads quickly in parallel. > > PyThreadState_Delete is called from very few places, and one of them strikes > me as suspicious: at the end of threadmodule.c's t_bootstrap, we have: > > PyThreadState_Clear(tstate); > PyEval_ReleaseThread(tstate); > PyThreadState_Delete(tstate); > PyThread_exit_thread(); > > The suspicious thing here is that PyEval_ReleaseThread releases the global > interpreter lock, so nothing is serializing calls to PyThreadState_Delete > made from the following line. PyThreadState_Delete in turn does no locking > of its own either, but mutates a shared list. > > If this isn't plain wrong, it's certainly not plain right . Matches > your symptoms, too (very rare blowups during high rates of thread death). > > Guido? I haven't been able to provoke Ray's problem under Win95, but the > above just doesn't smell right. > > win95-didn't-crash-but-the-TAB-and-ESC-keys-did-swap-their- > meanings!-ly y'rs - tim I've put a lock in pystate.c around anything that touches tstate, and it seems to have fixed the problem (although reproducing it is time-consuming). This seems to be the same solution that Tim suggests, but at one remove. Stephen -- Stephen Norris srn at fn.com.au PGP key available via finger srn at flibble.fn.com.au. Farrow Norris Pty. Ltd. http://www.fn.com.au/ From thantos at brimstone.mecha Wed Jun 23 23:25:28 1999 From: thantos at brimstone.mecha (Alexander Williams) Date: Thu, 24 Jun 1999 03:25:28 GMT Subject: total idiot question: +=, .=, etc... References: <877lov62z1.fsf@pbl.ddns.org> <7ks38p$l4m$1@brick.cswv.com> Message-ID: On 23 Jun 1999 20:56:41 -0500, Neel Krishnaswami wrote: >It's just that writing self.__class__ is so *ugly*! Everything else >in Python is beautiful, too, which makes this stand out even more. Er, that could be because you're doing it wrong? Try: class Foo: def __init__(me): me.x = 9 def setX(me, val): me.x = val >>> y = Foo() >>> y.x 9 >>> y.setX(12) >>> y.x 12 If you /really/ want to go frobbing around with the value that all instances of the class inherit from, instance.__class__.slot is likely a /great/ way of pointing out to the reader you're doing something funky (in that classes are usually thought of as immutable, despite the reality). The 'unsightly' nature of the construct makes it clear you're doing something unasthetic. -- Alexander Williams (thantos at gw.total-web.net) "In the end ... Oblivion Always Wins." From pduffin at mailserver.hursley.ibm.com Mon Jun 28 08:51:03 1999 From: pduffin at mailserver.hursley.ibm.com (Paul Duffin) Date: Mon, 28 Jun 1999 13:51:03 +0100 Subject: Why is tcl broken? References: <375F82C7.CF0F0477@iname.com> <375f92b4.618467559@news.u-psud.fr> <376100E9.855C11C0@mojam.com> Message-ID: <37776FB7.31D2@mailserver.hursley.ibm.com> Skip Montanaro wrote: > > Laurent POINTAL wrote: > > Fernando Mato Mira wrote: > > for Python vs Tcl > > >: If you have references to articles of the sort, that will be useful, > > >: too. > > > > See http://www.cwi.nl/~sjoerd/PythonVsTcl.html > > While I'm sure that what Sjoerd wrote is accurate, it described Python > and Tcl as they existed around late 1995 or early 1996. Both languages > have changed more than a little since then. > His descriptions of the languages were reasonably accurate when it was written but some of his comments about them and his comparisons between the two show a definite bias towards Python and show up his limited use of Tcl. > > I remeber having seen an article of a guy explaining why he switched > > from Tcl to Python for a large project... but I loose the URL. > > That would be Frank Stajano. He presented a paper at last November's > Python conference entitled "Implementing the SMS server, or why I > switched from Tcl to Python". > > > http://www.foretec.com/python/workshops/1998-11/proceedings/papers/stajano/stajano.html > > Frank's perspective is an interesting one, because unlike most of us, he > used Tcl and [incr Tcl] happily for several years before encountering > Python, so he brings a depth of understanding to the discussion most of His article is very good and the main reason why he uses Python and not Tcl is the large number of libraries shipped with the standard Python distribution and the object oriented nature of Python. > us don't have. (I, on the other hand, got an immediate bad taste from > Tcl and spit it right out. ;-) > My son did that when he first tasted red cabbage but since then his taste buds have matured and he know loves it ;-). -- Paul Duffin DT/6000 Development Email: pduffin at hursley.ibm.com IBM UK Laboratories Ltd., Hursley Park nr. Winchester Internal: 7-246880 International: +44 1962-816880 From arcege at shore.net Wed Jun 23 16:48:03 1999 From: arcege at shore.net (Michael P. Reilly) Date: Wed, 23 Jun 1999 20:48:03 GMT Subject: TkInter callback - how to ? References: <376F4E57.6A23A66F@cellware.de> Message-ID: <7Kbc3.1113$7X1.284549@news.shore.net> bernard wrote: : I have an array of buttons (a keypad) all using the same callback : function - is there any way of finding out which button invoked : the callback ? I suppose I am looking for a tcl/tk solution : something like : -command "myCallback $thisButton" : but tkInter only seems to provide : -command myCallback : Any help welcome for index in range(5): button = Button(None, text='%d' % index, command=lambda i=index: myCallback(i) ) button.pack() Generally it is easier to give it a bound method or other callable object with the needed information. -Arcege From arcege at shore.net Wed Jun 30 13:22:07 1999 From: arcege at shore.net (arcege at shore.net) Date: Wed, 30 Jun 1999 17:22:07 GMT Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> <3773c3a0.102825445@news.oh.verio.com> <00f701bec212$f6a83050$f29b12c2@secret.pythonware.com> <002e01bec316$4c8bf4d0$f29b12c2@secret.pythonware.com> Message-ID: <3nse3.362$6M6.123714@news.shore.net> Fredrik Lundh wrote: : Michael P. Reilly wrote: :> Hmm... something about that argument makes it circularly invalid. :> Non-idle event a comes in, but must be handled after idle event d. :> Event d can only execute when event a is taken care of. Sounds like :> deadlock to me. ;) : hmm. I thought I'd meant that idle tasks kept piling up : when the windowing system generates a lot of events : at once (like when you're redrawing an entire system). : instead of redrawing everything at once, Tkinter waits : until the window event queue is empty... Yes, indefinate postponement is a problem with the current definition of Tcl_DoOneEvent. But idle tasks are for when the event loop is idle, and indefinate postponement is the standard, accepted trade-off for that. Timer handlers exist for handling more time critical actions. You had made the comment(s) earlier in the thread: > The interface is only part of the story; many complaints > seem to come from the fact that Tk uses idle tasks to > redraw things. When an "expose" event arrives from > the windowing system, Tk calls "after_idle", rather > than redrawing the widget at once. And idle tasks > are only executed when there are no other events > to take care of... This lead me to think that you meant windowing events (such as expose) were handled as idle tasks and I don't see this (MotionNotify events, yes, not all others are handled by Tcl_QueueEvent). Hence my comment about the deadlock. -Arcege From fatjim at home.com Tue Jun 22 17:08:19 1999 From: fatjim at home.com (Jim Meier) Date: Tue, 22 Jun 1999 21:08:19 GMT Subject: Win32 Question References: <7koiib$fdu$1@nnrp1.deja.com> <376FF68A.5698AF68@home.com> Message-ID: <376FFAB1.4BAD1D1E@home.com> Jim Meier wrote: > does file on my system. I'd like to see more elegant solutions, though! er, does "FINE" on my system.. -Jim From amaranda at nospam.com Thu Jun 3 12:58:26 1999 From: amaranda at nospam.com (Alex Maranda) Date: Thu, 03 Jun 1999 17:58:26 +0100 Subject: pyGTK on Windows References: <3757D453.A302E757@interar.com.ar> Message-ID: <3756B432.3858@nospam.com> Nahuel wrote: > > Hi, im about to do a cross-plataform GUI application in Linux and > Windoze... i must > choose the GUI toolkit.. my question is .. can i use pyGTK under > Windows??? It's probably doable (as somebody's doing a port of GTK to Windoze - check out www.gtk.org for the URL), but not worthy in my oppinion (the port does not use Common Controls and the like). A much better choice is wxPython http://alldunn.com/wxPython, which is Python on top of wxWindows, a cross-platform GUI framework. You get Windoze, Unix (Gtk and Motif), and Mac. > > (I need a gui that can display a table with about 4000 lines without > crashing (not like Tk :)) > there is a wxGrid widget in wxWindows. Cheers, Alex -- Alex Maranda mailto: amaranda at spider dot com Spider Software Ltd. Tel: +44 (0)131 4757036 Edinburgh, UK http://members.xoom.com/Alex_Maranda STREAMS based communications protocols for embedded systems From zeitlin at seth.lpthe.jussieu.fr Sat Jun 26 17:50:24 1999 From: zeitlin at seth.lpthe.jussieu.fr (Vadim Zeitlin) Date: 26 Jun 1999 21:50:24 GMT Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> <3773CA67.7057F797@quasar.ipa.nw.ru> <3773D55B.8C966174@spacenet.tn.cornell.edu> Message-ID: On Fri, 25 Jun 1999 15:15:39 -0400, Tom Loredo wrote: >Well, one reason not to rush to wxWindows is that there is >no "real" Mac version. I realize that a Mac version is "underway", >but the wxWindows site has said that for a *long* time now. This is true, but someone (Stefan Csomor) has really worked on it hard during the last few months only. We all hope that we will have a "real" wxMac version soon now. >A beta version was posted about a month ago, but I've not >heard much about it, and most of the wx web site doesn't >seem to know it exists (e.g., the FAQ still says the beta >is forthcoming, and the dowload section appears to still >have the old preview alpha release). Oops, it's just an oversight. I will ask Julian to update it a.s.a.p. > I develop on both Unix >and Mac, and although the Unix part of me finds wx appealing, >the Mac side of me feels like a 2nd class citizen in the wx world. The sad truth is that macs are not very common nowadays. I would like to help develop wxMac, but I don't have one (nor at home nor anywhere near me in the office), so I really can't. If there were more people working on wxMac it would surely advance more quickly... Regards, VZ From alex at somewhere.round.here Sat Jun 5 15:24:04 1999 From: alex at somewhere.round.here (Alex) Date: 05 Jun 1999 15:24:04 -0400 Subject: Alien whitespace eating nanovirus strikes again! References: <375500C9.742DC539@pop.vet.uu.nl> <375536C2.DD917F99@prescod.net> <7j4e2u$8rh$1@m2.c2.telstra-mm.net.au> <37564132.2D01B7C3@pop.vet.uu.nl> <3756BAFC.2066A636@home.com> <3756F071.E717D0FA@pop.vet.uu.nl> <37573C16.D0233810@home.com> Message-ID: Thanks. Alex. > Look at: > > http://www.python.org/doc/essays/everybody.html > > - Dave From matomira at iname.com Mon Jun 14 06:21:55 1999 From: matomira at iname.com (Fernando Mato Mira) Date: Mon, 14 Jun 1999 12:21:55 +0200 Subject: broken References: <1282792849-95706075@hypernet.com> Message-ID: <3764D7C3.718E125E@iname.com> Gordon McMillan wrote: > > So far, you have not made one post to comp.lang.python that comes > anywhere close to the posting guidelines. > > Would you mind taking this to comp.lang.snobbery, or wherever it > belongs? Don't go into a flame war. I don't know ANY language that is not `broken' somehow, even my favorite ones or the ones that are not my favorite but that are also `good'. From iking at killthewabbit.org Sun Jun 6 02:09:00 1999 From: iking at killthewabbit.org (Ian King) Date: Sat, 5 Jun 1999 23:09:00 -0700 Subject: Sockets and lemon curry References: <1283483353-54170129@hypernet.com> Message-ID: <001401beafe3$12d50560$450010ac@killthewabbit.org> From: Gordon McMillan To: Ian King ; Sent: Saturday, June 05, 1999 8:14 PM Subject: Re: Sockets and lemon curry > Ian King writes: > > > I'm trying to implement an rshd server in Python. The problem seems > > to be with establishing the secondary socket for stderr. I'm using > > a Linux 2.0 box as client, and a Windows machine as server [snip] > > Yes. On *nix, it takes root authority to create sockets on ports > below 1024. No such limit on NT. You didn't say what 'port2' was, but > it sure fits the symptoms... > > - Gordon > This sounded right on, but as I played with it, I realized: the secondary port (which is, yes, a reserved port) is created on the Linux box; the NT machine is simply doing a connect() (and there are no problems as Python under NT creates *its* socket). Nonetheless, I played with .rhosts and such, to create as benign (and dangerous!) an environment as possible on the client, to no avail. Besides, if I couldn't connect() to reserved ports, that would pretty much preclude most Internet services! :-) From mlauer at asmoday-atm.rz.uni-frankfurt.de Sun Jun 6 12:44:32 1999 From: mlauer at asmoday-atm.rz.uni-frankfurt.de (mlauer at asmoday-atm.rz.uni-frankfurt.de) Date: 6 Jun 1999 17:44:32 +0100 Subject: [pickle] Different version of a class Message-ID: <375a9760@nntp.server.uni-frankfurt.de> Hi, my application uses pickle to store and load data. During developing cycle, many variables are added to the classes which are pickled. Whenever I load a file pickled with a previous version, some variables are not existent (naturally, because __init__ is not called). Is there an easy way to initialize the "new" variables or must I call __init__ - which would overwrite some of my saved variables. Any idea ? -- Regards & Gruesse from Mickey @ http://www.Vanille.de --------------------------------------------------------- How could anyone know me - when I don't even know myself ? From moshez at math.huji.ac.il Tue Jun 22 11:37:06 1999 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Tue, 22 Jun 1999 18:37:06 +0300 Subject: YAS to the "Reading line-by-line" Problem Message-ID: (YAS == Yet Another Solution) This solution introduces file-like objects which do the Right Thing(TM) at EOF: raise EOFError (instead of returning an empty string) ----------------- cut here ------------------ class File: '''\ File-like objects which throw EOFError on End-of-File. Initialize with a file-like object. ''' def __init__(self, file): self.__file=file def __getattr__(self, name): if name[:4]!='read': return getattr(self.__file, name) return _Wrap(getattr(self.__file, name)) class _Wrap: def __init__(self, function): self.function=function def __call__(self, *args, **kw): ret=apply(self.function, args, kw) if ret=='': raise EOFError, 'no more data in file' return ret def open(file, mode='r'): '''\ return a file like object open to /file/ with mode /mode/, which throws an EOFError on EOF ''' import __builtin__ return File(__builtin__.open(file, mode)) def _test(): import sys file=open('/etc/passwd') try: while 1: sys.stdout.write(file.readline()) except EOFError: pass if __name__=='__main__': _test() ---------------------------- cut here --------------------------- -- Moshe Zadka . #!/usr/bin/tail -1 Just another tail hacker. From claird at Starbase.NeoSoft.COM Sun Jun 13 09:59:16 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 13 Jun 1999 08:59:16 -0500 Subject: Broken 1.5.2 installation? Missing cw3215mt.dll References: <000901beb3b2$baa6d980$329e2299@tim> <37611D32.47BED973@callware.com> Message-ID: <7k0dfk$811$1@Starbase.NeoSoft.COM> In article <37611D32.47BED973 at callware.com>, Ivan Van Laningham wrote: . . . >[snort] > >I've just been installing Python/Tcl/PyWin/Win32All/blah blah on several >Win machines (95/98/NTW/NTS) over the past several days. It's a long >story (soon to be a major motion picture starring Mel Gibson), but >suffice it to say that in *every* case IDLE refused to run out of the >box. All that was required, though, was to update PATH to include the >Python directory, the Tcl directory and the Tcl/bin directory. I've >also installed Python/Tcl on my three Linux machines--RH5.2 and >RH6.0-SMP--but I didn't have to fiddle with anything at all in order to >get IDLE to run just fine. Of course, Python and Tcl etc. have been in >my path permanently for a long time on Linux;-) > >> followups-to-cameron-laird-ly y'rs - tim > >I'll gladly follow Cameron around if he's responsible for the install;-) . . . I regard installation as comparable to sanitation services (garbage removal) in the real world: an enormous enabler of comfort, theoretically inchoate, culturally underappre- ciated--and not my specialty. My ignorance about installation is even more massive than the one I have about art, for truly all I know about installation is what works for me. My personal belief, in fact, is that there are *no* experts in installation. It's turtles all the way, for everyone I've asked seems to have a mentor whom he trusts beyond his own experience. Elementary graph theory questions how this embeds in a finite population, but all I can do is report my own observations. I don't know off-hand who's responsible for Tk installations. If you want to track down the guilty parties, I'll be happy to help. In regard to Python, of course, The Guido knows all. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From paul at prescod.net Wed Jun 30 09:49:00 1999 From: paul at prescod.net (Paul Prescod) Date: Wed, 30 Jun 1999 13:49:00 GMT Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> <3773c3a0.102825445@news.oh.verio.com> <7laovo$c4s$1@Starbase.NeoSoft.COM> <377A24B7.AD6FAA1A@cfdrc.com> Message-ID: <377A204C.D843868D@prescod.net> Lyle Johnson wrote: > > Just to add fuel to the fire, we now have a Python interface to FOX, a > cross-platform GUI toolkit: I find it fascinating that there are so many GUI toolkits. The GUI is more than twenty years right and we haven't agreed on the basic programming model or API yet?? -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco "The new revolutionaries believe the time has come for an aggressive move against our oppressors. We have established a solid beachhead on Friday. We now intend to fight vigorously for 'casual Thursdays.' -- who says America's revolutionary spirit is dead? From faassen at pop.vet.uu.nl Thu Jun 3 17:15:29 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Thu, 03 Jun 1999 23:15:29 +0200 Subject: Alien whitespace eating nanovirus strikes again! References: <375500C9.742DC539@pop.vet.uu.nl> <375536C2.DD917F99@prescod.net> <7j4e2u$8rh$1@m2.c2.telstra-mm.net.au> <37564132.2D01B7C3@pop.vet.uu.nl> <3756BAFC.2066A636@home.com> Message-ID: <3756F071.E717D0FA@pop.vet.uu.nl> Jim Meier wrote: [snip] You're the guy who did the GGI wrapper, right? I've been playing with it a little, now I need more docs... Perhaps I'll go write some. > > I must say that Emacs Python mode helps tremendously in this respect, > > though. Without it or something similar block indentation wouldn't be as > > easy (though I've found I can code in Windows Notepad too if I really > > want to :). > > Oh, ditto. I just *love* (x)emacs now, though I would really like it to take far > less memory and be extendable with python. > > Wow, talking about old H/W makes me sound old - I'm only 19! Well, computer tech moves quickly (I'd say 'in internet time' but it already did before the net was popular). I remember the days before the great internet explosion, 1991 and such, where I could talk about the marvels of the net and get looks 'Martijn is talking about computer stuff again'. These days I sit in the bus and hear people talk about 'getting email'. And I'm only 25. :) I can go on and on about the MSX-2, its VDP chip and Z80 assembler. :) This made me come up with the Quantum-Martijn-Solipsist theory of Reality Alteration: 'If Martijn rambles about something exciting to people that people don't get, reality will change within a few years so that suddenly everybody is using it.' I'm rambling about Python these days. Yesterday I read a paper from Guido about how he was thinking about bringing Python (or some successor language) to *billions* of users. :) Regards, Martijn From aahz at netcom.com Fri Jun 11 13:56:25 1999 From: aahz at netcom.com (Aahz Maruch) Date: Fri, 11 Jun 1999 17:56:25 GMT Subject: waste of resources ? References: <375C0F91.1C73E4E3@icrf.icnet.uk> <87r9nl398o.fsf@psyche.evansnet> <375E86C1.73B2CF80@icrf.icnet.uk> <37606565.5A93BCE9@compaq.com> Message-ID: In article <37606565.5A93BCE9 at compaq.com>, Greg Ewing wrote: >Arne Mueller wrote: >> >> chfds.remove(i) >> os.waitpid(chpids[i], os.WNOHANG) >> del chpids[i] > >If you're explicitly waiting for a particular child, *don't* use >WNOHANG, because you *want* to block until that child has exited -- >which it may not have done yet, even though it has written its data. I can't speak to Arne's situation, but I'm about to rewrite a chunk of code to fork off a specific single child process precisely because I *don't* want the parent to block while this code executes, but I still want to reap the child later (and perform some final cleanup). -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het "That doesn't stop me from wanting to work all three of them over with the clue stick for while, with no safewords allowed." --abostick From delgado at Mathematik.Uni-Bielefeld.DE Wed Jun 16 16:39:56 1999 From: delgado at Mathematik.Uni-Bielefeld.DE (Olaf Delgado) Date: Wed, 16 Jun 1999 22:39:56 +0200 Subject: Newbie again: computing attributes on the fly In-Reply-To: References: Message-ID: On Wed, 16 Jun 1999, David Ascher wrote: > You may find that using ExtensionClass could help. See: > > http://www.digicool.com/releases/ExtensionClass/ > > (note especially the section on computed attributes in the documentation). Oops! That's the kind of advice I was fearing. Last time I tried to understand that stuff, I really got dizzy. Anyway, thanks! I'll have a look at it once more. Yours, Olaf -- //// Olaf Delgado Friedrichs, Uni Bielefeld, Mathematik Olaf Postfach 100131 (room: V4-109) `=' D-33501 Bielefeld, Germany (phone: +49 521 106-4765) http://www.mathematik.uni-bielefeld.de/~delgado From paul at prescod.net Tue Jun 29 12:20:25 1999 From: paul at prescod.net (Paul Prescod) Date: Tue, 29 Jun 1999 16:20:25 GMT Subject: PySequence_Check References: Message-ID: <3778F249.878FCCC@prescod.net> Reuben Sumner wrote: > > How can I do the equivalent of a PySequence_Check in Python? > GvR told me that the question was illdefined (if I explained it correctly) > and to ask here. >... > What am I missing? I have a nested structure of lists and tuple and I > just want to know when I have bottomed out. I can check for tuple or > list indivually but that is ugly and inflexible. I could just try > indexing and see if there was an exception but that is not much better. Hi, Reuben. This latter is probably our best bet. Python in general has no way of declaring that an object acts as a sequence or mapping. Therefore there can be no way of querying whether an object acts as a sequence or mapping. In general, Python has no way of declaring that an object "acts as" anything at all (other examples would include a set, a widget, a web browser). There is no concept of interface or protocol except in the C API. I think that the goal is to define the concept in general before applying it specifically to sequences, mappings, file objects and other "built-in" protocols. My discussion with Guido on this issue began here: or you can do a deja search with "IsMappingType" There are some tricky issues about what this interface stuff all means in a dynamically typed language. The constant re-occurence of discussions like this have lead to the development of a special interest group: http://www.python.org/sigs/types-sig/ -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco "The new revolutionaries believe the time has come for an aggressive move against our oppressors. We have established a solid beachhead on Friday. We now intend to fight vigorously for 'casual Thursdays.' -- who says America's revolutionary spirit is dead? From tseaver at palladion.com Wed Jun 23 23:18:00 1999 From: tseaver at palladion.com (Tres Seaver) Date: Wed, 23 Jun 1999 22:18:00 -0500 Subject: Why exceptions shouldn't be used for flow control [Re: YAS to the "Reading line-by-line" Problem] References: <376FDF70.4756AD38@mindspring.com> <377173F7.36BCFF6B@compaq.com> Message-ID: <3771A368.1F491DD0@palladion.com> William Tanksley wrote: > > On Thu, 24 Jun 1999 11:55:35 +1200, Greg Ewing wrote: > >William Tanksley wrote: > > >> Both should be handled by exception, not by returning a special > >> value. > > >I don't agree with that. Reaching the end of a file while > >reading it is not exceptional enough to warrant requiring > >the use of an exception handler to catch it. > > "Not exceptional enough". What does that mean? (I ain't never had too > much exception! ;-) > > It's an exception to the behavior of a function defined to return the next > entity in a file. It's not an exception to a function which returns the > next entity, or some reserved value otherwise. There's no such thing as a > partial exception; it's a quality, not a quantity. In Design-by-Contract terms, a service may throw exceptions for two reasons: * The caller violated the precondition of the contract (passing an invalid parameter, for instance). Note that ALL such exceptions are supposed to be avoidable, given enough diligence on the caller's part. * The service was unable to fulfill the contract due to the moral equivalent of force majeure (out of disk space, etc.). No action the caller could possibly take beforehand would obviate the need to catch / propagate these exceptions. The "EOF" problem in Python acts like one of the second group, because the file-object-protocol does not supply a test for EOF (callers who can't test for EOF, can't be blamed for reading off the end). The tradeoff here is that the FOP is a "bigger tent" than if it provided EOF(): many FOP-obeying objects literally can't determine EOF without trying to do the read anyway (sockets, FIFOs, etc). Using exceptions for other purposes requires a more definite protocol for them between caller and service, and thus requires more design justification. Two cases I see often: Because they unwind the stack cleanly, exceptions provide an expedient way to return "success" from deeply-recursive routines, such as graph searches. The justification is along the following lines: "non-exception implemtations will spend as much effort and code to handle returning the OOB data in line as they do performing the search". In Soft-n-GUI ("fewmet") programming: given a suitable framework which catches the exceptions at the outermost layer and displays them to the user, exceptions drastically simplify event-handling code: the event handlers check for nasty bits at the top, and throw if found; the rest of the code is unencumbered with the kinds of ugly control flow which would otherwise be required. > > >What bothers me about using exceptions for flow control > > Presumably you're talking about command flow. Okay, but exceptions do > nothing BUT affect flow control. What else can they do? > > >in situations like this is that the effect of an exception > >handler is *non-local*, whereas what you're trying to > >catch is really only a local concern. > > Is it? Are they? The effects of an exception toss are as local as the > user of the function want them to be. > > If EOF was truly local, then file.read would always be able to decide what > to do with it -- print a message, abort(), pop up a window, or whatever > else it takes. Here's the rub: if read() throws on EOF, it promulgates a policy that EOF is a "back out" condition: everyone must wrap almost any call to read() in a try block, even if only to ignore it, or break out of a local loop. Because read() doesn't throw (and thereby doesn't enforce policy at the mechanism level), applications which don't need the policy don't pay for it; yet it is trivial (as the original "YAS" poster shows) to layer the policy on top of the mechanism, if so desired. Use-exceptions-daily-in-GUI-code-_except_-when-threads-are-involved'ly Tres. -- ========================================================= Tres Seaver tseaver at palladion.com 713-523-6582 Palladion Software http://www.palladion.com From arcege at shore.net Tue Jun 22 16:16:11 1999 From: arcege at shore.net (Michael P. Reilly) Date: Tue, 22 Jun 1999 20:16:11 GMT Subject: Creating a new type with an extension module References: Message-ID: Michael P. Reilly wrote: : But the documentation on extending Python is pretty well known : deficiency. Luckily it is far easier than most languages, both to : accomplish and to understand (yet more kudos to Guido). Actually, in : responce to your earlier posting, I started writing a _SHORT_ webpage : explaining what is needed, which I hope to have available later today. : I plan (and hope) to make it into a How-To later. I've put a copy of my short, quick tutorial on how to write an extension. It is very terse, but has all the basics, including a full example, hints and some minor tricks. http://starship.python.net/crew/arcege/extwriting/pyext.html Let me know how well it reads (I doubt it reads well since it was started this morning). -Arcege From redsand at dsuper.net Sat Jun 26 22:14:01 1999 From: redsand at dsuper.net (Dave) Date: Sat, 26 Jun 1999 22:14:01 -0400 Subject: Advice for Newbie Message-ID: <377588E9.82E8F567@dsuper.net> I read the Python homepage. I sounds promising. What books do you commend for a beginner? From evan at tokenexchange.com Mon Jun 21 15:15:51 1999 From: evan at tokenexchange.com (Evan Simpson) Date: Mon, 21 Jun 1999 14:15:51 -0500 Subject: choosing random numbers with weights/probability? References: <929987267.6227@www.remarq.com> Message-ID: In this simple case, you could use: weighted = [0, 1, 2, 2] item = list[whrandom.choice(weighted)] If you really need arbitrary weights, try: list = [('one', 0.25), ('two', 0.25), ('three', 0.5)] def weighted_choice(list): from whrandom import uniform n = uniform(0, 1) for item, weight in list: if n < weight: break n = n - weight return item kevinsl wrote in message <929987267.6227 at www.remarq.com>... I've been using the whrandom.choice routine and it's very useful. But is there any way to add weights or probabilities of being chosen to the items in the list? example: list=['one','two','three'] item=whrandom.choice(list) Is there any way to say that 'one' and 'two' have a 25% chance of being chosen, and 'three' has a 50% chance? From graham at sloth.math.uga.edu Thu Jun 3 14:58:21 1999 From: graham at sloth.math.uga.edu (Graham Matthews) Date: 3 Jun 1999 18:58:21 GMT Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <7j450j$908$2@cronkite.cc.uga.edu> <7j5sr7$eb4$1@nnrp1.deja.com> Message-ID: <7j6j8d$58f$2@cronkite.cc.uga.edu> adjih at technologist.com wrote: : But there will be cases where full garbage collection will be : definitly a nuisance. : First, you must scan all the address space of the C code, which can be : a problem if you're just using the Python interpreter in a library (i.e. : don't have the ability to control or modifying the main program) ; or if : your address space is too big (I use python for instance in a program : that does an mmap of a 350 MB file). a) you can turn gc off b) I routinely use garbage collection on 1 Gig memory spaces with no speed problems. adjih at technologist.com wrote: : Second you kill the portability: you could use a subset of Python with : ANSI-C alone ; but you can't make a incremental GC in ANSI-C. Then don't use an incremental collector! Use a mark sweep collector. I use such a thing almost every day -- written entirely in ANSI-C. : You'd get problems when embedding Python in unusual environments ; for : instance if you embed Python in the Linux kernel, then the GC should : also trace all the pages in the swap, or be rewritten specially for that : case. Why do you need to do any of these things? adjih at technologist.com wrote: : The advantages of GC must be traded with its drawbacks: : - advantages: reclaims cyclic structures. : - drawbacks: non-portable, requires a special handling when linking with : C, high complexity for decent GC (multi-thread incremental with : finalization and support for C/C++ structures referencing Python : structures). The drawbacks you list are all misleading. Mark sweep collection (with refcounts) is highly portable. Non compacting (or even partially compacting) collectors require no special code to link with C. Complexity of a mark sweep collector is not very high at all (registering roots and traversing foreign objects being the main areas of complexity). I am sure that for *some* collection schemes some of the drawbacks you list are true, but not for all. graham -- The fool escaped from paradise will look over his shoulder and cry Sit and chew on daffodils and struggle to answer why? From proteus at cloud9.net Tue Jun 29 11:38:31 1999 From: proteus at cloud9.net (Michael Muller) Date: Tue, 29 Jun 1999 11:38:31 -0400 Subject: ssh with telnetlib References: <37778244.C4528C5B@hrz.uni-paderborn.de> Message-ID: <3778E876.6E4B86A5@cloud9.net> m liss wrote: > > Hello, > > has someone already made telnetlib.py support ssh ? > I want to use Python for remote administration. > > regards, > > Mirko > > -- > M Li?, I wouldn't expect to see this any time soon: telnet and ssh are very two different protocols. Your best options are: 1) use telnetlib to tunnel through an established ssh connection 2) write a module that wraps the ssh client, communicating to it through popen2 or popen3 Option 1 will require a telnet daemon to be available on the remote host. If you're interested, and can wait, I'm working on a python based distributed object system which will (eventually) support ssh tunneling. ============================================================================= michaelMuller = proteus at cloud9.net | http://www.cloud9.net/~proteus ----------------------------------------------------------------------------- Mantra for the 60's: Tune in, turn on, drop out Mantra for the 90's: Turn on, jack in, jerk off ============================================================================= From news at dorb.com Tue Jun 29 10:11:07 1999 From: news at dorb.com (Darrell) Date: Tue, 29 Jun 1999 10:11:07 -0400 Subject: Uploading files References: <377874C6.6941CCFF@boxer.no.---> Message-ID: Jostein S?iland wrote in message news:377874C6.6941CCFF at boxer.no.---... > Hi, I'm writing a script that needs to upload files from the user's > machine to a server, and it's used in combination with a form and > HTML-file that lies on the server side. I wrote a piece of code that I > thought would work, but it turned out that when i specify c:\foo.exe, it > is the file on the server side that is uploaded and not the foo.exe on > the client side. Evidently since the script is run on the server side. > > So my question is: How do I specify that it is the client's c:\foo.exe > and not the server file that gets uploaded? > > > Thanks > > Jostein S?iland > html>
I'm using bobo to read the response to the post that contains the file. This is a cut up snippet of how I did that, you just need something to accept the data and write it to disk. My skill level in these matters is about a 1, so I'm sure you could do better. def upload(REQUEST, RESPONSE): """ Get a new file from a user """ name= REQUEST.form[fieldName].filename if name=='': return names= string.split(name,'\\') names = string.split(names[-1],'/') name=names[-1] name = string.split(name) name = string.join(name,'') global baseDir fp = open(baseDir+name,'wb') buf = REQUEST.form[fieldName].read() fp.write(buf) fp.close() -- --Darrell From jim at interet.com Fri Jun 25 10:57:50 1999 From: jim at interet.com (James C. Ahlstrom) Date: Fri, 25 Jun 1999 10:57:50 -0400 Subject: Environment inheritance under Windows NT 4, Attempt 2 References: Message-ID: <377398EE.C224497B@interet.com> "Milton L. Hankins" wrote: > > Since I've not yet gotten a response to my first post, here's an > elaboration. > > Windows NT Workstation 4.00.1381, SP5. > C:\>echo %WINDIR% > C:\WINNT > > C:\>python -c "import os; print os.environ['windir']" > C:\WINNT > > C:\>set WINDIR=foo > > C:\>echo %WINDIR% > foo > > C:\>python -c "import os; print os.environ['windir']" > C:\WINNT > > ----------------------------------------------------- I don't get this behavior on NT 4.00.1381. This was copied from cmd.exe: N:\python\Python-1.5.2\PCbuild>ver Windows NT Version 4.0 N:\python\Python-1.5.2\PCbuild>./python -c "import os; print os.environ['WINDIR']" C:\WINNT35 N:\python\Python-1.5.2\PCbuild>set WINDIR=foo N:\python\Python-1.5.2\PCbuild>echo %WINDIR% foo N:\python\Python-1.5.2\PCbuild>./python -c "import os; print os.environ['WINDIR']" foo N:\python\Python-1.5.2\PCbuild> I think I am at service pack 4. I am using Python 1.5.2. What is your Python version (not that it should matter). Very peculiar. The code seems to be getting the environment from char **environ. The VC 6.0 docs say to use _environ, and I don't see a reference to _environ. The docs also say getenv() uses _environ. Although I can't duplicate the behavior you describe, it seems to me Python should be using _environ instead of environ. Does anyone know what environ is on NT? I see "#define environ _environ" in stdlib.h, but it is inside a bunch of #ifdef's. Jim Ahlstrom From Peter.Haight at p98.f112.n480.z2.fidonet.org Wed Jun 30 22:54:27 1999 From: Peter.Haight at p98.f112.n480.z2.fidonet.org (Peter Haight) Date: Thu, 01 Jul 1999 03:54:27 +0100 Subject: Why is no exception raised for file.read() when file is only writeable? Message-ID: <00001623@bossar.com.pl> From: Peter Haight I've been helping someone learn the language and he was having trouble understanding why this didn't work: test=open('testfile','w') testread=test.readline() I explained to him the problem, but I was wondering why Python doesn't raise an exception when you do this. He probably wouldn't have had to ask me anything if Python printed something like this: IOError: [Errno X] You can't read from a file only open for writing. From bernhard at alpha1.csd.uwm.edu Thu Jun 17 17:33:04 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 17 Jun 1999 21:33:04 GMT Subject: BiBTeX module? References: <7k950a$hsb@cs.vu.nl> Message-ID: On Wed, 16 Jun 1999 21:29:46 GMT, Frank Niessink wrote: >Joe Strout wrote: >> Is there a BiBTeX module for Python? Having a look at the current programs available for editing and entering BiBTeX files someone really ahs to write a good python/tk or python/wxpython program for this task, too. (sidebar: tkbibtex is not really good, and bibview-2.2, the old X11 program still seems to be the best, but hey old fashoined.) >A collegue and myself hacked up a package (called Bridge) which enables >you to generate BibTeX from SGML/XML (so it includes both a BibTeX SGML dtd >and a BibTeX XML dtd) and vice versa >The package itself is in a state of flux right now, but if you're >interested I guess we can make it available nevertheless. Make it available as free software, it sounds interesintg. thanks, Bernhard -- Research Assistant, Geog Dept UM-Milwaukee, USA. (www.uwm.edu/~bernhard) Funding/Promoting Association for a Free Informational Infrastructure (ffii.org) From tismer at appliedbiometrics.com Thu Jun 3 14:01:26 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Thu, 3 Jun 1999 18:01:26 GMT Subject: Alien whitespace eating nanovirus strikes again! References: <375500C9.742DC539@pop.vet.uu.nl> <375536C2.DD917F99@prescod.net> <7j4e2u$8rh$1@m2.c2.telstra-mm.net.au> <37564132.2D01B7C3@pop.vet.uu.nl> <3756BAFC.2066A636@home.com> Message-ID: <3756C2F6.9D7E6EFD@appliedbiometrics.com> ... > Ditto about not being afraid of the indentation. I've been rabidly happy about > using indentation properly ever since I moved up from a commodore vic-20: in the > vic's BASIC, you typed a line number and then just typed until you had trouble > reading the line - it would just wrap around the 20-character wide screen. Moving > up to a DOS machine with MS QBasic, I was very releived to be allowed to indent my > programs properly. But QBasic has crazy block open/closures: each type of > statement is different! ... > Wow, talking about old H/W makes me sound old - I'm only 19! Are you sure? How did you get your hands at a VIC-20, then? :-)) ciao - chris (do you want my AIM65 board with an 8 kb Forth?) -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From Guido.van.Rossum at p98.f112.n480.z2.fidonet.org Tue Jun 29 04:08:06 1999 From: Guido.van.Rossum at p98.f112.n480.z2.fidonet.org (Guido van Rossum) Date: Tue, 29 Jun 1999 09:08:06 +0100 Subject: total idiot question: +=, .=, etc... Message-ID: <000015a4@bossar.com.pl> From: Guido van Rossum > >>> class A(B): > >>> def __init__(self, x, y, z): > >>> B.__init__(self, x, y, z) > > [Greg Ewing] > > I could live with having to explicitly name the > > superclass, provided something checked that the > > class I named was actually a direct base class > > of the one where the method is defined. That > > way things would be less likely to break > > mysteriously when I rearrange the class > > hierarchy. > > [Guido] > > Oh, but that check *is* being made! (In fact this is the same check > > that prevents "class methods" from working ;-) > > Nope, that's a different check. If C derives from B derives from A, this > check allows either C.__init__ or B.__init__ to be called from A.__init__ > with an instance of A. Greg wants B.__init__ to be OK here, but not > C.__init__ (C is not a direct base class of the one (A) where the method > (A.__init__) is defined). IOW, he wants a way to restrict __init__ calls to > immediate bases of the class from which the __init__ is invoked, to e.g. > prevent level-skipping under class rearrangement. Sigh. Indeed. > I posted some ugly code to address that, but think it's really a job for a > text editor and a pair of eyeballs . Hm -- he may be right! I was reading some IDLE code the other day and noticed that PyShell's close() method was calling PyShellEditorWindow.close(self) while it didn't inherit from that class at all... Turns out the actual method was defined in a common base class -- a silent (and in this case harmless) bug, caused by, indeed, a class restructuring. So there is a point to his wish. On the other hand Python explicitly allows you to ignore base class methods in overriding ones, and even constructors... (And then again, there is something to say for requiring constructors to play be slightly different rules -- certainly they don't have to duplicate the signature of the base class constructor like regular methods need to do.) Enough, --Guido van Rossum (home page: http://www.python.org/~guido/) From kjwolf at online.de Sun Jun 20 21:01:09 1999 From: kjwolf at online.de (Klaus-Juergen Wolf) Date: Mon, 21 Jun 1999 03:01:09 +0200 Subject: Problem with Curses References: <87ogidzs37.fsf@home.ivm.de> <6Zeb3.526$4e1.32195@iad-read.news.verio.net> Message-ID: T.E.Dickey wrote: >>> It depends on when the executable is linked to libmytinfo, which only >>> takes place on platforms that don't know the terminfo database, like >>> BSD and Solaris; there are two competing declarations of tputs(). >> Why doesn't Freebsd know the terminfo database? Can't the one that is >> integrated into ncurses be used on FreeBSD? > I've been told ncurses 4.2 is incorporated in the FreeBSD 3.1 - but that > may still just be a port... Yes, there is such a port. Do you think, one could release code that works on several machines, while some of them must install a special program first? cu k.j. PS: It wouldn't have worked anyway. -- Support Julia Hill - save the Redwood trees: http://www.lunatree.org/ From ivnowa at hvision.nl Wed Jun 2 16:29:48 1999 From: ivnowa at hvision.nl (Hans Nowak) Date: Wed, 2 Jun 1999 20:29:48 GMT Subject: Alien whitespace eating nanovirus strikes again! In-Reply-To: <375500C9.742DC539@pop.vet.uu.nl> References: <375500C9.742DC539@pop.vet.uu.nl> Message-ID: <199906022028.WAA28874@axil.hvision.nl> On 2 Jun 99, Martijn Faassen wrote: > [Larry Wall:] > [Perl is postmodern] > > That is, if something's worth doing, it's worth driving into the ground to the > > exclusion of all other approaches. Look at the use of parentheses in Lisp or > > the use of white space as syntax in Python. Or the mandatory use of objects in > > many languages, including Java. All of these are ways of taking freedom away > > from the end user ``for their own good''. They're just versions of Orwell's > > Newspeak, in which it's impossible to think bad thoughts. We escaped from the > > fashion police in the 1970s, but many programmers are still slaves of the cyber > > police. > [Perl is postmodern and therefore allows freedom] > > One could say the same about Perl and it requiring it curly braces > around blocks? In fact, I heard the claim that its requirement to use > curly braces around single line blocks (unlike C which allows you to > remove them) makes Perl less prone to errors. And Perl excludes the use > of meaningful whitespace indentation! (python does allow #{ and #} > blocks ;) When I read his articles about postmodern Perl, I initially thought he was joking... this shtick about 'languages with one big idea... Java has objects, Lisp has parentheses, Python has whitespace', etc. couldn't be serious, right? But it seems he is serious after all... Sometimes I dare read a few messages in the Perl newsgroups, and some people there seem to think of Python as the summum of inflexibility. It doesn't allow you enough freedom to code what you want. Just look at that whitespace! -- Nonsense, of course. The fact that Python heavily uses whitespace doesn't mean you cannot code what you want, and in a way you want it. The same thing can be said for Scheme and Lisp. They use lots of parentheses, and while the languages look peculiar because of that, it doesn't make them any less flexible. On the contrary. Whitespace in Python enforces readability, it does not force you to use a certain coding style. I really cannot understand why some people seem to think Python is not flexible. It actually allows very much, just takes out brain-damaged things, like for instance adding strings and integers, which makes as much sense as adding file objects and complex numbers. :o) > Okay, I *will* say the same about Perl and its curly braces requirement: > > } That is, if something's worth doing, it's worth driving into the > ground to the > } exclusion of all other approaches. Look at the use of curly braces in > } Perl. $Yes, (%(and) quite) @a { $few %other $annoying {characters...} } > Okay, sorry for all this, it's out of line, I just needed to blow off > steam. :) Me too. :) Veel liefs, --Hans Nowak (ivnowa at hvision.nl) Homepage: http://fly.to/zephyrfalcon From movits at lockstar.com Tue Jun 29 10:35:42 1999 From: movits at lockstar.com (Mordy Ovits) Date: 29 Jun 1999 07:35:42 PDT Subject: [Python|Crypto] on handhelds (was Re: Thanks for Python...) References: <376ead64@anonymous.newsfeeds.com> <37716901.43CB604@lockstar.com> <37727194.D9CD6B7@lockstar.com> Message-ID: <37790460.47FAD8AF@lockstar.com> William Tanksley wrote: > I have a certain amount of leeriness about posting advocacy on unrelated > NGs, so I'll limit myself to saying that the difference is years, not > miles. The two machines work differently: one is a glorified organizer, > the other is a pocket computer. Both of them can fool you into thinking > they're something else, because they're both powerful. > > I need a personal organizer. To each his own. :-) Don't you wish all flame were required to end like that (i.e. before they started?) > >> I used Quartus on my Crypto exam to solve a modular equation after I > >> forgot how to solve modular equations (I had it use brute force). > > >Wow! I wish I had had my E100 when I was in college. I just realized how > >awesome that would have been. :-) > > Oh yeah. > > Actually, I sometimes miss my old OmniGo, which was a pocket computer, in > spite of being slower than the Pilot for some tasks. I really needed the > glorified organizer (and had been fooled into thinking that the OmniGo was > one), but the OmniGo had some abilties that the Pilot doesn't. I'm not familiar with the OmniGo. Got a link for me? > >The SECOND time I saw that sig was in ESR's mail. The first was mine. I doubt > >ESR copied mine, but who knows? :-) > > You mean you wrote it? If so, there seems to have crept into it a bug -- > one of the implicit unpackings don't work. No, I didn't write it. It was written by the all-talented AMK. I did write a nifty version of Bruuce Schneier's Solitaire algorithm, though. check out: http://www.counterpane.com/solitaire.html Mordy -- o Mordy Ovits o Cryptographic Engineer o LockStar Inc. --------------------------------------------------------------------------- #!/usr/local/bin/python from sys import*;from string import*;a=argv;[s,p,q]=filter(lambda x:x[:1]!= '-',a);d='-d'in a;e,n=atol(p,16),atol(q,16);l=(len(q)+1)/2;o,inb=l-d,l-1+d while s:s=stdin.read(inb);s and map(stdout.write,map(lambda i,b=pow(reduce( lambda x,y:(x<<8L)+y,map(ord,s)),e,n):chr(b>>8*i&255),range(o-1,-1,-1))) From tgm at math.uni-bonn.de Mon Jun 28 04:58:14 1999 From: tgm at math.uni-bonn.de (Thomas Ackermann) Date: Mon, 28 Jun 1999 10:58:14 +0200 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> <37766E1A.49FC9062@emsoft.de> Message-ID: <6fd7l7.9d.ln@final.math.uni-bonn.de> Could you possible resent this as an ordinary (text) mail, please? Michael S. Schliephake wrote: > > > Hallo - >
As a matter of fact, it appears to be very easy to > make commercial grade GUIs using wxPython.
> Commercial grade GUI's ? >

Think about some points: >

    >
  1. > Tcl/Tk is freeware but has a strong commercial support. Scriptics and a > growing number of companies support with commercial tools or provide software > based on Tcl/Tk.
    > This could make sure a long-time existence of this language, improvements > will be made possibly quickly. Even very large companies use it for in-house > developments,
  2. >
  3. > several books exists about programming,
  4. >
  5. > Performance for Tcl/Tk under Python to improve seems not to bee too complicated,
  6. >
  7. > it is very easily to program, just in the sense of a scripting language. > With some self-written utilities and classes one can realize the GUI even > much more faster,
  8. >
  9. > the actual Tkinter-interface allows it to incorporate Tcl/Tk-extensions > for test purposes without writing new extension code (just new wrapper > classes or so, implemented in Python, are necessary). It's o.k to write > extension code later, if the Tcl extension will be used permanently or > never if there is enough performance.
  10. >
  11. > There exist several GUI-Builders.
  12. >
> More pointes necessary? It's a world of freeware. So I do not see any reason > to define the one and only GUI. One should use the best fitting tool. But > in my point of view, Tcl/Tk seems to be - at least actually - the most > wise decision. >

Michael Schliephake. -- Thomas Ackermann | Tel. +49-(0)228/631369|73-7773 | finger tgm at rhein.math.uni-bonn.de for public key GNU LINUX Python gtk pygtk MySQL FUDGE GURPS From fatjim at home.com Wed Jun 16 13:24:12 1999 From: fatjim at home.com (Jim Meier) Date: Wed, 16 Jun 1999 17:24:12 GMT Subject: Fnorb Q.. Message-ID: <3767DD6F.595A04A5@home.com> I'd post this to the Fnorb list, but don't seem to have been added yet.. I appologise if this offends anyone's sense of relevance. In installing Fnorb on a Debian 2.1 linux system, I follow the instructions very carefully. I'm actually not using debian's Python package, but a self-installed/compile 1.5.2 Python, so I can fiddle with the source without needing to learn about packages. Fnorb seems to install fine, but when I try running fnidl on anything, it seems to chew for a while (disk activity, slight increase on load avg meter), but then waits an ridiculous amount of time (2-3 minutes), then spits out the error message at the bottom of this page. Am I doing something wrong? The command line I'm using is simple "fnidl (idl file)", which works fine under windows. Any help would be appreciated.. I really want to play with CORBA!! :) -- Traceback (innermost last): File "/home/fatjim/projects/balderdash/Fnorb/script/fnidl", line 2, in ? import sys; from Fnorb.script import fnidl; sys.exit(fnidl.main(sys.argv)) File "/home/fatjim/projects/balderdash/Fnorb/script/fnidl.py", line 102, in ma in result = main_batch(context, cpp_flags, idl_files) File "/home/fatjim/projects/balderdash/Fnorb/script/fnidl.py", line 147, in ma in_batch ifr = IntRepImpl.RepositoryImpl() File "/home/fatjim/projects/balderdash/Fnorb/cos/interface_repository/IntRepIm pl.py", line 581, in __init__ self.get_primitive(CORBA.pk_boolean), File "/home/fatjim/projects/balderdash/Fnorb/cos/interface_repository/IntRepIm pl.py", line 654, in get_primitive self._fnorb_register_impl(key, PrimitiveDefImpl._FNORB_ID, definition) File "/home/fatjim/projects/balderdash/Fnorb/cos/interface_repository/IntRepIm pl.py", line 77, in _fnorb_register_impl boa = BOA.BOA_init() File "/home/fatjim/projects/balderdash/Fnorb/orb/BOA.py", line 59, in BOA_init boa = BOA(argv, boa_id) File "/home/fatjim/projects/balderdash/Fnorb/orb/BOA.py", line 149, in __init_ _ protocol.enable(host, port) File "/home/fatjim/projects/balderdash/Fnorb/orb/IIOPProtocol.py", line 61, in enable self.__nudger = Nudger.Nudger() File "/home/fatjim/projects/balderdash/Fnorb/orb/Nudger.py", line 76, in __ini t__ self.__client.connect(listen_host, listen_port) KeyboardInterrupt Exception exceptions.AttributeError: '_Nudger__reactor' in ignored (ps: 'ignored'???) ... You know it's time to rethink your design when you can't debug your #defines. -Jim. From Rick_Rankin-P15254 at email.mot.com Thu Jun 10 12:50:21 1999 From: Rick_Rankin-P15254 at email.mot.com (Rick Rankin) Date: Thu, 10 Jun 1999 09:50:21 -0700 Subject: WinNT: Corrupt installation detected Message-ID: <7joq9h$qd2$1@schbbs.mot.com> I'm trying to install 1.5.2 on my Windows NT system. I previously had 1.5.2 beta 2 installed, which I uninstalled before trying to install the final release. When I try to run the installer (py152.exe), I immediately get a dialog box that says "Corrupt installation detected". I'm sure the downloaded installer is not corrupt. I opened it in WinZip and used the test function. All files in the archive tested fine. Has anyone seen this before? Thanks, Rick Rankin Motorola SATCOM From nospam at bitbucket.com Sun Jun 27 01:21:43 1999 From: nospam at bitbucket.com (Phil Mayes) Date: Sat, 26 Jun 1999 22:21:43 -0700 Subject: Memory leaks References: <7l35rf$dl3$1@news3.infoave.net> Message-ID: Steven L. Kille wrote in message <7l35rf$dl3$1 at news3.infoave.net>... >I'm embedding python in an MFC application. When I close the application I >get a bunch memory leak messages (16). Im sure this is just memory >allocated on startup and does not accumulate during the execution of my >program so it's not big deal. It's just kind of annoying, especially if >your looking for memory leaks in your own program. Does anyone know of any >other function I need to call other than Py_Finalize() when closing down my >app? If I just place the following two lines in my InitInstance() function >I get the memory leak messages: > >BOOL CFormulasApp::InitInstance() >{ > > Py_Initialize(); > Py_Finalize(); >return FALSE; >} I ran into this a while back, then discovered it was only in the debug build, so I ignored it. See if that's the case for you, too. I forget how I measured non-debug leaks - BoundsChecker, maybe. -- Phil Mayes pmayes AT olivebr DOT com Check out our PalmPilot news page at http://www.olivebr.com/pilot/news.htm From hniksic at srce.hr Wed Jun 2 16:46:49 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 02 Jun 1999 22:46:49 +0200 Subject: pickle vs .pyc References: <7j43pn$55l$1@mlv.mit.edu> Message-ID: <87wvxmba9y.fsf@pc-hrvoje.srce.hr> Michael Vezie writes: > from cache import fast,slow > > and it's right there. It's compiled, and seems really fast (loading > a 50k file in .12 seconds). I understand that .pyc files use marshal. Maybe this is simply a matter of marshal being faster than cPickle? Have you tried using marshal directly? (It makes sense for pickling to be slower than marshaling because it does more; for example, it takes care about recursive relationships and such.) From boud at rempt.xs4all.nl Sat Jun 26 16:00:58 1999 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 26 Jun 1999 20:00:58 GMT Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <59EAFD6B662F0706.86BFF3E906CBF8DE.784D2A219F85BC21@lp.airnews.net> <99062523473500.00769@Vegus> Message-ID: <7l3bhq$1se$1@essle.valdyas.org> John Travers wrote: i Has anybody tried the PyKDE/Qt package, (you don't have to have KDE), it is > absoloutly fantastic, quick, easy, powerful, far far better than Tkinter. > I love it! > So do I - I realize that it's currently a Unix only solution, but that's maybe because no-one has forked out for the Windows license of Qt! A few months ago I went through all the options myself, and PyKDE was the most satisfactory, especially in terms of pleasure in working with. It's now in version 0.8, and pretty good: http://www.river-bank.demon.co.uk/software/ is the place to get it. -- Boudewijn Rempt | www.xs4all.nl/~bsarempt From gutier at intergate.bc.ca Thu Jun 3 02:53:01 1999 From: gutier at intergate.bc.ca (Gerald Gutierrez) Date: 02 Jun 1999 23:53:01 -0700 Subject: Threaded Tkinter Message-ID: Hi all. I have two questions and I'd really appreciate it if someone could help me sort it out. My first one -- I'm starting out with Tkinter. I wrote the code below, which will supposedly create a button with an image, that image changing every second. If I set the button to call swapIcons() when pressed, the image changes fine, but using the SpinThread, the icons don't change. Is this because Tkinter is not thread-safe and I cannot safely change the button's image property from within a thread other than the main one? import Tkinter class App(Tkinter.Frame): def __init__(self): Tkinter.Frame.__init__(self) self.im1 = Tkinter.Image("photo", "tux", {"file":"oldtux.gif"}) self.im2 = Tkinter.Image("photo", "smiley", {"file":"smiley.gif"}) self.curImage = "tux" self.b = Tkinter.Button(self) self.b["image"] = self.curImage self.b["command"] = self.swapIcons self.b.pack({"side":"left"}) self.pack() def swapIcons(self): if (self.curImage == "tux"): self.curImage = "smiley" elif (self.curImage == "smiley"): self.curImage = "tux" self.b["image"] = self.curImage import threading import time class SpinThread(threading.Thread): def __init__(self, app): threading.Thread.__init__(self) self.app = app self.setDaemon(1) def run(self): while (1): self.app.swapIcons() time.sleep(1) app = App() st = SpinThread(app) st.start() app.mainloop() My second question -- I'd like to use Tkinter an Fnorb (CORBA) together as the UI and the network agent, respectively. Incoming CORBA calls will change appliation state and cause a change in the UI. Now, since both Tkinter and Fnorb have their own event loops, I probably have to run them each in a separate thread. This is fine with me. The problem is that, if my first problem above is caused by the fact that I cannot use Tkinter in mutiple threads, I will need to send UI change requests for processing from within the main thread. One way I know to do this is to have some sort of queue to which I can send messages. Tkinter's event loop will have to process the queue. How do I go about accomplishing this? If this is not the correct way, what is? Thanks for any help. Please forward replies to gutier at intergate.bc.ca. From jtravs at debian.org Sat Jun 26 19:12:04 1999 From: jtravs at debian.org (John Travers) Date: Sun, 27 Jun 1999 00:12:04 +0100 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <37741264.941B5B49@bioreason.com> Message-ID: <99062700165200.00448@Vegus> > John, > > Can you point me to any docs to help me get started with PyKDE? Have you tried the tutorial at: http://www.xs4all.nl/~bsarempt/python/tutorial.html Thats what got me started. Also you can use the Qt documentation almost literally, any deviations are described in the PyKDE docs. Hope this (very little) helps, I'm faily new to this too, just impressed by the ease of it all compared to GTK in C!! -- John Travers "Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us!" From arcege at shore.net Tue Jun 1 12:54:41 1999 From: arcege at shore.net (Michael P. Reilly) Date: Tue, 01 Jun 1999 16:54:41 GMT Subject: Looking for a lib fun References: <3753FDF4.5A13F8B8@zipzap.ch> Message-ID: Boris Borcic wrote: : There is a function I can't seem to find in the : standard library. One that will turn XML/HTML : offending characters to corresponding entity- or : character references. : Is it indeed in the lib ? Where ? If not, could a kind : soul hand me one ? Writing it really feels like : reinventing the wheel for the 10^nth time. : TIA Python 1.5 has the htmlentitydef module which you can use: import htmlentitydefs charmap = {} for key, val in htmlentitydefs.entitydefs.items(): charmap[val] = key At this point, charmap will contain character to entity references. charmap['>'] == 'gt' charmap[chr(160)] == 'nbsp' etc. I don't know if anyone has a more "complete" set tho. -Arcege From aahz at netcom.com Wed Jun 30 12:39:32 1999 From: aahz at netcom.com (Aahz Maruch) Date: 30 Jun 1999 16:39:32 GMT Subject: Python Editor References: Message-ID: <7ldh84$rle@dfw-ixnews12.ix.netcom.com> In article , Jose A. Antich wrote: > > Does anyone know if there's any Python Editor for the MAc? IDLE, a debugger/editor written in Python. You'll need Python 1.5.2 and Tcl/Tk 8.0 (*not* 8.1). -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het From amaranda at nospam.com Tue Jun 15 09:32:05 1999 From: amaranda at nospam.com (Alex Maranda) Date: Tue, 15 Jun 1999 14:32:05 +0100 Subject: (wxPython) Double left clicking and right clicking with ListBoxes References: <7k5ec1$pl3$1@zonnetje.NL.net> Message-ID: <376655D5.692A@nospam.com> Vivienne wrote: > > Hi there, [snip] Vivienne, The right place to ask about wxPython is on the m-list: http://starship.python.net/mailman/listinfo/wxpython-users This way you'll be sure that TOWK (The One Who Knows :) will see your messages (i.e. Robin Dunn). Cheers, -- Alex Maranda mailto: amaranda at spider dot com Spider Software Ltd. Tel: +44 (0)131 4757036 Edinburgh, UK http://members.xoom.com/Alex_Maranda STREAMS based communications protocols for embedded systems From fredrik at pythonware.com Tue Jun 22 07:15:28 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 22 Jun 1999 11:15:28 GMT Subject: htmllib: CR in CDATA References: <00d201bebc5a$adb129a0$0301a8c0@mnot.net> <012601bebc91$f3ded760$0301a8c0@mnot.net> <014401bebc9a$1963a9e0$0301a8c0@mnot.net> Message-ID: <000b01bebca0$8a022c20$f29b12c2@pythonware.com> Mark Nottingham wrote: > It appears that htmllib doesn't ignore returns in CDATA fields, as HTML 4.0 > says it should. well, htmllib doesn't claim to be HTML 4.0 compliant... > OK, I'm starting to have a really nice conversation with myself now ;-) > > htmllib DOESN'T change the newline to a single space - it leaves it in. > > CDATA is a sequence of characters from the document character set and may > include character entities. User agents should interpret attribute values as > follows: > Replace character entities with characters, > Ignore line feeds, > Replace each carriage return or tab with a single space. > User agents may ignore leading and trailing white space in CDATA > attribute values (e.g., " myval " may be interpreted as "myval"). > Authors should not declare attribute values with leading or trailing white > space. ...and it doesn't claim to be a "user agent", either... From mss at emsoft.de Sun Jun 27 14:31:54 1999 From: mss at emsoft.de (Michael S. Schliephake) Date: Sun, 27 Jun 1999 20:31:54 +0200 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> Message-ID: <37766E1A.49FC9062@emsoft.de> An HTML attachment was scrubbed... URL: From rdev at my-deja.com Wed Jun 30 14:18:57 1999 From: rdev at my-deja.com (rdev at my-deja.com) Date: Wed, 30 Jun 1999 19:18:57 +0100 Subject: Problem with bsddb on NT Message-ID: <000015ca@bossar.com.pl> From: rdev at my-deja.com I've been using bsddb on both Unix and NT and I found a very serious bug on the NT side: Using database opened with btopen: If I write random length records using a six byte key (arbitrary), the bsddb will crash with a protection exception after writing, typically, between 50 and 5000 records. Using database openend with hashopen: Same test as above, but rather than crashing with a protection exception, it generates a python exception as follows: Traceback (innermost last): File "Prog\bsddb_test.py", line 52, in ? test () File "Prog\bsddb_test.py", line 49, in test adb[key] = rec bsddb.error: (0, 'No error') It's easy to recreate using the test program below. It works just fine on Unix but dies quickly on NT. If anyone has any ideas at all, please help. This is a critical problem and I can't seem to find any workaround. Test Program: import random import bsddb import os # Test overview: # # Write a random length record between 1 and 1000 bytes, # using a 6 byte random valued # key. Repeat until the database crashes (typically between # 50 and 5000 writes. # # Crashes in different ways depending on whether bsddb was # opened as btree or hash database. def test (): count = 0 # Remove any old database in order to start clean try: os.remove('test.db') except: pass # Either open bsddb in hash mode or btree mode. # Each fails in its own way. adb = bsddb.btopen ('test.db', 'c') #adb = bsddb.hashopen ('test.db', 'c') # Generate a long constant string (1001 chars) longstring1 = 'a' * 1001 while 1: # Generate a large random string num = random.random() longstring = str(int(num * 1000000)) * 200 # Pick a record length from 1 to 1000 reclen = int(random.random() * 1000) + 1 # Use a keylen of 6 (arbitrary) keylen = 6 #if keylen + reclen > 214: # continue # Generate a key by taking the first keylen chars # from the long string key = longstring[:keylen] # Generate a record by taking the first reclen chars # from the constant string (contents don't matter here) rec = longstring1[:reclen] count = count + 1 print 'count = ', count print 'lengths = ', keylen, reclen, keylen + reclen print 'Key = ', key # Add it to the database adb[key] = rec test () Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From achrist at easystreet.com Mon Jun 21 20:08:48 1999 From: achrist at easystreet.com (Al Christians) Date: Mon, 21 Jun 1999 17:08:48 -0700 Subject: choosing random numbers with weights/probability? References: <929987267.6227@www.remarq.com> Message-ID: <376ED410.6D8B1562@easystreet.com> The standard way to do this (with non-integer weights) is to have a weight associated with each choice, normalized (scaled) so that the maximum weight is equal to 1.0. Then, after randomly selecting an item from the collection, generate a uniform random number between 0.0 and 1.0 and accept the choice only if the second random number is less than the weight of the randomly selected item. If it is not, the item is not used and you have to repeat the entire process with new random numbers as many times as needed to get an item for which the weight exeeds the second random number. Al kevinsl wrote: > > I've been using the whrandom.choice routine and it's very > useful. But is there any way to add weights or > probabilities of being chosen to the items in the list? > > example: > > list=['one','two','three'] > item=whrandom.choice(list) > > Is there any way to say that 'one' and 'two' have a 25% > chance of being chosen, and 'three' has a 50% chance? > > I'm hoping there's already a module to do this... or else > I'll be writing my own.. > > thanks, > > Kevin > > **** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) **** From hniksic at srce.hr Wed Jun 2 09:49:41 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 02 Jun 1999 15:49:41 +0200 Subject: A problem with re.split() Message-ID: <87pv3en24q.fsf@pc-hrvoje.srce.hr> I understand that the idea with "re" module is for it to behave as closely to Perl's regular expressions as possible (which is why the order of arguments in string.split and re.split is different, string.split being the logical one). The problem is with re.split() in this case: $ python Python 1.5.2 (#3, May 23 1999, 19:57:40) [GCC 2.8.1] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import re >>> re.split('', 'foo') ['foo'] Perl splits it to ['f', 'o', 'o']: $ perl -e 'print join(":", split("", "foo"))' f:o:o From skip at mojam.com Fri Jun 11 08:26:03 1999 From: skip at mojam.com (Skip Montanaro) Date: Fri, 11 Jun 1999 12:26:03 GMT Subject: Why is tcl broken? References: <375F82C7.CF0F0477@iname.com> <375f92b4.618467559@news.u-psud.fr> Message-ID: <376100E9.855C11C0@mojam.com> Laurent POINTAL wrote: > Fernando Mato Mira wrote: > for Python vs Tcl > >: If you have references to articles of the sort, that will be useful, > >: too. > > See http://www.cwi.nl/~sjoerd/PythonVsTcl.html While I'm sure that what Sjoerd wrote is accurate, it described Python and Tcl as they existed around late 1995 or early 1996. Both languages have changed more than a little since then. > I remeber having seen an article of a guy explaining why he switched > from Tcl to Python for a large project... but I loose the URL. That would be Frank Stajano. He presented a paper at last November's Python conference entitled "Implementing the SMS server, or why I switched from Tcl to Python". http://www.foretec.com/python/workshops/1998-11/proceedings/papers/stajano/stajano.html Frank's perspective is an interesting one, because unlike most of us, he used Tcl and [incr Tcl] happily for several years before encountering Python, so he brings a depth of understanding to the discussion most of us don't have. (I, on the other hand, got an immediate bad taste from Tcl and spit it right out. ;-) -- Skip Montanaro | Mojam: "Uniting the World of Music" http://www.mojam.com/ skip at mojam.com | Musi-Cal: http://www.musi-cal.com/ 518-372-5583 From piers at cs.su.oz.au Wed Jun 2 21:29:36 1999 From: piers at cs.su.oz.au (Piers Lauder) Date: Thu, 03 Jun 1999 11:29:36 +1000 Subject: cPickle dumps core Message-ID: <129.78.10.43.126.1589.928373856.156.11041> I have a problem with Python-1.5.2 and cPickle 1.63. Her's an example: # s Python-1.5.2 ; ./python Python 1.5.2 (#10, May 11 1999, 15:32:03) [GCC 2.8.1] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import cPickle >>> cPickle.loads("ht") Traceback (innermost last): File "", line 1, in ? cPickle.BadPickleGetBus error - core dumped (cPickle behaves similarly on a Linux/386 box.) I'd be very grateful if anyone can suggest a fix! From S.I.Reynolds at cs.bham.ac.uk Thu Jun 17 09:01:43 1999 From: S.I.Reynolds at cs.bham.ac.uk (Stuart Reynolds) Date: Thu, 17 Jun 1999 14:01:43 +0100 Subject: BiBTeX module? References: Message-ID: <3768F1B7.644A@cs.bham.ac.uk> Joe Strout wrote: > > Is there a BiBTeX module for Python? I did a search at python.org, but > apart from a Perl module (ick!), I didn't find anything. > I'm in the middle of writing a program to extract BibTeX tags from bib files at the moment. We'll be using it to produce an online reinforcement learning research papers database. If you can wait a couple of weeks it'll probably be finished and on the web. If you want, I'll send you the source when its done. Stuart From behrends at cse.msu.edu Sat Jun 26 01:50:38 1999 From: behrends at cse.msu.edu (Reimer Behrends) Date: 26 Jun 1999 05:50:38 GMT Subject: total idiot question: +=, .=, etc... References: <000d01bebeda$1b7430a0$d29e2299@tim> Message-ID: Tim Peters (tim_one at email.msn.com) wrote: > [Reimer Behrends] > > While I'd be the first to agree that C++ is not exactly the epitome of > > language design, I would think that at least the local variables should > > be easy to identify. The only real problem is to distinguish global > > variables from instance variables. And this is made worse in C++ by > > spreading all the information related to a class over more than one > > file. It should be noted that other languages do not necessarily have > > the same problem and that careful design can easily avoid it. > > But even with declarations up the wazoo, distinguishing local from instance > vars is a major problem in real-life C++: any OO language with declarations > has to allow local vars to shadow instance vars, To the contrary; Eiffel, under no circumstances allows shadowing of instance variables by formal parameters or by local variables. Yes, changing stuff in a superclass can thus break code in a subclass; but this can always happen (like if you add a new method that also exists in a subclass). Doing a major internal change to a superclass requires at least rechecking subclasses, anyway. (And I prefer compilers that are too picky rather than too lenient.) > else method implementations > can be broken by trivial changes in far-removed superclasses (e.g., Java > flatly prohibits shadowing in most cases -- but specifically allows this > one). Can you point me to the place in the Java language specification where this is said? I'm asking, because I've heard that, too, but haven't ever been able to find it and because the JDK happily allows to me shadow instance variables left and right. Of course, there are languages that don't have this problem. For instance, in either Smalltalk or Eiffel, there are no modules outside the class concept, and a variable is either local (which you can easily see in the method declaration, or an attribute. But I digress ... [...] > > But I do not think that the most basic operations of an OO language > > should be complicated by cumbersome syntax (this includes instance > > variable access and local method calls). The language should encourage > > use of these elements, not get in your way. > > Readability is more important to me over the long haul. Huh? Where have I said otherwise? I just happen to think that these two goals are not mutually exclusive. And there should be a better solution than the language ordaining a strange kind of Hungarian notation. > Say what you like, > but which vars belong to the instance is screamingly obvious the instant you > see > > self.x = self.y + k > > while in > > x = y + k > > it's at best a minor puzzle and at worst a long & tedious grep project. I tell you what--I have this great idea for an addition to Python. You know that you often can't tell what type a variable is? Well, we could introduce the following convention: Require variables to be prefixed with "$" to denote scalar values--strings and integers, "@" for lists, and "%" for dictionaries. Given the precedent of having to use self to access instance variables, this is entirely consistent with the current language, and is going to eliminate all those nasty problems where you can't tell from the context what the type of a variable or function is. :) Tongue-firmly-in-cheek-ly yours, Reimer From MHammond at skippinet.com.au Mon Jun 28 21:11:21 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Tue, 29 Jun 1999 11:11:21 +1000 Subject: ActiveX, IDE References: <7cKd3.3449$lr3.133866@news2.jacksonville.net> Message-ID: <7l96c1$5hn$1@m2.c2.telstra-mm.net.au> Hank Fay wrote in message <7cKd3.3449$lr3.133866 at news2.jacksonville.net>... >I'd like to make Wintel apps using ActiveX controls under Python: is there >an IDE for Python that will support this? Pythonwin supports hosting ActiveX controls, but if you are expecting an ActiveX IDE similar to VB, you will be dissapointed. http://starship.python.net/crew/mhammond Mark. From Sven.Drescher at dlr.de Fri Jun 18 04:59:47 1999 From: Sven.Drescher at dlr.de (Sven Drescher) Date: Fri, 18 Jun 1999 10:59:47 +0200 Subject: Dumb key-binding question References: <376434de@nntp.server.uni-frankfurt.de> Message-ID: <376A0A83.D9D11DF2@dlr.de> Hallo! Ist mal schoen jemanden auf Deutsch zu fragen, nicht das ich was gegen Fremdsprachen habe, aber ist halt einfacher. Ich las, dass Du es geschafft hast Key-Bindings zu implementieren. Ich versuche das schon seit laengerem, aber ohne Erfolg. Mit: name.bind("", command) klappt das naemlich nicht so richtig. Und das mit den Keysyms hab ich nicht so richtig verstanden. Waere schoen, wenn Du mir weiter helfen koenntest. Ueber ein kleines Beispiel wuerde ich mich freuen. Danke Sven mlauer at amalia-atm.rz.uni-frankfurt.de wrote: > Pardon, but I can not get binding > to work correctly. > works fine, but > only functions while > the holding the key. This is not exactly > what I was expecting... Hmm ? > > -- > -- > Regards & Gruesse from Mickey @ http://www.Vanille.de > --------------------------------------------------------- > How could anyone know me - when I don't even know myself ? -- _______________________________________ German Aerospace Research Establishment Institute of Flight Guidance Air Traffic Management Systems Tel.: (0531 -) 295 2515 From news at dorb.com Mon Jun 21 21:51:52 1999 From: news at dorb.com (Darrell) Date: Mon, 21 Jun 1999 21:51:52 -0400 Subject: choosing random numbers with weights/probability? References: <929987267.6227@www.remarq.com> Message-ID: Did a run of 100000. Looks like it works pretty well. Time: 5.33 sec {'one': 24781, 'three': 50148, 'two': 25071} --Darrell From MHammond at skippinet.com.au Tue Jun 1 19:30:27 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Wed, 2 Jun 1999 09:30:27 +1000 Subject: Why won't this work??? References: <7j0rkr$1eeu$1@rtpnews.raleigh.ibm.com> Message-ID: <7j1qc5$3rj$1@m2.c2.telstra-mm.net.au> Jr. King wrote in message <7j0rkr$1eeu$1 at rtpnews.raleigh.ibm.com>... >I know you are getting tired of me, but I have tried repeatedly to solve Well, I am now a little tired of you: * You post around 100 lines of C++/Python code with nothing more than "it doesnt work". Not even a hint of a symptom. * I try to mail you to let you know this to avoid further clogging of the newsgroup, and find your address spam protected! If you must ask simple questions about simple bugs in your own code, at least have the decency to put a valid email address so the rest of the newsgroup doesnt need to hear that you forgot to initialize a variable or some other trivial error. Mark. From mike at proteus.dialup.cloud9.net Fri Jun 4 10:55:31 1999 From: mike at proteus.dialup.cloud9.net (Michael Muller) Date: Fri, 4 Jun 1999 10:55:31 -0400 Subject: Threaded Tkinter In-Reply-To: <14167.21340.954229.2711@tiana.kli.prv> References: <375690B9.37C1B8B6@cloud9.net> <14167.21340.954229.2711@tiana.kli.prv> Message-ID: On Thu, 3 Jun 1999 gutier at intergate.bc.ca wrote: > > Hi Michael. > > Thanks for the suggestion. > > I had been mulling over the idea of somehow getting the Tk event loop > to periodically call a method of mine which would read a queue and do > what's needed. Would the lock you describe interfere with this in any > way? If not, how do I go about injecting messages into the Tk event > loop? > > Also, as you can guess I know little about Tk. Where is the event loop > in the code you provided below? Does the tk.after() call look at Tk's > event loop and perform necessary actions? [snip] I omitted the event loop call in this example. Add the line: tk.mainloop() This is the standard event loop, and it will continue to process events until the application is terminated. tk.after() creates a "timer"; the event handler subsequently reacts to the timer and calls the function at the appropriate time. ============================================================================= michaelMuller = proteus at cloud9.net | http://www.cloud9.net/~proteus ----------------------------------------------------------------------------- Mantra for the 60's: Tune in, turn on, drop out Mantra for the 90's: Turn on, jack in, jerk off ============================================================================= From matomira at iname.com Wed Jun 30 11:10:59 1999 From: matomira at iname.com (Fernando Mato Mira) Date: Wed, 30 Jun 1999 17:10:59 +0200 Subject: Language extensibility (was: Why is tcl broken?) References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> <37682DD3.43923243@compaq.com> <7ka2be$qja$1@nntp6.u.washington.edu> <37776FFA.2D85@mailserver.hursley.ibm.com> <876748mcxg.fsf@home.ivm.de> <37788BB9.ABD@mailserver.hursley.ibm.com> <3779ED0F.2C67@mailserver.hursley.ibm.com> Message-ID: <377A3383.D453468@iname.com> Tim Bradshaw wrote: > But the language of Lisp macros is Lisp, that's really the whole > point! Without knowing TCL, I find it hard to see how you can > introduce new constructs to the language *without* a macro language, > even if that language is TCL. Err.. What about Forth keywords? From greg.ewing at compaq.com Tue Jun 1 00:11:11 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Tue, 01 Jun 1999 16:11:11 +1200 Subject: Circular references (was: Defining VCL-like framework for Py References: <7hvnah$ern$1@cronkite.cc.uga.edu> <1284891865-6060292@hypernet.com> Message-ID: <37535D5F.10A86B10@compaq.com> Gordon McMillan wrote: > > Ce'Nedra, er, Hans wrote: > > Another way is to put one of them (the parent, normally) in some > kind of collection, (say, a dict keyed by a name, like id(parent)). > Tell the child the parent's name and the collection. When you cut the > parent loose from the dict, it goes away (the child does not directly > reference it). Then the child goes away (nobody is referencing it). I don't see how this helps, because then you have to do something special to make the parent go away (the dict is holding a reference to it). If you know when the parent is supposed to go away, you might as well call parent.free(). Greg From robin at jessikat.demon.co.uk Wed Jun 2 08:33:32 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Wed, 2 Jun 1999 13:33:32 +0100 Subject: Patch: Win32 stack overflow References: <375503B1.9893E25B@appliedbiometrics.com> Message-ID: In article <375503B1.9893E25B at appliedbiometrics.com>, Christian Tismer writes >Patch for python15.dll > >stack152.py > works great -- Robin Becker From graham at sloth.math.uga.edu Fri Jun 4 11:03:06 1999 From: graham at sloth.math.uga.edu (Graham Matthews) Date: 4 Jun 1999 15:03:06 GMT Subject: "The Python Way" References: <001101beae49$39af7bc0$949e2299@tim> Message-ID: <7j8pra$55v$4@cronkite.cc.uga.edu> [Fredrik Lundh] > Would both Guido and TIm Peters be willing to collaborate on a short > paper -- call it "The Python Way" for lack of a better title -- which > sets out the 10-20 prescriptives they might offer to those who come to > Python from other languages and immediately want to find a way to bend > it into uncomfortable positions -- (implement closures, etc.). Oh thank you Fredrik for posting the above. Does anyone else consider that the above sounds slightly paranoid? Can I make a suggestion. When someone, for example myself, makes a suggestion for adding something to Python or changing something, or dare I say it "improving" Python, perhaps you could consider the faint possibility that they are not trying to "find a way to bend Python into uncomfortable positions", but rather they are earnest Python users who happen to have some expertise/experience in the new idea being suggested, and think that it could not only greatly benefit Python, but also fit in rather well with the mystical "Python way". A short case in point. Recently I suggested adding mark-sweep-refcounting garbage collection to Python. I was immediately met with a wall of posts (some from you), saying basically what you say above, namely that "you want to bend Python into uncomfortable positions, ... positions that I suspect won't work or will be hard to implement". The reality is far from this. I don't want to bend Python at all. I quite *deliberately* proposed mark-sweep *with refcounts* (as opposed to any of the more high tech techniques) so that no existing Python code need change at all, so that the existing refcount mechanism stays the same, so that C extensions stay the same, etc. Moreover I quite *deliberately* proposed mark-sweep with refcounts because I know from experience with implementing such a scheme that it won't be hard to implement. In short when someone posts some suggested "improvement" to Python don't be so defensive. Open your mind to the possibility that the poster may have a point, that they are not trying to bend Python into uncomfortable positions, that they may know something about what they are positing about, and may even be positing something that would be good for Python. graham -- A cat named Easter He say "will you ever learn" Its just an empty cage girl If you kill the bird From asang at yahoo.com Wed Jun 30 19:58:16 1999 From: asang at yahoo.com (Asang Dani) Date: Wed, 30 Jun 1999 23:58:16 GMT Subject: Problem using freeze with pywintypes Message-ID: <7leauj$u2p$1@nnrp1.deja.com> I have discovered minor problem with using freeze with win32all modules by Mark Hammond. This occurs mainly because the name "PyWinTypes15.dll" given for the "pywintypes" module dll. (I am posting this because I don't want someone else to waste time on understanding the same problem). The problem and workaround are described as follows. 1. Create a small script test.py ------------------------------------------------------------ test.py ------------------------------------------------------------ import pywintypes import win32file ovstruct = pywintypes.OVERLAPPED() print 'hello World\n'. Unless "PYTHONEX" enviroment variable is set to the top level directory where sources for "win32all" modules reside, none of the win32* (and also pywintypes) module will get built into test.exe. Case A: PYTHONEX not set ------------------------- 2. freeze.py -p %pythonsrc% -o Build will try to build test.exe to be built in subdirectory "Build". 3. Copy test.exe, PyWinTypes15.dll,?python15.dll and win32file.pyd to a machine on which python is not installed. move PyWinTypes15.dll and python15.dll %systemroot%\system32 directory. 4. set PYTHONPATH=%cd% 5. type test.exe. Following error appears: "ImportError: No module named pywintypes". This occurs because "import pywintypes" statement causes core python's "find_module" function to be called,?which looks for 1. pywintypes.dll 2. pywintypes.pyd 3. pywintypes.pyc 4. pywintypes.py in %PYTHONPATH% and cannot find it there. Python on win32 also examines registry key: HKLM\SOFTWARE\Python\PythonCore\1.5\Modules\ In case such a key exists, it's value is taken as the "full-pathname" of the dll from which module can be loaded. When win32all-xxx.exe is installed, it creates such key for pywintypes and some other modules. For pywintypes, the value is of REG_SZ type and points to "C:\WINNT\system32\PyWinTypes15.dll". On the machine where it is not installed, "import fails". Renaming PyWinTypes15.dll PyWinTypes.dll will work if the script used *only* pywintypes module. If it uses any other module like win32file, it rename creates problem because win32file.pyd "depends" on PyWinTypes15.dll. WORKAROUND: ---------- 1. Create a text file follwing contents and name it as "pyreg.ini" \registry\machine\software\python PythonCore 1.5 Modules = pythoncom = REG_EXPAND_SZ %systemroot%\System32\pythoncom15.dll pywintypes = REG_EXPAND_SZ %systemroot%\System32\PyWinTypes15.dll 2. copy pyreg.ini to the target machine on which exe is used, and type "regini pyreg.ini". (This can be automated through simple windows cmd script very easliy. The script can launch test.exe automatically after creating registry keys). Case B: PYTHONEX is set to correct value ---------------------------------------- freeze.py -p %pythonsrc% -o Build will try to build test.exe to be built in subdirectory "Build". This fails with a linker error, "pywintypes.lib" not found. because the Makefile created by freeze.py does not give full path for pywintypes.lib. This can be patched by changing win32makemakefile.py to treat pywintypes module specially. (All the win32****.pyd modules, depend on pywintypes.lib). Hope this helps. Thanks asang.. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From news at dorb.com Wed Jun 2 17:03:38 1999 From: news at dorb.com (Darrell) Date: Wed, 2 Jun 1999 17:03:38 -0400 Subject: Python 2.0 References: <11A17AA2B9EAD111BCEA00A0C9B4179301E10ED1@forest.origin.ea.com> <374F1F6D.F3338F56@prescod.net> <374F5001.1C850DC@Lugoj.Com> <374F4591.3E66FB0@prescod.net> <374FF31A.6E990179@prescod.net> <37512edf.3024969@news.demon.co.uk> <3751573C.CAB4BFCB@hex.net> Message-ID: IONA has such a tool http://www.iona.com/products/orbix/comet1.html Also saw a book on this product but can't recall the name. I go buy it. -- --Darrell From tim_one at email.msn.com Tue Jun 15 01:29:06 1999 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 15 Jun 1999 01:29:06 -0400 Subject: fork() In-Reply-To: Message-ID: <000b01beb6ef$fcaba960$069e2299@tim> [Tim] > What you suggest is weaker, effectively lumping the SCCs into two gross > classes (singletons and non-singletons), and nuking the latter first. [Evan Simpson] > Sorry if I was unclear, but that's not what I meant by "dangly bits". > Rather, take the set of nodes from which you cannot reach a cycle. Their > subgraph is a union of DAGs, which can be released normally. In your > example, handing "c" a reference to "d<->e" converts it from a > dangly bit to a cycle-bridge. Ah, pulling the old DB-to-CB trick . I can't say for sure whether you were unclear before, but it's clear to me now. Thanks! > On the other hand, the SCC approach does look stronger than this, since it > can handle cycle-bridges as well. I'll happily take your word that > SCC-counting is likely to be too much trouble, but how about just doing an > SCC-analysis once M&S has discovered a cycle? If this is all happening in > the background, with no deadlines, and with rare, naughty data structures, > then it doesn't have to be terribly efficient. Well, we can *never* "win". The instant the "why aren't my cycles collected?" complaints go away, the "why does collecting my cycles take so bloody long?" complaints arrive. Note that the strongest proponents of GC over the years here have not, like the Perl camp, been worried about accidental cycles slowly piling up in long-running servers -- they're keen to create cycles all over the place. So slow won't fly forever. That said, identifying SCCs can actually be done quite efficiently; making an exact accounting of inter-SCC pointers is harder but still not a killer. I'm more bothered by the (lack of) *sense* in it all: ignoring a __del__ method on an object that has one is darned hard to justify, yet Python can't (any more than Java can!) do anything sensible with __del__ in cycles on its own. So my plan for the hour is: if M&S finds a cycle, it will clean it all up iff no involved object has a __del__. If an object in a trash cycle does have a __del__, tough, the cycle won't be reclaimed. Instead we'll supply a function you can call if you care, that will return those objects (one at a time? in a list? whatever), and you do with them what you will; if you don't clean them up, you'll keep getting them back every time you call that function until you resurrect them or break the cycle by hand in the way that makes most sense to your algorithm. In the face of ambiguity, refuse the temptation to guess <0.5 wink>. dear-lord-now-he's-quoting-himself-ly y'rs - tim From MHammond at skippinet.com.au Sun Jun 20 19:06:37 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Mon, 21 Jun 1999 09:06:37 +1000 Subject: Python source code documentation? References: <7kdv0l$n0g$1@nnrp1.deja.com> <7kenc7$1od$1@m2.c2.telstra-mm.net.au> <376D5BA2.70D845C4@compaq.com> Message-ID: <7kjs2b$k5n$1@m2.c2.telstra-mm.net.au> Greg Ewing wrote in message <376D5BA2.70D845C4 at compaq.com>... >Mark Hammond wrote: >> >> Pythondoc >> really doesnt want to introduce ugly mark-ups in the docstring > >What about non-ugly markups? Surely it's possible to >design a form of markup which doesn't look ugly. Well, "ugly" is in the eye of the beholder :-) The issue is a phrase such as: "This method is very similar to , but different" Clearly, when reading the docstring as a docstring in the source-code, this would qualify as ugly. It distracts from the user reading the text. Similarly, is also ugly, hence Pythondoc/structured text can convert *bold* into bold (for example). However, as far as marked-up text goes, I really dont consider my example ugly. Once you know that "om==object method", it really isnt that bad. I suppose what I was trying to say was "Pythondoc doesnt want to introduce mark-ups in the docstring as they are ugly" :-) Indeed, Pythondoes goes some way to move all links to the bottom of the docstring. I cant remember the exact format, but the text and the just target are kept seperate from each other. The analogy would be that in my world, I would consider: Please see quite acceptable, and indeed quite an improvement (wrt maintenance) if you consider the generated documentation the "primary documentation" - ie, the format people will most often use to read the docstrings. In fact, I believe this is the biggest difference between the pythondoc focus and the autoduck type focus. Pythondoc strives to keep completely readable docstrings and generate good documentation. Autoduck type formatting is happy to sacrifice some of the docstring readability in order to create better documentation. [Important to recall autoduck started as autodoc, which can parse C code and marked up comments. This is quite a different environment to Python docstrings available at runtime.] Mark. From gherron at aw.sgi.com Tue Jun 29 13:28:03 1999 From: gherron at aw.sgi.com (Gary Herron) Date: Tue, 29 Jun 1999 17:28:03 GMT Subject: Tkinter slide question References: <3778EC8B.833DEBC4@hti.com> Message-ID: <37790223.F469BC4D@aw.sgi.com> David Stokes wrote: > > I'm trying to implement a slide to control how often a function restarts > but it appears that I'm not getting the result back from the 'variable' > variable. Could some kind soul out there on the proper way to read the > slide 'position'? > > Code snipit: > Scale(label="Rescan",variable=self.yspeed,orient=HORIZONTAL,).grid(column=0) > > currently returns PY_VAR12 instead of the slider value. Try self.yspeed.get() to get the value of the variable. -- Dr. Gary Herron 206-287-5616 Alias | Wavefront 1218 3rd Ave, Suite 800, Seattle WA 98101 From jeffrey at Digicool.com Fri Jun 4 15:20:26 1999 From: jeffrey at Digicool.com (Jeffrey P Shell) Date: Fri, 04 Jun 1999 15:20:26 -0400 Subject: python active web pages References: Message-ID: <7j98qf$c96$1@autumn.news.rcn.net> > i also looked at ZTemplates (a component of Zope), > > , > > and while it doesn't actually embed python, it has a limited embedding > language of its own, DTML, which gets munged into python. i must say that > DTML looks a bit hideous (if anyone from digicool is reading, sorry guys). ZTemplates, aka DTML Syntax is this:: DTML Scripting is this:: It's not munged into python, it IS python. It's just expressions, and it's run through a Safe Evaluator (that (in Zope) works with security machinery, and tries to prevent things like infinite recursion and some other potentially unsafe things). Just wanted to clear that up. In Zope where everything can potentially be managed through the web and control can be turned over to other people, the safety of expressions and hook-ins to the Zope security machinery is a very powerful notion. .jPS | jeffrey at digicool.com zope, through the web. www.zope.org From xhyuan at oe.fau.edu Wed Jun 2 20:16:42 1999 From: xhyuan at oe.fau.edu (Xiaohong Yuan) Date: Wed, 2 Jun 1999 17:16:42 -0700 (PDT) Subject: problem with static linking Message-ID: I am working on Python c extensions on QNX. Since QNX doesn't support dynamic linking. I have to link my c extension module staticly with python interpreter. But in my c extension module, I have external variable declaration, which makes it fail to be linked with Python interpreter. There must be some way to solve this, could anybody help me with this? Thank you very much. Xiaohong Yuan From jason at harlequin.com Thu Jun 10 06:58:23 1999 From: jason at harlequin.com (Jason Trenouth) Date: Thu, 10 Jun 1999 10:58:23 GMT Subject: Asserting object class References: <375F8986.73BA3C5@i-data.com> Message-ID: <379899bf.2325681250@newshost> On Thu, 10 Jun 1999 09:46:46 +0000, Adi wrote: > In a method, I'd like to assert that a parameter is an object which is > of a specific class or has this class as it's base class. > > I can test on the __class__ and its __bases__ attributes, but its clumsy > and I'm wondering if there is an easier notation, like: > > def method(self, p) > assert class(p) == class(self) > > This is comparable to - in a strongly typed language - specifying a > required base class as the type of the parameter. FWIW, in Dylan you'd write it as: define method m (self, p) assert(object-class(p) == object-class(self)); .. end; __Jason From jdrudnicki at yahoo.com Wed Jun 2 04:59:35 1999 From: jdrudnicki at yahoo.com (Jim Rudnicki) Date: Wed, 2 Jun 1999 01:59:35 -0700 Subject: All this self dot is making me... Message-ID: To the beginner, having to type all these self. 's in class methods seems a bit painful. So all three of these methods below do the same thing. That leaves one to wonder "why have classes at all?" A little thought and I remember that this same thing is happening in C++: the compiler is adding a this pointer to the passed parameters. So Func and fooFunc are the same thing. The only difference between a method and a class method is scope/access rules and tacking on this pointers, which in C++ is done by the compiler. Correct? So what has me perplexed is why all the self. 's? Is this a namespace issue or maybe just to expensive to do at runtime? For those of us who have less cartilage left in their hands, would it be acceptable to use "my." or better "me." Or is self. strongly ingrained? The two less characters add up and the keys are on stronger fingers. nite, Jim def Func( this, a, b ): this.x = a + b class Foo: def __init__( self ): self.x = 0 self.f = Func def fooFunc( me, a, b ): me.x = a + b #if it was C++ # fooFunc( a, b ) { # x = a + b; } # who needs class methods? z1 = Foo() Func( z1, 5, 7 ) print z1.x # it doesn't really matter if the method is in a class z2 = Foo() z2.f( z2, 5, 7 ) print z2.x # this is the same as z1 approach z3 = Foo() z3.fooFunc( 5, 7 ) print z3.x From mlv at pobox.com Wed Jun 2 16:22:15 1999 From: mlv at pobox.com (Michael Vezie) Date: 2 Jun 1999 16:22:15 -0400 Subject: pickle vs .pyc Message-ID: <7j43pn$55l$1@mlv.mit.edu> I need to be able to read a couple very complex (dictionary of arrays of dictionaries, and array of dictionaries of array of dictionaries) data structures into python. To generate it by hand takes too long, so I want to generate it once, and read it each time (the data doesn't change). The obvious choice is, of course pickle, or some flavor thereof. But can someone tell me why this wouldn't be faster: In the code that does the "pickling", simply do: f = open("cache.py", "w") f.write("# cache file for fast,slow\n") f.write("fast = "+`fast`+'\n') f.write("slow = "+`slow'+'\n') f.close() import cache Then, later, when I want the data, I just do: from cache import fast,slow and it's right there. It's compiled, and seems really fast (loading a 50k file in .12 seconds). I just tried the same data using cPickle, and it took 1.4 seconds. It's also not as portable. There is a space savings with pickle, but it's only 5% (well, 56% if you count both the .py and .pyc files), but that doesn't really matter to me. Am I missing something here? This sounds like an obvious, and fast, way to do things. True, the caching part may take longer. But I really don't care about that, since it's done only once, and in the background. Michael From guido at cnri.reston.va.us Thu Jun 10 00:50:10 1999 From: guido at cnri.reston.va.us (Guido van Rossum) Date: 10 Jun 1999 00:50:10 -0400 Subject: GC SIG References: Message-ID: <5l7lpczmkd.fsf@eric.cnri.reston.va.us> Robert Meegan writes: > Are there enough potential Sanitation Engineers to create a Garbage > Collection SIG? Rather than create a hell (mailing list) where the discussion can go on forever without ever concluding, why not create a bible (FAQ) that summarizes all arguments pro and con once and for all? Then when the issue is raised, we can simply point to the GC FAQ. --Guido van Rossum (home page: http://www.python.org/~guido/) From tim_one at email.msn.com Wed Jun 9 01:18:39 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 9 Jun 1999 01:18:39 -0400 Subject: tstate invalid crash with threads In-Reply-To: <375D3424.6EF8E85F@commsecure.com.au> Message-ID: <000101beb237$88b71d80$999e2299@tim> Followups to the Thread-SIG, please. [Ray Loyzaga] > I have been playing with a multithreaded tcp based server for a while, > and during some serious stress testing continually hit a problem > involving the interpreter crashing with "Fatal Python error: > PyThreadState_Delete: invalid tstate". > ... > It appears to be a subtle race in PyThreadState_Delete .... > interestingly, if I uncomment the small sleep in "handle" in the server, > ie. make the server slower, it seems to work for ever ... 4m transactions > before I gave up. I think the problem only comes if you are creating and > destroying threads quickly in parallel. PyThreadState_Delete is called from very few places, and one of them strikes me as suspicious: at the end of threadmodule.c's t_bootstrap, we have: PyThreadState_Clear(tstate); PyEval_ReleaseThread(tstate); PyThreadState_Delete(tstate); PyThread_exit_thread(); The suspicious thing here is that PyEval_ReleaseThread releases the global interpreter lock, so nothing is serializing calls to PyThreadState_Delete made from the following line. PyThreadState_Delete in turn does no locking of its own either, but mutates a shared list. If this isn't plain wrong, it's certainly not plain right . Matches your symptoms, too (very rare blowups during high rates of thread death). Guido? I haven't been able to provoke Ray's problem under Win95, but the above just doesn't smell right. win95-didn't-crash-but-the-TAB-and-ESC-keys-did-swap-their- meanings!-ly y'rs - tim From tismer at appliedbiometrics.com Tue Jun 15 07:20:10 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Tue, 15 Jun 1999 11:20:10 GMT Subject: ANN: Stackless Python 0.2 References: <37628EAA.C682F16C@appliedbiometrics.com> <7k4fd4$c04$1@brick.cswv.com> Message-ID: <376636EA.84240129@appliedbiometrics.com> Neel Krishnaswami wrote: [Stackless Python 0.2] > This is very neat, and you are completely deranged. I know just > enough to know that I should cheer you on, mind, but I'll try to > cheer loudly. Feel free to make an announce when you add coroutine > support. Please? :) Thanks :-) Sure I will. I'd like to know wether my binary works ok for you. You might also try a recursive function, it should raise an exception after 29999 recursions (just to have *a* limit). I'm just undecided on the design. There are a couple of different coroutine interfaces. You find them for instance in Scheme, in Modula II, some Oberons, Icon, and in Tim Peter's example which I added to my stackless archive. Do you have a proposal? For Stackless V. 0.3 I'm planning for some more nonrecursive builtins, and also for a proper "invalid opcode" handling, which makes it possible to extend the standard interpreter without having to build Python or rewrite eval_code completely. This will give a new playing ground for Michael Hudson. Then the Stackless implementation will only undergo changes if something needs internal support. Everything else will go into extension modules which can be loaded on demand. One extension I'm planning is an API engine, which knows all C API calls and all internal structures. Together with a small fast engine, this will allow to build new fast functions without a compler. Maybe this is not for this year. But first I have to get out of this asylum :-? lunaticly y'rs - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From moshez at math.huji.ac.il Mon Jun 7 18:03:03 1999 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Tue, 8 Jun 1999 01:03:03 +0300 Subject: waste of resources ? In-Reply-To: <87pv37zpex.fsf@pc-hrvoje.srce.hr> References: <375C0F91.1C73E4E3@icrf.icnet.uk> <375C16A9.5ADC4990@icrf.icnet.uk> <375C2003.B01BEC3@arlut.utexas.edu> <87yahvzqz3.fsf@pc-hrvoje.srce.hr> <87pv37zpex.fsf@pc-hrvoje.srce.hr> Message-ID: On 7 Jun 1999, Hrvoje Niksic wrote: > I don't know about Perl, but a good fix would be to have the > interpreter do the hard work for us. If a system call fails and errno > is EINTR, then the signal handler should be called, *and* the syscall > should be restarted. Ummmmm...... You can do the hard-work yourself, but once and for all: def myread(file): while 1: try: return file.read() except (IOError, os.error), detail: if detail.args[0] != errno.EINTR: raise And just call myread(foo) instead of foo.read(). Where's the catch-22? -- Moshe Zadka . QOTD: My own exit is more likely to be horizontal then perpendicular. From tim_one at email.msn.com Thu Jun 17 01:58:13 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 17 Jun 1999 01:58:13 -0400 Subject: fork() In-Reply-To: Message-ID: <000101beb886$628a1ea0$099e2299@tim> [Hisao Suzuki and Tim, jockeying over new/delete in C++ vs __del__ in Python, and their relation to cycles and some Stroustrup quotes] [Hisao] > ... > You miss the point. Could be. Expect it's really that I disagree with it, though. I agree that (barring pathologies) the only a way an object is immortal in C++ is if it's explicitly new'ed but never explicitly delete'd, and that the only way an object is immortal in Python (make that CPython, & make that today) is if it's in a cycle. You want to infer something from that, while I think the languages are so different that trying to read anything into it is like trying to see animal figures in the passing clouds . > ... > If an object is part of a cycle, the object will never lose the > reference(s) to it. So the phrase `(be) never deleted' for C++ > can be safely translated as `(be) part of cycles' for Python. > You see? To me, that merely describes the conditions under which the respective languages treat an object as immortal today. It makes good sense for Stroustrup to say that in C++ a garbage collector shouldn't invoke the finalizer for its flavor of immortal objects, but he's not arguing that position *because* they're immortal today, but instead because explictly new'ed objects never have their finalizer invoked in C++ unless explicitly delete'd, and GC is not explicit delete'tion. Python has no such rules, so the core of his argument doesn't apply to Python without more strain than I can swallow <0.9 wink>. > | Further the C++ 3rd Ed. says: > | "It is possible to design a garbage collector to invoke the > | destructors for objects that have been specifically > | registered' with the collector. However, there is no > | standard way of `registering' objects. Note that it is > | always important to destroy objects in an order that ensures > | that the destructor for one object doesn't refer to an > | object that has been previously destroyed. Such ordering > | isn't easily achieved by a garbage collector without help > | from the programmer." [Tim] >> Java solved that one -- for all the good it did . [Hisao] > Are you referring to java.lang.ref.PhantomReference of Java2? No. > Otherwise you wholly miss the point. Whose point ? Java has always guaranteed to "destroy objects in an order that ensures that the destructor for one object doesn't refer to an object that has been previously destroyed", and indeed "without help from the programmer". So by "Java solved that one" I meant it satisfactorily addressed the points made in the quote. That doesn't mean there aren't other points to be made, but since the quote you gave didn't make any other points I don't feel bad about commenting on the points it did make . > The traditional mechanism of finalization in Java serves as only a > safety net at _best_. Sure. It can't be faulted for any of the points *Stroustrup* made, though. > ... > The idea of guardians is not so particular to Scheme. It might > be safe to say that Scheme is a language that happened to be > used. Needless to say, it is important to keep _Python_ simple, > handy, and consistent. Yes, except I'd rather Python be consistent with its own object semantics than with isolated portions of C++'s; and despite their frequent happy coexistence, "simple" for the user is not always "simple" for the implementation. > ... > However, the programmer often knows the expected refcount of the > object or the aggregation object of several objects when it > becomes unreachable from any other (aggregation of) objects. > Usually (though not always) he/she can pass the expected > refcount to the guardian. Afraid not! refcounts in Python are often unintuitive: D:\Python>python Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import sys >>> sys.getrefcount(3) 8 >>> sys.getrefcount("Suzuki") 4 >>> sys.getrefcount("Hisao Suzuki") 2 >>> sys.getrefcount(sys) 5 >>> People use getrefcount at their own risk, and the specific values returned are not bound to remain the same from one release to the next, or even one run to the next (toss in a thread or two, and they can bounce around seemingly "at random" even within a single run). The refcounts are there for the convenience of the implementation, not the user; so this isn't a foundation on which to build anything at the user level (although some people do, and some of those even live long enough to regret it <0.9 wink>). > ... > And it is our usual practice to make prototypes in Python first, > if possible, to experiment on some ideas, isn't it? :-) Definitely. In this case, though, it's probably easier to modify the Python source code <0.5 wink>. curmudgeonly y'rs - tim From Karthik.Ganesan at p98.f112.n480.z2.fidonet.org Wed Jun 30 13:32:03 1999 From: Karthik.Ganesan at p98.f112.n480.z2.fidonet.org (Karthik Ganesan) Date: Wed, 30 Jun 1999 18:32:03 +0100 Subject: idle- setting breakpoints Message-ID: <000015fd@bossar.com.pl> From: Karthik Ganesan Hi, To set a breakpoint under idle: -have a "Python Shell" (the one which opens up when you fire up idle) open -Select Debug->Debugger, a window should pop open having the GUI for the debugger Now you can set breakpoint in your code. If you dont have this debug window open, you get a bell from the function PyShellEditorWindow.set_breakpoint_here(self, event=none) as the attribute self.flist.pyshell.interp.debugger is . It seems that the function PyShell.toggle_debugger() (called when you select the above menu option) gives this attribute a valid value. -karthik From guido at CNRI.Reston.VA.US Wed Jun 23 11:08:32 1999 From: guido at CNRI.Reston.VA.US (Guido van Rossum) Date: Wed, 23 Jun 1999 11:08:32 -0400 Subject: List <-> news hosed again? Message-ID: <199906231508.LAA23048@eric.cnri.reston.va.us> Tim Peters wrote: > Seems to me the c.l.py mailing list -> news gateway stopped cold > again late last week. Less sure of the other direction, but I do > believe I've seen some older recent articles on DejaNews that > haven't come thru on the list. > If you're reading this and are not on the mailing list, share the > secret . We're looking into this; uunet changed their configuration and we neglected to make a matching change. It should be fixed now (presuming this message shows up on the uunet side of things). --Guido van Rossum (home page: http://www.python.org/~guido/) From fw at cygnus.stuttgart.netsurf.de Sun Jun 6 15:14:49 1999 From: fw at cygnus.stuttgart.netsurf.de (Florian Weimer) Date: 06 Jun 1999 21:14:49 +0200 Subject: Using CVS under Win95 References: Message-ID: "Emile van Sebille" writes: > D>cvs -d :pserver:pythoncvs at cvs.python.org:/projects/cvsroot login > (Logging in to pythoncvs at cvs.python.org) > CVS.EXE [login aborted]: could not find out home directory Did you set your HOME environment variable? >From the CVS documentation: | `$HOME' | `$HOMEPATH' | `$HOMEDRIVE' | Used to locate the directory where the `.cvsrc' file, and other | such files, are searched. On Unix, CVS just checks for HOME. On | Windows NT, the system will set HOMEDRIVE, for example to `d:' and | HOMEPATH, for example to `\joe'. On Windows 95, you'll probably | need to set HOMEDRIVE and HOMEPATH yourself. (I don't use CVS on Windows, so I don't know whether this really works.) From graham at sloth.math.uga.edu Sun Jun 6 20:46:14 1999 From: graham at sloth.math.uga.edu (Graham Matthews) Date: 7 Jun 1999 00:46:14 GMT Subject: "The Python Way" References: <000d01beaef4$ab3b5c40$f19e2299@tim> Message-ID: <7jf4om$bbo$1@cronkite.cc.uga.edu> [Patrick Phalen, misattributed to Fredrik Lundh] > Would both Guido and TIm Peters be willing to collaborate on a short > paper -- call it "The Python Way" for lack of a better title -- which > sets out the 10-20 prescriptives they might offer to those who come to > Python from other languages and immediately want to find a way to bend > it into uncomfortable positions -- (implement closures, etc.). [Graham Matthews] > Does anyone else consider that the above sounds slightly paranoid? Tim Peters (tim_one at email.msn.com) wrote: : Less so than your response <0.6 wink>. I don't think so Tim. I think my post was pretty fair actually. I think a fair evaluation of this group is that critiques of Python (and that includes suggestions for improvements) are met pretty hostily (if there is such a word). I think Python misses out on a lot of good ideas as a result, and that's a shame. The whole notion of "the Python way" is pretty much anathema to the notion of open discussion. Tim Peters (tim_one at email.msn.com) wrote: : I saw no hint that Patrick was : referring to you or your current agenda. In context, he was clearly asking : for the list of "Pythonic Principles" from which Guido supposedly deduces-- : with exacting rigor --what goes in and what stays out. That's all. I think you are showing your spots here Tim. My post clearly cited used my contributions to the GC thread *as an example* of the hostility that news (or old, as in this GC case) are treated. It clearly did *not* say that I thought Patrick's comments (badly attributed to Fredrik) were directed at me. graham -- One day in a nuclear age They may understand our rage We build machines that we can't control And bury the waste in a great big hole From hniksic at srce.hr Mon Jun 7 14:48:15 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 07 Jun 1999 20:48:15 +0200 Subject: fork() References: <375BE64A.EB997F24@icrf.icnet.uk> <87so840zcc.fsf@pc-hrvoje.srce.hr> <375BF721.4B1864F2@icrf.icnet.uk> Message-ID: <87u2sjzw28.fsf@pc-hrvoje.srce.hr> Arne Mueller writes: > > If you don't change the dictionary, the memory will not be copied. [...] > Huh, that's realy good news! But I don't understand how that works, It works by MMU (memory management unit) magic. The OS doesn't really "watch" the system activity -- it's more that when the child writes to one of the pages in question, a trap is invoked which copies the page and remaps the child's memory address to point to the copy. > However my children don't change anything in the dictionary ;-) Then the memory should be kept. You can test this by running a script like this: import os, time largestring = "x" * 10000000 for i in range(50): if os.fork() != 0: time.sleep(60) os._exit(0) time.sleep(60) This creates fifty processes, each of which sleep a minute and exit, and their parent does the same. Each process can access a 10M string. Needless to say, I don't have 500M virtual memory on my Linux box, so copy-on-write definitely works here. Also, `free' reports: {pc-hrvoje}[~]$ free total used free shared buffers cached Mem: 63272 62572 700 534736 88 9844 -/+ buffers/cache: 52640 10632 Swap: 120924 22112 98812 Of 534M memory shared between the processes (under the "shared" column), about 500 comes from the 50 python processes. From greg.ewing at compaq.com Mon Jun 28 23:16:51 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Tue, 29 Jun 1999 15:16:51 +1200 Subject: Why is tcl broken? References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> <37682DD3.43923243@compaq.com> <7ka2be$qja$1@nntp6.u.washington.edu> <37776FFA.2D85@mailserver.hursley.ibm.com> Message-ID: <37783AA3.CC63664C@compaq.com> Paul Duffin wrote: > > Actually you find that you can do everything that YOU want to > in Python and YOU find it easier than doing it in Tcl. I do not > believe that you can do everything in Python that you can do > in Tcl (at least as regards extending the language itself). I meant that Python addresses all the major areas of application that Tcl's designer claims Tcl was designed for. I don't regard extending Tcl as an "application" of Tcl -- it's just a means to an end. Python achieves many of the same ends as Tcl using different means. Greg From MHammond at skippinet.com.au Tue Jun 22 10:07:24 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Wed, 23 Jun 1999 00:07:24 +1000 Subject: IDLE 0.5 Function parameter display? References: <7kmpnu$red$1@nnrp1.deja.com> Message-ID: <7ko57c$cfk$1@m2.c2.telstra-mm.net.au> The best way at the moment is to add a docstring to the function in the C code. If you look at the help provided for (eg) string.split, it is quite effective even though it is only from the docstring. Mark. Sam Schulenburg wrote in message <7kmpnu$red$1 at nnrp1.deja.com>... >I love the ability of IDLE 0.5 to display the function parameter >requirements as defined in the original function definition. My problem >is when I have a function defined in a windows dll written in 'C', then From jan at q-bus.de Tue Jun 8 06:59:35 1999 From: jan at q-bus.de (Jan Walter) Date: Tue, 8 Jun 1999 12:59:35 +0200 Subject: I'll pay $40 in e-gold if you'll fix this bug. References: <7jigrv$ppo$1@xs3.xs4all.nl> Message-ID: <19990608120140.11DF2310440@bireme.oratrix.nl> Hi, Maybe you get confused a bit by the bash!!! Try following: bash$ tcsh tcsh: cd /tmp/ tcsh: mkdir dirOne tcsh: mkdir dirTwo tcsh: mkdir dirTwo/dirThree tcsh: ln -s dirTwo/dirThree/ . tcsh: cd dirThree/ tcsh: pwd /tmp/dirTwo/dirThree Do the same with the bash (removing the directories of course): bash$ cd /tmp/ bash$ mkdir dirOne bash$ mkdir dirTwo bash$ mkdir dirTwo/dirThree bash$ ln -s dirTwo/dirThree/ . bash$ cd dirThree/ bash$ pwd /tmp/dirThree The tcsh gives the right answer. You are in the /tmp/dirTwo/dirThree directory. If you try to move a file with "mv file.txt ../dirOne/file.txt" you can?t do that because there is no directory dirOne !!! Python works like tcsh. If you try the following you get the right answer: bash$ cd /tmp/dirThree/ bash$ python Python 1.5.1 (#1, May 6 1998, 01:48:27) [GCC 2.7.2.3] on linux-i386 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import os >>> os.getcwd() '/tmp/dirTwo/dirThree' My suggestion: You can test if there are symbolic links in your path (e.g. os.path.islink("/tmp/dirThree") within Python) or you can prove that /tmp/dirThree is in reality /tmp/dirTwo/dirThree and life with that fact ... Cheers, Jan From bwarsaw at cnri.reston.va.us Thu Jun 3 13:08:52 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Thu, 3 Jun 1999 13:08:52 -0400 (EDT) Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <87pv3iq6ss.fsf@ev.netlab.co.jp> <3752C76D.604CD474@prescod.net> <87n1ykr0z9.fsf@ev.netlab.co.jp> <375372F6.A874554@prescod.net> <87hfosquc0.fsf@ev.netlab.co.jp> <3753F121.E4A9BE8B@prescod.net> <87yai3ntdt.fsf@ev.netlab.co.jp> <7j3iif$134e$1@nntp6.u.washington.edu> <7j45iv$908$4@cronkite.cc.uga.edu> <7j4hhj$118u$1@nntp6.u.washington.edu> Message-ID: <14166.46756.866947.64007@anthem.cnri.reston.va.us> >>>>> "DC" == Donn Cave writes: DC> Does JPython use reference counts, and invoke delete methods DC> as soon as reference count drops to 0? JPython used to call __del__() when the Java object (PyInstance) was finalized. See my previous message on the subject for why this has been commented out. I don't believe __del__() is ever invoked now in JPython. -Barry From peterb at arch.sel.sony.com Tue Jun 22 05:10:42 1999 From: peterb at arch.sel.sony.com (Peter) Date: Tue, 22 Jun 1999 10:10:42 +0100 Subject: Drag and dropable scripts on NT Message-ID: <376F5312.C404B9E0@arch.sel.sony.com> I'm interested in packaging up some Python code such that I can drop a file onto the script icon and have it do it's thing... I have the script working fine. Don't know where to turn to figure out the next step. Thanks - From python-list at teleo.net Wed Jun 23 18:52:37 1999 From: python-list at teleo.net (Patrick Phalen) Date: Wed, 23 Jun 1999 15:52:37 -0700 Subject: Thanks for Python... References: Message-ID: <99062316154001.00558@quadra.teleo.net> Jeff Rush wrote: > ... Now if I could just get time to port > it to the PalmPilot, I'd never be away from it. Sounds like a job for Itsy, if Compaq ever decides to release it as a consumer product. http://www.research.digital.com/wrl/itsy/ Runs under Linux with GNU tools on the StrongARM SA-1100 with 16MB of DRAM (expandable), onboard USB, etc. They're already fooling around Java and Squeak versions. In fact, it appears generally rather Pythonic in design. :) From rozzin at geekspace.com Tue Jun 29 08:57:43 1999 From: rozzin at geekspace.com (Joshua Rosen) Date: Tue, 29 Jun 1999 08:57:43 -0400 Subject: Typing [Re: total idiot question: +=, .=, etc...] References: <000d01bebeda$1b7430a0$d29e2299@tim> Message-ID: <3778C2C7.3B101FD0@geekspace.com> Reimer Behrends wrote: > Require variables to be prefixed with "$" to denote scalar > values--strings and integers, "@" for lists, and "%" for > dictionaries. > > Given the precedent of having to use self to access instance variables, > this is entirely consistent with the current language, and is going to > eliminate all those nasty problems where you can't tell from the context > what the type of a variable or function is. :) +There is no difficulty in getting the program to know what type some piece of data is, which lessens the need for the type-declaring prefixes--use type(), and then check obj.__class__ if obj is a class-instance, and you need to -know- what class it is (if you want to -force- it to be a certain type, keep reading). +Requiring variables to bear a prefix denoting type sortof makes Python into a statically-typed language, where one of the big reasons for using it is that it's a dynamically-typed language. +There is no such thing as a `scalare', in Python--strings and numbers are different data-types, numeric data can actually be one of many different classes. +Forcing data to be of a specific type is already possible--see documentation on int(), str(), list(), tuple(), float(), long(), complex(), string.atoi(), et al. This functionality also lessens, if not completely eliminates the need for typing prefixes; the program knows what type the data is being coered into, and so does the programmer. In fact, all of the functionality that you're proposing (and then some) is already there--it just looks different. +If you really want a feature that -really- isn't offered by a language, the best decision may be to just use another language that -does- offer it. Try Pike, for one (I suggest it because it has nifty typing which you may like: you can declare a variable to be one or -more- types, or use a mixed type). Choose your languages based upon what you need them to do. -Rozzin. From none at microsoft.com Thu Jun 10 00:03:01 1999 From: none at microsoft.com (plz_reply_to_group) Date: Wed, 09 Jun 1999 21:03:01 -0700 Subject: How do I match . . . Thank you both very much! References: <375F21B3.D23A5EA9@west.boeing.com> Message-ID: <375F38F5.F610E07C@microsoft.com> Dang, those are both good ideas! Now that I have taken a little break from what i was doing, I can see that I was not thinking too clearly about what I was trying to do. I was thinking in terms of "regular expressions", not strings! I was almost going to resort to reversing the string, then matching the '/', clipping off the file name, then reversing it again, or using a while loop to match each occurance. Both seemed inelegant. Thanks! Jeff Polaski "Jeff P." wrote: > > I've been messing with this for a little while now, but I can't get this > to work. How do I match the last occurence of '\' in a string? I want to > remove the file name from a url (e.g. news/breakingnews/981001b.html --> > news/breakingnews/ ). > > Here is the simplest version (that doesn't work). It matches the _first_ > backslash. > > import regex > > file_in = open( 'dir.txt', 'r+' ) > for line in file_in.readlines(): > print regex.search( '/', line ) > > Thanks for any help! > > Jeff P. From mikael at pobox.com Fri Jun 25 18:21:06 1999 From: mikael at pobox.com (Mikael Lyngvig) Date: Fri, 25 Jun 1999 22:21:06 GMT Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> <3773c3a0.102825445@news.oh.verio.com> Message-ID: <59EAFD6B662F0706.86BFF3E906CBF8DE.784D2A219F85BC21@lp.airnews.net> On Fri, 25 Jun 1999 18:05:13 GMT, morse at harborcom.net (Kevin Dahlhausen) wrote: >I agree with your observations on TK. I looked at wxPython and some other >GUIs. I liked the Fast Light Toolkit API the best. At least Python allows us >to use the best GUI, with 'best' being defined by people according to their own >preferences. Could you please post an URL? I think this discussion is moving toward "Which GUI is the best for Python?", since at least one reader has . If everybody throws their favorite Python GUI on the table, we can (eventually) make a feature/performance comparison chart and, hopefully, agree about which one should be The Python GUI. I don't have any strong preferences, except the wxPython GUI seems to perform well. But, I haven't evaluated others, so perhaps the right one is hiding out there somewhere :) -- Mikael From iking at killthewabbit.org Sat Jun 5 16:23:20 1999 From: iking at killthewabbit.org (Ian King) Date: Sat, 5 Jun 1999 13:23:20 -0700 Subject: Sockets and lemon curry Message-ID: No, no, I don't know where the lemon curry fits in... with a melon? I'm trying to implement an rshd server in Python. The problem seems to be with establishing the secondary socket for stderr. I'm using a Linux 2.0 box as client, and a Windows machine as server (ultimately, this is to support rmt access to the Windows box's tape drive). In experimenting, I've gotten things to work with utilities that don't require the second socket (e.g. rcp). But the moment I try to establish the secondary socket, the client says, "protocol violation" and gives up. Ideas? In more detail, here's what I'm doing (without error handling, etc.): s = socket(AF_INET, SOCK_STREAM) s.bind('', 514) # RSH well-known port s.listen(1) conn, addr = s.listen() # blocks for client request response = conn.recv(1024) # this response has the secondary port number ...do some string stuff to get the port number into integer type as 'port2' s2 = socket(AF_INET, SOCK_STREAM) s2.connect(addr[0], port2) #addr tuple is host, port for conn ...and that's where the client says, "Pining for the fjords???" and gives up. I've done network tracing and can't find anything odd going on. This seems like a simple handshake, and if I use (for instance) the Windows machine as a client against the Linux server (and do a network trace), everything works and looks great. Any ideas? TIA - Ian Ian King iking at killthewabbit.org From bernhard at alpha1.csd.uwm.edu Wed Jun 23 00:20:10 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 23 Jun 1999 04:20:10 GMT Subject: total idiot question: +=, .=, etc... References: <877lov62z1.fsf@pbl.ddns.org> Message-ID: On 22 Jun 1999 21:54:42 -0500, Preston Landers wrote: >Can someone *please* give me a good reason why Python doesn't yet have >+=, -=, and .= and other such operators? I know it's just syntactic >sugar, but damn, it is such sweet sugar! >From what I understand, the python creators consider it unnecessary syntactic sugar. In fact they want one good way of writing expressions. The lack of these operators makes the source code more readable. += just saves some space and typing time. Your editor (given it is powerful enough can easily) immitate that piece of sugar for your and make it personal syntactic honey! Here is my posted vim example: |>> For vim, the following does the trick (without the special word matching |>> caps new vim versions provide. the ":noh is for people using hlsearch in |>> vim 5.x version.) | |:map! += ^[:s/\([a-zA-Z_][a-zA-Z0-9_]*\)$/\1=\1+/^M:noh^MA | |Where ":" means go into vim Commandmode | "^[" means Esc, you have to enter it pressing Ctrl-v and then Esc | "^M" means "Return', you have to enter pressing Ctrl-v and then Return >Also, if this is in 1.5.2+, please forgive me, as I'm not up to speed >on the new versions yet. It's not in there, I guess. Bernhard -- Research Assistant, Geog Dept UM-Milwaukee, USA. (www.uwm.edu/~bernhard) Funding/Promoting Association for a Free Informational Infrastructure (ffii.org) From paul at prescod.net Tue Jun 1 10:21:15 1999 From: paul at prescod.net (Paul Prescod) Date: Tue, 1 Jun 1999 14:21:15 GMT Subject: Python 2.0 References: <11A17AA2B9EAD111BCEA00A0C9B4179301E10ED1@forest.origin.ea.com> <374F1F6D.F3338F56@prescod.net> <374F5001.1C850DC@Lugoj.Com> <374F4591.3E66FB0@prescod.net> <374FF31A.6E990179@prescod.net> <37512edf.3024969@news.demon.co.uk> <3752ddac.3812702@nntp.ix.netcom.com> Message-ID: <3753EC5B.4C70860@prescod.net> Dennis Lee Bieber wrote: > > Ever seen the Amiga variant of REXX? AREXX had a very simple > interface to compatible applications (compatible meaning that the > application creates an "AREXX message port"). In (A)REXX, a statement > line that is not recognized as part of the language itself is sent to > the current "command interpreter" -- default is the command shell, but > it can just as easily be an application (ADDRESS > ). That's all cool, but on Windows you get to choose your scripting language which, for Python users, is even cooler. Still, I take your point that AREXX was years ahead of Windows. And AREXX was ripped off of mainframe REXX which was, of course, even older. -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco "Silence," wrote Melville, "is the only Voice of God." The assertion, like its subject, cuts both ways, negating and affirming, implying both absence and presence, offering us a choice; it's a line that the Society of American Atheists could put on its letterhead and the Society of Friends could silently endorse while waiting to be moved by the spirit to speak. - Listening for Silence by Mark Slouka, Apr. 1999, Harper's From avv at quasar.ipa.nw.ru Sun Jun 20 01:58:19 1999 From: avv at quasar.ipa.nw.ru (Alexander V. Voinov) Date: Sat, 19 Jun 1999 22:58:19 -0700 Subject: Curses for MSDOS References: <376BD33B.5A6F54BB@erols.com> Message-ID: <376C82FB.4B7F4350@quasar.ipa.nw.ru> Hi, Klaus-Juergen Wolf wrote: > Swartz wrote: > > Is there anything like curses for MS-DOS? Thanx. > > I know of PC-Curses. Written in the early 80s. Maybe someone has > extended it, but in the state I had seen it had no NCurses extensions > and wouldn't work with Python. > > Probably very few people used it, because that screen access mechanism > was relatively slow on MS-DOS. I learned that the emulation of curses in SLang (ftp://space.mit.edu/pub/davis/slang/) is sometimes even better than the original curses, ncurses, etc. I may be valid also for MS-DOS. If you can build the SLang library for MS-DOS and link your curses-demanding application with it you may have solved your problems. You may want to take a look at the Python wrapper for SLang: ftp://starship.python.net/pub/crew/avv/pyslang/pyslang-0.2.0.tgz I haven't yet tried it for MS-DOS (there were no demand, especially from myself :-), but it may compile out of box. For MS-DOS with djgpp everybody is welcom to try my very very alpha wrapper around TurboVision, please take a look at the binary "distribution" (just try and let me know if that makes sense for you) ftp://starship.python.net/pub/crew/avv/tvpython Regards Alexander From MHammond at skippinet.com.au Sun Jun 27 18:04:22 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Mon, 28 Jun 1999 08:04:22 +1000 Subject: Pythonwin and Office 2000 References: <377648A7.9B9BE59F@prescod.net> Message-ID: <7l672r$5k0$1@m2.c2.telstra-mm.net.au> Paul Prescod wrote in message <377648A7.9B9BE59F at prescod.net>... >I believe that Pythonwin is not compatible with Office 2000. Here are some >symptoms: I havent tried this, although I believe it! > File "testMSOffice.py", line 46, in TestWord > if gencache.EnsureModule("{00020905-0000-0000-C000-000000000046}", >1033, 8, >0) is None: This is expected (unfortunately). Word will have a new typelibrary, and hence a new IID for the library. The "fix" will be to work out what the library ID of the new one is (by using "makepy -i") and changing TestWord.py to gracefully allow either version. However, this is a PITA in general, and a less-clunky solution would be great! >>>> a=win32com.client.Dispatch("MSWord.Application") ... >com_error: (-2147221005, 'Invalid class string', None, None) That is a strange one :-( > def AddOLEObject(self, Left=0.0, Top=0.0, Width=-1.0, Height=-1.0, >ClassName >=L'', FileName=L'', DisplayAsIcon=0, IconFileName=L'', IconIndex=0, >IconLabel=L' >', Link=0): > >Is this "L" syntax a future syntax for Unicode that Python 1.5.2 doesn't >support? Perhaps PythonWin should test for support for that syntax before >it generates the Python code? Eeeek. I have no idea where that is coming from. I havent added special Unicode features anywhere. This _is_ a strange one! I hope to install Office2000 and IE5 soon, but until then Im not sure I can do much :-( Mark. From MHammond at skippinet.com.au Sun Jun 13 18:10:31 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Mon, 14 Jun 1999 08:10:31 +1000 Subject: do anonymous pipes normally work on NT? References: <7juatc$fef$1@nnrp1.deja.com> <7juq84$df3$1@m2.c2.telstra-mm.net.au> <7k07tu$veb$1@nnrp1.deja.com> Message-ID: <7k1a5f$krj$1@m2.c2.telstra-mm.net.au> Georg Mischler wrote in message <7k07tu$veb$1 at nnrp1.deja.com>... >> Second advantage is that you deal with > "PyHANDLE" objects, >> and explicit closing is not necessary (a-la files) > >I seem to remember a post by someone (you?) who stated >that *not* closing Windows handles on could lead to serious >resource leaks. Am I confusing something here or are >not all handles created equal? Well, not all handles are created equal anyway, but the point I was making that PyHANDLE object automatically close the handle when it dies - like a file object. So the handles will be closed even if you do not explicitely close them. My comment wasnt intended to throw light on the specific problem - just point out an advantage that PyHANDLE objects have. OTOH, I am wildly guessing that using CreateFile could solve the problem - not due to the "auto-close" behaviour, but simply because they remove the indirection. I have no basis for believing it will solve the problem, just a guess! Mark. From wtanksle at dolphin.openprojects.net Wed Jun 23 16:24:59 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Wed, 23 Jun 1999 20:24:59 GMT Subject: Thanks for Python... References: <376ead64@anonymous.newsfeeds.com> <37716901.43CB604@lockstar.com> Message-ID: On 23 Jun 1999 13:06:49 PDT, Mordy Ovits wrote: >Jeff Rush wrote: >> Welcome to the Python community, John. Yes, Python is a truly >> wonderful language for cranking out quick prototypes or test jigs. >> I prototyped a complete web-based general ledger system in Python, >> figuring I'd downcode it to C for speed later, but so far I haven't needed >> to. Python is also just plain fun... Now if I could just get time to port >> it to the PalmPilot, I'd never be away from it. >Get a Windows CE Palm-sized PC if you want to take Python with you whereever you >go. Python runs stunningly well on my Casio E-100, and has nifty GUI >libraries. It's not polished by any sense of the word but it works, and the >source is a barely changed version of the standard windows Python. This makes >for easy improvement. Sure, but we've got Pilots, so that's not an open option. Fortunately, the Pilot has Quartus Forth available for it -- it's not Python, but honestly, Forth fits the limitations of the device better. I used Quartus on my Crypto exam to solve a modular equation after I forgot how to solve modular equations (I had it use brute force). I'd still like to have Python, but dang, Quartus is good at what it does. Python and Forth -- for two different reasons, pretty much my favorite languages. >o Mordy Ovits >o Cryptographic Engineer >o LockStar Inc. >#!/usr/local/bin/python >from sys import*;from string import*;a=argv;[s,p,q]=filter(lambda x:x[:1]!= >'-',a);d='-d'in a;e,n=atol(p,16),atol(q,16);l=(len(q)+1)/2;o,inb=l-d,l-1+d >while s:s=stdin.read(inb);s and map(stdout.write,map(lambda i,b=pow(reduce( >lambda x,y:(x<<8L)+y,map(ord,s)),e,n):chr(b>>8*i&255),range(o-1,-1,-1))) You know, the first time I saw this it was in ESR's .sig, and I tried to remember how long the Perl version had been. A few minutes of searching revealed that it was three lines long -- but also revealed that it was using bc rather than Perl to do most of the work! I spent about half an hour searching for the real Perl version, only to find that it was five lines long. The Python for this .sig is shorter than the Perl! Cool, eh? -- -William "Billy" Tanksley Utinam logica falsa tuam philosophiam totam suffodiant! :-: May faulty logic undermine your entire philosophy! From gvinther at atex.com Mon Jun 7 16:44:37 1999 From: gvinther at atex.com (Gordon Vinther) Date: Mon, 7 Jun 1999 16:44:37 -0400 Subject: problems using Tkinter References: <928350546.726.80@news.remarQ.com> <02fc01beadf0$b3c3ea30$f29b12c2@pythonware.com> Message-ID: <928788254.441.84@news.remarQ.com> Fredrik Lundh wrote in message news:02fc01beadf0$b3c3ea30$f29b12c2 at pythonware.com... > Gordon Vinther wrote: > > I get the following error whenever I attempt to use Tk > > > > Os AIX4.2.1 > > Python 1.5.2 > > Tk/TCL 8.0.1 > > > > from Tkinter import * .............this works > > root=Tk() ........... this errors with the following message > > > > File "/usr/local/lib/python1.5/lib-tk/Tkinter.py", line 886, in __init__ > > self.tk = _tkinter.create(screenName, baseName, className) > > > > TclError: invalid command name "tcl_findLibrary" > > looks like tkinter is picking up the wrong Tcl/Tk > library files. try setting the TCL_LIBRARY and > TK_LIBRARY environment variables. > > > I tried the environment variables with no help. Doesn't this look like a Tcl/tk problem? Has anyone run Python with the new version of Tcl/Tk8.nn?? This is completely new code. Mayby Tkinter doesn't run with it. It seems Tcl is complaining about a command it doesn't understand....!!!!!! and not that it is not being communicated with. From jeremy at cnri.reston.va.us Wed Jun 9 11:58:37 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Wed, 9 Jun 1999 11:58:37 -0400 (EDT) Subject: "Programming Python" still worthwhile? In-Reply-To: <1283218560-70098357@hypernet.com> References: <7jki66$qam$1@news.gstis.net> <1283218560-70098357@hypernet.com> Message-ID: <14174.36177.272502.237392@bitdiddle.cnri.reston.va.us> >>>>> "RR" == Rick Robino writes: RR> wondering if anyone here could give me some advice as to whether RR> or not "Programming Python" is useful, if the current edition is RR> still current, if I should wait for the "Learning Python", or if RR> I should use some other resources. >>>>> "GMcM" == Gordon McMillan writes: GMcM> Learning Python is on the shelves. Haven't read it. Nobody's GMcM> flamed it, and that's a _very_ good sign. I bought a copy of Learning Python in a local technical bookstore that doesn't have a very good selection, so it ought to be easy to find. I haven't read the book carefully, but I did read through the chapter on classes (Chap. 6). I thought it was an excellent introduction to OOP and Python. It is much more thorough than the Python tutorial and other free documentation. So I don't think you'll go wrong with Learning Python. Jeremy From akuchlin at mems-exchange.org Tue Jun 22 13:47:55 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: Tue, 22 Jun 1999 13:47:55 -0400 (EDT) Subject: renegotiating socket connections In-Reply-To: References: Message-ID: <14191.52299.153087.487734@amarok.cnri.reston.va.us> Nathan Clegg writes: >I'm writing a server application in python. I understand that most >servers fork off a process for every incoming connection and then >renegotiate on a different port to free up the well-known server port. I Where does this bit of incorrect conventional wisdom come from? netstat on my machine is currently reporting: amarok.80 amarok.40531 32768 0 32768 0 ESTABLISHED amarok.80 amarok.40532 32768 0 32768 0 TIME_WAIT amarok.80 amarok.40534 32768 0 32768 0 ESTABLISHED amarok.80 amarok.40535 32768 0 32768 0 ESTABLISHED Several connections to port 80, and everything's fine. Now, you might have an architecture where a single gatekeeper process hands things off to another process, and therefore open a new socket to this second process, but for a simple forking server, I don't see why this port renegotiation would be required. (Even in this case, you could use file descriptor passing to avoid the second open, though I don't know if you can pass file descriptors from Python code easily.) -- A.M. Kuchling http://starship.python.net/crew/amk/ My nose shall never be touched while heaven give me strength. -- Sterne, _Tristram Shandy_ From arcege at shore.net Wed Jun 2 08:15:43 1999 From: arcege at shore.net (Michael P. Reilly) Date: Wed, 02 Jun 1999 12:15:43 GMT Subject: A tkinter kick-off References: <37544a32.0@news1.mcmail.com> Message-ID: Mark Butterworth wrote: : I've been using python for a few months now (I've actually managed to : persuade my company that freeware is a viable tool) and I've just started : looking at tkinter. However, my first little project doesn't require an : interactive window or dialog box. What I do require is a window which : displays the result's of my background processing. The processing will : simply be the compression and network transfer of some files. I'm not : looking for a full solution however, I just need a help starting off. I can : create a window containing a listbox alright, I just need to know how to : process in the background and display results within the listbox (maybe a : cancel button would also be useful). Most windowing applications over the last ten to fifteen years have been based on the event loop, and Tkinter is not exception. But (of course there is a but), Tkinter also has the nice feature of including various other control mechanisms. In this case I think you would want to be using the update_idletasks() or update() methods. root = Tk() done = 0 # function to turn off computations def canceler(): global done done = 1 # set up your widgets using root cancel = Button(root, text="Cancel", command=canceler) cancel.pack(side=BOTTOM) root.update_idletasks() while not done: # perform your computations, including updating the widgets root.update_idletasks() You might also want to look into the after_idle() method. The choice to use after_idle or update_idletasks should be based on which is going to take more time (and which is going to block for longer), the computations/networking or the windowing. You might also want to look into threads (just made sure that Tkinter is controlled in the main thread). FYI, Curses uses this "idletasks" method (called refresh). -Arcege From klassa at aur.alcatel.com Wed Jun 9 15:41:28 1999 From: klassa at aur.alcatel.com (John Klassa) Date: 9 Jun 1999 19:41:28 GMT Subject: fork() References: <000a01beb21f$a051d380$2fa22299@tim> <7jmbe1$r22$2@cronkite.cc.uga.edu> Message-ID: <7jmg18$1h4$1@aurwww.aur.alcatel.com> On 9 Jun 1999 18:22:57 GMT, Graham Matthews wrote: > observable reality. Where are the hoary theoretical arguments? Or > is this just more of the same old bluff and bluster arguing. Uh oh... This is starting to look like comp.lang.perl.misc. :-) -- John Klassa / Alcatel USA / Raleigh, NC, USA From jam at newimage.com Wed Jun 2 06:17:12 1999 From: jam at newimage.com (jam) Date: Wed, 2 Jun 1999 06:17:12 -0400 Subject: Python & IRC? In-Reply-To: ; from Benjamin Schollnick on Mon, May 31, 1999 at 08:21:17PM +0000 References: Message-ID: <19990602061712.F17948@toast.internal> On Mon, May 31, 1999 at 08:21:17PM +0000, Benjamin Schollnick wrote: > > Folks, > > Has anyone done anything in regards to making a IRC > daemon/server in Python? > > I'm thinking about sitting down and doing some socket > work with Python, and I wouldn't want to reproduce the wheel again... > > Benjamin yes. I have such code, and I'll be willing to send it to you presuming youare willing to honor an LGPL license for it.. I will also be willing to answer any questions or concerns you may have regarding how IRC works.. I've already been through the process, and it can get a bit hairy.. actually, if you look through dejanews, you may be able to find other posts along these lines.. what would be *really* cool is if we pooled resouces and wrote an irc daemon in python to compliment the irc client(s). let me know how you'd like to proceed. regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From andy at robanal.demon.co.uk Mon Jun 21 14:03:53 1999 From: andy at robanal.demon.co.uk (Andy Robinson) Date: Mon, 21 Jun 1999 18:03:53 GMT Subject: IPwP books available, 99cents References: <376a479b.131911984@news.texoma.net> Message-ID: <376e7e32.727764@news.demon.co.uk> jhouchin at texoma.net (Jimmie Houchin) wrote: >Hello, > >I was visiting a bookstore in Plano, TX yesterday and saw two new >copies of Internet Programming with Python on their shelves for $.99, >yes 99 cents. > Well, here in the U.K. they are appearing back on the shelves in the good bookstores after a long absence, and still at full price. I really hope your bookstore has misread Python's direction and not mine! - Andy Robinson From akuchlin at mems-exchange.org Thu Jun 3 17:03:50 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: Thu, 3 Jun 1999 17:03:50 -0400 (EDT) Subject: need help with decompress In-Reply-To: <66A53.34$a43.449@news.megsinet.net> References: <66A53.34$a43.449@news.megsinet.net> Message-ID: <14166.60854.252981.324857@amarok.cnri.reston.va.us> Philip C. writes: >using the zlib module o found out how to compress springs but I having >trouble with decompressing them. Decompressing is just as simple as compressing: amarok akuchlin>python Python 1.5.2 (#80, May 25 1999, 18:06:07) [GCC 2.8.1] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam i>>> import zlib >>> c = zlib.compress("""So, if this were indeed my Final Hour, ... """) >>> c 'x\234MQKn\3350\014\334\347\024\263\353\306\3601\212\006...' >>> print zlib.decompress(c) So, if this were indeed my Final Hour, these would be my words to you. I would not claim to pass on any secret of life, for there is none, or any wisdom except the passionate plea of caring ... Try to feel, in your heart's core, the reality of others. This is the most painful thing in the world, probably, and the most necessary. In times of personal adversity, know that you are not alone. Know that although in the eternal scheme of things you are small, you are also unique and irreplaceable, as are all of your fellow humans everywhere in the world. Know that your commitment is above all to life itself. >>> >is there any way to scramble string sort of encrypt them Python includes the "rotor" module, which does some simple but not necessarily secure encryption. mxCrypto (http://starship.python.net/crew/lemburg/mxCrypto.html) contains more industrial-strength encryption for Python. -- A.M. Kuchling http://starship.python.net/crew/amk/ From robin at alldunn.com Tue Jun 29 03:41:34 1999 From: robin at alldunn.com (Robin Dunn) Date: Tue, 29 Jun 1999 00:41:34 -0700 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> Message-ID: <1N_d3.30$oY.3604744@news.randori.com> Jeffrey Chang wrote in message ... > >Tkinter is very good for that type of thing. All I needed to do was >create a Canvas and then for each node, create an Oval with a callback to >a function that handles node clicks. Tk keeps track of the coordinates of >each Item so that I don't have to. Also, whenever I wanted to move the >tree, all I had to do was: >for widget in self._canvas.find_all(): > self._canvas.move(widget, xoff, yoff) > This will shortly be very easy to do with wxPython as well. If all goes well the next release will include the wxOGL library (Object Graphics Library) which handles drawing various shapes and such on a canvas, including event notification for those shapes, dragging, etc. -- Robin Dunn robin at AllDunn.com http://AllDunn.com/robin/ http://AllDunn.com/wxPython/ Check it out! Try http://AllDunn.com/laughworks/ for a good laugh. From cjw at connection.com Wed Jun 30 15:56:16 1999 From: cjw at connection.com (Colin J. Williams) Date: Wed, 30 Jun 1999 15:56:16 -0400 Subject: A Python problem? Message-ID: <377A765F.90367AC5@connection.com> This script below illustrates what appears to be a problem with the identification of a module in a package. The example is borrowed from the linbot material. Colin W. ''' A Python problem? . ''' def main(): import sys print 'Start:',dir() s0= sys.modules import plugins.rptlib s1= sys.modules if s0 == s1: print 'sys.modules is unchanged' print 'After attempt to import plugins.rptlib:', dir() try: print dir(plugins.rptlib) except AttributeError: import sys print sys.exc_info() from plugins.rptlib import * print 'rptlib names now available:', dir() main() ''' ------------------------ Resulting Display ---------------------------- >>> Start: ['sys'] sys.modules is unchanged After attempt to import plugins.rptlib: ['plugins', 's0', 's1', 'sys'] (, , ) rptlib names now available: ['Link', 'add_problem', 'check_and_warn', 'config', 'debugio', 'doBotMain', 'doTopMain', 'get_title', 'linbot', 'linkList', 'main_index', 'make_link', 'nav_bar', 'open_file', 'opener', 'os', 'plugins', 'problem_db', 'proxies', 'read_registry', 's0', 's1', 'sort_by_age', 'sort_by_author', 'sort_by_rev_age', 'sort_by_size', 'string', 'stylesheet', 'sys', 'urllib', 'version'] ''' From tim_one at email.msn.com Tue Jun 15 11:37:43 1999 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 15 Jun 1999 11:37:43 -0400 Subject: OO (was: Why is tcl broken?) In-Reply-To: <37660FEC.D4F3371B@iname.com> Message-ID: <000801beb745$02768220$979e2299@tim> [William Tanksley] > (I like all the languages I know, except Fortran. I even like C++, > although I wish they could break backwards compatibility.) [Fernando Mato Mira] > Quiz: What do Scheme, Common Lisp, HPF and Java have in common? Guy Steele's loving ministrations -- but even he gave up on Scheme . From jam at newimage.com Mon Jun 28 08:46:36 1999 From: jam at newimage.com (jam) Date: Mon, 28 Jun 1999 08:46:36 -0400 Subject: Extracting Text file contents using Python In-Reply-To: <37782f9a.0@news.smartnet.com.sg>; from john on Mon, Jun 28, 1999 at 07:37:50PM +0800 References: <37782f9a.0@news.smartnet.com.sg> Message-ID: <19990628084636.B16195@toast.internal> On Mon, Jun 28, 1999 at 07:37:50PM +0800, john wrote: > > Hi, > > I am trying to extract the following text file using python and the program > & text file are as shown below. > > But unfortunately I am unable to get every separate data displayed except > for the first data and after the separation line which is > "====================" the next data is not getting picked up by the > program. > Could anyone kindly let me know what could be wrong with the program. > > Example Text File - But will be similar > ---------------------------------------------------- [..snipped..] > > The python program is as follows: > [..snipped..] I didn't have any trouble with this code on my linux machine. the one thing that might be confusing the issue is that all of your records are identical.. one thing I did while testing your code was to change the 'rating' field to a unique number (only 8 records, so I changed each to have a number in that sequence).. then you can see the data changing, and it's much clearer whether or not it's working. give that a shot, and see what happens. regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From William.Tanksley at p98.f112.n480.z2.fidonet.org Tue Jun 29 19:15:57 1999 From: William.Tanksley at p98.f112.n480.z2.fidonet.org (William Tanksley) Date: Wed, 30 Jun 1999 00:15:57 +0100 Subject: Why exceptions shouldn't be used for flow control [Re: YAS to the Message-ID: <0000159d@bossar.com.pl> From: wtanksle at dolphin.openprojects.net (William Tanksley) On Mon, 28 Jun 1999 11:17:01 +1200, Greg Ewing wrote: >William Tanksley wrote: >> while not f.eof(): >> line = f.readline() >> # ... >I'd love to be able to write reading loops that way. >Unfortunately, it's a fact of life that some of the >things read() has to deal with are unable to detect >eof without trying to read something. I think the >existing definition of read() and friends is the best >that can be done in those circumstances. I'd guess that you're talking about things like text file parsing and such. I would use readline there, but that's fine. Yes, unstructured data is more difficult to handle. >> It's been a while since I've used read, so I >> don't recall what it actually returns >It returns an empty string if it can't read more >than 0 characters, same as readline(). Ah. There's a justification for that, as you observed. I don't like the fact that readline is stuck doing the same thing (record delimiters are not really part of the record). >> in a function designed to get n!=0 >> more characters, an EOF really is an error. Unfortunately for me, that's >> not the definition of 'read', and never will be. >Perhaps there should be a 2-parameter version of read: > read(min, max) >which would raise an exception if it couldn't read at >least min characters. Setting min=0 would give the >current behaviour, and setting min=max would allow >reading a fixed-length record without having to check >for errors. Then everyone would be happy! A facinating solution. Well, since I don't use read, I probably wouldn't use it, and I'm the only person whining. Therefore, it's probably not worth implementing (even though it is a cool solution). >Greg -- -William "Billy" Tanksley From shallib at netscape.com Thu Jun 10 00:22:32 1999 From: shallib at netscape.com (Steve Halliburton) Date: Wed, 09 Jun 1999 21:22:32 -0700 Subject: How do I match the last occurence of a character? Message-ID: <375F3D88.A3D1B408@netscape.com> Spam detection software, running on the system "albatross.python.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: I haven't used it on NT, but I know on unix it handles everything gracefully: >>> import os >>> t1 = 'http://tor.dhs.org/~bwinton/index.html' >>> t2 = 'home/bwinton/' >>> os.path.split(t1) ('http://tor.dhs.org/~bwinton', 'index.html') >>> os.path.split(t2) ('home/bwinton', '') [...] Content analysis details: (5.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.0 FH_DATE_IS_19XX The date is not 19xx. 0.5 RCVD_IN_PBL RBL: Received via a relay in Spamhaus PBL [205.217.237.46 listed in zen.spamhaus.org] 1.1 RCVD_IN_SORBS_WEB RBL: SORBS: sender is a abuseable web server [205.217.237.54 listed in dnsbl.sorbs.net] 0.1 RDNS_DYNAMIC Delivered to trusted network by host with dynamic-looking rDNS 2.2 FAKE_REPLY_C FAKE_REPLY_C -------------- next part -------------- An embedded message was scrubbed... From: Steve Halliburton Subject: Re: How do I match the last occurence of a character? Date: Wed, 09 Jun 1999 21:22:32 -0700 Size: 2573 URL: From steffen at biomedcomp.com Fri Jun 11 17:39:10 1999 From: steffen at biomedcomp.com (David Steffen) Date: Fri, 11 Jun 1999 16:39:10 -0500 Subject: Can't make python1.5.2 on rhLinux5.1 Message-ID: <37618200.91CC7370@biomedcomp.com> Howdy! I am trying to install Python 1.5.2 on a Red Hat Linux 5.1 / 386 (actually pentium) system and have run into a problem I can't find mention of in the README or the faq. I am a regular reader of this group, but don't read every single message, so if I have missed this one, my apologies. The problem occurs during make: cd Modules ; make OPT="-g -O2" VERSION="1.5" \ prefix="/usr/local" exec_prefix="/usr/local" all make[1]: Entering directory `/root/Python-1.5.2/Modules' gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c ./regexmodule.c <10 modules compiled OK> gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c ./timemodule.c ./timemodule.c: In function `time_strptime': ./timemodule.c:429: warning: assignment makes pointer from integer without a cast <5 modules compile OK> gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c ./socketmodule.c ./socketmodule.c: In function `initsocket': ./socketmodule.c:2212: `uint32_t' undeclared (first use this function) ./socketmodule.c:2212: (Each undeclared identifier is reported only once ./socketmodule.c:2212: for each function it appears in.) ./socketmodule.c:2212: parse error before `0xe0000000U' ./socketmodule.c:2217: parse error before `0xe0000001U' ./socketmodule.c:2222: parse error before `0xe00000ffU' make[1]: *** [socketmodule.o] Error 1 make[1]: Leaving directory `/root/Python-1.5.2/Modules' make: *** [Modules] Error 2 My Linux is mostly out of the box, though we have installed this and that on it; Perl5.005, Gimp, etc. The Python install is plain vanilla - I didn't hand edit anything and ran ./configure without any command line switches. In terms of the issues I have found in the README: 1) % rpm -qa | grep ^linuxthread 2) glibc I have installed is version 2.0.7 3) crypt module commented out as per default 4) I tried: make clean ./configure make ...with the same results Any suggestions? THANKS! -David Steffen- From landrum at foreman.ac.rwth-aachen.de Sat Jun 19 12:21:02 1999 From: landrum at foreman.ac.rwth-aachen.de (Gregory A. Landrum) Date: 19 Jun 1999 18:21:02 +0200 Subject: A Newbie Learns (part II) Message-ID: Continuing revelations of a learner... part II This time with a question for the experts --------------------------------- Matrix Multiplies The Matrix class (part of the NumPy distribution) provides a convenient way of dealing with matrices, so you can do stuff like: from Matrix import * M1 = Matrix([[1.,2.,3.,4.],[1.,2.,3.,4.],[1.,2.,3.,4.],[1.,2.,3.,4.]]) M2 = Matrix([[.1,.2,.3,.4],[.1,.2,.3,.4],[.1,.2,.3,.4],[.1,.2,.3,.4]]) M3 = M1*M2 This is considerably more convenient than using the array type defined in the Numeric module: from Numeric import * M1 = array([[1.,2.,3.,4.],[1.,2.,3.,4.],[1.,2.,3.,4.],[1.,2.,3.,4.]]) M2 = array([[.1,.2,.3,.4],[.1,.2,.3,.4],[.1,.2,.3,.4],[.1,.2,.3,.4]]) M3 = matrixmultiply(M1,M2) Unfortunately, it's also a ton slower. This is true because the Matrix class actually calls matrixmultiply itself. So the program ends up doing all of the work of matrixmultiply plus a bunch of overhead to convert the matrices to arrays. Some quick profiling indicates that using arrays instead of matrices takes approximately half as long when doing 10000 4x4 matrix multiplies. So the lesson I learned is: Skip the convenience of using the Matrix class if speed is at all important. ------------------- After these explorations and poking around in the Numeric source, I am left with a question. In Numeric.py, the following appears: #This is obsolete, don't use in new code matrixmultiply = dot If matrixmultiply is obsolete, what exactly are we supposed to use for doing matrix multiplies with 2D arrays? Sure, I can just call dot myself, but that leaves the code less readable. -greg --------------------- Dr. Greg Landrum (landrumSPAM at foreman.ac.rwth-aachen.de) Institute of Inorganic Chemistry Aachen University of Technology From greg.ewing at compaq.com Sun Jun 27 18:48:28 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Mon, 28 Jun 1999 10:48:28 +1200 Subject: total idiot question: +=, .=, etc... References: <877lov62z1.fsf@pbl.ddns.org> <7ks38p$l4m$1@brick.cswv.com> Message-ID: <3776AA3C.218936D8@compaq.com> Michael Hudson wrote: > > class Derived(base.Base): > def __init__(self,x,y,z,**kw): > apply(base.Base.__init__,(self,x,y),kw) > print z > > which I think is one of the ugliest things I've ever seen in Python > that I couldn't think of a prettier way round. Ideas, anyone? Yes! With the calling syntax extension that I have proposed before, that would be written Base.__init__(self, x, y, **kw) Still requires the self argument, but I think you'll agree it's a lot better than having to use apply! I'd also like a way of getting rid of the self argument in that situation as well, but this seems to be quite a difficult problem to solve within Python's existing execution model. I haven't thought of a good solution yet. Greg From cwebster at math.tamu.edu Fri Jun 25 20:21:25 1999 From: cwebster at math.tamu.edu (Corran Webster) Date: 26 Jun 1999 00:21:25 GMT Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <59EAFD6B662F0706.86BFF3E906CBF8DE.784D2A219F85BC21@lp.airnews.net> <99062523473500.00769@Vegus> Message-ID: <7l16e5$q4j$1@news.tamu.edu> In article <99062523473500.00769 at Vegus>, John Travers wrote: >Has anybody tried the PyKDE/Qt package, (you don't have to have KDE), it is >absoloutly fantastic, quick, easy, powerful, far far better than Tkinter. >I love it! This is missing the point - although PyKDE/Qt might be a very nice GUI, it's not cross-platform in the same way as Tcl/Tk. The same goes for Fltk, gtk or what have you. It sounds like wxWindows might be getting near the same level of cross-platform compatibility - and it certainly seems to be one of the groups' objectives - it's not there yet. The point of having a standard GUI for python is that it's _standard_. ie. that it's likely to work no matter what your platform. At present, Tk seems to be the only mature package with that sort of ubiquity. And for all it's shortcomings, Tkinter does at least get you your basic widgets up on the screen. The other possible approach, of course, is to have a standard GUI API for python which can have your favourite GUI slipped in under the covers. I believe that people have looked into that sort of approach, but I haven't looked recently at how things have developed. However because this has to be a lowest common denominator approach, you are sure to lose your favourite bells and whistles from your favourite GUI. In the meantime, by all means, develop using your favourite GUI, but the time is not right, it seems, for replacing Tk as the standard. Corran From fdrake at cnri.reston.va.us Tue Jun 15 11:02:18 1999 From: fdrake at cnri.reston.va.us (Fred L. Drake) Date: Tue, 15 Jun 1999 15:02:18 GMT Subject: Newbie: easy filecopy? In-Reply-To: <376531D3.7E42AC42@phoenix-edv.netzservice.de> References: <376531D3.7E42AC42@phoenix-edv.netzservice.de> Message-ID: <14182.27386.991483.999566@weyr.cnri.reston.va.us> Holger Jannsen writes: > I couldn't believe it. I think there must be an easy copy-function > in python (I only want to copy files under ext2- or FAT-FileSystems). > Call me "4 blind mice"-Joey, but I couldn't find it. Yes. As someone has pointed out, the shutil module contains the beast you're looking for. The Index of the Library Reference manual is often pretty helpful about things like this (not the Module Index, the general Index). Just click on the "i" icon at the top of any page of the library reference if you're using the HTML version. The index may be long, but I'm told it isn't too shabby. (If anyone thinks additional entries are needed, send a note telling what they are and where they should link to in the manual to python-docs at python.org; this kind of suggestion is usually well received by the damn fool^H^H^H^H^H^H^H^H^H^H poor bloke who receives mail at that address.) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From gerrit.holl at pobox.com Mon Jun 28 04:59:21 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Mon, 28 Jun 1999 08:59:21 GMT Subject: RuntimeError? In-Reply-To: <000401bec10d$b5bc3a60$e19e2299@tim>; from Tim Peters on Sun, Jun 27, 1999 at 10:27:04PM -0400 References: <19990627112432.A29097@optiplex.palga.uucp> <000401bec10d$b5bc3a60$e19e2299@tim> Message-ID: <19990628105921.A26266@optiplex.palga.uucp> On Sun, Jun 27, 1999 at 10:27:04PM -0400, Tim Peters wrote: > From: "Tim Peters" > To: "Gerrit Holl" , > Subject: RE: RuntimeError? > Date: Sun, 27 Jun 1999 22:27:04 -0400 > > [Gerrit Holl] > > can someone please give me an example when a RuntimeError is raised? > > > > I don't understand: if none of the others are raised. > > Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import sys > >>> del sys.stdout > >>> print "hi" > Traceback (innermost last): > File "", line 1, in ? > RuntimeError: lost sys.stdout > >>> > > Honestly, I had never seen a RuntimeError before! I found this one by > digging thru the source code to see when it gets raised. There's really no > pattern to it, and the RuntimeError docstring in Lib/exceptions.py > ("Unspecified run-time error.") is as accurate as anything that says nothing > can be . It generally seems to mean something bad and unexpected > happened, but not bad enough to shut down the interpreter (things *that* bad > raise SystemError). > Ah, I understand. But what kind of things are bad enough to raise SystemError? core dump? groeten, Gerrit. -- The Dutch Linuxgames homepage: http://linuxgames.nl.linux.org Personal homepage: http://www.nl.linux.org/~gerrit/ Discoverb is a python program (in several languages) which tests the words you learned by asking it. Homepage: http://www.nl.linux.org/~gerrit/discoverb/ From fandino at usa.net Mon Jun 7 12:06:16 1999 From: fandino at usa.net (Salvador =?iso-8859-1?Q?Fandi=F1o?=) Date: Mon, 07 Jun 1999 18:06:16 +0200 Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <87pv3iq6ss.fsf@ev.netlab.co.jp> <3752C76D.604CD474@prescod.net> <87n1ykr0z9.fsf@ev.netlab.co.jp> <375372F6.A874554@prescod.net> <7j34l3$hbj$1@nnrp1.deja.com> <7j66b7$il5$2@cronkite.cc.uga.edu> <3756C693.2C910B29@usa.net> <7j6jnl$58f$3@cronkite.cc.uga.edu> <3757A820.CE3F195F@usa.net> <7j8obc$55v$2@cronkite.cc.uga.edu> Message-ID: <375BEDF8.DD14C4E6@usa.net> Graham Matthews wrote: > The proposal I gave for adding mark sweep collection on top of reference > counts will delete non circularly referred objects in precisely the order > they are now deleted in current Python. That order doesn't appear to > random for you. You are right. > so I don't understand the above comment? As for circularly > referred data it will be deleted in the order determined by the collector, > but that's better than current Python which doesn't delete it at all. If I can't remove objects in the right order I would have to delete it explicitly the same way I have to do it now with ref counting. Lots of current __del__ methods will not perform properly and will raise exceptions if called after deleting related objects. You could use __del__ methods only for trivial task like freeing resources. It's an incomplete solution like reference counting is. - Salva. From peter.sommerfeld at gmx.de Tue Jun 15 16:29:21 1999 From: peter.sommerfeld at gmx.de (Peter Sommerfeld) Date: Tue, 15 Jun 1999 22:29:21 +0200 Subject: [Python-de] Python-Tutorium-1.5.2-de quasi fertig In-Reply-To: <3766745C.B9A88BB8@darwin.in-berlin.de> References: <37665567.6FD97DC0@darwin.in-berlin.de> Message-ID: Dino Gherman wrote: >Voila (uhmm, weiss jemand was "Odds and Ends" heissen soll, >"Vor- und Nachteile" vielleicht? Tips und Trix (Bin mir aber auch nicht ganz sicher). Sinngem?ss hei?t das glaube ich Ecken und Kanten, also dass was ?brigbleibt. Ich w?rde da einfach wortsch?pferisch t?tig werden ;) -- Peter PS: Wenn's um so etwas wie HTML Layout o.? geht kann ich gerne was tun. Kann allerdings kein TeX lesen (Mac). From thstr at serop.abb.se Thu Jun 10 01:37:56 1999 From: thstr at serop.abb.se (Thomas S. Strinnhed) Date: Thu, 10 Jun 1999 07:37:56 +0200 Subject: Python/C API and setattr References: <375E5257.8579541B@serop.abb.se> <50v73.2457$nn.746290@news.shore.net> Message-ID: <375F4F34.7EF9D260@serop.abb.se> Hi Michael P. Reilly wrote: > [quoted my message] > Thomas, the prototype for functions in the setattr slot of a Python type > is: > typedef int (*setattrfunc)(PyObject *, char *, PyObject *); > > Your counter_setattr function should return an int, true (0) for > success, false (-1) for error. I believe the source code and Mark's > book (somewhere in Ch 15? but I don't have the book with me) are about > the only places this is documented, and it is very obscure. > > "This looks like a job for Documentation Man!" > > -Arcege Thanks everyone, I finally managed to get it all to work. Embarrassing enough, the answer was in the Programming Python-book all the time (in ch.14 at p.561), but as said below: "it is very obscure". Actually we were all almost right, the prototype in the book is static int mytype_setattr(mytype *x, char *name, PyObject *value); so the problem was me trying to return nothing at all, None, the int value assigned and so on. I guess this answers a question from an earlier thread: "Programming Python" still worthwhile? with a big: "Yes, very much so!" (as goes for c.l.py :-) If anyone is interrested I've pasted the code to my function as it turned out below. Many Thanks -- Thomas S. Strinnhed. thstr at serop.abb.se static int counter_setattr(counterobject *self, char *name, PyObject *v) { if(strcmp(name, "value") == 0) { self->value = (int)PyInt_AsLong(v); return 0; } return -1; } From carlos.velasquez at ssmb.com Fri Jun 25 16:41:59 1999 From: carlos.velasquez at ssmb.com (Velasquez, Carlos) Date: Fri, 25 Jun 1999 20:41:59 GMT Subject: Please add me to the list Message-ID: Please add carlos.velasquez at smb.com to the list ______________________________________________________________________ C.F. Velasquez Asst. Vice President Global Database and Technology Division Salomon Smith Barney, Inc. From Gary.D..Duzan at p98.f112.n480.z2.fidonet.org Tue Jun 29 15:39:54 1999 From: Gary.D..Duzan at p98.f112.n480.z2.fidonet.org (Gary D. Duzan) Date: Tue, 29 Jun 1999 20:39:54 +0100 Subject: ANN: Stackless Python 0.2 Message-ID: <0000158d@bossar.com.pl> From: "Gary D. Duzan" In Message <37791B4D.43ADC401 at appliedbiometrics.com> , Christian Tismer wrote: =>Gary Duzan wrote: =>> =>> Toby J Sargeant wrote: =>> > =>... =>> This appears to be the conventional wisdom. The optimization class I =>> took used an ML-like language, and the first thing we did was to move =>> heap frames, which was the default, to the stack (i.e. closure =>> optimization.) => =>Loosing much of flexibility by doing that, btw. True. For example, (if I remember correctly; it has been a while) tail call optimization is defeated. In this particular case, however, we didn't break the language semantics (which didn't guarantee constant memory tail recursion) because we only did stack conversion after checking that it wouldn't break anything. Otherwise, the closure is left on the heap. I see that I wasn't clear about that in my original post; sorry 'bout that. =>> It might be less of an issue in an interpreted language if it already has =>> heap =>> allocation (or other sorts of) overhead to deal with when making calls. =>> There may be other allocation tricks which can be used, as well. =>> > It seems that this should affect Stackless Python equally as much. Does a nyone =>> > have anything to add on the subject? I would imagine that frames could be =>> > allocated and managed in chunks to alleviate a lot of the memory manageme nt =>> > load... =>> =>> I would think that as well (at least at first.) Maybe pools of different =>> sizes of frame to limit the space overhead. => =>Maybe you should really look into the sources. =>You are discussing things which are not Python =>related, since this simply does not apply. Freely conceeded. =>The Python "stacks" are so tiny that you can forget about them. =>Allocations always never occour, unless your program runs =>astray in recursion. => =>The cost of a call comes from the slightly complicated =>function setup which is done all the time. Frames belong =>to the fastest available Python objects already, =>like, say dictionaries. I thought that might be the case, which is the point I was making in my earlier paragraph. I was just briefly pondering possibilities for reducing frame memory management time, if it were necessary. Stackless Python certainly seems to me to be a Good Thing. Gary Duzan GTE Laboratories From bwarsaw at cnri.reston.va.us Mon Jun 7 22:51:13 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Mon, 7 Jun 1999 22:51:13 -0400 (EDT) Subject: waste of resources ? References: <375C0F91.1C73E4E3@icrf.icnet.uk> <375C16A9.5ADC4990@icrf.icnet.uk> <375C2003.B01BEC3@arlut.utexas.edu> <87yahvzqz3.fsf@pc-hrvoje.srce.hr> Message-ID: <14172.34081.978798.911000@anthem.cnri.reston.va.us> >>>>> "HN" == Hrvoje Niksic writes: | except (IOError, os.error), detail: Or you could just catch EnvironmentError. :) -Barry From jmrober1 at ingr.com Wed Jun 2 13:12:34 1999 From: jmrober1 at ingr.com (Joseph Robertson) Date: Wed, 02 Jun 1999 12:12:34 -0500 Subject: [tkinter] two questions regarding Canvas References: <3752a555@nntp.server.uni-frankfurt.de> Message-ID: <37556602.415AFA46@ingr.com> Sure does, heres some relevant clips. Sorry I couldn't send the whole thing but its too big. I have a class that creates the canvas, then I set the binding: def __init__(self) ... self.canvas.bind('', self.CellClick) ... Heres the working method: def CellClick(self, event): self.canvas.delete('rect') cellbbox = self.canvas.bbox('current') self.canvas.create_rectangle(cellbbox, outline='blue', tags='rect') Now I don't have it editable yet, I am using this, item = self.canvas.create_text(xpos, ypos, text=field, font=self.f) in a loop to put data onto the canvas. I'm sure that creating a hidden Entry and the moving it and making it visible would work fine, or don't move it and make a 'status line' type of data editing, like Lotus did. Good Luck, Joe mlauer at amalia-atm.rz.uni-frankfurt.de wrote: > Howdy, though I'm gaining knowledge through > browsing through all the available documentation > (that is, the tkinter life-preserver, tkinter.py > and the tk/tcl documentation) some things > remain misterious... > > For instance: > > a) Does the tk Canvas support "inplace" editing of > text items or what are the functions Canvas.icursor > and Canvas.focus for ? If so, how ? For instance, > binding the to a text item function, > which sets icursor and focus doesn't work for me > (yes, the canvas has the current focus) > > b) Does the Canvas support a visible selection > of items (such as a boundaring rectangle or so) > on its own or have I to do this via binding > and ? > > Have a nice day! > > -- > Regards & Gruesse from Mickey @ http://www.Vanille.de > --------------------------------------------------------- > How could anyone know me - when I don't even know myself ? From ian at cfmu.eurocontrol.be Thu Jun 10 07:49:02 1999 From: ian at cfmu.eurocontrol.be (Ian Wild) Date: Thu, 10 Jun 1999 13:49:02 +0200 Subject: Why is tcl broken? References: <375F82C7.CF0F0477@iname.com> Message-ID: <375FA62E.CCEF5079@cfmu.eurocontrol.be> Fernando Mato Mira wrote: > I'm trying to collect a list of all the _current_ issues making tcl > a bad language choice. I'd like concrete examples, Without knowing what you're choosing it FOR, how can anyone legitimately say it's a bad choice? For some problem domains it might well be ideal. (I mean, it's theoretically possible that, in some parallel universe, there's a even problem for which C++ is the ideal choice.) > Note that I've not listed comp.lang.tcl for increased productivity, > and to avoid starting a flame war. Yeah - right. And no Tcl users ever read here? From claird at Starbase.NeoSoft.COM Thu Jun 10 09:57:35 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 10 Jun 1999 08:57:35 -0500 Subject: Why is tcl broken? References: <375F82C7.CF0F0477@iname.com> <4.1.19990610150908.00d09790@exchsrv> Message-ID: <7jog8f$ljv$1@Starbase.NeoSoft.COM> In article <4.1.19990610150908.00d09790 at exchsrv>, Fernando Mato Mira wrote: . . . >A `TCLer' here is going to give a talk presenting the virtues of >tcl to the rest of the organization. As a hard-core lisper, it is obvious >to me that the core philosophical basis of the `New Jersey school' (i.e. the >whole idea of scripting languages) is broken, and obviously the syntax >is tasteless to me. But I'm looking for irrefutable signs of bad language Oh, so *that*'s your point. Well, RMS has already said it all--in fact, more than all, 'cause some of his claims are inaccurate. Myself, I see Tcl and LISP as more alike than different, but I gather that's not what you're after so much as . >design that result in low maintenability. For example, dynamic scoping, >ambiguities, etc. Things like the `string issue' are also interesting if they >can be exposed in a way that the answer is not "So what?". So I take it you're going to end up arguing for Eiffel in favor of Scheme? I'll ask a better question: is maintainability to you a philosophically-accessible dimension? Are you involved in an academic or "practical" inquiry? I respect both, but I find your ap- proach ambiguous. As a practical engineering matter, I find the distinctions you highlight are lost in comparison to larger organizational and architectural issues. Concretely, Tcl's characteristics are not absolutely bad, only (potentially so) in relation to the work practices of your organization. If you seriously want to debate syntax and semantics in academic abstraction ... well, at least we need to know that. > >I'm not putting in question the virtues of Tk, as you can access that >through STk, for example. But if there are bad things there, I'd like >to know, too. (eg: is there a lot of tcl code making a Tk interface run? Approximately 0.46 of a lot, yes. >If so, does speed ever become an issue? I assume that Tk works well Rarely. Much less often than the uninitiated suspect. >enough that you'd never have to look at the tcl code, and live happily >inside your reflective Scheme world) Some TkSchemers do. Some don't. It depends. . . . Be careful with your audience to make clear *which* "whole idea of scripting languages" you disfavor. The hazard is that they'll turn on Scheme. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From mlv at pobox.com Thu Jun 24 12:42:40 1999 From: mlv at pobox.com (Michael Vezie) Date: 24 Jun 1999 12:42:40 -0400 Subject: tkSimpleDialog.py & tvtwm Message-ID: <7ktn60$pun$1@mlv.mit.edu> I think I've found a bug in tkSimpleDialog (Python 1.5.1, apologies if it's been fixed in 1.5.2). In the Dialog class, in __init__(), it sets it's geometry by: self.geometry("+%d+%d" % (parent.winfo_rootx()+50, parent.winfo_rooty()+50)) Problem is, in tvtwm, if you're not in the first window, the rootx and rooty are that of the full virtual window (e.g., if you're in one window over, at X position 250 (relative to the current window), and your screen is 1000 pixels wide, rootx returns 1250. When the geometry is set, it then sets it to be 1250 relative to the current window, which, if your virtual space is only two screens wide, is off the screen, never to be seen again. A solution that I believe will work with both tvtwm and fvwm2 (only two I've checked, but probably others) is to add winfo_vrootx() to the mix. In fvwm2, vrootx is always 0 (I think), while in tvtwm, it is (in the above example), -1000. Adding it would give a current position of 250, which will work for future windows. I hope those who know much more about window managers than I do will correct my theories as they see fit. For myself, I'm fixing the problem locally by adding winfo_vrootx/y to that line. Let me know if there's a better way that is more portable (or preferably, whatever way will be used in future versions of python). Michael From tre17 at cosc.canterbury.ac.nz Thu Jun 3 23:30:22 1999 From: tre17 at cosc.canterbury.ac.nz (Timothy R Evans) Date: 04 Jun 1999 15:30:22 +1200 Subject: More Tkinter menu problems References: <3755C714.526B7994@pixar.com> <%Zm53.899$S15.46310@dfiatx1-snr1.gtei.net> Message-ID: "John Michelsen" writes: > > self.menu.add_command(label = new_name, > > command = lambda temp_color = new_color: > > self.select_color(temp_color)) > > > >but I get a Name Error on "self". So now "self" is out of scope when > >the menu call happens. > > > try: > self.menu.add_command(label = new_name, > command = lambda c=new_color, f=self.select_color: f(c)) > > John Another possible way of implemented getting the same result, without resorting to unreadable lambda expressions is to create a class something like... class Command: def __init__(self, func, *args, **kw): self.func = func self.args = args self.kw = kw def __call__(self, *args, **kw): args = self.args + args kw.update(self.kw) apply(self.func, args, kw) then... command = Command(self.select_color, new_color) This costs one extra function call when it is used, but I think the decrease in complexity of the expression make it worth it. -- Tim Evans From hniksic at srce.hr Sat Jun 5 09:56:32 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 05 Jun 1999 15:56:32 +0200 Subject: Deleting characters from a string Message-ID: <87n1ye3g4v.fsf@pc-hrvoje.srce.hr> string.translate can delete characters from a string, as well as translate them. But what if I want *only* to delete them? Currently I do this: dummytable = string.maketrans('', '') ... host = string.translate(host, dummytable, ' "') ... What I would really like to be able to do is write: host = string.translate(host, None, ' "') Am I missing a more elegant solution? From milliger at ausinfo.com Thu Jun 10 12:39:47 1999 From: milliger at ausinfo.com (mike milliger) Date: Thu, 10 Jun 1999 11:39:47 -0500 Subject: Date formats Message-ID: <375FEA53.95E3D3BC@ausinfo.com> I read the documentation in the Python Reference Library (6.3) on time access and conversions and chapter 8 in programming python, yet I can't figure out if i need ( or how to use) a tuple to format the return from localtime(). i get a string now (wed jun 10 1999 xx:xx:xx) but i need to format it to yyyymmdd_hhmmss. Is there any switch ( %) or function that can be useful? Any help is appreciated. --mike From ragica at news.vex.net Wed Jun 2 14:47:14 1999 From: ragica at news.vex.net (Ragica) Date: 2 Jun 1999 18:47:14 GMT Subject: Idle comments References: <7ipm6c$ln0$1@nnrp1.deja.com> <7iucf0$drp@vern.bga.com> Message-ID: <7j3u7h$45j$2@hub.org> On 31 May 1999 11:13:20 -0500, David Friedman wrote: > I think I've posted this before but I'll mention it again. I have my >Win95 color scheme set for white text on a dark background. The default I too have posted before asking about how to change the blinding (to me) IDLE background colour... and have seen your previous post also (and watched avidly for a response to it, as my message got no responses... but neither did yours). So hopefully someone anwsers this mystery this time! Just to let you know that there are others with the same problem who want to use IDLE but can't figure out how to change the background colour to something tolerable.... And now i see a new message about a nifty new extension to IDLE... callTips... can't someone make an extension to simply change the background colour?! Heh. From tre17 at cosc.canterbury.ac.nz Wed Jun 23 19:39:05 1999 From: tre17 at cosc.canterbury.ac.nz (Timothy R Evans) Date: 24 Jun 1999 11:39:05 +1200 Subject: TkInter callback - how to ? References: <376F4E57.6A23A66F@cellware.de> Message-ID: bernard writes: > I have an array of buttons (a keypad) all using the same callback > function - is there any way of finding out which button invoked > the callback ? I suppose I am looking for a tcl/tk solution > something like > -command "myCallback $thisButton" > but tkInter only seems to provide > -command myCallback > > Any help welcome > > bernard I posted a `Command' class that solves this a while ago, here it is again: class Command: def __init__(self, func, *args, **kw): self.func = func self.args = args self.kw = kw def __call__(self, *args, **kw): args = self.args + args kw.update(self.kw) apply(self.func, args, kw) then do this: command=Command(myCallback, thisbutton) The class given is rather general, and I'm not quite sure if my precedence for the keyword arguments makes sense. As you won't use the keyword arguments this won't matter. -- Tim Evans From sdm7g at Virginia.EDU Sat Jun 5 00:31:28 1999 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Sat, 5 Jun 1999 00:31:28 -0400 (EDT) Subject: threads In-Reply-To: <000a01beaef4$a53dda20$f19e2299@tim> References: <000a01beaef4$a53dda20$f19e2299@tim> Message-ID: On Fri, 4 Jun 1999, Tim Peters wrote: > the-guarantee-of-exclusion-simplifies-much-of-the-implementation-ly y'rs - > tim Ahh -- getting nostalgic for old arguments again: I recall this was one of the reasons I favored coroutines over threads -- the explicit yield means that you don't need locks. Sort of like the non-preemptive multitasking on the Mac. The Mac, of course, is now moving towards a fully preemptive multitasking model -- which makes better sense for a OS because you can't control all of the code in all of the apps and ensure that they all behave like good citizens. However, in a single app, that's not a problem, and cooperative multitasking with coroutines is a simpler model. BTW: Does anyone have anything to add about how threads and locking work in JPython? Is it Bug/Feature-compatible with CPython wrt threads, or does it manage to use any of the Java thread feature to advantage here? ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- "IA-64 looks just about like what you would expect from a PA-RISC and IA-32 train wreck with a little VLIW thrown in for spice." * Thomas J. Merritt in * From mal at lemburg.com Fri Jun 11 05:22:24 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 11 Jun 1999 11:22:24 +0200 Subject: ANN: mxODBC Package - Version 1.1.1 Message-ID: <3760D550.2071295E@lemburg.com> ANNOUNCING: mxODBC Version 1.1.1 A Python Extension Package providing a generic Interface to ODBC 2.x API compliant Database Drivers or Managers WHAT IT IS: mxODBC is an extension package that provides a Python Database API compliant interface to ODBC 2.x capable database drivers and managers. In addition to the capabilities provided through the standard API it also provides a rich set of catalog methods that allow you to scan the database for tables, procedures, etc. Furthermore, it uses the mxDateTime package for date/time value interfacing eliminating most of the problems these types normally introduce. mxODBC is known to work with Adabas, MySQL, iODBC Unix ODBC Manager, Solid, Sybase, OpenLink and Intersolv/Merant ODBC drivers, Oracle/NT, EasySofts ODBC-ODBC bridge and the Windows ODBC Manager. This covers pretty much the whole range of well known relational database engines and gives you all the connectivity you'll need for doing great database work in Python. WHAT'S NEW ? The 1.1.1 version fixes a few small bugs with Solid and Access and includes an improved test script that allows checking the database connection as well as the database's capabilities. The subpackages for EasySoft, MySQL and iODBC were updated to the latest available versions of the drivers/managers. Some helper functions for pretty printing result sets have also made their way into the package. WHERE CAN I GET IT ? The full documentation and instructions for downloading and installing can be found at: http://starship.skyport.net/~lemburg/mxODBC.html The mxDateTime package needed for mxODBC can be found at: http://starship.skyport.net/~lemburg/mxDateTime.html WHAT DOES IT COST ? mxODBC comes with a slightly modified Python-style license: Usage is free for non-commercial and commercial internal use. Redistribution of the package in commercial products requires a separate license and will only be free if the product itself is free. Detailed license information is available at: http://starship.skyport.net/~lemburg/mxODBC-License.html WHERE CAN I GET SUPPORT ? I am offering commercial support for this package through Python Professional Services Inc. (http://www.pythonpros.com). Look on their support pages for details or contact me directly. REFERENCE:

>> | | 2) Can you use CONFIGPARSER to write a *.INI file that | you have made, or read into config parser, back | out to disk? From reading Dejanews, I believe that | it can't be?!?!?!?!?!? If so, why? It seems silly to support | read but not write. | | - Benjamin this one I can't help with, i prefer LParser for configuration parsing :) scott From alan.gauld at gssec.bt.co.uk Fri Jun 25 07:34:48 1999 From: alan.gauld at gssec.bt.co.uk (Alan Gauld) Date: Fri, 25 Jun 1999 12:34:48 +0100 Subject: total idiot question: +=, .=, etc... References: <877lov62z1.fsf@pbl.ddns.org> <37722979.2FCD9A5F@gssec.bt.co.uk> Message-ID: <37736958.5BED2666@gssec.bt.co.uk> Reimer Behrends wrote: > While I'd be the first to agree that C++ is not exactly the epitome of > language design, I would think that at least the local variables should > be easy to identify. The only real problem is to distinguish global Not so. If the method is long(as these were - over 200 lines in some cases, mostly initialising huge DCE Data structures) you can't see the local definitions. C++ compounds this with its ability to declare local variables anywhere in the code (so a split screen editor doesn't help). Alan G. -- ================================================= This post represents the views of the author and does not necessarily accurately represent the views of BT. From olipt at mayo.edu Thu Jun 10 12:45:06 1999 From: olipt at mayo.edu (Travis Oliphant) Date: Thu, 10 Jun 1999 11:45:06 -0500 Subject: Advice on an how to handle errors in extension module. Message-ID: I'm writing some Python-C interfaces to some mathematical libraries in FORTRAN. In particular, I'm working on interfacing QUADPACK with Python. The code is basically complete and an old version can be found in Multipack at http://oliphant.netpedia.net The problem is that the FORTRAN code requires that there be an (external) function defined which computes the integrand. This function must be of a certain type. The function I use is a just wrapper that handles calling the user defined Python function (stored in a static global variable). The question I have is that if a Python error occurs while evaluation of the user-defined function, I'm not sure what to do inside this wrapper function which can only return a double. Currently, I'm printing the error (if it hasn't been printed before) and returning a zero. This won't stop the integrator from callling the function again but it will have the effect of treating the function as if it were zero. This actually works really well for 1-D integration. Lately, though, I've just made the C-interface so that it can be re-entrant (so the Python function itself could call an integration routine --- allows for easy multiple integration). But, this exposes the inelegance of my solution for handling a Python error. I'm just fishing for ideas from more knowledgeable people on this list. Travis Oliphant From mlh at swl.msd.ray.com Mon Jun 21 17:49:15 1999 From: mlh at swl.msd.ray.com (Milton L. Hankins) Date: Mon, 21 Jun 1999 17:49:15 -0400 Subject: Environment inheritance under Windows NT Message-ID: Python doesn't seem to pick up the environment from its parent process under Windows NT. If I set an EV (environment variable) in the Windows NT System control panel applet, then run a command prompt and use the SET command to change the variable's value, then run Python at that same command prompt, os.environ reflects the old (control panel) value of the EV. setlocal and endlocal do not appear to help. Am I simply expecting Windows to behave too much like UNIX here? (Please Cc your response to me.) -- Milton L. Hankins \\ ><> Ezekiel 18:21 ><> Software Engineer, Raytheon Systems Company // http://amasts.msd.ray.com/~mlh \\ RayComNet 7-225-4728 From tismer at appliedbiometrics.com Sun Jun 13 14:25:02 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Sun, 13 Jun 1999 18:25:02 GMT Subject: Variations on a theme by "pound bang" References: <3763e75f.3265255@news.iol.ie> Message-ID: <3763F77E.6094AEE9@appliedbiometrics.com> Sean Mc Grath wrote: > > Can anyone shed some light on the benefits of:- > > # !/usr/bin/env python Uses the env program which is allways there, to figure out from the environment settings which python to use. This can be useful when you are running multiple Python versions. Use this in a secure setup, on a local machine, and NEVER AS ROOT. This feature is dangerous in an CGI environment. CGI applications should depend on environment settings to the bare minimum. Whatever can be avoided, should be avoided. > as opposed to > > # !/usr/bin/python The way to go for CGI. Simple, explicit, not dependant from someone messing up with server settings. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From gmcm at hypernet.com Fri Jun 4 16:37:02 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Fri, 4 Jun 1999 15:37:02 -0500 Subject: threads In-Reply-To: <87aeug7yn7.fsf@pc-hrvoje.srce.hr> Message-ID: <1283593620-47537497@hypernet.com> Hrvoje Niksic writes: > "Barry A. Warsaw" writes: > > > You might be interesting in digging around for Greg Stein's > > free-threading patches. Greg did a lot of work, I think in the > > Python 1.4 days, to remove the central interpreter lock and make all > > the data structures and such thread safe. > > Why would I want to do that? See that other thread. > If Greg's patches haven't been applied > to the base, surely mine would not be either. As I recall, Greg's patches didn't make it because (1) they were late and (2) they were slow. Guido has never issued an "over my dead body" message on the subject, which considering how often it has come up, could be considered expressing interest in the idea. OTOH, if you don't feel strongly enough, or don't have the time, it can wait for someone else. - Gordon From amackay at starvision.com Wed Jun 30 15:36:55 1999 From: amackay at starvision.com (Angus MacKay) Date: Wed, 30 Jun 1999 12:36:55 -0700 Subject: ioctl in python Message-ID: <377A71D7.470AF9DA@starvision.com> is there some magic to the fcntl.ioctl() call? I can do these ioctl calls in C no problem (with a small wrapper): (amackay at phat)~/tmp$ ./ioctltest /tmp 0x80047601 0x80047601: 1 (amackay at phat)~/tmp$ ./ioctltest / 0x80047601 0x80047601: 0 (amackay at phat)~/tmp$ ./ioctltest /proc 0x80047601 /proc: Inappropriate ioctl for device that was the Linux ioctl for EXT2 version. but in python: >>> a = 0 >>> req = 0x80047601 >>> import fcntl >>> fo=open('/tmp') >>> fcntl.ioctl(fo.fileno(), req, a) Traceback (innermost last): File "", line 1, in ? IOError: (14, 'Bad address') >>> thanks in advance. cheers, Angus. From joechan25 at hotmail.com Sat Jun 26 07:47:45 1999 From: joechan25 at hotmail.com (Joe Chan) Date: Sat, 26 Jun 1999 11:47:45 GMT Subject: Python for large projects? Message-ID: <3774b5d1.690922@news.force9.net> Hi, I've been doing mostly desktop and Client/Server development work but I'm considering how best to develop web-based and distributed projects. I read a paper on the Python.org site comparing Java and Python and was impressed. I'm interested in other peoples views and experiences of using Python for: large projects; team developments; distributed objects; intranet development etc. TIA From matomira at iname.com Sun Jun 13 10:59:18 1999 From: matomira at iname.com (Fernando Mato Mira) Date: Sun, 13 Jun 1999 16:59:18 +0200 Subject: OO (was: Why is tcl broken?) References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> <3762988E.C94AA252@iname.com> Message-ID: <3763C746.5CA8FE78@iname.com> Peter wrote: > If you are a fan of CLOS, you might want to check out the Dylan > programming language. > > It is basically a thoroughly modernized descendant of Lisp/CLOS with an > infix instead of prefix syntax. In Dylan, almost everything is an object Although Dylan never really made it into "Fernando's elegibility list" because it was not a serious contender against Scheme and CL yet, it definitely got banished the day the Lisp syntax was dropped. I'm still waiting for the day when the Dylan fans will reinstate the alternative. But my dream is a `parenthesized Cecil' http://www.cs.washington.edu/research/projects/cecil/ or "all you wanted in CLOS (and more) since you got `corrupted' by Eiffel" ;-) -- Fernando D. Mato Mira Real-Time SW Eng & Networking Advanced Systems Engineering Division CSEM Jaquet-Droz 1 email: matomira AT acm DOT org CH-2007 Neuchatel tel: +41 (32) 720-5157 Switzerland FAX: +41 (32) 720-5720 www.csem.ch www.vrai.com ligwww.epfl.ch/matomira.html From claird at Starbase.NeoSoft.COM Tue Jun 29 11:45:16 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 29 Jun 1999 10:45:16 -0500 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> <7l4nht$jl7$1@nnrp1.deja.com> <9DDBCC52A7B26002.649D772F7232D418.CE2709D4B08E7401@lp.airnews.net> Message-ID: <7lapmc$d2g$1@Starbase.NeoSoft.COM> In article , Ernst-Udo Wallenborn wrote: > > >To ask a completely different question: What about >threads and GUI? With Tkinter you have to rewirte the >mainloop like this > > def mainloop(self): > while 1: > Frame.update(self) > time.sleep(0.02) > if self.quitting == 1: > sys.exit(0) > > >to convince it to run with thread or threading. I remember having >read a comment from Guido van Rossum, citing Jan Osterhout that Tk >will never be thread-safe and that therefore this problem will not go >away. > >Would this be any different with a different GUI kit? . . . As Mr. Zeitlin asserts in his follow-up, multi-threading the GUI is generally a futile hazard. Dr. Ousterhout always, as far as I know, goes by his Americanized given name John. I make the point because one of the people working most actively with Tk capabil- ities is Jan Nijtmans. Yes, John has said he expects Tk never to be thread-safe. That has changed, though, just in the last few months. You're quite right that many toolkits have issues in re- gard to threading. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From samschul at pacbell.net Tue Jun 22 11:33:54 1999 From: samschul at pacbell.net (Sam Schulenburg) Date: Tue, 22 Jun 1999 08:33:54 -0700 Subject: IDLE 0.5 Function parameter display? References: <7kmpnu$red$1@nnrp1.deja.com> <7ko57c$cfk$1@m2.c2.telstra-mm.net.au> Message-ID: Thanks Mark; I founnd that the following will also work. I do not know if it is an acceptable solution. from MyDll import my_func # first I import the function from my dll my_func.__doc__ = "This is my documentation string" Mark Hammond wrote in message <7ko57c$cfk$1 at m2.c2.telstra-mm.net.au>... >The best way at the moment is to add a docstring to the function in the C >code. If you look at the help provided for (eg) string.split, it is quite >effective even though it is only from the docstring. > >Mark. > >Sam Schulenburg wrote in message <7kmpnu$red$1 at nnrp1.deja.com>... >>I love the ability of IDLE 0.5 to display the function parameter >>requirements as defined in the original function definition. My problem >>is when I have a function defined in a windows dll written in 'C', then > > > From gmcm at hypernet.com Sun Jun 6 22:11:41 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Sun, 6 Jun 1999 21:11:41 -0500 Subject: "The Python Way" In-Reply-To: <7jf39e$4t4$2@cronkite.cc.uga.edu> Message-ID: <1283400745-59139041@hypernet.com> Graham Matthews wrote: > The key word is "discuss". To have a "discussion" one must have > participants who don't simply want to defend "the python way". > That's where that word "parachial" comes in! Please, Graham. Your posts about GC to collect cyclic references got quite a few favorable replies. No one surfaced with both the time and enthusiasm to implement it, but that should not be a surprise. Look at the state of Greg's free-threading patches, or the total lack of activity on the Types SIG. Remember also that most responses will be from people who feel strongly one way or the other, which will often have a negative correlation to the thoughtfulness of the replies. That's "Usenet". You did, however, start by proposing using Java as the implementation language for Python 2, which is a very different matter. petrolium-distillates-on-troubled-waters-ly y'rs - Gordon From kjwolf at online.de Wed Jun 9 15:54:33 1999 From: kjwolf at online.de (Klaus-Juergen Wolf) Date: Wed, 9 Jun 1999 21:54:33 +0200 Subject: Problem with Curses Message-ID: (Python 1.5.2 on FreeBSD 3.2-RELEASE (i386)) I found that (after having compiled Python with cursesmodule.c - testall.py succeeds) the following program gives a segmentation fault: -*- import curses mainscr=curses.initscr() testwin=mainscr.subwin(2,2,2,2) testwin.erase() del testwin curses.endwin() -*- I don't understand this - the C equivalent doesn't show any problems. (You can drop "del testwin", it has no effect anyway.) In no way, Python should end up in a segmentation fault - in this case, it appears that the first screen-writing call to libtermcap causes the problem. Can anyone help me? thanx & cu k.j. From jam at newimage.com Sun Jun 20 16:12:53 1999 From: jam at newimage.com (jam) Date: Sun, 20 Jun 1999 16:12:53 -0400 Subject: simple text file 'parsing' question In-Reply-To: ; from Matt Gushee on Mon, Jun 21, 1999 at 12:56:07AM +0900 References: <376B1AAC.19FE8BCE@mysolution.com> Message-ID: <19990620161253.A814@toast.internal> On Mon, Jun 21, 1999 at 12:56:07AM +0900, Matt Gushee wrote: > KP writes: > > > Here's my dilema: a directory filled (200+) with small emails. My goal > > is to strip all the headers and combine them into one file. I can read > > all the files just fine and write them all to one file, but I cannot > > discern how to strip the headers. > > I have no expertise in this area, but I've been reading the "Internet > Data Handling" section of the Library Reference (Ch. 12 of the 1.5.2 > edition), and it seems like there are several modules that might help > you. In particular, check out 'rfc822.' > > Hope this helps. > > Matt Gushee > Portland, Maine, USA > mgushee at havenrock.com > I wrote a small piece of code that does *exactly* what you are describing. it doesn't exactly strip the headers, but it parses the message using rfc822 and deals with it. you'll find it attached to this message. if for some reason it doesn't come through, let me know, and I'll resend it. regards, Jeff -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. -------------- next part -------------- #!/usr/bin/env python import os import dircache import mimetools import colacanister import getdate from rfc822 import Message _COLAROOT="/home/jam/projects/cola/cola.archive" _COLABASEHREF="http://www.cs.helsinki.fi/%7Emjrauhal/linux/cola.archive/" if __name__ == "__main__": l = dircache.listdir(_COLAROOT) print len(l) for item in l: p = os.path.join(_COLAROOT, item) if os.path.isdir(p): articles = dircache.listdir(p) for a in articles: if a[:5] != "cola." and a[:4] != "mjr.": continue fp = open(os.path.join(p, a), "r") m = Message(fp, seekable=0) fp.close() if not m.has_key("subject"): print "** message does not have subject line. skipped." continue url = os.path.join(item, a) print "processing '%s'" % (url), if colacanister.get_cola_by_archiveurl(url) is None: c = colacanister.colacanister() c["cola_from"] = m["from"] if m.has_key("date"): c["cola_dateposted"] = getdate.getdate(m["date"]) c["cola_subject"] = m["subject"] c["cola_archiveurl"] = url c.insert() print "added." else: print "already archived." From just at letterror.com Sat Jun 12 05:07:04 1999 From: just at letterror.com (Just van Rossum) Date: Sat, 12 Jun 1999 09:07:04 GMT Subject: gadfly install problem In-Reply-To: <7jrn7g$n2f$0@205.138.136.179> References: <7jrn7g$n2f$0@205.138.136.179> Message-ID: At 7:14 PM +0000 6/11/99, Douglas Nichols wrote: >I am trying to install gadfly for use on my mac with python 1.5.1 > >The installation seems to have worked. When I try to test gadfly by >creating a new database, I get the following error message: > >Python 1.5.1 (#37, Apr 27 1998, 13:36:04) [CW PPC w/GUSI w/MSL] Ah, you're on a Mac. >Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>>> import gadfly >>>> connection = gadfly.gadfly() >>>> connection.startup("testbase", "testfolder") >>>> cursor = connection.cursor() >>>> cursor.execute("create table ph (nm varchar, ph varchar)") >shift: no mem in addchild >Traceback (innermost last): > File "", line 1, in ? > File "Macintosh HD:Development:Python 1.5.1:Lib:lib-gadfly:gadfly.py", >line 320, in execute > from sqlsem import Parse_Context >MemoryError >>>> > >Any suggestions? I am very new to python and am still working my way >through the Learning Python book. You'll need to increase Python's memory partition. Python's parser uses a *lot* of memory if a source file is big. Just From ivnowa at hvision.nl Sun Jun 6 16:27:20 1999 From: ivnowa at hvision.nl (Hans Nowak) Date: Sun, 6 Jun 1999 20:27:20 GMT Subject: Newbie question In-Reply-To: <7je3sk$46$1@nnrp1.deja.com> References: <7je3sk$46$1@nnrp1.deja.com> Message-ID: <199906062025.WAA15357@axil.hvision.nl> On 6 Jun 99, mesak1234 at my-deja.com wrote: > Hi! > Well, i get problems with getting date from OS....(win32 at this > moment)... All what i need that to find out date attribute of a file. > But i even cannot find out what the function i can use to get the real > time (anything like Date date = new java.util.Date(); ???? :( ) > All functions of 'time library' seem fine but don't help so much... > Any suggestions? > Thanks, > Daniel To get the date and time attributes of a file, you can use os.stat. E.g. os.stat("myfile.txt") will return a tuple with file info... its size, attributes, etc. Element -2 (!) is the time used by the file system. You will see a weird long number like, for example, 928696080; this is because date and time are packed into one number. Unpack it with the time.localtime function. This returns another tuple whose elements are pretty straightforward (year, month, etc). The system time, on the other hand, can be retrieved with time.time(). Once again, you'll get one number, which needs to be unpacked with time.localtime(). For further information, I suggest you study the time module and os.stat. :) Veel liefs, --Hans Nowak (ivnowa at hvision.nl) Homepage: http://fly.to/zephyrfalcon From pduffin at mailserver.hursley.ibm.com Fri Jun 11 07:18:58 1999 From: pduffin at mailserver.hursley.ibm.com (Paul Duffin) Date: Fri, 11 Jun 1999 12:18:58 +0100 Subject: Embedded Tcl for Python References: Message-ID: <3760F0A1.1DDC@mailserver.hursley.ibm.com> Michael P. Reilly wrote: > > A few weeks ago, someone asked if there was a Tcl module for Python. > People responded (including myself) that Tkinter uses a Tcl/Tk > interpreter, but you couldn't get rid of the annoying window. > > I've since written an extension ("pytcl") that creates Tcl interpreter > objects. As part of that, I have also rewritten _tkinter to use these > new objects. > > I've had a short discussion with Guido and he's interested in the > idea. Now I need some alpha testers; I only have access to UNIX boxes, > and very few types at that. > > The _tkinter module has the same functionality as before, including the > same threading issues. I've include Deiter's Tcl/Tk8.1 patch but have > not had the opportunity to test that yet (right not it is just do-no- > damage). > > Contact me at arcege at shore.net if you are interested in helping me test > these modules. > I was interested in doing something similar in Tcl (e.g. creating a python interpreter object) and I was wondering if someone could give me some pointers as to how to go about doing it. -- Paul Duffin DT/6000 Development Email: pduffin at hursley.ibm.com IBM UK Laboratories Ltd., Hursley Park nr. Winchester Internal: 7-246880 International: +44 1962-816880 From behrends at cse.msu.edu Thu Jun 24 01:28:40 1999 From: behrends at cse.msu.edu (Reimer Behrends) Date: 24 Jun 1999 05:28:40 GMT Subject: total idiot question: +=, .=, etc... References: <877lov62z1.fsf@pbl.ddns.org> <8L_b3.1213$4s.136166@typhoon-sf.snfc21.pbi.net> Message-ID: Zigron (zigron at jps.net) wrote: > Reimer Behrends wrote in message > news:slrn7n0rr2.2fi.behrends at allegro.cse.msu.edu... [...] > > Among all the suggestions for Python 2.0, removing the necessity of > > prefixing methods and instance variables with "self." (and not having > > to list it as an argument, either) would be my #1 wish. > > Whyfor? I personally like the seperate scopes, beween the class > and the method. It makes it so I don't have to clean up as much. I can > use as many temporary variables as I want in a method, and as soon > as that method is gone...... its gone. I said nothing like that. I am simply saying that the syntax is a major pain. To remind you, pretty much every single OO language other than Python does not require you to add a self; yet at the same time they have per-method and per-object data. It's a matter of how you declare it. > The self.attribute thing makes sense. Each object has its own scope, > er, namespace, whatever. Methods are considered objects, as are > classes. Removing the 'self' requirement would, to me, change that. > Methods wouldn't be objects anymore. :) At least it seems so to me, I'm sorry, but I cannot make much sense of what you try to say here. Could you perhaps elaborate? [...] Reimer Behrends From fredrik at pythonware.com Fri Jun 4 12:35:15 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 4 Jun 1999 16:35:15 GMT Subject: "The Python Way" References: <001101beae49$39af7bc0$949e2299@tim> <7j8pra$55v$4@cronkite.cc.uga.edu> Message-ID: <00f301beaea8$39f419b0$f29b12c2@pythonware.com> Man looking for an argument (M) wrote: M> [Fredrik Lundh] M> > Would both Guido and TIm Peters be willing to collaborate on a short M> > paper M> M> Oh thank you Fredrik for posting the above. Does anyone else consider M> that the above sounds slightly paranoid? I didn't write that. Sure sounds like you're slightly paranoid, Graham. (If you want me to go on arguing, you'll have to pay for another five minutes). From neelk at brick.cswv.com Thu Jun 24 23:48:51 1999 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 24 Jun 1999 22:48:51 -0500 Subject: [ANN] DejaGrabber 0.1 -- search Dejanews with Python Message-ID: <7kuu73$1ki$1@brick.cswv.com> If you'd like a convenient way of searching the DejaNews archive using Python, I'm happy to present the DejaGrabber module. This is a module to make searching Dejanews easier. There are two classes, DejaGrabber and Article. I've tried to add a reasonable number of useful docstrings, too. The interface to DejaGrabber could probably use a bit of work. If I ever use it enough to find out what the flaws are, I will fix it. Patches are welcome. :) Here's an example: >>> from DejaGrabber import * >>> d = DejaGrabber(group='comp.lang.python', author='Tim Peters') >>> l = d.get_messages(4) >>> print l [99/06/23 30 comp.lang.python RE: Python Exes! Tim Peters , 99/06/18 28 comp.lang.python RE: Newbie: Truth values (th Tim Peters , 99/06/18 28 comp.lang.python RE: DATE ARITHMETIC Tim Peters , 99/06/18 28 comp.lang.python RE: NameError Problem Tim Peters , 99/05/18 25 comp.lang.python RE: while (a=b()) ... Tim Peters ] You can grab a copy at http://www.sff.net/people/neelk/free-software/DejaGrabber.py Neel From gmcm at hypernet.com Tue Jun 15 10:17:10 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 15 Jun 1999 09:17:10 -0500 Subject: extension called from embedded code In-Reply-To: <7k59i2$ijd$1@nnrp1.deja.com> Message-ID: <1282666009-103335976@hypernet.com> Henk Jansen writes: > Trying to get the most out off the C++/Python team I run into > problems when I try to load extension modules (written in C, like > kjbuckets or ranlib) from Python code that is embedded in a C++ > application. The API I use is 'PyRun_SimpleString("import > kjbuckets\n");' and causes unresolved symbol error messages from the > Python interpreter (e.g. PyType_Type for kjbucketsmodule.so and > PyExc_RuntimeError for ranlib.so). Loading these modules when Python > is in control goes fine. Has anyone any idea how to do this? This has something (platform / compiler / linker specific) to do with the way you've built your app. For some reason the symbols in your embedded Python are not getting exposed to the dynamic linker. Perhaps if you post the relevant snippets from your Makefile, someone with experience on that platform (compiler...) can help. - Gordon From sams at quinta.com Mon Jun 21 21:43:28 1999 From: sams at quinta.com (Sam Schulenburg) Date: Tue, 22 Jun 1999 01:43:28 GMT Subject: IDLE 0.5 Function parameter display? Message-ID: <7kmpnu$red$1@nnrp1.deja.com> I love the ability of IDLE 0.5 to display the function parameter requirements as defined in the original function definition. My problem is when I have a function defined in a windows dll written in 'C', then I do not have access to the function prototype information. Is their a way that I can re-prototype these functions without forgoing access to the original functions? Sam Schulenburg Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From gherron at aw.sgi.com Wed Jun 9 12:12:54 1999 From: gherron at aw.sgi.com (Gary Herron) Date: Wed, 9 Jun 1999 16:12:54 GMT Subject: Tkinter Question References: Message-ID: <375E9286.E39EF45A@aw.sgi.com> Robert Meegan wrote: > > Greetings --- > > I have an alarm display that consists of a Frame that contains multiple > frames within it, stacked one above the other. When a user clicks on one > of the subframes to acknowledge it, I want the subframe to disappear and > the parent frame to resize itself to remove the gap. > > Getting the subframe to remove itself is no problem. I bound the > event to a method and had the frame destroy itself. Life is > good. > > On the other hand, I can't figure out how to make the parent frame resize > itself. > > Suggestions will be greatly appreciated. > > --- Robert > > -------------------------------- > Robert Meegan > MCIWorldCom - Cedar Rapids, Iowa > 319.375.2416 You probably used `pack' to put each subframe into the main frame, so you should use its inverse operation `forget' to take it out. Then the parent frame resizes automatically. Here is a very small example: poke any of the buttons and watch it disappear and the frame resize around the remaining buttons. -- Dr. Gary Herron 206-287-5616 Alias | Wavefront 1218 3rd Ave, Suite 800, Seattle WA 98101 -------------- next part -------------- #!/usr/bin/env python from Tkinter import * root = Tk() for i in range(10): f = Frame(root) b = Button(f, text='%s'%i, command=lambda f=f: f.forget()) b.pack() f.pack() root.mainloop() From larsga at ifi.uio.no Tue Jun 8 05:04:38 1999 From: larsga at ifi.uio.no (Lars Marius Garshol) Date: 08 Jun 1999 11:04:38 +0200 Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <7j0urf$2dm$3@cronkite.cc.uga.edu> <19990601122134.A30248@chronis.pobox.com> Message-ID: * scott cotton | | kaffe, the gnu java implementation, has some interesting GC | features which might be explored for python 2.0: So does Allegro Common Lisp. I recommend anyone who's interested to go to and download an evaluation copy of ACL and read the doc/cl/gc.htm file. Personally, I don't even hesitate to say that Python 2.0 should have garbage collection, and preferably one that has both compactable and non-compactable references, as well as weak references. Ref-counting is slow and error-prone, as far as I'm aware, and should be avoided. --Lars M. From bwinton at tor.dhs.org Fri Jun 18 23:39:49 1999 From: bwinton at tor.dhs.org (Blake Winton) Date: Sat, 19 Jun 1999 03:39:49 GMT Subject: Newbie: Truth values (three-valued logic) References: <000201beb946$b9c99e00$969e2299@tim> Message-ID: On Fri, 18 Jun 1999, Olaf Delgado wrote: >On Fri, 18 Jun 1999, Tim Peters wrote: >> [Olaf Delgado] >I understand that. A new meaning for "and" and "or" would have to be >built into the language, but I don't think the merits would justify the >efforts. The simplest way I see would be to introduce a new type with >a single value "Maybe", similar to "None", which would have to be >handled specially by "if", "not", "and" and "or". It should be >relatively simple to implement this, as far as I can see, but of course >it would slow down things by having to consider all those special >cases. [snip] >Or I could set __and__(x,y)=x*y and __or__(x,y)=x+y-x*y. Then I only >would have to invent a way to partially execute a block of code. :) Wasn't it Intercal which first had something like this? if Maybe: # do this some of the time else: # do this other times # or is that do part of this, and part of that? I think the first is fairly easy to hack up, but the second would probably require some ByteCodeHacks (tm). Now I'm starting to be interested in one-value logic. I'm just not sure whether I want the value to be "True", "False", or "Maybe". Later, Blake. -- One Will. One Dream. One Truth. One Destiny. One Love. From gmcm at hypernet.com Mon Jun 14 22:44:36 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Mon, 14 Jun 1999 21:44:36 -0500 Subject: Basic python OOPs question In-Reply-To: <7jot0r$p32$1@nntpd.lkg.dec.com> Message-ID: <1282707564-100836116@hypernet.com> Daniel Mendyke asks: > > Do I understand correctly that objects are removed > from the name space when they go out of scope? They are reference counted. Going out of scope is one way to decrease the ref count. Rebinding the reference is another ("obj = None"). > And that they go out of scope based on indentation? Not exactly. An "if" statement, for example, does not have a new namespace. Functions and methods do. > If so is there a default function called on > objects that go out of scope? The __init__ > function is called when an object is created. > Is there a function that is called when the > object is destroyed? Yes. It's __del__. It is called when the refcount drops to 0. It's also called at clean-up time, which can be troublesome, because things you refer to in __del__ may well have already been cleaned up. There's a FAQ entry on the subject. - Gordon From mal at lemburg.com Mon Jun 7 17:12:00 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Mon, 7 Jun 1999 21:12:00 GMT Subject: mxODBC and MySQL References: Message-ID: <375C35A0.7754C3BD@lemburg.com> Joachim Schmitz wrote: > > Hi, > > I compiled and installed mxODBC for MySQL on SuSE 6.1 without problems. > I get this: > Python 1.5.2b2 (#6, Feb 28 1999, 21:41:19) [GCC egcs-2.91.60 19981201 > (egcs-1.1 > .1 on linux2 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import ODBC.MySQL > Traceback (innermost last): > File "", line 1, in ? > File "/usr/local/lib/python1.5/ODBC/MySQL/__init__.py", line 7, in ? > from mxODBC import * > ImportError: /usr/local/lib/python1.5/ODBC/MySQL/mxODBC.so: undefined > symbol: PyBuffer_Type > >> You can either upgrade to 1.5.2 final or turn off the buffer type code in mxODBC.c manually (enclosed in HAVE_PYTHON_BUFFEROBJECTS #defines). I guess you stumbled into test code that I forgot to remove for the distribution; sorry. -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 207 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From schorsch at schorsch.com Mon Jun 14 19:40:05 1999 From: schorsch at schorsch.com (Georg Mischler) Date: Mon, 14 Jun 1999 23:40:05 GMT Subject: do anonymous pipes normally work on NT? References: <7juatc$fef$1@nnrp1.deja.com> Message-ID: <7k43sk$6vd$1@nnrp1.deja.com> Ok, here we go again. I simplified my class to the absolute minimum I could. It now does nothing but create three pipes, save the parent ends to self.xxx, and create a process with the child ends of the pipes. After that it tries to write to the stdin pipe of the child, which goes without error, and tries to read from stdout, which blocks. To have a look at the other end, I wrote a little script that mimicks the unix "cat" command (in a very verbose logging incarnation...). This script first tries to write something to stdout as well, which goes without error, and then enters a loop reading from stdin and writing to stdout. This script is called from my class as a child process. The interesting thing is now, that in this case the child gets a "Bad file descriptor" when reading from stdin! There must be something going fundamentally wrong with the pipes, but without any Windows programming background, I have no chance left figuring out what. This happens on NT4sp3 with Python 1.5.2 (the binary from python.org) and the win32 extensions build 125, if that makes any difference. If this should be caused by a mistake I made (which may be likely), could anyone recommend a book where I can learn how to do this stuff right? And in any case, what is going on here? To try this out, copy both files together into a directory, change the path of python in the last code line of numproc.py to something that exists on your system, and call "python runproc.py". You'll have to kill the process with the task manager (at least I have to do this). The new file "log.txt" will contain the results of the child process. Thanks a lot for any help! -schorsch ------------------------------ '''cat.py a "enhanced" version of the good old cat unix filter. ''' import sys try: # write status to a file, in order not to lose it. f = open('log.txt', 'a') f.write('before write\n') sys.stdout.write('huh?') f.write('after write, before read\n') data = sys.stdin.read() f.write('after read\n') while data: f.write('in loop, before write\n') sys.stdout.write(data) f.write('in loop, after write, before read\n') data = sys.stdin.read() f.write('in loop, after read\n') except: import traceback, string tb_strs = traceback.format_exception( sys.exc_type, sys.exc_value, sys.exc_traceback) f.write(string.join(tb_strs)) # end of cat.py ------------------------------ '''cat.py an "enhanced" version of the good old cat unix filter. ''' import sys try: # write status to a file, in order not to lose it. f = open('log.txt', 'a') f.write('before write\n') sys.stdout.write('huh?') f.write('after write, before read\n') data = sys.stdin.read() f.write('after read\n') while data: f.write('in loop, before write\n') sys.stdout.write(data) f.write('in loop, after write, before read\n') data = sys.stdin.read() f.write('in loop, after read\n') except: import traceback, string tb_strs = traceback.format_exception( sys.exc_type, sys.exc_value, sys.exc_traceback) f.write(string.join(tb_strs)) # end of cat.py ------------------------------ '''runproc.py start a process with three inherited pipes. Try to write to and read from those. ''' import win32pipe import win32file import win32process import win32security class Process: def run(self, cmdline): # security attributes for pipes sAttrs = win32security.SECURITY_ATTRIBUTES() sAttrs.bInheritHandle = 1 # create pipes hStdin_r, self.hStdin_w = win32pipe.CreatePipe(sAttrs, 0) self.hStdout_r, hStdout_w = win32pipe.CreatePipe(sAttrs, 0) self.hStderr_r, hStderr_w = win32pipe.CreatePipe(sAttrs, 0) # set the info structure for the new process. StartupInfo = win32process.STARTUPINFO() StartupInfo.hStdInput = hStdin_r StartupInfo.hStdOutput = hStdout_w StartupInfo.hStdError = hStderr_w StartupInfo.dwFlags = win32process.STARTF_USESTDHANDLES # start the process. hProcess, hThread, dwPid, dwTid = win32process.CreateProcess( None, # program cmdline,# command line None, # process security attributes None, # thread attributes 1, # inherit handles, or USESTDHANDLES won't work. # creation flags. Don't access the console. win32process.DETACHED_PROCESS, None, # no new environment None, # current directory (stay where we are) StartupInfo) # normally, we would save the pid etc. here... err, bytes = win32file.WriteFile(self.hStdin_w, 'hmmm') print 'wrote:', bytes, 'bytes' res, str = win32file.ReadFile(self.hStdout_r, 1) if res == 0: print 'read:', str else: 'read nothing.' res, str = win32file.ReadFile(self.hStderr_r, 1) if res == 0: print 'read:', str else: 'read nothing.' if __name__ == '__main__': p = Process() p.run('c:\programme\python\python.exe cat.py') # end of runproc.py -- Georg Mischler -- simulation developper -- schorsch at schorsch.com +schorsch.com+ -- lighting design tools -- http://www.schorsch.com/ Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From claird at Starbase.NeoSoft.COM Tue Jun 29 11:33:11 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 29 Jun 1999 10:33:11 -0500 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> <3773c3a0.102825445@news.oh.verio.com> Message-ID: <7laovo$c4s$1@Starbase.NeoSoft.COM> In article , Michael P. Reilly wrote: . . . >There are other graphical packages for Python out there too, it would >be appropriate to contrast them as well. . . . I occasionally work on such a comparison, currently available at . I welcome updates from readers. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From fredrik at pythonware.com Wed Jun 30 18:23:22 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 30 Jun 1999 22:23:22 GMT Subject: problem with Fnorb and module new References: <377A8D17.9B4D17C8@sr.hp.com> Message-ID: <00ba01bec347$2aa95f70$f29b12c2@secret.pythonware.com> > I just tried installing Fnorb on HP-UX 10.20... the install went > smoothly, but when I tried stepping through the Hello World example, > python complained about not being able to find module new. The > complaint is certainly valid -- I can't find new.py anywhere either. > Anyone know what's going on here? it's a C module, not a Python module: http://www.python.org/doc/FAQ.html#4.70 and it's not built by default in 1.5.1. you have to rebuild Python with this module enabled (look for newmodule.c in the Modules/Setup file). or you can upgrade to 1.5.2... From news at dorb.com Wed Jun 30 13:19:24 1999 From: news at dorb.com (Darrell) Date: Wed, 30 Jun 1999 13:19:24 -0400 Subject: Reflection in Python? References: <7ldglr$ita$1@nnrp1.deja.com> Message-ID: # Get the testAdd method or attribute of MathTest test=getattr(MathTest,'testAdd') >>> class A: ... def myX(self): ... print 'xxx' ... >>> a=A() >>> af=getattr(a,'myX') >>> apply(af) xxx >>> af() xxx # Get the name of 'a' >>> print a <__main__.A instance at 7f79d0> >>> print `a` <__main__.A instance at 7f79d0> >>> print str(a) <__main__.A instance at 7f79d0> >>> print af >>> -- --Darrell wrote in message news:7ldglr$ita$1 at nnrp1.deja.com... > test = MathTest("testAdd") > > where test.run() will run the "testAdd" method on > the MathTest object? I also want to be able to > tell the user the name of the object (MathTest) > and the method in case the method fails. Any > thoughts? > > Thanks, > Anders Schneiderman > National Journal Daily Briefings Group > > > > > Sent via Deja.com http://www.deja.com/ > Share what you know. Learn what you don't. From daniel at virtualvoices.com Mon Jun 14 23:09:50 1999 From: daniel at virtualvoices.com (Daniel) Date: 14 Jun 1999 22:09:50 -0500 Subject: Support for mSQL? Message-ID: <3765b5ee@news.mdc.net> >From the 'python.org' web site the mSQL module is no longer being supported. Or has someone else picked up it's support? -Daniel From jeremy at cnri.reston.va.us Tue Jun 1 23:50:46 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Tue, 1 Jun 1999 23:50:46 -0400 (EDT) Subject: Python 2.0 (perhaps off topic) In-Reply-To: <375431E6.6BC64E80@prescod.net> References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <87pv3iq6ss.fsf@ev.netlab.co.jp> <3752C76D.604CD474@prescod.net> <87n1ykr0z9.fsf@ev.netlab.co.jp> <375372F6.A874554@prescod.net> <14164.7179.10346.998488@bitdiddle.cnri.reston.va.us> <375431E6.6BC64E80@prescod.net> Message-ID: <14164.43542.417731.361360@bitdiddle.cnri.reston.va.us> >>>>> "PP" == Paul Prescod writes: PP> Jeremy Hylton wrote: >> I don't think this is a good example. Even beginning users are >> going to have to learn a little about resource management about >> some point. People should not rely on files getting deallocated >> and closed by Python. All the beginners who start with JPython >> are going to get Java's GC. And they're going to need to close >> the files by hand. PP> It looks like this conversation has come all of the way PP> around. We are talking about whether the JVM should be the PP> default, standard Python distribution platform. It isn't fair, PP> then, to use the flaws in the JVM version of Python to argue FOR PP> that change. Perhaps this is what I get for jumping in in the middle of a conversation without learning how it got started. The example I was responding to depended on file object being immediately finalized to avoid leaking file descriptors. It isn't a flaw in JPython that performs differently. It's just a difference. Your skate on thin ice when you write code that depends on implementation issues rather than the language spec. It may be fine if you know what you're doing (love those bytecodehacks!), but it's hardly something you want to encourage a beginner to do. Of course, the implementation was sometimes posing as the language spec until JPython came along. PP> "Oh well, we'll lose compatibility with PIL but JPython users PP> have alreadly lost that so I guess it isn't a big deal." Tilt away . I took issue with your non-explicit close of a file, and didn't say anything about the merits of JPython vs. CPython. See my earlier post in this thread. I think I was unequivocal in my belief that the next version of Python needed to be in C or C++. Jeremy From da at ski.org Wed Jun 9 23:56:31 1999 From: da at ski.org (David Ascher) Date: Wed, 9 Jun 1999 20:56:31 -0700 (Pacific Daylight Time) Subject: Grimoire [was: How do I defect?] In-Reply-To: Message-ID: On Wed, 9 Jun 1999, Matthew Dixon Cowles wrote: > > So how do I defect from Perl to Python? I > > have the Programming Python book on order. > > What can I read to get started ASAP? The tutorial is what I recommend you get started with. However, I'd like to also put a little plug for a new document I discovered by accident (well, surfing =). Andrew Kuchling is too modest to advertise it, but his Python Grimoire is a good document to get a feel for common tasks in Python. It's at: http://starship.python.net/crew/amk/grimoire/ It's a good thing to read just after the tutorial. Cheers, --david ascher From gubitz at netcologne.de Tue Jun 22 09:39:07 1999 From: gubitz at netcologne.de (Hans Gubitz) Date: 22 Jun 1999 15:39:07 +0200 Subject: PhotoImage Message-ID: Python 1.5.1 (#1, Apr 5 1999, 00:08:45) [GCC egcs-2.91.66 19990314 (e on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import Tkinter >>> tk=Tkinter.Tk() >>> image1=Tkinter.PhotoImage(width=2,height=2) Traceback (innermost last): File "", line 1, in ? File "/usr/lib/python1.5/lib-tk/Tkinter.py", line 1768, in __init__ apply(Image.__init__, (self, 'photo', name, cnf, master), kw) File "/usr/lib/python1.5/lib-tk/Tkinter.py", line 1736, in __init__ apply(self.tk.call, TclError: unknown floating-point error, errno = 84 >>> What's wrong? -- Hans Gubitz email: gubitz at netcologne.de From luisroco at hotmail.com Tue Jun 8 17:10:15 1999 From: luisroco at hotmail.com (luisroco at hotmail.com) Date: Tue, 8 Jun 1999 21:10:15 GMT Subject: Using PIL with CGI scripts Message-ID: <7jk0rm$o9ar@eGroups.com> Hi all How can a CGI scripts outputs graphics images through Python code using the Python Imaging Library package? I just want to produce some images which has been processed using PIL and show them in a web site From robin at alldunn.com Tue Jun 22 01:13:38 1999 From: robin at alldunn.com (Robin Dunn) Date: Mon, 21 Jun 1999 22:13:38 -0700 Subject: wxPython under linux References: <7ke110$o4r$1@nntpd.lkg.dec.com> Message-ID: >I've installed the wxPython rpm under RH 6.0 >and I'm having the following problems. > >First, python can't locate the main module. >wx.py is located in /usr/lib/python1.5/site-packages/wxPython. >I've tried adding this path to PYTHONPATH but it >still has no effect. This should work if you are using wxPython as a package, e.g from "wxPython.wx import *". In other words, the wxPython directory does not need to be on the PYTHONPATH, but the directory which contains it. (And the site-packages directory is supposed to be there automagically.) > >Second, I can copy a simply script to the wxPython >directory and run it from there, however, if I'm >under KDE it fails with X-errors. If I switch to >a generic window manager the script runs fine. > I havn't heard of this one. What kind of X-errors? GTK and KDE are supposed to play nice together and I havn't had any troubles in this area. (Though I don't run KDE that often...) -- Robin Dunn robin at AllDunn.com http://AllDunn.com/robin/ http://AllDunn.com/wxPython/ Check it out! Try http://AllDunn.com/laughworks/ for a good laugh. From esuzm at primrose.csv.warwick.ac.uk Sat Jun 19 00:59:58 1999 From: esuzm at primrose.csv.warwick.ac.uk (Andrew Clover) Date: 19 Jun 1999 04:59:58 GMT Subject: Installing ODBC on PythonWin Message-ID: <7kf84e$fog$1@holly.csv.warwick.ac.uk> (References lost due to having to post through a slow newsfeed whilst reading replies in deja.com...) Gordon McMillan soothed my Access pain with: > Repeat after me: "Access is NOT a server, Access is NOT a server". Erm... Access is not a server. I guess. :-) Access is barely competent as a client... > If accessed through ODBC it is most definitely absolutely NOT safe. It's > not even safe for mutiple connections from one process. > Access is dandy on the desktop as an overgrown spreadsheet. It is the LAST > thing you should use for CGI. It would seem so. I knew we'd have to move to a non-cruddy dbms at some point, but I had imagined Access would be able to cope with a single user (viz me) clicking Reload on a CGI page repeatedly. I guess it was naive of me to expect anything much of MS's flagship Office suite... Oh well. I downloaded and installed MySQL and though the process wasn't terribly pleasant, at least the damned thing *works* now. Anyone want to criticise this choice of server/suggest something else? ObPython - actually Ob's-original posting: > I was able to partially install mxODBC by copying all the files into the > right place but I'm having trouble compiling the modules in vc++. > I'm going to pull my hair out!!! Could someone show me an easier way of > installing ODBC? Hmm... earlier whilst trying to figure out what was going on, I DLed mxODBC as a replacement for ODBC, and it worked relatively painlessly - the distribution at http://starship.skyport.net/crew/lemburg/mxODBC-1.1.1.zip included precompiled .pyds so there was no need to compile anything, though it is necessary to include the ODBC directory (and DateTime) in PythonPath somewhere. wwww - wish I weren't working with Windows. -- This posting was brought to you by And Clover. (Sorry.) From claird at Starbase.NeoSoft.COM Tue Jun 29 11:41:00 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 29 Jun 1999 10:41:00 -0500 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> Message-ID: <7lapec$cn0$1@Starbase.NeoSoft.COM> In article , Jeffrey Chang wrote: . . . >Abandoning Tkinter seems a little bit extreme, since there are some >applications for which its event model is well-suited. > >A few weeks ago I needed to build a viewer that displays binary trees >whose branches have variable lengths (actually, phylogenetic trees for >biological data). Since the trees are large, I need to be able to slide >it around the window. In addition, I needed each node to be clickable so >that the user can query for more data. > >Tkinter is very good for that type of thing. All I needed to do was >create a Canvas and then for each node, create an Oval with a callback to >a function that handles node clicks. Tk keeps track of the coordinates of >each Item so that I don't have to. Also, whenever I wanted to move the >tree, all I had to do was: >for widget in self._canvas.find_all(): > self._canvas.move(widget, xoff, yoff) > >Of course, Tk incurrs an overhead by making everything you draw on the >canvas its own object, but for this case, it made thigns a lot easier. . . . I don't get the point of the last paragraph. I think you're saying that good style in canvas programming is in terms of objects; if you're doing a lot of pixel-pushing, then you're in trouble, because Tk wraps even pixels up as objects, with a predictable performance hit. Is that correct? -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From doctorwes at mindspring.com Wed Jun 9 14:07:27 1999 From: doctorwes at mindspring.com (Wesley Phoa) Date: Wed, 9 Jun 1999 11:07:27 -0700 Subject: Using the Windows clipboard in Python References: <7jik35$esd$1@nntp6.atl.mindspring.net> Message-ID: <7jmaou$hdr$1@nntp9.atl.mindspring.net> Small modification: removed 'import win32con' as all I needed were two constants. So the Win32 extensions are no longer required. Also, added the ability to read/write NumPy arrays (via theclipboard.array attribute). Wesley Phoa wrote in message <7jik35$esd$1 at nntp6.atl.mindspring.net>... >This is a preliminary version of a module which lets you exchange data via >the Windows clipboard, either as a string or as a 2D array. For example, >this lets you copy and paste data between Python programs and Excel. From Vladimir.Marangozov at inrialpes.fr Tue Jun 8 13:51:34 1999 From: Vladimir.Marangozov at inrialpes.fr (Vladimir Marangozov) Date: Tue, 08 Jun 1999 19:51:34 +0200 Subject: fork() References: <000601beb1c7$682c6220$559e2299@tim> <7jjghd$9il$1@cronkite.cc.uga.edu> Message-ID: <375D5826.23197692@inrialpes.fr> Graham Matthews wrote: > > Tim Peters (tim_one at email.msn.com) wrote: > : OTOH, in a straightfoward mark-and-sweep GC scheme there will > : at least be a "mark bit" in each object header. So under that, > : or under any form of compacting GC, the *entire live object space* > : will get copied, regardless of whether *you* reference anything in > : it or not. So if RC truly sucks, what does that make GC ? > > But the reality is that copying memory can in fact speed applications > up! Think about locality of reference after you have copied all live > blocks to the start of memory. > True enough. At least, it sounds true and promising ;-) However, locality of reference (LOR) is something quite hard to measure in practice. One has to tweak the kernel to collect some stats on this, and even if one achieves LOR improvements on a partuclar system, say Solaris, it could result in a LOR degradation on Linux or Windows. Not to mention that nowadays nobody wants to play this game... I also thought that Python suffers from very bad LOR, but this is and will remain speculation (as well as statements regarding RC, GC or RC+GC) until someone proves that one strategy is better or worse than the other, in the average case, on the average system. Graham, you said that you won't contribute a RC+GC scheme to Python, despite your positive experience. If you change your mind and consider devoting some spare time to give it a try, I'll devote some spare time to help you with Python's internals and we'll see whether we could come up with something viable, which could compete with the actual RC scheme alone. Does this sound constructive enough? :-) -- Vladimir MARANGOZOV | Vladimir.Marangozov at inrialpes.fr http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252 From tre17 at cosc.canterbury.ac.nz Tue Jun 8 01:01:05 1999 From: tre17 at cosc.canterbury.ac.nz (Timothy R Evans) Date: 08 Jun 1999 17:01:05 +1200 Subject: waste of resources ? References: <375C0F91.1C73E4E3@icrf.icnet.uk> <375C16A9.5ADC4990@icrf.icnet.uk> <375C1FD1.A85565C@aw.sgi.com> Message-ID: Gary Herron writes: > Arne Mueller wrote: > > Im running python 1.5.2b2 on SGI power challange irix64 version 6.5. > > Everytime a child process is created via fork(), it realy does it's job > > but never dies, instead the number of zombie processes (as reported by > > the 'top' program) steadily increases, though I call the sys.exit(0) > > method for the child. Any idea how exit a process without creating a > > zombie? > > > > thanks alot, > > > > Arne > > Yes. The parent process must execute a os.wait() or os.waitpid() in > order for the child process's return code to be sent back to the parent > program. Only after that does the child process (now a zombie process) > actually get eliminated. > > Hope this helps. > > -- > Dr. Gary Herron > 206-287-5616 > Alias | Wavefront > 1218 3rd Ave, Suite 800, Seattle WA 98101 Another thing to note is that when a child process dies the parent will be sent a SIGCHLD signal (I think this also applies if the child process was paused with SIGSTOP). If you just want to ignore the return code of the child process, use code like this: import signal import os def sigchild_handler(signum, frame): os.wait() signal.signal(signal.SIGCHLD, sigchild_handler) This will run os.wait for each child process that exits. You will need to catch the return value of os.wait and inspect it if you care what the process returned or whether it was killed by a signal. -- Tim Evans From larsga at ifi.uio.no Fri Jun 18 10:58:49 1999 From: larsga at ifi.uio.no (Lars Marius Garshol) Date: 18 Jun 1999 16:58:49 +0200 Subject: BiBTeX module? References: <7k950a$hsb@cs.vu.nl> Message-ID: * Frederic Gobry | | I've also started such a project as free software. The parser and | the python interface are working correctly now. My idea was to write | something generic for bibliographic databases, BibTeX being only the | first module. A GNOME interface is also in progress (does some | display but no real edition yet) BTW: an XML version of BibTeX would be very useful. People keep asking for it in XML/SGML newsgroups, and it just plain makes sense, since XML is much better suited for this sort of thing than TeX is. Just an idea. --Lars M. From faria at ppgia.pucpr.br Tue Jun 1 14:32:31 1999 From: faria at ppgia.pucpr.br (Yen) Date: Tue, 1 Jun 1999 15:32:31 -0300 Subject: keeping the fraction...? Message-ID: <000d01beac5d$1c598f40$0301010a@poty> Hi everybody, Is there someway to keep the fraction notation like in CLOS: 5 + 3 = 8 or ( 5/3 + 3/3 = 8/3 ) 3 3 3 Tanx, Henrique Faria faria at ppgia.pucpr.br From delgado at Mathematik.Uni-Bielefeld.DE Wed Jun 16 10:07:28 1999 From: delgado at Mathematik.Uni-Bielefeld.DE (Olaf Delgado) Date: Wed, 16 Jun 1999 16:07:28 +0200 Subject: Newbie again: computing attributes on the fly Message-ID: Hi everybody, here's another couple of questions to the enlightened ones. I'd like to compute certain properties of a class instance only once and store it for future use. I'd like to do those computations on demand only, because some might be really, really expensive. My first try looks like this: class x: def __getattr__(self, attr): import string if string.find(attr, "get_") != 0: val = ( lambda x = getattr(self, "get_"+attr)(): x ) self.__dict__[attr] = val return val else: raise AttributeError("no such attribute") def get_lost(self): return 0 # really, really expensive :) def get_a_life(self): return 1 >>> y = x() >>> y.lost() 0 >>> y.a_life() 1 Here, the lambda is pointless somehow, but hints to a potential desire to add parameter support in the future (which I think I don't need, but who knows?). Question(s): 1) Is this 'good', or at least 'okay' style? 2) Any immediate suggestions for improvement? 3) Has anyone ever bothered to implement a more elegant or more complete approach, which might, for example, include such things as parameters, adding memorization to existing classes, you name it? Thanks for reading, Olaf -- //// Olaf Delgado Friedrichs, Uni Bielefeld, Mathematik Olaf Postfach 100131 (room: V4-109) `=' D-33501 Bielefeld, Germany (phone: +49 521 106-4765) http://www.mathematik.uni-bielefeld.de/~delgado From claird at Starbase.NeoSoft.COM Thu Jun 10 14:35:02 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 10 Jun 1999 13:35:02 -0500 Subject: Why is tcl broken? References: <375F82C7.CF0F0477@iname.com> <375FF969.C879B4CD@iname.com> Message-ID: <7jp0gm$fjd$1@Starbase.NeoSoft.COM> In article <375FF969.C879B4CD at iname.com>, Fernando Mato Mira wrote: . . . >About the Connoly one, the namespace issue seems to >be solved by [incr Tcl]. But what about that "interpreted >multiple times"? Is it just an efficiency issue, or a semantic >nightmare (maybe both)? . . . It's a different, but no less defensible, choice for quoting rules than the one LISP made. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From holger at phoenix-edv.netzservice.de Fri Jun 25 05:26:54 1999 From: holger at phoenix-edv.netzservice.de (Holger Jannsen) Date: Fri, 25 Jun 1999 09:26:54 GMT Subject: glint? References: <376F48B9.133D37C6@phoenix-edv.netzservice.de> Message-ID: <37734B5E.B01510C6@phoenix-edv.netzservice.de> Hello Karl, we just like to have a nice and easy tool written in python to install our different products on different platforms like WinNT, Win9X, Linux. I started to write python-code a few weeks ago. I couldn't imagine what a great publicity that language has. So I began to write my own tool without looking for ready solutions. Inside this book of Himstedt/M?tzel I found this notice about RedHat, but I don't think, it's that what we need. ... glint -- (Version 2.4.2, 429K) Glint is a graphical interface to the RPM package management tool. It allows you to browse packages installed on your system, verify and query those package. It allows allows you to update packages with new versions and install new packages. ... We don't like to manage RPM-packages. We need to untar/unzip many files from installation medium, create directories, set registry-entries or environments, links and so on... If we decide, that the tool is ready for public, we'll open source, I think. Then you could get a look at it, and perhaps it may be useful for somebody. But don't expect too much, I'm a newbie in python, and there may be many objects that you may be have done in a better way...;-) ciao, Holger Jannsen www.phoenix-edv.com Karl Eichwalder schrieb: > > Holger Jannsen writes: > > | I'm working on an installation-tool for linux/win without any > | graphical interface but file-controlled. > > How do you define "installation-tool"? There's "xrpm" that's able to > (de)install RPM packages nicely, and more. But "xrpm" has a GUI, too. > > It comes with SuSE Linux. > > -- > Karl Eichwalder From thstr at serop.abb.se Tue Jun 1 01:32:09 1999 From: thstr at serop.abb.se (Thomas S. Strinnhed) Date: Tue, 01 Jun 1999 07:32:09 +0200 Subject: More questions on dll's Message-ID: <37537059.C87856A9@serop.abb.se> Hi I'm embedding Python in another app, but I still want to run the interactive loop. (so I do) But, when I try to import a module (from the prompt or using PyRun_SimpleString() the trouble starts: only .py/.pyc files are found!! My .dll's just won't be imported, no matter what I append to sys.path or what directory they are in. Using Python in it's not embedded shape everything is OK, my .dll's are imported without fuzz an their functions are ready to use. I run on WinNT and MSVC++. That's what i used to build Python15 dll's and libs, my own dll's and the app with Python embedded. *And* (listen to this) I think this problem was not here from the beginning, as I recall I could import dll's as late as yesterday!! So if anyone knows what VC++-checkbox I've accidently touched; Please help me out on this one!! Desperately Thanking You -- Thomas S. Strinnhed, thstr at serop.abb.se From evan at tokenexchange.com Fri Jun 11 10:42:52 1999 From: evan at tokenexchange.com (Evan Simpson) Date: Fri, 11 Jun 1999 09:42:52 -0500 Subject: fork() References: <000c01beb3c1$a3f428a0$329e2299@tim> <199906110443.AAA02408@eric.cnri.reston.va.us> Message-ID: Sounds good to me, if the mechanism reports/logs cycles in such a way that you can figure out how to cleanly break them or avoid making them in the first place (#10 Errors should never pass silently). Perhaps I'm being naive, but I have the impression that when cycles arise it's usually a simple accident and easy to fix once you know you've done it. The hard part is noticing that you've pinched one off, yes? If a cycle is really hard to eliminate without contorting your code, you could make an explicit decision to allow it to be collected and make sure the affected objects don't need finalization (#11 Unless explicitly silenced). Would it be possible (and not too expensive) to distinguish actual cycle members from dangly bits (maximal non-cyclic subgraphs)? If so, it might be worth releasing the dangly bits normally through their root object after flushing the cycle. That way you could have cycles in a program yet still have a place to put resource finalizers. Tim-will-regret-those-20-Theses-yet-ly y'rs Evan Simpson Guido van Rossum wrote in message <199906110443.AAA02408 at eric.cnri.reston.va.us>... Could we get away with not calling (user) finalizers on objects in trash cycles at all? Since the finalization order is problematic at best, this almost seems acceptable: in the formal semantics, objects that are part of cycles would live forever, and as an invisible optimization we recycle their memory anyway if we know they are unreachable. (I've got the feeling that I've seen this rule before somewhere.) We'd still get complaints "my __del__ doesn't get called" from some users, and the answer would still be "it's in a cycle -- use an explicit close"; but those who know what they are doing can be guaranteed that their memory cycles get recycled. In other words it would be no worse than today and for some people it would be better. From arcege at shore.net Wed Jun 23 06:50:26 1999 From: arcege at shore.net (Michael P. Reilly) Date: Wed, 23 Jun 1999 10:50:26 GMT Subject: creating dictionnaries References: <376F82A6.82497D2B@der.edf.fr> Message-ID: Michael Hudson wrote: : "Michael P. Reilly" writes: :> Christian Caremoli wrote: :> : Hi, :> : Dictionnaries can be created like that : :> : d={'a':1,'b':2} :> :> : By calling a function you create a dictionnary like that : :> : def f(**d): :> : return d :> :> : d=f(a=1,b=2) :> :> : I would like to be able to create dictionnaries with some similar syntax :> : like keyed tuples : :> : d=(a=1,b=2) :> :> : Is there a way to do that ? :> :> In a word, No. The structure of the language would perform a namespace :> lookup on "a" and "b" instead of taking them as strings. Also a tuple :> is still an expression, and Python does not allow assignments inside :> expressions. This means that you would get a SyntaxError exception :> during bytecode compilation. And even if you didn't, it would be :> likely that you would get a NameError exception. :> :> -Arcege :> :> Note: I haven't looked at bytecodehacks, but that might let you do what :> you wish. Since it would be extremely non-portable, I wouldn't suggest :> it for published or long-term code. : What? byecodehacks can't affect syntax! I'm quite proud of that bit of : code, but lets not blow it up into things it just isn't... : yours, : Michael I only said might.. my thought was to splice a CALL_FUNCTION op in where the expression was. I did say that I haven't looked at the module so I wasn't sure of it's capabilities, or if it worked inside the parser or in the eval loop, but it seemed to be a reasonably possible capability. -Arcege PS: From what I've heard of the module, you should be proud of it. From bwinton at tor.dhs.org Wed Jun 9 23:50:13 1999 From: bwinton at tor.dhs.org (Blake Winton) Date: Thu, 10 Jun 1999 03:50:13 GMT Subject: Python 2.0 References: <000801beb2e8$05e98760$af9e2299@tim> Message-ID: On Wed, 9 Jun 1999, Tim Peters wrote: >[Graham Matthews] >> There are two obvious answers to almost all the above problems in >> Python >> a) don't call finalisers for circularly referenced collected objects. >> Instead just collect their memory. This is not perfect but better >> than current Python which doesn't run finalisers on circularly >> referenced objects nor collect their memory. >Solve the problem by ignoring it? Guido would find that more >attractive than I would . If so, then he would have given up on this thread a long time ago... Later, Blake. -- One Will. One Dream. One Truth. One Destiny. One Love. From scothrel at cisco.com Wed Jun 9 12:40:03 1999 From: scothrel at cisco.com (Scott Cothrell) Date: Wed, 9 Jun 1999 11:40:03 -0500 Subject: [Thread-SIG] RE: tstate invalid crash with threads References: <000101beb237$88b71d80$999e2299@tim> Message-ID: <003201beb296$b9be7d60$d5a245ab@cisco.com> I can confirm that we were seeing similar behavior under a highly threaded, highly stressed situation. We backed off on the number of threads and slowed things down as a workaround also. We couldn't trace it down to Python, as we have a Java, C, Python mix that has too many suspects. Scott Cothrell Cisco Systems, Inc. ----- Original Message ----- From: Tim Peters To: Ray Loyzaga ; Guido van Rossum ; Thread-SIG Cc: Sent: Wednesday, June 09, 1999 12:18 AM Subject: [Thread-SIG] RE: tstate invalid crash with threads > Followups to the Thread-SIG, please. > > [Ray Loyzaga] > > I have been playing with a multithreaded tcp based server for a while, > > and during some serious stress testing continually hit a problem > > involving the interpreter crashing with "Fatal Python error: > > PyThreadState_Delete: invalid tstate". > > ... > > It appears to be a subtle race in PyThreadState_Delete .... > > interestingly, if I uncomment the small sleep in "handle" in the server, > > ie. make the server slower, it seems to work for ever ... 4m transactions > > before I gave up. I think the problem only comes if you are creating and > > destroying threads quickly in parallel. > > PyThreadState_Delete is called from very few places, and one of them strikes > me as suspicious: at the end of threadmodule.c's t_bootstrap, we have: > > PyThreadState_Clear(tstate); > PyEval_ReleaseThread(tstate); > PyThreadState_Delete(tstate); > PyThread_exit_thread(); > > The suspicious thing here is that PyEval_ReleaseThread releases the global > interpreter lock, so nothing is serializing calls to PyThreadState_Delete > made from the following line. PyThreadState_Delete in turn does no locking > of its own either, but mutates a shared list. > > If this isn't plain wrong, it's certainly not plain right . Matches > your symptoms, too (very rare blowups during high rates of thread death). > > Guido? I haven't been able to provoke Ray's problem under Win95, but the > above just doesn't smell right. > > win95-didn't-crash-but-the-TAB-and-ESC-keys-did-swap-their- > meanings!-ly y'rs - tim > > > > _______________________________________________ > Thread-SIG maillist - Thread-SIG at python.org > http://www.python.org/mailman/listinfo/thread-sig > From ivanlan at callware.com Wed Jun 9 19:17:57 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Wed, 9 Jun 1999 23:17:57 GMT Subject: getargs.py Message-ID: <375EF625.8D265AD1@callware.com> Hi All-- I did some cutting and pasting, and put together a doc page for getargs.py. You can find it at: http://www.pauahtun.org/getargs.html The downloadable file includes getargs.py, testarg.py and getargs.html. The doc is not great, but it does exist. The nameserver for www.pauahtun.org is now back online, so anyone who had problems accessing the site should no longer have those problems. And the ftp daemon is running again, although it's not my registered copy--that's at home, & I have to bring that in. So anyone who happens to read the ftp daemon welcome message rest assured that I do not need to be urged to support shareware. -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From MHammond at skippinet.com.au Thu Jun 17 18:28:24 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Fri, 18 Jun 1999 08:28:24 +1000 Subject: wierdness with pythonwin dialogs, threads & refcounts References: <3768b75e.5469224@NNRP.UK.INSNET.NET> Message-ID: <7kbsn1$dno$1@m2.c2.telstra-mm.net.au> There could be a number of leaks in Pythonwin, but I dont think dialogs do. The ref count is likely to be 6, as the pywin.mfc.Dialog base class hooks a number of commands and messages. Each of these hooks is a circular reference, as a bound method is saved away. These references are deleted when a window recieves the WM_DESTROY message. So in a nutshell, there is nothing obvious as to why the dialog is leaking. The very first step would be to ensure it does not leak without threads. Otherwise, it may come down to me tracking this down, as there are some complicated interactions with MFC going on... Finally, there is a "threadedGui.py" (or something) that should demonstrate how to create "native Pythonwin threads". However, now that we have the threading module, there really isnt any real advantage to using Pythonwin threads over threading. Mark. Dave Kirby wrote in message <3768b75e.5469224 at NNRP.UK.INSNET.NET>... > >I have found strange behaviour (strange to me at least) when creating >a pythonwin dialog on a separate thread created using the standard From schorsch at schorsch.com Fri Jun 18 08:15:09 1999 From: schorsch at schorsch.com (Georg Mischler) Date: Fri, 18 Jun 1999 12:15:09 GMT Subject: do anonymous pipes normally work on NT? References: <4D0A23B3F74DD111ACCD00805F31D8100DB90DE4@RED-MSG-50> <7kbq78$vgm$1@nnrp1.deja.com> <7kckoh$ith$1@m2.c2.telstra-mm.net.au> Message-ID: <7kdd87$fnt$1@nnrp1.deja.com> Mark Hammond wrote: > Inside win32_src.zip you should find win32process.i and > win32processmodule.cpp - the latter is generated by SWIG from > the former. > > Bill is working from the same archive, so it must be there! Do I need to swig this stuff myself? or... > The only thing I can think of is that you didnt grab the > archives from my starship page... Uh, indeed. Are the source packages on www.python.org so heavily out of date? Someone might want to update them in that case. The binary package is obviously build 125, but a quick search didn't reveal the "build" number of the sources. I'll get them from the starship in any case to make sure it's the real thing. Thanks a lot! -schorsch -- Georg Mischler -- simulation developper -- schorsch at schorsch.com +schorsch.com+ -- lighting design tools -- http://www.schorsch.com/ Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From vlachid at otenet.gr Fri Jun 25 04:51:19 1999 From: vlachid at otenet.gr (Vlachidis Costas) Date: Fri, 25 Jun 1999 11:51:19 +0300 Subject: Newbie questions Message-ID: <37734307.DD77AA30@otenet.gr> Hi all After examining all python related modules ,I decided to use graphapp package in C language mixed with python scripts, to a project that I,m working on . My problem is that I never have enough time to read all related python documentation,So I appreciated any help in the following (in the graphapp package) . 1)With the askfilesave dialog box the scrollbar button sticks and fill all scrolling area after pressing once the scrolling buttons. Is there some tip in the dialog.c distribution file able to resolve this problem? 2)I'm not able to make newsubmenu function working properly.Can someone tel me how to use it in the midle of a menu, show submenu items and then show the rest of the parrent menu items?I thing thatit is a object handling related problem. 3)How to colorise menu items background? 4)Finaly how to make a python script call (in my case some openfile.py script) from inside a myprogramm.c file? Best regards Costas -------------- next part -------------- A non-text attachment was scrubbed... Name: vlachid.vcf Type: text/x-vcard Size: 366 bytes Desc: Card for Vlachidis Costas URL: From smjoshi at bellsouth.net Sat Jun 12 11:30:16 1999 From: smjoshi at bellsouth.net (SunitJoshi) Date: Sat, 12 Jun 1999 10:30:16 -0500 Subject: Raw Strings! Message-ID: Hi All If someone could show me how to use raw-strings with variables, I would really appreciate it. For e.g.: if str_path = "C:\\windows\\temp" thanks Sunit From hniksic at srce.hr Thu Jun 3 04:53:22 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 03 Jun 1999 10:53:22 +0200 Subject: pickle vs .pyc References: <7j43pn$55l$1@mlv.mit.edu> <87vhd69tdm.fsf@pc-hrvoje.srce.hr> Message-ID: <87k8tl7ji5.fsf@pc-hrvoje.srce.hr> Michael Hudson writes: > Yes, but usually you get an exception to show that somethings gone > awry: > > >>> import md5 > >>> marshal.loads(marshal.dumps(md5.md5())) > Traceback (innermost last): > File "", line 1, in ? > ValueError: unmarshallable object A good point. However, that is exactly the kind of behaviour I get for array objects -- in Python 1.5.1. In 1.5.2, I can repeat the bug you describe. Maybe 1.5.2 is supposed to allow marshalling arrays, but the support is buggy? OK, I think I got it. In 1.5.2, marshal.c contains this code: else if ((pb = v->ob_type->tp_as_buffer) != NULL && pb->bf_getsegcount != NULL && pb->bf_getreadbuffer != NULL && (*pb->bf_getsegcount)(v, NULL) == 1) { /* Write unknown buffer-style objects as a string */ char *s; w_byte(TYPE_STRING, p); n = (*pb->bf_getreadbuffer)(v, 0, (void **)&s); w_long((long)n, p); w_string(s, n, p); } ...which means that objects with tp_as_buffer property (whatever that means) get marshalled as strings. This wasn't the case in 1.5.1 and I have no idea why it would be useful to anyone because during unmarshalling, such simply remain strings instead of getting converted to the original form. Not that the conversion would work across different architectures anyway. I'm not sure what the new feature is supposed to buy us, but 1.5.1 behaviour looks more correct to me. From jtravs at debian.org Tue Jun 22 15:21:17 1999 From: jtravs at debian.org (John Travers) Date: Tue, 22 Jun 1999 20:21:17 +0100 Subject: PyOpenGl problem Message-ID: <99062220260100.01217@Vegus> I have compiled PyOpenGl and installed it but whenever I run a demo I get: File "./trees.py", line 1 in ? from oglpm import * File "./oglpm.py", line 4, in ? from OpenGL.GL import * File "/usr/lib/python1.5/site-packages/OpenGL/GL/__init.py", line 4, in ? from opengl_num import * ImportError: /usr/lib/libMesaGL.so.3: undefined symbol: XFreePixmap. Is this the wrong version of mesa or something? -- John Travers "Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us!" From MHammond at skippinet.com.au Tue Jun 1 19:26:05 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Wed, 2 Jun 1999 09:26:05 +1000 Subject: Windows Stack Size References: <3752C225.65C98B52@cloud9.net> <3752F154.6C444928@ricochet.net> <375413D8.C3B02D2@cloud9.net> Message-ID: <7j1q41$3fu$1@m2.c2.telstra-mm.net.au> >AFAIK, the code is not recursive (sometimes with GUI callbacks, you can >get a lot deeper into the stack than you might expect :-). It's been >running fine under Linux for months, but under Win 95 it traps >consistantly in some windows, _but not in all of them_, which is why I >thought there might be a tiny-stack issue. 1 meg should be plenty of >room. In this case, you definately would appear to have an infinite recursion bug. Fixing the stack size will mean it just takes longer to crash :-) > def __getattr__(self, attr): > if self.text: > return getattr(self.text, attr) > else: > raise AttributeError(attr) > >Upon further consideration, I wonder if the getattr could have something >to do with this. Certainly a good cause of accidental death by recursion. For example, had your code used "self.test" (ie, made a typo on "self.text") you would recurse infinitely, as you would trigger a __getattr_ for the attribute name. However, as you dont have a __setattr__ and you define self.text in __init__, this *looks* fine to me. However, a few well-chosen print statements in __getattr__ would make this immediately obvious. Also, the death should take a few seconds to occur - try hitting Ctrl+C in this period - you may get a traceback telling you exactly where the problem is. >I'd debug it myself except that I'm happily Windows-free (only creates >problems when I have to write code for Windows users). If there is no >obvious answer, I have a work-around. And what would the work-around be? Mark. From tim_one at email.msn.com Fri Jun 18 17:13:34 1999 From: tim_one at email.msn.com (tim_one at email.msn.com) Date: Fri, 18 Jun 1999 21:13:34 GMT Subject: error? inconsistent dedent References: <376A6796.814CBA24@phoenix-edv.netzservice.de> Message-ID: <7kecpk$snf$1@nnrp1.deja.com> In article <376A6796.814CBA24 at phoenix-edv.netzservice.de>, Holger Jannsen wrote: > Couldn't understand following error: > > C:\myPython>installation16.py -x -d test > inconsistent dedent > File "C:\myPython\installation16.py", line 619 > opts, args = getopt.getopt(sys.argv[1:], 'x') > ^ > SyntaxError: invalid token > > What does 'inconsistent dedent' mean? > Why does that error occur? Because you're running with the -x switch, the line number in the traceback is off by 1, and it's not showing the correct line either. This is fixed in the current development version of Python, but didn't make it in time for the 1.5.2 release. Go into your source file and look at the lines *next* to the line it's showing you here. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From adjih at technologist.com Thu Jun 3 08:35:51 1999 From: adjih at technologist.com (adjih at technologist.com) Date: Thu, 03 Jun 1999 12:35:51 GMT Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <7j450j$908$2@cronkite.cc.uga.edu> Message-ID: <7j5sr7$eb4$1@nnrp1.deja.com> In article <7j450j$908$2 at cronkite.cc.uga.edu>, graham at sloth.math.uga.edu (Graham Matthews) wrote: > Martijn Faassen (faassen at pop.vet.uu.nl) wrote: > : This sounds like an interesting idea; I believe I saw references to > : garbage collecting schemes that help clean up circular references caused > : by referencing counting. I forget where, though. :) > > Here. I posted comments in this thread and in a similar thread about > such systems. They are generally all variations on mark and sweep > collection. The more efficient ones use colouring. > > Martijn Faassen (faassen at pop.vet.uu.nl) wrote: > : * In the complex case, garbage collecting is nice as it cleans up > : circular references. There are unwanted side-effects of its > : unpredictability, though; a possible leaking of resources (files which > : aren't closed), and some difficulties interfacing with C. > > I don't buy either of these difficulties since I have worked with and > implemented systems which have full garbage collection and have no > problems interfacing to C, or dealing with resources like files. But there will be cases where full garbage collection will be definitly a nuisance. First, you must scan all the address space of the C code, which can be a problem if you're just using the Python interpreter in a library (i.e. don't have the ability to control or modifying the main program) ; or if your address space is too big (I use python for instance in a program that does an mmap of a 350 MB file). Second you kill the portability: you could use a subset of Python with ANSI-C alone ; but you can't make a incremental GC in ANSI-C. You'd get problems when embedding Python in unusual environments ; for instance if you embed Python in the Linux kernel, then the GC should also trace all the pages in the swap, or be rewritten specially for that case. The advantages of GC must be traded with its drawbacks: - advantages: reclaims cyclic structures. - drawbacks: non-portable, requires a special handling when linking with C, high complexity for decent GC (multi-thread incremental with finalization and support for C/C++ structures referencing Python structures). Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From fw at cygnus.stuttgart.netsurf.de Mon Jun 7 14:38:53 1999 From: fw at cygnus.stuttgart.netsurf.de (Florian Weimer) Date: 07 Jun 1999 20:38:53 +0200 Subject: fork() References: <375BE64A.EB997F24@icrf.icnet.uk> Message-ID: Arne Mueller writes: > All that woks fine now (after I spend a long time fiddling with the pipe > and select stuff to synchronize I/O). However the forking is a waste of > time and memory because all the children get their own large dictionary! > Is there a way to use shared memory in python, I mean how can different > processes access (for read only) one object without passing the keys of > the dictionary object through a pipe (the children need _quick_ access > to that dictionary)? If you've got a modern operating system, fork() doesn't copy the whole address space at once, the memory is shared as long as it is not modified. Unfortunately, even if you only fetch an object from a dictionary, Python is writing to previously shared memory behind the scene (because the reference counts are updated). This means that the memory sharing mechanism of the operating system doesn't work. I hope others will have better suggestions than I. First of all, you should be sure that you cannot solve this problem by throwing more RAM on it. RAM is so cheap these days, so it might be too expensive to spend hours on optimizing your program. (This obviously depends on the purpose of your program.) My second, more serious suggestion: Put the data contained in the objects stored in the dictionary into a C struct, write a simple C implementation of a hash table which stores those structs and a lookup function which creates suitable Python objects on the fly. This way, there are no reference counts which are perpetually updated and thus break he copy-on-write scheme, so the main data structure can be shared efficiently among the processes. Another solution is probably a Python version using the Boem garbage collector which gets rid of the reference counts as well. There are some patches floating around, but I don't know whether they are suited to recent Python releases or production use. From adjih at technologist.com Sat Jun 5 09:26:00 1999 From: adjih at technologist.com (adjih at technologist.com) Date: Sat, 05 Jun 1999 13:26:00 GMT Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7iqhkb$d7s@wiscnews.wiscnet.net> <7iu7ma$d33$1@cronkite.cc.uga.edu> <02hfonzsx2.fsf@rtp.ericsson.se> Message-ID: <7jb8h5$7rb$1@nnrp1.deja.com> In article <02hfonzsx2.fsf at rtp.ericsson.se>, Kumar Balachandran wrote: > > > >>>>> "Graham" == Graham Matthews writes: > > Graham> Graham Matthews wrote in message > Graham> <7ik6mi$lbk$1 at cronkite.cc.uga.edu>... > Graham> You are envangelising (a not uncommon response when > Graham> someone remotely criticises Python). Stop evangelising and > Graham> start considering the technical issues involve (read (!) > Graham> other posts for what those issues are). > > Graham> graham > Here is some useful evangelizing (methinks). One of the irritating things about > Python is the use of whitespace in syntax. Agreed, the code is > readable without parentheses or braces, but why not have optional > syntactic sugar such as > > if > ... > elif > ... > else > ... > fi > > def > ... > ... > fed > > while > ... > elihw or wend > > for > ... > rof > > etc. It makes the language more elegant. When I see code using > indentation or blank likes to achieve blocking of constructs, it > reminds me of an old language (FORTRAN I think it was called:-). > > The change is simple to achieve if backward compatibility is given to > accomodate people that grew up with FORTRAN. As I just responded in the "Alien whitespace eating nanovirus strikes again!" it is possible, although this will be only advisory (Python will only rely on white space). All you need to do is to write: fi,fed,elihw,wend,rof=0,0,0,0,0 and then you could write for i in range(100): if i%5==0: print "%d is divisible by 5" %i fi rof -- Cedric Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From Cepl at fpm.cz Mon Jun 7 05:32:05 1999 From: Cepl at fpm.cz (Matej Cepl) Date: Mon, 7 Jun 1999 10:32:05 +0100 Subject: bug in os.path.samefile (Python 1.5.1)? Message-ID: <1318D78C9072D11195C9006094EA98A72C20EF@ocesrv> Hi, trying to finish my port of sitemap.py (for original Sitemap.pl from ESR see http://www.tuxedo.org/%7Eesr/sitemap-1.9.tar.gz for it), I am not able to debug the attached procedure. There is a huge dictionary, where key is abspath of the file and content is list of some stuff to be pressented in the page. This procedure walks through this dictionary (recursively) and make the writings into output HTML. Now, I need to check whether the processed file is in the "current" directory or I should make steps to make recursive calling on another directory. I guess, that the best way how to do it, is by calling os.path.samefile(os.path.dirname(full_name),base) {see below for context). However, Python 1.5.1 (I cannot use 1.5.2 not having administrator's rights on WinNT 4.0 WK) complains by following report: --------------------------- C:\Program Files\Python\Contrib\SiteMap>python report.py > neco.txt Traceback (innermost last): File "report.py", line 121, in ? P = ReportPage(List,"","f:\\website\\",1) File "report.py", line 22, in __init__ self.generate() File "html_page.py", line 44, in generate self.generate_body () File "report.py", line 67, in generate_body if os.path.samefile(name,base): File "C:\Program Files\python\lib\ntpath.py", line 197, in samefile s2 = os.stat(f2) os.error: (2, 'No such file or directory') --------------------------- Do you have any idea, what's up (ntpath.samefile seems to be OK) and what should I do (please, do not recommend me 1.5.2)? Thanks Matthew --------------------------- def generate_body(self,base="",curIndex=0): """ prepare the list of all material in one directory and its subdirectories """ if base == "": base = string.lower(self.total_base) LCDir = len(base) Index = curIndex LenDict = len(self.klice) B = 1 self.f.write("" + base + "\n") self.prlog("Base = " + base) self.f.write("

\n") while ((Index + 1) <= LenDict) and B: full_name = string.lower(self.klice[Index]) self.prlog("Full_name = " + full_name) name = os.path.dirname(full_name) self.prlog("Shortened name = " + name) # THIS SEEMS TO BE A PROBLEM!!! ******** if os.path.samefile(name,base): # there is not dirname in name, therefore we can # printout current file information filetitle = self.WholeDict[full_name][0] filedesc = self.WholeDict[full_name][1] if filetitle <> "": self.f.write ("
") self.f.write ("") self.f.write (filetitle) self.f.write ("
\n") self.f.write ("
" + filedesc + "
\n") Index = Index + 1 else: # there is a dirname in a name next_base = string.lower(os.path.dirname(full_name)) self.prlog("Next dir is " + next_base) self.f.write("
\n") self.f.write ("
  • ") self.generate_body(next_base,Index) B = 0 From mgm at unpkhswm04.bscc.bls.com Wed Jun 23 10:19:04 1999 From: mgm at unpkhswm04.bscc.bls.com (Mitchell Morris) Date: 23 Jun 1999 14:19:04 GMT Subject: It's just magic, and I hate it ... References: <14190.35530.772547.166720@buffalo.fnal.gov> <37703621.B29B72CB@bioreason.com> Message-ID: In article <37703621.B29B72CB at bioreason.com>, Andrew Dalke wrote: [snip] > > 2) in the web server. From the Apache FAQ >http://www.apache.org/docs/misc/FAQ.html#nph-scripts > that's likely not the case because versions 1.3 and later don't >do an intermediate buffer, but you didn't say what web server >you are using nor the version number. That documentation may >describe what to do. > [snip] > > Andrew > dalke at acm.org Aha! A clue! It's an old Apache, v1.2.6, as it turns out. You may have saved my few remaining shreds of sanity! Thanks for the pointer, +Mitchell -- Mitchell Morris My wife and I married for better or worse ... I couldn't do better and she couldn't do worse From tismer at appliedbiometrics.com Mon Jun 28 07:09:09 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Mon, 28 Jun 1999 11:09:09 GMT Subject: ANN: Stackless Python 0.2 References: <37628EAA.C682F16C@appliedbiometrics.com> <7l6gc8$du4$1@news.tamu.edu> Message-ID: <377757D5.25A2AFF6@appliedbiometrics.com> Corran Webster wrote: > > In article <37628EAA.C682F16C at appliedbiometrics.com>, > Christian Tismer wrote: > >ANNOUNCING: > > > > Stackless Python 0.2 > > A Python Implementation Which > > Does Not Ese The C Stack > > > >What is it? > >A plugin-replacement for core Python. > >It should run any program which runs under Python 1.5.2 . > >But it does not need space on the C stack. > [snip] > > I managed to get this to build eventually (thanks to the hints from Michael > Hudson). Looking at it, I wonder whether there's the potential here for > more than coroutines and to write an implementation of threading within > Python. Each thread would presumably need its own Python stack, and a > queueing and locking system would need to be added somehow, but because > the Python and C stacks are no longer intertangled, switching between > threads should be easy (as opposed to impossible ). Please be a little patient. :-) Yesterday I finished an alpha version of first class continuations in Python. This allows you to do everything, and your threads are on my todo-list from the first time. > This wouldn't be quite as flexible as the current implimentations of > threads at the C level - C extensions would be called in a single block > with no way to swap threads until they return. On the other hand, this > would allow every platform to have some sort of threading available, > which would be a boon. Not really. C extensions can be written in a stackless manner. Whenever they need to call into the interpreter, they can do it in a conformant manner. They do so by just using their own frame with their own executor. You need to change your thinking here: There is no return in that sense any longer. We just have frames in some chains, and all local state is kept in frames. > Unfortunately I'm not familiar enough with threads to go out there and > implement it right away, but I thought I'd at least raise it as a > possibility and see what people think and what the pros and cons are. It will be available soon, and it will be nothing more than a Python module which tames continuations to behave as threads. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From kas at maps.magnetic-ink.dk Sun Jun 20 12:05:38 1999 From: kas at maps.magnetic-ink.dk (Klaus Alexander Seistrup) Date: Sun, 20 Jun 1999 18:05:38 +0200 Subject: Questions? Time Module? References: Message-ID: <376D1152.DC59E2BC@maps.magnetic-ink.dk> Benjamin Schollnick wrote: > I'm trying to figure out where the "time" functions are > stored, but GREP isn't finding anything in the \lib directory??!?!? It's in the binary timemodule. //Klaus -- ???[ Magnetic Ink ]????????????????????????????????????????????????????????? ???[ http://www.magnetic-ink.dk/ ]?????????????????????????????????????????? From holger at phoenix-edv.netzservice.de Fri Jun 18 11:36:54 1999 From: holger at phoenix-edv.netzservice.de (Holger Jannsen) Date: Fri, 18 Jun 1999 15:36:54 GMT Subject: error? inconsistent dedent Message-ID: <376A6796.814CBA24@phoenix-edv.netzservice.de> Couldn't understand following error: C:\myPython>installation16.py -x -d test inconsistent dedent File "C:\myPython\installation16.py", line 619 opts, args = getopt.getopt(sys.argv[1:], 'x') ^ SyntaxError: invalid token What does 'inconsistent dedent' mean? Why does that error occur? Thanx, Holger From fdrake at cnri.reston.va.us Tue Jun 15 16:57:17 1999 From: fdrake at cnri.reston.va.us (Fred L. Drake) Date: Tue, 15 Jun 1999 16:57:17 -0400 (EDT) Subject: Newbie: Truth values (three-valued logic) In-Reply-To: References: Message-ID: <14182.48685.82121.105521@weyr.cnri.reston.va.us> David Ascher writes: > Actually, after looking at the documentation for the operator module, I > think that there's a documentation problem -- reading it, one would think > that there is a __not__ special method, but it is not supported by the > core. I think a special comment should be added to the doc to that Done. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From sass at dresearch.de Tue Jun 22 04:17:46 1999 From: sass at dresearch.de (Daniel =?iso-8859-1?Q?Sa=DF?=) Date: Tue, 22 Jun 1999 10:17:46 +0200 Subject: How to call a Java superclass from jpython ?? References: <376E9415.8E002ACA@t-online.de> Message-ID: <376F46AA.67E2ADF2@dresearch.de> "Markus A. Greiner" wrote: > > Hello, > > I?m trying to port some java applications into jpython. > Now I got a problem. I?m not able to call a java superclass from > jpython. > Did anybody know how to call them? Here the code I?m trying to convert: > > It?s from PropertiesMetalTheme.java of the JDK Metalworks example. > In method initcolors: > > ... > primary1 = super.getPrimary1() > > Everything I tried in jpython failed. In some other cases replacing the > super call into a construct like: > > ... > ParentClass.method(self) > > works fine, but in this case > > ... > DefaultMetalTheme.getPrimary1() > > and all other constructs failed. I?m using JPython 1.1 beta 2 so > calls like self.super__method are obsolte and didn?t work anymore. > (I think :-)) or better I tried without success) > > Thanks Markus You try to call a protected method. This problem should be fixed in JPython 1.1. -- Daniel Sass From fdrake at cnri.reston.va.us Thu Jun 17 12:52:42 1999 From: fdrake at cnri.reston.va.us (Fred L. Drake) Date: Thu, 17 Jun 1999 16:52:42 GMT Subject: HTML bettering? In-Reply-To: References: <1318D78C9072D11195C9006094EA98A72C214D@ocesrv> Message-ID: <14185.10202.444275.557283@weyr.cnri.reston.va.us> Lars Marius Garshol writes: > You could very well use htmllib and just make an htmllib application > that writes the HTML back out again, and modify it slightly to do > heading numbering. I don't think HTMLFormatter would do you any good > for this sort of thing. Or you could add a skip=0 or seqnum=1 attribute to the first H? element, and then use Grail to display it all... ;-) (If Grail detects header sequence information, it turns on auto-numbering. Kinda neat! ;) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From faassen at pop.vet.uu.nl Wed Jun 2 05:27:28 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Wed, 02 Jun 1999 11:27:28 +0200 Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7iqhkb$d7s@wiscnews.wiscnet.net> <7iu7ma$d33$1@cronkite.cc.uga.edu> <007901beac05$5c964b00$f29b12c2@pythonware.com> <7j0un1$2dm$2@cronkite.cc.uga.edu> Message-ID: <3754F900.D742FB67@pop.vet.uu.nl> [Gang Li is against Python on top of the JVM] [Graham says you're just evangelizing] [Fredrik replies Gang Li did say something: Python not on Java, and offers some statistics on what developers do now] Graham Matthews wrote: > The only "reasons" he offers > for why Python shouldn't be "tied to Java" are all hyperbole and > evangelism. No technical content whatsoever. Please read my own reply about strategical arguments, which are in my opinion important as well, along with technical arguments. You offer some strategical arguments for building Python on top of Java, after all. For instance, the argument that building Python on top of the JVM is good because of continued heavy development in speeding up the JVM is not a purely technical argument, but also a strategical one. My post didn't have much technical content but seems well-reasoned and not overly evangelical, I think. I do agree Gang Li's arguments appeal to emotions a bit too much, but after all I'm butting in on you being involved in an emotional interchange yourself right now. :) (i.e. "But then again I should have known better than to start such a thread.") So let's try to calm down a little and go back to the technical and strategical concerns behind our emotions. And emotions aren't that bad after all, as long as we recognize that they're that, instead of shining rationality. :) Emotions-are-useful-ly yours, Martijn > Graham Matthews wrote: > > Stop evangelising and start considering the technical > > issues involve (read (!) other posts for what those issues > > are). > Fredrik Lundh (fredrik at pythonware.com) wrote: > : exactly. and since you seem to imply that you have con- > : sidered those issues, maybe you should follow up on some > : of the "non-envangelising" posts instead of miscrediting > : people who don't happen to agree with you? > > I have followed up Fredrik -- cf. posts on classes of references (some > compactable, some not), colouring mark and sweep collectors, JNI, etc. > But then again I should have known better than to start such a thread. > > graham > > -- > This mountain is not visible from any inhabitable place. > It has no name, and since it's discovery in 1856 by a > British survey team, it has mysteriously resisted every > attempt to name it. The mountain is known simply and starkly > by it's original designation on the surveyor's map ... K2. From graham at sloth.math.uga.edu Thu Jun 10 11:12:44 1999 From: graham at sloth.math.uga.edu (Graham Matthews) Date: 10 Jun 1999 15:12:44 GMT Subject: fork() References: <000b01beb2e8$09deb660$af9e2299@tim> Message-ID: <7joklc$hih$4@cronkite.cc.uga.edu> Tim Peters (tim_one at email.msn.com) wrote: : Back at Python 1.4, a set of patches was developed (by Greg Stein) that : *did* remove the global lock. This meant fine-grained locking of other : stuff as needed, refcounts included. The interpreter has changed quite a : bit since then, so old numbers aren't quantitatively relevant anymore; but : it was indeed a significant slowdown for single-threaded Python programs. : : It's particularly acute for Python because *everything* "is boxed"; nothing : is exempt, and refcounting is never delayed. : The Sisal language has an interesting approach to this problem. Rather than try to lock each refcount, it had n areas of memory you could allocate out of. When changing area i you had to lock it, but all users of the other areas could proceed without blocking. This was useful for do reference count fiddling. grahaml -- As you grow up and leave the playground where you kissed your prince and found your frog Remember the jester that showed you tears the script for tears From perryf at bigpond.NO.SPAM.com Wed Jun 30 19:20:43 1999 From: perryf at bigpond.NO.SPAM.com (Perry Faulkner) Date: Thu, 01 Jul 1999 09:20:43 +1000 Subject: ioctl in python References: <377A71D7.470AF9DA@starvision.com> <377A7374.C6919FD3@starvision.com> Message-ID: <377AA64A.B4C63805@bigpond.NO.SPAM.com> Hi Angus, The ioctl cmd code (0x80047601) is expecting a 4 byte buffer to be passed to it. The simplest thing is something like : rec = pack('BBBB', 0,0,0,0) or rec = pack('L', 0) depending on what's expected, then ioctl(handle, 0x80047601, rec) By the way, the 80 part of the command also says this is an input function, so you are writing the data, rec in this case! For an output function you would follow the ioctl with an unpack of the data buffer, as well. But you still need to supply the packed input buffer in any case. Hope this helps! Regards, Perry Angus MacKay wrote: > well it seems I have sort of solved my problem. if I use a > string for the 3rd arg then it works properly: > >>> fo=open('/tmp') > >>> fcntl.ioctl(fo.fileno(), 0x80047601, "hi") > '\001\000' > >>> fo=open('/') > >>> fcntl.ioctl(fo.fileno(), 0x80047601, "hi") > '\000\000' > >>> fo=open('/proc') > >>> fcntl.ioctl(fo.fileno(), 0x80047601, "hi") > Traceback (innermost last): > File "", line 1, in ? > IOError: (25, 'Inappropriate ioctl for device') > > the question is why? it will still fail with only 2 args or an int: > >>> fcntl.ioctl(fo.fileno(), 0x80047601) > Traceback (innermost last): > File "", line 1, in ? > IOError: (14, 'Bad address') > >>> fcntl.ioctl(fo.fileno(), 0x80047601, 1) > Traceback (innermost last): > File "", line 1, in ? > IOError: (14, 'Bad address') > > cheers, Angus. > > Angus MacKay wrote: > > > > is there some magic to the fcntl.ioctl() call? > > > > I can do these ioctl calls in C no problem (with a small wrapper): > > (amackay at phat)~/tmp$ ./ioctltest /tmp 0x80047601 > > 0x80047601: 1 > > (amackay at phat)~/tmp$ ./ioctltest / 0x80047601 > > 0x80047601: 0 > > (amackay at phat)~/tmp$ ./ioctltest /proc 0x80047601 > > /proc: Inappropriate ioctl for device > > > > that was the Linux ioctl for EXT2 version. > > > > but in python: > > >>> a = 0 > > >>> req = 0x80047601 > > >>> import fcntl > > >>> fo=open('/tmp') > > >>> fcntl.ioctl(fo.fileno(), req, a) > > Traceback (innermost last): > > File "", line 1, in ? > > IOError: (14, 'Bad address') > > >>> From sjturner at ix.netcom.com Tue Jun 8 09:17:16 1999 From: sjturner at ix.netcom.com (Stephen J. Turner) Date: Tue, 08 Jun 1999 09:17:16 -0400 Subject: Question about envvars References: <7jgl9n$p13$1@nnrp1.deja.com> <375BFE38.3FB3E83C@ix.netcom.com> <7jh7pc$as$1@nnrp1.deja.com> <375C3891.1D11E1A4@ix.netcom.com> <7ji1bl$955$1@nnrp1.deja.com> Message-ID: <375D17DC.9B524EFF@ix.netcom.com> Rob wrote: > If I specify a -S, can I compensate by specifically saying at the > appropriate time, "import site" ? Yes you can. In fact, older versions of Python required this; the implicit "import site" on interpreter startup was added as of 1.5a4. For full information on the site module, refer to the documentation at: http://www.python.org/doc/current/lib/module-site.html However, if you plan to go with this approach, consider that you probably won't want to install your MDIreg extension module in the $exec_prefix/lib/python1.5/site-packages directory (the usual place to install site-wide extensions), since that directory is added to sys.path by the site module. You'll more likely have to put it in a custom directory and make sure that directory in named in the PYTHONPATH environment variable. Even so, I'd be concerned about the fragility introduced into your MDIreg module by this approach -- namely, that the FileRegistry.exportEnvVars method cannot be used once the os module is imported. I'd much prefer to see you try the C++ subclassing suggested below, so that your extension module works regardless of the module import order. Regards, Stephen > In article <375C3891.1D11E1A4 at ix.netcom.com>, > "Stephen J. Turner" wrote: >> Hi Rob, >> >>> Boy I was excited to get a reasonable explaination so quickly, but >>> alas, it still does not work. Here is my test script: >>> >>> #!/usr/local/bin/python >>> >>> import MDIreg >>> >>> reg = MDIreg.FileRegistry(1,1) >>> reg.exportEnvVars() >>> >>> import os >>> print "child has it : " >>> os.system("env | grep MDI_REG_VERSION") >>> print "but do I have it? :" >>> print os.environ['MDI_REG_VERSION'] >>> >>> --- >>> >>> I am interested in this "MDI_REG_VERSION" envvar which gets exported >>> by my library. Here is the output: >>> >>> child has it : >>> MDI_REG_VERSION=10.0 >>> but do I have it? : >>> Traceback (innermost last): >>> File "regtest.py", line 12, in ? >>> print os.environ['MDI_REG_VERSION'] >>> File "/usr/local/lib/python1.5/UserDict.py", line 12, in __getitem__ >>> def __getitem__(self, key): return self.data[key] >>> KeyError: MDI_REG_VERSION >> >> Oops! I just realized that the site module, which is imported by >> default when the Python interpreter starts, imports the os module -- >> so by the time your script begins to execute, it's already too late. >> Just for grins, you could try disabling the site module by adding the >> '-S' option to the Python command line, as in: >> >> #!/usr/local/bin/python -S >> >> I'm not advocating this approach, since it's generally a good idea to >> import the site module. I'd just like to know if it works for you. >> >>> Any other ideas? Any way to tell the os/posix module to "refresh"? >> >> None that I can see from looking in Modules/posixmodule.c. Sorry. >> >>> By the way, thanks for the library implementation suggestion, but I >>> must keep it the way it is, because other c, and c++ (at the class >>> level) programs access this library. >> >> OK, how 'bout this? Suppose you added a virtual "putenv" method to >> your FileRegistry C++ class whose default implementation was to call >> the global putenv function. Then in your Python C extension, you >> could subclass FileRegistry and override the putenv method with one >> that modifies os.environ as described in the prior post. -- Stephen J. Turner From Taylor.Anderson at p98.f112.n480.z2.fidonet.org Wed Jun 30 06:06:01 1999 From: Taylor.Anderson at p98.f112.n480.z2.fidonet.org (Taylor Anderson) Date: Wed, 30 Jun 1999 11:06:01 +0100 Subject: theads & global namespaces Message-ID: <000015c5@bossar.com.pl> From: Taylor Anderson Greetings all, I am trying to share globals between threads. Is is possible for me to share globals between threads that call functions from different modules? Thus far I have had little success. I ask this question because I would prefer not to put all my code in one module. For example, I have 2 .py files: a.py and b.py. b.py contains the function ('foo()') to be executed under the new thread, as well as the global variable 'x'. a.py contains the call to start_new_thread(foo,()). a.py also tries to use the global variable x. ========================================= b.py x = 0 def foo(): global x x = x + 1 ========================================= a.py from b.py import * if __name__ == '__main__': start_new_thread(foo, ()) while 1: if x != 0: print x ========================================= So far, my code in a.py does not detect any change in x. Any suggestions for a workaround? Many thanks, Taylor From n at n.com Wed Jun 2 10:13:59 1999 From: n at n.com (Jr. King) Date: Wed, 2 Jun 1999 10:13:59 -0400 Subject: Why won't this work??? References: <7j0rkr$1eeu$1@rtpnews.raleigh.ibm.com> <7j1qc5$3rj$1@m2.c2.telstra-mm.net.au> Message-ID: <7j3e5q$nrq$1@rtpnews.raleigh.ibm.com> Uhhhh, excuse me but, I did point out the problem. The PyEval_CallObject call is failing everytime. I have it commented in the code, I guess that wasn't good enuff. Excuse me, but that is the way I have done and seen it done on c.l.c and the questions are usually answered minus the attitude. And I will be doggoned if I give out my darn email address on newsgroups again, I don't need all that trash about porno. From tim_one at email.msn.com Mon Jun 21 00:02:55 1999 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 21 Jun 1999 00:02:55 -0400 Subject: DATE ARITHMETIC In-Reply-To: <7kj3jv$ssu$1@coco.singnet.com.sg> Message-ID: <000301bebb9a$f0e2b6a0$619e2299@tim> [Ajith Prasad] > ... > The difficulty I had with the mxDateTime module was that results > seem to be expressed as date time objects with timestamps embedded > with dates and, given my limited knowledge of Python (just a few > chapters into "Learning Python") I have no clue as to how to extract > just the dates out. But I am sure that mxDateTime has all the > functionality that justifies further investment in learning it. An interactive shell (IDLE or PythonWin work great) is your best friend, along with the "dir" function, __doc__ strings, and just *trying* stuff; e.g., >>> import DateTime >>> dir(DateTime) # see what's in the module ['ARPA', 'Date', 'DateTime', ...] >>> print DateTime.Date.__doc__ # what does Date do? DateTime(year,month=1,day=1,hour=0,minute=0,second=0.0) Returns a DateTime-object reflecting the given date and time. Seconds can be given as float to indicate fractions. >>> t = DateTime.Date(1999, 6, 20) >>> t >>> dir(t) # see what t can do ['COMDate', 'Format', '__copy__', '__deepcopy__', 'absdate', 'absdays', 'abstime', 'absvalues', 'day', 'day_of_week', 'day_of_year', 'days_in_month', 'hour', 'is_leapyear', 'minute', 'month', 'second', 'strftime', 'ticks', 'tuple', 'tz', 'year', 'yearoffset'] >>> t.day # try something 20 >>> t + 20 # try adding >>> # looks like "+ int" adds that many days; >>> # wonder whether printing is prettier >>> print t + 20 1999-07-10 00:00:00.00 >>> # yup! That's how you get amazingly good at Python amazingly fast . > In response to my posting, Tim Peters and Jeff Bauer have pointed out > simpler date-time routines that could be used. Tim's routines (available > together with the Python source code disribution) use the American-style > "month-day-year" format while Jeff's use the less ambiguous > "year-month-date" format which also happens to be the format in which my > date data are in. FYI, Tim's code was actually written as a demo of then-new operator overloading facilities. That it happens to do anything sensible with dates for anyone is a reliable accident . OTOH, don't let MDY year stop you! Python excels at gluing things together, forcing nasty interfaces into forms that *you* like; e.g., it's a one-liner to write your own little function to accept YMD argument order instead, passing it on to Date's constructor in the order *it* likes. Do it once & never think about it again. > Jeff's notes at http://starship.python.net/crew/jbauer/normaldate/ make > some useful points on the need for simple routines which handle the > more common date arithmetic tasks without the added complications of > dealing with specific calendars, time zones, etc. Jeff has a very nice pkg there. I recall that when I first tried it, I was baffled by the results until I dug into the code & saw it special-cased the snot out of the year 1582 . Dates.py takes a more extreme view of simplicity, pretending today's rules extend infinitely in both directions. Of course that's *wrong* -- but then so is ignoring leap seconds . > Both Tim's and Jeff's routines are geared towards this. I will look at > the further references that Ivan has suggested for a deeper > understanding of the issues. No no no, Ivan is a calendar *expert*: he'll only break your heart. It's like asking me what 1.1 + 0.9 should return . experts-can't-abide-simple-answers-because-reality-is-a- frickin'-mess-ly y'rs - tim From MHammond at skippinet.com.au Thu Jun 3 03:04:28 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Thu, 3 Jun 1999 17:04:28 +1000 Subject: IDLE Extension: CallTips References: <7j2m5m$kuf$1@m2.c2.telstra-mm.net.au> Message-ID: <7j59be$ijh$1@m2.c2.telstra-mm.net.au> Guido suggested a few changes to CallTips.py as posted, making it work very nicely. I attach a version with the following changes: * Cancelling of the Call Tips is now robust, due to knowing the magic events to hook. * Turns out my code was Windows specific (surprise :-) Seems Tkinter on windows recongises "Key-(" but Unix does not. Changed to "", and it works fine on Unix (so Im told ) * Comments updated, and code cleaned slightly. This has now been checked into the Python CVS tree - if you are interested, please follow further updates there. Enjoy! Mark. begin 666 CallTips.py M(R!#86QL5&EP2 M($%N($E$3$4 at 97AT96YS:6]N('1H870@<')O=FED M97,@(D-A;&P at 5&EP6]U(&]P96X@ M<&%R96YS+ at T*#0II;7!OPT*(" @(" @(" G/#QP87)E;BUO M<&5N/CXG.B!;)SQ+97DM<&%R96YL969T/B==+ T*(" @(" @(" G/#QP87)E M;BUC;&]S93X^)SH at 6R<\2V5Y+7!A61E9G,@/2![#0H@(" @ M?0T*#0H@(" @9&5F(%]?:6YI=%]?*'-E;&8L(&5D:71W:6XI. at T*(" @(" @ M("!S96QF+F5D:71W:6X@/2!E9&ET=VEN#0H@(" @(" @('-E;&8N=&5X=" ] M(&5D:71W:6XN=&5X= T*(" @(" @("!S96QF+F-A;&QT:7 @/2!.;VYE#0H@ M(" @(" @(&EF(&AA2!)1$Q%+"!B=70@ M;F]T(%!Y=&AO;G=I;BX-"B @(" C(%-E92!?7VEN:71?7R!A8F]V92!F;W(@ M:&]W('1H:7,@:7,@=7-E9"X-"B @("!D968 at 7VUA:V5?=&M?8V%L;'1I<%]W M:6YD;W2X-"@T*(" @(&1E9B!P87)E M;E]C;&]S95]E=F5N="AS96QF+"!E=F5N="DZ#0H@(" @(" @(", at 3F]W(&IU M7,N;6]D=6QE7!E*&]B*3T]='EP M97,N365T:&]D5'EP93H-"B @(" @(" @(" @(&]B(#T@;V(N:6U?9G5N8PT* M(" @(" @(" @(" @87)G3V9F2!A;F0@ M8G5I;&0@;VYE(&9O71H;VX at 9&5F:6YE9"!F=6YC=&EO;G,-"B @(" @ M(" @:68@='EP92AO8BD@:6X at 6W1Y<&5S+D9U;F-T:6]N5'EP92P@='EP97,N M3&%M8F1A5'EP95TZ#0H@(" @(" @(" @("!T'0@/2 B M*"5S*2(@)2!A&-E<'0Z#0H@(" @(" @ M(" @(" @(" @<&%S Message-ID: <87iu8kdm8v.fsf@home.ivm.de> Swartz writes: > Is there anything like curses for MS-DOS? Thanx. pdcurses by M. Hessling , it can be found on some sites that also carry djgpp. dunno whether it can be brought to run with the pytrhon curses module whether by ellinghouse or andrich Klaus Schilling From mal at lemburg.com Tue Jun 15 10:47:05 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Tue, 15 Jun 1999 16:47:05 +0200 Subject: Installing ODBC on PythonWin References: <3760D550.2071295E@lemburg.com> <7k4got$avh$1@nnrp1.deja.com> Message-ID: <37666769.55555E8A@lemburg.com> bruises at my-deja.com wrote: > > Before I go wack and take it out on my computer > like this guy > (http://www.web42.com/badday/badday_small.mpg) > did, I'd like to ask for some help. > > I'm trying to install an ODBC module into > PythonWin, but it still *won't* work! > > It is written that the ODBC module is included in > the pythonwin distribution but >>>import ODBC > says otherwise. I've d/e'd (downloaded/executed) > Win32, but it died and said that it was looking > for version 1.4! > > I was able to partially install mxODBC by copying > all the files into the right place but I'm having > trouble compiling the modules in vc++. There should be no need to compile the module: the package comes with a precompiled version. All you have to do is unzip the archive in e.g. \python\lib and you're set. If you have the win32 libs installed, be sure to rename the included odbc.pyd to win32odbc.pyd. -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 199 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From balaji at platinum.com Fri Jun 11 11:47:11 1999 From: balaji at platinum.com (b s) Date: 11 Jun 1999 11:47:11 -0400 Subject: fork() References: <000c01beb3c1$a3f428a0$329e2299@tim> Message-ID: "Tim Peters" writes: When it comes to GC and whether 'ref count' or 'mark and sweep' is better, here are some opinions from Ken Thompson, on GC and it's implementation in Limbo. http://www.computer.org/computer/thompson.htm From aahz at netcom.com Sat Jun 26 12:06:32 1999 From: aahz at netcom.com (Aahz Maruch) Date: 26 Jun 1999 16:06:32 GMT Subject: How do can you make a variable static? References: <3772AE33.AA764DFA@alliedsignal.com> Message-ID: <7l2tq8$s5i@dfw-ixnews7.ix.netcom.com> In article <3772AE33.AA764DFA at alliedsignal.com>, H. P. Friedrichs wrote: > >Can anyone clarify? What's the workaround? For a variety of reasons I >won't go into right now, I really can't pass the dictionary as an >argument. Just as a reminder, "pass the dictionary" actually means "pass a *reference* to the dictionary"; if copying a huge block of memory is an issue, that's simply not happening. If you really want to do exactly what you're doing (and Darrell's suggestion of using a class is far better), you could create something like this (not tested, but I'm pretty sure it works): *** module foo.py def initFoo ( dict ) : global SymHanDict SymHanDict = dict Now your Foo() function should work correctly if you call initFoo() first in the main script. -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het From proteus at cloud9.net Thu Jun 17 11:06:15 1999 From: proteus at cloud9.net (Michael Muller) Date: Thu, 17 Jun 1999 11:06:15 -0400 Subject: GNU python? (GNUbe question) References: <3765B8B4.18DE0257@spots.ab.ca> <37667309.F9BBAE9A@mojam.com> <022c01beb7ec$f9617070$f29b12c2@pythonware.com> <37689AC2.B8F6579A@serop.abb.se> <87k8t3jh6j.fsf@home.ivm.de> Message-ID: <37690EE7.4CE24C26@cloud9.net> Klaus Schilling wrote: > > "Thomas S. Strinnhed" writes: > > > > Sounds like a good thing this GNUscript, it'll do almost anything. > > Is there a download site ;-) > > ftp://ftp.gnu.org/pub/gnu/guile > > Klaus Schilling The "do_it" function doesn't appear to be implemented in this release ;-). ============================================================================= michaelMuller = proteus at cloud9.net | http://www.cloud9.net/~proteus ----------------------------------------------------------------------------- There is no concept that is more demeaning to the human spirit than the notion that our freedom must be limited in the interests of our own protection. ============================================================================= From loewis at informatik.hu-berlin.de Sat Jun 19 12:15:19 1999 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 19 Jun 1999 18:15:19 +0200 Subject: GC play References: <3769A840.A5AE6778@compaq.com> Message-ID: Greg Ewing writes: > I don't think there's anything you can find out about the source > of any other kind of object. Although I wonder: Would it be possible to record a traceback for each object allocated, to support purify-like leak analysis? It would surely be very inefficient, and you'd also need to release all the locals in the traceback - but would it work? Regards, Martin From wtanksle at dolphin.openprojects.net Thu Jun 24 20:28:26 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Fri, 25 Jun 1999 00:28:26 GMT Subject: Thanks for Python... References: <376ead64@anonymous.newsfeeds.com> <37716901.43CB604@lockstar.com> <37727194.D9CD6B7@lockstar.com> Message-ID: On 24 Jun 1999 07:55:38 PDT, Mordy Ovits wrote: >William Tanksley wrote: >> Sure, but we've got Pilots, so that's not an open option. Fortunately, >> the Pilot has Quartus Forth available for it -- it's not Python, but >> honestly, Forth fits the limitations of the device better. >I had a Pilot for a year before I realized that it wasn;t what I needed. It's a >glorified organizer, when what I wanted was a pocket computer. So I shelled out >for the E-100 and I've never looked back. The difference is light years, not >miles. I have a certain amount of leeriness about posting advocacy on unrelated NGs, so I'll limit myself to saying that the difference is years, not miles. The two machines work differently: one is a glorified organizer, the other is a pocket computer. Both of them can fool you into thinking they're something else, because they're both powerful. I need a personal organizer. >> I used Quartus on my Crypto exam to solve a modular equation after I >> forgot how to solve modular equations (I had it use brute force). >Wow! I wish I had had my E100 when I was in college. I just realized how >awesome that would have been. :-) Oh yeah. Actually, I sometimes miss my old OmniGo, which was a pocket computer, in spite of being slower than the Pilot for some tasks. I really needed the glorified organizer (and had been fooled into thinking that the OmniGo was one), but the OmniGo had some abilties that the Pilot doesn't. >The SECOND time I saw that sig was in ESR's mail. The first was mine. I doubt >ESR copied mine, but who knows? :-) You mean you wrote it? If so, there seems to have crept into it a bug -- one of the implicit unpackings don't work. >Actually there IS a 3 line PERL version, but it does use dc for the heavy >lifting. I consider that cheating. That's what I said -- the first one I found was written in Perl, but used bc. >Python *is* my favorite language, I'd generally agree, although I like Forth a lot too. >Mordy -- -William "Billy" Tanksley Utinam logica falsa tuam philosophiam totam suffodiant! :-: May faulty logic undermine your entire philosophy! From MHammond at skippinet.com.au Mon Jun 14 19:08:49 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Tue, 15 Jun 1999 09:08:49 +1000 Subject: Embedding python in win32 (newbie question) References: <7jh81b$ftc@wapping.ecs.soton.ac.uk> Message-ID: <7k41va$c82$1@m2.c2.telstra-mm.net.au> You need to compile your app with "/MD". This is to ensure that Python and your app agree on the C runtime library, and thus understand each others FILE and memory objects etc. Mark. Ben wrote in message <7jh81b$ftc at wapping.ecs.soton.ac.uk>... >it evaluates fine. Unfortunately, when I pass a file pointer e.g. > >FILE *fp; >fp=fopen("test.py","r"); >if(!fp) exit(0); >Py_Initialize(); >PyRun_SimpleFile(fp,"test.py"); > >it crashes the computer with a nasty access error. > From jstok at bluedog.apana.org.au Wed Jun 16 21:07:22 1999 From: jstok at bluedog.apana.org.au (Jason Stokes) Date: Thu, 17 Jun 1999 01:07:22 GMT Subject: Why is tcl broken? References: <1283099377-77267484@hypernet.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> Message-ID: On Wed, 16 Jun 1999 21:27:52 GMT, David Thornley wrote: >I know little of this Qt animal. Is it free? Is it open source? >Does it run on the Macintosh? Is it easy to set up an interface with? See www.troll.no, but here's the synopsis: Qt is a cross-platform GUI toolkit for Unix and Windows. Qt releases a special "free edition" for Unix only which does match the open source definition, but with some licensing issues. The problem is that linking with the Qt free edition libraries is only allowed if you write open source software yourself. If you want to write a commercial application for Qt, you have to buy a license from Troll Tech. -- Jason Stokes: jstok at bluedog.apana.org.au From mlauer at amalia-atm.rz.uni-frankfurt.de Thu Jun 3 17:52:40 1999 From: mlauer at amalia-atm.rz.uni-frankfurt.de (mlauer at amalia-atm.rz.uni-frankfurt.de) Date: 3 Jun 1999 22:52:40 +0100 Subject: [tkinter] two questions regarding Canvas References: <3752a555@nntp.server.uni-frankfurt.de> <37556602.415AFA46@ingr.com> <19990604005922.07590@nms.otc.com.au> <02fb01beadf0$b358f360$f29b12c2@pythonware.com> Message-ID: <3756eb18@nntp.server.uni-frankfurt.de> Fredrik Lundh (fredrik at pythonware.com) wrote: > Greg McFarlane wrote: > > This is small attempt at adding editing bindings to canvas text items. > > This *must* have been done before, but a search of comp.lang.tcl did > > not come up with anything, except a mention of pg_access in postgresql > > which I could not find. Does anyone know of it? > http://www.pythonware.com/people/fredrik/fyi/fyi52.htm This is a GREAT resource! I'm very much appreciating all what will be published there in the future! Thanks for your work. A side note: I tried to emulate an editing canvas text item with a windows item which has a Tkinter.Text field inside. This is ok - but: While my other canvas items do much work within and bindings, the text field seems to eat up all events - which is ok for editing mode, but not when the user for instance wants to drag around the complete text field. Can I change this behaviour programmatically ? -- Regards & Gruesse from Mickey @ http://www.Vanille.de --------------------------------------------------------- How could anyone know me - when I don't even know myself ? From samw at masu.wwa.com Tue Jun 22 19:21:32 1999 From: samw at masu.wwa.com (Samuel G. Williams) Date: Tue, 22 Jun 1999 23:21:32 GMT Subject: Help with String Manipulation Message-ID: <0UUb3.1337$el4.44932@ord-read.news.verio.net> I know this is a very stupid question and one that has been addressed within available documentation, however I need a quick hand. I am in need of a routine to reverse the order of a string. I have tried several things that have resulted in failures. It is really stupid, but I am just learning python. I can do this readily in C, perl, tcl, but am at a loss. I would appreciate any help I can get. Thanks in advance. -- Sam Williams wb5yni samurai at acm.org Senior IS Staff Specialist samw at wwa.com --------------------------------------------------------------------------- Thinking of running your critical apps on NT? Isn't there enough world suffering? From gvinther at atex.com Tue Jun 8 14:04:25 1999 From: gvinther at atex.com (Gordon Vinther) Date: Tue, 8 Jun 1999 14:04:25 -0400 Subject: Tkinter doesn't work with Tcl/Tk 8.0.5 and probably 8.1. Message-ID: <928865040.722.4@news.remarQ.com> Tried to get Python 1.5.2 to work with Tcl/Tk 8.0.5, Aix 4.2.1 get the following error: from Tkinter import * ............. this works root=Tk() this fails with the message: TclError: invalid command name "tcl_findLibrary" In addition I still get one compile error under AIX : unable to convert unsignedlong* to int* in socketmodule.c From tim_one at email.msn.com Fri Jun 25 02:38:05 1999 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 25 Jun 1999 02:38:05 -0400 Subject: Environment inheritance under Windows NT 4, Attempt 2 In-Reply-To: Message-ID: <000901bebed5$480437a0$d29e2299@tim> [Milton L. Hankins, has trouble with envar WINDIR in NT] http://support.microsoft.com/support/kb/articles/Q100/8/43.asp will tell you that WINDIR is "special". Not exactly clear how, though. Best I can suggest is that you fight with NT until it delivers a correct value for WINDIR as soon as you boot; you really shouldn't be messing with this envar. search-ms-support-for-"windir"-to-find-out-why-not-ly y'rs - tim From tjreedy at udel.edu Thu Jun 3 09:58:53 1999 From: tjreedy at udel.edu (Terry Reedy) Date: 3 Jun 1999 13:58:53 GMT Subject: All this self dot is making me... References: Message-ID: <7j61mt$g7n$1@news.udel.edu> >For those of us who have less cartilage left in their hands, would it be >acceptable to use "my." or better "me." 'Acceptable' to whom? Python is a free language; use it as you wish 8). For private work, I abbreviate 'self' to 's' and 'other' (in __add__(), etc) to 'o'. This works precisely because the existing conventions make it obvious (to me) what is meant. TJ Reedy From schorsch at schorsch.com Mon Jun 21 08:03:21 1999 From: schorsch at schorsch.com (Georg Mischler) Date: Mon, 21 Jun 1999 12:03:21 GMT Subject: do anonymous pipes normally work on NT? References: <4D0A23B3F74DD111ACCD00805F31D8100DB90DFB@RED-MSG-50> <7kjgt1$noj$1@nnrp1.deja.com> <7kjv1k$ro6$1@nnrp1.deja.com> Message-ID: <7kl9m4$8dg$1@nnrp1.deja.com> Florent Heyworth wrote: > Georg Mischler wrote: > > Bill Tutt wrote: > > > After digging through this stuff, I went back and looked at > > > the code I had written for win32popen.cpp. > > > I realized that I had forgotten why I had > > > > Uh oh, Bill... > > > > If you should ever happen to visit the Munich Oktoberfest, > > please remind me that I owe you a few beer! > > > > > > Thanks a lot for all the tips and bug hunting! > > > > Well...... > > (I) never dug up the source - but I still spent 3 hours of my time > trying to get your code to work...... do I get a beer at the Fest 8-)? Oops! I knew this usenet thing was going to be expensive... Just warn me beforehand when you turn up there. And remember, as the name suggests, the Munich Oktoberfest is in September. ;) Have fun! -schorsch -- Georg Mischler -- simulation developper -- schorsch at schorsch.com +schorsch.com+ -- lighting design tools -- http://www.schorsch.com/ Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From kvrekp at hotmail.com Thu Jun 10 07:48:15 1999 From: kvrekp at hotmail.com (kvrekp at hotmail.com) Date: Thu, 10 Jun 1999 11:48:15 GMT Subject: Free Sex Links 7546 Message-ID: <3CN73.93097$pl3.57568@newreader.ukcore.bt.net> For Nasty Sex links visit: http://website.lineone.net/~simonsi/sexlinks.htm ztjorzgfvo From fdrake at cnri.reston.va.us Tue Jun 29 15:10:33 1999 From: fdrake at cnri.reston.va.us (Fred L. Drake) Date: Tue, 29 Jun 1999 19:10:33 GMT Subject: Binary pickle portability In-Reply-To: References: Message-ID: <14201.6697.811188.198805@weyr.cnri.reston.va.us> Olaf Delgado writes: > After looking a bit closer, I found that the problem is probably related > to the Numeric module (i.e., pickling matrices) and doesn't depend on > whether binary or ordinary mode is used. So please don't bother now! > Still, I am interested in whether people use binary pickles. The last release of Grail uses binary pickles to store caches of parsed bookmark files. There are no floating point or NumPy objects in the pickles, so that wouldn't test cases you may be interested in. My choice to use binary pickles was entirely based on the performance improvement; I doubt there are any substantial cross-platform issues for bookmark files, especially when only used as caches! -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From orlov at diasoft.ru Thu Jun 17 05:02:25 1999 From: orlov at diasoft.ru (Oleg Orlov) Date: Thu, 17 Jun 1999 13:02:25 +0400 Subject: ref counting, access from python Message-ID: <7kad31$o7f$1@ns.mtu.ru> Hello. How can i get objects current ref count from my python code? Thanks. -- ==================== Oleg Orlov orlov at diasoft.ru From Drew.Whitehouse at anu.edu.au Mon Jun 21 19:00:27 1999 From: Drew.Whitehouse at anu.edu.au (Drew Whitehouse) Date: 22 Jun 1999 09:00:27 +1000 Subject: WIN32/python/COM/Multimedia Message-ID: Hi, I was wondering if anyone has any code/examples of using python to control the playing back of things like audio files and CD's via python ? I've used makepy to generate the media player COM interface but have been unsuccessful (except for being able to pop up the "About" box....) in wrapping my simple UNIX brain around what's going on. Ideally I'd like to be able to do this without having to use the GUI, but if necessary I could have another program send commands to an iconified/hidden GUI app (maybe looking like a COM server ?). BTW I have seen the winsound module, but I'd like something a more powerful/flexible. -Drew -- ;; mailto:Drew.Whitehouse at anu.edu.au http://anusf.anu.edu.au/~drw900/ ;; Viz programmer, Australian National University Supercomputer Facility From suzuki611 at okisoft.co.jp Tue Jun 1 06:40:17 1999 From: suzuki611 at okisoft.co.jp (Hisao Suzuki) Date: 01 Jun 1999 19:40:17 +0900 Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <87pv3iq6ss.fsf@ev.netlab.co.jp> <7iv86a$iud@news.dns.microsoft.com> Message-ID: In article <7iv86a$iud at news.dns.microsoft.com>, "Vadim Chugunov" wrote: > Right, but java finalizers will not be called till the moment the memory is > collected. > Depending on the GC configuration and the program's memory consumption this > may be quite a while. You are right. The JLS (Java Language Specification) says: The Java language does not specify how soon a finalizer will be invoked, except to say that it will happen before the storage for the object is reused. (sect.12.6) In fact, there is no guarantee that all garbages will be reused, up to their last one byte, within the life time of the java process, and there is also no guarantee that ALL finalizers will be eventually invoked. It is an issue of the quality of JVM implementation, you know. > Can you explain exactly why is it more error prone? > If something can be done automatically, without writing explicit > deallocation code, > why can't we let it be that way? Perhaps it is safe to say that destructors with real GC are more error prone. (The present Python is safer in this respect!) In general, real GC simulates infinite memory virtually, and one should not rely on finalizers; objects remain virtually forever. With real GC, finalizers should be used only as the last resort. BTW, Mr. Matz has invented and implemented his excellent language, Ruby, which is a sort of Perl's successor with some intrinsic object-oriented features. IMHO, we must have respect for his opinion as such or, at the very least, as the evangelist of his own language. See http://www.netlab.co.jp/ruby/ --===-----========------------- Sana esprimo naskas sanan ideon. SUZUKI Hisao suzuki611 at okisoft.co.jp, suzuki at acm.org. From tim_one at email.msn.com Tue Jun 29 11:56:59 1999 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 29 Jun 1999 11:56:59 -0400 Subject: ANN: Stackless Python 0.2 In-Reply-To: Message-ID: <000101bec248$0549a960$6d9e2299@tim> > ... > Py_BEGIN_ALLOW_THREADS > ThreadedSpam(); > Py_END_ALLOW_THREADS > > it's-only-confusing-if-you-think-about-it-too-much-ly y'rs - tim [Robin Becker] > so do I then have to poll ThreadedSpam myself to see if it's finished or > is there a python api version of mutexes/locks etc. You're in C now -- you do anything you need to do, depending on the specifics of ThreadedSpam (which was presumed to be a pre-existing thread-safe C routine). The snippet above clearly assumes that ThreadedSpam "is finished" when it returns from the call to it. If your flavor of ThreadedSpam doesn't enjoy this property, that's fine too, but then you do whatever *it* requires you to do. This is like asking me whether the right answer is bigger than 5, or less than 4: how the heck should I know ? You can certainly use Python's lock abstraction in your own C code, but it's unlikely a pre-existing C function is using that too. python-doesn't-restrict-what-c-code-can-do-except-to-insist-that-it- acquire-the-lock-before-returning-to-python-ly y'rs - tim From MHammond at skippinet.com.au Wed Jun 9 18:41:08 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Thu, 10 Jun 1999 08:41:08 +1000 Subject: COM dates References: <816010E2456BD111A48700805FBBE2EEFDF353@ex-quebec-u1.baan.com> Message-ID: <7jmqev$g8v$1@m2.c2.telstra-mm.net.au> Check out the win32 extensions help file. This has a discussion of COM dates. In a nutshell, you use the int() function to convert it to a standard Python time module date, and you can assign a standard Python time module date to a COM date field and it will do the right thing. Mark. Gaetan Corneau wrote in message <816010E2456BD111A48700805FBBE2EEFDF353 at ex-quebec-u1.baan.com>... >Hello, > >I have a COM object with a field calles "StartDate". When I type: > >print Obj.StartDate, I get: > > > >Two questions: > >1) What is that PyTime object? Is it documented somewhere? > >2) Suppose I want to set StartDate to January 1, 1999, what do I write in my >script? From tjreedy at udel.edu Sat Jun 12 18:59:01 1999 From: tjreedy at udel.edu (Terry Reedy) Date: 12 Jun 1999 22:59:01 GMT Subject: extracting contents from a text file References: <375B5880.992B0C6C@mediamanager.com.sg> Message-ID: <7juonl$q1f$1@news.udel.edu> In article <375B5880.992B0C6C at mediamanager.com.sg>, john at mediamanager.com.sg says... >I would like to extract the text contents residing in another server and >display it as html format using python. Can anyone help me I am new to >python. You need three separate modules to 1. retrieve text file (1 of url libs or possible FTP lib); 2. process file (hope string or re rather than parser is sufficient); 3. write html (for instance, HTMLgen on starship site -- see python.org). TJ Reedy From thomas.heller at ion-tof.com Thu Jun 24 04:54:10 1999 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 24 Jun 1999 10:54:10 +0200 Subject: mxCGIPython question (was: Build the Python library into the binary) References: <376F9518.D3252CEE@interet.com> <7kolnv$gp6$1@nnrp1.deja.com> Message-ID: <015e01bebe1f$202e9560$4500a8c0@thomasnotebook> > Hi > > did you have a look at mxCGIPython at > http://starship.skyport.net/~lemburg/mxCGIPython.html ? > This is a single executable not shared library with the > standard Python library embedded. > > Cheers > -- > Florent Heyworth > Works great, except for one problem (under Windows): you cannot use any extension modules, because they do not find python15.dll (or, worse, they find the wrong python15.dll). Is it possible to build a python15.dll containing the standard library or is it only possible to freeze executables? Thomas Heller From proteus at cloud9.net Wed Jun 2 21:19:13 1999 From: proteus at cloud9.net (Michael Muller) Date: Wed, 02 Jun 1999 21:19:13 -0400 Subject: idle processing References: <3755bf01@nntp.server.uni-frankfurt.de> Message-ID: <3755D811.61AEC34@cloud9.net> mlauer at asmoday-atm.rz.uni-frankfurt.de wrote: > > Hi, > > is there an appropriate place to insert a method > which does some calculations while the application > is "idle" (user is not using it or just moving > the mouse...) - somewhere within the tkinter- > mainloop ? > > -- > Regards & Gruesse from Mickey @ http://www.Vanille.de > --------------------------------------------------------- > How could anyone know me - when I don't even know myself ? The "after" function allows you to execute code after a given period (in milliseconds) or in idle time: def someFunction(): " Your code here " win = SomeWindowClass() win.after('idle', someFunction) win.mainloop() This will cause "someFunction" to be evaluated *once* in the message loop when there are no events left in the event queue. You should be able to "chain" these by adding another "after idle" call _inside_ the function, thus allowing you to have a function that is performed whenver the message queue is idle. This doesn't seem to work quite right for me, though. The idle time function ends up blocking the message queue. It does seem to work if you force a delay between iterations, like so: win = SomeWindowClass() def otherFunc(): win.after('idle', someFunc) def someFunc(): "idle time processing here" # give the system a second to catch it's breath win.after(1000, otherFunc) win.after('idle', someFunc) ============================================================================= michaelMuller = proteus at cloud9.net | http://www.cloud9.net/~proteus ----------------------------------------------------------------------------- Mantra for the 60's: Tune in, turn on, drop out Mantra for the 90's: Turn on, jack in, jerk off ============================================================================= From Just.van.Rossum at p98.f112.n480.z2.fidonet.org Wed Jun 30 14:21:37 1999 From: Just.van.Rossum at p98.f112.n480.z2.fidonet.org (Just van Rossum) Date: Wed, 30 Jun 1999 19:21:37 +0100 Subject: Python Editor Message-ID: <000015c9@bossar.com.pl> From: Just van Rossum >In article , >Jose A. Antich wrote: >> >> Does anyone know if there's any Python Editor for the MAc? Python on the Mac is shipped with a Mac native IDE. At 4:39 PM +0000 6/30/99, Aahz Maruch wrote: >IDLE, a debugger/editor written in Python. You'll need Python 1.5.2 and >Tcl/Tk 8.0 (*not* 8.1). IDLE does not work well on the Mac. Just From greg.ewing at compaq.com Tue Jun 29 16:46:15 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Wed, 30 Jun 1999 08:46:15 +1200 Subject: file.tell problems (1.5.2/Win32) References: <7krd1r$2oa$1@holly.csv.warwick.ac.uk> <7l3aao$65c$1@nnrp1.deja.com> <3776ED63.35D87F89@compaq.com> <37782C9E.3061AF25@geekspace.com> Message-ID: <37793097.17D1BDA6@compaq.com> Joshua Rosen wrote: > > This leads me to believe that `append mode' is intended to `append' at the > *current* point in the file, which should, for consistency's sake, start at 0. I just tried an experiment (on Windows) using "a+" mode. It seems that f.tell() is telling the truth, but the truth is strange. What "a"/"a+" modes seem to mean is "open the file positioned at 0, but if the first operation is a write, go to the end of file before doing it". Which seems quite bizarre to me - wouldn't it be simpler to just go to the end of the file on opening? Greg From tim_one at email.msn.com Sun Jun 13 16:36:08 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 13 Jun 1999 16:36:08 -0400 Subject: OO (was: Why is tcl broken?) In-Reply-To: <3763C746.5CA8FE78@iname.com> Message-ID: <000a01beb5dc$5e88aa80$ae9e2299@tim> [Fernando Mato Mira] > Although Dylan never really made it into "Fernando's elegibility list" > because it was not a serious contender against Scheme and CL yet, it > definitely got banished the day the Lisp syntax was dropped. I'm still > waiting for the day when the Dylan fans will reinstate the alternative. OK! Now we know the answer Fernando is looking for: Tcl is fatally broken because its syntax differs from Lisp's <0.9 wink>. admit-it-up-front-and-maybe-this-will-go-away?-na-ly y'rs - tim From bwarsaw at CNRI.Reston.VA.US Fri Jun 11 09:55:50 1999 From: bwarsaw at CNRI.Reston.VA.US (Barry A. Warsaw) Date: Fri, 11 Jun 1999 09:55:50 -0400 (EDT) Subject: fork() References: <000c01beb3c1$a3f428a0$329e2299@tim> <199906110443.AAA02408@eric.cnri.reston.va.us> Message-ID: <14177.5478.427212.303048@anthem.cnri.reston.va.us> >>>>> "Guido" == Guido van Rossum writes: Guido> Could we get away with not calling (user) finalizers on Guido> objects in trash cycles at all? Guido> We'd still get complaints "my __del__ doesn't get called" Guido> from some users It's more mechanism, but if you go this far, it's probably best to call __del__ exactly once for each object, as Tim suggests. It's what Java people know and love, and it seems to make more sense than it never getting called. -Barry From Klaus.Schilling at home.ivm.de Wed Jun 16 14:53:52 1999 From: Klaus.Schilling at home.ivm.de (Klaus Schilling) Date: 16 Jun 1999 20:53:52 +0200 Subject: OO (was: Why is tcl broken?) References: <000801beb745$02768220$979e2299@tim> <871zfdp73f.fsf@home.ivm.de> <873dzsma6b.fsf@home.ivm.de> Message-ID: <87lndkkmda.fsf@home.ivm.de> Lars Marius Garshol writes: > * Klaus Schilling > | > | No, in the sense `Steele merely rediscovered scheme, not bring it > | into being' > > I don't understand what you mean by this. The two people who created > Scheme originally were Sussman and Steele. If that isn't bringing it > into being I don't know what would be. No, they discovered Scheme, they did not create it. Klaus Schilling From n89553 at hrz.uni-paderborn.de Mon Jun 28 10:10:12 1999 From: n89553 at hrz.uni-paderborn.de (m liss) Date: Mon, 28 Jun 1999 16:10:12 +0200 Subject: ssh with telnetlib Message-ID: <37778244.C4528C5B@hrz.uni-paderborn.de> Hello, has someone already made telnetlib.py support ssh ? I want to use Python for remote administration. regards, Mirko -- M Li?, From suzuki611 at okisoft.co.jp Wed Jun 2 05:19:21 1999 From: suzuki611 at okisoft.co.jp (Hisao Suzuki) Date: 02 Jun 1999 18:19:21 +0900 Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <87pv3iq6ss.fsf@ev.netlab.co.jp> <7iv86a$iud@news.dns.microsoft.com> <87so8bnsd6.fsf@ev.netlab.co.jp> Message-ID: In article <87so8bnsd6.fsf at ev.netlab.co.jp>, Yukihiro Matsumoto wrote: > |Perhaps it is safe to say that destructors with real GC are more > |error prone. (The present Python is safer in this respect!) > Safer than Java, probably. > > Ruby garantees (well, trying to garantee) that ALL finalizers will be > called before process termination, so that Ruby is as safe as Python, > at least theoretically. This sounds a sort of advocacy of your Ruby... Any way, the idea of destructors with "real" GC is a conceptual contradiction. Such GC emulates infinite memories and objects are never destroyed *virtually*. Thus the destructors should never be invoked with real GC. Certainly you may make your GC routine retrieve not only memories but also various resources (such as file descriptors), but it is highly error prone to make the routine invoke ARBITRARY destructors specified by arbitrary users. Such invocation may introduce serious indeterminism or unpredictability into the behavior of user's program. # Well, in this respect, Ruby might be more indeterministic # than Python. Even if Python has "real" GC someday, IMHO, the GC should be used only to imitate infinite resources. For the sake of conceptual simplicity, the future Python should still use reference counting both to invoke __del__ methods and to free storages; the GC routine should be used as the last resort. # Or, deprecate both __del__ methods and reference counting? # --- it will result in another language than Python. --===-----========------------- Sana esprimo naskas sanan ideon. SUZUKI Hisao suzuki611 at okisoft.co.jp, suzuki at acm.org. From graham at sloth.math.uga.edu Fri Jun 4 13:07:11 1999 From: graham at sloth.math.uga.edu (Graham Matthews) Date: 4 Jun 1999 17:07:11 GMT Subject: "The Python Way" References: <001101beae49$39af7bc0$949e2299@tim> <7j8pra$55v$4@cronkite.cc.uga.edu> Message-ID: <7j913v$6lk$2@cronkite.cc.uga.edu> Evan Simpson (evan at tokenexchange.com) wrote: : I get the distinct impression the the reception of *any* proposal to alter : Python is likely to be vastly improved by the presence of an implementation, : however primitive, and will allow you de facto last word on a lot of : arguments. My own pet suggestions have died for lack of this, apart from : "and while", for which some kind soul coded a mutant cousin. You are wrote. People here love to see code. And that would be a great proof of concept. But the problem with this line of reasoning is that people have other things to do, and do not necessarily have the time to provide such code. That should not however be grounds for writing an idea off. graham -- One day in a nuclear age They may understand our rage We build machines that we can't control And bury the waste in a great big hole From mwh21 at cam.ac.uk Sun Jun 13 12:11:05 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 13 Jun 1999 17:11:05 +0100 Subject: Module magic methods References: Message-ID: arcanedragonNOSPAM at NOSPAMhome.com (Chris Herborth) writes: > Do modules have magic methods? Specifically, I'm wondering if there's a > __del__() or __destroy__() method that I could use to clean up after myself > a little when the module is about to be unloaded... Don't think so. However you can fake it by creating a class instance and storing it in a module global, like so: class ByeBye: def __del__(self): print "bye bye" _byebye = ByeBye() Then, so long as no other entity has a reference to _byebye, when the module is unloaded _byebye will be collected and the __del__ method called. You know that, in general, modules aren't unloaded, except at interpreter shutdown time? And then the execution state is so unpredictable you can't really do anything? HTH Michael FWIW, I've often thought it would be funky to be able to define __add__ or __call__ etc methods to modules. Pointless, I'd have to admit, but still funky. > -- > ----------================================================---------- _ > Chris Herborth, R&D, Technical Writing | \ _ > Arcane Dragon Software Arcane Dragon -==(UDIC)==- | < /_\ > arcane dragon at home dot com DNRC Holder of Past Knowledge |_/ \_ From rozzin at geekspace.com Wed Jun 23 21:04:36 1999 From: rozzin at geekspace.com (Joshua Rosen) Date: Wed, 23 Jun 1999 21:04:36 -0400 Subject: How to obtain an instance's name at runtime? References: <7kqpu8$7u1$1@nnrp1.deja.com> Message-ID: <37718424.C70BB9DE@geekspace.com> "Dinu C. Gherman" wrote: > Question: How to obtain an instance's name at runtime? An *instance's* name? Instances have names? > >>> c.__name__ > 'c' Are you actually looking to have the instance tell you what the variable is? Wouldn't that be both [0]pointless and [1]meaningless, because [1]you already know what the variable is, otherwise you can't use it, and [2]the variable-name isn't necessarily the least bit unique, with regard to the variable to which it referrs? Classes have names, and I don't beleive that instances do, because, well..., the name of the class tells what the class is (as far as `what kind of object it is'--I don't really know how to expand on that, except with an analogy like `what species an animal is'), and it usually goes without saying that `what kind of object it is', with regard to C(), is C().__class__ (or C().__class__.__name__, if you want a label rather than an object). -Rozzin. From amaranda at nospam.com Mon Jun 7 06:32:25 1999 From: amaranda at nospam.com (Alex Maranda) Date: Mon, 07 Jun 1999 11:32:25 +0100 Subject: threads References: <000a01beaef4$a53dda20$f19e2299@tim> Message-ID: <375B9FB9.59D3@nospam.com> Steven D. Majewski wrote: > I recall this was one of the reasons I favored coroutines over threads -- > the explicit yield means that you don't need locks. Sort of like the > non-preemptive multitasking on the Mac. The Mac, of course, is now How do coroutines work on MP machines? They don't - just a reminder of how this thread started :) > moving towards a fully preemptive multitasking model -- which makes > better sense for a OS because you can't control all of the code in all > of the apps and ensure that they all behave like good citizens. However, > in a single app, that's not a problem, and cooperative multitasking > with coroutines is a simpler model. I have to disagree; yielding the processor explicitely (or forgetting to do it :) is something I can live without. And it very much depends on what you're doing - suppose you call a blocking syscall in one coroutine - you're handing out the CPU at least for the duration of the syscall; not so with a (kernel) threads implementation. The limitations of the current implementation (which really sucks only on MP machines, for a heavy-weight app) are just that, current limitations. Cheers, -- Alex Maranda mailto: amaranda at spider dot com Spider Software Ltd. Tel: +44 (0)131 4757036 Edinburgh, UK http://members.xoom.com/Alex_Maranda STREAMS based communications protocols for embedded systems From rozzin at geekspace.com Fri Jun 4 08:04:19 1999 From: rozzin at geekspace.com (Joshua Rosen) Date: Fri, 04 Jun 1999 08:04:19 -0400 Subject: "?:", "a and b or c" or "iif" (eval?) References: <7ieg4q$fhu$1@elle.eunet.no> <0sV23.12$KR2.13382@news.corridex.com> Message-ID: <3757C0C3.C56B3522@geekspace.com> Evan Simpson wrote: > It would need to be more than built-in (in the sense of being a function > defined in builtins) to get the semantics that I, at least, would expect > from this kind of construct; it would need to actually be part of the > language, so that it could do short-circuit evaluation of its parameters > (which no function can do). > > In other words, your "iif" always evaluates "a" and "b", when it is often > desirable to only evaluate "b" if "x" is false. It's true that the > full-blown "((test1 and [value1]) or (test2 and [value2]) or > [elsevalue])[0]" is clunky, but it's actually fairly efficient, and not too > bad once you've seen it twice. One could also probably use eval: eval(cond0 and "expr0" or "expr1") ..., though that's probably not the best way, in terms of execution-speed of expr0 or expr1, but it does give the effect of lazy evaluation, truly doing the short-circuit thing. Still, the syntax isn't ugly. . o O ( Of course, I don't think that the "(cond0 and [expr0] or [expr1])[0]" syntax is ugly, or even that "(cond0 and (expr0,) or (expr1,))[0]" is too bad, so who am I to judge?) From mwh21 at cam.ac.uk Tue Jun 1 12:00:35 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: Tue, 1 Jun 1999 16:00:35 GMT Subject: Python 2.0 In-Reply-To: <11A17AA2B9EAD111BCEA00A0C9B4179301E10ED9@forest.origin.ea.com> References: <11A17AA2B9EAD111BCEA00A0C9B4179301E10ED9@forest.origin.ea.com> Message-ID: On Tue, 1 Jun 1999, Stidolph, David wrote: > Py_TRACE_REFS seems to be defined if Py_DEBUG is defined. > > I cannot find a "getobjects" or any other similar function in the source > code or docs. I am using the Win32 version 1.5.2. Well, Python/sysmodule.c in the source contains this: static PyMethodDef sys_methods[] = { /* Might as well keep this in alphabetic order */ {"exc_info", sys_exc_info, 0, exc_info_doc}, {"exit", sys_exit, 0, exit_doc}, #ifdef COUNT_ALLOCS {"getcounts", sys_getcounts, 0}, #endif #ifdef DYNAMIC_EXECUTION_PROFILE {"getdxp", _Py_GetDXProfile, 1}, #endif #ifdef Py_TRACE_REFS {"getobjects", _Py_GetObjects, 1}, #endif {"getrefcount", sys_getrefcount, 0, getrefcount_doc}, #ifdef USE_MALLOPT {"mdebug", sys_mdebug, 0}, #endif {"setcheckinterval", sys_setcheckinterval, 1, setcheckinterval_doc}, {"setprofile", sys_setprofile, 0, setprofile_doc}, {"settrace", sys_settrace, 0, settrace_doc}, {NULL, NULL} /* sentinel */ }; and this: #ifdef Py_TRACE_REFS /* Defined in objects.c because it uses static globals if that file */ extern PyObject *_Py_GetObjects Py_PROTO((PyObject *, PyObject *)); #endif and Objects/object.c contains: PyObject * _Py_GetObjects(self, args) PyObject *self; PyObject *args; { ... This is all on Linux, but the source is the source, as I understand it. I mean the C source, not the Python Library source... I'd hoped that was obvious. I doubt it is documented anywhere - a quick grep through the docs finds nowt, though Doc/api/api.tex contains the line: XXX Explain Py_DEBUG, Py_TRACE_REFS, Py_REF_DEBUG. I'd heard about it sometime on the newsgroup. > Any help would be appreciated, If this is what you were looking for, you're welcome. Michael > David Stidolph. > > > -----Original Message----- > From: Michael Hudson [mailto:mwh21 at cam.ac.uk] > Sent: Tuesday, June 01, 1999 4:55 AM > To: python-list at cwi.nl > Subject: Re: Python 2.0 > > > "Stidolph, David" writes: > > > >OK, I'll try to propose something constructive. Maybe we need an object > > >protocol, that would enumerate > > >all references held by an object ? Writing a portable GC would be then > > much > > >easier. > > > > Sounds good to me for debugging. A call that could return a list of > > everything that holds a reference to an object - that would be cool! > > > > list = GetReferences(object) > > print 'List of referencest to',object > > for item in list: > > print 'item:',item > > > > Anybody know of a current way to do this? > > If you recompile Python with Py_TRACE_REFS defined, then the sys > module sprouts a "getobjects" function that returns a list of all > objects in existence. This could probably be used to implement > something like this. It would be veeeeery slow, I suspect. > > I've never resorted to this approach, tending always to make cyclic > references go away be staring at them very, very hard. > > I'm not sure this is at all what is being asked for, but it seems kind > of relavent. > > Yours, > Michael > From Klaus.Schilling at home.ivm.de Thu Jun 17 05:43:31 1999 From: Klaus.Schilling at home.ivm.de (Klaus Schilling) Date: 17 Jun 1999 11:43:31 +0200 Subject: GNU python? (GNUbe question) References: <3765B8B4.18DE0257@spots.ab.ca> <37667309.F9BBAE9A@mojam.com> <022c01beb7ec$f9617070$f29b12c2@pythonware.com> <37689AC2.B8F6579A@serop.abb.se> Message-ID: <87k8t3jh6j.fsf@home.ivm.de> "Thomas S. Strinnhed" writes: > > Sounds like a good thing this GNUscript, it'll do almost anything. > Is there a download site ;-) ftp://ftp.gnu.org/pub/gnu/guile Klaus Schilling From pduffin at mailserver.hursley.ibm.com Mon Jun 28 08:48:02 1999 From: pduffin at mailserver.hursley.ibm.com (Paul Duffin) Date: Mon, 28 Jun 1999 13:48:02 +0100 Subject: Why is tcl broken? References: <375F82C7.CF0F0477@iname.com> Message-ID: <37776F02.6EEA@mailserver.hursley.ibm.com> Tom Cloney wrote: > > > I'm trying to collect a list of all the _current_ issues making tcl > > a bad language choice... > > Well, the troll aside, I do have quite a lot of experience with Tcl. Among > other things, I've written a workflow system on the Macintosh for generating > technical book catalogs using a combination of a relational database (4th > Dimension), image processing applications (Photoshop, NIH Image), page > layout and database publishing software (FrameMaker MIF) and other apps. Tcl > was used extensively as glue for doing things like process control and > analyzing Encapsulated Postscript files. The Tcl I used is the one embedded > in Pete Keleher's Alpha text editor, which is a real joy to use. I wish we > had something like it on NT. I've also used standalone versions of Tcl with > and without Tk. I worked with it a lot from about 1992 - 1996, writing many > useful apps. I've kept an eye on the language since then, and while I'm no > longer very Tclish, I reckon my basic take is still valid. > > My opinions are, of course, shaped by the way I work. I lean towards > practical applications that one person can write and maintain and still have > a life. Most of the time I find myself practicing the Mad Max > post-apocalyptic school of programming, that is, cobbling together > interesting artifacts that come my way from both commercial and > non-commercial sources. I'm lazy -- I try to write only what I have to, and > then I look for the easiest tools to use to do it. I'm a businessman, so I'm > always balancing cost, productivity, and performance. I'm also aware that an > attractive solution may carry many hidden costs. I'm not going to get into > much academic hair-splitting here. For my purposes I judge language > environments by how easy it is to get things done in them, not by whether > they have a recursively bi-directed optimizing monkee gland compiler. YMMV. > > Since the late 60's I've done practical programming in over 60 languages, > from FORTRAN, TECO, and microcode to Java, Python, and *Lisp, with many fun > stops in between (pause for chest-thumping and vine-swinging ;>), which > either makes me experienced or a fossil, depending on your point of view. > That said, here's my take on Tcl. > > What I like: > > Very readable syntax. A great language for writing more or less > self-documenting "dumb" code that you can come back 6 months or a year later > and still understand and modify. This is hard to overemphasize: clever > things _will_ be forgotten! > > It's super when embedded in a text editor. Alpha is a great example. > > It's a very nice hackery language. You can just whack away at things until > they do what you want. You don't have to be feeling sharp and clever on days > when you use it. > > The language itself is pretty stable, that is, it doesn't usually crash in > bad ways. > > It's one of the better languages for text processing. Not as nice as Perl, > but pretty darn good. Good regexp support. Lots of easy and elegant string > munging built in. > > Support for lists, while not deep, is elegant and simple as far as it goes. > I don't like it when languages make list operations a big cumbersome deal, > so I appreciate Tcl's elegance here. > > Support for hash tables (associative arrays, whatever...) is also elegant. > > These three things: clean support for lists, hash tables, and regular > expressions are enough in themselves to make a language attractive. They > just make life much easier for a practical programmer. > > GUI support via Tk is nice. It's a bit ideosyncratic, but good for many > things. It's not shrinkwrap-quality stuff, but think of all the great > languages whose inexpensive implementations are crippled by having little, > if any, support for GUI (Perl until recently), produce GUIs that feel slow > and clunky (Java), or make it cumbersome (like the joys of COM/IDL). > > Wiser folk than I have said a good language should make doing simple things > simple. Tcl succeeds in this. > > Good support for file system ops. > > Straightforward interfaces to C etc. are a good thing. > > Intangible fun factor. Tcl puts you in a good mood. It's easy. You feel like > you're cheating. You concentrate on the problem domain. You still feel good > when you look at the code six months later. > > Now the cold slimy part: > > Tcl scales very badly. All the same things in Tcl that make simple things > simple make complex things hard. Tcl is broad and shallow (which is not > always a bad thing). List structure doesn't really scale. There is no OOP > support to speak of, and although various people have hacked quick and dirty > examples, it's not something you would really want to build on. The very > brainlessness of Tcl is part of its appeal, but this is part of the price. > This is a _procedural_ language, which is actually nice on days when you are > too fuzzed out to think like a computer professional. It's not CLOS or > Eiffel, folks. It's not even Java. > Actually since version 8.0 Tcl has scaled quite nicely thank you, 8.1 has reduced the scalability of string operations due to a naive implementation of Unicode / UTF8 support but that will be fixed soon. > The cute hacks that make string munging kind of cool can also be confusing. > You tend to spend a fair amount of time (by Tcl standards) finding subtle > bugs in the way you expressed complex string concatenations and such. It's > not that the language is buggy in this regard. The rules are relatively > simple. But the subtleties are hard to keep in mind. Tcl makes string > processing so easy that you tend to quickly give yourself enough rope to > hang yourself with. Easy debugging takes some of the sting out. > > Tcl is slow. Oh, I know that's relative. For many applications it will be > fine. But complex parsing on large amounts of text can really drag. In one > application I needed to parse FrameMaker MIF files. These are SGML-like > ASCII files that often stretch to 600k or more, and which give FrameMaker a > lot of its power as a database publishing platform. Tcl was dog-slow. Perl > was about an order of magnitude faster than Tcl. C++ using the STL was a bit > faster than Perl, but still distressingly slow. I ended up using "cheating > C++", which is C++ with a lot of C standard library calls in it. The C was > about another order of magnitude faster than Perl. Tcl is great for nabbing > some text out of a file and doing some clever things with it (like nipping > the image size data out of an EPS file), but a cruncher it's not. > Tcl can be used to crunch stuff but you just have to be very careful how you go about doing it. I have written a Tcl program to analyse the whole Tcl source which is nearly 5MB and it did it very fast indeed. > Perl can be much better for industrial-strength text processing. Perl has > better regexp handling than Tcl, in fact it's usually held up as the Tcl 8.1 now has the same (bar a few weird hacks) regular expression package that Perl has. > standard by which other regular expression packages are judged. Perl is much > faster than Tcl. Perl 5 has rudimentary OOP support, which is a lot better > than nothing and allows Perl to scale in ways Tcl can't. The comparisons OOP support doesn't imply scalabity does it ? > with Perl are important because Perl does a lot of the same things Tcl does > and more. For a long time the dilemma was that Perl was the better language, > but Tcl had a GUI. Now Perl has a Tk interface (I haven't used Tk from Perl, > so I can't vouch for its elegance). After a while, as I developed more > complex applications in the languages, I found myself abandoning Tcl in > favor of Perl because of the performance and scalability. Perl code lacks > the beautiful brainless stickiness of Tcl, though. Perl is a "clever" > language, with what many would describe as "line noise" syntax. Cleverness > is dreadful when you have to look at it six months later. Tcl is the glory > of "stupid" programming, which I lean towards whenever possible. But it will > drive you crazy the minute you need speed or want to encapsulate something. > It sounds as though you are being a bit unfair with Tcl. You seem to invest an awful lot of brainpower in Perl (not to deal with the problem but to deal with the language) but you don't spend any on Tcl because it is so simple. If you invested as much time learning how to program efficiently in Tcl as you do in Perl you would soon be able to match performance. > Tcl, Perl, and Python all hold out the promise of transcending the speed > problem via extensions written in C or another compiler language. This is > fine as far as it goes, but in the real world it's often difficult to fully > encapsulate speed-critical bits in separate modules (this could be the topic > of a whole thread). It's also somewhat complicated. Tcl makes it as easy as > anybody, but by the time you are organizing your work to the point where > you're designing a full component architecture, you're probably going to > find yourself thinking about using high-level compiler languages that let > you keep it all under one roof. > > Tk ports are slow to arrive on some platforms and are buggy for a while. It > took years for heroic volunteers to get a workable Tk on the Mac. I think > Tcl helped show the way, but many of its enthusiasts have drifted away as > more alternatives have become available. > > If you want to grind text, why not use Perl? If you want a slow, essentially > free hacking language with all the features of Tcl and very good OOP > support, why not use Python? And if you want a faster "scripting" language > based on the "Boy in the Bubble"* architecture, with built-in GUI, much > wider support, and a religion, there's always the J-word. > -- Paul Duffin DT/6000 Development Email: pduffin at hursley.ibm.com IBM UK Laboratories Ltd., Hursley Park nr. Winchester Internal: 7-246880 International: +44 1962-816880 From pphalen at teleo.net Sun Jun 13 14:04:52 1999 From: pphalen at teleo.net (Patrick Phalen) Date: Sun, 13 Jun 1999 11:04:52 -0700 Subject: Variations on a theme by "pound bang" References: <3763e75f.3265255@news.iol.ie> Message-ID: <99061311062410.00557@quadra.teleo.net> On Sun, 13 Jun 1999, Sean Mc Grath wrote: > Can anyone shed some light on the benefits of:- > > # !/usr/bin/env python > > as opposed to > > # !/usr/bin/python Yes: http://www.python.org/doc/FAQ.html From Christian.Tismer at p98.f112.n480.z2.fidonet.org Tue Jun 29 18:08:23 1999 From: Christian.Tismer at p98.f112.n480.z2.fidonet.org (Christian Tismer) Date: Tue, 29 Jun 1999 23:08:23 +0100 Subject: ANN: Stackless Python 0.2 Message-ID: <0000159c@bossar.com.pl> From: Christian Tismer "Gary D. Duzan" wrote: ... > =>The cost of a call comes from the slightly complicated > =>function setup which is done all the time. Frames belong > =>to the fastest available Python objects already, > =>like, say dictionaries. > > I thought that might be the case, which is the point I was making in > my earlier paragraph. I was just briefly pondering possibilities for > reducing frame memory management time, if it were necessary. I hoped it would be possible to save most of the frame initialization, in cases where the same function call appears in the same place again and again. The barrier is that I would have to keep references longer than necessary, so I'm not sure if that can be done. BTW, the continuations which I am just testing are doing a great job of creating hard to release references to frames. They are correct, but create some cycles, quickly. This project is becoming very time expensive already :-) cheers - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From mwh21 at cam.ac.uk Fri Jun 25 03:08:00 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 25 Jun 1999 08:08:00 +0100 Subject: total idiot question: +=, .=, etc... References: <877lov62z1.fsf@pbl.ddns.org> <7ks38p$l4m$1@brick.cswv.com> Message-ID: neelk at brick.cswv.com (Neel Krishnaswami) writes: > > It's just that writing self.__class__ is so *ugly*! Everything else > in Python is beautiful, too, which makes this stand out even more. > You want ugly? I think the whole area of calling base class functions is far uglier. You might have a base class like this: class C: def f(self,x): print self then a derived class that needed to call C.f would have to be written: class D(C): def f(self,x): C.f(self,x) print x I think needing `self' here sucks. It gets worse if there are keyword arguments, necessitating use of apply, or if the base class is in a different module. This can be combined with another irritation of mine, the lack of automatic initialization of base classes, to give a situation like this: base.py: class Base: def __init__(self,x,y,**kw): ... derived.py: import base class Derived(base.Base): def __init__(self,x,y,z,**kw): apply(base.Base.__init__,(self,x,y),kw) print z which I think is one of the ugliest things I've ever seen in Python that I couldn't think of a prettier way round. Ideas, anyone? twisted-ly y'rs Michael From xidicone at iname.com Mon Jun 28 09:20:19 1999 From: xidicone at iname.com (Jussi Jumppanen) Date: Mon, 28 Jun 1999 23:20:19 +1000 Subject: Zeus Editor Version 3.0 Beta Message-ID: <37777693.6EFE@iname.com> Zeus for Windows Version 3.0 Beta Release ----------------------------------------- The Zeus programmer's editor has been totally re-developed and the results of this full re-write are now ready in the form of an early beta version. The Zeus Beta Version 3.0 should work fine for Windows 95, Windows 98 or NT but at this stage it has only been rigourously tested against NT. For anyone interesting in test running the beta just point your browser to the following web site: http://www.geocities.com/SiliconValley/Monitor/6788/ But please remember it is beta quality software which means it is guaranteed to still have bugs! So what is new to Zeus: 1) New syntax highlighting engine should now support almost any language. 2) New plugable scripting modules allows you to write Zeus macro scripts using the Python, LUA or Small C macro languages. 3) New configuration model now makes it even easier for you to configure Zeus to do just what you want. 4) Enhanced compiler, project and tool support. 5) Improved keyboard mapping. Jussi Jumppanen Author of: Zeus for Windows, Win32 (Brief, WordStar, Emacs) Text Editor "The C/C++, Java, HTML, Pascal, Cobol, Fortran programmers text editor" Home Page: http://ourworld.compuserve.com/homepages/jussi/ From suzuki611 at okisoft.co.jp Sun Jun 6 21:30:06 1999 From: suzuki611 at okisoft.co.jp (Hisao Suzuki) Date: 07 Jun 1999 10:30:06 +0900 Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7j90va$6lk$1@cronkite.cc.uga.edu> Message-ID: In article <7j90va$6lk$1 at cronkite.cc.uga.edu>, graham at sloth.math.uga.edu (Graham Matthews) wrote: > I am completely confused by this statement. The two people that have > been advocating GC the hardest are myself and the author of Ruby. Since > Ruby has GC the author has clearly implemented a collector. ... Regrettably, I'd have to say that Ruby is (was?) suffering from its insufficient portability. Once I have used a certain i860 SVR4 box. On that box, Ruby did not run but dumped immediately with its twiddling the machine stack, while Python ran perfectly with no difficulty. As far as I know, the collector of Ruby has not changed so much since then. (I have before told this to the author of Ruby on a Japanese Pythoneers' mailing-list against his advocacy of Ruby, and now he appeared here again with just the same opinion before...) And one more thing: as the author of Ruby said, Ruby's user cannot specify her/his arbitrary code as destructor. If so were Python, it would not be matter what is the semantics of language in regard to storage management for users. Ignoring this point, the whole discussion might be irrelevant to Python. As you know from reading any Python-1.*.*/Doc/ext/ext.tex, GC has been taken into account already, and deliberately turned down from the current Python. Only a general or theoretical discussion would be no use here (except for some evangelism). --===-----========------------- Sana esprimo naskas sanan ideon. SUZUKI Hisao suzuki611 at okisoft.co.jp, suzuki at acm.org. From mwh21 at cam.ac.uk Sun Jun 13 12:19:47 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 13 Jun 1999 17:19:47 +0100 Subject: Interpolation (was: Keyword calling gotcha ?) References: <000d01beaa57$c3d2c780$9b9e2299@tim> Message-ID: "Tim Peters" writes: > I posted a link earlier to the Best Parsing Book on Earth; read the > first few chapters of that first. Which one was that? I think I missed it! Thanks, Michael From eric at unifix-online.com Wed Jun 30 02:28:38 1999 From: eric at unifix-online.com (Eric Boudaillier) Date: Wed, 30 Jun 1999 08:28:38 +0200 Subject: Python GUIs: Summary and Conclusion References: <99FA4A1A1280BEBD.0A1ABA62CC989479.4C2C6022F695BEAC@lp.airnews.net> <377805C8.C6BBD4C1@unifix-online.com> Message-ID: <3779B916.20AF33E6@unifix-online.com> John Michelsen wrote: > > Philippe, they look very nice. How did you use them with Python > and Tkinter? Any Python code that you would like to share > demonstrating BWidgets? I would be especially interested > to see use of the tree widget. Same as Tkinter: directly call tcl command To lauch the demo: cln46ib:ficus/FicusSrc > cd ../../BWidget/demo/ cln46ib:BWidget/demo > python Python 1.5.2 (#5, Jun 23 1999, 18:09:42) [C] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import Tkinter >>> app=Tkinter.Tk() >>> app.tk.call('source', 'demo.tcl') '' >>> But, if some volunteers would like to encapsulate BWidget in python classes... -- Eric Boudaillier Unifix - http://www.unifix-online.com/ From tim_one at email.msn.com Fri Jun 4 02:24:15 1999 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 4 Jun 1999 02:24:15 -0400 Subject: A problem with re.split() In-Reply-To: <87pv3en24q.fsf@pc-hrvoje.srce.hr> Message-ID: <001c01beae52$dee5b560$949e2299@tim> [Hrvoje Niksic] > I understand that the idea with "re" module is for it to behave as > closely to Perl's regular expressions as possible (which is why the > order of arguments in string.split and re.split is different, > string.split being the logical one). The regexp *language* was meant to be compatible with (a snapshot of then-current) Perl's, but there wasn't much desire to mimic the rest. WRT argument ordering, this was deliberate but for a different reason: every function in the string module takes "the string" as its first argument because that's the ordering that makes the most sense if you think of the string as being an object and the function a method of that object. Likewise every function in the re module takes "the regexp" as its first argument. Intra-module consistency was judged to be more important than inter-module consistency in the case of "split". Not a pure win, but still seems the lesser evil. > The problem is with re.split() in this case: > > $ python > Python 1.5.2 (#3, May 23 1999, 19:57:40) [GCC 2.8.1] on sunos5 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import re > >>> re.split('', 'foo') > ['foo'] > > Perl splits it to ['f', 'o', 'o']: > > $ perl -e 'print join(":", split("", "foo"))' > f:o:o Python won't change here (IMO) -- re.split needed to be compatible with the old regsub.split too, and (IMO) that had a more sensible rule than Perl's: when splitting on a pattern, never take an empty match as a split point. That's really all that's going on here; e.g., try perl -e 'print join(":", split(/b?/, "foobar"))' Did you expect f:o:o:a:r? I like Python's ["foo", "ar"] much better. BTW, Python's string.split also refuses to split on an empty separator. Also note: >>> list("foo") ['f', 'o', 'o'] >>> adopting-perl's-language-didn't-imply-adopting-its-accent-ly y'rs - tim From vlachid at otenet.gr Mon Jun 7 00:38:18 1999 From: vlachid at otenet.gr (Vlachidis Costas) Date: Mon, 07 Jun 1999 07:38:18 +0300 Subject: FREE HARDCORE TEEN PICS 6141 References: <7ja8ou$7j4$4641@nclient5-gui.server.virgin.net> Message-ID: <375B4CB9.79B220B6@otenet.gr> how to stop this??? qnmdjb at ffff.com wrote: > FOR THE BEST FREE TEEN SEX PICTURES VISIT: > > http://freespace.virgin.net/eric.johnston/freepics.htm > gldoqlclctgtcizceuovzqleir -------------- next part -------------- A non-text attachment was scrubbed... Name: vlachid.vcf Type: text/x-vcard Size: 366 bytes Desc: Card for Vlachidis Costas URL: From Colin.J..Williams at p98.f112.n480.z2.fidonet.org Wed Jun 30 07:56:16 1999 From: Colin.J..Williams at p98.f112.n480.z2.fidonet.org (Colin J. Williams) Date: Wed, 30 Jun 1999 12:56:16 +0100 Subject: A Python problem? Message-ID: <000015d4@bossar.com.pl> From: "Colin J. Williams" This script below illustrates what appears to be a problem with the identification of a module in a package. The example is borrowed from the linbot material. Colin W. ''' A Python problem? . ''' def main(): import sys print 'Start:',dir() s0= sys.modules import plugins.rptlib s1= sys.modules if s0 == s1: print 'sys.modules is unchanged' print 'After attempt to import plugins.rptlib:', dir() try: print dir(plugins.rptlib) except AttributeError: import sys print sys.exc_info() from plugins.rptlib import * print 'rptlib names now available:', dir() main() ''' ------------------------ Resulting Display ---------------------------- >>> Start: ['sys'] sys.modules is unchanged After attempt to import plugins.rptlib: ['plugins', 's0', 's1', 'sys'] (, , ) rptlib names now available: ['Link', 'add_problem', 'check_and_warn', 'config', 'debugio', 'doBotMain', 'doTopMain', 'get_title', 'linbot', 'linkList', 'main_index', 'make_link', 'nav_bar', 'open_file', 'opener', 'os', 'plugins', 'problem_db', 'proxies', 'read_registry', 's0', 's1', 'sort_by_age', 'sort_by_author', 'sort_by_rev_age', 'sort_by_size', 'string', 'stylesheet', 'sys', 'urllib', 'version'] ''' From Robert.Meegan at wcom.com Wed Jun 9 10:04:19 1999 From: Robert.Meegan at wcom.com (Robert Meegan) Date: Wed, 9 Jun 1999 14:04:19 GMT Subject: Scripting vs. "Real Programming" Message-ID: Greetings --- Even in the relatively short time that I've been using Python, there has been a notable shift in the focus for the questions and comments on C.L.P. In the past, it seems that Python was primarily used as a scripting language. That is to say, most of the programs written were small and intended to run for short periods of time, generally serving one well defined purpose. Now, an ever greater number of the contributors to this august forum are discussing issues that are more indicative of Python being used for large and complex programs. Some of the topics that highlight this change include: * Garbage Collection * Threading * Forking * Interprocess Communications It is a credit to our founding fathers (especially Guido) that Python is so well equipped with these tools. In general, they are complete and robust (my desire for more garbage collection does not imply that the current interpreter leaks memory, but rather that I can't be trusted to clean up after myself). What seems to be lacking are guides for creating large, stable programs using these tools. My wife is expecting a deliverable in about a month, after which I expect that there may be a few late nights. During this time, I hope to add a few entries to the FAQ regarding this topic. I would be grateful if people would offer suggestions for both questions and answers. I will attempt to collate the existing knowledge, as well as adding my own limited contributions. I am at your service, --- Robert -------------------------------- Robert Meegan MCIWorldCom - Cedar Rapids, Iowa 319.375.2416 From rdev at my-deja.com Wed Jun 30 15:18:38 1999 From: rdev at my-deja.com (rdev at my-deja.com) Date: Wed, 30 Jun 1999 20:18:38 +0100 Subject: theads & global namespaces Message-ID: <000015d0@bossar.com.pl> From: rdev at my-deja.com Two suggestions: - If you're running on Solaris, the thread won't get to run unless you give up some time. So try putting a time.sleep(.001) into your while loop. On NT, this is not necessary (don't know why.) - Your thread will only increment once and then exit, so you'll never see x>1. If you want to keep the thread running, put it in a while loop. Make sure you give up the time slice there as well. Roger Dev dev at opticominc.com In article <377A5C88.32A1FAB6 at notes.cba.ufl.edu>, andersdt at notes.cba.ufl.edu wrote: > Greetings all, > > I am trying to share globals between threads. Is is possible for me to > share globals between threads that call functions from different > modules? Thus far I have had little success. I ask this question > because I would prefer not to put all my code in one module. > > For example, I have 2 .py files: a.py and b.py. b.py contains the > function ('foo()') to be executed under the new thread, as well as the > global variable 'x'. a.py contains the call to > start_new_thread(foo,()). a.py also tries to use the global variable x. > > ========================================= > b.py > > x = 0 > > def foo(): > global x > x = x + 1 > > ========================================= > a.py > > from b.py import * > > if __name__ == '__main__': > > start_new_thread(foo, ()) > while 1: > if x != 0: > print x > > ========================================= > > So far, my code in a.py does not detect any change in x. Any > suggestions for a workaround? > > Many thanks, > > Taylor > > Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From hyoon at bigfoot.com Mon Jun 7 10:10:02 1999 From: hyoon at bigfoot.com (Hoon Yoon) Date: Mon, 07 Jun 1999 10:10:02 -0400 Subject: Python an Tcl/Tk 8.1 References: <7jaeof$7ja$1@news.rapidnet.com> Message-ID: <375BD2BA.9C960A06@bigfoot.com> Jared, First thing you should do is blow away all old tk*.dll and tcl*.dll's from your computer. If you have mult old copies Python will be confused. Then you have to set tk_library and tcl_library from autoexec.bat. Then use the Tcl/Tk that comes with python.exe installation. You should have no problem afterward. The docs do say that newest is problmatic. Hoon, Jared Hanson wrote: > > I am new to all of this. I am running Windows 98, and I just downloaded > Python and the newest version of Tcl/Tk (8.1). Unfortunately, it appears > that Python doesn't like this version. Doing an import Tkinter command > prints out an error message saying that its looking for 8.0 dlls. I was > wondering what files I need to change to point to 8.1 dlls in order to make > it work (if that would make it work at all) Or do I just need to get a copy > of the 8.0 dlls and stick them in the same folder. Any help you could offer > me would be appreciated, just reply to my post. > > Thanks, > Jared Hanson -- ***************************************************************************** S. Hoon Yoon (Quant) Merrill Lynch Equity Trading, yelled at yahoo.com hoon at bigfoot.com(w) "Miracle is always only few standard deviations away, but so is catastrophe." * Expressed opinions are often my own, but NOT my employer's. "I feel like a fugitive from the law of averages." Mauldin ***************************************************************************** -------------- next part -------------- A non-text attachment was scrubbed... Name: vcard.vcf Type: text/x-vcard Size: 202 bytes Desc: Card for Hoon Yoon URL: From greg.ewing at compaq.com Thu Jun 17 19:16:34 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Fri, 18 Jun 1999 11:16:34 +1200 Subject: Compiled main program References: Message-ID: <376981D2.61C7D46D@compaq.com> Clarence Gardner wrote: > > x = MakeMeMain() > del x Wouldn't it just be simpler to do MakeMeMain() Greg From arcege at shore.net Fri Jun 25 22:14:46 1999 From: arcege at shore.net (Michael P. Reilly) Date: Sat, 26 Jun 1999 02:14:46 GMT Subject: load_dynamic problem References: <7l0j58$cbh$1@nnrp1.deja.com> Message-ID: John Fisher wrote: : Hey folks, : I'm having a bit of trouble loading a C extension into Python 1.5.2. : I'm getting the error: : Traceback (innermost last): : File "", line 1, in ? : File "bpinter.py", line 9, in ? : PyBPMPD = imp.load_dynamic('PyBPMPD', 'PyBPMPD.so') : ImportError: ./PyBPMPD.so: undefined symbol: setdef : setdef, not written by me, but called from inside PyBPMPD.c, is : prototyped as: : extern int setdef(bpmparam *); : The module itself compiles without complaint with: : gcc -I/usr/include/python1.5/ -shared -o PyBPMPD.so PyBPMPD.c : I'd appreciate any ideas on the problem. I'm rather stumped. : Thanks, : John John, It sounds like "setdef" is in some library that you are not compiling with. Or "setdef" was typed incorrectly in your code: resolving symbols in shared objects is performed at runtime. When compiling the shared object, you must include library being referenced (the one that contains "setdef"). Preferably, that library will be a static library (.a), or you would have to set LD_LIBRARY_PATH (or LIBPATH on some systems) to point to the correct location at run-time. If the library is /usr/local/lib/libdef.so or /usr/local/lib/libdef.a, then add "-L/usr/local/lib -ldef" to the gcc command you have. Good luck, -Arcege From nathan at islanddata.com Mon Jun 21 14:06:48 1999 From: nathan at islanddata.com (Nathan Clegg) Date: Mon, 21 Jun 1999 11:06:48 -0700 (PDT) Subject: choosing random numbers with weights/probability? In-Reply-To: <929987267.6227@www.remarq.com> Message-ID: list = [('one', 25), ('two', 25), ('three', 50)] l = [] for x, y in list: l.extend([x] * y) item=whrandom.choice(list) Too bulky? On 21-Jun-99 kevinsl wrote: > I've been using the whrandom.choice routine and it's very > useful. But is there any way to add weights or > probabilities of being chosen to the items in the list? > > example: > > list=['one','two','three'] > item=whrandom.choice(list) > > Is there any way to say that 'one' and 'two' have a 25% > chance of being chosen, and 'three' has a 50% chance? > > I'm hoping there's already a module to do this... or else > I'll be writing my own.. ---------------------------------- Nathan Clegg nathan at islanddata.com From MHammond at skippinet.com.au Thu Jun 10 18:00:33 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Fri, 11 Jun 1999 08:00:33 +1000 Subject: COM dates References: <816010E2456BD111A48700805FBBE2EEFDF354@ex-quebec-u1.baan.com> <375F77C1.629FED7B@lemburg.com> Message-ID: <7jpcfb$9bn$1@m2.c2.telstra-mm.net.au> M.-A. Lemburg wrote in message <375F77C1.629FED7B at lemburg.com>... >Not sure how you would convert the Win32 PyTime objects into >DateTime objects though. If they implement the int() APIs, then >DateTimeFromTicks(pyTime) will do, otherwise there's also a >constructor DateTimeFromCOMDate(comdate) which takes the raw >COM date float as argument. "Win32 PyTime" dates and "COM dates" are the same thing. Although COM uses them most heavily, we decided to move the date support into the Win32 extensions, so everyone can use them. (Specifically, they are implemented in pywintypes15.dll, along with our Unicode objects, HANDLE objects, UUID objects, etc) FWIW, I personally use mxDateTime whenever I hit the many limitations in Python dates. As Marc said, I used DateTimeFromCOMDate, then work with the DateTime object. Can''t recall exactly how I convert it back, but it is definately there. Mark. From news at dorb.com Wed Jun 16 16:25:04 1999 From: news at dorb.com (Darrell) Date: Wed, 16 Jun 1999 16:25:04 -0400 Subject: GC In Python: YAS (Yet Another Summary) References: <1282571877-108998356@hypernet.com> Message-ID: Tried the lazy plumbo and it found a cycle in a large application I'm working on. And it was easy to fix, once found ::) It took 5min at least to find the cycle. I'm not complaining because it would have taken me a lot longer. But maybe there is a way to speed this up. Maybe the Guido idea of only tracking dictionaries and objects in dictionaries would be useful ? Or move find cycles to 'C' A nice feature might be to allow queries so lazy developers could find out where all the memory has gone. Such as when you have no cycles and still consuming 100meg. Hope no one finds a basic flaw. Until then I'm dumb, lazy and happy :) -- --Darrell From mwh21 at cam.ac.uk Tue Jun 22 02:36:46 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 22 Jun 1999 07:36:46 +0100 Subject: newbie idiom question References: Message-ID: Alex Rice writes: > Something I keep getting tripped up about is that objects being > iterated in "for" statements cannot be modified. > > I keep trying to do this: > > >>> eggs = [1,2,3] > >>> for spam in eggs: > ... spam = 'cooked' > ... > >>> eggs > [1, 2, 3] > >>> > > The tutorial says this: > > If you need to modify the list you are iterating over, e.g., duplicate > selected items, you must iterate over a copy. The slice notation makes > this particularly convenient: > > >>> for x in a[:]: # make a slice copy of the entire list > ... if len(x) > 6: a.insert(0, x) > ... > >>> a > ['defenestrate', 'cat', 'window', 'defenestrate'] > > Understood, but what if you want to modify each element in a list? > What's the best way to do this in terms of speed and elegance? I guess > I just haven't seen a good example of this yet in Python If I know I'm not going to be altering the length of the list, I generally do it like this: for i in range(len(a)): if is_cooked(a[i]): a[i] = "cooked" If the list might be changing length, then I generally do i = 0 while i < len(a): ... and keep track of i by hand. HTH Michael > What I'm unfortunately used to is this, in Perl: > > @eggs = (1,2,3); > foreach $spam (@eggs) { > $spam = 'cooked'; > } > print "@eggs"; > >>> cooked cooked cooked > > Thanks, > Alex Rice From bwarsaw at CNRI.Reston.VA.US Thu Jun 3 14:48:35 1999 From: bwarsaw at CNRI.Reston.VA.US (Barry A. Warsaw) Date: Thu, 3 Jun 1999 14:48:35 -0400 (EDT) Subject: Use of StringIO vs cStringIO in standard modules References: <8790a1620b.fsf@pc-hrvoje.srce.hr> <199906031425.KAA06935@eric.cnri.reston.va.us> <87aeuh5kqc.fsf@pc-hrvoje.srce.hr> Message-ID: <14166.52739.423023.826815@anthem.cnri.reston.va.us> >>>>> "HN" == Hrvoje Niksic writes: | try: | from cStringIO import StringIO | except: | from StringIO import StringIO I do this (though I use "except ImportError") in all my new code. Maybe Guido would take patches to the standard library (most of which probably pre-dates cStringIO) to effect this change? -Barry From skip at mojam.com Tue Jun 15 11:34:17 1999 From: skip at mojam.com (Skip Montanaro) Date: Tue, 15 Jun 1999 15:34:17 GMT Subject: GNU python? References: <3765B8B4.18DE0257@spots.ab.ca> Message-ID: <37667309.F9BBAE9A@mojam.com> Maxwell Sayles wrote: > > Looking to try out python... is there a GNU python for Win9x? and a > tutorial maybe? Not sure just how a GNU Python would differ from the real thing, but you can visit the Python Software Association's web site at http://www.python.org/ to find what you're looking for. There's a Windows Topic Guide (upper left corner of the screen) and a tutorial (click the Documentation link). -- Skip Montanaro | Mojam: "Uniting the World of Music" http://www.mojam.com/ skip at mojam.com | Musi-Cal: http://www.musi-cal.com/ 518-372-5583 From greg.ewing at compaq.com Sun Jun 13 17:47:22 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Mon, 14 Jun 1999 09:47:22 +1200 Subject: Solution to finalisation problem [Re: fork()] References: <000901beb424$b2878200$a49e2299@tim> Message-ID: <376426EA.B6C9729E@compaq.com> Tim Peters wrote: > > the combo of > finalizers, cycles and resurrection seems to be a philosophical mess even in > languages that take it all seriously. Indeed, which leads me to believe that the idea of giving objects a __del__ method is fundamentally flawed in the first place. Fortunately, there *is* a way to do finalisation that avoids all these problems. Instead of an object doing its own finalisation, it designates some *other* object to do its finalisation on its behalf after it is dead. The benefits of this are: (1) The object doing the finalisation is fully alive and operates in a predictable environment. (2) The object which triggered the finalisation is fully dead (its memory has already been reclaimed by the time the finaliser is called) and there is no possibility of it being resurrected. In Python, it might look something like this from the user's point of view: class FileWrapper: # Example of a class needing finalisation. # Has an instance variable 'file' which needs # to be closed. def __init__(self, file): self.file = file register_finaliser(self, FileWrapperFinaliser(file)) class FileWrapperFinaliser: def __init__(self, file): self.file = file def __finalise__(self): self.file.close() In this example, register_finaliser() is a new built-in method which stores the object and its finaliser in some special global dict. Whenever an object is reclaimed (either by refcount or M&S) the dict is checked for a finaliser for that object. If one is found, its __finalise__ method is called and it is removed from the dict. Note that the finaliser object shouldn't be given a reference to the original object (doing so would prevent it from ever becoming unreachable), but only enough information to enable the finalisation to be carried out. If a scheme like this were adopted, it should completely replace the existing __del__ method mechanism, so that there would be no difference between the finalisation of cyclic and non-cyclic trash. As such it would have to wait for Python 2.0. A-final-solution-to-the-finalisation-problem, Greg From holger at phoenix-edv.netzservice.de Mon Jun 14 05:21:44 1999 From: holger at phoenix-edv.netzservice.de (Holger Jannsen) Date: Mon, 14 Jun 1999 09:21:44 GMT Subject: os.mkdir() References: Message-ID: <3764C9A8.E9E33575@phoenix-edv.netzservice.de> High, Oleg Broytmann schrieb: > > On Wed, 9 Jun 1999, Holger Jannsen wrote: > > Look: > > >>>os.mkdir("c:\\blabla") > > OSError: [Errno 17] File exists: 'C:\\blabla' > > > > or > > >>>os.makedirs("c:\blabla\nana\gugu") > > produces > > OSError: [Errno 2] No such file or directory: 'c:\blabla\nana' > > os.makedirs("c:\\blabla\\nana\\gugu") > ^^ ^^ ^^ > > Double your backslashes. Oh, yes, sorry....;-<))) > Oleg. > ---- > Oleg Broytmann Netskate/Inter.Net.Ru phd at emerald.netskate.ru > Programmers don't die, they just GOSUB without RETURN. From ddainese05x at x25dsi.unive.it Tue Jun 15 13:33:18 1999 From: ddainese05x at x25dsi.unive.it (Diego Dainese) Date: 15 Jun 1999 17:33:18 GMT Subject: Basic python OOPs question References: <7jot0r$p32$1@nntpd.lkg.dec.com> Message-ID: On Thu, 10 Jun 1999 17:45:35 GMT, Daniel wrote: > Do I understand correctly that objects are removed > from the name space when they go out of scope? > And that they go out of scope based on indentation? > Yes. > If so is there a default function called on > objects that go out of scope? The __init__ > function is called when an object is created. > Is there a function that is called when the > object is destroyed? > The __del__ function. In the Chapter 3 of the Language Reference there is the whole list of these `special' methods. Bye, -- d i e g o -- To reply remove the numbers and the `x' from my address -- Sorry for my bad English! From daniel.mendyke at digital.com Fri Jun 18 14:02:36 1999 From: daniel.mendyke at digital.com (Daniel) Date: Fri, 18 Jun 1999 18:02:36 GMT Subject: wxPython under linux Message-ID: <7ke110$o4r$1@nntpd.lkg.dec.com> I've installed the wxPython rpm under RH 6.0 and I'm having the following problems. First, python can't locate the main module. wx.py is located in /usr/lib/python1.5/site-packages/wxPython. I've tried adding this path to PYTHONPATH but it still has no effect. Second, I can copy a simply script to the wxPython directory and run it from there, however, if I'm under KDE it fails with X-errors. If I switch to a generic window manager the script runs fine. Has anyone else had these problems? Can you offer me some suggestions to solve them? -Daniel From Klaus.Schilling at home.ivm.de Mon Jun 14 04:47:50 1999 From: Klaus.Schilling at home.ivm.de (Klaus Schilling) Date: 14 Jun 1999 10:47:50 +0200 Subject: OO (was: Why is tcl broken?) References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> <3762988E.C94AA252@iname.com> <3763C746.5CA8FE78@iname.com> Message-ID: <87pv2zjhhl.fsf@home.ivm.de> Andreas Bogk writes: > Fernando Mato Mira writes: > > > Although Dylan never really made it into "Fernando's elegibility list" > > because > > it was not a serious contender against Scheme and CL yet, it definitely got > > banished the day the Lisp syntax was dropped. I'm still waiting for the day > > when the Dylan fans will reinstate the alternative. > > This is an age-old flamewar. It just so happens that there are people > who like infix syntax and detest prefix, and then there are people who > love their parens and hate infix. Prefix rocks, infix is crap. Klaus Schilling From billtut at microsoft.com Wed Jun 16 17:02:18 1999 From: billtut at microsoft.com (Bill Tutt) Date: Wed, 16 Jun 1999 21:02:18 GMT Subject: do anonymous pipes normally work on NT? Message-ID: <4D0A23B3F74DD111ACCD00805F31D8100DB90DE0@RED-MSG-50> > From: radbit at my-deja.com [mailto:radbit at my-deja.com] > > > In article <4D0A23B3F74DD111ACCD00805F31D8100DB90DDC at RED-MSG-50>, > Bill Tutt wrote: > > Well, I finally noticed this thread, and I'll chime in with what I > found out > > so far: > > (No, I haven't figured it all out yet, its time for sleep.) > > > > Symptoms: > > python -u cat.py < cat.py is allowed to read from stdin. > > python cat.py < cat.py isn't allowed to read from stdin. > > python -u cat.py > blah is allowed to write to stdout > > python cat.py > blah isn't allowed to wrtie to stdout. > > python runproc.py (with -u) cat.py isn't allowed to write to stdout > > python runproc.py cat.py isn't allowed to write to stdout. > > > > -u does two things: > > 1) turns stdin/stdout into binary streams > > 2) turns off stdio buffering > > Hi > > maybe I'm missing something about what you are looking for: here are 2 > test scripts that work as anonymous pipes: > That's not the question... Anonymous pipes on NT work wonderfully. (just not the way we're expecting from this particular Python context) Calling SetStdHandle() is particularly silly as well, you shouldn't need to overwrite the current stdout just to get this to work. > win32file.WriteFile(std_out, 'this method works....') > Calling GetStdHandle shouldn't be necessary either. The CRT already grabbed that information for us when Python started up. The question is why does sys.stdout.write() not seem to work without -u when the above line works wonderfully.... I'm not worried about a working example of anonymous pipes in general, thats the easy part. Bill From gerrit at nl.linux.org Sat Jun 12 11:39:28 1999 From: gerrit at nl.linux.org ('Gerrit Holl) Date: Sat, 12 Jun 1999 17:39:28 +0200 Subject: Raw Strings! In-Reply-To: ; from SunitJoshi on Sat, Jun 12, 1999 at 10:30:16AM -0500 References: Message-ID: <19990612173928.A23568@humbolt.nl.linux.org> On Sat, Jun 12, 1999 at 10:30:16AM -0500, SunitJoshi wrote: > From: "SunitJoshi" > Newsgroups: comp.lang.python > Subject: Raw Strings! > Date: Sat, 12 Jun 1999 10:30:16 -0500 > To: python-list at python.org > > Hi All > If someone could show me how to use raw-strings with variables, I > would really appreciate it. > For e.g.: if str_path = "C:\\windows\\temp" > var = r"D:\\stupid\\windows\\path" note the "r" of "raw" before the string. This is always the case. 9 minutes and i reply... hmm, not bad :-) regards, Gerrit. From chega_ at yahoo.com Tue Jun 1 01:49:46 1999 From: chega_ at yahoo.com (Vadim Chugunov) Date: Mon, 31 May 1999 22:49:46 -0700 Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com><87pv3iq6ss.fsf@ev.netlab.co.jp> <3752C76D.604CD474@prescod.net> <87n1ykr0z9.fsf@ev.netlab.co.jp> Message-ID: <7ivs9q$dc5@news.dns.microsoft.com> > Remember the original statement is like this: > > >As many people have noted before, you would not be able to use > >destructors to free up resources like memory or file descriptors. > >which, as I understand, means destructors can not be used with real >GC. That's just not true. I'm sorry for being unclear, but the key words here were: "to free up resources". And I meant "to free up resources the moment I expect them to", not "some time later". BTW, this is a common expectation from anyone coming from a C++ background. In C++, deallocation in destructors is the only way you can use exceptions without leaking resources. Vadim From yopen at my-deja.com Sat Jun 26 17:47:27 1999 From: yopen at my-deja.com (Bill Wilkinson) Date: Sat, 26 Jun 1999 21:47:27 GMT Subject: Environment inheritance under Windows NT References: Message-ID: <7l3hpf$84v$1@nnrp1.deja.com> In article , "Milton L. Hankins" wrote: > Python doesn't seem to pick up the environment from its parent process > under Windows NT. > > If I set an EV (environment variable) in the Windows NT System control > panel applet, then run a command prompt and use the SET command to change > the variable's value, then run Python at that same command prompt, > os.environ reflects the old (control panel) value of the EV. yeah, bummer huh... This has nothing to do with python, but with how NT handles environment variables. If you take a look after you change the variable using "set", you will notice that there are actually two copies of your variable. The new one can be changed on demand in the current window. You can ease the pain a little by using the setx.exe utility that comes with the resource kit. I am sure there is somthing in the pythonwin extensions that would handle this as well. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From pduffin at mailserver.hursley.ibm.com Fri Jun 11 08:39:50 1999 From: pduffin at mailserver.hursley.ibm.com (Paul Duffin) Date: Fri, 11 Jun 1999 13:39:50 +0100 Subject: Why is tcl broken? References: <375F82C7.CF0F0477@iname.com> <375FF969.C879B4CD@iname.com> <37601668.D9105225@mayo.edu> <3760E130.7456447@iname.com> <3760FA1F.7BCD@mailserver.hursley.ibm.com> <3761021C.8C029142@iname.com> Message-ID: <37610395.6799@mailserver.hursley.ibm.com> Fernando Mato Mira wrote: > > Paul Duffin wrote: > > > In Tcl if you want to pass a "reference" you pass a variable name > > I was refering to this, hence the quotes. Then I can assure you that "dynamic scoping" is not a problem. -- Paul Duffin DT/6000 Development Email: pduffin at hursley.ibm.com IBM UK Laboratories Ltd., Hursley Park nr. Winchester Internal: 7-246880 International: +44 1962-816880 From tim_one at email.msn.com Wed Jun 23 01:14:05 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 23 Jun 1999 01:14:05 -0400 Subject: List <-> news hosed again? Message-ID: <000201bebd37$36eff8e0$cb9e2299@tim> Seems to me the c.l.py mailing list -> news gateway stopped cold again late last week. Less sure of the other direction, but I do believe I've seen some older recent articles on DejaNews that haven't come thru on the list. If you're reading this and are not on the mailing list, share the secret . another-day-another-day-ly y'rs - tim From jcw at equi4.com Sat Jun 19 06:56:36 1999 From: jcw at equi4.com (Jean-Claude Wippler) Date: Sat, 19 Jun 1999 12:56:36 +0200 Subject: Python source code documentation? References: <7kdv0l$n0g$1@nnrp1.deja.com> <7kenc7$1od$1@m2.c2.telstra-mm.net.au> Message-ID: <376B7764.D26F56FF@equi4.com> Mark Hammond wrote: > > Sam Schulenburg wrote in message <7kdv0l$n0g$1 at nnrp1.deja.com>... > >I have been using a freeware product called Autoduck to document my > >Python source code. > > Cool! I use AutoDuck to document all my Python extension C++ code. [...] > However, depending on how far you have gone with AutoDuck, > pythondoc/gendoc isnt solving the exact same problem. Well, they all > attempt to solve the same problem, but have different strengths. Another package you may want to look at is Mark Peskin's Perceps: http://friga.mer.utexas.edu/mark/perl/perceps/ The following site docs for a C++ library were done with it (frames and all, but I didn't want to activate the Java class hierarchy browser): http://www.equi4.com/metakit/info/docs/ Perceps was written in that other p-language, last time I checked. 'nother idea, since we have some many of these tools, and so many languages (including SWIG, which also disects definitions), why not define a "language -> XML" defs/docs extractor, plus a package which turns that into docs, pdf's, help files, web sites (indexed), and such? -- Jean-Claude From poinot at onera.fr Wed Jun 16 03:43:33 1999 From: poinot at onera.fr (Marc POINOT) Date: Wed, 16 Jun 1999 09:43:33 +0200 Subject: pygtk - clist title button Message-ID: <376755A5.15621A4@onera.fr> Hmmm... a question about pygtk, but I guess it's more gtk than python :} I make this public instead of sending it to James Henstridge as a private email (or to gtk list). How to connect a signal to a clist title button? Marcvs [alias \begin{flame} What about using Gtk instead of Tkinter in the Python "core" built ? \end{flame} ] From emile at fenx.com Thu Jun 10 15:12:38 1999 From: emile at fenx.com (Emile van Sebille) Date: Thu, 10 Jun 1999 12:12:38 -0700 Subject: Scripting Telnet Message-ID: Hello all, I've accepted a project and I think I can use Python for part of it. The project is moving data collected in a warehouse management system into a proprietary, legacy CHUI application. The information is to be processed hourly by a cron job under HPUX. Most of the legacy app source code is available, but there are some black boxes in there I can't get at. The app doesn't like standard input redirection, but will run in a telnet session. My choices appear to be 1) write a utility in the native app's environment the mimics the result set of the current app (and I _really_ don't want to wade through that crap to figure it out); or 2) script the input requirements and feed the application while it runs (I've done this for smaller projects using VB sendkeys). I feel that python ought to be good for this, and I'm hoping you'll point me to the appropriate modules to look into or techniques to use. I did a little browsing through dejanews and saw a reference to perl's expect that looks like it does this kind of work, so maybe there's a python tool too? Trying-to-get-paid-and-learn-more-python-at-it-ly y'rs, -- Emile van Sebille emile at fenx.com ------------------- From rhww at erols.com Thu Jun 10 09:19:12 1999 From: rhww at erols.com (R Wentworth) Date: Thu, 10 Jun 1999 09:19:12 -0400 Subject: Debug: Module to track python objects. References: <11A17AA2B9EAD111BCEA00A0C9B4179301E10EF0@forest.origin.ea.com> Message-ID: <375FBB50.D53B7DFC@erols.com> > I'm open to comments, include those designed to make it more effecient, > powerful or easier to use. David, One thought on ease of use... you could easily set things up so that classes did not need to initially be defined with your Debug package in mind. This might work as follows (this hasn't been debugged): class "Debug": class WrapMethod: "Helper class to wrap a class method" def __init__(self,appendfunc, method=None): self.appendfunc = appendfunc self.method = method def __call__(self, *largs, **kargs): if self.method: apply(self.method, (self,)+largs, kargs) if __debug__: apply(appendfunc, (self,)) def DebugClass(self, Class): "Add debugging functionality to class Class" if hasattr(Class, "__del__"): Class.__del__ = self.WrapMethod(self.LogDel, Class.__del__) else: Class.__del__ = self.WrapMethod(self.LogDel) if hasattr(Class, "__init__"): Class.__init__ = self.WrapMethod(self.LogInit, Class.__init__) else: Class.__init__ = self.WrapMethod(self.LogInit) if hasattr(Class, "__destroy__"): Class.__destroy__ = self.WrapMethod(self.LogDestroy, Class.__destroy__) else: Class.__destroy__ = self.WrapMethod(self.LogDestroy) ... class MyClass: ... debug=Debug() debug.DebugClass(MyClass) In addition, you could write a "DebugModule()" method which, given a module, would find all the class definitions and apply DebugClass() to each. name? Finally, the name "Debug" is a bit generic for a module. Maybe something like "ObjLifeDebug"? FWIW, Bob Wentworth "Stidolph, David" wrote: > > First and foremost I want to thank Guido for the traceback system - just > having made this module possible and my task MUCH easier. > > This is an update to a debugging module that I posted before. See the end > of this mail for the module. > > Purpose: The Debug module tracks python class instances between their > __init__ and __del__ method calls. The idea is to provide tracking for > objects so that a report can be generated with objects that have not been > freed. When we first ran this on our code we found almost 300 objects that > were not being destroyed (more than half were windows resources like graphic > texture files). > > Asumptions: The __init__ method of every class calls LogInit method of the > debug class. The __del__ method calls LogDel. We have a special method > called Destroy for every class that is designed to remove references to > other objects and handle the circular reference problem. The Destroy method > calls LogDel > > Useage (we have a Globals module with specific instance variables to grant > access to modules like Debug): > > #sample > import Globals > > class Name: > def __del__(self): > if __debug__: > Globals.debug.LogDel(self) > > def __init__(self): > if __debug__: > Globals.debug.LogInit(self) > # your code > > def Destroy(self): > if __debug__: > Globals.debug.LogDestroy(self) > # your code > > Questions: > > 1. We are losing the tracebacks. At some point the output terminates. This > happens after a large output, so I suspect a buffer overrun. > 2. Can we shrink the tracebacks? Keeping all the strings while the program > runs seems a little much. We also want to modify the output for MSVC. > 3. Is there any other tracking we can do for catching bugs? Ways to enhance > this module? > > > Thank you for your help, > > David Stidolph > Origin. [detailed code omitted] From aahz at netcom.com Wed Jun 2 11:33:44 1999 From: aahz at netcom.com (Aahz Maruch) Date: Wed, 2 Jun 1999 15:33:44 GMT Subject: Alien whitespace eating nanovirus strikes again! References: <375500C9.742DC539@pop.vet.uu.nl> <375536C2.DD917F99@prescod.net> Message-ID: In article <375536C2.DD917F99 at prescod.net>, Paul Prescod wrote: > >I consider it a compliment that he can't find anything real to point out >as Python's contribution to language fascism but I also find it >distressing that he feels the need to sow the seeds of fear, uncertainty >and doubt in the minds of would-be Python users. The Python feature that >most of us (in retrospect, unnecessarily) worry about before trying Python >is the whitespace handling. Larry can only turn people off of Python by >suggesting that that is Python's central feature or philosophy. I disagree with your parenthetical comment. I wouldn't call myself an "expert" Python programmer by any stretch of the imagination, but I've written a fair bit of it in connection with a multi-person project over the past four months. As a seasoned programmer of many years and many languages, I've disagreed with almost all the whines that have been brought against Python (e.g. the stupid "=" vs. "==" thread), but this is one point that still annoys me. Oh, I've gotten used to it, no question about that, and I even appreciate the readability when it comes to working over someone else's code (which is what I've mostly been doing). But the whitespace problem is a real PITA when it comes time to make a change to the structure of a program -- it's an investment I don't mind making when I'm doing "real" programming, but when I'm making a bunch of quick, fiddly changes to debug something it continually gets in my way. I'm not trying to push a change, mind you. I'm just pointing out that IMAO the whitespace issue is a legitimate complaint. There are plenty of real issues to be worked on, though. -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het "NRE is a lot like cocaine. Feels great while you're on it, makes you feel very special and talented, and you become highly annoying to those who aren't on it." -- Stef From aahz at netcom.com Thu Jun 24 12:31:41 1999 From: aahz at netcom.com (Aahz Maruch) Date: Thu, 24 Jun 1999 16:31:41 GMT Subject: class static vs. module global Message-ID: I have a module aC, which conveniently holds a class aC. During some recent changes, I needed to share information across class instances. Primarily to localize things, I elected to store the information in the class. Anyone want to share opinions on why I should instead have used a module global variable? Or perhaps a different approach? (Some additional information: instances of aC get invoked by aQ; with the exception of two methods, aQ knows nothing about the actual workings of aC, so storing the info in aQ would be a bad idea. If it helps any, the information I'm storing in aC is essentially a cache that gets flushed regularly. Also, I was trying to preserve the structure of existing code as much as possible to make testing and re-integration easier.) -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Javascript: The 90s incarnation of the Commodore 64 Sprite -- SJM From tismer at appliedbiometrics.com Tue Jun 8 15:17:52 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Tue, 8 Jun 1999 19:17:52 GMT Subject: fork() References: <000601beb1c7$682c6220$559e2299@tim> <7jjghd$9il$1@cronkite.cc.uga.edu> <375D5826.23197692@inrialpes.fr> Message-ID: <375D6C60.FF9998DE@appliedbiometrics.com> Vladimir Marangozov wrote: > > Graham Matthews wrote: > > > > Tim Peters (tim_one at email.msn.com) wrote: > Graham, you said that you won't contribute a RC+GC scheme to Python, despite > your positive experience. If you change your mind and consider > devoting some spare time to give it a try, I'll devote some spare > time to help you with Python's internals and we'll see whether we > could come up with something viable, which could compete with the > actual RC scheme alone. Does this sound constructive enough? :-) Just an idea here: If we have knowlegde of the internals of every Python structure, and if there were no hidden internal references to Python objects, then we could quite easily build a non-pessimistic GC, without the need to be hardware specific, scan the stack and so on. You know that I have an (early) Python with no stack. Would this help? Let's assume that we use our own allocator. Something which allows to create a couple of heaps which can be identified. Now, with every new interpreter incarnation, a new heap could be associated. Under the assumptions that - only known types are garbage collected - only known (well-behaved) functions are called, it seems to be safe to me to run a garbage collector for all these objects which were created in the current interpreter. And since stackless Python has very few interpreters (after the imports, there is almost just one), very many objects would have this nice property. I don't know how to handle calls to unknown functions. Perhaps, parameters to such functions must me recorded in some structure which marks them as "unsafe to collect". What do you think? -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From jhauser at ifm.uni-kiel.de Sun Jun 27 13:39:39 1999 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 27 Jun 1999 19:39:39 +0200 Subject: Python for large projects? References: <3774b5d1.690922@news.force9.net> Message-ID: <87d7yhv8ys.fsf@lisboa.i-did-not-set--mail-host-address--so-shoot-me> Jody Winston writes: > I've used Python for three large distributed applications (each > 100k > lines of Python). The only other recommendation that I would add is > to define interfaces to the code. If this is done with a product like > ILU or FNORB, you can then easily call the Python code from other > languages. In addition, you can replace critical sections with other > languages if needed. > I have thought about this as the perfect way to do ``data hiding'', publish only special interfaces for your data. Has this a significant overhead, if used on one machiene, or is it overkill just for this purpose :-)? __Janko -- Institut fuer Meereskunde phone: 49-431-597 3989 Dept. Theoretical Oceanography fax : 49-431-565876 Duesternbrooker Weg 20 email: jhauser at ifm.uni-kiel.de 24105 Kiel, Germany From arcege at shore.net Wed Jun 30 15:04:23 1999 From: arcege at shore.net (Michael P. Reilly) Date: Wed, 30 Jun 1999 19:04:23 GMT Subject: theads & global namespaces References: <377A5C88.32A1FAB6@notes.cba.ufl.edu> Message-ID: Taylor Anderson wrote: : Greetings all, : I am trying to share globals between threads. Is is possible for me to : share globals between threads that call functions from different : modules? Thus far I have had little success. I ask this question : because I would prefer not to put all my code in one module. : For example, I have 2 .py files: a.py and b.py. b.py contains the : function ('foo()') to be executed under the new thread, as well as the : global variable 'x'. a.py contains the call to : start_new_thread(foo,()). a.py also tries to use the global variable x. : ========================================= : b.py : x = 0 : def foo(): : global x : x = x + 1 : ========================================= : a.py : from b.py import * : if __name__ == '__main__': : start_new_thread(foo, ()) : while 1: : if x != 0: : print x : ========================================= : So far, my code in a.py does not detect any change in x. Any : suggestions for a workaround? This isn't just a threads problem, but a namespace problem. When you create a variable, it is a name bound to an object, a reference if you will. When you assign to that same name, often another object will be bound. When you import using "from...import *" you create new bindings to these objects in the new module, but not referencing the same bindings. What this means is, when you use "from...import...", assignments within the module can be hidden from the calling module: Python 1.5.2 (#14, Jun 11 1999, 16:31:09) [C] on aix4 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import foo >>> foo.x 1.0 >>> from foo import x >>> x 1.0 >>> x is foo.x 1 >>> foo.x = "hi" >>> x 1.0 >>> x is foo.x 0 >>> When foo.x was changed, x (in the local module) did not change with it, becuase the variable "foo.x" is not the same as the variable "x". Even if both pointed to the same object at first. Your solution is to import "b" and reference the variable as "b.x". [If your system is any more complex than what you describe above, you might have other problems with "x" within a multi-threaded environment if you do not have some type of synchronization.] -Arcege From Cepl at fpm.cz Wed Jun 16 11:31:31 1999 From: Cepl at fpm.cz (Matej Cepl) Date: Wed, 16 Jun 1999 16:31:31 +0100 Subject: Python-list digest, Vol 1 #455 - 20 msgs Message-ID: <1318D78C9072D11195C9006094EA98A72C2151@ocesrv> > From: Lars Marius Garshol > Date: 16 Jun 1999 16:59:53 +0200 > > You could very well use htmllib and just make an htmllib application > that writes the HTML back out again, and modify it slightly to do > heading numbering. I don't think HTMLFormatter would do you any good > for this sort of thing. > [MCepl] That was exactly my question: how to make filter with htmllib.py doing nothing and just copying HTML input on output? Matthew From mal at lemburg.com Fri Jun 4 05:18:32 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 04 Jun 1999 11:18:32 +0200 Subject: Changing environment variables into python variables References: <7j7f0t$165$1@nnrp1.deja.com> Message-ID: <375799E8.247758A0@lemburg.com> sragsdale at my-deja.com wrote: > > I'm writing a script that needs to import environment variables into > python as standard variables. I.E. if the environment variable USER is > set to 'soren', after my program starts up and does its thing I want > there to be a variable named USER with a value of 'soren'. > > When I try to write this in python, I have this error: > > ------------------------------- > import posix You should import os, not posix... > for var in posix.environ.keys(): > command = var+" = \""+posix.environ[var]+"\"" > print command > eval(command) This is dangerous, as someone may easily stick some Python code into your environ, e.g. WIPEOUT="+os.system('rm -rf /')+". Better do something like this: import os namespace = locals() for key,value in os.environ.items(): namespace[key] = value -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 210 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From mark at _spamspamlovelyspam_btweng.krakow.pl Thu Jun 17 17:10:10 1999 From: mark at _spamspamlovelyspam_btweng.krakow.pl (MK) Date: Thu, 17 Jun 1999 21:10:10 GMT Subject: Crawling Python Message-ID: <37695707.3168269@news.tpnet.pl> Hello everyone, While playing with anydbm module using IDLE 0.4, I have made Python to do the following: Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import anydbm >>> d=anydbm.open('c:\\any.db','n') >>> for i in range(1000): d[`i`]=`range(i,i+10)` >>> d.close() >>> >>> d=anydbm.open('c:\\any.db') >>> s='' >>> for i in d.keys(): s=s+d[i] >>> >>> len(s) 49035 >>> Then I tried was typing s only to see the string. Shell printed it after some 20 seconds, and then came to a crawl. It responded to a command once and then it hang indefinitely. Techically it does not crash, but it displays a prompt, accepts command and processes it for minutes for some unfathomable reason. Curioser and curioser, I have said to myself. Can't I have ~50K strings without Python crawling? I thought that unlike in other cases crawling was not max performance for _this_ kind of animal? v----e----r----y------s---l---o----w-----l----y------y'rs PS. I have tried the same thing in DOS executable -- above does not happen. Looks like only IDLE is affected. This is second feature, err, bug I have found in IDLE. Maybe somebody is willing to give me a job? ;-))) MK -------------------------------------------------- Reality is something that does not disappear after you cease believing in it - VALIS, Philip K. Dick -------------------------------------------------- Delete _spamspamlovelyspam_ from address to email me postmaster at 127.0.0.1 root at 127.0.0.1 webmaster at 127.0.0.1 From Eric.Boudaillier at p98.f112.n480.z2.fidonet.org Wed Jun 30 06:28:38 1999 From: Eric.Boudaillier at p98.f112.n480.z2.fidonet.org (Eric Boudaillier) Date: Wed, 30 Jun 1999 11:28:38 +0100 Subject: Python GUIs: Summary and Conclusion Message-ID: <000015a7@bossar.com.pl> From: Eric Boudaillier John Michelsen wrote: > > Philippe, they look very nice. How did you use them with Python > and Tkinter? Any Python code that you would like to share > demonstrating BWidgets? I would be especially interested > to see use of the tree widget. Same as Tkinter: directly call tcl command To lauch the demo: cln46ib:ficus/FicusSrc > cd ../../BWidget/demo/ cln46ib:BWidget/demo > python Python 1.5.2 (#5, Jun 23 1999, 18:09:42) [C] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import Tkinter >>> app=Tkinter.Tk() >>> app.tk.call('source', 'demo.tcl') '' >>> But, if some volunteers would like to encapsulate BWidget in python classes... -- Eric Boudaillier Unifix - http://www.unifix-online.com/ From Klaus.Schilling at home.ivm.de Mon Jun 28 13:51:07 1999 From: Klaus.Schilling at home.ivm.de (Klaus Schilling) Date: 28 Jun 1999 19:51:07 +0200 Subject: Why is tcl broken? References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> <37682DD3.43923243@compaq.com> <7ka2be$qja$1@nntp6.u.washington.edu> <37776FFA.2D85@mailserver.hursley.ibm.com> Message-ID: <876748mcxg.fsf@home.ivm.de> Marco Antoniotti writes: > Paul Duffin writes: > > ... > > > Correct. With Tcl you can create new control structures which > > are indistinguishable from the built in ones, you cannot do > > that in Python. Python is much more rigid in its syntax although > > it does have a lot of nice hooks to allow objects to behave > > in different ways. > > But you can do that much more easily and elegantly in the L-word > language :) It can be done best in the Scheme, by means of the almighty call-with-current-continuation, the best of all control structures, and define-syntax on top of it. Klaus Schilling From mlh at idt.ntnu.no Wed Jun 16 18:52:48 1999 From: mlh at idt.ntnu.no (Magnus L. Hetland) Date: 17 Jun 1999 00:52:48 +0200 Subject: Learning Python on first page at amazon.co.uk Message-ID: Subject says it all :) -- Magnus Making no sound / Yet smouldering with passion Lie The firefly is still sadder / Than the moaning insect Hetland : Minamoto Shigeyuki From pduffin at mailserver.hursley.ibm.com Fri Jun 11 07:50:46 1999 From: pduffin at mailserver.hursley.ibm.com (Paul Duffin) Date: Fri, 11 Jun 1999 12:50:46 +0100 Subject: Why is tcl broken? References: <375F82C7.CF0F0477@iname.com> <375FF969.C879B4CD@iname.com> Message-ID: <3760F816.6B53@mailserver.hursley.ibm.com> Fernando Mato Mira wrote: > > Lars Marius Garshol wrote: > > > * Fernando Mato Mira > > | > > | I'm trying to collect a list of all the _current_ issues making tcl > > | a bad language choice. > > > > You can find three interesting articles on this at > > > > > > Thanks. But the Sah article is not accessible, > and his homepage makes no reference to it. > > Regarding the Stallman article, it's a quite vague, > and it's not sure one can extrapolate from their TECO experience > to Tcl. > > About the Connoly one, the namespace issue seems to > be solved by [incr Tcl]. But what about that "interpreted > multiple times"? Is it just an efficiency issue, or a semantic > nightmare (maybe both)? > > What about dynamic scoping? > Dynamic scoping I assume describes the mechanism that Tcl uses to pass references through to procedures, namely that the calling procedure passes the name of the variable and the called procedure creates a link from its stack frame back to the calling procedures stack frame. If this is the case then it is just not a problem, unless you use it badly which of course could be said of just about any programming construct from "goto" to "multiple inheritance". Obviously some built in support for passing references would be nice but the BIG advantage that Tcl has over just about every other language apart from Lisp is its ability to morph itself (which of course can also be abused) so it is possible to do this in Tcl itself. > BTW, I just found: > > http://www.vanderburg.org/~glv/Tcl/war/ > http://www.vanderburg.org/~glv/Tcl/war2/ As with most of these articles they are out of date and the authors tend to have (although not all) an agenda of their own which REQUIRES that they prove Tcl (or whatever language they are 'analysing') is "bad". Take for instance the Connolly article. "Tcl has one great big huge namespace" 8.0 introduced support for namespaces "Tcl code is interpreted multiple times during the execution of a program. There is no intermediate form as in Python and Perl" 8.0 introduced a byte compiler The Stallman article written in 1994 is also way out of date and adversely affected by his agenda. Also considering his complaints about Tcl's syntax I was amazed to find that he chose Lisp because if you replace the '() with {} and replace all other () with newlines you end up with a Tcl program (almost). -- Paul Duffin DT/6000 Development Email: pduffin at hursley.ibm.com IBM UK Laboratories Ltd., Hursley Park nr. Winchester Internal: 7-246880 International: +44 1962-816880 From greg.ewing at compaq.com Thu Jun 17 20:16:56 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Fri, 18 Jun 1999 12:16:56 +1200 Subject: Why is tcl broken? References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> <37682DD3.43923243@compaq.com> <7ka2be$qja$1@nntp6.u.washington.edu> Message-ID: <37698FF8.BE29BB9@compaq.com> Donn Cave wrote: > > But I think > Tcl is syntactically more adaptable, where Python kind of makes > a virtue of its fixed ways. Yes, someone who likes languages with highly reconfigurable syntax would perhaps like Tcl for that reason. Personally I find that Python provides as much flexibility as I need or want almost all the time. Python's keyword arguments are quite useful for designing little sub-languages for certain contexts. Tk's option settings for widgets map naturally onto keyword arguments, for example. Greg From jlj at cfdrc.com Thu Jun 3 12:47:05 1999 From: jlj at cfdrc.com (Lyle Johnson) Date: Thu, 03 Jun 1999 11:47:05 -0500 Subject: pyGTK on Windows References: <3757D453.A302E757@interar.com.ar> Message-ID: <3756B189.DAD53068@cfdrc.com> I'll put in my plug for FOX: http://www.cfdrc.com/FOX/fox.html And though they're not quite ready yet, I'm working on the Python wrappers as we speak. Should be available within a week. Nahuel wrote: > Hi, im about to do a cross-plataform GUI application in Linux and > Windoze... i must > choose the GUI toolkit.. my question is .. can i use pyGTK under > Windows??? > > (I need a gui that can display a table with about 4000 lines without > crashing (not like Tk :)) > > Nahuel Greco. From pointal at lure.u-psud.fr Thu Jun 10 06:31:28 1999 From: pointal at lure.u-psud.fr (Laurent POINTAL) Date: Thu, 10 Jun 1999 10:31:28 GMT Subject: Why is tcl broken? References: <375F82C7.CF0F0477@iname.com> Message-ID: <375f92b4.618467559@news.u-psud.fr> [note Follow-up to: set to comp.lang.python] On Thu, 10 Jun 1999 11:17:59 +0200, Fernando Mato Mira wrote: for Python vs Tcl >: If you have references to articles of the sort, that will be useful, >: too. See http://www.cwi.nl/~sjoerd/PythonVsTcl.html I remeber having seen an article of a guy explaining why he switched from Tcl to Python for a large project... but I loose the URL. A+ Laurent. --- Laurent POINTAL - CNRS/LURE - Service Informatique Experiences Tel/fax: 01 64 46 82 80 / 01 64 46 41 48 email : pointal at lure.u-psud.fr ou lpointal at planete.net From tim_one at email.msn.com Wed Jun 9 22:22:00 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 9 Jun 1999 22:22:00 -0400 Subject: Python 2.0 In-Reply-To: <7jmb47$r22$1@cronkite.cc.uga.edu> Message-ID: <000801beb2e8$05e98760$af9e2299@tim> [various people gripe about finalizers in Java Graham asks for an explanation Tim paraphrases the Java Spec's section 12.6 ] [Graham Matthews] > There are two obvious answers to almost all the above problems in Python > > a) don't call finalisers for circularly referenced collected objects. > Instead just collect their memory. This is not perfect but better > than current Python which doesn't run finalisers on circularly > referenced objects nor collect their memory. Solve the problem by ignoring it? Guido would find that more attractive than I would . > b) better still use a two pass collector. If you don't know what that is > just think about what you need to do (or not do) in pass 1 to ensure > that all the objects needed for a __del__ method to execute in a known > environment are there. Java does this. Start the thread from its beginning again <0.5 wink>. circularly y'rs - tim From tim_one at email.msn.com Fri Jun 11 12:08:51 1999 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 11 Jun 1999 12:08:51 -0400 Subject: fork() In-Reply-To: <199906110443.AAA02408@eric.cnri.reston.va.us> Message-ID: <000901beb424$b2878200$a49e2299@tim> [Tim] >> ... >> Guido will also want a doubly-linked list (where the links don't >> count against the refcount!) so that when a dict goes out of >> existence via the normal refcount-hits-0 route, the dict can >> efficiently unlink itself from the list. [Guido Himself] > Probably, although everytime this comes up I try to figure out a > clever scheme to use a singly-linked list, where the zero-refcnt ones > are recycled at the next mark-and-sweep. When a class instance (not involved in a cycle) loses its last reference, I assume __del__ will still get called right away (else we're combining the worst features of all possible schemes <0.5 wink>). This is also the time to clear the instance's __dict__ (provided the instance __del__ doesn't resurrect the instance), and for the same reason. Ditto for ordinary dead objects of other kinds holding dicts. Provided those are true, it may not hurt much to keep the stripped dict hanging around (I see that dict.clear() releases the internal table memory, so all that's left is the dict header). OTOH, straightforward M&S (without generational etc gimmicks) is quite expensive, so you won't want to run it often; e.g., I don't think we can afford to wait until a thread dies to finish cleaning up all the non-cyclic trash (Perl gets away with waiting that long because it *doesn't* delay tossing any non-cyclic trash). >> ... >> So, ignoring that, you make one pass over the trash list just to run >> finalizers. > Bzzt! We only have a trash list of dictionaries. The finalizers are > typically on class instances (or extension type objects) that are somehow > referenced by those dictionaries! Ack, yes. I was regurgitating the (start of the) scheme we (w/ JimF) hashed out in email a few years ago, which tracked every object. Ignoring the wheels means it can't get up enough speed to fly . > Could we get away with not calling (user) finalizers on objects in > trash cycles at all? Since the finalization order is problematic at > best, this almost seems acceptable: in the formal semantics, objects > that are part of cycles would live forever, and as an invisible > optimization we recycle their memory anyway if we know they are > unreachable (I've got the feeling that I've seen this rule before > somewhere.) The usual dodge is to say that GC is emulating infinite memory, "therefore" the user has no right to expect finalizers to ever get called. It's usually used to justify not adding finalizers to a language, not to castrate the semantics of languages that already have them <0.7 wink>. Cycles are irrelevant to that line of argument, and if you introduce a distinction ("finalizers in cycles don't get called, all others do") then the "optimization" is not invisible: cleaning up the cycle can cause objects that are not *themselves* in a cycle to become trash, so *their* finalizers will get called (else the distinction is as inexplicable as a coin toss), but would not have been called had the cycle been left in unreachable peace. IOW, Humpty Dumpty sits on a cyclic wall. If the wall goes away, his poor little egg butt certainly notices, and especially if the wall doesn't get to toss out a pillow on its way to reincarnation as an omelet pan . > We'd still get complaints "my __del__ doesn't get called" from some > users, and the answer would still be "it's in a cycle -- use > an explicit close"; but those who know what they are doing can be > guaranteed that their memory [gets] recycled. The last clause should be stronger (if for no other reason than that those who know what they're doing can already worm around this!): those who *don't* know what they're doing get a guarantee that their memory will (eventually) get recycled. Certainly value in that. > In other words it would be no worse than today and for some people > it would be better. So far as that goes, yes. It would, e.g., be better for me -- I like to create an occasional cycle, and almost never write __del__ methods anyway. It would be more convenient not to need to write & call dict-clearing .close() methods. Hard to weigh that against the probable increases in memory and runtime; and, philosophically, you gotta admit it's a mess. OTOH, the combo of finalizers, cycles and resurrection seems to be a philosophical mess even in languages that take it all seriously. Don't know, Guido! I could live happily with it provided it didn't slow things down much, and especially provided I don't think about the semantics at all . But then I'm not a __del__-lover to begin with. Anyone following this who is? resurrection-should-be-reserved-to-gods-ly y'rs - tim From bwarsaw at cnri.reston.va.us Tue Jun 1 10:56:19 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Tue, 1 Jun 1999 10:56:19 -0400 (EDT) Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <87pv3iq6ss.fsf@ev.netlab.co.jp> Message-ID: <14163.62611.886487.694094@anthem.cnri.reston.va.us> >>>>> "YM" == Yukihiro Matsumoto writes: YM> I don't get it. There's no relation between destructors and YM> real garbage collection. For example, Java uses destructors YM> called finalizers, even though most Java VM use real GC. Interesting side-note, re finalizers and JPython. I recall JimH talking about finalizers during his JPython code review a few months back. Here's what I wrote down at the time: "PyInstances were 2-5x slower [than now] because __del__() was implemented in a finalize method. But [current] JVMs assume most classes don't have a finalize [overriding Object's no-op'd version] and having them on everything slows frees down /a lot/ [emphasis somebody's :) ]" Apologies to JimH for any transcription errors! But I think he's correct as implied by the discussion in section 12.6 of the Java Language Specification: "We encourage implementations to treat such objects [those that don't override Object.finalize() or do so only trivially] as having a finalizer that is not overridden, and to finalize them more efficiently." And if you look at the diagram and discussion in section 12.6.1, you can see why this might be so inefficient! -Barry From evan at tokenexchange.com Fri Jun 11 15:37:00 1999 From: evan at tokenexchange.com (Evan Simpson) Date: Fri, 11 Jun 1999 14:37:00 -0500 Subject: Any Production ZOPE sites we can visit? References: <37614A32.79FE554E@metricom.com> Message-ID: Michael Kersey wrote in message <37614A32.79FE554E at metricom.com>... > Are there many production Zope sites visible on the www? > It's a little tough to get my hands around how Zope works and what it > can do without good examples. The Zope.org site is its own best example; you can view source for any page. > Is Zope being used primarily for intranets? No idea. I run a whole collection of small sites on Zope, but the most extensive of them is members-only, so you might not really be able to see much. Nevertheless: http://www.sylvanfoa.com http://www.littlemotivators.com Someone on Zope-list recently opened a super-duper-all-singing-all-dancing-framed-JScripted site running on Zope, at: http://www.master.cit.be/c8/default.html From cwebster at math.tamu.edu Tue Jun 29 16:43:25 1999 From: cwebster at math.tamu.edu (Corran Webster) Date: 29 Jun 1999 20:43:25 GMT Subject: printing with print References: <377925EF.1CBB640F@starvision.com> Message-ID: <7lbb5d$121$1@news.tamu.edu> In article <377925EF.1CBB640F at starvision.com>, Angus MacKay wrote: >is there any other way to print that with print? >perhaps with a real function. Yes, use sys.stdout, which is a file object: Python 1.5.2 (#13, Jun 16 1999, 23:19:35) [GCC egcs-2.91.60 19981201 (egcs-1.1.1 on netbsd1 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import sys >>> foo = "there" >>> sys.stdout.write("Hi"); sys.stdout.write(foo); Hithere>>> Notice that it doesn't even put a newline in. Also, you'll need to do conversion to a string to get the result you want for foo = 2. >>> sys.stdout.write("Hi"); sys.stdout.write(str(foo)); Hi2>>> >foo = 2 >print "hi" + foo You could do the explicit string conversion here too: print "hi" + str(foo) Corran From amackay at starvision.com Wed Jun 30 15:43:48 1999 From: amackay at starvision.com (Angus MacKay) Date: Wed, 30 Jun 1999 12:43:48 -0700 Subject: ioctl in python References: <377A71D7.470AF9DA@starvision.com> Message-ID: <377A7374.C6919FD3@starvision.com> well it seems I have sort of solved my problem. if I use a string for the 3rd arg then it works properly: >>> fo=open('/tmp') >>> fcntl.ioctl(fo.fileno(), 0x80047601, "hi") '\001\000' >>> fo=open('/') >>> fcntl.ioctl(fo.fileno(), 0x80047601, "hi") '\000\000' >>> fo=open('/proc') >>> fcntl.ioctl(fo.fileno(), 0x80047601, "hi") Traceback (innermost last): File "", line 1, in ? IOError: (25, 'Inappropriate ioctl for device') the question is why? it will still fail with only 2 args or an int: >>> fcntl.ioctl(fo.fileno(), 0x80047601) Traceback (innermost last): File "", line 1, in ? IOError: (14, 'Bad address') >>> fcntl.ioctl(fo.fileno(), 0x80047601, 1) Traceback (innermost last): File "", line 1, in ? IOError: (14, 'Bad address') cheers, Angus. Angus MacKay wrote: > > is there some magic to the fcntl.ioctl() call? > > I can do these ioctl calls in C no problem (with a small wrapper): > (amackay at phat)~/tmp$ ./ioctltest /tmp 0x80047601 > 0x80047601: 1 > (amackay at phat)~/tmp$ ./ioctltest / 0x80047601 > 0x80047601: 0 > (amackay at phat)~/tmp$ ./ioctltest /proc 0x80047601 > /proc: Inappropriate ioctl for device > > that was the Linux ioctl for EXT2 version. > > but in python: > >>> a = 0 > >>> req = 0x80047601 > >>> import fcntl > >>> fo=open('/tmp') > >>> fcntl.ioctl(fo.fileno(), req, a) > Traceback (innermost last): > File "", line 1, in ? > IOError: (14, 'Bad address') > >>> From gherman at my-deja.com Fri Jun 25 04:05:36 1999 From: gherman at my-deja.com (Dinu C. Gherman) Date: Fri, 25 Jun 1999 08:05:36 GMT Subject: How to obtain an instance's name at runtime? References: <7kqpu8$7u1$1@nnrp1.deja.com> <3771127C.E40F9BF3@home.com> Message-ID: <7kvd8b$ueb$1@nnrp1.deja.com> In article <3771127C.E40F9BF3 at home.com>, Jim Meier wrote: > > Well, there sort of is a solution, but I don't think you're going > to like it. Incidentally, why are you trying to discover this? I'm > not a super-meister-coder, but I can't imagine a situation where > knowing this would be useful. Ok, I knew I was going to look like a dumb camel right after posting my question... Nevertheless there is a useful case of knowing such an instance's name, at least I believe I found one. Have a look at the following page, spot the question mark and you'll know what I mean: http://starship.python.net/crew/gherman/UMLgenTest.pdf But, PLEASE, don't start to ask me anything about the project itself!! It's all in a very pre-pre-pre-alpha phase... There might be some workaround solution in oder to get that name I want, as in some of the replied in this thread, but I'll evaluate that later... Regards, Dinu Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From Lyle.Johnson at p98.f112.n480.z2.fidonet.org Wed Jun 30 23:46:02 1999 From: Lyle.Johnson at p98.f112.n480.z2.fidonet.org (Lyle Johnson) Date: Thu, 01 Jul 1999 04:46:02 +0100 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? Message-ID: <0000160f@bossar.com.pl> From: Lyle Johnson I've already worked up the binary distribution of FXPy for Windows; I just forgot to mention it in the previous post. The binary installer can be found at: ftp://ftp.cfdrc.com/pub/FOX/FXPy-0.99.42-win32.exe I haven't worked up a binary distribution of the (C++) FOX distribution itself, primarily because it changes most every day :) But that is in the plans as well. Thanks, Lyle Mikael Lyngvig wrote: > On Wed, 30 Jun 1999 09:07:51 -0500, Lyle Johnson > wrote: > > >Just to add fuel to the fire, we now have a Python interface to FOX, a > >cross-platform GUI toolkit: > > > > http://www.cfdrc.com/pub/FOX/fox.html > > > >The latest version of the Python wrappers can be picked up at: > > > > ftp://ftp.cfdrc.com/pub/FOX/FXPy-0.99.42.tar.gz > > > >I don't know how the speed of FXPy would compare with some of the others > >mentioned (Tk, wxWindows, Qt, GTK, ...) but it would be worthwhile for > >some independent opinions. > > I'm downloading it now. The http URL is wrong, it should be > http://www.cfdrc.com/FOX/fox.html. > > The presentation seems promising, but I'd like to suggest a binary > distribution for PC/Intel computers. I know this is not common for > Unix distributions, but it's the norm for PCs. > > -- Mikael From fdrake at cnri.reston.va.us Tue Jun 29 14:02:26 1999 From: fdrake at cnri.reston.va.us (Fred L. Drake) Date: Tue, 29 Jun 1999 18:02:26 GMT Subject: RuntimeError? In-Reply-To: <000401bec10d$b5bc3a60$e19e2299@tim> References: <000401bec10d$b5bc3a60$e19e2299@tim> Message-ID: <14201.2610.316947.169868@weyr.cnri.reston.va.us> Tim Peters writes: > Honestly, I had never seen a RuntimeError before! I found this one by Ooh, lucky you! ;-) Actually, I've seen very few. > digging thru the source code to see when it gets raised. There's really no > pattern to it, and the RuntimeError docstring in Lib/exceptions.py When RuntimeError is raised by the interpreter itself, that seems to be the case. When documenting modules, I've seen that a lot of them do things like "raise RuntimeError" (note: no parameters) whenever they need to raise an exception and the programmer hadn't already defined an exception specific to the module. I consider this a real problem, since it becomes hard to catch just the right exception. The ones I've seen in modules didn't seem to be so serious, just lazy about defining new exceptions the might only get used in one place. I've not maintained a list of where I've see this, unfortunately: fixing them would be a worthwhile activity. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From matomira at iname.com Tue Jun 15 05:50:07 1999 From: matomira at iname.com (Fernando Mato Mira) Date: Tue, 15 Jun 1999 11:50:07 +0200 Subject: broken References: <1282792849-95706075@hypernet.com> <3764D7C3.718E125E@iname.com> <002f01beb64d$58e7b5f0$f29b12c2@pythonware.com> <37651951.ED54894E@acm.org> <005501beb674$c5575890$f29b12c2@pythonware.com> Message-ID: <376621CF.88C95B5E@iname.com> Fredrik Lundh wrote: > btw, while we're on this topic, here's an interesting > article by kent pitman: > > http://world.std.com/~pitman/pfaq/cross-posting.html > > "Why are crossposts generally antisocial? > - Physical Burden of Reading Crossposted News > - Consumption of Community Resources > - Targeted Audience > - Inclusivity and Exclusivity" Well, I have no time for reading that. Obviously crossposts are useful. I'll tell you how it works: 1.There's one issue A you want to investigate, and the people with a balanced view read different newsgroups, B, C, D, E. You even know that some people in E are too young and E is obviously a contender with A. As the people in E is quite alike that in D, you leave out E, even if you think it's more probable there's more people that actually know about A in E than in D. You know that B is a contender with A, but there's nothing you can do about it, as that seems to be the most promising group. So you _crosspost_ (not multiple post) to A,B,C,D 2. You have to explain that you want to be straight regarding A, so you give an example of how some thing C and is obviously not in a D tradition is `wrong' but good. So that the same could be true about A. 3. You correct a point regarding C (still on the same line), which relates to F, that you know about and it's good, but where something bothers you, specially because sometimes you _do_ consider F. You obviously have to add F to the discussion. 4. Nobody comes up with anything against A. So you learn that your preconceptions about A are wrong, that all the bad things that were said about A were religious, and that all you can do is express your stylistic and philosophical objections against A, but nothing more. The A people is happy. It has been a great victory, and something has changed from today. The A people fade off. 5. Suddenly, the silent B people start compaining. What vibe did you touch? Was it an explicit G vibe (you don't care about telling G because it's pointless, and you don't care about fixing G either, even if you `are a G' (by force)), or an implicit B vibe? Is it just some people that think they own the truth? And that do not like learning? (If something tells you you're right, and you already believe that, you learn nothing. If they tell you you're wrong, at least you'll contemplate the issue) Or is it that they were silent only while something bad about A was looming? 6. Suddenly, your beliefs about B are changed. It seems that even if B were good, you don't want to have anything to do about it, because then you would have to hang around with the Bs. And you think that maybe A is better just because the As are more mature (of course you've never set foot in A). Oh, are the As having a party. In conclusion, when choosing a language one must not underestimate the style of its community. And actually, not wanting to hang around in G, even if I have used G for the last 4 years has always struck me as basically perverse (actually, I even went offline for a couple years, as there was not a compelling reason to be wired. Occasionals emails and FTPs were enough). May I have my PhD in Anthropology now? ;-) From evan at tokenexchange.com Fri Jun 4 12:51:09 1999 From: evan at tokenexchange.com (Evan Simpson) Date: Fri, 4 Jun 1999 11:51:09 -0500 Subject: Alternative dictionary output format? References: <7j8pd8$f01$1@nnrp1.deja.com> Message-ID: I don't know if this is 100% bulletproof, but it has simple behavior: pctsub = re.compile('%(?!%*\()').sub def pfstr(s, pctsub = pctsub): '''Double all '%' except those leading up to a '(', for dict formatting''' return pctsub('%%', s) >>> pfstr("%(href)s/foo/bar?x=%m&y=%n") % {'href': 'baz' } 'baz/foo/bar?x=%m&y=%n' All percent signs pass unharmed, except for those in front of a left paren. In that case '%(href)' => 'baz', '%%(href)' => '%(href)', '%%%(href)' => '%baz', etc. Jeff Epler wrote in message ... On Fri, 04 Jun 1999 14:55:42 GMT, rael at my-deja.com wrote: >s = "%(href)s/foo/bar?x=%m&y=%n" (he wants to only substitute the %(href) and not the rest) s = "%(href)s/foo/bar?x=%%m&y=%%n" i.e., double the percents you want to have not interpolated at this stage of the game. A clever regular expression might be able to do this for you, but the way to write it 100% bulletproof escapes me. From MHammond at skippinet.com.au Wed Jun 9 08:58:55 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Wed, 9 Jun 1999 22:58:55 +1000 Subject: makepy not war References: <375DD2BE.D918CCCE@yahoo.com> Message-ID: <7jlobk$85f$1@m2.c2.telstra-mm.net.au> Flbill Blipf wrote in message <375DD2BE.D918CCCE at yahoo.com>... >I hope this is not too general of a question. > >After running makepy.py on a type library, how do I use >the resulting file? > >I know how to use win32com.client.Dispatch, and I kinda >sort of know how to use CoCreateInstance, QueryInterface, >etc. with C++. You should be able to just use "win32com.client.Dispatch", and it will magically use the makepy support. Print the repr() of a COM object with and without makepy support, and the difference should be obvious. If it doesnt, let me know (or search deja-news for discussions about how to use Notes, which is one that doesnt work correctly) Mark. From bhosu at my-deja.com Tue Jun 1 14:04:09 1999 From: bhosu at my-deja.com (bhosu at my-deja.com) Date: Tue, 01 Jun 1999 18:04:09 GMT Subject: Handling variable number of arguments. Message-ID: <7j17dm$pks$1@nnrp2.deja.com> Hi All, I am embedding Python in an application(C++). I would like to pass variable number of args to the python function. I could do that from python by using def foo(*args). How do I parse these arguments inside my application? In PyARg_ParseTuple, I have to know exactly how many args to read etc. I am using Python v 1.4. I was looking at PyArg_ParseTupleAndKeywords but that needs the args to be a dictionary. I am looking a similar thingy for lists. A typeical scenario of the usage is like, import foo foo.set_args('bar','=','1','2','3') where foo is the module containing the method implementation. Thanks, Bhosu. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From graham at sloth.math.uga.edu Wed Jun 2 16:50:33 1999 From: graham at sloth.math.uga.edu (Graham Matthews) Date: 2 Jun 1999 20:50:33 GMT Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7iv86a$iud@news.dns.microsoft.com> <87vhd7nsra.fsf@ev.netlab.co.jp> <3754F5D7.2B6E1954@pop.vet.uu.nl> Message-ID: <7j45ep$908$3@cronkite.cc.uga.edu> Aahz Maruch (aahz at netcom.com) wrote: : I'm curious: does GC provide any advantages other than its ability to : deal with circular references? You have obviously never worked on a large C project! GC promotes code modularity. For example say I am using some library, L, and I do a call to one of it's routines, say f, as follows, b = some_temporarily_allocated_thing a = L.f(some_arguments_including_b) Now at this point does my code have to decref b, delete b, incref a? The answers to all these questions depends on the precise calling conventions of the routine f in L. Now what say I had called function g in L, instead of f, then what would have been the answer to those questions? It depends on the conventions for g, which may of course be different to those for f. Moreover what happens if I upgrade to a new version of the library L -- then what are the answers to the above questions (they might depend on the version number of the library L!). In a garbage collection system you have none of these problems. Code modularity is improved. graham PS: before anyone scoffs I should note that I have encountered all of the above in large C projects. As well as the usual errors where the library code forget to incref/decref, or decreffed where they should have increffed, etc. -- Like a bird on a wire Like a drunk in a midnight choir I have tried in my way To be free From mhagger at blizzard.harvard.edu Fri Jun 18 16:12:26 1999 From: mhagger at blizzard.harvard.edu (Michael Haggerty) Date: 18 Jun 1999 16:12:26 -0400 Subject: Crawling Python References: <37695707.3168269@news.tpnet.pl> Message-ID: mark at _spamspamlovelyspam_btweng.krakow.pl (MK) writes: > >>> s='' > >>> for i in d.keys(): > s=s+d[i] Please, before you complain about Python's speed, think twice about the algorithm that you are using. The above algorithm is O(n^2), which means that if you have n keys the time it takes is proportional to n squared. That's because each time you add to the end of the string, the whole string has to be copied. (Unless there is a nontrivial optimization built into Python for this special case, but I don't think so.) But if instead you do >>> import string >>> s = [] >>> for i in d.keys(): >>> s.append(d[i]) >>> s = string.join(s, '') then you get exactly the same result in O(n) time, because s.append() doesn't have to copy each time. For large n the second algorithm will beat the first one every time, by an increasingly huge margin. It may be that idle has problems too, but at least part of this problem can be blamed on the algorithm. Michael -- Michael Haggerty mhagger at blizzard.harvard.edu From faassen at pop.vet.uu.nl Tue Jun 15 13:35:20 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Tue, 15 Jun 1999 19:35:20 +0200 Subject: GNU python? References: <3765B8B4.18DE0257@spots.ab.ca> <37667309.F9BBAE9A@mojam.com> Message-ID: <37668ED8.1103C514@pop.vet.uu.nl> Skip Montanaro wrote: > > Maxwell Sayles wrote: > > > > Looking to try out python... is there a GNU python for Win9x? and a > > tutorial maybe? > > Not sure just how a GNU Python would differ from the real thing, * It'd only come with the GNU Public license. * GNU Python would use the GNU coding style guidelines (in Python!) * It'd be used for Emacs extensions. * It'd do all those functional programming things. Closures and macros and so on. * Zope wouldn't have been developed because of the GPL, and then would never have been opensourced. * No COM support, unless provided by Cygnus. * Cygnus comes with 'peggton', an experimental development adding static type checking and more optimizations. * Any product of would have to be called GNU-Python , because after all the total size of the library modules imported by that product would be larger than the product code itself. Actually-I-like-the-FSF-ly yours, Martijn From tim_one at email.msn.com Thu Jun 3 00:01:38 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 3 Jun 1999 00:01:38 -0400 Subject: pickle vs .pyc In-Reply-To: <7j4rf5$5h0$1@mlv.mit.edu> Message-ID: <000901bead75$c7c04cc0$309e2299@tim> [Michael Vezie] > ... > This is the first I've heard of marshal. I take it from various > hints here and there that the .pyc files are handled internally > by marshal, yes? Yes, "code objects" in particular are the one type marshal can handle that pickle can't. I think we try to sell that as "a feature", though > > ... > One final asside, I've seen disagreements both online and in the > web docs about the spelling of marshal. Guido's spelling is the only one we'll mention here, thank you. > ... > marshaling-up-the-courage-to-convert-working-code-to-marshal'ly yrs > > ... (hoping-this-'ly yrs-tag-isn't-trademarked-or-only-available- > to-those-who've-achieved-some-level-of-pythondom'ly yrs) No particular qualifications, fees or exams are needed to use a "-ly y'rs" closing. I do own exclusive worldwide rights to it, but grant everyone an unlimited license in perpetuity. How can I afford to do this? Easy: there are only so many people out there who want to come across as an ass year after year . it's-not-the-form-it's-the-content-ly y'rs - tim From mal at lemburg.com Tue Jun 1 05:33:07 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Tue, 01 Jun 1999 11:33:07 +0200 Subject: Any Python-friendly web presence providers? References: Message-ID: <3753A8D3.6B0CAA70@lemburg.com> Matt Gushee wrote: > > Greetings, Pythoneers-- > > I'm working on setting up a (virtual) internet domain ... reserved my > domain name today ... now I need to find a place to put it. I would > like to use Python for CGI scripts. Before I wear myself out searching > the web, I thought maybe someone here could recommend a provider. You can use basically any decent provider which gives you at least a cgi-bin dir to execute CGI programs and a FTP connection. No need to have Python preinstalled; just install it yourself using one of these easy-install binaries: http://starship.skyport.net/~lemburg/mxCGIPython.html -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 213 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From rwentwor at bna.com Wed Jun 30 15:14:45 1999 From: rwentwor at bna.com (rwentwor at bna.com) Date: Wed, 30 Jun 1999 15:14:45 -0400 Subject: Reflection in Python? Message-ID: <852567A0.0069BB98.00@notes1.bna.com> Assuming you're working with Python class instance objects, something like the following might work: # define class class SillyMathTest: def testAdd(self, x, y): return x+y # create class instance object MathTest = SillyMathTest() # get reference to bound method MathTest.testAdd test = getattr(MathTest, "testAdd") # effectively do MathTest.testAdd(3,5) test(3,5) As to getting naming info: well, you already have the name of the method as a string, you can get the name of the class as MathTest.__class__.__name__, but there is no way to extract the string "MathTest" from the MathTest object because "MathTest" is the name of a variable referencing the object, not something that is really part of the object. (You couldn't do this in Java either, so I'm not sure what you had in mind.) Bob Wentworth --original message-- I've just started programming in Python, and I could really use some help figuring out something. I'd like to implement Kent Beck's unit tester in Python (someone posted a very nice alternative a few weeks ago, but Junit's approach works better for my project's needs). How do I do the equivalent of what Java calls reflection? I wantto do the following: test = MathTest("testAdd") where test.run() will run the "testAdd" method on the MathTest object? I also want to be able to tell the user the name of the object (MathTest) and the method in case the method fails. Anythoughts? From fbo at dde.dk Fri Jun 25 07:24:26 1999 From: fbo at dde.dk (Finn Bock) Date: Fri, 25 Jun 1999 13:24:26 +0200 Subject: Pb. with JPython & VisiBroker References: <7kr72p$942$1@news.imaginet.fr> Message-ID: <377366EA.AA48A43F@dde.dk> Franck Arnulfo wrote: > I try to use the scripting facilities of JPython with VisiBroker for Java > ORB. > But I've a problem to make an instance of the ORB. > Here is a copy of the output : > > C:\JPython-1.1beta2>set PATH > PATH=C:\jdk1.1.7B\bin > PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.JS > > C:\JPython-1.1beta2>set CLASSPATH > CLASSPATH=C:\jdk1.1.7B\lib\classes.zip;C:\vbroker\lib\vbjorb.jar;C:\vbroker\ > lib\vbjapp.jar > > C:\JPython-1.1beta2>pythonjdk11 > JPython 1.1beta2 on java1.1.7B > Copyright (C) 1997-1999 Corporation for National Research Initiatives > >>> from org.omg.CORBA import * > >>> orb = ORB.init(None, None) > Traceback (innermost last): > File "", line 1, in ? > NameError: ORB > >>> I known, this is not much help, but I can access the ORB just fine. [c:\storage]jpython packageManager: processing new jar, "C:\java\JPython-1.1beta2\jpython.jar" packageManager: processing new jar, "C:\storage\vbjorb.jar" packageManager: processing new jar, "C:\java\jdk1.1.8\lib\classes.zip" JPython 1.1beta2 on java1.1.8 Copyright (C) 1997-1999 Corporation for National Research Initiatives >>> from org.omg.CORBA import * >>> ORB.init(None, None) com.visigenic.vbroker.orb.ORB at 20db91 >>> I didn't properly install Visibroker. I just added a vbjorb.jar I found from a altavista search to my CLASSPATH. Consequently, I have no clue to which version of vbjorb.jar I'm using. -- Regards, Finn Bock From phd at emerald.netskate.ru Tue Jun 22 11:25:38 1999 From: phd at emerald.netskate.ru (Oleg Broytmann) Date: Tue, 22 Jun 1999 19:25:38 +0400 (MSD) Subject: restoring signal handlers In-Reply-To: Message-ID: On Tue, 22 Jun 1999, Nathan Clegg wrote: > Is it necessary to restore original signal handlers before quitting a No. > ---------------------------------- > Nathan Clegg > nathan at islanddata.com Oleg. ---- Oleg Broytmann Netskate/Inter.Net.Ru phd at emerald.netskate.ru Programmers don't die, they just GOSUB without RETURN. From n at n.com Mon Jun 7 13:05:21 1999 From: n at n.com (Jr. King) Date: Mon, 7 Jun 1999 13:05:21 -0400 Subject: more python to c/c++ questions. References: <7jgqas$6a6$1@rtpnews.raleigh.ibm.com> Message-ID: <7jgu2u$19s6$1@rtpnews.raleigh.ibm.com> Ok, I found some info on it but, it still doesn't work I changed my c module to this... static PyObject* objPass(PyObject *self, PyObject* args){ PyObject *result = NULL; PyObject *temp; if (PyArg_ParseTuple(args, "O", &temp)) { PyObject* xarg = Py_BuildValue("(s)","i"); xarg = PyObject_GetAttr(temp,xarg); // not getting anything but null int val; PyArg_ParseTuple(xarg,"i",&val); } Py_INCREF(Py_None); result = Py_None; return result; } Python module snippet class Cow: i = 10 x = 0 str = "string" def genie(self): print str testmeth.setCallback(setN) testmeth.testmeth(13,9) cow = Cow() testmeth.objpass(cow); Thanks jamarijr at liam_toh.com ^hotmail... Must spoil spammers From huy4huy at cs.com Wed Jun 2 14:47:40 1999 From: huy4huy at cs.com (HUY4HUY) Date: 2 Jun 1999 18:47:40 GMT Subject: need scripts...help Message-ID: <19990602144740.17875.00000120@ng-cf1.news.cs.com> I need a program that would automate an age verification system, I need the script to handle all aspects. It should have easy sign up for webmasters and surfers, anti cheater devices as well as the real time monitoring of all system activities, email notification to the webmaster joining to the admin, logs all traffic trough the system and gathers email addresses, built in password protection for admin area, no SSL's, no htaccess...this is an example of the format I need. I will appreciate it, if anyone can help me out......thanks -------------------------------------------------------------------- Mark Davidson inert28 at hotmail.com please inform with the information to the email address above, thanks. From NOSPAMbruce_wheeler at hp.com.NOSPAM Fri Jun 4 15:48:45 1999 From: NOSPAMbruce_wheeler at hp.com.NOSPAM (Bruce Wheeler) Date: Fri, 04 Jun 1999 12:48:45 -0700 Subject: python active web pages References: Message-ID: <37582D9D.3D7A4B1D@hp.com.NOSPAM> Jonathan Hogg wrote: > > hi there, > > i'm looking to embed python into web pages in a similar way to ASP and > PHP3 and so forth. > take a look at From salvador at my-deja.com Wed Jun 2 07:30:43 1999 From: salvador at my-deja.com (salvador at my-deja.com) Date: Wed, 02 Jun 1999 11:30:43 GMT Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <87pv3iq6ss.fsf@ev.netlab.co.jp> <3752C76D.604CD474@prescod.net> <87n1ykr0z9.fsf@ev.netlab.co.jp> <375372F6.A874554@prescod.net> Message-ID: <7j34l3$hbj$1@nnrp1.deja.com> In article <375372F6.A874554 at prescod.net>, Paul Prescod wrote: > Yukihiro Matsumoto wrote: > > > > >As many people have noted before, you would not be able to use > > >destructors to free up resources like memory or file descriptors. > > > > which, as I understand, means destructors can not be used with real > > GC. That's just not true. > > Is there a language with real GC where destructors are called as > predictably as they are in Python? No, but it could be done in Python, GC isn't incompatible with reference counting and both can be combined. A simple GC could be added just to detect ciclical data structures and remove it Even new special obect methods could be suported by the language to handle it, say __gc__, that gets called by the GC requesting the object to liberate its references to other objects so the ciclid data breaks. > > |But I think that the bigger problem with "real GC" is that C programs > > |often hang on to references to Python objects and any kind of compacting > > |GC would invalidate those references. > > > > It's the common legend especially here in comp.lang.python. > > > > >From my experience with Scheme and Ruby, both with real GC, the real > > GC is mostly very fast. > > Speed wasn't my concern. I asked about references in C code. Do we use > PyObject **s instead of PyObject *s now? GC doesn't need to move objects in memory, it's only an optimization that speeds up memory allocation (it could be implemented with reference counting too). The problems associated to GC an foreign modules are usually caused because the GC doesn't know enough about external objects to determine its references to native language objects. - Salva. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From Gaetan_Corneau at baan.com Wed Jun 9 22:44:31 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Thu, 10 Jun 1999 02:44:31 GMT Subject: COM dates Message-ID: <816010E2456BD111A48700805FBBE2EEFDF354@ex-quebec-u1.baan.com> Thanks Mark! Another question: why no "strptime" function under WIN32? This function is not, as far as I know, difficult to implement. Tnanks again, ______________________________________________________ Gaetan Corneau Software Developer (System integration Team) BaaN Supply Chain Solutions E-mail: Gaetan_Corneau at baan.com Compuserve: Gaetan_Corneau at compuserve.com ICQ Number: 7395494 Tel: (418) 654-1454 ext. 252 ______________________________________________________ "Profanity is the one language all programmers know best" > -----Original Message----- > From: Mark Hammond [SMTP:MHammond at skippinet.com.au] > Sent: Wednesday, June 09, 1999 6:41 PM > To: python-list at cwi.nl > Subject: Re: COM dates > > Check out the win32 extensions help file. This has a discussion of COM > dates. In a nutshell, you use the int() function to convert it to a > standard Python time module date, and you can assign a standard Python > time > module date to a COM date field and it will do the right thing. > > Mark. > From neelk at brick.cswv.com Mon Jun 28 23:09:10 1999 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 28 Jun 1999 22:09:10 -0500 Subject: [ANN] DejaGrabber 0.1 -- search Dejanews with Python References: <7kuu73$1ki$1@brick.cswv.com> <8DF363D15duncanrcpcouk@news.rmplc.co.uk> Message-ID: <7l9dcm$an$1@brick.cswv.com> In article , Markus Stenberg wrote: >duncan at rcp.co.uk (Duncan Booth) writes: >> Nice bit of work. Two comments though: >> Why does get_messages(4) return 5 messages? The doc string implies it >> should return only as many as its argument. > >It's neat, admittedly (I thought of writing one myself the other day, and >then found that one ;->). The first time I need to do some serious Deja >action, I'll be using it :>. > >There's some oops in slicing's internal logic at get_messages; following >patch fixed behavior (for me, anyhow). [Code snipped] Thanks -- I've applied the change and put the new version up. >> It would be useful if a test example was included in a "if >> __name__=='__main__'" block at the end of the file. At the very least the >> example you give above, but perhaps more usefully a full command line >> driven grabber. This is a good idea, but I'm not sure what the right interface would look like. I suspect that producing a command-line interface useful enough to play well with other tools would be a bigger job than the class itself -- a decent UI must be flexible, and flexibility is always trickier than it seems. That said, I'm all for it, and will probably take a shot at it RSN. A query can return multiple messages, and I think that we can want as output either: a) A list of headers, b) A big file of headers+messages, c) A lot of little files each with a message in it, d) A single HTML file with a list of headers with links to the message bodies (using HTML in-page links). Any I missed, or any of these fundamentally the wrong thing to do for a reason I'm not seeing? Neel From Christian.Caremoli at der.edf.fr Tue Jun 22 08:33:42 1999 From: Christian.Caremoli at der.edf.fr (Christian Caremoli) Date: Tue, 22 Jun 1999 14:33:42 +0200 Subject: creating dictionnaries Message-ID: <376F82A6.82497D2B@der.edf.fr> Hi, Dictionnaries can be created like that : d={'a':1,'b':2} By calling a function you create a dictionnary like that : def f(**d): return d d=f(a=1,b=2) I would like to be able to create dictionnaries with some similar syntax like keyed tuples : d=(a=1,b=2) Is there a way to do that ? Thanks Christian Caremoli From faassen at pop.vet.uu.nl Tue Jun 8 16:43:35 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Tue, 08 Jun 1999 22:43:35 +0200 Subject: In what order does Python read dictionary keys? References: <7jjnt5$snk$1@nnrp1.deja.com> Message-ID: <375D8077.EA539C6D@pop.vet.uu.nl> tcpeter at my-deja.com wrote: > > Hello, all. I've checked the docs and queried DejaNews for this but I > couldn't come up with an answer. I wrote a script to convert rgb > values to hex for when I'm doing colors in HTML pages and don't have > Photoshop handy. The code appears below. My question is, how does > Python decide in which order to read the keys? Notice that I have the > dictionary set up in this order: red, blue, green. (I mistyped it while > writing the code). But when I ran the code, the options were presented > in the desired order. (A trifle creepy, if you ask me. Turing would be > delighted.) Anyway, how does Python decide the order. Thanks. Hi there, The answer is that Python doesn't have any set orders for dictionaries. The internal hashing algorithm the python dictionary uses has no guaranteed order. So basically you shouldn't depend on any particular order it produces. Regards, Martijn From faassen at pop.vet.uu.nl Wed Jun 9 04:36:55 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Wed, 09 Jun 1999 10:36:55 +0200 Subject: "Programming Python" still worthwhile? References: <1283218560-70098357@hypernet.com> <7jl750$qsu$1@news.gstis.net> Message-ID: <375E27A7.4871EA36@pop.vet.uu.nl> Rick Robino wrote: > Gordon McMillan wrote: > > Python 2 is around a really, really big corner, and then down the > > block quite a ways. Python 1.6 sometime in 2000 (which will be > > backwards compatible), so no 2 until 2001 or 2002. > > I didn't do alot of research, but I couldn't get a good feel from > the huge thread that has been going on here named after 2.0. Appreciate > the ETA. Python 2, while one of the favorite topics, is actually (as far as known) in complete vaporware stage, and no public designs exist. Of course, Python 2 will also solve all our problems, be resistent to whitespace eating nanoviruses, and be both garbage collected and reference counted, automagically. It'll feature the solution to assignments in expressions too! For some reason Pythoneers in this newsgroup (me included) like to talk about improving the language, though it's a very nice language already. Although some see this as a bad sign, I think the fairly intelligent discussion that *usually* is the result is quite interesting. Some discussions excepted. :) Thanks to some newsgroup luminaries like Tim Peters (Tim, you're a newsgroup luminary now!), who seems to have programmed in just about any language in existence and can compare them all fairly to Python, the level of discussion remains fairly mature at most times. Though the latest Python 2 thread became a bit too emotional for my tastes in places. The *true* Python 2 things are the rare statements made by Guido on it (and rumors of his statements :). Regards, Martijn From aahz at netcom.com Wed Jun 16 00:39:21 1999 From: aahz at netcom.com (Aahz Maruch) Date: Wed, 16 Jun 1999 04:39:21 GMT Subject: Newbie: easy filecopy? References: <376531D3.7E42AC42@phoenix-edv.netzservice.de> <37665D08.267A697C@phoenix-edv.netzservice.de> Message-ID: In article <37665D08.267A697C at phoenix-edv.netzservice.de>, Holger Jannsen wrote: > >The problem with >f=open(aFile) >x=f.read() >f.close >f.open(toFile) >f.write(x) >f.close >is, that some special ASCII-codes are not copied as usual >under Windows-systems, so e.g. CarriageReturn (tested with normal >Asccii-text). Open the file in binary mode. -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het "That doesn't stop me from wanting to work all three of them over with the clue stick for while, with no safewords allowed." --abostick From faassen at pop.vet.uu.nl Wed Jun 2 14:00:48 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Wed, 02 Jun 1999 20:00:48 +0200 Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7iv86a$iud@news.dns.microsoft.com> <87vhd7nsra.fsf@ev.netlab.co.jp> <3754F5D7.2B6E1954@pop.vet.uu.nl> Message-ID: <3755714F.294CCB8D@pop.vet.uu.nl> Aahz Maruch wrote: > It might make more sense to simply add tools to locate and stomp > circular references, perhaps augmented by explicit calls to delete > specific instances of circular references. Well, those tools would essentially be a form of garbage collecting, right? > I'm curious: does GC provide any advantages other than its ability to > deal with circular references? I think certain forms of GC can use less memory; I don't think all forms of GC need extra data for all objects, like you need to store the ref counter in. Regards, Martijn From gerrit.holl at pobox.com Sun Jun 27 05:28:41 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Sun, 27 Jun 1999 11:28:41 +0200 Subject: Ellipsis? Message-ID: <19990627112841.A31130@optiplex.palga.uucp> Hallo, In the python reference manual, there is this text: Ellipsis: This type has a single value. There is a single object with this value. This object is accessed through the built-in name Ellipsis. It is used to indicate the presence of the "..." syntax in a slice. Its truth value is true. Can someone please explain that to me? What's so special about '...'? groeten, Gerrit. -- The Dutch Linuxgames homepage: http://linuxgames.nl.linux.org Personal homepage: http://www.nl.linux.org/~gerrit/ Discoverb is a python program (in several languages) which tests the words you learned by asking it. Homepage: http://www.nl.linux.org/~gerrit/discoverb/ From ovidiu at cup.hp.com Thu Jun 24 20:28:59 1999 From: ovidiu at cup.hp.com (Ovidiu Predescu) Date: Fri, 25 Jun 1999 00:28:59 +0000 Subject: signal handler References: <376F87CB.DC3802E6@pk.highway.ne.jp> Message-ID: <3772CD4B.38677556@cup.hp.com> Thooney Millennier wrote: > > Hi, I want to use "signal()" in my program. > > import signal; > def func(arg1,arg2): > DO_SOMETHING_GOOD; > print "OK!"; > signal.signal(SOME_SIGNAL,func); > > It seems "func()" is not called > when the program gets signal "SOME_SIGNAL". > Why? It looks like you forgot to send the signal. One way you could implement this code is: from signal import signal, SIGINT from os import getpid, kill def signalHandler (signum, frame): print 'signal handler called for signal %d' % (signum,) signal (SIGINT, signalHandler) kill (getpid (), Take a look at the manpage for signal(7) to get the list of signals you can send to a process. Hope this helps, -- Ovidiu Predescu http://www.geocities.com/SiliconValley/Monitor/7464/ From garry at sage.att.com Tue Jun 15 09:43:30 1999 From: garry at sage.att.com (Garrett G. Hodgson) Date: Tue, 15 Jun 1999 13:43:30 GMT Subject: lockfile problem Message-ID: <37665882.9AEA315A@sage.att.com> i'm having some trouble using mailman, and it appears to be a problem with lockfiles and either nfs or sgi. given the following program: import sys, os, marshal, string, posixfile, time ou = os.umask(0) try: lock_file = posixfile.open( os.path.join( '/home/mailman/locks', '%s.lock' % 'testlock' ), 'a+') finally: os.umask(ou) lock_file.lock('w|', 1) when i run it on a sunos machine, where /home/mailman actually resides, it works. when i run it on our sgi web server machine, where it is nfs mounted, it fails with: $ testlock.py Traceback (innermost last): File "testlock.py", line 12, in ? lock_file.lock('w|', 1) File "/usr/local/lib/python1.5/posixfile.py", line 190, in lock flock = fcntl.fcntl(self._file_.fileno(), cmd, flock) IOError: (22, 'Invalid argument') any ideas how i can fix this? -- Garry Hodgson comes a time garry at sage.att.com when the blind man Software Innovation Services takes your hand, says, AT&T Labs "don't you see?" From DOUGS at oceanic.com Wed Jun 23 05:17:13 1999 From: DOUGS at oceanic.com (Doug Stanfield) Date: Wed, 23 Jun 1999 09:17:13 GMT Subject: Help with String Manipulation Message-ID: <5650A1190E4FD111BC7E0000F8034D26A0EE6B@HUINA> > From: wtanksle at dolphin.openprojects.net on Tuesday, June 22, 1999 3:26 PM > Whew! Is there any reason to not use: ... ?? The opportunity to challenge with a reference that I consider a good read? Actually, I was deliberately much more pedantic than you made me out to be. Doing: >>> testring = "This is an example" >>> testlist = map (ord, testring) >>> testlist [84, 104, 105, 115, 32, 105, 115, 32, 97, 110, 32, 101, 120, 97, 109, 112, 108, 101] I thought made it much more obvious that a transformation happened, where a newbie might confuse: >>> x = list("This is an example.") >>> x ['T', 'h', 'i', 's', ' ', 'i', 's', ' ', 'a', 'n', ' ', 'e', 'x', 'a', 'm', 'p', 'l', 'e', '.'] as having not done anything. I know I had that problem as a beginner and was hoping this would somehow help illustrate mutable and immutable more clearly. YMMV. -Doug- From Max.M..Stalnaker at p98.f112.n480.z2.fidonet.org Wed Jun 30 11:11:10 1999 From: Max.M..Stalnaker at p98.f112.n480.z2.fidonet.org (Max M. Stalnaker) Date: Wed, 30 Jun 1999 16:11:10 +0100 Subject: Using freeze Message-ID: <000015f9@bossar.com.pl> From: "Max M. Stalnaker" Not an expert, but I have done it using vc++5. In the freeze directory, under tools, which directory you get when to download and install the source, which you have to do, there is a html file that is where you need to go next. My project plan would be : 1) compile source (to prove things are set up and you know what to do) 2) execute freeze.py on your program, with a command line parameter to put the result in c:\temp 3) goto c:\temp and type nmake 4) test the result You might have problems with 6.0 since 5.0 is what is supported out of the box. The resulting executionable will be dependent on some external programs. SunitJoshi wrote: > Hello > I'm trying to make exe's from python scripts using VC6++. However I'm > lost as to how to use freeze to accomplish this. If someone could include > some details I would really appreciate it. > > thanks > Sunit -- Max M. Stalnaker stalnaker at acm.org Astar Computer Consulting: Networking and Custom Accounting Software From wtanksle at dolphin.openprojects.net Sat Jun 26 13:47:39 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Sat, 26 Jun 1999 17:47:39 GMT Subject: Why exceptions shouldn't be used for flow control [Re: YAS to the "Reading line-by-line" Problem] References: <376FDF70.4756AD38@mindspring.com> <377173F7.36BCFF6B@compaq.com> <3772AED9.D9E1110@compaq.com> Message-ID: On Fri, 25 Jun 1999 10:19:05 +1200, Greg Ewing wrote: >William Tanksley wrote: >> "Not exceptional enough". What does that mean? (I ain't never had too >> much exception! ;-) >Sorry, I was using "exceptional" in a non-technical sense there. >I meant "not abnormal enough". >I don't agree that reaching EOF is necessarily "abnormal". >If I want to read all the data in a file, and I don't know >in advance how much there is, I write a loop that keeps reading >until EOF. In that case, reaching EOF is not abnormal at all - >it's bound to happen eventually! This is completely true, but a good functional design for an API has each function doing as little as possible. By that rule, we'd do well to remove EOF handling from the contract of the read function, and put it into an eof function. I'm also aware that doing so goes against the C API, so that's one overwhelming strike against doing that to the current library (quite aside from breaking all software ;-). >The question, then, is what a general-purpose library routine >should do on EOF, given that the "right thing" depends on the >circumstances. You would have it always throw an exception, >and require the programmer to catch it if it is an "expected" >exception. Right. >Personally, I prefer it the way it is. If I want an exception >thrown, I can always write a wrapper which does so. Doing it >the other way around - wrapping exception-throwing code into >something which doesn't - is trickier to get right; as I've >shown, it's hard to make sure that it catches only what you >want to catch. You're entirely correct there. Exceptionn-throwing code depends upon having a good test system. Without complete tests, it doesn't happen. OTOH, that particular exceptionn would get thrown only in a truly bizzare situation, because all code would look somethinng like this: while not f.eof(): line = f.readline() # ... Most programmers wouldn't expect to have to catch an exception any mmore thann they'd have to test for an exceptionnal returnn value. >> In addition, the complexity of the failure required to produce this is >> pretty high. How many files do you need to read to get the next line from >> this file? >It's perhaps not the best example of this kind of problem. >A better one, which I actually have experienced, is from the >days when it was common to catch KeyError as a way of telling >when a key wasn't in a dictionary: > try: > v = d[the_key()] > except KeyError: > v = some_default_value Yes, I agree. And I suspect the problem was that my explanation of my solution was bad. >The subtle problem with that piece of code is that if there >is a bug which causes the_key() to raise a KeyError (which I >think you'll agree is *not* an unlikely event) it gets >incorrectly caught instead of triggering a traceback. >To guard against that, you have to be very careful what >you put inside the try: > i = the_key() > try: > v = d[i] > except KeyError: > v = some_default_value >This is one of the reasons that the get() method was >added to dictionaries. Using it, you can write > v = d.get(the_key(), some_default_value) >which is not only less error-prone but shorter and >clearer as well. This is a very interesting case of a "bad" API replacing what I would have called a "good" one. It's obvious that I would have been incorrect. I think the distinction here is that a dictionary isn't a stream, and there's a reasonable expectation of atomic access. >> If someone else's uncaught EOFError hits this function, something nasty is >> almost always going to happen... if it fails, it does so loudly so that >> the tester notices and reports the problem. >But that's exactly what *doesn't* happen! The misdirected exception >silently terminates a loop that it wasn't meant to terminate, and >later on the program fails with some set of symptoms that give little >or no clue as to what the original cause was. I would much rather get >a traceback pinpointing exactly what was thrown and where it was thrown >from. You're right -- and the solution to this is the samme as the solution to the corresponding problem with exceptional return values (-1 for EOF). Build the API so that they're never something you'd want to catch. >> C is famous for noiselessly casting the -1 to a char (look at >> the old Bash security bug), and Python is even worse -- any return you can >> possibly make will almost certainly fit in noiselessly with anything you >> do with it. >The design of read() is perhaps not the best here -- it might be >better to return None, which would cause most things expecting a >string to blow up rather more quickly. That's also a good idea. It's been a while since I've used read, so I don't recall what it actually returns (I've used nothing but readline). >> You ought to feel lucky. Some respected programming gurus recommend >> calling abort() on any odd results >Raising an exception is Python's equivalent of calling abort(). But >it only works as such if you can be sure that your exception isn't >going to be caught by something that makes unwarranted assumptions >about its cause. The more you use exceptions for "normal" things, >such as EOF or KeyError or IndexError when they aren't really errors, >the more likely that is to happen. In my experience, anyway. You're entirely right. And so am I -- in a function designed to get n!=0 more characters, an EOF really is an error. Unfortunately for me, that's not the definition of 'read', and never will be. And it doesn't really matter -- one writes wrappers for everything anyhow (read is supposed to be primitive). >Greg -- -William "Billy" Tanksley Utinam logica falsa tuam philosophiam totam suffodiant! :-: May faulty logic undermine your entire philosophy! From cwebster at math.tamu.edu Sun Jun 27 20:41:44 1999 From: cwebster at math.tamu.edu (Corran Webster) Date: 28 Jun 1999 00:41:44 GMT Subject: ANN: Stackless Python 0.2 References: <37628EAA.C682F16C@appliedbiometrics.com> Message-ID: <7l6gc8$du4$1@news.tamu.edu> In article <37628EAA.C682F16C at appliedbiometrics.com>, Christian Tismer wrote: >ANNOUNCING: > > Stackless Python 0.2 > A Python Implementation Which > Does Not Ese The C Stack > >What is it? >A plugin-replacement for core Python. >It should run any program which runs under Python 1.5.2 . >But it does not need space on the C stack. [snip] I managed to get this to build eventually (thanks to the hints from Michael Hudson). Looking at it, I wonder whether there's the potential here for more than coroutines and to write an implementation of threading within Python. Each thread would presumably need its own Python stack, and a queueing and locking system would need to be added somehow, but because the Python and C stacks are no longer intertangled, switching between threads should be easy (as opposed to impossible ). This wouldn't be quite as flexible as the current implimentations of threads at the C level - C extensions would be called in a single block with no way to swap threads until they return. On the other hand, this would allow every platform to have some sort of threading available, which would be a boon. Unfortunately I'm not familiar enough with threads to go out there and implement it right away, but I thought I'd at least raise it as a possibility and see what people think and what the pros and cons are. Corran From jody at ldgo.columbia.edu Sun Jun 27 19:10:40 1999 From: jody at ldgo.columbia.edu (Jody Winston) Date: 27 Jun 1999 19:10:40 -0400 Subject: Python for large projects? References: <3774b5d1.690922@news.force9.net> <87d7yhv8ys.fsf@lisboa.i-did-not-set--mail-host-address--so-shoot-me> Message-ID: >>>>> "Janko" == Janko Hauser writes: Janko> Jody Winston writes: >> I've used Python for three large distributed applications (each >> > 100k lines of Python). The only other recommendation that I >> would add is to define interfaces to the code. If this is done >> with a product like ILU or FNORB, you can then easily call the >> Python code from other languages. In addition, you can replace >> critical sections with other languages if needed. >> Janko> I have thought about this as the perfect way to do ``data Janko> hiding'', publish only special interfaces for your Janko> data. Has this a significant overhead, if used on one Janko> machiene, or is it overkill just for this purpose :-)? For my data, which are large arrays read from disk, the ILU program is 50% slower on a simple benchmark that just transfers the arrays from one address space to another on the same machine. The xml-rpc program, which transfers the same data from a client to a server, is 2 times slower as the ILU program[1]. However both of these bechmarks, for my case, do not really mean anything since the real code is compute bound. To understand the impact of a distributed object system will have on your design, you'll need to understand how you will access your data and the possible bottlenecks. Footnotes: [1] That's really amazing in my book since all of the xml-rpc data is ASCII. -- Jody Winston Lamont-Doherty Earth Observatory RT 9W, Palisades, NY 10964 jody at ldeo.columbia.edu, 914 365 8526, Fax 914 359 1631 Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats. From mwh21 at cam.ac.uk Wed Jun 2 17:34:46 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 02 Jun 1999 22:34:46 +0100 Subject: Bizarre error while ./configure-ing PIL References: Message-ID: Matt Gushee writes: > Hello, folks-- > > This may be the weirdest thing I've yet seen happen on a Linux > box. I'm running RedHat Linux 5.2 and trying to compile PIL 1.0b1. I > have a feeling this isn't really a PIL- or Python-specific problem, > but just in case anyone's run into this: > > [matt at crawdad Imaging-1.0b1]$ ls -dl libImaging > drwxr-xr-x 2 matt matt 2048 Jun 1 03:26 libImaging > [matt at crawdad Imaging-1.0b1]$ cd libImaging/ > [matt at crawdad libImaging]$ ls -l configure > -rwxr-xr-x 1 matt matt 65845 Jan 10 04:29 configure > [matt at crawdad libImaging]$ ./configure > bash: ./configure: Permission denied > [matt at crawdad libImaging]$ su > Password: > [root at crawdad libImaging]# ./configure > bash: ./configure: Permission denied > > What the --- ? Random guess, but check the first line of ./configure. It should probably read #!/bin/sh My guess is either 1) /bin/sh is not executable (very unlikely, all sorts of things would barf at that) 2) the line's gotten mangled somehows - maybe a misplaced space? HTH Michael > Extremely puzzledly yours, > Matt Gushee > Portland, Maine, USA From Michael.P..Reilly at p98.f112.n480.z2.fidonet.org Wed Jun 30 14:49:18 1999 From: Michael.P..Reilly at p98.f112.n480.z2.fidonet.org (Michael P. Reilly) Date: Wed, 30 Jun 1999 19:49:18 +0100 Subject: socket timeouts Message-ID: <000015cb@bossar.com.pl> From: "Michael P. Reilly" Nathan Clegg wrote: : Is there any way to set the timeout for a TCP/IP connection? : Specifically, I'm writing some apps meant to run on the same machine, so : if they can't connect *immediately* (i.e. the server app is not running), I : need to go to plan B. Any answers or alternate solutions? I'm also : interested in a similar issue across the internet, but I'm more generous : about timeouts in this circumstance. Thanks. Since you are using a TCP/IP connection (ie. a socket), using select() should be cross-platform enough. import select class TimeoutError(Exception): pass def wait_for_socket(sock, timeo): timeo = float(timeo) rdrs, wtrs, excs = select.select([sock], [], [], timeo) if not rdrs: raise TimeoutError, "no responce" If the exception is raised, then the connection did not complete. -Arcege From jeffrey at Digicool.com Fri Jun 4 15:14:52 1999 From: jeffrey at Digicool.com (Jeffrey P Shell) Date: Fri, 04 Jun 1999 15:14:52 -0400 Subject: python active web pages References: Message-ID: <7j98g1$atj$1@autumn.news.rcn.net> > i also looked at ZTemplates (a component of Zope), > > , > > and while it doesn't actually embed python, it has a limited embedding > language of its own, DTML, which gets munged into python. i must say that > DTML looks a bit hideous (if anyone from digicool is reading, sorry guys). Well, DTML (especially outside of Zope) is not meant to be scripting-inside-of-HTML, which most Active Server Page type things are. Personally, I think that is beyond hideous, the <% document.write('') document.write('%s' % someTitleString) ... %> is terrible (i have seen plenty of PHP source that looks like the above). DTML Scripting can look quite ugly, but it's (a) safe (which is good because DTML in Zope and even on its own can be edited through the web and you have security issues with that), and (b) very powerful depending on the namespace given it (which is very powerful in Zope due to the inherent Acquisition model). Using ZPublisher (the beast previously known as Bobo) and DocumentTemplates is very powerful for web development. The DocumentTemplates are meant to be _views_ on an Object, not just a web page unto themselves. Thus, DTML has a lot of very powerful batch processing features (it's basically a reporting language in its web form) and very powerful namespace features. This seperation (which was most effective before DTML scripting, aka the embedding of python expressions in DTML, was implemented into DTML) is very powerful as it enforces the seperation of Code and Presentation, a rather MVC (Model-View-Controller) style paradigm. My first Bobo app was turning a socket server into a web application. Since I had made my classes and the views on those classes rather seperate in the socket server implementation, turning into a web app took only a matter of hours. I was able to make a very simple DTML page for displaying results from a search form and focus on implementing some new methods needed for this new way of accessing data. Once those methods were implemented, I was able to spend the rest of the day in web-designer mode since I already knew all the data that I had available to me and I could just write DTML and not even have to think about Python. That was very very _VERY_ powerful to me. I wouldn't have had such an easy (nor as fun or as flexible) time in an ASP type environment where all the code is embedded on a page. Granted, you can write ASP type pages that import modules and use the beautifully simple <%= foo %> and have a similar abstraction, but it's not built into the system. DTML (esp. DTML Scripting) has gotten rather beyond control in some cases, but I believe it's the most "right". But yes, I work for digital creations so I'm a bit biased. But all that bias is based on the first time I wrote a major application and just how _EASY_ (and powerful) that was. Viva MVC ! > anyone have any experience with active web pages using either of these or > something else? yes. :) .jPS | jeffrey at digicool.com zope, through the web. www.zope.org From jam at newimage.com Sat Jun 19 09:00:39 1999 From: jam at newimage.com (jam) Date: Sat, 19 Jun 1999 09:00:39 -0400 Subject: [announce] 'getdatemodule' released. date expression extension for python Message-ID: <19990619090039.L19541@toast.internal> greetings, I've extracted a parser from the 'cvs' sources that knows how to deal with common date expressions like 'now', 'tomorrow', 'next week', 'next thursday', etc. I wrote a simple wrapper around it's one useful function, and packaged it all up as a tgz file, and uploaded it to starship. the code works great, but I'd really love it if someone could help come up with a spec file so it can be released as a binary RPM package, and also perhaps a perl version. I realize that SWIG could make quick work of something like this, but I saw a great deal of benefit in writing a 'pure' interface, in order to get more practice writing extension modules. I uploaded the file to recently. the latest available snapshot should always be there. I also run a small *low bandwidth* bbs that I would like to use as a support site for this module and others as they are released. if anyone is interested, it can be reached via the url below (quark.newimage.com). please let me know if there are any questions, concerns, problems, patches or whathaveyou related to getdatemodule, the bbs, or python and linux in general. regards, Jeff -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 210 bytes Desc: not available URL: From donn at u.washington.edu Wed Jun 2 20:16:51 1999 From: donn at u.washington.edu (Donn Cave) Date: 3 Jun 1999 00:16:51 GMT Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <87pv3iq6ss.fsf@ev.netlab.co.jp> <3752C76D.604CD474@prescod.net> <87n1ykr0z9.fsf@ev.netlab.co.jp> <375372F6.A874554@prescod.net> <87hfosquc0.fsf@ev.netlab.co.jp> <3753F121.E4A9BE8B@prescod.net> <87yai3ntdt.fsf@ev.netlab.co.jp> <7j3iif$134e$1@nntp6.u.washington.edu> <7j45iv$908$4@cronkite.cc.uga.edu> Message-ID: <7j4hhj$118u$1@nntp6.u.washington.edu> graham at sloth.math.uga.edu (Graham Matthews) writes: | Donn Cave (donn at u.washington.edu) wrote: |: You're in good company here, I think the leading lights of the Python |: world all prefer explicit termination in these cases. Ref counting sure |: offers a great convenience here, though. Files close and flush their |: buffers, dialogues disappear, all in accordance with their programmatic |: lifetime. I personally will miss this finalization more than any resource |: management if reference counting is taken away. | | You seem to believe that garbage collection implies no reference counts. | Why do you believe that? (a lot of GC schemes use reference counts). | You also seem to believe that with GC finalisation will disappear. Why | do you believe that (a lot of GC schemes have finalisation). Does JPython use reference counts, and invoke delete methods as soon as reference count drops to 0? | ... Finally I | believe you are mis-using finalisation if you use it to close up files, | sockets, etc. That's what close calls are for. Well, I think there's something to be said for it. With Python, we're free from the obnoxious requirement imposed by the storage model of languages like C, that forces the programmer to account for each scrap of malloc'd memory lest there be leaks. That allows me to export an object reference (e.g., via function return) and forget about it, and that has radically beneficial implications for how things can be structured. Why should I enjoy this freedom with memory resources, but welcome exactly the same constraints when an object has other termination requirements? Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From shr at chat.net Sun Jun 6 15:26:51 1999 From: shr at chat.net (Scott RoLanD) Date: Sun, 6 Jun 1999 12:26:51 -0700 Subject: Library load err with --prefix build 1.5.2 Message-ID: <19990606122651.A9771@chat.net> I just did a virgin Mandrake 6.0 install (which comes with Python 1.5.1) and I want to compile and install 1.5.2 in: /home/shr/python I want to leave the original 1.5.1 RPM right where it is and have my new 1.5.2 install function in place without any problems. However, it seems that if the 1.5.1 version is at the head of my PATH, then I have problems using the 1.5.2 version. I built as follows: ./configure --prefix=/home/shr/python make make test (test_long failed; test_types crashed) make install So now I have a binary at: /home/shr/python/bin/python But the problem comes when I try to use this simple script 'example': #################### %: unset PYTHONPATH %: which python /usr/bin/python %: python Python 1.5.1 (#1, Apr 13 1999, 03:12:59) [GCC pgcc-2.91.60 19981201 (e on linux-i386 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> %: cat example #!/home/shr/python/bin/python import sys print sys.path %: ./example Built-in exception class not found: EnvironmentError. Library mismatch? Warning! Falling back to string-based exceptions ['.', '/usr/lib/python1.5/', '/usr/lib/python1.5/plat-linux2', '/usr/lib/python1.5/lib-tk', '/usr/lib/python1.5/lib-dynload'] %: /home/shr/python/bin/python example ['', '/home/shr/python/lib/python1.5/', '/home/shr/python/lib/python1.5/plat-linux2', '/home/shr/python/lib/python1.5/lib-tk', '/home/shr/python/lib/python1.5/lib-dynload'] %: PATH=/home/shr/python/bin:$PATH %: which python /home/shr/python/bin/python %: python Python 1.5.2 (#1, Jun 6 1999, 15:06:23) [GCC pgcc-2.91.66 19990314 (egcs-1.1.2 on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> %: ./example ['.', '/home/shr/python/lib/python1.5/', '/home/shr/python/lib/python1.5/plat-linux2', '/home/shr/python/lib/python1.5/lib-tk', '/home/shr/python/lib/python1.5/lib-dynload'] %: /usr/bin/python example ['', '/usr/lib/python1.5/', '/usr/lib/python1.5/test', '/usr/lib/python1.5/plat-linux-i386', '/usr/lib/python1.5/lib-tk', '/usr/lib/python1.5/lib-dynload'] #################### I don't want to have to set PYTHONPATH in order to get this to work. Anyone with a vanilla environment should be able to use this script. This should work; what is going on? Thanks In Advance. -- Scott RoLanD http://www.chat.net/~shr/ From fredrik at pythonware.com Wed Jun 30 04:37:10 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 30 Jun 1999 08:37:10 GMT Subject: printing with print References: <377925EF.1CBB640F@starvision.com> Message-ID: <011a01bec2d3$c215a900$f29b12c2@secret.pythonware.com> Angus MacKay wrote: > is there any other way to print that with print? > perhaps with a real function. > > I want to print two things without a space being added between them: > foo = "there" > print "hi" + foo > > works fine but: > foo = 2 > print "hi" + foo > > does not. I like the printing of any object ability of "print" so I > do not want to use "" % style printing, I just want to be able to > govern the whitespace that gets output. note that the "s" formatting operator can handle any non-tuple object, just like print (both use "str" to convert non-string objects to strings). the following two statements give the same result, as long as foo is not a tuple. print foo print "%s" % foo to deal with tuples too, you can call str yourself, or wrap the object in a singleton tuple: print "%s" % str(foo) print "%s" % (foo,) From news at dorb.com Fri Jun 25 15:37:55 1999 From: news at dorb.com (Darrell) Date: Fri, 25 Jun 1999 15:37:55 -0400 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> Message-ID: I know less than nothing about this subject, but have a though to contribute. What about using a tool like this: http://www.ndim.edrc.cmu.edu/dougc/jpi/Home.html To make use of Java's GUI tools. Yes speed may be an issue, but it would work on the Mac and book stores are loaded with Java.... Then Jpython and Cpython would share the same GUI tools. -- --Darrell From matz at netlab.co.jp Wed Jun 2 00:14:33 1999 From: matz at netlab.co.jp (Yukihiro Matsumoto) Date: 02 Jun 1999 13:14:33 +0900 Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <87pv3iq6ss.fsf@ev.netlab.co.jp> <7iv86a$iud@news.dns.microsoft.com> Message-ID: <87vhd7nsra.fsf@ev.netlab.co.jp> "Vadim Chugunov" writes: |> I don't get it. There's no relation between destructors and real |> garbage collection. For example, Java uses destructors called |> finalizers, even though most Java VM use real GC. | |Right, but java finalizers will not be called till the moment the memory is |collected. |Depending on the GC configuration and the program's memory consumption this |may be quite a while. |> I hate ref counting. It is memory-leak prone, does not reclaim cyclic |> data without explicit cycle-cut. I know, by ref counting, object is |> recycled as soon as it looses last reference to it, but relying on |> that behavior is error prone, I think. | |Can you explain exactly why is it more error prone? |If something can be done automatically, without writing explicit |deallocation code, |why can't we let it be that way? Well, the reasons why ref counting is more error prone are: * ref counting never reclaim cyclic references, resulting memory leak. * extension module writers are easy to forget to put INCREF(), DECREF() properly, resulting memory problems (leak or crash). These two never be caused by real GC. From my viewpoint (of cource biased), avoiding these is more important than predictability. |OK, I'll try to propose something constructive. Maybe we need an object |protocol, that would enumerate |all references held by an object ? Writing a portable GC would be then much |easier. Some languages use both. Ref counting for usual basis, real GC for full clean up. How about adding real GC to Python 2.0, co-working with ref counting? matz. From marcoxa at copernico.parades.rm.cnr.it Wed Jun 16 18:28:18 1999 From: marcoxa at copernico.parades.rm.cnr.it (Marco Antoniotti) Date: 17 Jun 1999 00:28:18 +0200 Subject: Why is tcl broken? References: <375F82C7.CF0F0477@iname.com> Message-ID: "Tom Cloney" writes: ... > > It's super when embedded in a text editor. Alpha is a great example. > Emacs is a great example :) Cheers Marco -- Marco Antoniotti =========================================== PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY tel. +39 - 06 68 10 03 17, fax. +39 - 06 68 80 79 26 http://www.parades.rm.cnr.it/~marcoxa From hank at prosysplus.com Mon Jun 28 08:43:31 1999 From: hank at prosysplus.com (Hank Fay) Date: Mon, 28 Jun 1999 08:43:31 -0400 Subject: ActiveX, IDE Message-ID: <7cKd3.3449$lr3.133866@news2.jacksonville.net> I'd like to make Wintel apps using ActiveX controls under Python: is there an IDE for Python that will support this? TIA, Hank Fay -- http://www.prosysplus.com From gmcm at hypernet.com Thu Jun 3 18:12:56 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 3 Jun 1999 17:12:56 -0500 Subject: Where to find samples??? In-Reply-To: <7j6n4g$1jqq$1@rtpnews.raleigh.ibm.com> Message-ID: <1283674270-42685846@hypernet.com> Jr. King asks: > Where can I find some good c/c++ integrated with python, besides the > 2 or 3 that comes with the download of Python for windows??? The first place to look is at anything in the Modules and Objects directories in the source distribution. Or poke around on the contrib section of the ftp site. Or download CXX from LLNL. Or use SWIG and look at what it generates. - Gordon From Darrell at p98.f112.n480.z2.fidonet.org Wed Jun 30 05:19:24 1999 From: Darrell at p98.f112.n480.z2.fidonet.org (Darrell) Date: Wed, 30 Jun 1999 10:19:24 +0100 Subject: Reflection in Python? Message-ID: <000015c1@bossar.com.pl> From: "Darrell" # Get the testAdd method or attribute of MathTest test=getattr(MathTest,'testAdd') >>> class A: ... def myX(self): ... print 'xxx' ... >>> a=A() >>> af=getattr(a,'myX') >>> apply(af) xxx >>> af() xxx # Get the name of 'a' >>> print a <__main__.A instance at 7f79d0> >>> print `a` <__main__.A instance at 7f79d0> >>> print str(a) <__main__.A instance at 7f79d0> >>> print af >>> -- --Darrell wrote in message news:7ldglr$ita$1 at nnrp1.deja.com... > test = MathTest("testAdd") > > where test.run() will run the "testAdd" method on > the MathTest object? I also want to be able to > tell the user the name of the object (MathTest) > and the method in case the method fails. Any > thoughts? > > Thanks, > Anders Schneiderman > National Journal Daily Briefings Group > > > > > Sent via Deja.com http://www.deja.com/ > Share what you know. Learn what you don't. From graham at sloth.math.uga.edu Wed Jun 2 20:47:42 1999 From: graham at sloth.math.uga.edu (Graham Matthews) Date: 3 Jun 1999 00:47:42 GMT Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <87pv3iq6ss.fsf@ev.netlab.co.jp> <3752C76D.604CD474@prescod.net> <87n1ykr0z9.fsf@ev.netlab.co.jp> <375372F6.A874554@prescod.net> <87hfosquc0.fsf@ev.netlab.co.jp> <3753F121.E4A9BE8B@prescod.net> <87yai3ntdt.fsf@ev.netlab.co.jp> <7j3iif$134e$1@nntp6.u.washington.edu> <7j45iv$908$4@cronkite.cc.uga.edu> <7j4hhj$118u$1@nntp6.u.washington.edu> Message-ID: <7j4jbe$dhh$1@cronkite.cc.uga.edu> graham at sloth.math.uga.edu (Graham Matthews) writes: | You seem to believe that garbage collection implies no reference counts. | Why do you believe that? (a lot of GC schemes use reference counts). | You also seem to believe that with GC finalisation will disappear. Why | do you believe that (a lot of GC schemes have finalisation). Donn Cave (donn at u.washington.edu) wrote: : Does JPython use reference counts, and invoke delete methods as soon as : reference count drops to 0? I don't think reference counting garbage collection is mandated in Java (it used to be but I think that has changed). But I am not sure I see what the connection is between how JPython does memory management and garbage collection in Python in general. graham at sloth.math.uga.edu (Graham Matthews) writes: : | ... Finally I : | believe you are mis-using finalisation if you use it to close up files, : | sockets, etc. That's what close calls are for. Donn Cave (donn at u.washington.edu) wrote: : Well, I think there's something to be said for it. With Python, we're : free from the obnoxious requirement imposed by the storage model of : languages like C, that forces the programmer to account for each scrap : of malloc'd memory lest there be leaks. : ... : Why should I enjoy this freedom with memory resources, but welcome exactly : the same constraints when an object has other termination requirements? Because other kinds of objects are different to memory? Also I am not sure why you think GC can't handle other kinds of objects as well. Maybe Java doesn't do a good job of resource finalisation, but that doesn't mean it can't be done. graham -- Bang, bang, Maxwell's silver hammer came down on her head Bang, bang, Maxwell's silver hammer made sure that she was dead From otto at olympus.net Tue Jun 8 23:11:33 1999 From: otto at olympus.net (Otto Smith) Date: 9 Jun 99 03:11:33 GMT Subject: Indentation and grouping proposal References: <000b01beb14d$b502a480$aaa02299@tim> Message-ID: <01beb225$07ef2600$efed85c6@otto> # Re: Indentation and grouping proposal # You don't need to change python to get # the functionality you request.. # nips.py # Non Intuitive Parsing System... ''' Here are some routines that allow you to write in a style similar to that proposed in the: "Indentation and grouping proposal". The routines will take ugly unreadable code and translate it to simple, neatly indented python code. The constants below set the block grouping symbols to '_{' and '}_' and the statement separator to ';', but you are welcome to change these to anything you want. Usage is simple: parsenips() takes block delimited code and converts it into a list of lists format. makeright() takes the output of parsnips and makes it into python indented code. Example: ##### import from nips import makeright, parsenips ugly = """ if 1<2: _{ print 'Ho ho'; print '1 < 2' }_ else: _{ print "surprise"; print '2 < 1!!!' }_ """ print makeright(parsenips( ugly )) ##### Which produces: if 1<2: print 'Ho ho' print '1 < 2' else: print 'surprise' print '2 < 1!!!' ''' import string SPARSEX = "String parse exception" MYSTART = '_{' MYEND = '}_' MYLINE = ';' BADQUOTES = "'"+'"' len_mystart = len(MYSTART) len_myline = len(MYLINE) def match(beg, end, str): lbeg = len(beg) lend = len(end) dex = lbeg count = 1 while dex < len(str): if str[dex:dex+lend] == end: count = count-1 if count == 0: return (str[lbeg:dex],str[dex+lbeg:]) dex = dex+lend elif str[dex:dex+lbeg] == beg: count = count+1 dex = dex+lbeg else: dex = dex + 1 continue if count < 0: raise SPARSEX, 'badly matched quote brackets' raise SPARSEX, 'badly matched quote brackets' def parsenips( str ): str = string.strip(str) curinst = '' statementlist = [] dex = 0 while str: if str[dex] in BADQUOTES: quote = str[dex] val, str = match( quote, quote, str[dex:] ) curinst = curinst+quote+val+quote dex = 0 elif str[dex:dex+len_mystart] == MYSTART: if curinst: statementlist.append( string.strip(curinst) ) val, str = match( MYSTART, MYEND, str[dex:] ) statementlist.append( parsenips(val)) curinst = '' dex = 0 elif str[dex:dex+len_myline] == MYLINE: statementlist.append( string.strip(curinst) ) str = string.strip(str[dex+len_myline:]) curinst = '' dex = 0 else: curinst = curinst + str[dex] dex = dex+1 if string.strip(curinst): statementlist.append( string.strip(curinst)) return filter(None, statementlist) SPACER = ' ' def makeright( list, level=0 ): pystrings = [] for val in list: if type(val) == type(""): pystrings.append( (SPACER*level)+val ) else: ## Assert type(val) == ListType pystrings.append( makeright(val,level+1) ) return string.join( pystrings, '\n') #Otto #otto at olympus.net From phd at emerald.netskate.ru Mon Jun 28 05:19:15 1999 From: phd at emerald.netskate.ru (Oleg Broytmann) Date: Mon, 28 Jun 1999 13:19:15 +0400 (MSD) Subject: ConfigParser & STRPTIME ???? In-Reply-To: Message-ID: Hi! On Mon, 28 Jun 1999, Benjamin Schollnick wrote: > 2) Can you use CONFIGPARSER to write a *.INI file that > you have made, or read into config parser, back > out to disk? From reading Dejanews, I believe that > it can't be?!?!?!?!?!? If so, why? It seems silly to support > read but not write. Few years ago i wrote a class library full of config files parsers. Among other things there is a parser for .INI files. Parsed config can be written back to disk. http://members.xoom.com/phd2/Software/Python/ http://www.fortunecity.com/skyscraper/unix/797/Software/Python/ look for "Flat ASCII Database and config files modules". The .INI-part of the library was not extenceivly tested - usually I use other classes for storing information in text files... > - Benjamin Oleg. ---- Oleg Broytmann Netskate/Inter.Net.Ru phd at emerald.netskate.ru Programmers don't die, they just GOSUB without RETURN. From tim_one at email.msn.com Sat Jun 5 23:25:33 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 5 Jun 1999 23:25:33 -0400 Subject: Idle comments In-Reply-To: <7jcdcm$19qi$2@hub.org> Message-ID: <000501beafcc$3c407900$639e2299@tim> [Ragica , seeking a way to change something about IDLE's color decisions] > I know it's in the code. I have even looked for where (believe it or > not). In the IDLE readme for example it tells you where and what to > change to adjust the syntax highlight colours--but not the default > background colour--, I looked around there. Alas, to no avail. I > freely admit i find that code confusing. I am not quite the python > programming genius as yoursly truly. It's really a question about Tk, whose mysteries are as deep to me as to anyone. The thing to do is to grep (or "findstr" on NT) the IDLE source for "background". You won't get many hits, and one of them may be the thing you need to change. Most likely in EditorWindow's __init__ function (last place you'd look, right ?). Look for where it creates a Text widget "... = Text(...)". If there are background=whatever foreground=whatever keyword arguments already, change them; else add them. I don't have the 1.5.2 IDLE source anymore, so can't be more specific. > ... > I have to tell you, even if the guidos of the world are ever infinitely > more programatically exalted than insignificant I... > i simply can't fathom people who hard code stuff into their programs! > Even at early stages. In my books setting-type variables at very least > should go somewhere highly visible and up-front... so as to be easy > to access and find. But that's just me, perhaps. It's only hard to find the first time . In the meantime, a comprehensive subsystem for managing user preferences is a major piece of work, and Guido appears to have devoted his limited IDLE time to adding major new functionality instead. That's the downside of Open Source, of course: unlike as with proprietary software, you don't get to pay for the privilege of feeling ignored . patience-works-better-than-impatience-ly y'rs - tim From dalke at bioreason.com Sat Jun 12 03:13:00 1999 From: dalke at bioreason.com (Andrew Dalke) Date: Sat, 12 Jun 1999 01:13:00 -0600 Subject: module import, but different Message-ID: <3762087C.98EA86DA@bioreason.com> Hello, I would like to add a test suite to our software so at the top level of the distribution I can do a "make check" and run the tests. (We are planning to do something based to Python's regrtest code.) I'm running into a problem because I don't know how to deal with packages; and we do almost everything as packages. It comes down to needing a way to import a package when you can't include the package's parent directory in the PYTHONPATH. I'll describe the problem with some detail first. Here's an example package layout: MCS/ Makefile __init__.py Graph.py ... doc/ to which I plan to add test/ br_regrtest.py ("br_" for "Bioreason's version of") test_graph.py ... And in the Makefile add something like check: cd test && $(PYTHON) br_regrtest.py Inside the test directory will be programs like "test_graph.py". They will have code like "import MCS.Graph". This will fail because MCS isn't a module or package on the PYTHONPATH. (Setting PYTHONPATH to ".." will fail for modules which have non-trivial __init__.py files; and we have a couple of that form.) One solution would be to include "../.." but that wouldn't be appropriate because that may include files which get imported by accident. For example, I keep all of my development code under src/, so src/MCS, src/daylight, etc. But when I'm doing unit testing I want to import the globally installed "daylight" and not the ../../daylight imported by adding ../.. to the path. Of course, I could arbitrarily decide to enforce that ../.. not contain importable code, but that require me to change my development style, and for everyone using one of these packages to understand the problem and obey the solution. Ain't gonna happen. Besides, we distribute the packages with version numbers, as in MCS-1.0. Including ../.. means we would have to convert the name somehow. The Python distribution solves the problem, I think, because in getpath.c it adds `Lib' to the PYTHONPATH if python was was run in the build tree. Seems sneaky to me! Another possibility is to make a symbolic link in the test/ directory, as in ln -s ../ MCS This will work under unix, but isn't very portable, and I expect we'll have to support Windows someday. (Or do the other OSes have something equivalent to this?) A third solution is to move the code tree to its own subdirectory -- what automake calls a "deep" package -- as in: MCS/ Makefile MCS/ __init__.py Graph.py ... doc/ test/ In that way I can do cd test && PYTHONPATH=.. $(PYTHON) br_regrtest.py This is probably the best solution, except that 1) we already have about 20 modules with code in the top level, 2) the patches I made for automake assume the code will be of this form 3) I will be contributing the patches back to automake, and I can guarantee that others won't be writing packages of this form. 4) other reasons I can't currently come up with, other than "it doesn't feel right/is too complicated" (eg, because there will always have to be two Makefiles, one in the top directory and one for the source subdir) The last solution, and the one I want, is to have some way to fake the import system so that "../" is treated as a module, say, by calling special_import("MCS", "../") which fakes out sys.modules. Here is a unix specific implementation: = = = = import os, sys # One way to remove the links with Python exits... class CleanUp: def __init__(self, name): self.name = name self.unlink = os.unlink # os gets deleted too early! def __del__(self): self.unlink(self.name) clean_up = [] def special_import(name, location): os.symlink(location, name) sys.modules[name] = __import__(name) clean_up.append(CleanUp(name)) = = = = Suggestions? Andrew Dalke dalke at bioreason.com From clarence at silcom.com Fri Jun 18 11:01:10 1999 From: clarence at silcom.com (Clarence Gardner) Date: Fri, 18 Jun 1999 15:01:10 GMT Subject: Compiled main program References: <376981D2.61C7D46D@compaq.com> Message-ID: Greg Ewing (greg.ewing at compaq.com) wrote: : Clarence Gardner wrote: : > : > x = MakeMeMain() : > del x : : Wouldn't it just be simpler to do : : MakeMeMain() : : Greg Sure would -- I noticed that after I posted and felt a blush of embarassment. That came up because I first wrote del MakeMeMain() (don't ask me why), which is illegal (because you del a name, not a value) so with a quick jerk of the hand I put in 'x'. By the way, just to compound my initial stupidity, as was pointed out to me in email by , I didn't need the MakeMeMain() class at all -- this suffices: sys.modules['__main__'] = sys.modules[__name__] I must have had a mental block when I was trying to think of how to get a reference to the current module, which made me wander off into class-land. -- -=-=-=-=-=-=-=-= Clarence Gardner AvTel Communications Software Products and Services Division clarence at avtel.com From Michael.Hudson at p98.f112.n480.z2.fidonet.org Wed Jun 30 15:32:47 1999 From: Michael.Hudson at p98.f112.n480.z2.fidonet.org (Michael Hudson) Date: Wed, 30 Jun 1999 20:32:47 +0100 Subject: Reflection in Python? Message-ID: <000015c3@bossar.com.pl> From: Michael Hudson anders777 at my-deja.com writes: > I've just started programming in Python, and I > could really use some help figuring out something. > I'd like to implement Kent Beck's unit tester in > Python (someone posted a very nice alternative a > few weeks ago, but Junit's approach works better > for my project's needs). How do I do the > equivalent of what Java calls reflection? I want > to do the following: > > test = MathTest("testAdd") > > where test.run() will run the "testAdd" method on > the MathTest object? I also want to be able to > tell the user the name of the object (MathTest) > and the method in case the method fails. Any > thoughts? > > Thanks, > Anders Schneiderman > National Journal Daily Briefings Group > Not entirely sure I follow, but will this do what you want? class Test: def __init__(self,object,meth): self.object = object self.meth = meth def run(): try: getattr(self.object,self.meth)() except: print self.object.__class__.__name__, "failed!" then test = Test(MathTest,"testAdd") test.run() does what you ask (I think). Anyway, I suspect the builtin "getattr" is what you're after. HTH Michael From morse at harborcom.net Fri Jun 25 14:05:13 1999 From: morse at harborcom.net (Kevin Dahlhausen) Date: Fri, 25 Jun 1999 18:05:13 GMT Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> Message-ID: <3773c3a0.102825445@news.oh.verio.com> m >I'd like some discussion on whether or not it is a good idea to >abandon TkInter, before it gets too widely used, and instead adopt >wxPython as the primary GUI framework for Python. > >Having said this, I have to say that I'm in no way a TkInter or a >wxPython expert. I've evaluated both of them and found wxPython to be >the winner - and TkInter without a real chance of getting used by me. > >Also, can anyone comment on the features available in TkInter and >wxPython - perhaps even make a feature comparison chart? > >[1] By sluggish I mean: You can see, or at least sense, the window >update operations. Windows are not drawn instantly, but in visually >detectable steps. I agree with your observations on TK. I looked at wxPython and some other GUIs. I liked the Fast Light Toolkit API the best. At least Python allows us to use the best GUI, with 'best' being defined by people according to their own preferences. >P.S. Let's not make a war out of this; I just want to know if there's >anybody else who feels wxPython is performing better than TkInter. As long as we don't talk about politics,tabs, spaces, and indentation, we should be fine. From alex at somewhere.round.here Tue Jun 8 10:06:17 1999 From: alex at somewhere.round.here (Alex) Date: 08 Jun 1999 10:06:17 -0400 Subject: Two minor problems with running python in emacs Message-ID: Hi. When I run a python script in a py-shell under emacs, sometimes C-cC-c doesn't return me to the shell for a VERY long time. Does anyone know why, and is there a workaround? In case it's relevant, I think I'm working under RedHat 5.2. And now a question from the "there's no harm in asking"-department: if a script running under a py-shell runs pdb.set_trace (), is there some way to get emacs to do gud things like point to the debugger's current execution line in some other buffer? Alex. From Greg.Ewing at p98.f112.n480.z2.fidonet.org Wed Jun 30 16:46:15 1999 From: Greg.Ewing at p98.f112.n480.z2.fidonet.org (Greg Ewing) Date: Wed, 30 Jun 1999 21:46:15 +0100 Subject: file.tell problems (1.5.2/Win32) Message-ID: <00001596@bossar.com.pl> From: Greg Ewing Joshua Rosen wrote: > > This leads me to believe that `append mode' is intended to `append' at the > *current* point in the file, which should, for consistency's sake, start at 0. I just tried an experiment (on Windows) using "a+" mode. It seems that f.tell() is telling the truth, but the truth is strange. What "a"/"a+" modes seem to mean is "open the file positioned at 0, but if the first operation is a write, go to the end of file before doing it". Which seems quite bizarre to me - wouldn't it be simpler to just go to the end of the file on opening? Greg From fleck at informatik.uni-bonn.de Sat Jun 12 05:06:20 1999 From: fleck at informatik.uni-bonn.de (Markus Fleck) Date: 12 Jun 1999 09:06:20 GMT Subject: urllib: an alternative URLOpener References: Message-ID: <7jt7uc$sh4@news.rhrz.uni-bonn.de> Moshe Zadka wrote: > Whom do I contact about adding the following code to urllib: > -------------->8-------------->8------------------------- > class QuietFancyURLOpener(FancyURLOpener): > def prompt_user_password(self, host, realm): > return None, None > -------------->8-------------->8------------------------- > (Yes, I realize I can put it in my own program. But it seems a generally > useful thing for non-interactive downloaders) While we're at it... :-) - It might also be nice to have a FancyURLOpener that raises an exception on an authentication mismatch. And one that takes a user-defined user/password table dictionary or a callback function. Yours, Markus. -- "That isn't the future I have in mind for the information highway: I want to access more diverse connections and deeper thoughts, not cooler commercials and new tolls." -- Geoff Dutton, http://photo.net/philg/humor/media-lab.html From MHammond at skippinet.com.au Thu Jun 10 18:26:03 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Fri, 11 Jun 1999 08:26:03 +1000 Subject: Pythonwin - advise sought References: <375FA468.98976DDF@connection.com> Message-ID: <7jpdv5$aq0$1@m2.c2.telstra-mm.net.au> Colin J. Williams wrote in message <375FA468.98976DDF at connection.com>... >I am looking at Pythonwin as an alternative to Tk and would appreciate advice on >the following three questions. > >The Pythonwin documentation points to MFC documents as a source of information. >The MSDN site has: > >http://msdn.microsoft.com/library/devprods/vs6/vc++/vcmfc/_mfc_about_the_mi crosoft_foundation_classes.htm''' > >Q1: Are there better sources which can be recommended? Not buy me. Ive been doing MFC for years now and never owned a book on it :-( >The code fragment below: > > code1= "win32ui.CreateFileDialog(1)" > fd= eval(code) > print(repr(fd)) Or: print repr(win32ui.CreateFileDialog(1)) :-) > object 'PyCFileDialog' - assoc is 007CC240, vf=False, > notify=0,ch/u=0/0, mh=0,kh=0 These are really for debugging: assoc is: The address of the MFC object wrapped (ie, the CFileDialog) vf=false: Is there a .py class associated with this C+ object? notify=0: How many HookNotify() calls have been made on the object ch/i=0/0: Can't remember - use the source :-) mh=0: How many HookMessage calls. kh=0: How many keyboard handlers. >Q3. Is there some way that one can test that fd is an instance of some class, >any class? FD is not a class, it is a type. There are no good examples for a file dialog, but consider: >>> ps=win32ui.CreatePropertySheet("Test") >>> ps object 'PyCPropertySheet' - assoc is 01102980, vf=False, notify=0,ch/u=0/0, mh=0, kh=0 >>> Same as your example. Now lets create a property sheet using a Python class: >>> ps=pywin.mfc.dialog.PropertySheet("Test") >>> ps Now it is a Python class. We can get the win32ui type object by looking at _obj_ - ie: >>> ps._obj_ object 'PyCPropertySheet' - assoc is 01104F10, vf=True, notify=0,ch/u=0/0, mh=1, kh=0 >>> Note in this example we have "mh=1" indicating that the pywin.dialog.PropertySheet class hooked a single windows message. Hope this helps... Mark. From marcoxa at copernico.parades.rm.cnr.it Tue Jun 29 11:39:41 1999 From: marcoxa at copernico.parades.rm.cnr.it (Marco Antoniotti) Date: 29 Jun 1999 17:39:41 +0200 Subject: Why is tcl broken? References: <1283099377-77267484@hypernet.com> <876748mcxg.fsf@home.ivm.de> <37788BB9.ABD@mailserver.hursley.ibm.com> <7laoq0$bvh$1@Starbase.NeoSoft.COM> Message-ID: > Delivery-Date: Tue, 29 Jun 1999 17:28:08 +0200 > Date: Tue, 29 Jun 1999 10:30:14 -0500 (CDT) > From: Cameron Laird > Newsgroups: comp.lang.python,comp.lang.lisp,comp.lang.scheme > Organization: NeoSoft, Inc. +1 713 968 5800 > content-length: 645 > > In article , > Marco Antoniotti wrote: > . > . > . > >spin. :) Finally, AFAIU, a Tcl "macro" must run as an interpreter of > >the spec. A Common Lisp (Scheme) macro is compiled into regular code > >by read-time expansion. > . > . > . > Are you making a semantic point, or arguing > on the basis of implementation-specific per- > formance? It is (mostly) a semantic point. > If the latter, please be aware > that the Tcl community is actively investi- > gating dramatic speedups of [eval]. I have no problems with that. But the following example is pretty hard to beat. :) ============================================================================== * (defmacro zut (a) `(list ,a)) ZUT * (defun zot (x) (zut x)) ZOT * (compile 'zot) ZOT * (disassemble 'zot) 071B5790: .ENTRY ZOT(x) ; (FUNCTION (T) LIST) 7A8: ADD -18, %CODE 7AC: ADD %CFP, 32, %CSP 7B0: CMP %NARGS, 4 ; %NARGS = #:G0 7B4: BNE L0 7B8: NOP 7BC: MOVE %A0, %A4 ; %A0 = #:G1 7C0: MOVE %A4, %A0 ; No-arg-parsing entry point 7C4: ADD 4, %ALLOC 7C8: ANDN %ALLOC, 7, %A3 7CC: OR 3, %A3 7D0: MOVE %A3, %A1 7D4: ST %A0, [%A1-3] 7D8: ST %NULL, [%A1+1] 7DC: TADDCCTV 4, %ALLOC 7E0: MOVE %A3, %A0 7E4: MOVE %CFP, %CSP 7E8: MOVE %OCFP, %CFP 7EC: J %LRA+5 7F0: MOVE %LRA, %CODE 7F4: UNIMP 0 7F8: L0: UNIMP 10 ; Error trap 7FC: BYTE #x04 7FD: BYTE #x19 ; INVALID-ARGUMENT-COUNT-ERROR 7FE: BYTE #xFE, #xED, #x01 ; NARGS 801: .ALIGN 4 * ============================================================================== Of course I could have defined a much more intricated macro. Cheers -- Marco Antoniotti =========================================== PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY tel. +39 - 06 68 10 03 17, fax. +39 - 06 68 80 79 26 http://www.parades.rm.cnr.it/~marcoxa From bwarsaw at cnri.reston.va.us Mon Jun 7 09:12:39 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Mon, 7 Jun 1999 09:12:39 -0400 (EDT) Subject: File locking References: <199905301615.MAA00996@mira.erols.com> <14163.61310.936743.849211@anthem.cnri.reston.va.us> Message-ID: <14171.50503.221763.561735@anthem.cnri.reston.va.us> >>>>> "MS" == Markus Stenberg writes: >> "Barry A. Warsaw" writes: >> You might want to look at Mailman's flock.py module. The doc >> string says: MS> At least on our HP-UX devel box (HP-UX 11.0) it failed MS> miserably, didn't have the time to examine why, though. Darn. If you get the chance, I'd really like to know more about the failure. I don't have an HP-UX box to debug this on and it would help make Mailman more robust. -Barry From ivnowa at hvision.nl Sat Jun 12 07:15:12 1999 From: ivnowa at hvision.nl (Hans Nowak) Date: Sat, 12 Jun 1999 11:15:12 GMT Subject: Newbie question: DOS console commands? Message-ID: <199906121113.NAA01576@axil.hvision.nl> > I'm new to Python this week and was wondering if there are any console > commands to use on a DOS screen (e.g. ClearScreen, GotoXY, Foreground and > Background colors, etc.) > > I've got PythonWin running on Windows 95 and am having fun learning the > language and Tkinter, but I have a need to write a simple DOS interface > program. I could pull out my copy of TurboPascal, but I'd like to write it > in Python to further my education. I happen to maintain a Python version for DOS, which has *some* support for screen manipulation. Due to the little interest in a DOS Python, I never really looked into this, I just kludged together a few modules and functions. Now if this stupid little #&#*(@( computer vendor had provided me with a well-working box, I would have been able to look at it right now and maybe write a few extra functions... but since they didn't, I'm unable to update Python-DX (and my snippets page) at this moment. I will in the (hopefully near) future though. Meanwhile, you could check out Python-DX at http://www.cuci.nl/~hnowak/html/python-dx.html . Check out modules like _conio and _pc. (There are wrapper modules for them, but they're part of a separate library, which I have different plans with.) If you're really wanting to use this extensively I will update my modules and docco as soon as I can. Veel liefs, --Hans Nowak (ivnowa at hvision.nl) Homepage: http://fly.to/zephyrfalcon --Hans Nowak (ivnowa at hvision.nl) Homepage: http://fly.to/zephyrfalcon From dick.wall at usa.net Mon Jun 14 09:12:07 1999 From: dick.wall at usa.net (root) Date: 14 Jun 1999 09:12:07 -0400 Subject: High performance Python on NT References: <000301beb3b7$4f973810$6eba0ac8@kuarajy.infosys.com.ar> <37609429.65A7E802@palladion.com> <37611A73.348C6C5C@erols.com> Message-ID: R Wentworth writes: > Tres Seaver wrote: > > Run, don't walk, to http://www.zope.org. You'll think you've died and gone to > > heaven. Agreed, I just used Zope for a project here to replace some java servlet code which was under-performing. After convincing my bosses to let me demo it, I got the go ahead. A month later I am running a web based administration system that is nice and fast, and pretty bullet proof to boot. I actually used the ZPublisher part of the system and pretty much ignored the templates and IDE just because I like the hands on approach, and also I wanted to use the existing Java Servlet templates, which used a different mark-up to the DTML stuff in Zope. It was a dream to develop in. > > I looked at Zope a little while ago, and it did seem rather exciting. > Depends a little bit on your constraints, though, whether it's the > right solution. I had a project that needed to be hosted via a commercial > hosting provider, and nobody was willing to run Zope unless I rented > a dedicated server. (Actually, not really nobody, but with web hosting > providers it can be devastatingly bad to become dependent on a single > hosting service unless you've got a lot of prior positive experience > with them.) Zope can run in a number of ways though. We use it as a back end to an existing web-server (in fact website pro since we are using NT as the OS, the work I did was developed in Linux though because I prefer the taste of it :-). You do need to run it has a process (UNIX) or a service (NT) but apart from this and a suitable re-direct on an existing web server, it has fairly minimal impact. > > I chose instead to go with a solution using the Java "servlet" interface > (instead of CGI), and writing JPython (http://www.jpython.org/) servlets > instead of Java servlets. Don't know if this could be considered a > "high-performance" solution; it avoids the process creation and > DB connection overhead of CGI solutions, but JPython is inherently > slower than Python. So, depends what sort of performance matters. > I expect JPython to be fine as long as I'm not too compute-intensive; > we'll see. In this model, if I run into performance bottlenecks > I can improve things by selectively rewriting code into Java. Well, the Java servlet stuff did not perform as we wanted it too which was why we started this in the first place. In fairness it was not the servlet framework itself that was the problem, but rather some of the support libraries which would not perform quickly or reliably enough. > > (I did have a few other concerns about Zope: I wanted to do some > non-hierarchical design, and found that the limited documentation > made attempting such a thing difficult. Still, I hope to have > an excuse to learn/use Zope someday in the future.) Agreed, it took me about a week of playing to really "get it" but after I did, it was smooth sailing from there. I would recommend looking into using ZPublisher directly, as it helps with understanding the rest of the system better (at least it did for me). > > Robert Wentworth Cheers Dick From jeremy at cnri.reston.va.us Mon Jun 14 11:42:14 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Mon, 14 Jun 1999 11:42:14 -0400 (EDT) Subject: urllib: an alternative URLOpener In-Reply-To: <14178.38855.323759.698523@bitdiddle.cnri.reston.va.us> References: <7jt7uc$sh4@news.rhrz.uni-bonn.de> <14178.38855.323759.698523@bitdiddle.cnri.reston.va.us> Message-ID: <14181.8918.956963.762261@bitdiddle.cnri.reston.va.us> Ok. There is now an alpha version of urllib2 available from my Web page: http://the-tech.mit.edu/~jeremy/python/ I wrote this module because the current urllib is too hard to customize. It was difficult to use only a subset of the basic functionality in FancyURLopener and the error reporting was problematic. I hope to have addressed both these issues with urllib2. This code has not received extensive testing. I expect that there are a number of lurking bugs. There is too much diversity on the Web for my own testing to have covered all the possible cases. I'd appreciate bug reports, comments on the design, requests for new features, etc. Most of all, I need suggestions for a name; urllib2 is a clunker. I expect to make one or two more alpha releases, as I finalize the feature set. I've got no timetable in mind, although I have a vacation in August, which would be an appropriate time to make a final release. Jeremy From radbit at my-deja.com Sun Jun 20 20:10:01 1999 From: radbit at my-deja.com (radbit at my-deja.com) Date: Mon, 21 Jun 1999 00:10:01 GMT Subject: Newbie Q: How to call unmodified VB DLL from Python References: <3769bcd1.54492213@news.earthlink.net> Message-ID: <7kjvsl$rtu$1@nnrp1.deja.com> In article <3769bcd1.54492213 at news.earthlink.net>, lull at acm.org (John Lull) wrote: > As a first Python project, I'd like to use Python (or JPython) to > automate some hardware testing under Win95/98/NT. The hardware in > question is run by a DLL written in VB, and to which I do not have > source. > > "Extending & Embedding the Python interpreter", ch. 3, has > instructions for building a DLL which will work, but assumes you're > working in VC++ and have the source. > > If anyone could point me toward instructions on how to make this work, > I'd be grateful. > > Thanks. > > Regards, > John > > Hi since VB has only been able to do in-process OLE (Com) Dlls since VB4.0 I take it that this DLL exposes its methods via COM. In which case it should be a snip to talk to it via Marc Hammond's Pythonwin COM support. Find out what it's programmatic id is (progid) from Pythonwin's COM browser or MS VC++'s COM Viewer. Once you know what progid it has you can do: >>> from win32com.client import Dispatch >>> vbObj=Dispatch('progid') or you can also look at the methods it exposes via Pythonwin's Com browser. If the Dll is not written in VB then you'll probably need Sam Rushing's CallDll package which lets you invoke the LoadLibray,GetProcAddress, etc functions. Hope this helps -- Florent Heyworth Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From news at dorb.com Tue Jun 22 10:58:57 1999 From: news at dorb.com (Darrell) Date: Tue, 22 Jun 1999 10:58:57 -0400 Subject: choosing random numbers with weights/probability? References: <929987267.6227@www.remarq.com> <7knamm$kas$1@news.udel.edu> Message-ID: Orig: Time: 10.28 sec {'one': 25167, 'two': 25144, 'three': 49689} Terry's: Time: 9.94 sec {'one': 24983, 'three': 50020, 'two': 24997} -- --Darrell From jrush at summit-research.com Fri Jun 18 03:04:55 1999 From: jrush at summit-research.com (Jeff Rush) Date: 18 Jun 1999 07:04:55 GMT Subject: Parsing HTML References: <376984E2.5055E13D@lockstar.com> Message-ID: On Thu, 17 Jun 1999 13:27:33, Mordy Ovits wrote: > What is the best way to parse HTML into a Python data structure, allow me change it, > and output it as HTML? > -- > o Mordy Ovits > o Cryptographic Engineer > o LockStar Inc. One good way is to use the DOM framework of XML. You can get the module and docs at www.python.org in the XML-SIG section. A tiny example follows: ----- cut here ----- #!/usr/bin/env python from xml.dom.html_builder import HtmlBuilder from xml.dom.writer import HtmlWriter # Read in Original HTML Source # and Build a DOM Tree Structure # ---------------------------- htmlstr = open('test.html', 'r').read() b = HtmlBuilder(ignore_mismatched_end_tags=1) b.feed(htmlstr) # Stuff the HTML Source into the HTML Parser doc = b.document # Get the Newly Constructed Document Object # Perform Modifications as Needed # ------------------------------- text = doc.createTextNode("Additional Title Text") titlenode = doc.getElementsByTagName('TITLE')[0] titlenode.appendChild(text) # Write DOM Tree Back as HTML Source # -------------------------------- fd = open('output.html', 'w') w = HtmlWriter(stream=fd) w.write(doc) ----- cut here ----- There is also an XML/DOM based HTML Pretty Printer posted in here a week ago, which I find useful to clean up the output HTML. If you can't find it, drop me a line. -Jeff Rush From pduffin at mailserver.hursley.ibm.com Fri Jun 11 08:00:56 1999 From: pduffin at mailserver.hursley.ibm.com (Paul Duffin) Date: Fri, 11 Jun 1999 13:00:56 +0100 Subject: Why is tcl broken? References: <375F82C7.CF0F0477@iname.com> <7jp5lp$jo1$1@Starbase.NeoSoft.COM> Message-ID: <3760FA78.63AA@mailserver.hursley.ibm.com> Cameron Laird wrote: > > In article , > Michael P. Reilly wrote: > . > . > . > >I believe that current releases of Tcl can handle null bytes, but I > >have not verified that. > Yes. Tcl8.0 and after handle null bytes. > . > . > . Although 8.0 did/does have some holes in its null byte support. -- Paul Duffin DT/6000 Development Email: pduffin at hursley.ibm.com IBM UK Laboratories Ltd., Hursley Park nr. Winchester Internal: 7-246880 International: +44 1962-816880 From andrew at andrewcooke.free-online.co.uk Wed Jun 23 04:22:15 1999 From: andrew at andrewcooke.free-online.co.uk (Andrew Cooke) Date: Wed, 23 Jun 1999 08:22:15 GMT Subject: Thread for Tkinter (NT) Message-ID: <7kq5fh$1g9$1@nnrp1.deja.com> Hi, Does the thread running Tk.mainloop() have to be the main (initial) thread on W32? This is what I seem to be experiencing, and given W32's thread based messaging for windows it wouldn't surprise me, but could someone please confirm? And if so, is there any way around this - the GUI can't start first, but is started via call to a subroutine. If the main thread is then locked in mainloop is there any way of starting a new thread with the main thread's stack at that point and returning back to the rest of the code (OK, I guess not :-) Thanks, Andrew Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From jeremy at cnri.reston.va.us Thu Jun 3 14:31:19 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Thu, 3 Jun 1999 14:31:19 -0400 (EDT) Subject: threads In-Reply-To: <3756C078.5D998D3B@icrf.icnet.uk> References: <3756C078.5D998D3B@icrf.icnet.uk> Message-ID: <14166.51558.850416.153999@bitdiddle.cnri.reston.va.us> >>>>> "AM" == Arne Mueller writes: AM> Hi All, I'm using the threading module in python 1.5.2b2. I'm AM> wondering wheather the different threads are all executed in AM> parallel on a multiprocessor machine. The short answer is no. The Python interpreter has a lock that prevents allows only a single thread to execute at a time. This is an FAQ that isn't in the FAQ yet. Here's a more detailed answer: http://x37.deja.com/getdoc.xp?AN=415182307&CONTEXT=928434593.1326317628&hitnum=0 Jeremy From bwarsaw at cnri.reston.va.us Sun Jun 6 19:39:39 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Sun, 6 Jun 1999 19:39:39 -0400 (EDT) Subject: Using CVS under Win95 References: Message-ID: <14171.1723.95797.26115@anthem.cnri.reston.va.us> >>>>> "EvS" == Emile van Sebille writes: EvS> I'm trying to access the python source per (session paste EvS> follows): D> cvs -d :pserver:pythoncvs at cvs.python.org:/projects/cvsroot D> login | (Logging in to pythoncvs at cvs.python.org) | CVS.EXE [login aborted]: could not find out home directory When you log in, CVS tries to write a file called .cvspass in your home directory, containing authentication information. Your CVS client on Win95 apparently can't find your home directory to write this file. I have no idea how to set this up on Win95. -Barry From delgado at Mathematik.Uni-Bielefeld.DE Tue Jun 29 13:01:35 1999 From: delgado at Mathematik.Uni-Bielefeld.DE (Olaf Delgado) Date: Tue, 29 Jun 1999 19:01:35 +0200 Subject: Binary pickle portability Message-ID: Hi folks! Lately I observed strange things when trying to unpickle a binary pickle (including floating point numbers) produced on a different architecture. The Python versions involved were 1.5.1 and 1.5.2, the systems Irix 5 on Mips and Linux on Intel x86. Explanations I can think of: a) An incompatibility of binary pickles between 1.5.1 and 1.5.2 b) Pickle stores floats in native format. c) A problem in my installations. Any hints? Should binary pickles be avoided when sharing files between different systems/installations? Thanks! Olaf From thstr at serop.abb.se Mon Jun 7 03:45:48 1999 From: thstr at serop.abb.se (Thomas S. Strinnhed) Date: Mon, 07 Jun 1999 09:45:48 +0200 Subject: Programming Python - examples from the book work, no? Message-ID: <375B78AC.5DB962E4@serop.abb.se> Hi Doing everything in MSVC++ on NT I try to run the Example 14-2 (p534-540 ) from "Programming Python" by Mark Lutz. I run it just like it comes on the CD included with the book (CD-DRIVE:/Examples/DOS/Extend/Stacktyp.c) trying to extend Python with this Stack-type. BUT: I get an I-don't-know-what-this-is-about kind of compiler error, complaing about this call: PyObject_HEAD_INIT(&PyType_Type) with message "initializer is not a constant". PyObject_HEAD_INIT is in object.h as #define PyObject_HEAD_INIT(type) 1, type, and PyType_Type is (also in object.h) extern DL_IMPORT(PyTypeObject) PyType_Type; /* The type of type objects */ What's missing in this picture? Is it a version clash?? My sys.version '1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)]' (goes for everything but stacktyp.c, which I think is v1.3) Is it some declaration/definition missing that I need to add? Has anyone else had problems with this example code? ...and solved it? maybe even with some MS-developer-environment-point-of-view?? If it is an obvious mistake from my side, please point it out to me, otherwise just please point it out to me. Many Thanks -- Thomas S. Strinnhed, thstr at serop.abb.se (Below is the complete initialization of the Stacktype from stacktyp.c, near the eind of the file.) ... static PyTypeObject Stacktype = { /* main python type-descriptor */ /* type header */ /* shared by all instances */ PyObject_HEAD_INIT(&PyType_Type) 0, /* ob_size */ "stack", /* tp_name */ sizeof(stackobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* standard methods */ (destructor) stack_dealloc, /* tp_dealloc ref-count==0 */ (printfunc) stack_print, /* tp_print "print x" */ (getattrfunc) stack_getattr, /* tp_getattr "x.attr" */ (setattrfunc) 0, /* tp_setattr "x.attr=v" */ (cmpfunc) stack_compare, /* tp_compare "x > y" */ (reprfunc) 0, /* tp_repr `x`, print x */ /* type categories */ 0, /* tp_as_number +,-,*,/,%,&,>>,pow...*/ &stack_as_sequence, /* tp_as_sequence +,[i],[i:j],len, ...*/ 0, /* tp_as_mapping [key], len, ...*/ /* more methods */ (hashfunc) 0, /* tp_hash "dict[x]" */ (binaryfunc) 0, /* tp_call "x()" */ (reprfunc) 0, /* tp_str "str(x)" */ }; /* plus others: see Include/object.h */ ... From bmatt at acm.org Thu Jun 10 23:05:50 1999 From: bmatt at acm.org (Bruno Mattarollo) Date: Fri, 11 Jun 1999 03:05:50 GMT Subject: High performance Python on NT Message-ID: <000301beb3b7$4f973810$6eba0ac8@kuarajy.infosys.com.ar> Hi! I am about to start a project where I will need to do some high performance Web CGI scripts on WinNT ... I have no choice ... I know it's not the best combination. It's not my decision ;-) I am looking for some advice. Is it better if I use some kind of Active Python Scripting Page (ASP but with Python)? Or just doing CGI with threads it will be fine... ? I know this is a very vague question... I just want to know if someone had to take a similar decision... The app I will be doing should support several hundred users connecting to the Web server and doing some serious CGI activity ... Almost all hits that the server will receive will be scripts. The hardware is no problem in this case... When can scale up to Quad PII Xeon with 1GB RAM ... U2W SCSI discs... I know exactly what to do in a UNIX env... but I am not sure of the decision to take regarding win32... TIA /B Bruno Mattarollo ... proud to be a PSA member From gmcm at hypernet.com Thu Jun 17 10:21:51 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 17 Jun 1999 09:21:51 -0500 Subject: wierdness with pythonwin dialogs, threads & refcounts In-Reply-To: <3768b75e.5469224@NNRP.UK.INSNET.NET> Message-ID: <1282492928-113747642@hypernet.com> Dave Kirby writes: > I have found strange behaviour (strange to me at least) when > creating a pythonwin dialog on a separate thread created using the > standard python thread module. The dialog object is never deleted > since the thread is keeping references to it. > > The following example uses dlgtest.py that comes with the pythonwin > distribution: > > #------------- 8< ---------------------------- > C:\dev\PYTHON\Pythonwin\pywin\DEMOS>python > Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on > win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> from dlgtest import TestDialog > >>> import sys, thread > >>> def test(): > ... t = TestDialog() > ... print "refs:", sys.getrefcount(t) > ... t = None > ... > >>> test() > Edit text changed! > refs: 2 > >>> thread.start_new_thread( test, () ) > >>> refs: 6 > #------------- 8< ---------------------------- > > As you can see from the above, creating the dialog in the thread > gives it an extra 4 references compared with the non-threaded > invocation. Is this a bug, or is the thread module incompatible with > pythonwin? If so how would I do the equivalent using pythonwin > threads? I have read the available docs, but it is still pretty > opaque to me. First, there's no incompatibility with the thread module in Pythonwin. Second, you should use threading.py, not the low level thread module (which is very, very primitive). Or you can use win32process.beginthreadex which is a wrapper around MFC threads. This lets you manipulate priorities. (As of a couple years ago, there was a small memory leak involved with using MFC threads, however). As for the source of your questions - without doing things in a debug build of python / Pythonwin, it's almost impossible to tell what's going on, or even if there really is a problem. Using sys.getrefcount increments the refcount. Printing something in the interactive interp binds the thing to a var named "_" (to optimize looking at it again). Printing to stdout in Pythonwin involves all kinds of hidden manipulations. If you want to know whether you're leaking TestDialogs you could code a loop that creates threading.Thread's that show a TestDialog and then joins the Thread. Run it for as many iterations as you can stand, and watch the process in TaskManager. hope-you're-not-prone-to-Carpal-Tunnel-Syndrome-ly y'rs - Gordon From avv at quasar.ipa.nw.ru Thu Jun 3 00:11:53 1999 From: avv at quasar.ipa.nw.ru (Alexander V. Voinov) Date: Wed, 02 Jun 1999 21:11:53 -0700 Subject: ANN: pyslang-0.2.0 Message-ID: <37560089.83BD84A8@quasar.ipa.nw.ru> Dear Colleagues, This release provides more Pythonic way to invoke three SLang functions which deal with the 'raw' representation of the portions of the screen as a sequence of pairs (color, character): SLsmg_write_color_chars( [(color1, char1), (color2, char2), ...]) list_length, [(color, char), ...] = SLsmg_read_raw(list_length)) SLsmg_write_raw([(color, char), ...]) The 'char's in these synopses are represented also pythonically as strings of the length 1. An element of the list used as the parameter (but NOT the result) here may also be just an unsigned short, composed as color << 8 | char. In that case 'char' is really the character's integer representation (obtained, e.g., via ord()). This is retained for better compatibility with the underlying C library, but may be discontinued in future releases. The result of the function SLsmg_read_raw is always a list of tuples as depicted above. When color value is OR'd with 0x80 it represents the alternative character set, supposed to contain pseudographic characters. Unfortunately, this part of SLang occur to work differently under Unix and win32. In the first case, at least under Linux, one switches the character sets or uses 0x80-d colors and gets pseudographics by specifying chars as 'q', 'v', etc from a subset of the first 128 ASCII characters. Under win32, however, both switching the character sets and 0x80-ing the colors does nothing, and pseudographics is found, in usual PC manner, in the higher half of the ASCII table. Certainly one would easily map the win32 behaviour onto the Unix one within the slang.i interface file. But it would break proper transparency on the pyslang wrapper. The best would be if the appropriate mapping was done within the SLang library itself, probably with some additional 'option-set' function, which would retain standard win32 behaviour for those who requires best backward compatibility with the older PC/DOS stuff. Any ideas/comments/desires are welcome to be reflected in future releases. In that version the demo_*.py examples are best viewed under Unix. They run however, under win32, with some minor ugliness. The distribution is found at the Starship: ftp://starship.python.net/pub/crew/avv/pyslang/pyslang-0.2.0.tgz It contains sources for Unices and win32 together with two binaries: for Linux (latest glibc) and win32. Alexander From hniksic at srce.hr Thu Jun 3 16:00:57 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 03 Jun 1999 22:00:57 +0200 Subject: threads References: <3756C078.5D998D3B@icrf.icnet.uk> <14166.51558.850416.153999@bitdiddle.cnri.reston.va.us> Message-ID: <8790a1njeu.fsf@pc-hrvoje.srce.hr> Jeremy Hylton writes: > >>>>> "AM" == Arne Mueller writes: > > AM> Hi All, I'm using the threading module in python 1.5.2b2. I'm > AM> wondering wheather the different threads are all executed in > AM> parallel on a multiprocessor machine. > > The short answer is no. The Python interpreter has a lock that > prevents allows only a single thread to execute at a time. Eek. That's depressing. Isn't supporting threads and not allowing simultaneous execution a bit weird? From jeremy at cnri.reston.va.us Wed Jun 2 12:33:17 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Wed, 2 Jun 1999 12:33:17 -0400 (EDT) Subject: Python 2.0 (perhaps off topic) In-Reply-To: <3754BAFE.192D7648@prescod.net> References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <87pv3iq6ss.fsf@ev.netlab.co.jp> <3752C76D.604CD474@prescod.net> <87n1ykr0z9.fsf@ev.netlab.co.jp> <375372F6.A874554@prescod.net> <14164.7179.10346.998488@bitdiddle.cnri.reston.va.us> <375431E6.6BC64E80@prescod.net> <14164.43542.417731.361360@bitdiddle.cnri.reston.va.us> <3754BAFE.192D7648@prescod.net> Message-ID: <14165.22828.439378.233057@bitdiddle.cnri.reston.va.us> >>>>> "PP" == Paul Prescod writes: PP> Jeremy Hylton wrote: >> Perhaps this is what I get for jumping in in the middle of a >> conversation without learning how it got started. The example I >> was responding to depended on file object being immediately >> finalized to avoid leaking file descriptors. PP> This is a documented feature of Python (documented in the FAQ at PP> least). New users do not currently need to learn otherwise That doesn't count! Among other reasons, the FAQ predates JPython. Guido and Jim spent some time going through the differences between CPython and JPython, and deciding which of the differences where legitimate and which were bugs or incompatibilities. I believe that memory management is one of those implementation-dependent issues that the language semantics do not specify. PP> unless they use JPython which is incompatible in this regard. In PP> other words, this IS a demonstration of a flaw in GC, or at PP> least in Java GC because it required a change in the Python PP> language semantics. Don't think it's fair to call it a change-- just a clarification. Nor would the problem necessarily lie with the garbage collector. If the language spec had said that finalizers were always called such that you could depend on it to free resources like file descriptors, then it would have been a bug in the spec <0.1 wink>. PP> I think that that is all anyone has been saying. Many people PP> like the current semantics and don't trust that a full GC would PP> deterministically invoke finalizers for arbitrary resources. I'm sure it wouldn't, but as the FAQ entry you mentioned explains, there are some exceptions with reference counting, too. In general, it's a rather risky to depend on the finalizers to close resources for you. Even with reference counting, it's easy to have one more reference than you think and not have some files get closed. Jeremy From schorsch at schorsch.com Sun Jun 20 15:54:12 1999 From: schorsch at schorsch.com (Georg Mischler) Date: Sun, 20 Jun 1999 19:54:12 GMT Subject: do anonymous pipes normally work on NT? References: <4D0A23B3F74DD111ACCD00805F31D8100DB90DFB@RED-MSG-50> Message-ID: <7kjgt1$noj$1@nnrp1.deja.com> Bill Tutt wrote: > After digging through this stuff, I went back and looked at the code I had > written for win32popen.cpp. I realized that I had forgotten why I had > written the DuplicateHandle() code, so I went back commented it out from the > KB article that I had originally used, and then modified runproc.py to do > the same thing. > > cat.py is now much happier with life with the new and improved runproc.py. [more stuff] Uh oh, Bill... If you should ever happen to visit the Munich Oktoberfest, please remind me that I owe you a few beer! Actually, I stayed with the inheriting version for the moment, as it will work with existing versions of the win32 extensions. And I'm not sure if I got the changes in the sources (or the compilation) right. At least I didn't see any changes after replacing my win32process.pyd. The most important thing is of course that my code works now. I'll have another look at the esthetically more pleasing changes later, when the dust has settled a little in my brain... > Notice I also changed the DETACHED_PROCESS to a zero. This is to not do > those wierd things that DETACHED_PROCESS seems to do. Since stdin, etc.. are > pipes, it doesn't matter if the process technically has access to > runproc.py's NT console. (if any) Another thing I noted here, is that with pythonw.exe (instead python.exe), the second generation of processes gets those problems again, no matter what you do (my application starts a "process wrapper" in python, which will call other programs to do the real work in the background). > The other alternative from 0 would be to pass in CREATE_NEW_CONSOLE, > and tweak win32process_win32module.cpp to add: > {"wShowWindow", T_INT, OFF(m_startupinfo.wShowWindow)}, > //@prop integer|wShowWindow| > > onto the end of PySTARTUPINFO::memberlist, and then do the following: > StartupInfo = win32process.STARTUPINFO() > StartupInfo.hStdInput = hStdin_r > StartupInfo.hStdOutput = hStdout_w > StartupInfo.hStdError = hStderr_w > StartupInfo.dwFlags = win32process.STARTF_USESTDHANDLES | > win32process.STARTF_USESHOWWINDOW > StartupInfo.wShowWindow = win32con.SW_HIDE > > Mark: please add that line when you get a chance. :) Yes, I noticed this attribute missing as well, but wasn't sure what to insert where... Interestingly, STARTF_USESHOWWINDOW keeps the console window from opening even without it. The structure member seems to get initialized to zero somehow. > '''runproc.py > [and more of my code expertively enhanced...] Thanks a lot for all the tips and bug hunting! -schorsch -- Georg Mischler -- simulation developper -- schorsch at schorsch.com +schorsch.com+ -- lighting design tools -- http://www.schorsch.com/ Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From arcege at shore.net Mon Jun 7 11:52:45 1999 From: arcege at shore.net (Michael P. Reilly) Date: Mon, 07 Jun 1999 15:52:45 GMT Subject: bug in os.path.samefile (Python 1.5.1)? References: <1318D78C9072D11195C9006094EA98A72C20EF@ocesrv> <22Ms+CA0H7W3EwBA@jessikat.demon.co.uk> Message-ID: Robin Becker wrote: : In article , Thomas Bryan writes :> :>On Mon, 7 Jun 1999, Matej Cepl wrote: :> :> : ... :> :>Aren't filenames case-sensitive on NT? Look at your traceback. Notice : last time I used NT4.0 in November paths were case insensitive I think case-insensitive is correct; and there is os.path.normcase() for this I believe. I've just tried Python 1.5.2 (don't have 1.5.1 installed anymore, sorry) on WinNt 4.0 SP3 and get case-insensitivity: Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit ] on win32 Copyright 1991-19995 Stichting Mathematisch Centrum, Amsterdam >>> import os, win32api >>> os.getcwd() 'D:\\Program Files\\Python' >>> os.listdir('d:\\python files\\python') ['DLLs', 'Doc', 'include', INSTALL.LOG', 'Lib', 'libs', 'py.ico', 'pyc.ico', 'pycon.ico', 'python.exe', 'pythonw.exe', 'Tools', 'UNWISE.EXE'] >>> os.stat('doc') (16895, 0, 3, 1, 0, 0, 0, 957573914, 918516880, 918516864) >>> win32api.GetVersionEx() (4, 0, 1381, 2, 'Service Pack 3') >>> os.path.normcase('D:\\Program files\\Python') 'd:\\program files\\python' >>> Not really answering the original posting I know, but... :) -Arcege From tim_one at email.msn.com Fri Jun 4 21:42:21 1999 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 4 Jun 1999 21:42:21 -0400 Subject: threads In-Reply-To: <87u2sn4p31.fsf@pc-hrvoje.srce.hr> Message-ID: <000b01beaef4$a73d0580$f19e2299@tim> [Hrvoje Niksic] > ... > Ironically, when I first saw "tuples" in Python, I assumed they were > invented to speed up threading because you don't need to lock access > to immutable structures. (The same applies to immutable strings.) > Boy, was I wrong. :-( Besides, immutable structures are still mutable "under the covers": in particular, their refcounts get boosted and dropped all the time. That also needs to be atomic. OTOH, you weren't wrong! Guido is well aware of the optimizations that *may* someday apply thanks to immutability. That not all coneivable such have been implemented yet is merely evidence that time has extent . the-poor-man's-so-depressed-about-whitespace-he-can-barely-get- thru-the-day-ly y'rs - tim From mnot at pobox.com Sat Jun 12 22:59:09 1999 From: mnot at pobox.com (Mark Nottingham) Date: Sun, 13 Jun 1999 02:59:09 GMT Subject: urllib: an alternative URLOpener References: <7jt7uc$sh4@news.rhrz.uni-bonn.de> <14178.38855.323759.698523@bitdiddle.cnri.reston.va.us> Message-ID: <016301beb548$b5ef8a80$0301a8c0@cbd.net.au> FWIW, I've put a fairly complete spidering class together as part of a project... may be useful for somebody out there... http://www.mnot.net/cacheability/download.html ----- Original Message ----- From: Jeremy Hylton Newsgroups: comp.lang.python To: Sent: Sunday, June 13, 1999 3:24 Subject: Re: urllib: an alternative URLOpener > I've been working on-and-off on a replacement for urllib that is more > easily customizable; they basic philosophy has been to avoid > inheritance as the customization mechanism. Instead, a single > director class coordinates the activities of many small handlers that > implement one feature/protocol. > > The resulting architecture makes it much easier to create a UrlOpener > that handles redirects (which is probably the crucial feature of > FancyUrlOpener) without getting all of the other cruft (like prompting > the user to enter a password on stdin). > > I've been delayed a bit because I wanted to add better support for > proxies, e.g. using a proxy only for URLs that match some pattern. > Since people are asking about this, I'll expedite my release plans > :-). I'll try to make a useful release available early next week. > > Jeremy > > > > > From Alan.Daniels at p98.f112.n480.z2.fidonet.org Wed Jun 30 23:55:35 1999 From: Alan.Daniels at p98.f112.n480.z2.fidonet.org (Alan Daniels) Date: Thu, 01 Jul 1999 04:55:35 +0100 Subject: Python suitable for a game engine? Message-ID: <000015f7@bossar.com.pl> From: daniels at mindspring.com (Alan Daniels) I'm working on a Quake-style game engine, where my goal is to give it a fully integrated editor, similar to the excellent ones in Starcraft and Unreal. I'm planning on doing this by giving the game and the editor as much back-end code in common as possible. What I want to do is be able to design the level in the editor, and then sprinkle objects and monsters around the level. All of these will have default low-level behaviors, so that level designers don't have to do monster AI from scratch. However, all the objects and monsters will have simple properties manipulated through a property list, similar to that in VB. This way, they can set properties such as, is the monster aggressive or passive, etc. Here's the thing. I want to have a script as its main property, so that the monsters can have elaborate behaviors, such as being mournful when their leader is killed, etc. The events would be things such as "create", "monster sees player", "clock tick", etc. All the functions in the script would be callbacks written in C++, to manipulate the monster to do things such as "patrol area", "play an animation", "sleep for X seconds", etc. In other words, the scripts would be glue, not the main thread of execution. I'm been using Python for a couple of years now, and it is my favorite scripting language. But, I don't have much experience with embedding it in a another program, and I don't know enough about the speed issues. So, my questions are... - Will Python be fast enough? Even with possibly 100 or 200 active items on a level? - Especially when all of the scripts will be live, and usually in the middle of a callback? - Should I use the interpreter in the library, or should I take an approach of crunching the byte-codes myself? I've seen plenty of cases where Python is used as a "VBA" style embedded language (load up the script, run it, and be done with it), but I haven't seen anything like this mentioned before. My other two candidate languages are Scheme and Perl, and I hate the syntax of both. So I really REALLY want to use Python if its viable. :=) If anybody can shed some light on this, I'd appreciate it. Thanks. -- ======================= Alan Daniels daniels at mindspring.com daniels at cc.gatech.edu From kjwolf at online.de Sun Jun 20 21:43:33 1999 From: kjwolf at online.de (Klaus-Juergen Wolf) Date: Mon, 21 Jun 1999 03:43:33 +0200 Subject: Problem with Curses References: <87ogidzs37.fsf@home.ivm.de> <6Zeb3.526$4e1.32195@iad-read.news.verio.net> Message-ID: <5c5kk7.fn.ln@solling.seismic.de> T.E.Dickey wrote: >>> It depends on when the executable is linked to libmytinfo, which only >>> takes place on platforms that don't know the terminfo database, like >>> BSD and Solaris; there are two competing declarations of tputs(). >> Why doesn't Freebsd know the terminfo database? Can't the one that is >> integrated into ncurses be used on FreeBSD? > I've been told ncurses 4.2 is incorporated in the FreeBSD 3.1 - but that > may still just be a port... Yes, there is such a port. Do you think, one could release code that works on several machines, while some of them must install a special program first? In the top priority, Python should work. When you compile it, it should work. When you decide to link libraries you have, it should work. When you release code for Python, it *must* work. Therefore, there are some modules that base on old, long forgotten states, but still, some machines work with these, and only with these. Curses now is a very old UI, very old, it was old when I first learned it in the beginning of the 80's. Most people have forgotten that there was a Curses before NCurses came up. cursesmodule now, it bases on Curses with NCurses extensions. It is not acceptable to release a cursesmodule that wouldn't work on all those platforms it formerly worked on. If you intend that, you'll have to give it a new name. Furthermore, you can't say, to make cursesmodule work, you have got to download another one, it's beta, but maybe, it works on your desolated site. But that's no solution. That's a cramp. Anyway, that wouldn't have helped in my case, I think, since the name conflict would have still existed - libtermcap would have been linked before, since libreadline demands it, and, I'm afraid, since ncurses originally defines tputs(), it would also been mis-linked. I don't really know, I guess. I'm not so familiar with the dynamic linking rules under ELF/BSD. cu k.j. -- Support Julia Hill - save the Redwood trees: http://www.lunatree.org/ From greg.ewing at compaq.com Thu Jun 10 20:02:27 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Fri, 11 Jun 1999 12:02:27 +1200 Subject: Python 2.0 References: <000b01beb21f$a17ff340$2fa22299@tim> Message-ID: <37605213.2ACAE4D3@compaq.com> Tim Peters wrote: > > "Therefore, we recommend that the design of finalize methods be kept simple > and that they be programmed defensively, so that they will work in all > cases." In my experience, this advice applies just as much to Python __del__ methods, their alleged greater predictability notwithstanding. The only times I can recall using __del__ methods were in shadow classes which needed to free resources in an extension module. I found that I had to program them very defensively, because when the interpreter shut down, it would dismantle the contents of my modules in a random order, causing my __del__ methods to crash if I wasn't careful. So I regard the environment of a __del__ method as pretty much unknowable as well! Greg From news at dorb.com Wed Jun 16 14:39:44 1999 From: news at dorb.com (Darrell) Date: Wed, 16 Jun 1999 14:39:44 -0400 Subject: GC In Python: YAS (Yet Another Summary) References: <1282571877-108998356@hypernet.com> Message-ID: Lars Marius Garshol wrote in message news:wku2s86nmb.fsf at ifi.uio.no... > > This may be a perfect world for lazy whiners after all. :) > > Check the web site again for a function that has a lazy mode. It > doesn't print anything unless there actually is a cycle, but other > than that it should make you happy. > > --Lars M. Wow ! Lars you are the man. That was fast. I'll give it a try. Thanks very much. --Darrell From siona at chiark.greenend.org.uk Tue Jun 22 06:50:25 1999 From: siona at chiark.greenend.org.uk (Sion Arrowsmith) Date: 22 Jun 1999 11:50:25 +0100 (BST) Subject: Creating a new type with an extension module References: Message-ID: In article , Sion Arrowsmith wrote: >http://www.python.org/doc/current/api/newTypes.html is unhelpful >in the extreme -- do I have to resort to reading source? It appears that I do, but thanks to everyone who pointed me in the direction of suitably readable source. I've got what I wanted working -- it would just be nice to understand why it works.... -- \S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/ ___ | "Frankly I have no feelings towards penguins one way or the other" \X/ | -- Arthur C. Clarke | If music be the food of love, bring me a doggie bag. From gmcm at hypernet.com Wed Jun 16 12:25:57 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 16 Jun 1999 11:25:57 -0500 Subject: Xbase files? In-Reply-To: <1318D78C9072D11195C9006094EA98A72C2149@ocesrv> Message-ID: <1282571876-108998462@hypernet.com> > Is there any module for their reading? > > matthew At ftp://ftp.python.org/pub/python/contrib/Database/ there should be a dbf.py for this purpose. - Gordon From adi at i-data.com Thu Jun 10 05:46:46 1999 From: adi at i-data.com (Adi) Date: Thu, 10 Jun 1999 09:46:46 +0000 Subject: Asserting object class Message-ID: <375F8986.73BA3C5@i-data.com> In a method, I'd like to assert that a parameter is an object which is of a specific class or has this class as it's base class. I can test on the __class__ and its __bases__ attributes, but its clumsy and I'm wondering if there is an easier notation, like: def method(self, p) assert class(p) == class(self) This is comparable to - in a strongly typed language - specifying a required base class as the type of the parameter. Sincerely, Anders Dinsen -- i-data is a leading vendor of printing connectivity solutions, e-forms software, and networking products. More information is available at www.i-data.com Disclaimer: I speak for myself, not my employer. From matomira at acm.org Mon Jun 14 08:22:22 1999 From: matomira at acm.org (Fernando D. Mato Mira) Date: Mon, 14 Jun 1999 14:22:22 +0200 Subject: OO (was: Why is tcl broken?) References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> <3762988E.C94AA252@iname.com> <3763C746.5CA8FE78@iname.com> <87pv2zjhhl.fsf@home.ivm.de> Message-ID: <3764F3FE.F7CBE6BA@acm.org> Klaus Schilling wrote: > Prefix rocks, infix is crap. Wow, wow, wow. Let's not go there.. -- Fernando D. Mato Mira Real-Time SW Eng & Networking Advanced Systems Engineering Division CSEM Jaquet-Droz 1 email: matomira AT acm DOT org CH-2007 Neuchatel tel: +41 (32) 720-5157 Switzerland FAX: +41 (32) 720-5720 www.csem.ch www.vrai.com ligwww.epfl.ch/matomira.html From larsga at ifi.uio.no Wed Jun 16 11:53:00 1999 From: larsga at ifi.uio.no (Lars Marius Garshol) Date: 16 Jun 1999 17:53:00 +0200 Subject: OO (was: Why is tcl broken?) References: <000801beb745$02768220$979e2299@tim> <871zfdp73f.fsf@home.ivm.de> <873dzsma6b.fsf@home.ivm.de> Message-ID: * Klaus Schilling | | No, in the sense `Steele merely rediscovered scheme, not bring it | into being' I don't understand what you mean by this. The two people who created Scheme originally were Sussman and Steele. If that isn't bringing it into being I don't know what would be. (See section 2.8 of 'The Evolution of Lisp'. ) --Lars M. From see-sig at wavedivision.com Tue Jun 8 22:05:58 1999 From: see-sig at wavedivision.com (Rick Robino) Date: 9 Jun 1999 02:05:58 GMT Subject: "Programming Python" still worthwhile? Message-ID: <7jki66$qam$1@news.gstis.net> Greetings, I've been watching this group for some time and just now getting warm to Python. Looking at source examples has been great, but for completeness' sake I'd like to get more of the "why" maybe found in a book. Since Python is at 1.5.2 and people are talking about 2.0 as if it's around the corner, I was wondering if anyone here could give me some advice as to whether or not "Programming Python" is useful, if the current edition is still current, if I should wait for the "Learning Python", or if I should use some other resources. I expect to come up to speed fairly quickly and I'm just looking for those fundamental insights into OOP and Python that can build up the kind of inuition and understanding one needs in order to "get comfortable" connecting/creating the dots. Currently I only program small - medium programs in C and shell (Korn). Any sage pointers to resources? TIA, --Rick ^^^^^^^^^^^^^^ Rick Robino rrobino at wavedivision.com From MHammond at skippinet.com.au Wed Jun 2 19:19:22 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Thu, 3 Jun 1999 09:19:22 +1000 Subject: Alien whitespace eating nanovirus strikes again! References: <375500C9.742DC539@pop.vet.uu.nl> <375536C2.DD917F99@prescod.net> Message-ID: <7j4e2u$8rh$1@m2.c2.telstra-mm.net.au> Aahz Maruch wrote: >I disagree with your parenthetical comment. I wouldn't call myself an >"expert" Python programmer by any stretch of the imagination, but I've >written a fair bit of it in connection with a multi-person project over >the past four months. As a seasoned programmer of many years and many >languages, I've disagreed with almost all the whines that have been >brought against Python (e.g. the stupid "=" vs. "==" thread), but this >is one point that still annoys me. Of course, this is your HO. Many other people (including myself) found that a few weeks in, they thought "this is great", and many years later, can't believe that other language still hold on to the "old ways". When I take a quick look at some of the new little languages referenced on this newsgroup, believe it or not, my _first_ reaction is "God those block closers are stupid and ugly" :-) Of course, I see and understand you concern, but I dont share it. My guess, from newgroup postings and anecdotal evidence, is that most seasoned programmers also do not share it. >code (which is what I've mostly been doing). But the whitespace problem >is a real PITA when it comes time to make a change to the structure of a >program -- it's an investment I don't mind making when I'm doing "real" Not to me. If I make structural changes to C or other programs, I always re-indent the reorganised code correctly, and I would bet that you do too. In almost all languages block indenting is _very_ important to the human reader. Further, when indenting the new C/whatever code, I attempt to keep the tabs/space usage correct (surprise surprise - not :-) so that other editors still display the code correctly - there isnt much more annoying than seeing _any_ code (Python or otherwise) incorrectly indented. So, for me anyway, I tend to do _exactly_ what I do with Python with any language. The only difference I can see is that other languages force me to use redundant block delimiters. Mark. From garry at sage.att.com Thu Jun 17 16:41:25 1999 From: garry at sage.att.com (Garrett G. Hodgson) Date: Thu, 17 Jun 1999 20:41:25 GMT Subject: Starting a project: any hints? References: <19990617154643.A1680@optiplex.palga.uucp> <7kb384$lgs$1@nnrp1.deja.com> Message-ID: <37695D75.CF8B877F@sage.att.com> Darrell wrote: > > - Make your program works from the very first day , it doesn't matter > > if it barely works. > > I'd like to emphasize this point. Don't write it all then try it. > Its easier to evolve from a functional kernel than to materialize all at > once. i second that emotion. also, don't be afraid to throw it away and rewrite if you find yourself painted into a corner. the value of the code is what you learned while writing it; the rewrite will be all the better for it. -- Garry Hodgson comes a time garry at sage.att.com when the blind man Software Innovation Services takes your hand, says, AT&T Labs "don't you see?" From Corran.Webster at p98.f112.n480.z2.fidonet.org Tue Jun 29 16:43:25 1999 From: Corran.Webster at p98.f112.n480.z2.fidonet.org (Corran Webster) Date: Tue, 29 Jun 1999 21:43:25 +0100 Subject: printing with print Message-ID: <00001597@bossar.com.pl> From: cwebster at math.tamu.edu (Corran Webster) In article <377925EF.1CBB640F at starvision.com>, Angus MacKay wrote: >is there any other way to print that with print? >perhaps with a real function. Yes, use sys.stdout, which is a file object: Python 1.5.2 (#13, Jun 16 1999, 23:19:35) [GCC egcs-2.91.60 19981201 (egcs-1.1.1 on netbsd1 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import sys >>> foo = "there" >>> sys.stdout.write("Hi"); sys.stdout.write(foo); Hithere>>> Notice that it doesn't even put a newline in. Also, you'll need to do conversion to a string to get the result you want for foo = 2. >>> sys.stdout.write("Hi"); sys.stdout.write(str(foo)); Hi2>>> >foo = 2 >print "hi" + foo You could do the explicit string conversion here too: print "hi" + str(foo) Corran From rdelon at my-deja.com Mon Jun 21 12:44:20 1999 From: rdelon at my-deja.com (Remi Delon) Date: Mon, 21 Jun 1999 16:44:20 GMT Subject: Check for valid date Message-ID: <7klq51$etp$1@nnrp1.deja.com> Hi, I'm trying to use the time module to check whether a date is actually a valid day or not. Unfortunately, it looks like the strptime function only performs a basic range check. (for example, it will accept 02/30/199) Here is a little test I did: >>> strptime('02/30/1999','%m/%d/%Y) (1999, 2, 30, 0, 0, 0, 61, 0) >>> mktime((1999, 2, 30, 0, 0, 0, 61, 0)) 920361600.0 >>> ctime(920361600.0) 'Tue Mar 2 00:00:00 1999' Is there a way to check test whether the day actually exists or not ? I also have a totally different problem : I'm trying to get python 1.5.2 to run with Tcl/Tk 8.1. Has anyone been able to do that on AIX ? I found 2 patches for tkinter that were supposed to fix the problems, but unfortunately, they don't work for AIX. Thanks Remi. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From thantos at brimstone.mecha Fri Jun 25 02:17:35 1999 From: thantos at brimstone.mecha (Alexander Williams) Date: Fri, 25 Jun 1999 06:17:35 GMT Subject: total idiot question: +=, .=, etc... References: <877lov62z1.fsf@pbl.ddns.org> <7ks38p$l4m$1@brick.cswv.com> <7kuocf$1an$1@brick.cswv.com> Message-ID: On 24 Jun 1999 21:09:19 -0500, Neel Krishnaswami wrote: >IMO, it's bad style to set properties that should belong to the type >in the instance initializer -- for example, the sort order is >something that's a property of the class, rather than the instances. Here's the crux of the problem, a sense of asthetics at variance with the usefullness of your code. Allow me to present a dissenting view: Setting properties which can vary dynamically over the life of an instance should be set on the instance itself, since the Class itself may have multiple instantiations in a multithreaded or multi-persistance environment. Ultimately, it becomes easier to note and manage varying fields on instances as they are easily seen in the __init__ function (and so satisfy lexical locality in finding them for maintainance) as well as cuts back on strange circumlocutions in dealing with them syntactically. > sortorder = 'date' # can be anything in Article.comparators.keys() Let's assume you set this in the __init__: def __init__(me): me.sortorder = 'date' > def __cmp__(self, other): > return self.__class__.comparators[self.__class__.sortorder](self, > other) .... then this becomes: def __cmp__(me, them): return me.comparators[me.sortorder](me, them) Note that comparators is set on the instance by inheritance, so we don't need to obscure that with a specialized __class__ reference, and with sortorder being an instance variable, there's no need for obscuration /there/, either. >I want the user to be able to determine how a list of Article's can be >sorted by setting the class's sortorder member. So a statement like > >>>> Article.sortorder = 'author' > >would change how lists of articles are sorted. This is definitely >something that's shouldn't be an instance attribute, imo; it would >defeat the purpose if each article could compare differently than >any other. (Oppose standardized testing! :]) In this case, the order in which articles are sorted shouldn't be on the Article object at all, then! Remember, encapsulation, encapsulation. Sort-order storage should be on the object that you use to contain references to Article-objects, and thus only needs to be changed in one place at one time (but still should be an instance variable, since it does change dynamically and shouldn't be inherited by all children of ArticleStore, since each may want to be sorted in a different way, providing different views into the same data). >It's perfectly reasonable for someone else to subclass Article and >override the Article.comparators attribute. (Say to add an ordering to >put Tim Peter's posts at the top of the list, or to use something >faster than my lambdas.) With the clear way of writing it, the >NewArticle class would mysteriously fail to do the right thing, >because the __cmp__ method would look in the Article class dictionary >without bothering to check NewArticle's. See above; note that calling me.comparators will /always/ work with inheritance. >This is an unusual glitch in Python; usually the readable way of doing >something is the right way of doing it. Ah, but it /is/ the right way, you're just insisting on the wrong way out of a twisted sense of asthetics. :) -- Alexander Williams (thantos at gw.total-web.net) "In the end ... Oblivion Always Wins." From mikael at pobox.com Wed Jun 30 19:51:19 1999 From: mikael at pobox.com (Mikael Lyngvig) Date: Wed, 30 Jun 1999 23:51:19 GMT Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> Message-ID: <64F6457BE0585BB3.1CF2F67BC8A680BD.A19A9FEE23BC9E58@lp.airnews.net> On 26 Jun 1999 21:37:12 GMT, zeitlin at seth.lpthe.jussieu.fr (Vadim Zeitlin) wrote: > While I don't think wxPython can replace TkInter as a de-facto GUI standard >for Python I still think that it has several advantages compared to TkInter. >Instead of saying how much better, prettier, faster (this one has really made >me smile, BTW: I don't think wxWin is currently very fast, if it has been >cited as its advantage it must really mean that TkInter is extremely slow. Well, TkInter is extremely slow, but not because of the Python part. Even the Tk widget tour, included with Tk, is so slow that you almost think "Please, draw the next character - you can do it." whenever a window with some text needs to be redrawn. In contrast, the wxPython demo is so fast that you probably wouldn't realize it is implemented in Python, unless you're used to do GUI programming yourself. One important point is that I probably experience Tk(Inter) as slow because I'm used to Win32 desktops with very fast graphics hardware and no X/Windows style client/server architecture. I imagine that many X/Windows users experience Tk(Inter) as fast enough. >we're working on performance problems too...) - instead, I'd just like to say >that unlike probably any other GUI toolkit, wxWindows developers are >interested in making their toolkit useful to the Python community. I don't >speak only about Robin Dunn, of course, who developed wxPython, but about >"core" wxWindows developers as well. The wxWindows performance problems must be more of the "this could be done better" than "this has to be done better" nature. > TkInter has, for the moment, several advantages compared to wxWindows (it >would be nice if someone did the comparison of 2 toolkits - I'm afraid I don't >know TkInter well enough to do it), but we're working hard to change this and >I sincerely believe that wxWin will have all the features we still miss and >which are present in TkInter really soon (an advanced text widget and >integrated HTML viewer are in alpha and beta stage; image support in wxWin >already includes GIF/JPEG/PNG/BMP/XPM; multimedia classes are waiting to >be integrated in the main distribution; the grid control is being actively >worked on by several people right now). A very strong plus for wxWindows is that the Python API and the native C++ API are so close that it actually makes sense to use Python in the design and prototyping phase and then rewrite the Python code to C++, if you want to, when you've reached a stable design. Personally I feel that it makes most sense to retain TkInter as the de-facto GUI for Python - at least for a while yet. But, I don't think I will ever use TkInter for anything. (this is probably an argument for not having a de-facto standard GUI for Python) As my reply to Michael P. Reilly shows, I don't believe that TkInter can be boosted significantly unless a *lot* of energy is put into the task. I think it would be better to spend this energy on extending and enhancing wxWindows till it is ready to take over. P.S. No offense intended to TkInter users. This is just the way I see things. -- Mikael From s_hubbard at my-deja.com Tue Jun 15 07:18:20 1999 From: s_hubbard at my-deja.com (s_hubbard at my-deja.com) Date: Tue, 15 Jun 1999 11:18:20 GMT Subject: Python CGI on IIS Message-ID: <7k5cpn$jdk$1@nnrp1.deja.com> Hello and Help I'm writing CGI using Python rather than embedding python in ASP, and I need to know how and if I can read and write to the session object. Regards and Thanks in Advance Senior Developer Simon Hubbard Rapid Business Solutions Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From Tim.Peters at p98.f112.n480.z2.fidonet.org Tue Jun 29 03:56:56 1999 From: Tim.Peters at p98.f112.n480.z2.fidonet.org (Tim Peters) Date: Tue, 29 Jun 1999 08:56:56 +0100 Subject: total idiot question: +=, .=, etc... Message-ID: <00001594@bossar.com.pl> From: "Tim Peters" >>> class A(B): >>> def __init__(self, x, y, z): >>> B.__init__(self, x, y, z) [Greg Ewing] > I could live with having to explicitly name the > superclass, provided something checked that the > class I named was actually a direct base class > of the one where the method is defined. That > way things would be less likely to break > mysteriously when I rearrange the class > hierarchy. [Guido] > Oh, but that check *is* being made! (In fact this is the same check > that prevents "class methods" from working ;-) Nope, that's a different check. If C derives from B derives from A, this check allows either C.__init__ or B.__init__ to be called from A.__init__ with an instance of A. Greg wants B.__init__ to be OK here, but not C.__init__ (C is not a direct base class of the one (A) where the method (A.__init__) is defined). IOW, he wants a way to restrict __init__ calls to immediate bases of the class from which the __init__ is invoked, to e.g. prevent level-skipping under class rearrangement. I posted some ugly code to address that, but think it's really a job for a text editor and a pair of eyeballs . although-something-to-be-said-for-automating-the-eyeballs-ly y'rs - tim From news at dorb.com Mon Jun 21 15:57:58 1999 From: news at dorb.com (Darrell) Date: Mon, 21 Jun 1999 15:57:58 -0400 Subject: choosing random numbers with weights/probability? References: <929987267.6227@www.remarq.com> Message-ID: import time, whrandom list1 = [('one', 0.25), ('two', 0.25), ('three', 0.5)] def wc(list): from whrandom import uniform n = uniform(0, 1) for item, weight in list: if n < weight: break n = n - weight return item def wc_test1(list, cnt=100000): t1=time.time() hist={} for i in range(cnt): k=wc(list) if hist.has_key(k): hist[k]=hist[k]+1 else: hist[k]=1 print " Time: %.2f sec"%(time.time()-t1) return hist def popList(l): selList=[] for i in l: for v in range(i[1]): selList.append(i[0]) return selList list2=popList([('one',25),('two',50),('three',25)]) def wc_test2(list, cnt=100000): t1=time.time() hist={} list=popList([('one',25),('two',50),('three',25)]) for i in range(cnt): k=whrandom.choice(list) if hist.has_key(k): hist[k]=hist[k]+1 else: hist[k]=1 print " Time: %.2f sec"%(time.time()-t1) return hist wc_test1(list1) Time: 10.36 sec {'one': 25069, 'three': 50087, 'two': 24844} wc_test2(list2) Time: 4.52 sec {'one': 24964, 'two': 50278, 'three': 24758} Selecting from a list is faster. -- --Darrell From news at dorb.com Wed Jun 2 17:33:28 1999 From: news at dorb.com (Darrell) Date: Wed, 2 Jun 1999 17:33:28 -0400 Subject: Python 2.0 References: <11A17AA2B9EAD111BCEA00A0C9B4179301E10ED6@forest.origin.ea.com> Message-ID: Stidolph, David wrote in message news:11A17AA2B9EAD111BCEA00A0C9B4179301E10ED6 at forest.origin.ea.com... > >OK, I'll try to propose something constructive. Maybe we need an object > >protocol, that would enumerate > >all references held by an object ? Writing a portable GC would be then > much > >easier. > > Sounds good to me for debugging. A call that could return a list of > everything that holds a reference to an object - that would be cool! > This would be very useful. When I've needed this, I didn't want to see everything in the system. In an effort to avoid performance problems and major changes. Insert a soon to be designed trace object as a member of the instance you want to trace. It captures file/line number ... Haven't I seen this sort of thing here before ? For those times when you have no idea where to begin. sys.settrace could be used in some way to watch everything. Slowly yes. The output could be analyzed for cyclic references. Run this like a lint. Now that you've found the cycles could some code be auto generated to handle the clean up ? -- --Darrell From Robert.Meegan at wcom.com Fri Jun 4 12:57:38 1999 From: Robert.Meegan at wcom.com (Robert Meegan) Date: Fri, 4 Jun 1999 16:57:38 GMT Subject: "The Python Way" In-Reply-To: <14167.60002.783156.583193@anthem.cnri.reston.va.us> References: <14167.60002.783156.583193@anthem.cnri.reston.va.us> Message-ID: On Fri, 4 Jun 1999, Barry A. Warsaw wrote: [...] > > Way I see it, making the Timbot code Open Source is the only moral thing > to do. Besides, wouldn't it be cool to check out the Python > translation of the old Emacs Lisp RMS AI code? > Actually, he's just a version of ELIZA that's stuck in a particularly cranky loop. --- Robert -------------------------------- Robert Meegan MCIWorldCom - Cedar Rapids, Iowa 319.375.2416 From gvinther at atex.com Tue Jun 8 14:11:40 1999 From: gvinther at atex.com (Gordon Vinther) Date: Tue, 8 Jun 1999 14:11:40 -0400 Subject: Tkinter doesn't work with Tcl/Tk8.0.5 part 2 Message-ID: <928865476.429.20@news.remarQ.com> I forgot to mention that I rebuilt with Tcl7.6/Tk4.2 and everything is hunky dory. From tim_one at email.msn.com Sat Jun 26 13:48:27 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 26 Jun 1999 13:48:27 -0400 Subject: GC In Python: YAS (Yet Another Summary) In-Reply-To: <3773EFF7.27D29899@bioreason.com> Message-ID: <000301bebffc$184fcf60$da9e2299@tim> [Andrew Dalke, worries about Boehm collection vs Fortran] > The latter. Example object creation code might look like: > > dt_Handle mol = dt_smilin("CCC", 3); > > where dt_Handle is a typedef to unsigned long. In the SWIGged > wrapped version, this is mol = dt_smilin("CCC"). > > Yes, the library has a pointer table to the object. The problem > I see is, how does the Boehm collector (or other GC) know what to > collect from this vendor library? I can't see how, given that > my Python code stores it as an integer. > > That's why I don't see how you say "It fully supports C and C++" > when this is a package which doesn't do "pointer XORing or other > crimes" but cannot be usable with a GC w/o modifications. > > But then, I'm a computational biophysicist by training and don't > know much about GC other than the general concepts. One of the > references on the SGI page says Boehm can be used in "uncooperative > environments" so I'll end by saying that I don't know enough. You know enough to say this: no matter *what* Fortran throws at it, Python's current flavor of GC won't have a problem with it <0.5 wink>. The BDW collector is a truly wonderful example of the GC art, and can perform seeming miracles in hostile environments. But you can't know whether it will work * a priori*. It needs to take over all dynamic allocation (typically "malloc" in C, but your platform's Fortran may not use that), understand everything about how your platform's compilers and runtime systems use the machine stack and registers, and implicitly relies on the compiler not generating "confusing" code (pointer xor'ing is something compiler-generated code probably never does, but aggressively optimizing compilers can & do perform transformations equally as confusing to BDW; Boehm wrote a paper about that, so I'll skip it ). All of those caveats have to do with BDW being able to find every bit-pattern that *may* be a live pointer. It typically doesn't know ints from doubles from real pointers, and doesn't care: if a string of bits "looks like" a heap address, it's treated as one. This makes it err on the side of safety, but all assuming that all live pointers are found in their natural form in the places it knows where to look. Despite all that, it would probably work fine for you. I think it's a dead issue here regardless, though, because Guido isn't going to tell anyone they have to use a particular routine for memory allocation. Python could use its own malloc for its own objects (& Vladimir Marangozov has written a very nice PyMalloc, available from his Starship page), but that breaks down as soon as any extension has its own view of how to get memory. can't-chase-what-you-can't-see-ly y'rs - tim From hinsen at cnrs-orleans.fr Mon Jun 7 04:43:35 1999 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 07 Jun 1999 10:43:35 +0200 Subject: Cannot store Sequences in Numeric arrays of Objects References: <375453CE.3192@cs.bham.ac.uk> Message-ID: Stuart I Reynolds writes: > >>>#Cannot store an array > >>> a[0,0] = b > Traceback (innermost last): > File "", line 1, in ? > ValueError: array too large for destination NumPy handles assignments from sequences to arrays correctly in the "standard" cases, but unfortunately this makes it difficult to assign sequences to individual elements of general object arrays (which aren't that well supported anyway). However, you can assign sequences to elements of one-dimensional arrays: >>> from Numeric import * >>> a = zeros((5,), PyObject) >>> a[0] = [1, 2, 3] >>> a[1] = ['a', ['b', 'c']] >>> a array([[1, 2, 3] , ['a', ['b', 'c']] , 0 , 0 , 0 ],'O') >>> a[2:4] = ['foo', 'bar'] >>> a[4] = array(3*[None], PyObject) >>> a array([[1, 2, 3] , ['a', ['b', 'c']] , foo , bar , [None None None ] ],'O') In your case, a[0][0] = b will do what you want. I don't know why assignment to higher-dimensional arrays fails, but I don't really want to figure it out either! -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From tre17 at cosc.canterbury.ac.nz Mon Jun 21 22:41:53 1999 From: tre17 at cosc.canterbury.ac.nz (Timothy R Evans) Date: 22 Jun 1999 14:41:53 +1200 Subject: tkMessageBox returns 'can't invoke "frame" command:' error References: <7kktvv$550$1@nnrp1.deja.com> Message-ID: The actuall error is caused by the Tk mainloop cannot be restarted, obviously Tkinter was never designed to support what you're doing here. The cause of your problem seems be partly that you actually expected this to work, putting lots of code in a module initialisation is not good style. If you post a description of what you are trying to do I can give you a correct and better style solution. -- Tim Evans From fatjim at home.com Thu Jun 3 13:37:12 1999 From: fatjim at home.com (Jim Meier) Date: Thu, 03 Jun 1999 17:37:12 GMT Subject: pyGTK on Windows References: <3757D453.A302E757@interar.com.ar> Message-ID: <3756BDC7.5382BE2@home.com> Nahuel wrote: > Hi, im about to do a cross-plataform GUI application in Linux and > Windoze... i must > choose the GUI toolkit.. my question is .. can i use pyGTK under > Windows??? > > (I need a gui that can display a table with about 4000 lines without > crashing (not like Tk :)) For now, GTK is strictly a unix toolkit. There are some ports to windows, but most require an X server. I did run across one that didn't require X, but I lost it's address. It was very alpha anyways. I don't know what your best bet is, but try searching deja.com for keys like "toolkit", "tkinter", "pyGTK" and "wxPython". That last one sounds like it might be your answer, but I've never tried it. -Jim From Richard.Jones at fulcrum.com.au Mon Jun 14 20:21:31 1999 From: Richard.Jones at fulcrum.com.au (Richard Jones) Date: Tue, 15 Jun 1999 10:21:31 +1000 Subject: python-1.5.2 Alpha Linux RPM? Message-ID: <199906150021.KAA04106@icarus.fulcrum.com.au> Does anyone know of the existence of an RPM of 1.5.2 for Alpha Linux? Thanks, Richard From aa8vb at yahoo.com Wed Jun 2 12:18:41 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Wed, 2 Jun 1999 12:18:41 -0400 Subject: A tkinter kick-off In-Reply-To: <37544a32.0@news1.mcmail.com>; from Mark Butterworth on Tue, Jun 01, 1999 at 09:58:01PM +0100 References: <37544a32.0@news1.mcmail.com> Message-ID: <19990602121841.A280136@epa.gov> Mark Butterworth: |I've been using python for a few months now (I've actually managed to |persuade my company that freeware is a viable tool) and I've just started |looking at tkinter. However, my first little project doesn't require an |interactive window or dialog box. What I do require is a window which |displays the result's of my background processing. The processing will |simply be the compression and network transfer of some files. I'm not |looking for a full solution however, I just need a help starting off. I can |create a window containing a listbox alright, I just need to know how to |process in the background and display results within the listbox (maybe a |cancel button would also be useful). | |Any help appreciated!?! For a recent project, I needed exactly what you describe. See the ShellWindow.py example in the Python dist. A little adaptation of this module was all that was needed. Randall From tim_one at email.msn.com Sun Jun 6 14:04:50 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 6 Jun 1999 14:04:50 -0400 Subject: Using CVS under Win95 In-Reply-To: Message-ID: <000001beb047$126c3300$579e2299@tim> [Emile van Sebille] > I've downloaded CVS and appear to have successfully compiled it using MS > C++5.0. Do yourself a favor and use Cyclic's precompiled Windows distribution. > I'm trying to access the python source per (session paste follows): > > D>cvs -d :pserver:pythoncvs at cvs.python.org:/projects/cvsroot login > (Logging in to pythoncvs at cvs.python.org) > CVS.EXE [login aborted]: could not find out home directory Ya, I vaguely remember this. Went away after setting a bunch of environment vrbls for CVS's benefit ... set HOMEDRIVE=d: set HOMEPATH=\hugga set CVSROOT=:local:d:\hugga Why on earth I installed it into d:\hugga will forever remain a mystery even to me, but having done so CVS wants to be told about it in multiple redundant ways . linux-isn't-nearly-as-much-fun-ly y'rs - tim From news at dorb.com Wed Jun 23 16:38:40 1999 From: news at dorb.com (Darrell) Date: Wed, 23 Jun 1999 16:38:40 -0400 Subject: How to obtain an instance's name at runtime? References: <7kqpu8$7u1$1@nnrp1.deja.com> Message-ID: Maybe I'm missing the point here. I use this approach which shows the class name and an address for the instance. That's about as good a name as I can imagine possible for that instance. Unless you start adding name attributes. >>> class A: ... pass ... >>> a=A() >>> str(a) '<__main__.A instance at 7f6350>' If you want to keep track of the name of the variable that your instance is contained within. Then I don't think this is possible because it would require that each instance keep a list of the variables that it was stored in. Even then you would be faced with a list instead of a single name. >>> str(b) '<__main__.A instance at 7f6350>' -- --Darrell From velzev at freemail.nl Tue Jun 15 07:43:49 1999 From: velzev at freemail.nl (Vivienne) Date: Tue, 15 Jun 1999 13:43:49 +0200 Subject: (wxPython) Double left clicking and right clicking with ListBoxes Message-ID: <7k5ec1$pl3$1@zonnetje.NL.net> Hi there, I've gotten into some trouble over making a selection in a listbox with a double-left click or a right-click. It doesn't work. At first I used the available EVT_LISTBOX_DCLICK(id, function). The problem here is that it forgets the selection that I made, and with event.GetSelection() always gives the index of the first item (i.e. 0). So I thought, OK, let's try it with EVT_COMMAND_LEFT_DCLICK(id, function). But now my application doesn't even respond to the fact that I'm double-clicking. The problem with right-clicking is twofold : 1. There is no available method for right-clicking in a listbox (that I could find) 2. The use of EVT_COMMAND_RIGHT_CLICK(id, function) gives the same result as EVT_COMMAND_LEFT_DCLICK(id, function) Could anyone please tell me how to use double-left clicking and right clicking in listboxes (or wxPython in general)? Thanks alot, Vivienne PS. I use Python 1.5.2 and wxPython 2_0b9. Here is the code I've written that doesn't work: def InitializeBox(self, ID, StartPoint, BoxSize): self.box = wxListBox(panel, ID, StartPoint, BoxSize, self.namenlijst, wxLB_SINGLE|wxLB_SORT) EVT_LISTBOX(panel,ID,self.OnLeftClick) EVT_COMMAND_LEFT_DCLICK(panel,ID,self.OnDLeftClick) EVT_COMMAND_RIGHT_CLICK(panel, ID, self.OnRightClick) def OnDLeftClick(self, event): p = event.GetSelection() print p From arcege at shore.net Wed Jun 30 10:07:14 1999 From: arcege at shore.net (Michael P. Reilly) Date: Wed, 30 Jun 1999 14:07:14 GMT Subject: PySequence_Check References: <000401bec2a4$3be15200$f39e2299@tim> Message-ID: Tim Peters wrote: : [Reuben Sumner] :> How can I do the equivalent of a PySequence_Check in Python? :> GvR told me that the question was illdefined (if I explained it correctly) :> and to ask here. It seems that some of the functions in abstract.h :> are available from python (len(), callable()) and others are not :> (PySequence_Check, PyNumber_Check). :> :> What am I missing? : For starters, unquestioning faith in Guido's pronouncements . :> I have a nested structure of lists and tuple and I just want to know :> when I have bottomed out. : Then why not check for that directly and be done with it? :> I can check for tuple or list indivually but that is ugly and :> inflexible. : Not to mention simple, obvious and unsurprising . :> I could just try indexing and see if there was an exception but that :> is not much better. : OK, you tell me: what *is* a sequence? Answer that, and you'll know how to : check for it <0.5 wink>. Before answering too fast, note that mapping types : can be indexed without raising an exception, and so can strings. Do you : want your nest of "lists and tuples" *not* to "bottom out" at a string? : Probably not -- but if so, you're not really interested in testing whether : it's a sequence! Note too that user-defined classes can support the : __getitem__ protocol without supporting the __getslice__ protocol, or vice : versa. Are either of those sequences, or do they need to support both? : Whichever way you answer, half the world will disagree. : I think that, in most cases, when people say "sequence": (A) it's : ill-defined ; and, (B) after five rounds of tedious questioning they : end up deciding they mean "responds to slicing but isn't a string". So : there you go: : def issequence(x): : try: : x[0:0] : except: : return 0 : return type(x) is not type("") My basis (in my own programming) has been: import types, UserList def issequence(x): return (isinstance(x, types.ListType) or isinstance(x, types.TupleType) or isinstance(x, UserList.UserList)) It is very restrictive in some cases, but if I want a user defined sequence, I usually _try_ to make one from UserList. -Arcege From a.mueller at icrf.icnet.uk Mon Jun 7 14:29:37 1999 From: a.mueller at icrf.icnet.uk (Arne Mueller) Date: Mon, 07 Jun 1999 19:29:37 +0100 Subject: waste of resources ? Message-ID: <375C0F91.1C73E4E3@icrf.icnet.uk> Hi All In my program I always get an OSError number 11 (Resource temporarely not available). It reads in lots of files using child processes communication with the parent. Each child also uses popen to get data from lauched 'gunzip' process. After ~1000 processed files the program raises OSError[11]. I'm pretty sure that all the child processes close their pipes to the parent and that popen is also closed. The parent stores the file descriptors connected to the children in a list but uses the lists 'remove' method to delete descriptors that are finished (those which the parent has already read from). However, I'd like to get sure that's not the number of used filedescriptors what's causing the error. How can I examine the cause of error, I mean is there a python method or a variable that tell you the number of currently used file descriptors or better that lists all the resources a program is using including it's children? Hm, maybe I'll have a hard night of debugging :-( thanks, Arne -- Arne Mueller Biomolecular Modelling Laboratory Imperial Cancer Research Fund 44 Lincoln's Inn Fields London WC2A 3PX, U.K. phone : +44-(0)171 2693405 | Fax : +44-(0)171 269 3258 email : a.mueller at icrf.icnet.uk | http://www.icnet.uk/bmm/ From cgw at fnal.gov Tue Jun 1 13:05:34 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Tue, 1 Jun 1999 17:05:34 GMT Subject: Looking for a lib fun In-Reply-To: <3753FDF4.5A13F8B8@zipzap.ch> References: <3753FDF4.5A13F8B8@zipzap.ch> Message-ID: <14164.4830.69989.763470@buffalo.fnal.gov> Boris Borcic writes: > There is a function I can't seem to find in the > standard library. One that will turn XML/HTML > offending characters to corresponding entity- or > character references. is cgi.escape() what you're looking for? From garry at sage.att.com Tue Jun 8 10:18:16 1999 From: garry at sage.att.com (Garrett G. Hodgson) Date: Tue, 8 Jun 1999 14:18:16 GMT Subject: Teaching python to beginners References: <7ipbca$4jh$2@news.islandnet.com> Message-ID: <375D2628.3B3BC188@sage.att.com> Deryk Barker wrote: > > Does anyone have any experience with teaching Python as a *first* > programming language. > > I'm looking into the feasbility of this and would like to discuss it > with anyone who has experience or thoughts in the area. i've used it to teach my 11 year old to program. python is just about ideal, in my estimation. we've just done some simple things, cataloguing her beanie baby collection in a flat file database. but she found it very easy to pick up. -- Garry Hodgson comes a time garry at sage.att.com when the blind man Software Innovation Services takes your hand, says, AT&T Labs "don't you see?" From marc at oscar.noc.cv.net Mon Jun 28 02:22:29 1999 From: marc at oscar.noc.cv.net (marc) Date: Mon, 28 Jun 1999 06:22:29 GMT Subject: Python for large projects? References: <3774b5d1.690922@news.force9.net> <87n1xm85mf.fsf@lisboa.i-did-not-set--mail-host-address--so-shoot-me> <3776EF65.A07CBEFC@compaq.com> Message-ID: In article <3776EF65.A07CBEFC at compaq.com>, Greg Ewing wrote: >Darrell wrote: >> >> I'll give that a look, but they can always get to it if they want. Maybe >> that's ok, just worries me. > >If you clearly warn them in the docs not to do >it, and they do it anyway and get into trouble, >it's not your fault. > >Greg But what does management think?? If the user screws something up how much down time/loss of data will result? I remember people coming back from desert storm and telling me about how people were playing with unexploded submunitions, aka small bombs with flaky fuses, I am not kidding on this. So the question is how much damage can an moron do with a screw driver to your program and is that an acceptable tradeoff for the benifits of python? If you are realy parinoid present it to your boss and ask him to decide. marc ps just because you are parinoid does not mean you are wrong. From andermoe at online.no Wed Jun 16 16:13:51 1999 From: andermoe at online.no (Anders Moe) Date: Wed, 16 Jun 1999 22:13:51 +0200 Subject: need exit from 'exec' execution Message-ID: <3768057F.D7473931@online.no> Hi all - My python-embedded app frequently makes use of 'exec '. I'd like to create a Tk Button to halt this execution at some point, with the option of aborting it. The only command that comes close is the exit statement, but its to powerful - it exits from the whole app, whereas I only wanted a local exit from the exec's program-string. Anyone know how to make this kind of local exit ? Thanks in advance, Anders Moe From greg.ewing at compaq.com Wed Jun 23 17:27:16 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Thu, 24 Jun 1999 09:27:16 +1200 Subject: total idiot question: +=, .=, etc... References: <877lov62z1.fsf@pbl.ddns.org> Message-ID: <37715134.399AFB2D@compaq.com> Bernhard Reiter wrote: > > += just saves some space and typing time. It's not quite as simple as that, because a[i] = a[i] + expr and a[i] += expr would be semantically different if the former did the index lookup only once. However, there are serious difficulties with trying to incorporate such semantics into Python's execution model, and the consensus among experienced Python implementation hackers seems to be that the results would be Not Worth The Bother (tm). Greg From arcege at shore.net Thu Jun 3 14:44:05 1999 From: arcege at shore.net (Michael P. Reilly) Date: Thu, 03 Jun 1999 18:44:05 GMT Subject: Alien whitespace eating nanovirus strikes again! References: <375500C9.742DC539@pop.vet.uu.nl> <375536C2.DD917F99@prescod.net> <19990602132331.A281155@epa.gov> Message-ID: Randall Hopper wrote: : Aahz Maruch: : |Paul Prescod wrote: : |> : |>...whitespace handling.... : | : |...this is one point that still annoys me. : | : |Oh, I've gotten used to it, no question about that, and I even : |appreciate the readability when it comes to working over someone else's : |code (which is what I've mostly been doing). But the whitespace problem : |is a real PITA when it comes time to make a change to the structure of a : |program -- it's an investment I don't mind making when I'm doing "real" : |programming, but when I'm making a bunch of quick, fiddly changes to : |debug something it continually gets in my way. : I actually have like Python's whitespace-as-syntax, but I can see your : perspective. : If I was still locked onto vi, it'd be a pain, and I can see that being an : issue with some editors. Though with emacs, there's rectangular kill : (^Xrk) and block indent/dedent (^X^I) -- key sequences I use without even : thinking anymore. I don't even see it as a problem in vi. There are pretty simple block operations (:'a,.s/^/ /) that make it easy enough (as easy as vi can be anyway). Given the problem of multiple coders and "proper whitespace" (insert your definition here), there is _usually_ going to be an indent/outdent problem, regardless of the language or the editor. -Arcege From mark.geib at echostar.com Mon Jun 7 12:22:05 1999 From: mark.geib at echostar.com (mark.geib at echostar.com) Date: Mon, 07 Jun 1999 16:22:05 GMT Subject: can't link with python libs Message-ID: <7jgrj2$rin$1@nnrp1.deja.com> I have installed python 1.5.2 on Redhat 5.2 Linux, both the python and python-dev RPMs. The problem is I am writting a C 'main' funtion to invoke python but cannot link the program because I have no libModules, libPython, etc. Is there another package I need to install or what...? THanks, Mark Geib Echostar Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From claird at Starbase.NeoSoft.COM Thu Jun 10 13:29:37 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 10 Jun 1999 12:29:37 -0500 Subject: Why is tcl broken? References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> Message-ID: <7josm1$bgc$1@Starbase.NeoSoft.COM> In article <375FDCA7.62FF at mailserver.hursley.ibm.com>, Paul Duffin wrote: . . . >Tcl has many OO features, you can have C++ like, Java like, SmallTalk >like ... it is up to you. A lot of them are implemented in pure Tcl. With new ones coming on line all the time: . > >> Has anyone messed with Guile, GNU's extension language? One specific >> thing they want to do is be a "universal" back end, that is you can write >> translators from language A to Guile, and their page[2] mentions Python >> several times... >> > >Nice idea but I doubt they will even manage one language completely, >never mind 2, or 3, or 4 ... Oh, it appears to be in use already. Skepticism about its larger ambitions, though, is widespread . I wish the Guile folk well, and certainly RSM and others continue to invest energy in it. From my distant ob- servation post, it doesn't feel as though it has the critical mass of resources necessary to "take off". I believe the time *is* ripe for deeper connections be- tween different languages. Perhaps what the original questioner was after was something like, "What are apt areas for Tcl, and how can other technologies exploit its strengths?" OK, that's too coy. I recognize that *I* wanted him to have asked that, but he definitely didn't do so. Like Paul, I find it hard to think of syntax and seman- tics which are bad in isolation from context. . . . -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From mikey1cal at aol.com Wed Jun 23 16:59:46 1999 From: mikey1cal at aol.com (Mike Callahan) Date: Wed, 23 Jun 1999 20:59:46 GMT Subject: newbie IDLE question Message-ID: <37714A8C.C6E581@aol.com> Where can I find documentation on IDLE? Also, is version 0.5 ready to be downloaded? What about any IDLE vs PTUI comparisons. Mike Callahan From vdkoijk at linux01.prc.tno.nl Wed Jun 16 08:36:12 1999 From: vdkoijk at linux01.prc.tno.nl (John van der Koijk) Date: 16 Jun 1999 14:36:12 +0200 Subject: DDE link memory leak? Message-ID: <87vhco726b.fsf@linux01.prc.tno.nl> Hi There, I'm using dde under PythonWin to control a data aquisition system known as Windmill (http://www.windmill.co.uk). This system contains a program called wmdde (DDE link) which provides an interface to the hardware via DDE (don't ask me why I use this). If one is very gentle with the DDE interface, it works. For a while. Then, it crashes. Interestingly, it is not possible to start new processes on the Windows machine after that happens: it complains that there is not enough memory available. I suspect that something is leaking memory. Being a Unix afficionado I was allready happy I got it to work in the first place, and I haven't got the foggiest about what to do now. For instance, I can kill PythonWin and all associated processes, and still have no memory left!? I can't even start a shell window. Windmill says: use Excell (or VB). It works fine for our customers. Well... I've also tried to use calldll, but the IMLKIT dll delivered by Windmill does not seem to work (16-bit?). Any pointers are appreciated, -- John van der Koijk. From " HPeter.Friedrichs" at alliedsignal.com Tue Jun 22 18:29:53 1999 From: " HPeter.Friedrichs" at alliedsignal.com (H. P. Friedrichs) Date: Tue, 22 Jun 1999 15:29:53 -0700 Subject: Newbie: How do you "clear" PythonWin between runs? Message-ID: <37700E61.5388E101@alliedsignal.com> I've just started playing with python, so all of this is very new to me. I have been writing some scripts, saving them to *.py files, and running them under PythonWin 1.5.2 . The process is iterative; I code, save, run, code, save, run, etc. What I have noticed is that python doesn't "reset" between runs. Sometimes error messages reappear even though I have fixed the problem, because some artifact of a previous run lingers. So, my question is this: How can I "flush" or "clear" the python interpreter between successive runs? Is there a command I can add to my script to initialize python before running the script? Thanks, Pete hpeter.friedrichs at alliedsignal.com -- ----------------------------------------------- | The opinions expressed here are my own, | | and not necessarily those of my employer. | ----------------------------------------------- From abrahams at mediaone.net Sun Jun 27 13:44:59 1999 From: abrahams at mediaone.net (Dave Abrahams) Date: Sun, 27 Jun 1999 13:44:59 -0400 Subject: Newbie: How do you "clear" PythonWin between runs? References: <37700E61.5388E101@alliedsignal.com> Message-ID: In article <37700E61.5388E101 at alliedsignal.com> , "H. P. Friedrichs" <" HPeter.Friedrichs"@alliedsignal.com> wrote: > So, my question is this: How can I "flush" or "clear" the python > interpreter between successive runs? Is there a command I can add to my > script to initialize python before running the script? I haven't tried it yet, but I've been thinking: # when you start up the IDE import sys modules = sys.modules.copy() # To "clear" the python interpreter sys.modules = modules.copy() Just might work, Dave From matomira at acm.org Mon Jun 14 11:41:30 1999 From: matomira at acm.org (Fernando D. Mato Mira) Date: Mon, 14 Jun 1999 17:41:30 +0200 Subject: broken (was: OO) References: <000a01beb5dc$5e88aa80$ae9e2299@tim> Message-ID: <376522AA.9BEE7E5E@acm.org> Tim Peters wrote: > OK! Now we know the answer Fernando is looking for: Tcl is fatally broken > because its syntax differs from Lisp's <0.9 wink>. Response to 0.1 non-wink: No! I wanted to know if there were any theoretical reasons for tcl-bashing (that some people bash it because it lacks data structures, I can understand, but there the pragmatic evaluation is not the same in different contexts). Of all the languages I know that I mentioned, the only one I can say is BAD is C++. And 200K lines plus a high personal cost entitle me to say it. In spite of that, the STL taught me a lot about how to program `ADT style'. However, I still don't know how useful that actually is when you have a language with type inference. But what I _do_ learned from that once you find out the proper way to write C++ is that static typing without inference is BROKEN BROKEN BROKEN (you really wear out your keyboard). Note that C++ could be fixed to use inference, but that won't save it (overloading, casts, you name it). -- Fernando D. Mato Mira Real-Time SW Eng & Networking Advanced Systems Engineering Division CSEM Jaquet-Droz 1 email: matomira AT acm DOT org CH-2007 Neuchatel tel: +41 (32) 720-5157 Switzerland FAX: +41 (32) 720-5720 www.csem.ch www.vrai.com ligwww.epfl.ch/matomira.html From aprasad at magix.com.sg Sun Jun 20 12:08:55 1999 From: aprasad at magix.com.sg (Ajith Prasad) Date: Mon, 21 Jun 1999 00:08:55 +0800 Subject: DATE ARITHMETIC References: <7kejrv$e57$1@violet.singnet.com.sg> <376C08D8.A9032304@callware.com> Message-ID: <7kj3jv$ssu$1@coco.singnet.com.sg> Noted and thanks for all the feedback. The difficulty I had with the mxDateTime module was that results seem to be expressed as date time objects with timestamps embedded with dates and, given my limited knowledge of Python (just a few chapters into "Learning Python") I have no clue as to how to extract just the dates out. But I am sure that mxDateTime has all the functionality that justifies further investment in learning it. In response to my posting, Tim Peters and Jeff Bauer have pointed out simpler date-time routines that could be used. Tim's routines (available together with the Python source code disribution) use the American-style "month-day-year" format while Jeff's use the less ambiguous "year-month-date" format which also happens to be the format in which my date data are in. Jeff's notes at http://starship.python.net/crew/jbauer/normaldate/ make some useful points on the need for simple routines which handle the more common date arithmetic tasks without the added complications of dealing with specific calendars, time zones, etc. Both Tim's and Jeff's routines are geared towards this. I will look at the further references that Ivan has suggested for a deeper understanding of the issues. Ivan Van Laningham wrote in message news:376C08D8.A9032304 at callware.com... > Hi All-- > > Ajith Prasad wrote: > > > > I need to do some simple date arithmetic - finding the number of days > > between any 2 days, the age of a person on a day given his birthday. The > > mxDateTime module downloadable from the Python website is more complex than > > what I need. Any other suggestions? > > No. Date arithmetic is by nature non-trivial. Marc-Andre's mxDateTime > is perfectly suited for your application. > > If you *really* *really* don't want to use it, though, look up "Julian > Date" and Scaliger (Joseph Justus) on the web. Learn how to reduce > Gregorian dates to Julian Period dates, and once you do that you can add > and subtract dates as if they have just become big numbers. > > Which they will have done, assuming you follow up on Julian Period > dates. > > <8-K'an-12-Sotz'>-ly y'rs, > Ivan > ---------------------------------------------- > Ivan Van Laningham > Callware Technologies, Inc. > From pharaoh at novagate.com Fri Jun 11 15:14:56 1999 From: pharaoh at novagate.com (Douglas Nichols) Date: 11 Jun 1999 19:14:56 GMT Subject: gadfly install problem Message-ID: <7jrn7g$n2f$0@205.138.136.179> I am trying to install gadfly for use on my mac with python 1.5.1 The installation seems to have worked. When I try to test gadfly by creating a new database, I get the following error message: Python 1.5.1 (#37, Apr 27 1998, 13:36:04) [CW PPC w/GUSI w/MSL] Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import gadfly >>> connection = gadfly.gadfly() >>> connection.startup("testbase", "testfolder") >>> cursor = connection.cursor() >>> cursor.execute("create table ph (nm varchar, ph varchar)") shift: no mem in addchild Traceback (innermost last): File "", line 1, in ? File "Macintosh HD:Development:Python 1.5.1:Lib:lib-gadfly:gadfly.py", line 320, in execute from sqlsem import Parse_Context MemoryError >>> Any suggestions? I am very new to python and am still working my way through the Learning Python book. Thanks, Doug Nichols pharaoh at novagate.com http://www.ottawahumane.org From mark at chem.uwa.edu.au Sun Jun 6 21:44:28 1999 From: mark at chem.uwa.edu.au (Mark C Favas) Date: 7 Jun 99 01:44:28 GMT Subject: intractable(?) Tkinter scrollbar problem References: <19990601001054.36247@nms.otc.com.au> Message-ID: Dieter Maurer writes: >Greg McFarlane writes on Mon, 31 May 1999 14:10:54 GMT: >> I include a Tkinter script below, modified from one by Mark C Favas, >> using, I believe, Fredrik Lundh's AutoScrollbar class. When this >> script is run, the two scrollbars continuously get mapped and unmapped >> and the window continuously changes size. >I think, I now understand the instability and I should have >a solution. ...... >class AutoScrollbar(Tkinter.Scrollbar): > _active= 0 > def set(self, lo, hi): > self.lo= lo; self.hi= hi > #if self._active: print 'active'; return > self._active= 1; self.update_idletasks(); self._active= 0 > self._set() > # > def _set(self): > lo= self.lo; hi= self.hi > #print self.id, lo, hi > if float(lo) <= 0.0 and float(hi) >= 1.0: > self.tk.call("grid", "remove", self) > else: > self.grid() > Tkinter.Scrollbar.set(self, lo, hi) Thanks for your interesting explanation, Dieter. Interestingly, your fix as posted, works, even though the test for self._active is commented out (it also works if the test is uncommented). So, I tried the following, which also works. The key is saving and restoring the values of lo and hi around the call to self.update_idletasks()... class AutoScrollbar(Tkinter.Scrollbar): def set(self, lo, hi): self.lo = lo self.hi = hi self.update_idletasks() lo = self.lo hi = self.hi if float(lo) <= 0.0 and float(hi) >= 1.0: self.tk.call("grid", "remove", self) else: self.grid() Tkinter.Scrollbar.set(self, lo, hi) -- Email - mark at chem.uwa.edu.au ,-_|\ Mark C Favas Phone - +61 9 380 3482 / \ Department of Chemistry Fax - +61 9 380 1005 ---> *_,-._/ The University of Western Australia v Nedlands Loc - 31.97 S, 115.81 E Western Australia 6009 From fredrik at pythonware.com Thu Jun 3 14:39:57 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 3 Jun 1999 18:39:57 GMT Subject: [tkinter] two questions regarding Canvas References: <3752a555@nntp.server.uni-frankfurt.de> <37556602.415AFA46@ingr.com> <19990604005922.07590@nms.otc.com.au> Message-ID: <02fb01beadf0$b358f360$f29b12c2@pythonware.com> Greg McFarlane wrote: > This is small attempt at adding editing bindings to canvas text items. > This *must* have been done before, but a search of comp.lang.tcl did > not come up with anything, except a mention of pg_access in postgresql > which I could not find. Does anyone know of it? http://www.pythonware.com/people/fredrik/fyi/fyi52.htm From greg.ewing at compaq.com Wed Jun 23 20:04:16 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Thu, 24 Jun 1999 12:04:16 +1200 Subject: Windows - Drag & drop on Python script? Message-ID: <37717600.D076BF10@compaq.com> How can I create an icon onto which I can drop a file, and have it run a Python script with the dropped file as an argument? I've tried myriad combinations of .bat files, shortcuts, etc., but nothing seems to work. The obvious thing would seem to be to use a .bat file, but the dropped file seems to end up as the standard input or something, rather than getting passed as an argument. There *must* be a way of doing this, surely? Thanks for any help, Greg From mkersey at metricom.com Fri Jun 11 21:49:22 1999 From: mkersey at metricom.com (Michael Kersey) Date: Fri, 11 Jun 1999 20:49:22 -0500 Subject: Any Production ZOPE sites we can visit? References: <37614A32.79FE554E@metricom.com> <7jrou7$p42$1@news.clarkson.edu> Message-ID: <3761BCA2.29AC4F2E@metricom.com> It may not be exciting to you, but to me this site is an eye-opener! Bravo to it's developers. Especially nice depiction/presentation of regions versus counties and the handy use of mapping/graphics capabilities throughout. Your ties into http://tiger.census.gov/ are extremely sharp and well-done, IMO. When you say "airport lookups", what do you mean? Is part of the search done with Zope per se, and another part passed to an external database? For instance AFAI can tell, the URL http://www.air.gen.ny.us/Airports/AirportInfo?identifier=NY54 may be (I'm guessing) handled by Zope's own object-oriented database and DTML, while the URL http://www.airnav.com/cgi-bin/airport-info?N66 may be handled by significantly different code (not DTML) executing SQL queries? BTW, having worked with it for years, I have a hard time finding anything exciting about SQL!-)) TIA, Michael Kersey Brad Clements wrote: > http://www.air.gen.ny.us > Nothing exciting there really, except that the airport lookups are done > through an SQL query.. > I'm working on an events Calendar, that'll really look nice when it's done From claird at Starbase.NeoSoft.COM Wed Jun 16 21:21:31 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 16 Jun 1999 20:21:31 -0500 Subject: Why is tcl broken? References: <1283099377-77267484@hypernet.com> <37628EBF.207F7A8F@iname.com> Message-ID: <7k9iir$8uq$1@Starbase.NeoSoft.COM> In article , David Thornley wrote: . . . >I know little of this Qt animal. Is it free? Is it open source? >Does it run on the Macintosh? Is it easy to set up an interface with? . . . Qt comes in a handful of flavors. Some are free of charge. There's an open-sourced work-alike. None of these run under MacOS, to the best of my knowledge. I'm collecting information about them at -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From ivanlan at callware.com Mon Jun 14 10:49:14 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Mon, 14 Jun 1999 14:49:14 GMT Subject: Broken 1.5.2 installation? Missing cw3215mt.dll References: <1282960807-85602620@hypernet.com> Message-ID: <3765166A.D4351063@callware.com> Hi All-- Gordon ``Cannibal'' McMillan wrote: > > Ivan Van Laningham wrote: > > > ... I've also installed Python/Tcl on my three Linux > > machines--RH5.2 and RH6.0-SMP--but I didn't have to fiddle with > > anything at all in order to get IDLE to run just fine. Of course, > > Python and Tcl etc. have been in my path permanently for a long time > > on Linux;-) > > [double snort] > > A few months ago you were running some auto-port from a PDP-8. Did > RH finally convince you no warm-blooded animals were used in user > testing? > The closest I ever got to a PDP-8 was a MicroVax. Disgusting box. As my mother-in-law says, ``Oh wonderful. Everything I hate most in one sandwich!'' And I understood that RH only uses poikilothermic cannibals in their testing. -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From cgw at fnal.gov Wed Jun 30 14:52:15 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Wed, 30 Jun 1999 18:52:15 GMT Subject: socket timeouts In-Reply-To: References: Message-ID: <14202.26463.616657.95654@buffalo.fnal.gov> Nathan Clegg writes: > Is there any way to set the timeout for a TCP/IP connection? > Specifically, I'm writing some apps meant to run on the same machine, so > if they can't connect *immediately* (i.e. the server app is not running), I > need to go to plan B. What type of platform are you running on? On my Linux 2.2.10 box, a "connect" to a port on the local host with no server app fails immediately with a "connection refused". From fredrik at pythonware.com Wed Jun 30 04:09:30 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 30 Jun 1999 08:09:30 GMT Subject: PySequence_Check References: Message-ID: <00f501bec2cf$e22f1db0$f29b12c2@secret.pythonware.com> Reuben Sumner wrote: > How can I do the equivalent of a PySequence_Check in Python? > GvR told me that the question was illdefined (if I explained it correctly) > and to ask here. It seems that some of the functions in abstract.h > are available from python (len(), callable()) and others are not > (PySequence_Check, PyNumber_Check). import operator operator.isSequenceType operator.isNumberType operator.isMappingType not documented, and should probably be considered as deprecated (see replies from Paul and Tim for some back- ground). > What am I missing? I have a nested structure of lists and tuple and I > just want to know when I have bottomed out. I can check for tuple or > list indivually but that is ugly and inflexible. > I could just try indexing and see if there was an exception but > that is not much better. given that Python has no support for declared inter- faces, that's a reasonable approach. works just fine, and adds no extra overhead. on the other hand, it doesn't work if you have strings in there. but that's true for most other approaches as well: >>> operator.isSequenceType("spam") 1 >>> operator.isSequenceType("spam"[0]) 1 >>> operator.isSequenceType("spam"[0][0]) 1 >>> operator.isSequenceType("spam"[0][0][0]) 1 >>> operator.isSequenceType("spam"[0][0][0][0]) 1 >>> operator.isSequenceType("spam"[0][0][0][0][0]) 1 From Andrew_Tanner at mw.3com.com Wed Jun 23 12:07:12 1999 From: Andrew_Tanner at mw.3com.com (Andrew Tanner) Date: Wed, 23 Jun 1999 11:07:12 -0500 Subject: Freeze size Question Message-ID: <86256799.0058B93D.00@mwgate02.mw.3com.com> When I compiled hello.py using freeze.py on my Solaris 2.6 machine it came out being 1.5 megs! I then used strip to remove all of the symbols and it came to about 511k which seems a bit more reasonable. Doesn't 1 megabyte of symbol information seems a bit excessive? And compiling with out the '-g' switch only cuts around 50k off the binary. I'm trying to make the smallest, tightest, easiest binary to distribute, is there anyway I can poke or prod freeze.py to succumb to my wishes? Thanks, Andrew. From larsga at ifi.uio.no Tue Jun 29 13:02:42 1999 From: larsga at ifi.uio.no (Lars Marius Garshol) Date: 29 Jun 1999 19:02:42 +0200 Subject: Why is tcl broken? References: <1283099377-77267484@hypernet.com> <7laoq0$bvh$1@Starbase.NeoSoft.COM> <7laqeb$e17$1@Starbase.NeoSoft.COM> Message-ID: * Cameron Laird | | As it happens, there's very good work going on just now to beef up | Tcl's introspective capabilities. Is *that*-- introspection--the | real content of your preference? I don't know exactly what Marco had in mind, but this is certainly not the main value of the Common Lisp macro facility. The main value lies in being able to extend the language seamlessly with no run-time costs. Things like the while loop (which does not exist in CL), the Common Lisp Object System and programming by contract features can be built on top of the Lisp core using nothing but CL primitives. Personally, I dream of finding the time to toy with Aspect-Oriented programming in CL through extension macros. I know tcl has a similar capability, but I'm unsure whether it is of comparable power and convenience. [From your first posting in this sub-thread] | Are you making a semantic point, or arguing on the basis of | implementation-specific performance? Is there more than one implementation of tcl? If so, does any of them do macro expansions at compile-time? If not, I think arguments based on performance also carry considerable weight. I doubt that you would disagree that C++ has better performance than does tcl. Given than CL achieves comparable performance to C++ a conclusion seems near at hand. :) (BTW, I don't know if you're aware of this, but Dylan, which you wrote an excellent article on[1] is essentially Common Lisp bereft of one of its major features, the S-expression syntax.) | Incidentally, many of the same ideas and possibilities are available | to Python, although I don't know of anyone actively pursuing them | for Python. Actually, macros, performance and S-expressions are among the things I miss the most in Python. bytecodehacks, although certainly cool, are just a pale shadow of what CL macros provide. As for introspection, Common Lisp has good support for that as well, although I very much doubt that that was Marco's point. | [...] I occasionally argue that 'twould be worth the effort to do | introspection for Python in a more unified way. 'twould indeed, but I find other issues more pressing. --Lars M. [1] From claird at Starbase.NeoSoft.COM Wed Jun 2 07:17:01 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 2 Jun 1999 06:17:01 -0500 Subject: A tkinter kick-off References: <37544a32.0@news1.mcmail.com> Message-ID: <7j33re$ip0$1@Starbase.NeoSoft.COM> In article <37544a32.0 at news1.mcmail.com>, Mark Butterworth wrote: >I've been using python for a few months now (I've actually managed to >persuade my company that freeware is a viable tool) and I've just started >looking at tkinter. However, my first little project doesn't require an >interactive window or dialog box. What I do require is a window which >displays the result's of my background processing. The processing will >simply be the compression and network transfer of some files. I'm not >looking for a full solution however, I just need a help starting off. I can >create a window containing a listbox alright, I just need to know how to >process in the background and display results within the listbox (maybe a >cancel button would also be useful). . . . hints at what you're after. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From l11403 at alunos.uevora.pt Tue Jun 22 12:45:19 1999 From: l11403 at alunos.uevora.pt (Jose Saias) Date: Tue, 22 Jun 1999 17:45:19 +0100 Subject: Python scope and parameter passing method Message-ID: Hy I'm a portuguese student and I am comparing Python to Objective C. Can some one help me in this? I would like to ask you about Python: - the parameter-passing methods (call-by name/value/reference); - dynamic memory control (garbage collection?, allocation for activation records); - the scope of a name (lexical/dynamic); - innermost or outermost evaluation; - a small example program that explores the language possibilities. I appreciate your help! Jose Saias From donn at u.washington.edu Fri Jun 11 18:20:14 1999 From: donn at u.washington.edu (Donn Cave) Date: 11 Jun 1999 22:20:14 GMT Subject: ^C and os.system() References: Message-ID: <7js22u$r7e$1@nntp6.u.washington.edu> Douglas Alan writes: | Greetings. Is it considered a bug or a feature that if I type ^C at a | Python program that is in the middle of executing a call to | os.system(), the Python program never seems to see the SIGINT signal? | Instead, only the process created by os.system() receives the signal. | Consequently, if I have a Python script that executes a program | repeatedly for a list of files, for instance, I can't kill the Python | script with ^C. It's neither bug nor feature, it's just the implementation of the C system() function. In the NetBSD source, I see system() ignores SIGINT and SIGQUIT in the parent fork while calling waitpid(), and I imagine Solaris 2.6 may do something similar. Can't explain why. | Also, when I have the Python program check the return status of a | command invoked via os.system() and subsequently killed with ^C, | instead of getting back 0x0002, as would be expected from a process | killed by SIGINT, I usually get back 0x8200. Sometimes I get back | 0xd000. Only infrequently do I get back the 0x0002 that I would | expect. Now that looks like a bug in the Solaris 2.6 system(). I don't get this effect on Digital UNIX, for example. You might try a little C program, it should look the same as Python. | None of these problems occur if I use commands.getstatusoutput() | instead of os.system(), so I guess I will stick with getstatusoutput() | for the time being. Uses popen(), which doesn't have the same signal handling. You can also roll your own system() with fork() and exec*(). Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From WESTER at ilt.fhg.de Wed Jun 2 04:37:27 1999 From: WESTER at ilt.fhg.de (Rolf Wester) Date: Wed, 02 Jun 1999 10:37:27 +0200 Subject: Posix: Exec format error Message-ID: <3754ED47.54C2F0AF@ilt.fhg.de> Hi, when doing the following: import os id=os.fork() if id == 0: os.execl("/home/wester/test/test","-d", "indata") else: os.wait() I get the error message: OSError: [Errno 8] Exec format error Can aybody tell me how the format should look like? Thanks in advance Rolf From befletch at my-deja.com Sat Jun 26 01:53:53 1999 From: befletch at my-deja.com (Bruce Fletcher) Date: Sat, 26 Jun 1999 05:53:53 GMT Subject: Python socket performance testing Message-ID: <7l1ptf$ov9$1@nnrp1.deja.com> I have Python 1.5.1 on a Mac (G3/233) and a Linux box (Celeron/366). These are connected by 10BT ethernet, and I get good speed with normal HTTP and FTP clients/servers. Curiously, I can't seem to get good speed (yet) in transfering data from Python to Python on the two machines. Here's some excerpts from my client/server code: #client: (Mac) data = 'a' * 1024 sock = socket( AF_INET, SOCK_STREAM ) sock.connect( SERVER, DATA_PORT ) loops = 1024 t1 = time.clock() while loops > 0: sock.send( data ) loops = loops - 1 reply = sock.recv(128) t2 = time.clock() sock.close() print 'Test time:', t2 - t1, 'seconds.' #server: (Linux) sock = socket( AF_INET, SOCK_STREAM ) sock.bind( '', DATA_PORT ) sock.listen(1) conn, addr = sock.accept() loops = 1024 while loops > 0: data = conn.recv(1024) loops = loops - 1 conn.send('ok') conn.close() This 1 meg transfer takes 73 seconds! That works out to 14 kb/sec or so, which isn't exactly blinding. Am I doing something silly in my test? I suppose I should go test this just on the Linux box, just on the Mac, etc. but I'm not too confident in my Python code yet so I thought I'd ask for pointers. Something else interesting; time.clock() doesn't seem to work on Linux (RedHat 6.0) in either 1.5.1 or 1.5.2. The time is always < 1, and it doesn't change. Thanks, - Bruce Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From holger at phoenix-edv.netzservice.de Wed Jun 9 08:27:58 1999 From: holger at phoenix-edv.netzservice.de (Holger Jannsen) Date: Wed, 9 Jun 1999 12:27:58 GMT Subject: os.mkdir() Message-ID: <375E5DCE.7005D71A@phoenix-edv.netzservice.de> Hello again, I couldn't find a resolution in helpfiles, so please give a hint to my (easy to solve!?) question: I'd like to create directories under WinNT. There is already a file with the same name as the directory I want to create. Look: >>>os.mkdir("c:\\blabla") OSError: [Errno 17] File exists: 'C:\\blabla' or >>>os.makedirs("c:\blabla\nana\gugu") produces OSError: [Errno 2] No such file or directory: 'c:\blabla\nana' Don't know if python doing the same under linux, but I need to solve the problem for every OS! I think, there must be an easy solution?! Ciao, Holger From cmedcoff at my-deja.com Sat Jun 5 19:57:34 1999 From: cmedcoff at my-deja.com (cmedcoff at my-deja.com) Date: Sat, 05 Jun 1999 23:57:34 GMT Subject: Looking for for some ideas for argument processing Message-ID: <7jcdhc$htd$1@nnrp1.deja.com> I'm writing a script with is going to make heavy use of script arguments. I'd like to hear some ideas on some ways to support this. One idea I've had so far is to write a class which is a dictionary of "directives" to function objects, where a "directive" might be '- c', '/f', or whatever. This seems to work well if all arguments are of this simple form. However I would also like to support arguments like "python myscript.py /a /f /x "bip" "bop", /g"; the point here being that "directives" may take arguments. This kind of messes up the simple loop you'd otherwise use to process arguments. a = BuildArgumentProcessor() # process arguments for x in sys.argv[1:]: opt = x[1:2] optArg = x[2:] a.Process(opt, optArg) This would work if somehow inside the for loop one could "increment this list iterator more that once" (sorry I'm coming from a C++ background). I don't see anyway of doing this. Is it possible? Any other ideas? Regards, Chuck Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From hs at inferno.nirvananet Fri Jun 11 18:52:02 1999 From: hs at inferno.nirvananet (Hartmann Schaffer) Date: Fri, 11 Jun 1999 22:52:02 GMT Subject: Why is tcl broken? References: <375F82C7.CF0F0477@iname.com> <375FF969.C879B4CD@iname.com> <37601668.D9105225@mayo.edu> <3760E130.7456447@iname.com> <3760FA1F.7BCD@mailserver.hursley.ibm.com> Message-ID: In article <3760FA1F.7BCD at mailserver.hursley.ibm.com>, Paul Duffin writes: > ... > "Call by name" has some very particular characteristics the main one > being that you cannot implement "swap". I can assure you that you can This is news to me. Afair, "call-by-name" was the term for the Algol60 style parameter mechanism, which essentially required each argument passed by a parameterless function returning a pointer to the passed value. Parameter swapping (and a few pretty usually pointless tricks like "Jensen's device"(?)) were quite possible. > ... Hartmann Schaffer From andermoe at online.no Wed Jun 16 15:59:54 1999 From: andermoe at online.no (Anders Moe) Date: Wed, 16 Jun 1999 21:59:54 +0200 Subject: Raw Strings! References: Message-ID: <37680239.DFDBB6B1@online.no> SunitJoshi wrote: > Hi All > If someone could show me how to use raw-strings with variables, I > would really appreciate it. > For e.g.: if str_path = "C:\\windows\\temp" > > thanks > Sunit Since I suspect you have path-strings like the above in mind, may I suggest simply using forward slashes - they will work on win98. Else I recommend using 'os.sep'. Anders Moe From perry at ac-copy.net Tue Jun 8 02:44:25 1999 From: perry at ac-copy.net (Joachim Schmitz) Date: Tue, 8 Jun 1999 06:44:25 GMT Subject: mxODBC and MySQL In-Reply-To: <375C35A0.7754C3BD@lemburg.com> References: <375C35A0.7754C3BD@lemburg.com> Message-ID: I ugraded to 1.5.2 now I get: Python 1.5.2 (#1, Jun 8 1999, 07:26:20) [GCC egcs-2.91.66 19990314 (egcs-1.1.2 on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import ODBC.MySQL Traceback (innermost last): File "", line 1, in ? File "/usr/local/lib/python1.5/ODBC/MySQL/__init__.py", line 7, in ? from mxODBC import * ImportError: /usr/local/lib/python1.5/ODBC/MySQL/mxODBC.so: undefined symbol: SQLTables regards Joachim Schmitz On Mon, 7 Jun 1999, M.-A. Lemburg wrote: > Joachim Schmitz wrote: > > > > Hi, > > > > I compiled and installed mxODBC for MySQL on SuSE 6.1 without problems. > > I get this: > > Python 1.5.2b2 (#6, Feb 28 1999, 21:41:19) [GCC egcs-2.91.60 19981201 > > (egcs-1.1 > > .1 on linux2 > > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > > >>> import ODBC.MySQL > > Traceback (innermost last): > > File "", line 1, in ? > > File "/usr/local/lib/python1.5/ODBC/MySQL/__init__.py", line 7, in ? > > from mxODBC import * > > ImportError: /usr/local/lib/python1.5/ODBC/MySQL/mxODBC.so: undefined > > symbol: PyBuffer_Type > > >> > > You can either upgrade to 1.5.2 final or turn off the buffer > type code in mxODBC.c manually (enclosed in HAVE_PYTHON_BUFFEROBJECTS > #defines). I guess you stumbled into test code that I forgot to remove > for the distribution; sorry. > ------------------------------------------------------------------------------ P R O F I . N E T A G * Joachim Schmitz * Senior Network Consultant ------------------------------------------------------------------------------ profi.net | Aindlinger Str. 7 | Voice +49 821 27062-0 Hassler & Mair AG | 86167 Augsburg | Fax +49 821 27062-99 | Germany | Email js at profi.net From aahz at netcom.com Tue Jun 8 18:43:39 1999 From: aahz at netcom.com (Aahz Maruch) Date: Tue, 8 Jun 1999 22:43:39 GMT Subject: dict vs kjBuckets vs ??? Message-ID: I'm currently using a dict for storing references to objects (call them customer objects, referenced by customer ID (a number)). I'm using a dict (instead of SQL or something similar) because we're willing to trade lots of memory to get speed. However, I've heard that after about 10K items in a dict, it starts having problems. Is this a specious rumor, should I switch to kjBuckets, or should I do something else? Does the answer change if we have 100K objects? A million? (The only operations are object insert, update, delete, and lookup.) -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het "I'm not tense, i'm just terribly, terribly alert" -- unknown From larsga at ifi.uio.no Wed Jun 16 13:50:36 1999 From: larsga at ifi.uio.no (Lars Marius Garshol) Date: 16 Jun 1999 19:50:36 +0200 Subject: GC In Python: YAS (Yet Another Summary) References: <1282571877-108998356@hypernet.com> Message-ID: * news at dorb.com | | At the risk of sounding like a lazy whiner. This would be more | useful if it could run more like profile or pdb. Hmmm. This sounds like a useful alternative to the current mode of operation. | Having to add calls like "r.add_object(non_GCed_object)" make it | less useful. For some uses, perhaps. I can probably still think of cases where the original behaviour is wanted, but the idea is a good one. The reason I didn't do it was simply that I wasn't sufficiently ambitious. :) | Is there a way to capture the creation of any instance and call | r.add_object? A little experimentation lead to a trace function that worked. And since it was so cool I just went ahead and added it to plumbo. | In perfect world for lazy whiners this works, plumbo.run("myStuff") | and it gives me a report. This may be a perfect world for lazy whiners after all. :) Check the web site again for a function that has a lazy mode. It doesn't print anything unless there actually is a cycle, but other than that it should make you happy. --Lars M. From gerrit.holl at pobox.com Tue Jun 22 09:44:05 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Tue, 22 Jun 1999 15:44:05 +0200 Subject: Check for valid date In-Reply-To: <376F7C8A.A809C0A@zxa.basf-ag.de>; from Paolo G. Cantore on Tue, Jun 22, 1999 at 02:07:38PM +0200 References: <7klq51$etp$1@nnrp1.deja.com> <376F7C8A.A809C0A@zxa.basf-ag.de> Message-ID: <19990622154405.B19393@optiplex.palga.uucp> On Tue, Jun 22, 1999 at 02:07:38PM +0200, Paolo G. Cantore wrote: > From: "Paolo G. Cantore" > Newsgroups: comp.lang.python > Subject: Re: Check for valid date > Date: Tue, 22 Jun 1999 14:07:38 +0200 > To: python-list at python.org > > Hi Remi, > > I use a two-step procedure: > > >>>def check_date(year, month, day): > ... tup1 = (year, month, day, 0,0,0,0,0,0) > ... try: > ... date = time.mktime (tup1) > ... tup2 = time.localtime (date) > ... if tup1[:2] != tup2[:2]: > ... return "Date not valid." > ... else: > ... return "Date valid." > ... except OverflowError: > ... return "Date not valid." > ... > >>> import time > >>> print date_valid(1999,2,29) > Date not valid. > >>> print date_valid(1999,2,28) > Date valid. > I would return 0 or 1, instead of what you're doing. groeten, Gerrit. -- The Dutch Linuxgames homepage: http://linuxgames.nl.linux.org Personal homepage: http://www.nl.linux.org/~gerrit/ Discoverb is a python program in Dutch and English which tests the words you learned by asking it. Homepage: http://www.nl.linux.org/~gerrit/discoverb/ From graham at sloth.math.uga.edu Thu Jun 3 14:53:28 1999 From: graham at sloth.math.uga.edu (Graham Matthews) Date: 3 Jun 1999 18:53:28 GMT Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <87n1ykr0z9.fsf@ev.netlab.co.jp> <7ivs9q$dc5@news.dns.microsoft.com> <87k8toqv70.fsf@ev.netlab.co.jp> <7j44ql$908$1@cronkite.cc.uga.edu> <7j5rn5$dvs$1@nnrp1.deja.com> Message-ID: <7j6iv8$58f$1@cronkite.cc.uga.edu> adjih at technologist.com wrote: : Hmm... How do you do multi-thread real-time (i.e. incremental) GC being : a) portable (must run on PalmPilot, WinCE, Unix, Mac,...) b) without : relying on assumptions [that will fail in some programs] (such as "very : few writes in shared space"). The supplementary condition would be "c) : efficient" which would be useful for languages such as C/C++ or compiled : Java, but I grant you that this is not necessary for the current Python, : and that we are comparing here to reference counting anyway. I am no expert on real time garbage collection, but I have read a few papers which clearly show that it can be done. Moreover done quite portably and efficiently (indeed if it were not efficient, it can't be *real-time* can it). I am just suggesting you read such papers before you right off the whole idea. graham -- The fool escaped from paradise will look over his shoulder and cry Sit and chew on daffodils and struggle to answer why? From mrkbutty at mcmail.com Wed Jun 2 19:58:28 1999 From: mrkbutty at mcmail.com (Mark Butterworth) Date: Thu, 3 Jun 1999 00:58:28 +0100 Subject: A tkinter kick-off References: <37544a32.0@news1.mcmail.com> Message-ID: <3755c6e1.0@news1.mcmail.com> First of all thanks for the help. The pointers to code everyone sent certainly helped me, and the pipe capturing code will come in handy for something else I've in mind. However what I was after was something quick and dirty (and simple) not to capture command output. Please find my test code below, once I span out the process function (it in turn will call many more functions) it should be Ok. Anyone got any suggestions for adding a "Finished" message dialogue at the end and a method of keeping the listbox scrolled to the end of the list would be appreciated (and save me hunting through limited documentation). Any pointers to decent documentation would come in handy, the tkinter tutorials are fine but of limited use as reference. from Tkinter import * from tkmessagebox import * import tkMessageBox,threading class Logscreen: def __init__(self, master): frame = Frame(master) self.status = StringVar() self.status.set("My Test status") Label(frame, textvariable=self.status).pack() scrollbar=Scrollbar(frame, orient=VERTICAL) self.listbox=Listbox(frame, yscrollcommand=scrollbar.set) scrollbar.config(command=self.listbox.yview) scrollbar.pack(side=RIGHT, fill=Y) self.listbox.pack(side=LEFT, fill=BOTH, expand=1) frame.pack() def process(root, listbox, status): for x in range(1,500): listbox.insert(END,'x is set to %d' % x) status.set('x is set to %d' % x) status.set('finished') root.destroy() root = Tk() root.title('My first Tk test') root.resizable(1,0) logscreen = Logscreen(root) t=threading.Thread(target=process, args=(root, logscreen.listbox,logscreen.status,)) t.start() root.mainloop() -- Regards, ]\/[r]{ From timo at bbn.com Wed Jun 2 14:24:56 1999 From: timo at bbn.com (Tim O'Malley) Date: Wed, 2 Jun 1999 18:24:56 GMT Subject: Package for Solaris In-Reply-To: <3755494B.61C863B2@InfoMation.com> References: <3755494B.61C863B2@InfoMation.com> Message-ID: <199906021824.OAA29791@ghost.bbn.com> hola. Aron K. Insinga writes: > I built 1.5.2 from the sources, but is there a Solaris "package" for it? http://sunfreeware.com/ -- ..................................................................... . happy daze . Age and treachery will beat . . -tim O . youth and skill every time. . ..................................................................... From akuchlin at mems-exchange.org Thu Jun 10 10:11:48 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: Thu, 10 Jun 1999 10:11:48 -0400 (EDT) Subject: Grimoire [was: How do I defect?] In-Reply-To: References: Message-ID: <14175.51108.398189.219804@amarok.cnri.reston.va.us> David Ascher writes: >On Wed, 9 Jun 1999, Matthew Dixon Cowles wrote: >The tutorial is what I recommend you get started with. However, I'd like >to also put a little plug for a new document I discovered by accident >(well, surfing =). Andrew Kuchling is too modest to advertise it, ... I don't advertise it because it's nowhere near finished; I wanted to write a chapter on classes first, because that's the major missing piece. It's on my Web pages for the odd person who comes across it -- some nice people have even sent me corrections already. However, since it's been outed... the Grimoire is a task-oriented manual, structured along the same lines as the Perl Cookbook from O'Reilly -- each chapter covers a topic, starting with a general introduction, and followed by sections that explain various common questions (derived from FAQs, newsgroup discussions, the tutor list, etc.) -- A.M. Kuchling http://starship.python.net/crew/amk/ In cyberspace everyone will be anonymous for 15 minutes. -- Graham Greenleaf From holger at phoenix-edv.netzservice.de Mon Jun 14 06:49:37 1999 From: holger at phoenix-edv.netzservice.de (Holger Jannsen) Date: Mon, 14 Jun 1999 10:49:37 GMT Subject: force sequenz with only one item? References: <1282887498-90012442@hypernet.com> Message-ID: <3764DE41.9551EED1@phoenix-edv.netzservice.de> Thanx again, Gordon! mg, Holger From jlj at cfdrc.com Wed Jun 30 10:07:51 1999 From: jlj at cfdrc.com (Lyle Johnson) Date: Wed, 30 Jun 1999 09:07:51 -0500 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> <3773c3a0.102825445@news.oh.verio.com> <7laovo$c4s$1@Starbase.NeoSoft.COM> Message-ID: <377A24B7.AD6FAA1A@cfdrc.com> Just to add fuel to the fire, we now have a Python interface to FOX, a cross-platform GUI toolkit: http://www.cfdrc.com/pub/FOX/fox.html The latest version of the Python wrappers can be picked up at: ftp://ftp.cfdrc.com/pub/FOX/FXPy-0.99.42.tar.gz I don't know how the speed of FXPy would compare with some of the others mentioned (Tk, wxWindows, Qt, GTK, ...) but it would be worthwhile for some independent opinions. Lyle Cameron Laird wrote: > In article , > Michael P. Reilly wrote: > . > . > . > >There are other graphical packages for Python out there too, it would > >be appropriate to contrast them as well. > . > . > . > I occasionally work on such a comparison, currently available at http://starbase.neosoft.com/~claird/comp.lang.python/python_GUI.html>. > I welcome updates from readers. > -- > > Cameron Laird http://starbase.neosoft.com/~claird/home.html > claird at NeoSoft.com +1 281 996 8546 FAX From greg.ewing at compaq.com Wed Jun 23 19:55:35 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Thu, 24 Jun 1999 11:55:35 +1200 Subject: Why exceptions shouldn't be used for flow control [Re: YAS to the "Reading line-by-line" Problem] References: <376FDF70.4756AD38@mindspring.com> Message-ID: <377173F7.36BCFF6B@compaq.com> William Tanksley wrote: > > Both should be handled by exception, not by returning a special > value. I don't agree with that. Reaching the end of a file while reading it is not exceptional enough to warrant requiring the use of an exception handler to catch it. What bothers me about using exceptions for flow control in situations like this is that the effect of an exception handler is *non-local*, whereas what you're trying to catch is really only a local concern. When you write something like while 1: try: line = read_me_a_line() except EOFError: break what you really mean by the try-except is "if THIS PARTICULAR reading operation reaches the end of the file". But that's not what it does - it catches any EOFError raised by any operation invoked by read_me_a_line() that wasn't caught by something else first. In my experience, that sort of behaviour tends to mask bugs. I prefer results which are not errors to be returned normally, so that I can be sure where they came from. Greg From bwarsaw at cnri.reston.va.us Tue Jun 15 17:22:18 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Tue, 15 Jun 1999 17:22:18 -0400 (EDT) Subject: easy filecopy? - JPython? References: <1282653264-104102639@hypernet.com> <14182.35687.906156.126592@weyr.cnri.reston.va.us> Message-ID: <14182.50186.228957.979438@anthem.cnri.reston.va.us> >>>>> "Fred" == Fred L Drake writes: Fred> Gordon, This certainly would make sense. The question Fred> becomes "If os.chmod doesn't exist, should shutil.copy() Fred> fail?" I'd say yes, because you can't guarantee the documented semantics, i.e. that the permission bits are copied. However, shutil.copyfile() shouldn't fail though -- and doesn't: JPython 1.1beta1 on java1.2.1 Copyright (C) 1997-1999 Corporation for National Research Initiatives >>> import shutil >>> shutil.copy('/tmp/foo.txt', '/tmp/bar.txt') Traceback (innermost last): File "", line 1, in ? File "/home/bwarsaw/projects/python/pristine/Lib/shutil.py", line 53, in copy File "/home/bwarsaw/projects/python/pristine/Lib/shutil.py", line 34, in copymode AttributeError: class 'org.python.modules.os' has no attribute 'chmod' >>> shutil.copyfile('/tmp/foo.txt', '/tmp/bar.txt') If you had Finn Bock's jnios module (see my other msg in this thread), then shutil.copymode() and hence shutil.copy() probably won't fail because then you /would/ have os.chmod(). I haven't tested this though... -Barry From tim_one at email.msn.com Tue Jun 29 03:15:15 1999 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 29 Jun 1999 03:15:15 -0400 Subject: ANN: Stackless Python 0.2 In-Reply-To: <19990629121441.A19011@longford.cs.monash.edu.au> Message-ID: <000301bec1ff$22ac6fe0$719e2299@tim> [Tim sez Python stores space for each code object's "Python stack" in a runtime frame object] [Toby J Sargeant] > This might be completely irrelevant, but during the course of my > masters, I considered doing this kind of thing to java in order to > allow asynchronous threads to share stack frames (don't ask...). Don't tell . > My supervisor complained bitterly on the grounds that function > invocations where orders of magnitude more common than object creation, > and hence associating memory allocation/deallocation with every call was > considered horrendously inefficient. > > It seems that this should affect Stackless Python equally as > much. No more so than Stackful Python: Python has always worked this way; Stackless Python doesn't change this aspect. > Does anyone have anything to add on the subject? I would imagine that > frames could be allocated and managed in chunks to alleviate a lot of > the memory management load... The code is in Objects/frameobject.c, and easy to follow. frameobjects are recycled via their own free list. Typically the total number of frame-associated mallocs is proportional to the maximum depth of the call stack, not to the number of calls made. Setting up a Python frame remains expensive, but for other reasons. 115-lines-of-code-doesn't-run-in-one-cycle-malloc-or-not-ly y'rs - tim From rfreedm1 at nospam.rochester.rr.com Wed Jun 23 17:19:01 1999 From: rfreedm1 at nospam.rochester.rr.com (Benjamin Schollnick) Date: Wed, 23 Jun 1999 21:19:01 GMT Subject: help? strptime .... References: Message-ID: On Wed, 23 Jun 1999 20:21:56, aahz at netcom.com (Aahz Maruch) wrote: > In article , > Benjamin Schollnick wrote: > > > > I'm trying to use strptime (from the time module) and can't.... > > What version of Python? I'm getting AttributeError in 1.5.1, so I > suspect it's only in 1.5.2. I'll bet mxDateTime has what you need, > though, if you don't want to upgrade. I'm using v1.51 as well.... But STRPTIME is clearly documented in the v1.51docs.... (I haven't printed the v1.52 docs yet) I'll try to see if the OS v1.52 python is available yet.... - Ben From MHammond at skippinet.com.au Tue Jun 22 10:11:42 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Wed, 23 Jun 1999 00:11:42 +1000 Subject: [pythonwin] popup menu problems (was: [Pythonwin] Help needed creating a Window) References: <37651bde.25372123@NNRP.UK.INSNET.NET> <376f6b7a.760974@nnrp.uk.insnet.net> Message-ID: <7ko5fd$cp8$1@m2.c2.telstra-mm.net.au> Dave Kirby wrote in message <376f6b7a.760974 at nnrp.uk.insnet.net>... >way. I only found it when I enclosed the line in a try/except clause. >I *think* the exception is getting caught & thrown away somewhere in >the pythonwin code since I didnt have any try clauses in my code at >that point. Eeek. If you can determine this is true, I would like to know about it. >level window to process the WM_CANCELMODE message. Is there a way to >register my icon window to handle this message, or do I need to go the win32ui.HookMessage() should do the job? >[1] well, almost - further experimentation shows that it only closes >the menu if I click within the Pythonwin window, rather than anywhere >on the screen. Well, maybe you should set the owner to the desktop? Mark. From jfisher at are.berkeley.edu Fri Jun 25 14:52:29 1999 From: jfisher at are.berkeley.edu (John Fisher) Date: Fri, 25 Jun 1999 18:52:29 GMT Subject: load_dynamic problem Message-ID: <7l0j58$cbh$1@nnrp1.deja.com> Hey folks, I'm having a bit of trouble loading a C extension into Python 1.5.2. I'm getting the error: Traceback (innermost last): File "", line 1, in ? File "bpinter.py", line 9, in ? PyBPMPD = imp.load_dynamic('PyBPMPD', 'PyBPMPD.so') ImportError: ./PyBPMPD.so: undefined symbol: setdef setdef, not written by me, but called from inside PyBPMPD.c, is prototyped as: extern int setdef(bpmparam *); The module itself compiles without complaint with: gcc -I/usr/include/python1.5/ -shared -o PyBPMPD.so PyBPMPD.c I'd appreciate any ideas on the problem. I'm rather stumped. Thanks, John Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From jantich at cantv.net Wed Jun 30 11:31:14 1999 From: jantich at cantv.net (Jose A. Antich) Date: Wed, 30 Jun 1999 11:31:14 -0400 Subject: Python Editor Message-ID: Does anyone know if there's any Python Editor for the MAc? Thank's From mlh at idt.ntnu.no Sun Jun 6 18:49:03 1999 From: mlh at idt.ntnu.no (Magnus L. Hetland) Date: 07 Jun 1999 00:49:03 +0200 Subject: Deleting characters from a string References: <87n1ye3g4v.fsf@pc-hrvoje.srce.hr> <199906052144.XAA15045@axil.hvision.nl> Message-ID: "Hans Nowak" writes: > On 5 Jun 99, Hrvoje Niksic wrote: > [...] > host = filter(lambda c: not c in ' "', host) Or - IMO more appropriately : host = filter(lambda c: c not in ' "', host) > > Depends on how much you like, or hate, functional idiom, though. :) -- Magnus Making no sound / Yet smouldering with passion Lie The firefly is still sadder / Than the moaning insect Hetland : Minamoto Shigeyuki From joeld at anisci.com Thu Jun 24 17:54:24 1999 From: joeld at anisci.com (Joel Davis) Date: 24 Jun 1999 14:54:24 PDT Subject: C++ and Python Message-ID: <3772AA7D.A7855B93@anisci.com> I am trying to wrap a bunch of c++ classes so that virtual methods in derived classes can be written in python, and still callable from c++, SWIG and friends seem to be one-way, they let you subclass a C++ class in python via shadow classes or fancy extention types, but the subclasses behavior only shows up on the python side. I am trying to add the ability to mix python derived classes into a large c++ application. I guess what I'm asking is, the ORA Python book says (p626), "it's also possible to route C++ virtual method calls back down to methods in a python subclass, but it may require a stub-class on the C++ side of the interface, too (this is left as a Exercise to the Reader)." Are there any tools to help make this easier, or any good examples of this? thanks, joel -- ---------------------------------------------------------------- joeld at anisci.com From see-sig at wavedivision.com Wed Jun 9 04:03:44 1999 From: see-sig at wavedivision.com (Rick Robino) Date: 9 Jun 1999 08:03:44 GMT Subject: "Programming Python" still worthwhile? References: <1283218560-70098357@hypernet.com> Message-ID: <7jl750$qsu$1@news.gstis.net> Thanks Gordon and William! > Rick Robino originally posted: >> I've been watching this group for some time and just now getting >> warm to Python. Looking at source examples has been great, but for >> completeness' sake I'd like to get more of the "why" maybe found in >> a book. Since Python is at 1.5.2 and people are talking about 2.0 as >> if it's around the corner, I was wondering if anyone here could give >> me some advice as to whether or not "Programming Python" is useful, >> if the current edition is still current, if I should wait for the >> "Learning Python", or if I should use some other resources. Gordon McMillan wrote: > Python 2 is around a really, really big corner, and then down the > block quite a ways. Python 1.6 sometime in 2000 (which will be > backwards compatible), so no 2 until 2001 or 2002. I didn't do alot of research, but I couldn't get a good feel from the huge thread that has been going on here named after 2.0. Appreciate the ETA. I have read the tutorial and it is wonderful, especially the couple extra smaller ones mentioned in the "Python as a first language" thread. Just wanted more meat; you know how that is ;) > Learning Python is on the shelves. Haven't read it. Nobody's > flamed it, and that's a _very_ good sign. There's only a few things > out of date in PP, and you'll find updates on Mark's web site. I > liked PP very much (and the difficult to find Internet Programming > with Python, Watters et al, M&T books). When Mark wrote PP, he > thought it might be the only Python book ever, so he stuffed in > everything he could think of. So don't feel bad if you skip stuff. Hmm... the Internet Programming book sounds interesting. I'll pick up that and also the new book to check it out - I'll be a good test ;) I have one of those weird learning curves where I need things explained really simply at first and then I can usually jump up pretty fast. I'll let you all know how I thought the book was. Daring advertisement... still feels like there is nothing I can't do in shell that perl can do, cuz maybe it looks so much like shell? Most of my friends would slap me silly for such heresy but after poking around with python for a couple of weeks, I think its quite nice. --Rick ^^^^^^^^^^^^^^ Rick Robino rrobino [at] wavedivision.com From aprasad at magix.com.sg Fri Jun 18 12:20:18 1999 From: aprasad at magix.com.sg (Ajith Prasad) Date: Sat, 19 Jun 1999 00:20:18 +0800 Subject: DATE ARITHMETIC Message-ID: <7kejrv$e57$1@violet.singnet.com.sg> I need to do some simple date arithmetic - finding the number of days between any 2 days, the age of a person on a day given his birthday. The mxDateTime module downloadable from the Python website is more complex than what I need. Any other suggestions? From mal at lemburg.com Tue Jun 8 04:04:53 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Tue, 8 Jun 1999 08:04:53 GMT Subject: mxODBC and MySQL References: Message-ID: <375CCEA5.3EA8C134@lemburg.com> Joachim Schmitz wrote: > > I ugraded to 1.5.2 now I get: > > Python 1.5.2 (#1, Jun 8 1999, 07:26:20) [GCC egcs-2.91.66 19990314 > (egcs-1.1.2 on linux2 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import ODBC.MySQL > Traceback (innermost last): > File "", line 1, in ? > File "/usr/local/lib/python1.5/ODBC/MySQL/__init__.py", line 7, in ? > from mxODBC import * > ImportError: /usr/local/lib/python1.5/ODBC/MySQL/mxODBC.so: undefined > symbol: SQLTables Hmm, the MyODBC driver does define this function. Could be that you've linked against the wrong lib or that the loader doesn't find the .so file. Cheers, -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 206 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From scott at hk.super.net Tue Jun 29 07:23:59 1999 From: scott at hk.super.net (Scott Deerwester) Date: Tue, 29 Jun 1999 19:23:59 +0800 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <59EAFD6B662F0706.86BFF3E906CBF8DE.784D2A219F85BC21@lp.airnews.net> <99062523473500.00769@Vegus> <7l16e5$q4j$1@news.tamu.edu> Message-ID: <3778ACCF.ACE29713@hk.super.net> Corran Webster wrote: > John Travers wrote: > >> Has anybody tried the PyKDE/Qt package, (you don't have to have KDE), it is >> absoloutly fantastic, quick, easy, powerful, far far better than Tkinter. >> I love it! > > This is missing the point - although PyKDE/Qt might be a very nice GUI, it's > not cross-platform in the same way as Tcl/Tk. The same goes for Fltk, > gtk or what have you. It sounds like wxWindows might be getting near > the same level of cross-platform compatibility - and it certainly seems > to be one of the groups' objectives - it's not there yet. That's probably true, but Qt IS cross-platform. Has anybody ever tried running pyKDE with the Windows version of Qt? I've used pyKDE a bit and it seems to win in regard to completeness and usability. One "problem" is that pyKDE (unlike Qt) seems to have tightly coupled KDE (which isn't cross-platform) with Qt (which is). Haven't used wxWindows yet. I've used Tkinter a fair bit and have grown to dislike it. Very awkward windowing and event model, as others have pointed out. It also tends to be kind of ugly. Qt yields a lot prettier interfaces. and wins on functionality. PythonWin is okay, but (obviously) Windows only. Sigh. From moshez at math.huji.ac.il Wed Jun 16 08:53:52 1999 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Wed, 16 Jun 1999 15:53:52 +0300 Subject: GC In Python: YAS (Yet Another Summary) In-Reply-To: Message-ID: On Wed, 16 Jun 1999, Robert Meegan wrote: > On Wed, 16 Jun 1999, Moshe Zadka wrote: > > > Regarding the recend discussion here about garbage collection, I wrote > > a small article. > > Moshe --- > > You didn't provide the document or a URL. You're absolutely right! Shame on me! http://www.geocities.com/TheTropics/Island/2932/gcpy.html -- Moshe Zadka . QOTD: My own exit is more likely to be horizontal then perpendicular. From MHammond at skippinet.com.au Fri Jun 18 20:15:26 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Sat, 19 Jun 1999 10:15:26 +1000 Subject: Python source code documentation? References: <7kdv0l$n0g$1@nnrp1.deja.com> Message-ID: <7kenc7$1od$1@m2.c2.telstra-mm.net.au> Sam Schulenburg wrote in message <7kdv0l$n0g$1 at nnrp1.deja.com>... >I have been using a freeware product called Autoduck to document my >Python source code. Cool! I use AutoDuck to document all my Python extension C++ code. All the helpfiles in the Win32 extensions are generated using autoduck. As another poster pointed out, you should look at pythondoc/gendoc. Sorry in advance for the length of this, but I am in exactly the same predicament as you, and have been thinking for a number of years how to resolve this. Im really pleased to finally find someone else with this problem, and really hope we can solve it in a reasonable way. However, depending on how far you have gone with AutoDuck, pythondoc/gendoc isnt solving the exact same problem. Well, they all attempt to solve the same problem, but have different strengths. IMO, AutoDuck generates far superior reference documentation. Pythondoc's big strength is the integration with Python. Using docstrings is an obvious advantage, and much of what you need to explicitely mark-up using autoduck, pythondoc already knows. AutoDuck has 3 strengths over pythondoc that I am having trouble reconciling: * pythondoc really doesnt support natural links to objects. Autoduck can say "see method " or "@xref object|method" to generate inline links or a cross-references section. Has been some discussion how to expand Pythondoc to support this, but a) it hasnt been done and b) it still is not as natural as autoduck. * Autoduck pulls-apart and re-assembles the output. For example, one method you may define entries in the following order: return description, params, notes and cross-references. A different method may define them in a completely different order (as the best place to add the documentation is right next to the appropriate code. Autoduck will still always produce a reference guide formatted as you choose - eg, always "params, return desc, comments, cross-referneces". * It can be used to document C extensions damn well. Some of these problems boil down to an underlying philosophy of pythondoc - attempting to use raw, unmarked docstrings to produce the doc. Pythondoc really doesnt want to introduce ugly mark-ups in the docstring, as this tends to make the docstring hard to use in native form - it really _must_ be read via the document generation tool. This would be a serious bummer given Python's introspective nature, and that IDE's may use this info on the fly. (otoh, autoduck info doesnt exist at runtime at all!) Sooooo. I have come to the conclusion that we need a _new_ tool - PythonDuck. It should work with Pythondoc, and be capable of enhancing its output. A new release of pythondoc uses XML I believe, so PythonDuck could be a tool that can enhance the documentation generated by pythondoc. Alternatively we just graft it in, and beat up Daniel until he agrees :-) This tool could possibly still work from comments, or maybe from the tail-end of the doc strings (thereby stripped from the documentation, and not messing the raw docstring too much). #@ comments could be considered "directives" for the generated output. Eg, "#@ xref SomeOtherFunction" will create a cross-references section. A comment such as "#@ paramtype param_name " would direct that the param called "param_name" should be documented as being of type "SomeType" and a cross-reference to the SomeType definition be added. The tool should resolve all links at the end, and report bad links. I know I am not making my point that well, and unfortunately dont have time to fix this. But in summary, Pythondoc exists and is very cool, but doesnt quite cover what AutoDuck can do (and vise-versa, but that isnt the point now). I believe a real need exists for the functionality AutoDuck provides, and further I need it personally! So we should try and make this happen... Mark. From dave_kirby at eur.3com.com Thu Jun 17 05:49:25 1999 From: dave_kirby at eur.3com.com (Dave Kirby) Date: Thu, 17 Jun 1999 09:49:25 GMT Subject: wierdness with pythonwin dialogs, threads & refcounts Message-ID: <3768b75e.5469224@NNRP.UK.INSNET.NET> I have found strange behaviour (strange to me at least) when creating a pythonwin dialog on a separate thread created using the standard python thread module. The dialog object is never deleted since the thread is keeping references to it. The following example uses dlgtest.py that comes with the pythonwin distribution: #------------- 8< ---------------------------- C:\dev\PYTHON\Pythonwin\pywin\DEMOS>python Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> from dlgtest import TestDialog >>> import sys, thread >>> def test(): ... t = TestDialog() ... print "refs:", sys.getrefcount(t) ... t = None ... >>> test() Edit text changed! refs: 2 >>> thread.start_new_thread( test, () ) >>> refs: 6 #------------- 8< ---------------------------- As you can see from the above, creating the dialog in the thread gives it an extra 4 references compared with the non-threaded invocation. Is this a bug, or is the thread module incompatible with pythonwin? If so how would I do the equivalent using pythonwin threads? I have read the available docs, but it is still pretty opaque to me. Any help would be greatly appreciated. Dave K From Gaetan_Corneau at baan.com Thu Jun 10 09:13:14 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Thu, 10 Jun 1999 09:13:14 -0400 Subject: COM dates Message-ID: <816010E2456BD111A48700805FBBE2EEFDF357@ex-quebec-u1.baan.com> I did it the Python way: I looked at what I really needed, looked at the documentation to see what I had, and wrote a 3 line function that takes year, month, date, hour, minute and second and returns time in the same numeric format as time.time(). I knew about mxDateTime and think it's really cool (I have written something similar in C++ years ago), but for many reasons, I don't want to rely on extensions for this particular project. Thanks, ______________________________________________________ Gaetan Corneau Software Developer (System integration Team) BaaN Supply Chain Solutions E-mail: Gaetan_Corneau at baan.com Compuserve: Gaetan_Corneau at compuserve.com ICQ Number: 7395494 Tel: (418) 654-1454 ext. 252 ______________________________________________________ "Profanity is the one language all programmers know best" > -----Original Message----- > From: M.-A. Lemburg [SMTP:mal at lemburg.com] > Sent: Thursday, June 10, 1999 4:31 AM > To: Gaetan Corneau > Cc: Python List @ Python.org > Subject: Re: COM dates > > > You could check out mxDateTime. It has COM date support, strptime() > and also a much more powerful date/time parser: > From perry at ac-copy.net Thu Jun 3 17:16:52 1999 From: perry at ac-copy.net (Joachim Schmitz) Date: Thu, 3 Jun 1999 21:16:52 GMT Subject: build of python 1.5.2 with threads on SunOs 5.6 fails Message-ID: Hi, I compiled Python 1.5.2 on SunOS 5.6/Solaris 2.6 without threads successfully. But doing a configure --with-threads, and make results in the following error: ..... cd Modules; make OPT="-g -O2" VERSION="1.5" \ prefix="/usr/local" exec_prefix="/usr/local" \ LIBRARY=../libpython1.5.a link gcc python.o \ ../libpython1.5.a -lsocket -lnsl -ldl -lthread -lm -o python Undefined first referenced symbol in file Py_Main python.o ld: fatal: Symbol referencing errors. No output written to python *** Error code 1 make: Fatal error: Command failed for target `link' Current working directory /u/src/Python-1.5.2/Modules *** Error code 1 make: Fatal error: Command failed for target `python' any help is welcome Joachim Schmitz From delgado at Mathematik.Uni-Bielefeld.DE Wed Jun 16 16:54:50 1999 From: delgado at Mathematik.Uni-Bielefeld.DE (Olaf Delgado) Date: Wed, 16 Jun 1999 22:54:50 +0200 Subject: Newbie again: computing attributes on the fly In-Reply-To: <1282559115-109766087@hypernet.com> References: <1282571882-108998091@hypernet.com> <1282559115-109766087@hypernet.com> Message-ID: On Wed, 16 Jun 1999, Gordon McMillan wrote: > [Olaf on my very simple getattr hack]: > > > Yes, I definitely want to generalize that. The problem is that that > > method may be defined in a superclass, so "self.__dict__" won't find > > it. AFAIK (which may be not be very far), I have to use "hasattr" > > and/or "getattr", which in turn will call "__getattr__". > > Oh, getattr isn't bad. Wait 'till you try setattr! Anyway, this > should demonstrate how to control the recursion: [...] Yes, that looks much more civilized than my version. So, I'll have to take a closer look at all these magic methods. -- //// Olaf Delgado Friedrichs, Uni Bielefeld, Mathematik Olaf Postfach 100131 (room: V4-109) `=' D-33501 Bielefeld, Germany (phone: +49 521 106-4765) http://www.mathematik.uni-bielefeld.de/~delgado From tbryan at arlut.utexas.edu Mon Jun 14 23:28:15 1999 From: tbryan at arlut.utexas.edu (Thomas Bryan) Date: Mon, 14 Jun 1999 22:28:15 -0500 Subject: Looking for modules? Config files? Ini files? in python.... References: Message-ID: <3765C84F.FC952ACE@arlut.utexas.edu> Benjamin Schollnick wrote: > > Folks, > > I'm trying to find a simple method to deal with *.INI or other > styles of configuration files.... ConfigParser http://www.python.org/doc/current/lib/module-ConfigParser.html user http://www.python.org/doc/current/lib/module-user.html site http://www.python.org/doc/current/lib/module-site.html rexec http://www.python.org/doc/current/lib/module-rexec.html depending on your needs. ------------------------------------------- Tom Bryan Applied Research Laboratories University of Texas at Austin From borkman at usa.net Sun Jun 20 22:51:07 1999 From: borkman at usa.net (Lee Borkman) Date: Mon, 21 Jun 1999 02:51:07 GMT Subject: XML-toolkit for Windows - binaries available? References: <376701a3.72288277@newssrv> <3767fc51.1547455@news.iol.ie> <37693395.731772@news.iol.ie> Message-ID: <376da59b.2034245@news> Thanks very much, but I'm afraid I'm still unsure. I have copied pyexpat.dll and sgmlop.dll to the DLLs directory I have modified the PythonPath to include: C:\Program Files\Python\Lib\xml-0.5.1 and: C:\Program Files\Python\Lib\xml-0.5.1\expat\bin (this is where xmlparse.dll lives) Now I have to edit __init__.py to include sgmlop and pyexpat in the __all__ list, is that right? Now which __init__.py would that be? I assume it's C:\Program Files\Python\Lib\xml-0.5.1\__init__.py Okay, I've done that. But none of the demos will work. I keep getting: ImportError: No module named xml.sax or: ImportError: No module named pyversioncheck I guess I still don't understand where Python (and PythonWin) look for their modules, and I guess I don't understand quite a bit of other stuff. Thanks very much for all of your help. I've obviously got a bit more homework to do before I proceed. Leeb. On Thu, 17 Jun 1999 17:43:22 GMT, digitome at iol.ie (Sean Mc Grath) wrote: >On 16 Jun 1999 23:05:38 +0200, Lars Marius Garshol >wrote: > >> >>* Sean Mc Grath >>| >>| The binaries are there but a bit of fiddling is required to get >>| things working. (This is from memory but here goes) >>| >>| The pyexpat and sgmlop dlls have to be copied into the xml/parsers >>| subdirectory. You also need to edit the __init__.py file to include >>| 'pyexpat' and 'sgmlop' in the __all__ string. >> >>Heh. I didn't know you could do this! :) >> >>I just put them in the python/dlls directory, and that worked for me. >> >Lars, is quite right. python/dlls is a better place to put them than >xml/parsers. > >Sean > > > From Mike.C..Fletcher at p98.f112.n480.z2.fidonet.org Wed Jun 30 23:25:28 1999 From: Mike.C..Fletcher at p98.f112.n480.z2.fidonet.org (Mike C. Fletcher) Date: Thu, 01 Jul 1999 04:25:28 +0100 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? Message-ID: <000015f6@bossar.com.pl> From: "Mike C. Fletcher" There is a binary distribution of the python version in the FTP directory, very nice package. I'm thinking of rewriting my (few) GUI applications tonight and ditching tkinter entirely. Documentation seems rather sparse, but since everything looks fairly simple, it might be doable. Note, the OpenGL demos are dependent on PyOpenGL. This should be mentioned somewhere. My only other comment is that the window-dragging border in the demos looks like static (i.e. noise), instead of a controlled GUI element. Installation went flawlessly, was able to run the demos in less than a few minutes after download. Enjoy, Mike ----- Original Message ----- From: Mikael Lyngvig Newsgroups: comp.lang.python To: Sent: Wednesday, June 30, 1999 8:48 PM Subject: Re: Python GUIs: Abandoning TkInter and welcoming wxPython? ... > http://www.cfdrc.com/FOX/fox.html. > > The presentation seems promising, but I'd like to suggest a binary > distribution for PC/Intel computers. I know this is not common for > Unix distributions, but it's the norm for PCs. ... From mwh21 at cam.ac.uk Fri Jun 11 13:28:45 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 11 Jun 1999 18:28:45 +0100 Subject: newbie questions References: Message-ID: Jeff Norden writes: > I've been tinkering with python for a few days. I have to admit that my > first impression was that this language would turn me into a newt, but I got > better :-) > > A few questions: > > 1) Is there no equivalent to perl's "use strict" in which all variables > have to be declared? How about perl's "-w" flag, which at least gives a > warning when a variable is only used once. These features are nice for > catching common mistakes, i.e., if you try to increment spam with > > span = spam + 1 > > python will just create a new span variable, and no error message. > Or, consider the even more insidious error: vikingl = viking1 + spam Python has no declarations at all, ever (I think). There's some kpylint package found off of www.chordate.com that will check for identifiers that are only used once. It's not incredibly bright (it doesn't really try to be). > 2) Is the above the correct way to increment a variable? Yes. > I can't find an > equivalent for "++" or "+=" That would be because there isn't one. You could use my bytecodehacks package to fake them, but don't ;-). > 3) These are rather minor, but is there no way to "forward declare" function > definitions? No. > I'd rather put them at the end of the file instead of the > beginning. Python does parse the whole file before it starts execution, > doesn't it? Yes. > Also, is there a way to just check for syntax errors without > execution, like perl's "-c" switch? Well, you could try this: def check_file(file): import parser try: parser.suite(open(file).read()) print "no syntax errors" except parser.ParserError: print "syntax error" this was thrown together in about a minute. seems to work. HTH Michael From tim_one at email.msn.com Fri Jun 4 01:15:18 1999 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 4 Jun 1999 01:15:18 -0400 Subject: "The Python Way" In-Reply-To: Message-ID: <001301beae49$3c88da80$949e2299@tim> [Steven D. Majewski] > What makes you think that Tim and Guido would agree on "The Python Way" ? Just like the old days, Steven: we would be forced to, just to oppose you . ah-nostalgia-ly y'rs - tim From graham at sloth.math.uga.edu Tue Jun 8 15:39:11 1999 From: graham at sloth.math.uga.edu (Graham Matthews) Date: 8 Jun 1999 19:39:11 GMT Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <87pv3iq6ss.fsf@ev.netlab.co.jp> <3752C76D.604CD474@prescod.net> <87n1ykr0z9.fsf@ev.netlab.co.jp> <375372F6.A874554@prescod.net> <7j34l3$hbj$1@nnrp1.deja.com> <7j66b7$il5$2@cronkite.cc.uga.edu> <3756C693.2C910B29@usa.net> <7j6jnl$58f$3@cronkite.cc.uga.edu> <3757A820.CE3F195F@usa.net> <7j8obc$55v$2@cronkite.cc.uga.edu> <375BEDF8.DD14C4E6@usa.net> <7jgs5g$q55$1@cronkite.cc.uga.edu> <375CE5BD.3E865EF4@usa.net> Message-ID: <7jjrgv$h16$1@cronkite.cc.uga.edu> Graham Matthews wrote: > I really don't understand this. A lot of languages (eg. Java) have > garbage collection and finalisers. All these languages manage to delete > objects in an order that does not cause any problems (all finalisers etc > work). Salvador =?iso-8859-1?Q?Fandi=F1o?= (fandino at usa.net) wrote: : I have been using Java since it was invented and I haven't programed a : finaliser ever. They should run under so unknown and inconsistent : environment that they are not usable at all (except for freeing external : resources). I am not sure I understand this. Can you explain to me how a finaliser can run in an unknown environment. Surely everything the finaliser needs is referenced by the finaliser (either directly or indirectly) and hence is still there. Salvador =?iso-8859-1?Q?Fandi=F1o?= (fandino at usa.net) wrote: : BTW, how could be acceptable that the same __del__ method could be : called from two totally different schemes (GC reclaiming objects or : reference count becoming 0)? it would break all the library classes that : now use __del__ . Because anything referenced by a __del__ method will always be there when the __del__ is called, under any GC scheme. graham -- As you grow up and leave the playground where you kissed your prince and found your frog Remember the jester that showed you tears the script for tears From neelk at brick.cswv.com Tue Jun 15 22:19:22 1999 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 15 Jun 1999 21:19:22 -0500 Subject: Module magic methods References: Message-ID: <7k71ja$i8b$1@brick.cswv.com> In article , Michael Hudson wrote: > >FWIW, I've often thought it would be funky to be able to define >__add__ or __call__ etc methods to modules. Pointless, I'd have to >admit, but still funky. Not so pointless, imo, because a module is just a singleton class with a light dusting of nonstandard syntax and semantics. I've been bitten now and again by the differences (don't ask), and I compiled a list of the differences. Some are superficial, and some are significant: o Classes are defined by the block a "class" statement contains; a module is defined by the contents of its file (sort of). o Instances of classes are created by the __init__ method of the class (mostly), and a module instance is created with the "import" statement. o Type-checking is performed on a call to a method of a class to guarantee that the first argument is the same class as the class the method belongs to (sigh), whereas no such type checking is performed on functions inside a module. o Assigning to a instance attribute of the same name as a class variable will just shadow the class attribute for that instance. For the module, no such shadowing happens. That is, >>> class Foo: q = 'foo' >>> x = Foo() >>> x.q = 'bar' >>> print x.q bar >>> print Foo.q foo >>> import math >>> print math.pi 3.14159265359 >>> math.pi = 3 >>> print math.pi 3 >>> del math; import math >>> print math.pi 3 Right now, since classes and modules are built-in types, so we don't have access to what makes them different. So you can't have a module intializer that you can pass information to, for example. But in the promised land of Python 2.0, when types and classes are unified, it may be possible to do things like this: class WhyWhyWhy(Module, Class): [...] In addition to just being gross, notice how we've snuck a metaclass into the equation. This would just be too cool, wouldn't it? :) Neel From jkraai at murl.com Thu Jun 3 09:45:48 1999 From: jkraai at murl.com (jkraai at murl.com) Date: Thu, 3 Jun 1999 13:45:48 GMT Subject: starship.python.net Message-ID: <000601beadc7$75b2ecb0$8b7125a6@cpda6686.mcit.com> Ok, I don't go to the starship root very often, but went there this morning. It's _beautiful_. Who did this excellent work? Chris T? Wow. Clean, elegant, etc. From news at dorb.com Wed Jun 16 10:22:55 1999 From: news at dorb.com (Darrell) Date: Wed, 16 Jun 1999 10:22:55 -0400 Subject: GC In Python: YAS (Yet Another Summary) References: Message-ID: Guido's idea sounds least intrusive. Is there any merit to building a tool to tell me if I have cycles and where they are ? Then I apply one of N strategies to kill them. How often does the normal Joe have or care that he has cycles ? I find them hard to track down. -- --Darrell From amackay at starvision.com Fri Jun 18 19:19:21 1999 From: amackay at starvision.com (Angus MacKay) Date: Fri, 18 Jun 1999 16:19:21 -0700 Subject: looking at function prototypes Message-ID: <376AD3F9.C51AAED2@starvision.com> how can one look at a function prototype in python? the interpreter will tell you the number but what about the type? I am using fnorb for some CORBA stuff and would like to know what types are expected in the methods. I do realize that this might be impossible as function arguments are not typed. it so then anyone know how to get "fnidl" to generate doc strings with the prototype in it? cheers, Angus. From sams at quinta.com Wed Jun 23 13:08:49 1999 From: sams at quinta.com (Sam Schulenburg) Date: Wed, 23 Jun 1999 17:08:49 GMT Subject: Embedded Python Documentation information Message-ID: <7kr4an$cft$1@nnrp1.deja.com> While trying to add docinfo strings to my embedded C libraries I found the folloing documentation issue: The following structure follows the definition for setting up the 'C' Python interface in embedded code. What is missing is the information on the docinfo field parameters. ================== As defined in documentation ====================== // This function is the only exported function from the // DLL and has to be of type non-static, all other functions must be static. __declspec(dllexport) void initASPIPy(void) { Py_InitModule("ASPIPy",ASPIPyFuncs); } // Define the Methods array static PyMethodDef ASPIPyFuncs[] = { //Python_Func_Name C_Func_Name Method_Flags {"startaspi" ,PyStart ,METH_VARARGS}, {"cls" ,PyCls ,METH_VARARGS}, {"io6" ,PyIO6 ,METH_VARARGS}, {"io10" ,PyIO10 ,METH_VARARGS}, {"io12" ,PyIO12 ,METH_VARARGS}, {"settid" ,PySetTID ,METH_VARARGS}, {"setasciion" ,PySetASCIIOn ,METH_VARARGS}, {"gettid" ,PyGetTID ,METH_VARARGS}, =============== End Original documentation ========= The following is the correct definition for the Methods array adding the docinfo string: // Define the Methods array static PyMethodDef ASPIPyFuncs[] = { // P_Func_Name C_Func_Name Method_Flags DocInfo {"startaspi" ,PyStart ,METH_VARARGS,"startaspi(string,flag)"}, {"cls" ,PyCls ,METH_VARARGS,"cls(void) Clears screen"}, {"io6" ,PyIO6 ,METH_VARARGS,"io6(cdb0...cdb5}", {"io10" ,PyIO10 ,METH_VARARGS,"io10(cdb0...cdb9)"}, {"io12" ,PyIO12 ,METH_VARARGS,"io12(cdb0..cdn11)"}, {"settid" ,PySetTID ,METH_VARARGS,"settid(TID)"}, {"setasciion" ,PySetASCIIOn ,METH_VARARGS,"setasciion(flag)"}, {"gettid" ,PyGetTID ,METH_VARARGS,"gettid(void)"} } Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From Paul.Prescod at p98.f112.n480.z2.fidonet.org Wed Jun 30 09:49:00 1999 From: Paul.Prescod at p98.f112.n480.z2.fidonet.org (Paul Prescod) Date: Wed, 30 Jun 1999 14:49:00 +0100 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? Message-ID: <000015b9@bossar.com.pl> From: Paul Prescod Lyle Johnson wrote: > > Just to add fuel to the fire, we now have a Python interface to FOX, a > cross-platform GUI toolkit: I find it fascinating that there are so many GUI toolkits. The GUI is more than twenty years right and we haven't agreed on the basic programming model or API yet?? -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco "The new revolutionaries believe the time has come for an aggressive move against our oppressors. We have established a solid beachhead on Friday. We now intend to fight vigorously for 'casual Thursdays.' -- who says America's revolutionary spirit is dead? From greg.ewing at compaq.com Wed Jun 16 18:22:30 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Thu, 17 Jun 1999 10:22:30 +1200 Subject: Raw Strings! References: <19990612173928.A23568@humbolt.nl.linux.org> Message-ID: <376823A6.E8B2F7AA@compaq.com> "Magnus L. Hetland" wrote: > > The point with raw strings is that backslashes can be written > out without being escaped. Be warned that raw strings are not *quite* completely raw! For example, s = r"\abc\def\" is a syntax error. On the other hand, s = r"\abc\def\\" is not. I'll leave you with the fun of trying to guess what the resulting string contains... They-should-really-be-called-rare-strings, Greg From aahz at netcom.com Mon Jun 14 01:48:42 1999 From: aahz at netcom.com (Aahz Maruch) Date: Mon, 14 Jun 1999 05:48:42 GMT Subject: Variations on a theme by "pound bang" References: <3763e75f.3265255@news.iol.ie> Message-ID: In article <3763e75f.3265255 at news.iol.ie>, Sean Mc Grath wrote: > >Can anyone shed some light on the benefits of:- > ># !/usr/bin/env python ObSmartAss: there's no benefit here, try using "#!" instead. -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het "That doesn't stop me from wanting to work all three of them over with the clue stick for while, with no safewords allowed." --abostick From ovidiu at cup.hp.com Wed Jun 16 18:43:02 1999 From: ovidiu at cup.hp.com (Ovidiu Predescu) Date: Wed, 16 Jun 1999 22:43:02 GMT Subject: Emacs package to the Python debugger? In-Reply-To: Your message of "Wed, 16 Jun 1999 16:25:03 CDT." <14184.5679.711795.786883@buffalo.fnal.gov> References: <14184.5679.711795.786883@buffalo.fnal.gov> Message-ID: <199906162243.PAA03215@hpcll563.cup.hp.com> On Wed, 16 Jun 1999 16:25:03 -0500 (CDT), Charles G Waldman wrote: > Ovidiu Predescu writes: > > > Is there any pac kage that allows debugging Python programs from > > within Emacs? Something that is integrated with Emacs' GUD would > > be very convenient. > > Recent versions (21.0 and up) of XEmacs include this in the > "prog/debug" package. > > If you don't use the XEmacs package system, you can still get the > single-file "pdb.el" from > > ftp://ftp.aifb.uni-karlsruhe.de/pub/wwe/pdb.el > > And, yes, it is build on top of the Grand Unified Debugger. Thanks, I already got the pdb.el from that site. I'm still using Xemacs 20.4 so I had to install it manually on my machine. One thing I noticed is that it doesn't have a debugger mode for the source file similar with gdbsrc-mode. This requires me to use the python debugger buffer to enter the commands. I cannot simply type 'n' or 's' on the buffer containing the source. Do you know if such a thing is available? Thanks, Ovidiu From holger at phoenix-edv.netzservice.de Tue Jun 22 04:26:33 1999 From: holger at phoenix-edv.netzservice.de (Holger Jannsen) Date: Tue, 22 Jun 1999 08:26:33 GMT Subject: glint? Message-ID: <376F48B9.133D37C6@phoenix-edv.netzservice.de> Hi, I'm working on an installation-tool for linux/win without any graphical interface but file-controlled. I just got the german translated book about python from Himstedt/M?tzel. They tell about RedHat who built their installation-routine with python. Now I'd like to get more informations about that. We've got only SuSE-linux-distributions here, so I couldn't have a look at myself. At homepage of RedHat I found: ftp://ftp.redhat.com/redhat/old-releases/redhat-4.2/i386/RedHat/RPMS/glint-2.1.5-1.i386.rpm but the server was down (or something else?!)..;-( Is 'glint' the right thing I'm searching for? Is it with free source??? Thanx, Holger From mnot at pobox.com Tue Jun 22 07:09:41 1999 From: mnot at pobox.com (Mark Nottingham) Date: Tue, 22 Jun 1999 11:09:41 GMT Subject: htmllib: CR in CDATA References: <00d201bebc5a$adb129a0$0301a8c0@mnot.net> <012601bebc91$f3ded760$0301a8c0@mnot.net> Message-ID: <015701bebc9f$ba85b7a0$0301a8c0@mnot.net> And here's a go at a patch. Looking at the DTD, practically all attribute types are CDATA, and those that aren't shouldn't have tabs or newlines in them anyway. It uses string.translate; how efficient is this? *** /opt/local/lib/python1.5/sgmllib.py Thu Apr 15 00:54:11 1999 --- sgmllib.py Tue Jun 22 21:02:05 1999 *************** *** 38,43 **** --- 38,44 ---- '[%s]*([a-zA-Z_][-.a-zA-Z_0-9]*)' % string.whitespace + ('([%s]*=[%s]*' % (string.whitespace, string.whitespace)) + r'(\'[^\']*\'|"[^"]*"|[-a-zA-Z0-9./:+*%?!\(\)_#=~]*))?') + cdata_tr = string.maketrans('\t\n', ' ') # SGML parser base class -- find tags and call handler functions. *************** *** 251,256 **** --- 252,258 ---- elif attrvalue[:1] == '\'' == attrvalue[-1:] or \ attrvalue[:1] == '"' == attrvalue[-1:]: attrvalue = attrvalue[1:-1] + attrvalue = string.translate(attrvalue, cdata_tr, '\r') attrs.append((string.lower(attrname), attrvalue)) k = match.end(0) if rawdata[j] == '>': From mark at _spamspamlovelyspam_btweng.krakow.pl Fri Jun 18 14:00:52 1999 From: mark at _spamspamlovelyspam_btweng.krakow.pl (MK) Date: Fri, 18 Jun 1999 18:00:52 GMT Subject: Crawling Python References: <000601beb91d$e1321ae0$839e2299@tim> Message-ID: <376a1ac1.10261180@news.tpnet.pl> On Thu, 17 Jun 1999 20:02:39 -0400, "Tim Peters" wrote: >> PS. I have tried the same thing in DOS executable -- above does >> not happen. >Sure, and in return none of IDLE's history, undo/redo, searching, replacing, >scrolling or editing cmds work in a DOS box either . True, that's not what I meant, however -- whether it is Python or IDLE that is affected by the problem. Since Python itself is OK, no problem. Strangling IDLE continued: in DOS box I tried >>> s='' >>> for i in range(10000): ... s=s+`range(i,i+20)` ... >>> len(s) 1178515 and everything is OK. While the same loop in IDLE crashed it (I mean it hangs for some period, then it stops responding and has to be killed). MK -------------------------------------------------- Reality is something that does not disappear after you cease believing in it - VALIS, Philip K. Dick -------------------------------------------------- Delete _spamspamlovelyspam_ from address to email me postmaster at 127.0.0.1 root at 127.0.0.1 webmaster at 127.0.0.1 From tavares at connix.com Mon Jun 7 22:17:58 1999 From: tavares at connix.com (Chris Tavares) Date: Mon, 07 Jun 1999 22:17:58 -0400 Subject: COM Question - QueryInterface? Message-ID: <375C7D56.C9744E39@connix.com> I've got a (hopefully easy) question about python's COM support. I'm developing a COM object in C++ which implements the COM collection idiom - an Item method that returns another object. The code in Python I'm using is something like this: from win32com.client import Dispatch drives = Dispatch("AmAccess.Drives") drive = drives.Item("c:") dir = drive.Item("some-area") On this last line, I get an AttributeError for Item. I think I know the reason why - the interface returned from Drives.Item isn't a dual, it's an oleautomation compatible vtable interface. IDispatch on that object is implemented separately. So, PythonCOM sees the VT_UNKNOWN return type and wraps a PYIUnknown object around it. I need to be able to do a QueryInterface for IDispatch. How do I get Python to do that? There's a PyIID type, but apparently it only works for class or progids. Anyone got any suggestions? Thanks for any help, -Chris From gerrit.holl at pobox.com Tue Jun 22 09:36:58 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Tue, 22 Jun 1999 15:36:58 +0200 Subject: signal handler In-Reply-To: <376F87CB.DC3802E6@pk.highway.ne.jp>; from Thooney Millennier on Tue, Jun 22, 1999 at 09:55:39PM +0900 References: <376F87CB.DC3802E6@pk.highway.ne.jp> Message-ID: <19990622153658.A19393@optiplex.palga.uucp> On Tue, Jun 22, 1999 at 09:55:39PM +0900, Thooney Millennier wrote: > Newsgroups: comp.lang.python > Subject: signal handler > Date: Tue, 22 Jun 1999 21:55:39 +0900 > To: python-list at python.org > > import signal; > def func(arg1,arg2): > DO_SOMETHING_GOOD; > print "OK!"; > signal.signal(SOME_SIGNAL,func); > Why all those ';'s? groeten, Gerrit. -- The Dutch Linuxgames homepage: http://linuxgames.nl.linux.org Personal homepage: http://www.nl.linux.org/~gerrit/ Discoverb is a python program in Dutch and English which tests the words you learned by asking it. Homepage: http://www.nl.linux.org/~gerrit/discoverb/ From Darrell at p98.f112.n480.z2.fidonet.org Tue Jun 29 06:43:46 1999 From: Darrell at p98.f112.n480.z2.fidonet.org (Darrell) Date: Tue, 29 Jun 1999 11:43:46 +0100 Subject: run .py not in PATH Message-ID: <00001588@bossar.com.pl> From: "Darrell" #!/usr/bin/env python """ The .py you want to run is in the python path but not in your shell path. I know everyone but me already has this problem solved in a better way than this. If so please show me the way. Assuming this is runIt.py then runIt.py someScript.py arg1 arg2 """ import sys import imp fp, pathname, description = imp.find_module(sys.argv[1]) sys.argv=sys.argv[2:] md=imp.load_module('__main__', fp, pathname, description) From cfelling at iae.nl Thu Jun 24 18:45:39 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 25 Jun 1999 00:45:39 +0200 Subject: tkMessageBox returns 'can't invoke "frame" command:' error References: <7kktvv$550$1@nnrp1.deja.com> <7ku1l5$13q$1@vvs.superst.iae.nl> Message-ID: <7kucej$1aq$1@vvs.superst.iae.nl> Carel Fellinger wrote: > though I'm new to python and Tkinter myself, I think I know what the so, I'm new and reacted to soon > As for your error message complaining about the frame command not working > because the application has been destroyed, that's a little trickier. > Just where should I start... > First, Tkinter keeps track of the current Tk invocation using the var > Tkinter._default_root, initially this equals None, and upon invocing > Tk() it gets initialised. Unfortunately Tkinter doesn't reset this > var to None upon termination of Tk through an appropriate destroy()! > (maybe this should be considered a bug? who should know about it?) I know, I should have read the source. Or the docs. In Tkinter.py I found that Tk.destroy() *does* reset Tkinter._default_root when appropriate. But elas, this function doesn't get called when you press the window-close-button without having redefined the window-close protocol:(. Still a bug in my opinion, but a subtle one. The Tkinter C module (_tk) provides its own window-close handler. And this one, as can be read in Lund's excellent albeit slowly growing Tkinter Introduction docs, doesn't tidy-up the python/tk widget hiearchy. But even if it did, and according to Lund's docs in future versions it will, this wouldn't reset Tkinter._default_root to None. So all in all, just use rootWindow.destroy instead of rootWindow.quit as command for buttons used to end your script. And use rootWindow.destroy as the command for the window-close protocol (see Lund's docs). I sure hope I have it right this time:) -- groetjes, carel From robin at jessikat.demon.co.uk Fri Jun 11 13:52:18 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Fri, 11 Jun 1999 18:52:18 +0100 Subject: Embedded Tcl for Python References: <3760F0A1.1DDC@mailserver.hursley.ibm.com> Message-ID: In article <3760F0A1.1DDC at mailserver.hursley.ibm.com>, Paul Duffin writes >Michael P. Reilly wrote: >> >> A few weeks ago, someone asked if there was a Tcl module for Python. >> People responded (including myself) that Tkinter uses a Tcl/Tk >> interpreter, but you couldn't get rid of the annoying window. >> >> I've since written an extension ("pytcl") that creates Tcl interpreter >> objects. As part of that, I have also rewritten _tkinter to use these >> new objects. >> >> I've had a short discussion with Guido and he's interested in the >> idea. Now I need some alpha testers; I only have access to UNIX boxes, >> and very few types at that. >> >> The _tkinter module has the same functionality as before, including the >> same threading issues. I've include Deiter's Tcl/Tk8.1 patch but have >> not had the opportunity to test that yet (right not it is just do-no- >> damage). >> >> Contact me at arcege at shore.net if you are interested in helping me test >> these modules. >> > >I was interested in doing something similar in Tcl (e.g. creating a >python interpreter object) and I was wondering if someone could give >me some pointers as to how to go about doing it. > Paul I created a socket linked python interpreter and have used it with reasonable success from Tcl. Latest code is at http://www.jessikat.demon.co.uk in the file pyserver.zip this may not be as efficient as havin the in core thing, but gets round the problem of threading model problems etc. -- Robin Becker From news at dorb.com Thu Jun 24 14:09:53 1999 From: news at dorb.com (Darrell) Date: Thu, 24 Jun 1999 14:09:53 -0400 Subject: Environment inheritance under Windows NT 4, Attempt 2 References: Message-ID: Works fine for me. Use the same case for the python version. > C:\>python -c "import os; print os.environ['WINDIR']" -- --Darrell Milton L. Hankins wrote in message news:Pine.SGI.3.95q.990623204139.149495A-100000 at masox202... > Since I've not yet gotten a response to my first post, here's an > elaboration. > > Windows NT Workstation 4.00.1381, SP5. > > 1. Right click on My Computer, choose Properties, Environment tab. Note > the value of the System Variable "windir" and press Cancel. (On my > system, this is "C:\WINNT".) > > 2. Open a Command prompt. > > 3. Here's a transscript of my CMD session, you can follow along: > > ----------------------------------------------------- > C:\>echo %WINDIR% > C:\WINNT > > C:\>python -c "import os; print os.environ['windir']" > C:\WINNT > > C:\>set WINDIR=foo > > C:\>echo %WINDIR% > foo > > C:\>python -c "import os; print os.environ['windir']" > C:\WINNT > > ----------------------------------------------------- > > What is going on here? I wrote a program using VC5 to extract a variable > (1) directly from environ and _environ and (2) by calling getenv(). All > three reported "foo". (Source provided below.) > > After rummaging through the Python source, it appears that os.environ is > provided through the posix module, which in turn gets the environment data > from the "extern char** environ". > > Could this have something to do with Microsoft's run-time DLLs? I noticed > that Cygwin B19 used to exhibit this behavior as well, but it seemed to go > away in B20.1. > > Python picks up the environment correctly if I go into the Control Panel, > System, Environment, and click OK. But I have to do this each time I log > in to NT. > > > ---------------------------------------------------------------------- > #include > #include > #include > #include > > extern char** environ; > > #define BIG 80 > > > int envIndex(const char** envArray, const char* key) { > int i; > char keyPrime[BIG]; > > strcpy(keyPrime, key); > strcat(keyPrime, "="); > > > for (i = 0; envArray[i] != NULL; i++) { > if (strstr(envArray[i], keyPrime) == envArray[i]) { > break; > } > } > > return i; > } > > > // Don't screw with my return value... > const char* myGetEnv(const char** envArray, const char* key) { > int i; > > i = envIndex(envArray, key); > > if (envArray[i] == NULL) return NULL; > else return (envArray[i]+strlen(key)+1); > } > > > void printenvMulti(const char* key) { > char* s; > > s = myGetEnv(_environ, key); > if (s == NULL) printf("%s is not in _environ\n", key); > else printf("myGetEnv(_environ, \"%s\") --> %s\n", key, s); > > s = myGetEnv(environ, key); > if (s == NULL) printf("%s is not in environ\n", key); > else printf("myGetEnv(environ, \"%s\") --> %s\n", key, s); > > s = getenv(key); > if (s == NULL) printf("%s is not available to getenv()\n", key); > else printf("getenv(\"%s\") --> %s\n", key, s); > } > > > int main(int argc, char** argv) { > assert(argv[1] != NULL); > > printenvMulti(argv[1]); > return 0; > } > ---------------------------------------------------------------------- > > -- > Milton L. Hankins \\ ><> Ezekiel 18:21 ><> > Software Engineer, Raytheon Systems Company // > http://amasts.msd.ray.com/~mlh \\ RayComNet 7-225-4728 > > > From graham at sloth.math.uga.edu Thu Jun 3 11:21:44 1999 From: graham at sloth.math.uga.edu (Graham Matthews) Date: 3 Jun 1999 15:21:44 GMT Subject: Python 2.0 (perhaps off topic) References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> Message-ID: <7j66i8$il5$4@cronkite.cc.uga.edu> Paul Prescod (paul at prescod.net) wrote: : Personally, I wouldn't mind if Python ran on the JVM or had real GC. I : just think that both sides need to be told. Python is the way it is not by : accident but through design decisions intended to keep it simple to use : and embed. Why does having GC or implementing on top of the JVM make things more complex, or restrict embeddability? graham -- So I turned around And 40,000 headmen bit the dirt Firing twenty shotguns each And man it really hurt From schorsch at schorsch.com Wed Jun 16 19:17:26 1999 From: schorsch at schorsch.com (Georg Mischler) Date: Wed, 16 Jun 1999 23:17:26 GMT Subject: do anonymous pipes normally work on NT? References: <4D0A23B3F74DD111ACCD00805F31D8100DB90DE0@RED-MSG-50> Message-ID: <7k9b9u$2ti$1@nnrp1.deja.com> Bill Tutt wrote: > > > radbit at my-deja.com wrote: > > > > maybe I'm missing something about what you are looking for: > > here are 2 test scripts that work as anonymous pipes: > > > > That's not the question... > Anonymous pipes on NT work wonderfully. (just not > the way we're expecting from this particular Python context) Well, at least he solved *my* problem! And after fiddling a little, it even works with my cat.py as well, and should work with arbitrary child processes. I'll just have to steal a readline() method somewhere to make it practical... The Documentaion provided with VC++ about this stuff it not very helpful, so you have to try and guess. Here's what I figured by now: The CreateProcess() function has several ways to pass handles to child processes. The way I tried it (passing through StartupInfo.hStdXxx) only seems to work with disk files, and not with pipes. The other way is to assign the handles to the stdxxx of the current process, and inherit them to the child. This does work with pipes, and is fundamentally incompatible with the first approach. In fact, as soon as you just tell it you want to pass any handles in the StartupInfo, by assigning STARTF_USESTDHANDLES to it's dwFlags attribute, inheritance is dead. Still, if you *want* to pass (file) handles through the StartupInfo object, you nonetheless *need* to set the bInheritHandles parameter of CreateProcess() to TRUE. Go figure... The least obvious thing though, which I only found by comparing the working code with mine very carefully, is that for inheritance to work, the dwCreationFlags must *not* contain win32process.DETACHED_PROCESS. The VisualStudio docs (and consequently the win32proc help file) tell us that this would deny acess to the *console* of the parent process. In fact, it appears to cut all connections between the two processes. many thanks for everybody's assistance in figuring this out! > Calling SetStdHandle() is particularly silly as well, > you shouldn't need to overwrite the current stdout just > to get this to work. In fact, This is the way I saw it in several C++ examples by now, and my own observations make me think that it's just needed if you want to inherit *pipe* handles. > > win32file.WriteFile(std_out, 'this method works....') > > Calling GetStdHandle shouldn't be necessary either. The CRT > already grabbed that information for us when Python started up. > > The question is why does sys.stdout.write() not seem to work > without -u when In my latest experiments this *does* work if the parent process manages to get the handles across. CreateProcess() has so many mutually exclusive combinations of parameters that it's just hard to find the right ones for a particular purpose. I don't mind setting and resetting the std handles in the parent, as long as I get the result I want. But then, I'm also trying to get along with as little knowledge as possible about Windows programming. I assume you look at it from a slightly different angle. Thanks again to everybody! -schorsch -- Georg Mischler -- simulation developper -- schorsch at schorsch.com +schorsch.com+ -- lighting design tools -- http://www.schorsch.com/ Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From rozzin at geekspace.com Thu Jun 24 14:23:51 1999 From: rozzin at geekspace.com (Joshua Rosen) Date: Thu, 24 Jun 1999 14:23:51 -0400 Subject: How to obtain an instance's name at runtime? References: <7kqpu8$7u1$1@nnrp1.deja.com> <37718424.C70BB9DE@geekspace.com> <7ksgad$nvp$1@news.udel.edu> Message-ID: <377277B7.AC477B79@geekspace.com> Terry Reedy wrote: > As near as I can remember, only three types of objects have definition > names (in readonly? __name__ attributes): modules, functions, and > classes. All others are anonymous, though they may or may not have one > or more namespace references. > > While named objects usually get a namespace (reference) name equal to > the definition name, there is no necessary connection. Consider: > > def f(): pass > g=f > del f > > Now the function which internally thinks of itself as 'f' is referred to > externally as 'g' and only as 'g'. Yes, it makes sense for functions, classes, and modules to all have names, because they are all -definers-, which is what I think I was trying to say. Instances aren't `definers'--they don't act as the root of the definition for `what something is'. -Rozzin. From mwh21 at cam.ac.uk Fri Jun 11 09:44:44 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 11 Jun 1999 14:44:44 +0100 Subject: Python as a shared library on Unix References: <376102C9.5648@mailserver.hursley.ibm.com> Message-ID: Paul Duffin writes: > Is it possible to build Python itself as a small executable and a > shared library, rather than an archive library which of > course results in a monolithic executable. Not really. For a start look at http://x35.deja.com/[ST_rn=ps]/getdoc.xp?AN=468116075&CONTEXT=929108272.1543635130&hitnum=0 HTH Michael > I know how to get the modules built as shared libraries but cannot get > Python built as a shared library. > > -- > Paul Duffin > DT/6000 Development Email: pduffin at hursley.ibm.com > IBM UK Laboratories Ltd., Hursley Park nr. Winchester > Internal: 7-246880 International: +44 1962-816880 From hinsen at cnrs-orleans.fr Mon Jun 7 04:31:17 1999 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 07 Jun 1999 10:31:17 +0200 Subject: problem with static linking References: Message-ID: Xiaohong Yuan writes: > I am working on Python c extensions on QNX. Since QNX doesn't support > dynamic linking. I have to link my c extension module staticly with python > interpreter. But in my c extension module, I have external variable > declaration, which makes it fail to be linked with Python interpreter. > There must be some way to solve this, could anybody help me with this? Why do you need the external declaration? Where is this external variable ultimately defined? -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From m01ymu00 at cwcom.net Sat Jun 12 15:41:27 1999 From: m01ymu00 at cwcom.net (Daniel Faulkner) Date: Sat, 12 Jun 1999 20:41:27 +0100 Subject: Browsers Message-ID: <3762B7E7.CB001E3D@cwcom.net> I have just been messing around with some network modules and I was wondering how you would go about turning HTML into a basic picture (you know just get rid of the HTML tabs make some of the writing bold and include some spaces/center it nothing to hard or complicated) I have messed around with some of the parsers but they don't seem to make a huge difference. Any tips? Dan From hniksic at srce.hr Wed Jun 2 17:37:09 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 02 Jun 1999 23:37:09 +0200 Subject: pickle vs .pyc References: <7j43pn$55l$1@mlv.mit.edu> Message-ID: <87vhd69tdm.fsf@pc-hrvoje.srce.hr> Michael Hudson writes: > Random aside: something fishy's going on when I try to try to marshal > *arrays* (as opposed to mere lists): The documentation for marshal says: Not all Python object types are supported; in general, only objects whose value is independent from a particular invocation of Python can be written and read by this module. The following types are supported: `None', integers, long integers, floating point numbers, strings, tuples, lists, dictionaries, and code objects (...) From thstr at serop.abb.se Wed Jun 9 09:45:07 1999 From: thstr at serop.abb.se (Thomas S. Strinnhed) Date: Wed, 09 Jun 1999 15:45:07 +0200 Subject: Python/C API and setattr References: Message-ID: <375E6FE3.A5CDA87@serop.abb.se> Hi, Thank you for a fast response. Moshe Zadka wrote: [my original message] > You should return Py_None from a function. Every function called by > Python has the following prototype: > PyObject *f(PyObject *self, PyObject *args) > (Actually, this is a lie. But a small white Knuth one) > -- > Moshe Zadka . > QOTD: My own exit is more likely to be horizontal then perpendicular. Well I thought so too, but actually it must be something else, cause it doesn't go away!! static PyObject *counter_setattr(counterobject *self, char *name, PyObject *v) { if(strcmp(name, "value") == 0) { self->value = (int)PyInt_AsLong(v); Py_INCREF(Py_None); return Py_None; } Py_INCREF(Py_None); return Py_None; } Just doesn't help!! Could there be something about this line; self->value = (int)PyInt_AsLong(v); (self->value is an int and v is PyObject*) And about the prototype: The few examples I've found about setattr are just like I've used it: compare my prototype static void counter_setattr(counterobject *self, char *name, PyObject *v) with this one from Objects\xxobject.c static int xx_setattr(xxobject *xp, char *name, PyObject *v) I think my main question would be: Where to find detailed documentation/information about this? and subquestion asked standing on my bare knees (?? :-) What's happening here?? (Here beeing my code) Admit it's tricky?? Many Thanks -- Thomas S. Strinnhed, thstr at serop.abb.se From akuchlin at mems-exchange.org Fri Jun 4 13:37:16 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: Fri, 4 Jun 1999 13:37:16 -0400 (EDT) Subject: Python 2.0 In-Reply-To: <7j90va$6lk$1@cronkite.cc.uga.edu> References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7j90va$6lk$1@cronkite.cc.uga.edu> Message-ID: <14168.3788.596777.267373@amarok.cnri.reston.va.us> Graham Matthews writes: >I have no plans to implement a GC for Python. I have already implemented >enough standard collectors for one lifetime. Besides which someone far >more intimate with the implementation details of Python would take less >time. That's not a cop out. I just don't have the time. Someone once added full GC to Python by adding a separate garbage collector thread, at the cost of a sizable speed hit and requiring threads. That might at least prove a good starting point, and perhaps some optimization work could make it a practical proposition. Unfortunately I'm unable to pull up any postings in DejaNews with a pointer to the code (though I can get the previous GC flamewar). I vaguely recall the code was on a host in .hr, but can't track it down. Anyone remember that -- A.M. Kuchling http://starship.python.net/crew/amk/ I want to know the truth, however perverted that may sound. -- Stephen Wolfram From arcege at shore.net Tue Jun 22 09:43:12 1999 From: arcege at shore.net (Michael P. Reilly) Date: Tue, 22 Jun 1999 13:43:12 GMT Subject: Creating a new type with an extension module References: Message-ID: Sion Arrowsmith wrote: : In article , : Sion Arrowsmith wrote: :>http://www.python.org/doc/current/api/newTypes.html is unhelpful :>in the extreme -- do I have to resort to reading source? : It appears that I do, but thanks to everyone who pointed me in : the direction of suitably readable source. I've got what I : wanted working -- it would just be nice to understand why it : works.... Mark Lutz's _Programming Python_ book explains this quite well (I still use these parts today in fact). He has two chapters on embedding and extending Python. But the documentation on extending Python is pretty well known deficiency. Luckily it is far easier than most languages, both to accomplish and to understand (yet more kudos to Guido). Actually, in responce to your earlier posting, I started writing a _SHORT_ webpage explaining what is needed, which I hope to have available later today. I plan (and hope) to make it into a How-To later. -Arcege From graham at sloth.math.uga.edu Wed Jun 2 16:39:49 1999 From: graham at sloth.math.uga.edu (Graham Matthews) Date: 2 Jun 1999 20:39:49 GMT Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <87n1ykr0z9.fsf@ev.netlab.co.jp> <7ivs9q$dc5@news.dns.microsoft.com> <87k8toqv70.fsf@ev.netlab.co.jp> Message-ID: <7j44ql$908$1@cronkite.cc.uga.edu> Aahz Maruch (aahz at netcom.com) wrote: : In addition to Paul's excellent comments, if one is writing an : interactive process, one cannot afford the unpredictability of random : garbage collection. Garbage collection could run in a thread, but then : one is restricted to environments where threads are well-supported. You appear to be making an argument like "when a GC occurs the system pauses, and this is bad in an interactive environment". If that's the case then this is an old chestnut. Modern GC implementations do not have such pauses. Look up papers on real-time garbage collection for example. graham -- Like a bird on a wire Like a drunk in a midnight choir I have tried in my way To be free From hjstein at bfr.co.il Tue Jun 15 17:46:56 1999 From: hjstein at bfr.co.il (Harvey J. Stein) Date: 16 Jun 1999 00:46:56 +0300 Subject: OO (was: Why is tcl broken?) References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> <3762988E.C94AA252@iname.com> <3763C746.5CA8FE78@iname.com> <87pv2zjhhl.fsf@home.ivm.de> <3764F3FE.F7CBE6BA@acm.org> <0Sgs3BA5FPZ3Ew6E@jessikat.demon.co.uk> <3765B3B8.E45F373B@spots.ab.ca> Message-ID: wtanksle at dolphin.openprojects.net (William Tanksley) writes: > On Tue, 15 Jun 1999 01:54:53 GMT, Maxwell Sayles wrote: > >Robin Becker wrote: > > >> postfix, prefix, infix etc etc are isosemantic > > >for myself and the others who might not know... can we get an example of > >each? > >and i remember someone mentioned parenthesized vs non-parenthesized... > > Infix (ML and Prolog): > > 3 + (4 minus 10) == 1 > (parenthesis are not optional) > > Prefix (C, Lisp, Scheme): > > function(that(x(1))) > or: > (do-this (do-that (x 1))) > (Parenthesis are not optional) > > Postfix (Forth, Postscript): > > 3 4 + SWAP MOD do-that > rinse on agitate 10 seconds rinse off > (Parenthesis are not optional) > > As a common thread, note that in none of the languages are parenthesis > optional. In Postfix parenthesis are not optional because they have nno > meaning; in the other languages they're assigned arbitrary meaning. This isn't a completely fair example. Postfix can get away without parentheses only when a) everything that's not a number is a function and b) the arity (# of arguments) of each function is known and fixed. Given such restrictions one can also drop the parentheses in prefix notation. Infix still requires parentheses even given the above restrictions. -- Harvey J. Stein Bloomberg LP hjstein at bfr.co.il From wtanksle at dolphin.openprojects.net Mon Jun 14 19:07:06 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Mon, 14 Jun 1999 23:07:06 GMT Subject: OO (was: Why is tcl broken?) References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> <3762988E.C94AA252@iname.com> <3763C746.5CA8FE78@iname.com> <87pv2zjhhl.fsf@home.ivm.de> Message-ID: On 14 Jun 1999 21:31:47 +0200, Stig Hemmer wrote: >> Prefix rocks, infix is crap. >(think I (meant you (and (rocks prefix) (is-crap infix)))) prefix rocks infix crap is and false = ...as long as we're fighting... :-) >Stig Hemmer, >Jack of a Few Trades. (I like all the languages I know, except Fortran. I even like C++, although I wish they could break backwards compatibility.) -- -William "Billy" Tanksley Utinam logica falsa tuam philosophiam totam suffodiant! :-: May faulty logic undermine your entire philosophy! From catlee at my-deja.com Wed Jun 23 14:04:10 1999 From: catlee at my-deja.com (catlee at my-deja.com) Date: Wed, 23 Jun 1999 18:04:10 GMT Subject: total idiot question: +=, .=, etc... References: <877lov62z1.fsf@pbl.ddns.org> Message-ID: <7kr7ii$dss$1@nnrp1.deja.com> > |>> vim 5.x version.) > | > |:map! += ^[:s/\([a-zA-Z_][a-zA-Z0-9_]*\)$/\1=\1+/^M:noh^MA > | > |Where ":" means go into vim Commandmode > | "^[" means Esc, you have to enter it pressing Ctrl-v and then Esc > | "^M" means "Return', you have to enter pressing Ctrl-v and then Return I've got the following in my .vimrc file: au BufReadPost * if b:current_syntax == "python" au BufReadPost * map! += ^[:s/\(\S*\)$/\1=\1+/^M:noh^MA au BufReadPost * endif What this does is check to see if the current syntax is python. The mapping hopefully covers more complex expressions than yours does, it takes all the previous non-whitespace characters as the expression to copy. I wonder if there's a way to use the vim syntax parsing mechanism to determine what an expression is? Cheers, Chris Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From gherman at my-deja.com Wed Jun 2 05:49:34 1999 From: gherman at my-deja.com (Dinu C. Gherman) Date: Wed, 02 Jun 1999 09:49:34 GMT Subject: Pictures of JPF1 available Message-ID: <7j2und$fp9$1@nnrp1.deja.com> Hello, please have a look at a few pictures I've taken during the JPF1 French Python meeting last week-end in Paris. Guido and Aaron were there, plus others. The page below will also provide some comments about how the pictures were taken. http://starship.python.net/crew/gherman/photography/jpf1/ Enjoy, Dinu -- Dinu C. Gherman : Mit Berlin kannste mir jagen! ................................................................ LHS International AG : http://www.lhsgroup.com 8050 Zurich : http://www.zurich.ch Switzerland : http://pgp.ai.mit.edu : mobile://49.172.3060751 ......................:......................................... Vote against SPAM on http://www.politik-digital.de/spam Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From Lyle.Johnson at p98.f112.n480.z2.fidonet.org Wed Jun 30 23:43:05 1999 From: Lyle.Johnson at p98.f112.n480.z2.fidonet.org (Lyle Johnson) Date: Thu, 01 Jul 1999 04:43:05 +0100 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? Message-ID: <0000160e@bossar.com.pl> From: Lyle Johnson Kevin, Right now each instance has its own copy of the message table, and this is set up in the class constructor. But I would prefer that the message table data belonged to the class itself (as it is in the C++ FOX, static class data). Lyle Kevin Dahlhausen wrote: > Lyle Johnson wrote: > > >Just to add fuel to the fire, we now have a Python interface to FOX, a > >cross-platform GUI toolkit: > > > > http://www.cfdrc.com/pub/FOX/fox.html > > How did you get around the requirement of preprocessor > table definitions for message handlers? > > (I'm downloading it now....) From paul at polariscomm.com Thu Jun 10 18:56:48 1999 From: paul at polariscomm.com (Paul Stillwell) Date: Thu, 10 Jun 1999 15:56:48 -0700 Subject: tkinter and events Message-ID: <7oX73.898$q3.114540@news21b.ispnews.com> Ok, I am missing some critical piece of information so maybe someone out there can help me. I want to be able to click on an object on the canvas and reference variables within that object, but I am not sure how to do it. When I try it, I always get the values from the last object of that type that I created. For example, I have the following code: from Tkinter import * from Canvas import * class MyTestObject: def __init__(self, Parent, Domain, State): self.Parent = Parent self.Domain = Domain self.State = State self.Canvas = Parent Distance = 5 self.x = 370 self.y = 30 + (Distance * Domain) self.Begx = self.x - 320 self.Begy = self.y - 10 self.Endx = self.x + 320 self.Endy = self.y + 10 self.Box = Rectangle(Parent, self.Begx, self.Begy, self.Endx, self.Endy) self.text = CanvasText(Parent, self.x, self.y, text = "Domain = %x, State = %s" % (Domain, State)) self.Canvas.bind('', self.DoubleClickHandler) def DoubleClickHandler(self, event): print "Clicked on domain %x" % self.Domain class Demo(Frame): def __init__(self, parent = None): Frame.__init__(self, parent) self.pack(fill = BOTH, expand = YES) self.Canvas = Canvas(self, width = "7.5i", height = "6i", background = "white", scrollregion = (0, 0, "7.5i", "100i")) self.Canvas.ScrollY = Scrollbar(self, orient = VERTICAL) self.Canvas['yscrollcommand'] = self.Canvas.ScrollY.set self.Canvas.ScrollY['command'] = self.Canvas.yview self.Canvas.ScrollY.pack(side = RIGHT, fill = Y) self.Canvas.pack(side = RIGHT, fill = BOTH, expand = YES) and I do the following at the Python command prompt (tester is the module I created that has the above code): Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> from tester import * >>> root = Tk() >>> app = Demo(root) >>> o1 = MyTestObject(app.Canvas, 0x10, 50) >>> o2 = MyTestObject(app.Canvas, 0x20, 70) So, when I run the code and double click on o1, I get: >>> Clicked on domain 20 which is the last object I created even though I double clicked on the first object. What am I doing wrong? Please help! Paul paul at polariscomm.com From panakal at bigfoot.com Fri Jun 4 19:31:30 1999 From: panakal at bigfoot.com (ADP) Date: Fri, 4 Jun 1999 16:31:30 -0700 Subject: Python 1.5 help References: <7j6uht$q1tk@eGroups.com> Message-ID: <7j9nhk$6sd$1@news.fm.intel.com> O'Reilly publishing has a fairly recent book called 'Learning Python' that is an extremely readable introduction to the language. It also has good further references. From hyoon at bigfoot.com Thu Jun 10 15:03:31 1999 From: hyoon at bigfoot.com (Hoon Yoon) Date: Thu, 10 Jun 1999 15:03:31 -0400 Subject: IDLE interacting w Shell Message-ID: <37600C03.A5B4FE28@bigfoot.com> Hi, I am trying to use IDLE somewhat like Emacs. I can't use Emacs because some of Numpy Code will stop and kill the shell on Emacs when certain errors occur. Not to mention IDLE is a lot lighter. Every time I hit F5 or 'Edit|Run module' I get an output window. I want to get the run results and direct to shell like Emacs' C-c C-c, instead of getting an output window. for exaple: if I have following in Editor and press F5 import os I would like to see following working on the shell: >> dir(os) Any help would be much appreciated! -- ***************************************************************************** S. Hoon Yoon (Quant) Merrill Lynch Equity Trading, yelled at yahoo.com hoon at bigfoot.com(w) "Miracle is always only few standard deviations away, but so is catastrophe." * Expressed opinions are often my own, but NOT my employer's. "I feel like a fugitive from the law of averages." Mauldin ***************************************************************************** -------------- next part -------------- A non-text attachment was scrubbed... Name: vcard.vcf Type: text/x-vcard Size: 202 bytes Desc: Card for Hoon Yoon URL: From arcege at shore.net Mon Jun 21 17:39:31 1999 From: arcege at shore.net (Michael P. Reilly) Date: Mon, 21 Jun 1999 21:39:31 GMT Subject: while(s=infile.readline()): # reading input References: <376EA6E2.4E5EE527@starvision.com> Message-ID: Angus MacKay wrote: : why can't I have syntax like this? : python is written in C after all isn't it? : this works fine: : while infile.readline(): : print "Hi!" : this doe not: : while s = infile.readline(): : print s : which is okay, but alas this does not work: : while(s=infile.readline()): : print s : is there any way to avoid using the ugly: : while 1: : s = infile.readline() : if not s: break : print s Please read the FAQ 6.30 "Why can't I use an assignment in an expression?" (http://grail.cnri.reston.va.us/cgi-bin/faqw.py?req=show&file=faq06.030.htp). You can also read numerous discussions on this question from past years on Dejanews (http://www.dejanews.com/). As for your other question about chomp; this question was also asked in this newsgroup a year or two ago, you can probably find that discussion on Dejanews as well. One basic answer is the difference between CISC and RISC: CISC stands for "complex instruction set computer" and RISC is "reduced instruction set computer". Perl is CISC-oriented, and has specialized functions and operations like chomp(); Python is RISC-oriented, giving you a simplier, more flexible language, at the perceived expense of not having "nifty functions." For that reason and many, many others, "things" like assignment expressions and specialized core language constructs just aren't there in Python (there are always exceptions tho). Then there is Python 2.0 coming in the future (don't ask when); and we trust Guido not to make the mistake of Perl5. -Arcege From tcpeter at my-deja.com Tue Jun 8 19:27:13 1999 From: tcpeter at my-deja.com (tcpeter at my-deja.com) Date: Tue, 08 Jun 1999 23:27:13 GMT Subject: In what order does Python read dictionary keys? References: <7jjnt5$snk$1@nnrp1.deja.com> <375D8077.EA539C6D@pop.vet.uu.nl> Message-ID: <7jk8s8$3ma$1@nnrp1.deja.com> In article <375D8077.EA539C6D at pop.vet.uu.nl>, M.Faassen at vet.uu.nl wrote: > tcpeter at my-deja.com wrote: >> when I ran the code, the options were presented > > in the desired order. (A trifle creepy, if you ask me. Turing would be > > delighted.) Anyway, how does Python decide the order. Thanks. > > Hi there, > > The answer is that Python doesn't have any set orders for dictionaries. > The internal hashing algorithm the python dictionary uses has no > guaranteed order. So basically you shouldn't depend on any particular > order it produces. OK. So is there a way to ensure a specific order? In this instance I've given it's not particularly critical, but there are times where it might be. Any ideas? Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From cmedcoff at my-deja.com Sun Jun 6 10:30:47 1999 From: cmedcoff at my-deja.com (cmedcoff at my-deja.com) Date: Sun, 06 Jun 1999 14:30:47 GMT Subject: Looking for for some ideas for argument processing References: <7jcdhc$htd$1@nnrp1.deja.com> <3759A481.135D19CF@arlut.utexas.edu> Message-ID: <7je0mn$v7d$1@nnrp1.deja.com> I didn't even know that was there. Still a newbie I guess. I also just realized I can simulate a C-style for loop using a while loop in Python. Silly me.. Regards, Chuck Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From tim_one at email.msn.com Tue Jun 15 01:28:57 1999 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 15 Jun 1999 01:28:57 -0400 Subject: fork() In-Reply-To: Message-ID: <000901beb6ef$f73c0f60$069e2299@tim> [Hisao Suzuki] > ... > [quoting Stroustrup] and in the C++ 3rd Ed. (1997): > "When an object is about to be recycled by a garbage > collector, two alternatives exist: > [1] Call the destructor (if any) for the object. > [2] Treat the object as raw memory (don't call its > destructor). > By default, a garbage collector should choose option (2) > because objects created using _new_ and never _delete_d are > never destroyed. Thus, one can see a garbage collector as a > mechanism for simulating an infinite memory." (C.9.1.3 > Destructors) > > Python's __del__ is conceptually equivalent to C++'s destructor. This is true, but Python has nothing equivalent to the C++ "delete" operator, and *everything* in Python acts as if it had been created by the C++ "new" operator. Stroustrup is only talking about C++ objects explicitly created by "new" but never explicitly destroyed by "delete". C++ has several other ways for objects to come in and out of existence that don't involve "new" or "delete" (block-scope auto; static; anonymous temps in expressions), and rigidly defines when destructors are invoked for those (more rigidly than Python, which actually opens some uses for destructors in C++ that can't quite be done in Python). > (Otherwise we would not rely on self.close() at __del__ in > Lib/tempfile.py!) The above phrase `(be) never deleted' for C++ > can be safely translated as `(be) part of cycles' for Python. > Thus, Guido's idea is quite consistent and orthodox in this > regard. If there's an analogy to be drawn here, it would be that since everything in Python acts as if created by C++ "new" and can never by explicitly destroyed, Stroustrup is arguing that Python should never invoke a destructor period. The contexts are so different, though, that this analogy is as silly as it sounds . As a practical matter, there's a universe of difference between a user explicitly forcing heap-based storage via C++ "new" and a Python programmer who happens to create a cycle by design or accident. For example, the former is apparent via static inspection of program text, while the latter is impossible to determine statically. > It will be acceptable to most of the current working Pythoneers, > including me, even if they are not fans of the Lots of Intolerable Stupid > Parentheses ;-) But now you're getting *really* practical . I'm still most concerned that (besides it being an incoherent mess <0.9 wink>) objects that aren't themselves in a cycle may nevertheless by reachable only from an unreachable cycle, and in that case it seems intolerable to say the (in Evan's nice turn of phrase) "dangly bits" won't have destructors invoked either. "Well, sure, open file objects get closed by magic -- unless they happen to be buried in some object reachable only via an unreachable cycle." That's a true stmt today, and not sure there's real gain if it continues to be true tomorrow. > By the way, C++'s destructor and Python's __del__ have been > proved useful in practice, particularly in conjunction with the > `resource acquisition is initialization' technique. On the > other hand, such a finalizer as found in Java is almost useless > and unreliable because of its unpredictability. I have never > made use of finalize() in Java for years, and I don't know any > skilled Java programmer substantially making use of finalize(). All different mechanisms, though. Useful in C++ because block-scope autos are reliably destructed upon block exit, and at least current C++ rigidly defines the order in which they're destructed (so cyclic autos have *some* ground to stand on). Useful in Python because RC gets close to the same effect (but less flexibly & less reliably). > Further the C++ 3rd Ed. says: > "It is possible to design a garbage collector to invoke the > destructors for objects that have been specifically > `registered' with the collector. However, there is no > standard way of `registering' objects. Note that it is > always important to destroy objects in an order that ensures > that the destructor for one object doesn't refer to an > object that has been previously destroyed. Such ordering > isn't easily achieved by a garbage collector without help > from the programmer." Java solved that one -- for all the good it did . > All in all, we need a sort of control or programmability over > the behavior of our programs when a fixed, built-in mechanism of > the language cannot solely address the problem very well. > Suppose that Python recycles the memory of unreachable cycles of > objects without calling __del__. What if cycles that contain > `registered' objects are saved from deallocation so that > clean-up or other arbitrary actions can be performed? > > Such an action will break, say, an unreachable doubly-linked > tree into separated nodes. Then the nodes will be destroyed by > a normal process including invocations of __del__. To make this > occur, > (a) the programmer must register the root of the tree with a > function to break up the tree, which will be invoked later > automatically by the garbage collector, or > > (b) the programmer must register the root of the tree, and at > certain point of the program she/he must explicitly invoke > a function which retrieves the trees unreachable except > from the `registration' server and breaks them up. > > (In any case, unreachable trees that contain no `registered' > objects will be recycled with no invocations of __del__.) > > I am not sure which option is more useful in practice, but > either of them would be acceptable since they are entirely > optional and compatible with the current semantics of Python. > With no zapping in the formal semantics, they are conceptually > clean and their implementations will be straightforward (thus > they are also very Pythonic ;-) I'm getting very keen on *some* scheme that gives motivated users control over what happens when dead cycles are found, but Guido really wants to track only dicts and handing the user a list/enumeration of disembodied dicts isn't giving them much to work with . > As for a reference to option (b), see, say, R. Kent Dybvig's > ftp://ftp.cs.indiana.edu/pub/scheme-repository/doc/pubs/guardians.ps.gz > which I have mentioned before in this newsgroup, though it is > written for Scheme and actually the coming version of GNU guile > implements guardians, i.e. `registration' servers described in > it. Indeed a very general mechanism! Combining it with sensible __del__ rules for non-cycles could well lead to something better than Scheme and Python <0.5 wink>. > Note that the guardians may be implemented somehow in 100% > pure Python even if it doesn't have a garbage collector. The > sys.getrefcount built-in function will be used then. Don't think so. Knowing the refcount doesn't tell you whether a thing is trash, e.g. class A: pass a = A() a.seq = [a] * 1000000 del a and there's no general way to trace the objects reachable from a given object without a protocol for the reachable objects to cooperate in revealing who is directly reachable from them (it can be laboriously accomplished for objects of builtin types now by exploiting deep knowledge of the way they happen to be implemented, but toss in an extension type and you're dead). In any case, implementing M&S in Python is even slower than implementing it in C . much-ado-over-garbage-ly y'rs - tim From jan at q-bus.de Tue Jun 8 06:59:35 1999 From: jan at q-bus.de (Jan Walter) Date: Tue, 8 Jun 1999 10:59:35 GMT Subject: I'll pay $40 in e-gold if you'll fix this bug. References: <7jigrv$ppo$1@xs3.xs4all.nl> Message-ID: <375CF797.FF0D6436@q-bus.de> Hi, Maybe you get confused a bit by the bash!!! Try following: bash$ tcsh tcsh: cd /tmp/ tcsh: mkdir dirOne tcsh: mkdir dirTwo tcsh: mkdir dirTwo/dirThree tcsh: ln -s dirTwo/dirThree/ . tcsh: cd dirThree/ tcsh: pwd /tmp/dirTwo/dirThree Do the same with the bash (removing the directories of course): bash$ cd /tmp/ bash$ mkdir dirOne bash$ mkdir dirTwo bash$ mkdir dirTwo/dirThree bash$ ln -s dirTwo/dirThree/ . bash$ cd dirThree/ bash$ pwd /tmp/dirThree The tcsh gives the right answer. You are in the /tmp/dirTwo/dirThree directory. If you try to move a file with "mv file.txt ../dirOne/file.txt" you can?t do that because there is no directory dirOne !!! Python works like tcsh. If you try the following you get the right answer: bash$ cd /tmp/dirThree/ bash$ python Python 1.5.1 (#1, May 6 1998, 01:48:27) [GCC 2.7.2.3] on linux-i386 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import os >>> os.getcwd() '/tmp/dirTwo/dirThree' My suggestion: You can test if there are symbolic links in your path (e.g. os.path.islink("/tmp/dirThree") within Python) or you can prove that /tmp/dirThree is in reality /tmp/dirTwo/dirThree and life with that fact ... Cheers, Jan From Klaus.Schilling at home.ivm.de Tue Jun 22 04:05:12 1999 From: Klaus.Schilling at home.ivm.de (Klaus Schilling) Date: 22 Jun 1999 10:05:12 +0200 Subject: need some fast balanced-tree datastructure References: <376ED372.FA73994F@cs.ucsd.edu> Message-ID: <874sk0k6dj.fsf@home.ivm.de> Pavel Velikho writes: > Hi, > I am looking for a fast implementation of incremental container that > > maintains an ordering on the keys... (i.e. I want an AVL, Red-Black, or > anything similar). I have tried the b+tree in Python but its not fast > enough. > Is there anything like that available as a C extension module? There is an avltree implementation in C by Ben Pfaff on the gnu ftp site ftp.gnu.org/pub/gnu . Maybe this can be swigged to python. Klaus Schilling From Angus.MacKay at p98.f112.n480.z2.fidonet.org Tue Jun 29 01:57:39 1999 From: Angus.MacKay at p98.f112.n480.z2.fidonet.org (Angus MacKay) Date: Tue, 29 Jun 1999 06:57:39 +0100 Subject: clobbering Message-ID: <0000158f@bossar.com.pl> From: Angus MacKay is there any way to get python to warn you when you clobber a function refrence with a variable? I was writing this and it vexed me for some time: for dir in sys.path: dir(...) ... it is silly user error but a flag to say warn if clobbering functions with variables (or at lease builtin functions). cheers, Angus. From Newbie at p98.f112.n480.z2.fidonet.org Tue Jun 29 20:55:49 1999 From: Newbie at p98.f112.n480.z2.fidonet.org (Newbie) Date: Wed, 30 Jun 1999 01:55:49 +0100 Subject: Decent Tutorial Message-ID: <000015af@bossar.com.pl> From: "Newbie" <8499 at greenhead.ac.uk> Where can I find a decent tutorial which is for beginners to Python, preferably including some documented source code and avaliable for download. Thanks. From wtanksle at dolphin.openprojects.net Thu Jun 3 23:07:53 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Fri, 04 Jun 1999 03:07:53 GMT Subject: All this self dot is making me... References: Message-ID: On Wed, 2 Jun 1999 01:59:35 -0700, Jim Rudnicki wrote: >To the beginner, having to type all these self. 's in class methods seems a >bit painful. So all three of these methods below do the same thing. That >For those of us who have less cartilage left in their hands, would it be >acceptable to use "my." or better "me." Or is self. strongly ingrained? >The two less characters add up and the keys are on stronger fingers. It's absolutely acceptable to use something else. It's good to make it clear, so "self" is the best, "this" works well, "me" and "my" are fine, and "snowman" is abominable. The reason you don't want to use external functions is that object orientation doesn't work on them -- you can't override them. >Jim -- -William "Billy" Tanksley Utinam logica falsa tuam philosophiam totam suffodiant! :-: May faulty logic undermine your entire philosophy! From zigron at jps.net Sun Jun 20 23:05:41 1999 From: zigron at jps.net (Zigron) Date: Sun, 20 Jun 1999 20:05:41 -0700 Subject: python15.dll Message-ID: <1%hb3.804$o7.114638@typhoon-sf.snfc21.pbi.net> Can it be obtained /alone/, without the rest of the distribution? I goofed, and it got screwed. I'm lazy, don't wanna download the whole 5meg distrib :) Thanks! --Stephen, who goes back to desperately trying to uncross his eyes as he works with non-existing c/c++ knowledge to build a wxWindows add-on into it, then SWIGify it into Python. ugh! Shoot me? From rdev at my-deja.com Wed Jun 30 14:02:46 1999 From: rdev at my-deja.com (rdev at my-deja.com) Date: Wed, 30 Jun 1999 19:02:46 +0100 Subject: Reflection in Python? Message-ID: <000015c8@bossar.com.pl> From: rdev at my-deja.com In article <7ldglr$ita$1 at nnrp1.deja.com>, anders777 at my-deja.com wrote: > ...How do I do the > equivalent of what Java calls reflection? I want > to do the following: > > test = MathTest("testAdd") > > where test.run() will run the "testAdd" method on > the MathTest object? I also want to be able to > tell the user the name of the object (MathTest) > and the method in case the method fails. Any > thoughts? > If I understand what you are trying to do, it's easy in Python. Assuming MathTest is an object instance: test = MathTest.testAdd will return you a bound method object which you can then call as: test() Getting the name of the object class and method is also easy. There are several ways to do this: 1) Define a doc string within the method by putting a quoted string as the first line under the def line. You can then refer to it as "test.__doc__". This could say, for example, "Method bar of class foo". 2) "test.__name__" will return the name of the method. "test.im_class.__name__" will return the name of the class that the method is defined within. Example: class MathTest: def testAdd(self, parm1, parm2): "Method testAdd of Class MathTest" result = parm1 + parm2 return result <<< mt = MathTest() <<< test = mt.testAdd <<< test.run(2,2) 4 <<< print test.__doc__ Method testAdd of Class MathTest <<< print test.__name__ testAdd <<< print test.im_class.__name__ MathTest I hope that helps. - Roger Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From Johann.Spies at p98.f112.n480.z2.fidonet.org Wed Jun 30 04:14:49 1999 From: Johann.Spies at p98.f112.n480.z2.fidonet.org (Johann Spies) Date: Wed, 30 Jun 1999 09:14:49 +0100 Subject: Please help me to understand classes Message-ID: <000015ab@bossar.com.pl> From: Johann Spies On Tue, 29 Jun 1999, Stidolph, David wrote: > Finally, a simple question I can answer! > > First of all, class methods like "druk" need to have a parameter declared in > them called self (or whatever you want to call it). Secondly you need to > call the method with open/close parens: > > class A: > def druk(self): > print 'Jy is in Class A' > > class B: > def druk(self): > print 'Jy is in Class B' > > a = A() > c = B() > c.druk() > Jy is in Class B > a.druk() > Jy is in Class A > > I hope this helps, Thanks David. It helped. After your message I went back and read the tutorial again and saw what you mean. Johann -------------------------------------------------------------------------- | Johann Spies Windsorlaan 19 | | jhspies at futurenet.co.za 3201 Pietermaritzburg | | Tel/Faks Nr. +27 331-46-1310 Suid-Afrika (South Africa) | -------------------------------------------------------------------------- "Because he himself suffered when he was tempted, he is able to help those who are being tempted." Hebrews 2:18 From arcege at shore.net Wed Jun 30 11:04:54 1999 From: arcege at shore.net (Michael P. Reilly) Date: Wed, 30 Jun 1999 15:04:54 GMT Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> <3773c3a0.102825445@news.oh.verio.com> <00f701bec212$f6a83050$f29b12c2@secret.pythonware.com> Message-ID: Fredrik Lundh wrote: : Michael P. Reilly wrote: :> But.. the argument over (these two) GUIs is not exactly a valid one. :> Tkinter was written using the Tcl interface not the Tk/C API. If :> Tkinter was rewritten to use the C API, it probably wouldn't be slower :> than wxPython. : The interface is only part of the story; many complaints : seem to come from the fact that Tk uses idle tasks to : redraw things. When an "expose" event arrives from : the windowing system, Tk calls "after_idle", rather : than redrawing the widget at once. And idle tasks : are only executed when there are no other events : to take care of... Hmm... something about that argument makes it circularly invalid. Non-idle event a comes in, but must be handled after idle event d. Event d can only execute when event a is taken care of. Sounds like deadlock to me. ;) Events (from Tk_MainLoop) are handled by Tcl_QueueEvent and Tcl_ServiceEvent (handled by Tcl_DoOneEvent). Yes, it handles idle events IF those are the only ones being requested to be serviced: (taken from tcl8.0.5/generic/tclNotify.c, lines 668-672, in the function Tcl_DoOneEvent) /* * If idle events are the only things to service, skip the * main part of the loop and go directly to handle idle * events (i.e. don't wait even if TCL_DONT_WAIT isn't set). */ Otherwise the first thing called is Tcl_ServiceEvent. Now yes, this means that when it is servicing idle events, it will not check to see if there are any pending events, but I see that as a different issue. In fact, what might be objectionable, is there are two Tcl_ServiceEvent calls (one on either side of the Tcl_WaitForEvent) before the Tcl_ServiceIdle call, delaying the "do_idle" even more. : Tk also uses double buffering for all widgets, which is : quite expensive, especially since Tk allocates a new : buffer for each update :-( Yes, that could be a problem, but see what I mean down below about additional layers. : In fact, since wxPython has to go thru extra layers, it :> would probably be slower (Tk/C is written on the native API on all the :> platforms). : What native API? As of 8.0, Tk still emulates all widgets : except the scrollbar, and use a somewhat ineffective : X emulation layer for graphics. AFAIK, they haven't : changed that in 8.1... Exactly, Tk is using the native API: X11 (not Motif, not Xt, no emulation other than its own), Windows, MacOS. wxWindows requires GTK or Motif on UNIX, requiring another level of software. Motif is licensed (but most vendors have gotten around that. GTK+ 1.2.3 is 2.58 Mb with monthly updates (they do kindly give patch updates tho). Also, Tk was developed on X11, where the window object created is stored in the X server (another process), not in the application. It is standard practice to keep your own information about the objects you request creation of. This is no different from what wxWindows would have to do using GTK or Motif, both using X11 (except that wxWindows would probably have its own information as well as similar information would be stored for widgets created from either GTK or Motif). I'm not saying that Tk is the greatest thing since sliced bread, just that it may not be as off-kilter as people think. Tkinter is off in that is uses the Tcl/Tk interpreter instead of the Tk/C API (but I for one am not complaining ;). -Arcege From hniksic at srce.hr Sun Jun 6 09:27:53 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 06 Jun 1999 15:27:53 +0200 Subject: Looking for for some ideas for argument processing References: <7jcdhc$htd$1@nnrp1.deja.com> <3759A481.135D19CF@arlut.utexas.edu> Message-ID: <87iu91zcfa.fsf@pc-hrvoje.srce.hr> "Thomas A. Bryan" writes: > cmedcoff at my-deja.com wrote: > > > > I'm writing a script with is going to make heavy use of script > > arguments. I'd like to hear some ideas on some ways to support this. > > I usually just use Python's getopt or DPyGetOpt. > > The first is in the standard library. > > The second is modeled after Perl's GetOpt::Long, which is very > flexible and supports many options. Hey! I've been meaning to write such a thing -- glad it's already been written. The chief problem with Python's getopt is that it doesn't support some nice features of GNU getopt, such as naming the options after the arguments (e.g. wget URL -o outfile). From aahz at netcom.com Sat Jun 26 22:26:45 1999 From: aahz at netcom.com (Aahz Maruch) Date: 27 Jun 1999 02:26:45 GMT Subject: Advice for Newbie References: <377588E9.82E8F567@dsuper.net> Message-ID: <7l4255$c22@dfw-ixnews13.ix.netcom.com> In article <377588E9.82E8F567 at dsuper.net>, Dave wrote: > >I read the Python homepage. I sounds promising. What books do you >commend for a beginner? If you already have experience with other programming languages, some combination of the following: _Programming Python_, _Learning Python_, and the on-line tutorial/documentation. If you're not a programmer and you're not in a hurry, wait for _Teach Yourself Python in 24 Hours_. -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het From MHammond at skippinet.com.au Tue Jun 29 06:27:45 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Tue, 29 Jun 1999 20:27:45 +1000 Subject: PythonWin VSS Integration References: <002a01bec203$1fc90230$a9807018@yec1.on.wave.home.com> Message-ID: <7la6vj$rh0$1@m2.c2.telstra-mm.net.au> Mike C. Fletcher wrote in message <002a01bec203$1fc90230 [Laments about Pythonwin and Source Safe] >So, any hints? What does visual source safe integration mean? Well, it _should_ give you some clues. Note that you need to restart Pythonwin before the option will take effect. Also note that the file must be marked read-only on the disk. Once enabled, and assuming VSS is installed correctly, the most likely error message you will see is something like "this directory is not configured for VSS". [Once the option is checked, you should get _some_ message on a read-only file] In this case, you need a "mssccprj.scc" file either in the file's directory or a parent directory. This is the same name and format as VB uses - basically a Windows INI file. A section [Python] with entry "Project=ProjectName" is referenced. The project name is the name of the VSS project the Python code attempts to check the file out from. If the .scc file is in a parent directory, the correct relative VSS path is built - so if your file system matches your VSS structure, you only need a single .scc file in the VSS "root" directory. Hope this makes sense. Mark. > >Thanks, >Mike > From evan at tokenexchange.com Mon Jun 14 11:35:02 1999 From: evan at tokenexchange.com (Evan Simpson) Date: Mon, 14 Jun 1999 10:35:02 -0500 Subject: fork() References: <000601beb56d$829f6720$319e2299@tim> Message-ID: Tim Peters wrote in message <000601beb56d$829f6720$319e2299 at tim>... > [Evan Simpson] >> ... >> Perhaps I'm being naive, but I have the impression that when cycles >> arise it's usually a simple accident and easy to fix once you know >> you've done it. > Exactly so: you're being naive . I rather thought so, although I did know about Guido's "native" cycles already. > Stuff "like that" pops up in all sorts of apps. With practice you learn > ways around it most often. I've noted more than once that the resulting > cycle-free design is often more robust and comprehensible than its cyclic >ancestor, so I think it's a fruitful exercise to do this; doesn't always > succeed, though, and when you're in a rush it's a pain in the ass to have to > bother. "easy to fix" was a bit of an overstatement, but this is essentially what I meant. >> Would it be possible (and not too expensive) to distinguish actual cycle >> members from dangly bits (maximal non-cyclic subgraphs)? [Interesting SCC approach snipped] > What you suggest is weaker, effectively lumping the SCCs into two gross > classes (singletons and non-singletons), and nuking the latter first. Sorry if I was unclear, but that's not what I meant by "dangly bits". Rather, take the set of nodes from which you cannot reach a cycle. Their subgraph is a union of DAGs, which can be released normally. In your example, handing "c" a reference to "d<->e" converts it from a dangly bit to a cycle-bridge. On the other hand, the SCC approach does look stronger than this, since it can handle cycle-bridges as well. I'll happily take your word that SCC-counting is likely to be too much trouble, but how about just doing an SCC-analysis once M&S has discovered a cycle? If this is all happening in the background, with no deadlines, and with rare, naughty data structures, then it doesn't have to be terribly efficient. and-my-non-existent-code-can-be-maximally-inefficient-if-it-wants-ly y'rs Evan Simpson From greg.ewing at compaq.com Wed Jun 16 19:15:08 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Thu, 17 Jun 1999 11:15:08 +1200 Subject: Module magic methods References: Message-ID: <37682FFC.FF1A59B7@compaq.com> "G. David Kuhlman" wrote: > > import mymodule > # > # Do some stuff with mymodule > # > mymodule = None > > Won't reference counting cause the space taken up by mymodule to be > garbage collected? Nope, because references all imported modules are kept on a global list in the bowels of the interpreter, so that the next time the module is imported you get a reference to the previously loaded instance. > this is what > I'm going to tell them to do when they want to reclaim space in > long running programs. It won't work. > anInstance = mymodule.MyClass() > mymodule = None > anInstance.show() > > Something must stay around so that I can call the methods defined > MyClass. The instance has a reference to the class, so as long as the instance is alive the class will be too, even if you wipe out the reference to it in the module where it was defined. Greg From gmcm at hypernet.com Tue Jun 8 12:18:47 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 8 Jun 1999 11:18:47 -0500 Subject: more python to c/c++ questions. In-Reply-To: <7jgu2u$19s6$1@rtpnews.raleigh.ibm.com> Message-ID: <1283263515-67394082@hypernet.com> Jr. King is asking something or other: > Ok, I found some info on it but, it still doesn't work > > I changed my c module to this... > > static PyObject* objPass(PyObject *self, PyObject* args){ > PyObject *result = NULL; > PyObject *temp; > > if (PyArg_ParseTuple(args, "O", &temp)) { > PyObject* xarg = Py_BuildValue("(s)","i"); You've just built a tuple. Probably not what you want. > xarg = PyObject_GetAttr(temp,xarg); // not getting anything but > null int val; PyArg_ParseTuple(xarg,"i",&val); > } > Py_INCREF(Py_None); > result = Py_None; > return result; > } > > Python module snippet > > class Cow: > i = 10 > x = 0 > str = "string" > def genie(self): > print str > > testmeth.setCallback(setN) > testmeth.testmeth(13,9) > cow = Cow() > testmeth.objpass(cow); - Gordon From n at n.com Tue Jun 1 10:45:25 1999 From: n at n.com (Jr. King) Date: Tue, 1 Jun 1999 10:45:25 -0400 Subject: Why won't this work??? Message-ID: <7j0rkr$1eeu$1@rtpnews.raleigh.ibm.com> I know you are getting tired of me, but I have tried repeatedly to solve this on my own and I can't get it to work. I am trying to do a python callback to call from a c/c++ program. Here is the c/c++ code // learnPyth.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "python.h" #include "stdio.h" #include #include static PyObject *my_callback = NULL; static PyObject* Test(PyObject *self, PyObject* args){ cout<<"Test"< Hi.. I was just wondering if there are any other online docs for python on internet for free? From proteus at cloud9.net Sat Jun 5 14:48:40 1999 From: proteus at cloud9.net (Michael Muller) Date: Sat, 05 Jun 1999 14:48:40 -0400 Subject: ask help for problem with static linking (fwd) References: Message-ID: <37597107.5FB5324C@cloud9.net> Xiaohong Yuan wrote: [snip] > I am sorry I didn't make it clear. In my C extension module, I declare > some extern variables. Those extern variables are for my own application. > They can not be found in Python interpreter source code. So when I do > static linking, my c extension module fails to be linked with the python > interpreter. I don't want to add into Python source code the definition of > my extern variables. There might be some way to wrap my c extensions such > that extern variables would not cause a problem. My platform is QNX, my > compiler is watcom compiler. I don't think platform and compiler matter, > the problem might be how should I deal with extern variable when writing > python c extensions. > > --Xiaohong Yuan I am assuming that you mean that your externs are defined in some main program that your extension is normally linked to, and are presumably used to share information between your extension and your main program. If this is the case syou have two options: 1) redesign your extension so that the information shared by your external variables is shared through an API instead. If necessary, this information can be stored statically in the extension library. 2) Create a stub file which is linked to your extension that provides bogus (but useable) definitions for these variables. Method 2 is a hack. Information that needs to be shared between components should almost always be shared using an API. This allows a "loose coupling" of components, so that you can make implementation changes in one without affecting the other. ============================================================================= michaelMuller = proteus at cloud9.net | http://www.cloud9.net/~proteus ----------------------------------------------------------------------------- If you are not willing to control your own mind, there are plenty of other people who are willing to do it for you. ============================================================================= From aahz at netcom.com Fri Jun 11 14:02:49 1999 From: aahz at netcom.com (Aahz Maruch) Date: Fri, 11 Jun 1999 18:02:49 GMT Subject: Any Production ZOPE sites we can visit? References: <37614A32.79FE554E@metricom.com> Message-ID: In article <37614A32.79FE554E at metricom.com>, Michael Kersey wrote: > >Are there many production Zope sites visible on the www? http://www.searchbutton.com/ We're still looking for Python programmers, BTW.... -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het "That doesn't stop me from wanting to work all three of them over with the clue stick for while, with no safewords allowed." --abostick From gmcm at hypernet.com Sat Jun 12 20:45:43 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Sat, 12 Jun 1999 19:45:43 -0500 Subject: force sequenz with only one item? In-Reply-To: <375FA9AE.6299E9DD@phoenix-edv.netzservice.de> Message-ID: <1282887498-90012442@hypernet.com> Holger Jannsen asks: > > I think it's easy to solve, but I couldn't get it right now. > Take a look at the command-line source below: > > >>> A = 0 > >>> B = 1 > >>> seq=raw_input("?") > ?A,B > >>> print seq > A,B > >>> print eval(seq) > (0, 1) > >>> seq=raw_input("?") > ?A > >>> print eval(seq) > 0 > >>> A in seq > Traceback (innermost last) :... > TypeError: 'in' or 'not in' needs sequence right argument > >>> The reason "A,B" gets evaluated to the sequence (0,1) is because of the comma. "(A,)" would get evaluated to (0,), while "[A]" would evaluate to [0]. If you want to always end up with sequences, you should probably eval it and test it: if type(evaledinput) not in (type(()), type([])): evaledinput = (evaledinput,) Single element tuples need the extra comma to distinguish them from a simple grouping, as in 4 * ( 3 + 7 ). It would cause great wailing and gnashing of teeth if it yeilded (10, 10, 10, 10). even-worse-than-while-1-ly y'rs - Gordon From pavlos at gaaros.com Sat Jun 19 15:04:58 1999 From: pavlos at gaaros.com (pavlos at gaaros.com) Date: Sat, 19 Jun 1999 19:04:58 GMT Subject: HTML bettering? In-Reply-To: <14186.24371.249981.437742@weyr.cnri.reston.va.us> References: <14186.24371.249981.437742@weyr.cnri.reston.va.us> Message-ID: <7kgpkq$kma7@eGroups.com> <14186.24371.249981.43774- at weyr.cnri.reston.va.us> wrote: Original Article: http://www.egroups.com/group/python-list/?start=61289 > > Matej Cepl writes: > > goodwill, is it? But, to make Pythonians more happy, the story is as > > A worthy goal! ;-) > > > html2ps which has much better output, but it numbers headings in > > different way (still unresolved issue, what it the top level -- H2 or Or if your HTML is well structured you can use the html2pdf converter in the Zpdf (it is an alpha release) package http://starship.python.net/crew/pavlos It does heading numbering too. Pavlos From aahz at netcom.com Sun Jun 6 02:18:57 1999 From: aahz at netcom.com (Aahz Maruch) Date: Sun, 6 Jun 1999 06:18:57 GMT Subject: Newbie question References: <3759FF72.E393CAEA@massey.ac.nz> Message-ID: In article <3759FF72.E393CAEA at massey.ac.nz>, yourname wrote: > >I'm getting this error when I try to call a function > >Traceback (innermost last): > File "ftpclient", line 229, in ? > FTPLogin(oFtp,site,port,sUserID,sUserPassword) #site,port) >NameError: FTPLogin Try ftplib.FTPLogin() (or something like that). In general, you need to explicitly specify the namespace you're using. -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het "Why do you like my boyfriend to tie you up and beat me.?" -- ELIZA generates a poly moment From orlov at diasoft.ru Wed Jun 23 09:48:16 1999 From: orlov at diasoft.ru (Oleg Orlov) Date: Wed, 23 Jun 1999 17:48:16 +0400 Subject: set im_self Message-ID: <7kqokb$7as$1@ns.mtu.ru> Hello. Is there any way to set im_self attribute (ie bind method object)? Thanks. -- ==================== Oleg Orlov orlov at diasoft.ru From mukundd at my-deja.com Wed Jun 30 15:17:28 1999 From: mukundd at my-deja.com (mukundd at my-deja.com) Date: Wed, 30 Jun 1999 20:17:28 +0100 Subject: Problem embedding C++ code Message-ID: <000015d1@bossar.com.pl> From: mukundd at my-deja.com Hi, I am trying to write a wrapper around a library written in C++ and I am running into lots of problems. I am running Python 1.5.2 on SunOS 5.5.1 (compiled with SUN's cc and linked with Sun's CC) The wrapper is written in a file called link-wrap.c and currently it contains only one very simple function. CC -c -KPIC link-wrap.c -I/home/mdeshpan/SW/include/python1.5 "link-wrap.c", line 13: Warning: String literal converted to char* in formal argument 1 in call to Py_BuildValue(char*, ...). 1 Warning(s) detected. CC -G link-wrap.o -lapic -lpthread -o link.so libapic.so is the library which I am trying to write the wrapper for, it was compiled using Sun's CC compiler when I try to import link module in python I get the following error.. daffy:~/Swig$python Python 1.5.2 (#3, Jun 29 1999, 11:17:23) [C] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import link Traceback (innermost last): File "", line 1, in ? ImportError: ld.so.1: python: fatal: relocation error: file ./libapic.so: symbol _ex_rethrow_q: referenced symbol not found any help would be greatly appreciated.. Thanks in advance Mukund Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From mcfletch at home.com Thu Jun 10 23:21:05 1999 From: mcfletch at home.com (Mike C. Fletcher) Date: Thu, 10 Jun 1999 23:21:05 -0400 Subject: Broken 1.5.2 installation? Missing cw3215mt.dll References: <000901beb3b2$baa6d980$329e2299@tim> Message-ID: <01cb01beb3b9$7130fc70$a9807018@yec1.on.wave.home.com> Of course, should have done that in the first place (been too long since a reformat). Second thing I should have done was to think a few seconds. I'd renamed the cygnus install's directory but hadn't searched the system32 directory where some ancient version of the TK/TCL dlls was hanging around... Thanks Tim, all working fine now, evil old TCL dlls banished to the aether, Mike ______________________________________ M i k e C . F l e t c h e r mcfletch at vrtelecom.com Designer, Researcher ----- Original Message ----- From: Tim Peters To: Mike C. Fletcher ; Sent: Thursday, June 10, 1999 22:33 Subject: RE: Broken 1.5.2 installation? Missing cw3215mt.dll > > Problem is encountered when loading command-line Python or IDLE. IDLE is > > non-functional, command line works fine after acknowledging the > > missing DLLs (as far as I can see). > > ... > > Could be the Cygnus TCL is interfering I suppose. > > Aha! Stop your grinnin' and drop your linen, Mike. Having more than one > version of tk*.dll or tcl*.dll anywhere in your entire *city* is like > putting a male brain-eater in your left ear and a female brain-eater in your > right ear at the peak of brain-eater mating season, then betting you can > keep them apart by force of moral suasion. You should reformat your drives > and reinstall NT to be *sure* , but before that try uninstalling every > Tcl/Tk you have, "dir/s" your drives from the roots to make sure nothing > matching tk*.dll or tcl*.dll survived, uninstall Python, and reinstall > Python with the One True Tcl/Tk that comes with it. > > followups-to-cameron-laird-ly y'rs - tim > > From ivnowa at hvision.nl Sat Jun 5 17:45:38 1999 From: ivnowa at hvision.nl (Hans Nowak) Date: Sat, 5 Jun 1999 21:45:38 GMT Subject: Deleting characters from a string In-Reply-To: <87n1ye3g4v.fsf@pc-hrvoje.srce.hr> References: <87n1ye3g4v.fsf@pc-hrvoje.srce.hr> Message-ID: <199906052144.XAA15045@axil.hvision.nl> On 5 Jun 99, Hrvoje Niksic wrote: > string.translate can delete characters from a string, as well as > translate them. But what if I want *only* to delete them? Currently > I do this: > > dummytable = string.maketrans('', '') > > ... > host = string.translate(host, dummytable, ' "') > ... > > What I would really like to be able to do is write: > > host = string.translate(host, None, ' "') > > Am I missing a more elegant solution? Hmm... how about host = filter(lambda c: not c in ' "', host) Depends on how much you like, or hate, functional idiom, though. :) --Hans Nowak (ivnowa at hvision.nl) Homepage: http://fly.to/zephyrfalcon From tgallati at mainnet.com Tue Jun 15 20:58:27 1999 From: tgallati at mainnet.com (Tim Gallati) Date: Wed, 16 Jun 1999 00:58:27 GMT Subject: Cut down on writing repetitive code Message-ID: <3766f6a8.19474000@news2.mainnet.net> If you do a lot of repetitive typing, check out Perfect Keyboard Lite. I use it everyday and consider it my most useful program. It launches when you boot your computer and creates a file of frequently used phrases, paragraphs, e-mail addresses, URLs and macros. They are activated in any application by typing a short abbreviation. Free 30 day trial. http://www.tricksandtrinkets.com/pk From Evan.Simpson at p98.f112.n480.z2.fidonet.org Tue Jun 29 06:00:14 1999 From: Evan.Simpson at p98.f112.n480.z2.fidonet.org (Evan Simpson) Date: Tue, 29 Jun 1999 11:00:14 +0100 Subject: Please help me to understand classes Message-ID: <00001590@bossar.com.pl> From: "Evan Simpson" Your Pascal experience is showing . While you can call a parameterless function or procedure without parentheses in Pascal, Python always requires them, since functions are first-class objects. So when you write "a.druk", you are fetching the method "druk" from "a", but then doing nothing with it. You should write "a.druk()", which will call the method with no parameters. One reason for the required parentheses is the ability to do this: f = a.druk # get the method and make f refer to it. f() # call the method. Johann Spies wrote in message ... I have been playing around with python for some time now, but I am a relative newbie as it is my hobby and normally I have very little time for programming. I am on leave now and want to write a program but I find python a very difficult language to comprehend despite the fact that I have a few years of experience in programming a language like Pascal. Maybe it is because I have little experience in OOP. Can somebody explain to me why the following program produces no output: --------------------------------------------- class A: def druk(): print 'Jy is in Class A' class B: def druk(): print 'Jy is in Class B' a = A() c = B() c.druk a.druk From ivanlan at callware.com Fri Jun 18 11:01:11 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Fri, 18 Jun 1999 15:01:11 GMT Subject: Newbie: Truth values (three-valued logic) References: <000f01beb7b8$2722a540$2ca22299@tim> <37697DFD.91C2B8F6@compaq.com> Message-ID: <376A5F37.F13DB3CA@callware.com> Hi All-- Greg Ewing wrote: > > Olaf Delgado wrote: > > > > Next time I'll want to redefine 'and' and 'or'. > > You could use '*' and '+', if you always know > when you're dealing with a 3-valued boolean > (troolean? trillian?). > Triskelion! > By the way, I think Python 2.0 should let you define > new infix operators -- and design new characters to > represent them! We all have bitmapped screens now -- > there's no reason why we should be restricted to a > fixed character set any more... > Ah, yes. I can see it now. Little Mayan glyphs peppering everyone's screens. ``The "'Ahaw" operator is logically equivalent to the 'doit' command in GNUScript.'' World domination is close! -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From moshez at math.huji.ac.il Fri Jun 11 08:52:14 1999 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Fri, 11 Jun 1999 15:52:14 +0300 Subject: urllib: an alternative URLOpener Message-ID: Whom do I contact about adding the following code to urllib: -------------->8-------------->8------------------------- class QuietFancyURLOpener(FancyURLOpener): def prompt_user_password(self, host, realm): return None, None -------------->8-------------->8------------------------- (Yes, I realize I can put it in my own program. But it seems a generally useful thing for non-interactive downloaders) -- Moshe Zadka . QOTD: My own exit is more likely to be horizontal then perpendicular. From MHammond at skippinet.com.au Fri Jun 18 01:18:42 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Fri, 18 Jun 1999 15:18:42 +1000 Subject: do anonymous pipes normally work on NT? References: <4D0A23B3F74DD111ACCD00805F31D8100DB90DE4@RED-MSG-50> <7kbq78$vgm$1@nnrp1.deja.com> Message-ID: <7kckoh$ith$1@m2.c2.telstra-mm.net.au> Inside win32_src.zip you should find win32process.i and win32processmodule.cpp - the latter is generated by SWIG from the former. Bill is working from the same archive, so it must be there! The only thing I can think of is that you didnt grab the archives from my starship page... Mark. Georg Mischler wrote in message <7kbq78$vgm$1 at nnrp1.deja.com>... >But then, I just downloaded win32_src.zip and Pythonwin_src.zip >and didn't find anything resembling a win32processmodule in there. >Guess I am looking in the wrong place. Where is this module defined? From tgm at math.uni-bonn.de Mon Jun 28 05:03:34 1999 From: tgm at math.uni-bonn.de (Thomas Ackermann) Date: Mon, 28 Jun 1999 11:03:34 +0200 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> Message-ID: <6pd7l7.9d.ln@final.math.uni-bonn.de> When i need to do some GUI, i always prefered GTK (and the formidable pygtk from James Henstridge) ... As it uses gtk, i hope it will soon be available on all mayor platforms. Is anybody capable of comparing Tkinter, pygtk and wxWindows? Byebye, -- Thomas Ackermann | Tel. +49-(0)228/631369|73-7773 | finger tgm at rhein.math.uni-bonn.de for public key GNU LINUX Python gtk pygtk MySQL FUDGE GURPS From claird at Starbase.NeoSoft.COM Wed Jun 16 21:17:58 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 16 Jun 1999 20:17:58 -0500 Subject: Why is tcl broken? References: <1283099377-77267484@hypernet.com> <37628EBF.207F7A8F@iname.com> Message-ID: <7k9ic6$8oh$1@Starbase.NeoSoft.COM> In article , Julian Einwag wrote: . . . >Do you know where you can get the Qt bindings? Im quite interested in >it. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From holger at phoenix-edv.netzservice.de Fri Jun 18 12:01:40 1999 From: holger at phoenix-edv.netzservice.de (Holger Jannsen) Date: Fri, 18 Jun 1999 16:01:40 GMT Subject: NT Message-ID: <376A6D64.DF881D27@phoenix-edv.netzservice.de> Hi, another problem under NT: I'd like to message the user a longer description about the programm with sys.stdout.write(usagetxt). The user should have possibility to pipe the output like he wants, e.g. with 'less' or 'more'. But I get an error: C:\myPython>installation15.py /? |more Traceback (innermost last): File "C:\myPython\installation15.py", line 642, in ? switcher() File "C:\myPython\installation15.py", line 629, in switcher __usage() File "C:\myPython\installation15.py", line 189, in __usage sys.stdout.write(usagetxt) IOError: [Errno 9] Bad file descriptor If I start with 'C:\myPython>python installation15.py /? |more' there's no problem and it works allright. I've read the messages about NT and piping in this group, but I think it's something differnt, ouh?! hand (='have a nice day'!), Holger From morse at harborcom.net Wed Jun 30 15:12:15 1999 From: morse at harborcom.net (Kevin Dahlhausen) Date: Wed, 30 Jun 1999 19:12:15 GMT Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> <3773c3a0.102825445@news.oh.verio.com> <7laovo$c4s$1@Starbase.NeoSoft.COM> <377A24B7.AD6FAA1A@cfdrc.com> Message-ID: <377a6bb0.10820509@news.oh.verio.com> Lyle Johnson wrote: >Just to add fuel to the fire, we now have a Python interface to FOX, a >cross-platform GUI toolkit: > > http://www.cfdrc.com/pub/FOX/fox.html How did you get around the requirement of preprocessor table definitions for message handlers? (I'm downloading it now....) From gmcm at hypernet.com Sat Jun 5 23:14:51 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Sat, 5 Jun 1999 22:14:51 -0500 Subject: Sockets and lemon curry In-Reply-To: Message-ID: <1283483353-54170129@hypernet.com> Ian King writes: > I'm trying to implement an rshd server in Python. The problem seems > to be with establishing the secondary socket for stderr. I'm using > a Linux 2.0 box as client, and a Windows machine as server > ... In experimenting, I've gotten things to work with utilities > that don't require the second socket (e.g. rcp). But the moment I > try to establish the secondary socket, the client says, "protocol > violation" and gives up. Ideas? /snip code/ > ... This seems like a simple handshake, and if I use (for > instance) the Windows machine as a client against the Linux server > (and do a network trace), everything works and looks great. Yes. On *nix, it takes root authority to create sockets on ports below 1024. No such limit on NT. You didn't say what 'port2' was, but it sure fits the symptoms... - Gordon From gmcm at hypernet.com Fri Jun 18 18:48:53 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Fri, 18 Jun 1999 17:48:53 -0500 Subject: Installing ODBC on PythonWin In-Reply-To: <7ke9kq$3c2$1@holly.csv.warwick.ac.uk> Message-ID: <1282376107-120775232@hypernet.com> Andrew Clover has Access problems: > I've got an Access database accessed by Python scripts under CGI. > However, > sometimes, calls to odbc.odbc(dsn) hang up and never return. > (Eventually the web server times out and kills the process.) This > seems to happen randomly, but increasingly. Does anyone have any > idea why? A fault with the odbc module, or Access, or what? Repeat after me: "Access is NOT a server, Access is NOT a server". It is a file access method. If you access it through Jet (ie, DAO or one of those) it is sort-of safe for multiuser usage. If accessed through ODBC it is most definitely absolutely NOT safe. It's not even safe for mutiple connections from one process. Access is dandy on the desktop as an overgrown spreadsheet. It is the LAST thing you should use for CGI. - Gordon From misty at pao.fiba.tampere.fi Thu Jun 17 02:16:55 1999 From: misty at pao.fiba.tampere.fi (Juhani Rantanen) Date: 17 Jun 1999 06:16:55 GMT Subject: Why is tcl broken? References: <1283099377-77267484@hypernet.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> Message-ID: On Wed, 16 Jun 1999 21:27:52 GMT, David Thornley wrote: >I know little of this Qt animal. Is it free? Is it open source? >Does it run on the Macintosh? Is it easy to set up an interface with? Qt will be soon licensed with an open-source license, though it will be practically very restrictive (all changes must be distributed as patches). Current version of Qt is not free software, and I am surprised to find one who doesn't know about the flamewars... Try "qt gtk free" in Altavista or Dejanews to find out:) I also suggest looking at Gtk+ that is used in GIMP (free Photoshop clone for Unix/Linux http://www.gimp.org/), Gnome (a free desktop environment for GNU project http://www.gnome.org/) . Gnome folks have made a version of Guile with Gtk and Gnome bindings, but this is not very widely tested AFAIK, and some higher-level interface would be preferable (though now we have C-level API mapped to scheme, the higher-level interface could be written in scheme). Gtk+ is available on Unix and Win32. Win32 support is not in the official sources, but I even occasionally use a version of GIMP on Windows NT and it is quite robust compared to some commercial programs on the same operating system (though both Gtk+ and Gimp on that machine are developer's versions from CVS). -- Juhani Rantanen L?hderanta 20 G 55 Espoo This message is best read on a 80x24 tty with 2 colors and a non-proportional font From hniksic at srce.hr Fri Jun 4 11:50:52 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 04 Jun 1999 17:50:52 +0200 Subject: threads References: <3756C078.5D998D3B@icrf.icnet.uk> <14166.51558.850416.153999@bitdiddle.cnri.reston.va.us> <8790a1njeu.fsf@pc-hrvoje.srce.hr> <14166.60091.353043.829598@amarok.cnri.reston.va.us> <87k8tks2y5.fsf@pc-hrvoje.srce.hr> <14167.61710.929549.586641@anthem.cnri.reston.va.us> Message-ID: <87aeug7yn7.fsf@pc-hrvoje.srce.hr> "Barry A. Warsaw" writes: > You might be interesting in digging around for Greg Stein's > free-threading patches. Greg did a lot of work, I think in the > Python 1.4 days, to remove the central interpreter lock and make all > the data structures and such thread safe. Why would I want to do that? If Greg's patches haven't been applied to the base, surely mine would not be either. I certainly have no wish to maintain a parallel version of Python. From arcege at shore.net Sat Jun 12 21:51:14 1999 From: arcege at shore.net (Michael P. Reilly) Date: Sun, 13 Jun 1999 01:51:14 GMT Subject: tkinter and signals References: <3762392C.AE94C44D@saiph.com> Message-ID: Pierre Imbaud wrote: : Hi everyone. : Im quite new to tkinter. I try to make a program using tkinter, that : is able to listen to some signals: read a pipe, perform periodic : actions. I first tried with SIGALRM, with a widget changing fg color : every second. I dont wait() for SIGALRM, just return in mainloop(). : the behavior I get is: I need the mouse to hover on the app, to get : the SIGALRM signal. My diagnostic, right or wrong is: in the mainloop, : the idle state is a wait() for a signal (dunno which) related to an X : event. In this state, an unwaited signal just wont wake up the : process. : It just occurs to me threads might be the solution: for every possible : signal source, spawn a thread that will explicitly wait for this : signal? Im not familiar with thread either, so I better wait for a : confirmation from someone who knows.... : Oh, btw, Im using Solaris 2.5.1 on X86 (its an Unix V.4) : Thanks for answering! I would suggest first looking into the after() and after_idle() methods. They are designed for this type of operation. There is also a lower-level interface, the _tkinter.createtimerhandler function. The after() and _tkinter.createtimerhandler() functions both take a number of milliseconds and a function. f = Frame(None) oneminute = 60000 def change_red(f=f): f.config(fd="red") f.after(oneminute, change_green) def change_green(f=f): f.config(fg="green") f.after(oneminute, change_red) f.after(oneminute, change_red) -Arcege From mwh21 at cam.ac.uk Wed Jun 9 06:57:44 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 09 Jun 1999 11:57:44 +0100 Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7iqhkb$d7s@wiscnews.wiscnet.net> <7iu7ma$d33$1@cronkite.cc.uga.edu> <02hfonzsx2.fsf@rtp.ericsson.se> <02909zzou0.fsf@rtp.ericsson.se> <87zp2f4qrz.fsf@pc-hrvoje.srce.hr> <14172.6652.550882.854800@bitdiddle.cnri.reston.va.us> Message-ID: Jeremy Hylton writes: > >>>>> "DS" == Dan Schmidt writes: > > DS> Hrvoje Niksic writes: | Kumar Balachandran > DS> writes: | | > What you > DS> said is quite wrong. Since Python provides closures, I can | > > DS> change my programming style to be completely different from the > DS> | > standard C or Fortran style and use a functional interface. > DS> | | Since when does Python provide closures? > > DS> The bytecodehacks module allows the creation of closures as I > DS> understand them. > > Yes and no. The bytecodehacks closures work right most of the time, > but there some problems with them. Hence, I would guess, the name > "hacks." Quite. PLease note that the bytecodehacks resulted from me having an idea that noone else seems to have had before and running away with it as far as I could get it. The modules and functions that resulted from this were really just illustrations of what the technique can do, rather than solutions to any particular problem. Having said that, if someone does find them useful, then that makes me happy. [explanantion of why "BCH closures" aren't quite like scheme closures] > > def works(): > sum = [0] > def add(x): > sum[0] = sum[0] + x > def sub(x): > sum[0] = sum[0] - x > cadd = closure.bind_locals(add) > csub = closure.bind_locals(sub) > cadd(2) > cadd(3) > csub(1) > return sum[0] It probably wouldn't be all that hard to make bytecodehacks.closure generate code like this automatically if it sees the substituted name being mutated via STORE_FAST/STORE_GLOBAL. Also note that the above code puts a mutable value into a code object, something that isn't supposed to happen: (from the Language Reference) | Unlike function objects, code objects are immutable and contain no | references (directly or indirectly) to mutable objects. Also Python expects to ba able to marshal code objects, so if you use clsure.bind with an unmarshallable value there might be trouble. Having said all that, it shouldn't cause any real problems (at least not in 1.5.2). Have a nice day! Michael From matomira at iname.com Tue Jun 15 09:11:22 1999 From: matomira at iname.com (Fernando Mato Mira) Date: Tue, 15 Jun 1999 15:11:22 +0200 Subject: OO (was: Why is tcl broken?) References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> <3762988E.C94AA252@iname.com> <3763C746.5CA8FE78@iname.com> <87pv2zjhhl.fsf@home.ivm.de> <37660FEC.D4F3371B@iname.com> <37661C02.9CA6E258@cfmu.eurocontrol.be> Message-ID: <376650FA.1AED1606@iname.com> Ian Wild wrote: > Fernando Mato Mira wrote: > > > > William Tanksley wrote: > > > > > (I like all the languages I know, except Fortran. I even like C++, > > > although I wish they could break backwards compatibility.) > > > > Quiz: What do Scheme, Common Lisp, HPF and Java have in common? > > And when's Java*, the massively parallel version, coming out? I seem to have forgotten C, too.. From gerrit.holl at pobox.com Thu Jun 10 09:34:23 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Thu, 10 Jun 1999 15:34:23 +0200 Subject: Why is tcl broken? In-Reply-To: <375FA62E.CCEF5079@cfmu.eurocontrol.be>; from Ian Wild on Thu, Jun 10, 1999 at 01:49:02PM +0200 References: <375F82C7.CF0F0477@iname.com> <375FA62E.CCEF5079@cfmu.eurocontrol.be> Message-ID: <19990610153423.A23327@optiplex.palga.uucp> On Thu, Jun 10, 1999 at 01:49:02PM +0200, Ian Wild wrote: > From: Ian Wild > Subject: Re: Why is tcl broken? > Date: Thu, 10 Jun 1999 13:49:02 +0200 > To: python-list at python.org > > Fernando Mato Mira wrote: > > > I'm trying to collect a list of all the _current_ issues making tcl > > a bad language choice. I'd like concrete examples, > > (I mean, it's theoretically possible that, in some > parallel universe, there's a even problem for which > C++ is the ideal choice.) > Can I conclude that C++ isn't a good language? I'm a starting programmer: why isn't C++ good for many problems? -- The Dutch Linuxgames website. De Nederlandse Linuxgames pagina. Everything about games on Linux. Alles over spelletjes onder Linux. Site address: http://linuxgames.nl.linux.org Personal homepage: http://nl.linux.org/~gerrit/ From ivanlan at callware.com Sat Jun 19 17:17:12 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Sat, 19 Jun 1999 21:17:12 GMT Subject: DATE ARITHMETIC References: <7kejrv$e57$1@violet.singnet.com.sg> Message-ID: <376C08D8.A9032304@callware.com> Hi All-- Ajith Prasad wrote: > > I need to do some simple date arithmetic - finding the number of days > between any 2 days, the age of a person on a day given his birthday. The > mxDateTime module downloadable from the Python website is more complex than > what I need. Any other suggestions? No. Date arithmetic is by nature non-trivial. Marc-Andre's mxDateTime is perfectly suited for your application. If you *really* *really* don't want to use it, though, look up "Julian Date" and Scaliger (Joseph Justus) on the web. Learn how to reduce Gregorian dates to Julian Period dates, and once you do that you can add and subtract dates as if they have just become big numbers. Which they will have done, assuming you follow up on Julian Period dates. <8-K'an-12-Sotz'>-ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From matomira at acm.org Mon Jun 14 11:46:23 1999 From: matomira at acm.org (Fernando D. Mato Mira) Date: Mon, 14 Jun 1999 17:46:23 +0200 Subject: broken References: <1282792849-95706075@hypernet.com> <3764D7C3.718E125E@iname.com> <002f01beb64d$58e7b5f0$f29b12c2@pythonware.com> Message-ID: <376523CF.607E59A@acm.org> Fredrik Lundh wrote: > as far as I can tell, you haven't even mentioned Python in any > of your posts to comp.lang.python and the python language > mailing list. sure looks like the usual cross-posting time-wasting > usenet troll to me, but maybe someone is abusing your user > account? No. The vague impression I got from python tells me it's a good language, and their folk seem pretty much on track. As many of its users seem to have the same kinds of needs the tcl people do, I thought it would probably be the place to find knowledgeable people with a balanced opinion. >the other hand, if you're not interested in Python, maybe you >could stop wasting our time? If the subject does not interest you, you don't need to read. Myself, I find it very enriching to meet people from other `cults'. That's how you can learn new things. You've been polite, but the last line is pretty ambiguous to me in tone, given the limitations of this electronic medium. And the same happened with some other person in the newsgroup. Beware. That does not do Python any good. Suddenly, I have the impression the group is populated with very excitable and all-knowing `Linux kiddies' (obviouly, why didn't I think so? - I also use Linux), and that it's not one some place one should want to visit very often (like comp.lang.c++, for example). Just think about it. And no, I don't see why I should use Python instead of other things. Although seeing it everywhere (ILU, GNOME, etc.) has intrigued me, although not from a practical perspective, so I haven't really looked at it. For me, it would be interesting to study it if there was something `new', like Occam has CSP, Eiffel has assertions, Ada has tasking (and ADTs were `new', at the time I studied it, in1986), Haskell has monads, etc. Regards, -- Fernando D. Mato Mira Real-Time SW Eng & Networking Advanced Systems Engineering Division CSEM Jaquet-Droz 1 email: matomira AT acm DOT org CH-2007 Neuchatel tel: +41 (32) 720-5157 Switzerland FAX: +41 (32) 720-5720 www.csem.ch www.vrai.com ligwww.epfl.ch/matomira.html From peterh at sapros.com Wed Jun 2 22:37:51 1999 From: peterh at sapros.com (Peter Haight) Date: Wed, 02 Jun 1999 19:37:51 -0700 Subject: idle processing Message-ID: <199906030237.TAA08709@wartch.sapros.com> >is there an appropriate place to insert a method >which does some calculations while the application >is "idle" (user is not using it or just moving >the mouse...) - somewhere within the tkinter- >mainloop ? One way is to not use mainloop and call update and whatever other functions that you want in your own loop like this: root = Tkinter.Tk() while 1: root.update() idle_processing() From dalke at bioreason.com Mon Jun 14 23:09:44 1999 From: dalke at bioreason.com (Andrew Dalke) Date: Mon, 14 Jun 1999 21:09:44 -0600 Subject: Bug in `imp' module? Message-ID: <3765C3F8.D3F8A4CD@bioreason.com> Summary: imp.find_file returns the .py file before the .pyc file when I think it should be the other way around. Solution should be to swap two lines in Python/importdl.c I've been learning how to use the imp module. There is a function called find_module which looks up the initialization information needed for a given module name. So I tried it out: val> cat > norm.py bar = "Cheers" val> python Python 1.5.1 (#21, Nov 23 1998, 15:04:47) [C] on irix6 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import norm >>> val> ls -l norm* -rw-r--r-- 1 dalke staff 15 Jun 14 20:10 norm.py -rw-r--r-- 1 dalke staff 98 Jun 14 20:10 norm.pyc >>> import imp >>> imp.find_module("norm") (, 'norm.py', ('.py', 'r', 1)) --- PROBLEM --- I expected to get something like: (, 'norm.py', ('.py', 'r', 2)) My expectation was that it would act like a normal import and try to get the .pyc (or .pyo) file first, before getting the source file. Hence, a ".pyc" for the filename extension and a 2 (==imp.PY_COMPILED) instead of a 1 (==imp.PY_SOURCE). If I remove the .py file, it does get the .pyc file with the right description information: val> python Python 1.5.1 (#21, Nov 23 1998, 15:04:47) [C] on irix6 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import imp >>> imp.find_module("norm") (, 'norm.pyc', ('.pyc', 'rb', 2)) I believe the problem boils down to the list returned from imp.get_suffixes. The standard list is: [('.so', 'rb', 3), ('module.so', 'rb', 3), ('.py', 'r', 1), ('.pyc', 'rb', 2)] so .py files are found before .pyc files. (BTW, the .pyc will be replaced with a .pyo if -O is used.) I tested this possibility by changing Python/importdl.c to swap the .py and the .pyc lines when building _PyImport_Filetab: > {".pyc", "rb", PY_COMPILED}, /* added */ > {".py", "r", PY_SOURCE}, > /* {".pyc", "rb", PY_COMPILED},*/ /* original */ After recompiling, I get that the .pyc file is indeed found first: val> ls -l norm* -rw-r--r-- 1 dalke staff 15 Jun 14 20:10 norm.py -rw-r--r-- 1 dalke staff 98 Jun 14 20:10 norm.pyc val> ~/Python-1.5.1/python Python 1.5.1 (#32, Jun 14 1999, 20:37:01) [C] on irix6 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import imp >>> imp.find_module("norm") (, 'norm.pyc', ('.pyc', 'rb', 2)) >>> and if the .pyc isn't present it will back down to the .py file. Is this really a bug? Oh, and the most recent version I have, 1.5.2a2, has the same problem, and no one in Deja News has mentioned it. Andrew Dalke dalke at bioreason.com From scott at chronis.pobox.com Tue Jun 1 12:21:34 1999 From: scott at chronis.pobox.com (scott cotton) Date: Tue, 1 Jun 1999 12:21:34 -0400 Subject: Python 2.0 In-Reply-To: <7j0urf$2dm$3@cronkite.cc.uga.edu>; from Graham Matthews on Tue, Jun 01, 1999 at 03:39:27PM +0000 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <7j0urf$2dm$3@cronkite.cc.uga.edu> Message-ID: <19990601122134.A30248@chronis.pobox.com> kaffe, the gnu java implementation, has some interesting GC features which might be explored for python 2.0: 0601 12:11 bort:src/kaffe-1.0b4# kaffe --help Unknown flag: --help usage: kaffe [-options] class Options are: [...] -ss Maximum native stack size -mx Maximum heap size -ms Initial heap size -as Heap increment -verbosegc Print message during garbage collection -noclassgc Disable class garbage collection [...] -noasyncgc * Do not garbage collect asynchronously -oss * Maximum java stack size 0601 12:11 bort:src/kaffe-1.0b4# Additionally, it's garbage collection takes place through an interface which can be implemented any number of ways, including using reference counting. import gc; gc.refcounting(1) or gc.markandsweep(1) or class MyGC: pass gc.setgc(MyGC) seems like they could come in handy. memory management has no single ideal for any language, it seems best to let the programmer manipulate it a bit. in the land of python-2.0 anything is possible ;) scott On Tue, Jun 01, 1999 at 03:39:27PM +0000, Graham Matthews wrote: | Paul Boddie (paulb at infercor.no) wrote: | : As has been discussed before on this newsgroup/list, such resources get | : overlooked in many a garbage collection scheme. I'm sure a perusal of various | ---- | : news/list archives would provide a substantial amount of relevant literature. | | That word "many" is your key Paul. Just because many a garbage collection | scheme works that way doesn't mean all do, or all have to. It's entirely | an implementation dependent thing. | | You are creating a strawman argument that GC cannot properly free resources | like files. But some GC do just that so what is your point? | | graham | | | -- | This mountain is not visible from any inhabitable place. | It has no name, and since it's discovery in 1856 by a | British survey team, it has mysteriously resisted every | attempt to name it. The mountain is known simply and starkly | by it's original designation on the surveyor's map ... K2. | | -- | http://www.python.org/mailman/listinfo/python-list From tismer at appliedbiometrics.com Thu Jun 17 06:03:55 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Thu, 17 Jun 1999 10:03:55 GMT Subject: ref counting, access from python References: <7kad31$o7f$1@ns.mtu.ru> Message-ID: <3768C80B.14B245E6@appliedbiometrics.com> Oleg Orlov wrote: > > Hello. > How can i get objects current ref count from my python code? > Thanks. >>> import sys >>> sys.getrefcount(None) 1583 >>> print "ciao - chris" ciao - chris >>> -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From mgushee at havenrock.com Sun Jun 20 12:48:11 1999 From: mgushee at havenrock.com (Matt Gushee) Date: 21 Jun 1999 01:48:11 +0900 Subject: newbie tkinter -- radio buttons References: <376C672C.F817E0C0@pixar.com> Message-ID: Hi, Cynthia-- Welcome to the great Tkinter adventure! Cynthia Pettit writes: > Okay, you get your choice of answering any single one of these questions > to solve my woes! :) > > I'm making a color menu in a drawing program. It allows you to add > named colors as you go. > > At first, I was adding colors this way: > > self.color_menu.add_radiobutton(label=color_name, > value = color_name, > variable = self.current_color) > > [Note: a couple other issues: value and variable don't seem to work. > When I choose the button, it does not change the value of > self.current_color.] I bet you're trying to do this: new_color = self.current_color I wish the documentation were clearer on this inherently confusing point. The 'variable' attribute of a Tkinter widget does *not* refer to a Python variable. It refers to a Python *object* which acts as the interface to a Tk variable. So you need to 1) Create an instance of IntVar, StringVar, DoubleVar, or BooleanVar, e.g.: self.current_color = StringVar() and 2) Use the get() and set() methods to access the value: new_color = self.current_color.get() the menu constructor command is fine as you wrote it. > temp = Radiobutton(self.color_menu, text=color_name, > value = color_name, > variable = self.current_color) > temp.pack(anchor=W) > temp.select() > ... > But now, of course, this conflicts with other calls, like add_command > and add_separator. [eg "Add Color"] The buttons look to be on top of > eachother. I think this is due to the .pack() calls not working with > the add_radiobutton calls. Well, they're not supposed to. The Menu class isn't designed to contain other widgets; the radiobuttons, separators, etc. within menus that are created with add_radiobutton are not class instances, they're just components of the Menu instance. Hence they don't have their own methods, and must be manipulated through the methods of the Menu class. Unless you want to go to the trouble of manually creating a menu from a Frame() class instance -- but unless you need to do something extremely sophisticated and non-standard, I don't see why you would need to do that. > Here's a choice of things that if solved would save me [in order of > preference]: > > Call .select() on an add_radiobutton [and just how *does* one ever > access these buttons ever again?!?!] Haven't worked with Tkinter in a while, but IIRC, calling the set() method of your radiobutton variable should do what you want. Have you read the Tk manual page for the Menu class? If not, I'd highly recommend doing so. It's a shame to have to learn two languages in order to use one, but the Tkinter documentation has a ways to go yet. Personally I find that understanding Tk widgets from a Tcl perspective has saved me a lot of unproductive flailing around w/ Tkinter. Hope this helps a bit. Matt Gushee Portland, Maine, USA mgushee at havenrock.com From nickb at earth.ox.ac.uk Mon Jun 7 07:57:31 1999 From: nickb at earth.ox.ac.uk (Nick Belshaw) Date: Mon, 07 Jun 1999 12:57:31 +0100 Subject: event handling in classes? References: <7ivg74$rau$1@nnrp1.deja.com> Message-ID: <375BB3AA.9CC679A6@earth.ox.ac.uk> bgue at my-deja.com wrote: > Hi, I'm stumped on how to accomplish event handling with a Tkinter app > that's a class. I didn't find anything on a Dejanews search either...can > anybody tell me what the following example is doing wrong? > > from Tkinter import * > > class gui(Frame): > def __init__(self, parent=None): > Frame.__init__(self, parent) > self.grid() > self.bind("", self.callback) > self.str = "" > self.mainloop() > > def callback(self, event): > print event.char > self.str = self.str + event.char > > g = gui() > > ----- I don't see any replies so I'll try a little clumsy help. Your code seems a bit confused so if I modify it slightly.... #--------------------------------------- from Tkinter import * class gui(Frame): def __init__(self, parent=None): self.test_widget1 = Canvas(parent,width=50,height=50) self.test_widget1.pack() self.test_widget1.bind('<1>', self.callback) self.test_widget2 = Text(parent,width=10,height=10) self.test_widget2.pack() self.test_widget2.bind('', self.callback) def callback(self, event): print event Main = Tk() g = gui(Main) Main.mainloop() #---------------------------------------- Same class approach but I have initialised a master-window with Tk() and passed it to the instance on creation and finally started the Tk.event-loop outside the instance with Main.mainloop() Your main problem is with the widget bindings. You can only bind things to a widget that the widget can recognise. So the Canvas will recognise the mouse '<1>' press but if you bind a it will not see it. A Text widget will then see the event ok of course. You had a Frame which might take entry and motion bindings (not sure - maybe none) but a Frame is a holder for other widgets. Anyway - hope that sets you on the right track. For more info try http://www.pythonware.com/library.htm cheers Nick/Oxford From mlh at swl.msd.ray.com Mon Jun 28 10:03:30 1999 From: mlh at swl.msd.ray.com (Milton Hankins) Date: Mon, 28 Jun 1999 14:03:30 GMT Subject: Environment inheritance under Windows NT References: <7l3hpf$84v$1@nnrp1.deja.com> Message-ID: <7l7vba$hil$1@nnrp1.deja.com> In article <7l3hpf$84v$1 at nnrp1.deja.com>, Bill Wilkinson wrote: >... > If you take a look after you change the variable using "set", > you will notice that there are actually two copies of your variable. > The new one can be changed on demand in the current window. > > You can ease the pain a little by using the setx.exe utility that comes > with the resource kit. Yes, I tried installing the resource kit, but it required Internet Explorer 4. So, off I went to find a copy of IE4 to download. No luck. So, I tried installing IE5. I tried for several hours; the install kept failing. Besides, doesn't setx change the "global" environment -- the same as in the System control panel? That's not really the effect we want. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From news at dorb.com Tue Jun 15 15:48:40 1999 From: news at dorb.com (Darrell) Date: Tue, 15 Jun 1999 15:48:40 -0400 Subject: Newbie: Truth values (three-valued logic) References: Message-ID: <29y93.24$U6.625@newsr2.twcny.rr.com> Not exactly what you want I know. But None is close. >>> not 0 1 >>> not None 1 >>> ... def myNot(x): ... if x != None: ... return not x ... return x ... >>> From yopen at my-deja.com Sat Jun 26 15:40:09 1999 From: yopen at my-deja.com (Bill Wilkinson) Date: Sat, 26 Jun 1999 19:40:09 GMT Subject: file.tell problems (1.5.2/Win32) References: <7krd1r$2oa$1@holly.csv.warwick.ac.uk> Message-ID: <7l3aao$65c$1@nnrp1.deja.com> hmmm.... not too sure what your asking, here is a session on my NT box. >>> g = open("c:\\temp\\trick.ini","a") >>> g.tell() 0 >>> g.seek(5) >>> g.tell() 5 In article <7krd1r$2oa$1 at holly.csv.warwick.ac.uk>, esuzm at primrose.csv.warwick.ac.uk (Andrew Clover) wrote: > I've been meeting some surprises using the seek and tell on file objects > recently. I don't know if these are bugs in Python or stdio, in Win32 or > in general, or are simply broken as designed, but: > > - If a file is opened in 'a'ppend mode, but nothing has yet been written to > it, tell() returns zero. > > - Values returned by tell() - possibly only on a append file, I don't know - > seem to be randomly a bit wrong unless flush() is used before reading. > > Can anyone confirm this? > > -- > This posting was brought to you by And Clover. > (Sorry.) > Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From MHammond at skippinet.com.au Wed Jun 2 08:35:41 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Wed, 2 Jun 1999 22:35:41 +1000 Subject: need help checking for stack overflow in Win32 References: <5lk8to3su3.fsf@eric.cnri.reston.va.us> <7j1pcc$256$1@m2.c2.telstra-mm.net.au> <375502C7.39C4FD0E@appliedbiometrics.com> Message-ID: <7j38bs$ipe$1@m2.c2.telstra-mm.net.au> Christian Tismer wrote in message <375502C7.39C4FD0E at appliedbiometrics.com>... >Nope. The trap is: >You compiled with VC++ 6.0 which has better register spilling. >Therefore, recusion costs only 100 bytes, not 104. >Not calculate 104 * 10000 and you see why 1 MB stack >lets it crash. Cool. Thanks. But doesnt the fact remain that counting the recursion depth is dangerous? Im thinking of embedded environments, where a) the stack size of the hosting .exe can't be known and b) the stack used by the app before Python is even called can't be determined. Add to this callbacks in GUI and COM type applications, and we seem to be applying more band-aids. The idea of counting space used seems better, but still assumes a known stack size. >I submitted a patch program for this kind of >problems, so I think there is no need to change >Python 1.5.2 at all. Huh? Are you suggesting people continue to build from sources, then run your script to get an "official" version? Wouldnt it be better to get Guido to apply these changes to the build process? You have provided an excellent interim fix, but IMO the problem remains. Mark. From vmas at servicom2000.com Tue Jun 22 05:15:11 1999 From: vmas at servicom2000.com (vmas) Date: Tue, 22 Jun 1999 11:15:11 +0200 Subject: file system quota Message-ID: Hi, I'm using Python for writing system administration scripts with a Unix system and I'd like to set quota limits for a given user. Do you know how to manipulate the file system quotas using Python? Maybe you know some module for managing file system quotas ... Thanks. -- ========================================================================= Vicente Mas || Dpto. Tecnico, Servicom 2000 || Do or do not ... There is no try. e-mail: vmas at servicom2000.com || Yoda (The Empire Strikes Back) Tel: +34963618776 || Fax: +34963605508 || ========================================================================= From alan.gauld at gssec.bt.co.uk Wed Jun 9 12:41:39 1999 From: alan.gauld at gssec.bt.co.uk (Alan Gauld) Date: Wed, 09 Jun 1999 17:41:39 +0100 Subject: "Programming Python" still worthwhile? References: <1283218560-70098357@hypernet.com> Message-ID: <375E9943.F9FEA7BA@gssec.bt.co.uk> Gordon McMillan wrote: > Rick Robino writes: > > me some advice as to whether or not "Programming Python" is useful, Yes it is. If you are used to the O'Reilly style and are happy with it PP is an excellent book. I'm currently jusat over half way thru' and it has helped me a lot. At work we have Python 1.3 (don't ask!) and at home I use 1.5.2. The vast majority of things work on both systems. > > if the current edition is still current, if I should wait for the > > "Learning Python", or if I should use some other resources. I looked at LP but couldn't see a good reason to buy it at the stage I'm now at - basic Tkinter and CGI programs without recourse to the books. > liked PP very much (and the difficult to find Internet Programming > with Python, Watters et al, M&T books). I had no problem getting the IPwithP book via Amazon :-) I didn't find it too useful, and still wasn't clear how much of the code applied to the standard distribution of Python and how much was for the book only. It reminded me of being at uni' where the lecturers insist on deriving everything from first principles before telling you that you can buy a book of tables... (Actually, come to think of it I'm still not that clear on some of it!) [ The socket examples are OK. ] The general layout of the language reference part was confusing to me. Sorry Guido, but I prefer PP.... YMMV of course. > > I expect to come up to speed fairly quickly and I'm just looking for > > those fundamental insights into OOP and Python that can build up the > > kind of inuition and understanding one needs in order to "get > > comfortable" connecting/creating the dots. I'd say thats exactly where the PP book fits. Its not a hold hands tutorial, neither is it a function by function reference (you get that with the online documents!) There are another 2 books on Python around and at least one other on its way. Browse away. Alan g. -- ================================================= This post represents the views of the author and does not necessarily accurately represent the views of BT. From andersdt at notes.cba.ufl.edu Wed Jun 30 14:06:01 1999 From: andersdt at notes.cba.ufl.edu (Taylor Anderson) Date: Wed, 30 Jun 1999 14:06:01 -0400 Subject: theads & global namespaces Message-ID: <377A5C88.32A1FAB6@notes.cba.ufl.edu> Greetings all, I am trying to share globals between threads. Is is possible for me to share globals between threads that call functions from different modules? Thus far I have had little success. I ask this question because I would prefer not to put all my code in one module. For example, I have 2 .py files: a.py and b.py. b.py contains the function ('foo()') to be executed under the new thread, as well as the global variable 'x'. a.py contains the call to start_new_thread(foo,()). a.py also tries to use the global variable x. ========================================= b.py x = 0 def foo(): global x x = x + 1 ========================================= a.py from b.py import * if __name__ == '__main__': start_new_thread(foo, ()) while 1: if x != 0: print x ========================================= So far, my code in a.py does not detect any change in x. Any suggestions for a workaround? Many thanks, Taylor From qnmdjb at ffff.com Sat Jun 5 00:23:58 1999 From: qnmdjb at ffff.com (qnmdjb at ffff.com) Date: 5 Jun 1999 04:23:58 GMT Subject: FREE HARDCORE TEEN PICS 6141 Message-ID: <7ja8ou$7j4$4641@nclient5-gui.server.virgin.net> FOR THE BEST FREE TEEN SEX PICTURES VISIT: http://freespace.virgin.net/eric.johnston/freepics.htm gldoqlclctgtcizceuovzqleir From fredrik at pythonware.com Thu Jun 3 15:16:03 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 3 Jun 1999 19:16:03 GMT Subject: pyGTK on Windows References: <3757D453.A302E757@interar.com.ar> Message-ID: <037b01beadf5$8b5d1a80$f29b12c2@pythonware.com> Nahuel wrote: > Hi, im about to do a cross-plataform GUI application in Linux and > Windoze... i must > choose the GUI toolkit.. my question is .. can i use pyGTK under > Windows??? > > (I need a gui that can display a table with about 4000 lines without > crashing (not like Tk :)) you do mean 4,000,000 lines, don't you? or did you use a seriously broken version of Tk(inter)? after all, if it's a bug in your program, changing the UI toolkit won't help... From smigowsky at dspace.de Tue Jun 8 08:01:51 1999 From: smigowsky at dspace.de (Stefan Migowsky) Date: Tue, 8 Jun 1999 12:01:51 GMT Subject: COM Question - QueryInterface? Message-ID: <137053459BA7D211B3930090272A62CA07B4EC@newsintern.dspace.de> Hi, you get the IDispatch interface with this call prtoviding you have an IUnknown. >>>import pythoncom >>>IUnk >>>IUnk.QueryInterface(pythoncom.IID_IDispatch) # Query IDispatch >>>IUnk.QueryInterface(pythoncom.IID_IDispatch).QueryInterface(pythoncom.IID _IUnknown) # Query IUnkown again You just have to get hold off at least one interface object. If you use the wrapper classes generated by makepy you can get the interface by using the _oleobj_ attribute e.g: >>>from win32com.client import Dispatch >>>drives = Dispatch("AmAccess.Drives") >>>drives._oleobj_ Hope this helps Stefan > ---------- > Von: Chris Tavares[SMTP:] > Gesendet: Dienstag, 8. Juni 1999 03:17:58 > An: python-list at cwi.nl > Betreff: COM Question - QueryInterface? > > I've got a (hopefully easy) question about python's COM support. > > I'm developing a COM object in C++ which implements the COM collection > idiom - an Item method that returns another object. The code in Python > I'm using is something like this: > > from win32com.client import Dispatch > drives = Dispatch("AmAccess.Drives") > drive = drives.Item("c:") > dir = drive.Item("some-area") > > On this last line, I get an AttributeError for Item. > > I think I know the reason why - the interface returned from > Drives.Item > isn't a dual, it's an oleautomation compatible vtable interface. > IDispatch on that object is implemented separately. So, PythonCOM sees > the VT_UNKNOWN return type and wraps a PYIUnknown object around it. I > need to be able to do a QueryInterface for IDispatch. > > How do I get Python to do that? There's a PyIID type, but > apparently it > only works for class or progids. Anyone got any suggestions? > > Thanks for any help, > > -Chris > > > From matomira at acm.org Sun Jun 13 21:31:57 1999 From: matomira at acm.org (Fernando D. Mato Mira) Date: Mon, 14 Jun 1999 03:31:57 +0200 Subject: broken References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> Message-ID: <37645B8D.1A267771@acm.org> Fernando Mato Mira wrote: > [For example, I can think the Eiffel syntax is `philosophically' broken, but > as `infix' syntaxes go, it is not. And it's a good language (I programmed Correction. There's one thing broken. The Subject Oriented syntax, but as Eiffel was started in '85, I guess that is understandable. Ada 95 got this one right. Unfortunately, the semantics qualify as `multiply broken' regarding this issue: 1. They thought about multiple dispatch, and they broke it on purpose. 2. If you specialize on more than one parameter, it should be the same type specifier for all of them, i.e. only applicable to predicates, copying, arithmetic and things like that, not useful most of the times one wants several specializers. 3. Worse of all, instead of just adopting a left-to-right precedence rule, one that looks very ugly was added, increasing the complexity of a document that is already big enough. In '95, at VRAI we refocused our application from AI-oriented to (soft) real-time. I grabbed the 9X specs, and the initial excitement turned to dissapointment (the prototype was in CLOS). Moving would have not only meant losing a lot in flexibility, but, worse of all, we would move only from being third-class to second-class citizens (SGI platform). And I would have rather dedicate the extra effort to CL. So after a little successful experience, and given the simpler requirements, we went with C++. Needless to say, the project became a death march. You don't go with C++ unless you can afford paying 5-10 times more for a lot less functionality. -- Fernando D. Mato Mira Real-Time SW Eng & Networking Advanced Systems Engineering Division CSEM Jaquet-Droz 1 email: matomira AT acm DOT org CH-2007 Neuchatel tel: +41 (32) 720-5157 Switzerland FAX: +41 (32) 720-5720 www.csem.ch www.vrai.com ligwww.epfl.ch/matomira.html From tavares at connix.com Thu Jun 10 21:43:59 1999 From: tavares at connix.com (Chris Tavares) Date: Thu, 10 Jun 1999 21:43:59 -0400 Subject: COM Question - QueryInterface? References: <375C7D56.C9744E39@connix.com> <375fe0b1.1117810@news.freeserve.net> <375EFF29.2C1D0FB7@connix.com> <3760ffc3.2905460@news.freeserve.net> Message-ID: <376069DF.399FD81D@connix.com> Toby Dickenson wrote: > (posted and cced to Chris) > > Chris Tavares wrote: > > >Thanks. The reason that the interface in question isn't a dual is because my > >object design depends quite heavily on having multiple interfaces. If you have > >multiple duals, you end up with lots of problems with IDispatch, since you can't > >safely implement more than one version of the same interface on a single object > >(and lots of people have tried, REALLY HARD). > > This is a fallacy about IDispatch that I've heard from many sources, but it > certainly is not true. > > One true statement is that you can only have one interface known as > IID_IDispatch. This causes a problem for scripting languages that can not > QueryInterface (or, worse, which QueryInterface behind your back).[ > I would disagree that this is a fallacy. It DOES cause problems for scripting languages that won't do QI, but there's another client that can do a QI behind your back - the COM remoting layer. You've got the possibility of some really wierd bugs that don't show up in inproc that jump up and bite you when you go oop or remote. > > If you need to support this kind of client (VBScript, JScript, what else? > definitely not Python) then you need to implement IID_IDispatch with the union > of the methods from all your other interfaces. The page Chris mentions (below) > has a great summary of some solutions to this. > > >So what I'm doing is having multiple oleautomation compatible interfaces, and then > >using a typelib-driven IDispatch implementation that I got from > >http://www.sellsbrothers.com/tools/multidisp/index.html. This automagically merges > >all my separate interfaces into a pseudo-object model. Really neat stuff, and > >saves a TON of work. > > Follow that advice if you need to support those lesser scripting clients, or > don't if you don't. > > In any case, there is still no reason not to make all your other interfaces dual > too. This should be an easy step. I am assuming you already have some IDL for > these interfaces? Change the oleautomation line to dual, and hook up the same > typelib-driven IDispatch implementation you are already using for IID_Dispatch. > If you are using ATL for this implementation then it all comes for free. The > advantages? You get easier access from Python, and in VB you get compile time > type safety. > I understand the argument you're making. To be honest, I don't expect anyone other than me to call these objects from Python - heck, my coworkers are still doing database apps in C++! I don't want to make the interfaces dual. Just chalk it up to stubborness, I guess. And in VB I've already got type safety. > > In your specific example, the type library would say your collection object's > Item method returns an ITavaresDrive (or whatever) and python would use an > appropriate makepy-generated wrapper. > > >Having tried that, I find that I now have access to IDispatch::Invoke. Well, what > >I really wanted was win32com.client.dynamic.Dispatch. How do I get to the wrapped > >IDispatch rather than the raw one? > > drive = drives.Item("c:")._oleobj_.QueryInterface(pythoncom.IID_IDispatch) > win32com.client.Dispatch(drive) > > (from memory) > Thanks, I think this will do the trick! > > I hope this helps, > > Toby Dickenson Sure does! -Chris From tim_one at email.msn.com Sat Jun 5 15:59:58 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 5 Jun 1999 15:59:58 -0400 Subject: Proper Radix Formatting of Longs? In-Reply-To: <7j4vp6$je8$1@bashir.ici.net> Message-ID: <000201beaf8d$fde14100$8c9e2299@tim> [Tom Vrankar] > I use Python a lot for computer hardware testing and communications. It > generally works great. > > However, > [a number of irritations boiling down to that Python has no unsigned > integral type & checks for overflow on signed integer arithmetic, > so unsigned 32-bit int arithmetic is clumsy on a 32-bit platform] > ... > Is there a standard pythonic idiom for using 32-bit integers as > if they were unsigned, so that 0x8000_0000 +0x8000_0000 =0, just > like in C or my hardware ALU? Curiously, I first started using Python when working for a HW vendor trying to use 32-bit workstations to design a 64-bit CPU with a 64x64->128 multiplier. All the same irritations applied there -- but since *no* form of 32-bit arithmetic was adequate (in Python or C), it never occurred to us that faking it with Python longs was a burden . Which is the easiest all-Python answer there is: Python doesn't have an unsigned integral type, period. So you convert everything to long on input, live happily for the duration, and cut it back to whatever you need on output. If that's not fast enough (it was for me -- in fact, even wrapped stuff in classes to hide the I/O conversions), you'll have to write a C extension module. Note that Python doesn't gripe about 32-bit bit-fiddling ops (~ & | ^ << >>), so maybe you can get away with writing just a handful of C functions. > Is there a standard pythonic way to format longs into > arbitrary radices (sort of like an inverse string.atol)? str(), hex() and oct() are "it". Feed hex a long, and it will always have "0x" at the front and "L" at the end, so hex(along)[2:-1] always works to strip the decorations. > Is there a secret handshake required to at least get string.atoi() > to happily convert "0x8000_0000" symmetrically with "%x" %0x8000_0000? No. Python allows 0x notation with the MSB set in numeric program literals for the convenience of programmers building bit masks; atoi is stricter because it's used to crack user (as opposed to programmer) input. Note that there's a real distinction here: as a *bitmask*, 0xffffffff yields an int with exactly the least-significant 32 bits set, regardless of whether you're running an a platform where Python's ints are 32 bits or 64 bits. But as an *integer* (which is atoi's view of the world), 0xffffffff would be -1 on a 32-bit platform but 4294967295 on a 64-bit one. So the dual view of bounded signed ints as either bitmasks or integers isn't symmetric "even in theory", and Python picked a compromise. It's not convenient for everyone, but so it goes. The dual view of *un*bounded signed ints doesn't suffer this asymmetry, and is independent of platform. > Yes, I know I could probably write some elaborate python > functions to manually convert back and forth, If you can afford Python speed, "elaborate" is inaccurate -- these kinds of functions are generally trivial to knock off; e.g., >>> def last32(i, _mask32=0xffffffffL): try: return int(i) except OverflowError: tail = i & _mask32 # now positive long return (int(tail >> 1) << 1) | int(tail & 1) >>> def uns32_add(i, j): try: return i + j except OverflowError: return last32(long(i) + j) >>> uns32_add(0x80000000, 0x80000000) 0 >>> > but when handling megabytes, the performance would be unacceptable. That's what you get for working in a field 99.9999% of the world doesn't care about . Seriously, Python isn't going to grow an unsigned 32-bit type overnight, so if it really is too slow in Python you're going to have to avail yourself of the extension facilities. You can write a complete uns32 type as an extension type (a doable but non-trivial project), or just the handful of functions you need most. general-purpose-vs-all-purpose-ly y'rs - tim From da at ski.org Tue Jun 29 00:35:41 1999 From: da at ski.org (David Ascher) Date: Mon, 28 Jun 1999 21:35:41 -0700 (Pacific Daylight Time) Subject: Python GUIs: Summary and Conclusion In-Reply-To: <377845DD.23AD193A@compaq.com> Message-ID: On Tue, 29 Jun 1999, Greg Ewing wrote: > Wasn't there a Tcl-less Tk interface once before, that wasn't kept up > to date? Called something beginning with R that I can't remember. Rivet. > Maybe you could use that as a starting point if the Tk C interface > hasn't changed too radically. I wouldn't -- I don't think the rivet webpage is around anymore! My Trinket.py is still around, but certainly not up to date. I thought that Max Skaller had done some work more recently along the same lines, but I can't find a URL for it. --david From jepler at inetnebr.com Wed Jun 2 10:36:03 1999 From: jepler at inetnebr.com (Jeff Epler) Date: Wed, 02 Jun 1999 14:36:03 GMT Subject: A problem with re.split() References: <87pv3en24q.fsf@pc-hrvoje.srce.hr> Message-ID: import re def resplit(pat, str): """Emulate perl braindamage at the cost of an extra function call""" if not pat: return map(None, str) else: return re.split(pat, str) Jeff -- \/ http://www.redhat.com/ Jeff Epler jepler at inetnebr.com Hey, what do you expect from a culture that *drives* on *parkways* and *parks* on *driveways*? -- Gallagher From tim_one at email.msn.com Tue Jun 29 03:15:19 1999 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 29 Jun 1999 03:15:19 -0400 Subject: total idiot question: +=, .=, etc... In-Reply-To: <377847EE.D5B97A23@compaq.com> Message-ID: <000501bec1ff$2517f1a0$719e2299@tim> >> class A(B): >> def __init__(self, x, y, z): >> B.__init__(self, x, y, z) >> >> can be grating too [Greg Ewing] > I could live with having to explicitly name the > superclass, provided something checked that the > class I named was actually a direct base class > of the one where the method is defined. That > way things would be less likely to break > mysteriously when I rearrange the class > hierarchy. > > I'm still thinking about how to implement > this... Hard! Class attrs (like __init__) don't point back to the class they belong to. In the absence of sharing, though, the class chain can be searched for the class that owns a particular attr value. I'll attach something that does that; it's ugly; I'll never use it ; could speed it a lot by caching the search result. seems-a-lot-easier-to-do-it-by-eye-ly y'rs - tim class BaseInit: """A mixin class for "safe" superclass __init__ calls. class X(Y, Z, ..., BaseInit): def __init__(self, whatever): self.baseinit(K, whatever) self.baseinit(K, whatever) invokes K.__init__(self, whatever), but raises an error unless K is a direct base class of X (the class in which the __init__ calling baseinit is defined). """ def baseinit(self, base, *args, **kwargs): import sys if not isinstance(self, base): raise TypeError(`self` + " isn't even an instance of " + `base`) # init <- code object of __init__ we were called from try: raise 'bogus' except 'bogus': tb = sys.exc_info()[2] init = tb.tb_frame.f_back.f_code # back to the __init__ if init.co_name != "__init__": raise ValueError("baseinit must be called from __init__") # search the class hierarchy for that __init__, setting # c to the class it belongs to candidates = [self.__class__] while candidates: c = candidates.pop(0) if c.__dict__.has_key("__init__"): cinit = c.__init__.im_func.func_code if init is cinit: break candidates = list(c.__bases__) + candidates else: raise SystemError("didn't find __init__ in class or bases!") if base not in c.__bases__: raise TypeError("attempt to init superclass " + `base` + " from " + `c` + " but the " "superclass isn't an immediate base class") apply(base.__init__, (self,) + args, kwargs) class A: def __init__(self): print "in A's init" class B(A, BaseInit): def __init__(self): print "in B's init" self.baseinit(A) class C(B, BaseInit): def __init__(self): print "in C's init" self.baseinit(B) print "next one should be bogus" self.baseinit(A) b = B() c = C() From larsga at ifi.uio.no Wed Jun 16 10:59:53 1999 From: larsga at ifi.uio.no (Lars Marius Garshol) Date: 16 Jun 1999 16:59:53 +0200 Subject: HTML bettering? References: <1318D78C9072D11195C9006094EA98A72C214D@ocesrv> Message-ID: * Matej Cepl | | How to make as simple as tool which would make some simple operation | over HTML (e.g., headings numbering)? If I would use htmllib.py, I | would have to build HTMLformatter or I am wrong and it is easy? You could very well use htmllib and just make an htmllib application that writes the HTML back out again, and modify it slightly to do heading numbering. I don't think HTMLFormatter would do you any good for this sort of thing. However, HTML isn't a very good SGML application for this sort of thing, since the following is entirely legal: ...
    On the topic of nesting

    Why it's good

    And why HTML doesn't have it

    ... ISO HTML provides a better starting point for this sort of thing, as do most other SGML applications intended for articles. Personally, I use a private SGML DTD for my articles and then use DSSSL stylesheets to produce the HTML, complete with a table of contents. Adding heading numbering should take all of 5 minutes. :) And today I've put together the infrastructure to produce PDF from the same SGML source as well. Here's an example: --Lars M. From tismer at appliedbiometrics.com Wed Jun 16 10:09:27 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Wed, 16 Jun 1999 14:09:27 GMT Subject: Python Webserver References: <3767A69D.50DC7FBF@serop.abb.se> Message-ID: <3767B017.BA69E220@appliedbiometrics.com> "Thomas S. Strinnhed" wrote: > > Hi > > I don't know if I've dreamt, but I think I saw something about > a webserver written in Python. (It's not the embedded-in-Apache-thing > I'm thinking of) > Now I just can't seem to find it anywhere, so does someone know anything > about this. Hipshots are welcome. I thought it'd be something fun to > play with. go to http://www.nightmare.com/ and read about Medusa. That's it. -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From joe at strout.net Wed Jun 16 16:58:44 1999 From: joe at strout.net (Joe Strout) Date: Wed, 16 Jun 1999 13:58:44 -0700 Subject: BiBTeX module? Message-ID: Is there a BiBTeX module for Python? I did a search at python.org, but apart from a Perl module (ick!), I didn't find anything. Thanks, -- Joe -- ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe at strout.net http://www.strout.net | `------------------------------------------------------------------' Check out the Mac Web Directory! http://www.strout.net/macweb.cgi From bernhard at alpha1.csd.uwm.edu Thu Jun 3 14:17:08 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 3 Jun 1999 18:17:08 GMT Subject: Why won't this work??? References: <7j0rkr$1eeu$1@rtpnews.raleigh.ibm.com> <7j1qc5$3rj$1@m2.c2.telstra-mm.net.au> <7j3e5q$nrq$1@rtpnews.raleigh.ibm.com> <7j5pp9$68c$1@rtpnews.raleigh.ibm.com> Message-ID: On Thu, 3 Jun 1999 07:44:21 -0400, Jr. King wrote: > Most of > the time people look for email answer they get the response Post here, Read > Here, I thought that was a rule. It depends. Generally it is true. Of course there are several occasions, when it is better to mail the poster and not clutter of the newsgroup with messages which are only interesting to the author. Right now I don't feel like looking it up, but AFAIR not giving a email address is broadly considered unappropriate in newsgroups. > I can say he was wrong all I want, and you can say he wasn't. > You will not be changing my opinion. I just wanted to give you some insights in views of other persons, if you decide not to use it, that is entirely up to you. This is not about opinion. Bernhard From news at dorb.com Thu Jun 24 20:41:24 1999 From: news at dorb.com (Darrell) Date: Thu, 24 Jun 1999 20:41:24 -0400 Subject: How do can you make a variable static? References: <3772AE33.AA764DFA@alliedsignal.com> Message-ID: > from foo import foo > > SymHanDict={0:0} > > foo() #each call to foo() should add items to > the dictionary > foo() > foo() > > *** the following contained in module foo.py ************************ > def foo(): > global SymHanDict Global means look for it in the foo.py module In this case SymHanDict is in another file and your best bet is to pass it to foo(). If you just don't want to do that try something like this in the module where you plan to call foo(). import foo SymHanDict={0:0} def myFoo(): foo.foo(SymHanDict) Passing a parm is much cleaner than globals anyway. Might I suggest using a class: class Foo: def __init__(self, dict): self._myDict=dict def __call__(self): """Do foo stuff here""" pass myFoo = Foo(SymHanDict) # Call the foo thing here. myFoo() --Darrell From news at dorb.com Thu Jun 17 13:00:35 1999 From: news at dorb.com (Darrell) Date: Thu, 17 Jun 1999 13:00:35 -0400 Subject: Starting a project: any hints? References: <19990617154643.A1680@optiplex.palga.uucp> <7kb384$lgs$1@nnrp1.deja.com> Message-ID: > - Make your program works from the very first day , it doesn't matter > if it barely works. I'd like to emphasize this point. Don't write it all then try it. Its easier to evolve from a functional kernel than to materialize all at once. -- --Darrell From proteus at cloud9.net Wed Jun 2 08:37:48 1999 From: proteus at cloud9.net (Michael Muller) Date: Wed, 02 Jun 1999 08:37:48 -0400 Subject: Windows Stack Size References: <3752C225.65C98B52@cloud9.net> <3752F154.6C444928@ricochet.net> <375413D8.C3B02D2@cloud9.net> <7j1q41$3fu$1@m2.c2.telstra-mm.net.au> Message-ID: <3755259C.3513D254@cloud9.net> Mark Hammond wrote: [snip] > statements in __getattr__ would make this immediately obvious. Also, the > death should take a few seconds to occur - try hitting Ctrl+C in this > period - you may get a traceback telling you exactly where the problem is. > As I recall, the trap was immediate. I'll try the "print"s under linux, though, just to see if there's anything funky going on. > >I'd debug it myself except that I'm happily Windows-free (only creates > >problems when I have to write code for Windows users). If there is no > >obvious answer, I have a work-around. > > And what would the work-around be? > > Mark. Using the raw Tkinter 'Text' control instead of my ScrollingText class. It doesn't seem to have this problem. Unfortunately, it doesn't have scrollbars either. ============================================================================= michaelMuller = proteus at cloud9.net | http://www.cloud9.net/~proteus ----------------------------------------------------------------------------- We are explorers in the further reaches of experience: demons to some, angels to others. - "Pinhead" from "Hellraiser" ============================================================================= From MHammond at skippinet.com.au Tue Jun 1 19:13:30 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Wed, 2 Jun 1999 09:13:30 +1000 Subject: need help checking for stack overflow in Win32 References: <5lk8to3su3.fsf@eric.cnri.reston.va.us> Message-ID: <7j1pcc$256$1@m2.c2.telstra-mm.net.au> Actually, I was about to post this yesterday, and to prove my point I wrote: def die(): die() Expecting to see the crash. I was then going to go into a rant about how win32api.Apply would actually let you catch this (and any other Win32) exception as a temporary solution. But it worked correctly - ie, Python raised a RuntimeError: Max Recursion. So I guessed that 1.5.2 had fixed this, presumably by reducing the recursion count for Win32. Apparently not! Thomas' reply is correct, and indeed a number of years ago I did play with this. I even reported my results, but no one seemed interested, so I dropped it (waiting for someone else to complain :-) It still seems to me that this is not the ideal good solution. In my simple example above, we did not die. But make anything less contrived, and we have C frames with larger allocations on the stack, and we will die. Whatever number we pick, we would need to make it quite a bit lower than the "normal" case, to handle the fact that some C functions may allocate from bytes to kilobytes on the stack. A better mechanism would be to use Win32 exception handlers. Then you dont need artificial recursion checks at all - leave it to the OS. However, it isnt clear to me where this exception handler should be placed, nor indeed if setting up a Win32 exception handler inside the VM would have a significant performance hit. A plus would be we could also catch Access Violations (Im not sure what we would do with them - but a traceback would be nicer than Dr Watson when dealing with buggy extensions!) Thomas' solution is simple, and requires either a simple source file change, or using the MSVC GUI to adjust the stack size. If you would like to experiment with a Win32 exception handler then I would be happy to see where that leads us... Mark. Guido van Rossum wrote in message <5lk8to3su3.fsf at eric.cnri.reston.va.us>... >I could use some help from someone with a little time, some knowledge >of Python internals, and some Win32 C expertise. On Win32 platforms, >infinite recursion causes an Application Error (a fatal windows >error). There is some machinery in Python to check for this >condition, but apparently it doesn't work on Win32. Please help! > >--Guido van Rossum (home page: http://www.python.org/~guido/) From gerrit.holl at pobox.com Sun Jun 27 05:24:33 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Sun, 27 Jun 1999 11:24:33 +0200 Subject: RuntimeError? Message-ID: <19990627112432.A29097@optiplex.palga.uucp> Hallo, can someone please give me an example when a RuntimeError is raised? I don't understand: if none of the others are raised. groeten, Gerrit. -- The Dutch Linuxgames homepage: http://linuxgames.nl.linux.org Personal homepage: http://www.nl.linux.org/~gerrit/ Discoverb is a python program (in several languages) which tests the words you learned by asking it. Homepage: http://www.nl.linux.org/~gerrit/discoverb/ From mark.butterworth at cis.co.uk Wed Jun 23 04:25:52 1999 From: mark.butterworth at cis.co.uk (Mark Butterworth - U-Net) Date: Wed, 23 Jun 1999 09:25:52 +0100 Subject: pkzip and using popen on Windows 98 ??? Message-ID: <2H1c3.180$T3.411@newsr2.u-net.net> Im having trouble using os.system or popen (both win32pipe & os) under windows 98. It will not return the exit value of the command Im running (which is infozips - zip). Also when attempting to use win32pipe.popen3 - my pipe read's hang after one or two reads. Also does anyone know of any python modules which can read / write pkzip (or infozip) format files as I don't like calling external commands. Any help would be appreciated? From matomira at iname.com Sat Jun 12 13:07:36 1999 From: matomira at iname.com (Fernando Mato Mira) Date: Sat, 12 Jun 1999 19:07:36 +0200 Subject: OO (was: Why is tcl broken?) References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> Message-ID: <376293D8.163C6C15@iname.com> Fernando Mato Mira wrote: > [For example, I can think the Eiffel syntax is `philosophically' broken, but > as `infix' syntaxes go, it is not. And it's a good language (I programmed Actually, it's a _great_ language to learn OO (although of course in the restricted single-dispatch way most people know about. I like to call that "Subject Oriented"). Occan taught me about concurrency. Eiffel taught me OO. CLOS taught me what OO really means. -- "Object Oriented is to not think only about your `subject' and forget about your `arguments' - the syntactic objects of your sentence". Fernando D. Mato Mira Real-Time SW Eng & Networking Advanced Systems Engineering Division CSEM Jaquet-Droz 1 email: matomira AT acm DOT org CH-2007 Neuchatel tel: +41 (32) 720-5157 Switzerland FAX: +41 (32) 720-5720 www.csem.ch www.vrai.com ligwww.epfl.ch/matomira.html From kas at maps.magnetic-ink.dk Wed Jun 30 05:39:04 1999 From: kas at maps.magnetic-ink.dk (Klaus Alexander Seistrup) Date: Wed, 30 Jun 1999 11:39:04 +0200 Subject: I am v. stupid, please help References: <3779d5f5@discussions> Message-ID: <3779E5B8.3CDB36CB@maps.magnetic-ink.dk> Newbie wrote: > name = input('What is your name : ') > > This works for integers but not for strings, Use raw_input() instead. //Klaus -- ???[ Magnetic Ink ]?????????????????????????????????????????????????????????? ???[ http://www.magnetic-ink.dk/ ][ maps == mail abuse prevention system ]??? From arcege at shore.net Thu Jun 3 14:13:50 1999 From: arcege at shore.net (Michael P. Reilly) Date: Thu, 03 Jun 1999 18:13:50 GMT Subject: Use of StringIO vs cStringIO in standard modules References: <8790a1620b.fsf@pc-hrvoje.srce.hr> <199906031425.KAA06935@eric.cnri.reston.va.us> <87aeuh5kqc.fsf@pc-hrvoje.srce.hr> Message-ID: Hrvoje Niksic wrote: : Guido van Rossum writes: :> Hrvoje Niksic : :> :> > I noticed that many standard modules use StringIO and not :> > cStringIO, although they don't need subclassing. Is this :> > intentional? :> > :> > For example, base64.py uses StringIO to implement encodestring() :> > and decodestring(). Since both functions write to output line by :> > line, I imagine the performance hit of StringIO vs cStringIO might :> > be non-negligible. :> :> Have you noticed any speed difference? : Yes, quite a bit. Trivially replacing StringIO with cStringIO in : base64.py makes encoding 2.3 times and decoding 3.6 times faster. : That's on my system (Ultra 2 under Solaris 2.6), measured repeatedly : with time.clock() and an approx. 1M sample string. I can post the : script if there is interest. : Maybe the correct solution for base64.py would be to use something : like this at top-level: : try: : from cStringIO import StringIO : except: : from StringIO import StringIO :> cPickle, because calling it from C is much faster than calling :> StringIO from C; however I believe that for calls from Python, :> StringIO isn't that much slower. : I've looked at the code, and to me it seems that the slowness comes : from creating new strings on each write, where cStringIO just resizes : its internal buffer and creates the string only at the end. :> > Furthermore, is there a particular reason for maintaining two :> > parallel StringIO implementations? If subclassing is the reason, :> > I assume it would be trivial to rewrite StringIO to encapsulate :> > cStringIO the same way that UserDict encapsulates dictionary :> > objects. :> :> That's not the reason; it's got more to do with not requiring a C :> extension where plain Python code will do. Also to have a reference :> implementation. : But then you have to maintain both, *and* you get much slower code. : Is it worth it? There are some interface differences between calls to cStringIO.StringIO and StringIO.StringIO which I think makes StringIO more "usable" in some cases. Specifically, if you create an instances of cStringIO.StringIO with initializeing data, then the instance becomes unwritable: >>> import cStringIO, StringIO >>> f = StringIO.StringIO("Hi there") >>> f.seek(0, 2) >>> f.write("\n") >>> f.getvalue() 'Hi there\012' >>> g = cStringIO.StringIO("Hi there") >>> g.seek(0, 2) >>> g.write("\n") Traceback (innermost last): File "", line 1, in ? AttributeError: write >>> This could surely break some of the existing code. But I will mention that: f = StringIO.StringIO(str) is equivalent to: f = cStringIO.StringIO() f.write(str) f.seek(0) I would want to see cStringIO mimic StringIO before the two are merged. And yes, Guido, I have noticed some differences at times. -Arcege From tom at spirit.gcrc.upenn.edu Mon Jun 7 13:01:38 1999 From: tom at spirit.gcrc.upenn.edu (Tom Fenn) Date: Mon, 07 Jun 1999 13:01:38 -0400 Subject: Giving talk on Python. Need references. Message-ID: <375BFAF2.C543178B@spirit.gcrc.upenn.edu> Hello all, I will be giving a talk on using Python at the ASMS Conference on Mass Spectrometry next week. I'm discussing a "Cross Platform solution to data analysis applications" with an emphasis on chromatography and mass spectrometry. I'd like some references to other scientific/numerical applications that I can reference. If anyone has a relevent document they'd like cited, please send me the reference. (And a copy I can look at if it's not readily available.) Thanks. Tom Fenn From harv at hub.org Tue Jun 1 23:38:22 1999 From: harv at hub.org (Michael Harvey) Date: 2 Jun 1999 03:38:22 GMT Subject: ax25 module? Message-ID: <7j28ve$2k8u$1@hub.org> Hi, I know that this question is probably answered in documentation somewhere that I can't find, but I'm going to ask anyway. Are there any ax25 modules for Python? There might not be, but I just started using it yesterday, and am wondering if there are. Thanks in advance Mike Harvey harv at hub.no_spam.org From guido at CNRI.Reston.VA.US Thu Jun 3 10:25:03 1999 From: guido at CNRI.Reston.VA.US (Guido van Rossum) Date: Thu, 03 Jun 1999 10:25:03 -0400 Subject: Use of StringIO vs cStringIO in standard modules In-Reply-To: Your message of "03 Jun 1999 11:56:36 +0200." <8790a1620b.fsf@pc-hrvoje.srce.hr> References: <8790a1620b.fsf@pc-hrvoje.srce.hr> Message-ID: <199906031425.KAA06935@eric.cnri.reston.va.us> Hrvoje Niksic : > I noticed that many standard modules use StringIO and not cStringIO, > although they don't need subclassing. Is this intentional? > > For example, base64.py uses StringIO to implement encodestring() and > decodestring(). Since both functions write to output line by line, I > imagine the performance hit of StringIO vs cStringIO might be > non-negligible. Have you noticed any speed difference? cStringIO is important for cPickle, because calling it from C is much faster than calling StringIO from C; however I believe that for calls from Python, StringIO isn't that much slower. (This as opposed to cPickle vs. Pickle, where the performance difference is 2-3 orders of magnitude.) > Furthermore, is there a particular reason for maintaining two parallel > StringIO implementations? If subclassing is the reason, I assume it > would be trivial to rewrite StringIO to encapsulate cStringIO the same > way that UserDict encapsulates dictionary objects. That's not the reason; it's got more to do with not requiring a C extension where plain Python code will do. Also to have a reference implementation. (Ditto for pickle.) --Guido van Rossum (home page: http://www.python.org/~guido/) From Reimer.Behrends at p98.f112.n480.z2.fidonet.org Wed Jun 30 09:14:09 1999 From: Reimer.Behrends at p98.f112.n480.z2.fidonet.org (Reimer Behrends) Date: Wed, 30 Jun 1999 14:14:09 +0100 Subject: total idiot question: +=, .=, etc... Message-ID: <000015b4@bossar.com.pl> From: behrends at cse.msu.edu (Reimer Behrends) Bernhard Herzog (herzog at online.de) wrote: [...] > I think a better solution that better fits the python syntax is to > simply omit the self but not the dot: > > .last = .lines[-1] > .lines = .lines[:-1] Such a syntax was proposed a few years ago for private variables, IIRC, but was discarded because it had various problems. And personally, I'd rather live with the inconvenience of the explicit self rather than having Python's design obfuscated by some strange syntax; syntax highlighting can go a long way towards making the current state of affairs more manageable. Reimer Behrends From bbaetz at ug.cs.usyd.edu.au Tue Jun 1 19:38:02 1999 From: bbaetz at ug.cs.usyd.edu.au (Bradley Baetz) Date: Wed, 02 Jun 1999 09:38:02 +1000 Subject: Reproducable Python core dump Message-ID: <37546EDA.20825D43@ug.cs.usyd.edu.au> Spam detection software, running on the system "albatross.python.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hi, My CS project for this semester involves modifying Grail to support navigation through a keypad, similarly to Lynx. Whilst testing my handing of nested tables, I came across this bug: The following will cause a reproducable core dump in Python: [...] Content analysis details: (5.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.0 FH_DATE_IS_19XX The date is not 19xx. -0.0 NO_RELAYS Informational: message was not relayed via SMTP 0.0 NORMAL_HTTP_TO_IP URI: Uses a dotted-decimal IP address in URL 1.3 URI_HEX URI: URI hostname has long hexadecimal sequence 2.2 HTML_IMAGE_ONLY_12 BODY: HTML: images with 800-1200 bytes of words 3.2 HTML_OBFUSCATE_10_20 BODY: Message is 10% to 20% HTML obfuscation 0.0 HTML_MESSAGE BODY: HTML included in message 1.1 HTML_SHORT_LINK_IMG_1 HTML is very short with a linked image -0.0 NO_RECEIVED Informational: message has no Received headers -3.9 AWL AWL: From: address is in the auto white-list The original message was not completely plain text, and may be unsafe to open with some email clients; in particular, it may contain a virus, or confirm that your address can receive spam. If you wish to view it, it may be safer to save it to a file and open it with an editor. -------------- next part -------------- An embedded message was scrubbed... From: Bradley Baetz Subject: Reproducable Python core dump Date: Wed, 02 Jun 1999 09:38:02 +1000 Size: 3497 URL: From a.mueller at icrf.icnet.uk Mon Jun 7 11:33:37 1999 From: a.mueller at icrf.icnet.uk (Arne Mueller) Date: Mon, 07 Jun 1999 16:33:37 +0100 Subject: fork() Message-ID: <375BE64A.EB997F24@icrf.icnet.uk> Hi All, I've switched from 'threading' to 'fork' (remember the discussion some days ago) since that gives me real parallel processing. But (off course) there are other problems when forking a process ;-( : 1. The parent process reads in a discitonary with about 250000 keys, this is a sort of static database which never changes. 2. A bidirectional pipe is created for each child process 3. The parent forks 4. The children claculate some for which they've to access the large dictionary. 5. All the children are able to send pickled objects to the parent (via the pipe) All that woks fine now (after I spend a long time fiddling with the pipe and select stuff to synchronize I/O). However the forking is a waste of time and memory because all the children get their own large dictionary! Is there a way to use shared memory in python, I mean how can different processes access (for read only) one object without passing the keys of the dictionary object through a pipe (the children need _quick_ access to that dictionary)? Thanks alot (again) for your suggestions, Arne -- Arne Mueller Biomolecular Modelling Laboratory Imperial Cancer Research Fund 44 Lincoln's Inn Fields London WC2A 3PX, U.K. phone : +44-(0)171 2693405 | Fax : +44-(0)171 269 3258 email : a.mueller at icrf.icnet.uk | http://www.icnet.uk/bmm/ From suzuki611 at okisoft.co.jp Mon Jun 7 20:18:13 1999 From: suzuki611 at okisoft.co.jp (Hisao Suzuki) Date: 08 Jun 1999 09:18:13 +0900 Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7iqhkb$d7s@wiscnews.wiscnet.net> <7iu7ma$d33$1@cronkite.cc.uga.edu> <02hfonzsx2.fsf@rtp.ericsson.se> <02909zzou0.fsf@rtp.ericsson.se> <87zp2f4qrz.fsf@pc-hrvoje.srce.hr> <14172.6652.550882.854800@bitdiddle.cnri.reston.va.us> Message-ID: In article <14172.6652.550882.854800 at bitdiddle.cnri.reston.va.us>, Jeremy Hylton wrote: | >>> (let ((sum 0)) | (let ((add (lambda (x) (set! sum (+ sum x)))) | (sub (lambda (x) (set! sum (- sum x))))) | (add 2) | (add 3) | (sub 1) | sum)) | 4 A bound method is equivalent to a closure (or rather a function with its own environment) in a certain sense. The `self' parameter serves as the environment. The traditional (or good old :-) translation of the above code would be like this: def alsoWorks(): class _alsoWorks_t: def add(self, x): self.sum = self.sum + x def sub(self, x): self.sum = self.sum - x i = _alsoWorks_t() i.sum = 0 i.add(2) i.add(3) i.sub(1) return i.sum --===-----========------------- Sana esprimo naskas sanan ideon. SUZUKI Hisao suzuki611 at okisoft.co.jp, suzuki at acm.org. From mwh21 at cam.ac.uk Wed Jun 23 13:28:34 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 23 Jun 1999 18:28:34 +0100 Subject: set im_self References: <7kqokb$7as$1@ns.mtu.ru> Message-ID: "Oleg Orlov" writes: > Hello. > Is there any way to set im_self attribute (ie bind method object)? > Thanks. The `new' module can do this: >>> class C: ... def m(self): ... print self ... >>> c=C() >>> c.m() <__main__.C instance at 8111318> >>> import new >>> cm=new.instancemethod(C.m.im_func,c,C.m.im_class) >>> cm() <__main__.C instance at 8111318> Be aware that RedHat up to version 5.2 (I think) shipped a Python without the new module compiled in, so you'll need to recompile or update from an Andrich rpm if you're lumbered with one of those. HTH Michael From paul at prescod.net Wed Jun 30 19:53:38 1999 From: paul at prescod.net (Paul Prescod) Date: Wed, 30 Jun 1999 23:53:38 GMT Subject: Mailbox, tell and read Message-ID: <377AAE02.E8591727@prescod.net> The mailbox message objects simulate a file interface by seeking through a mailbox. A read() returns the entire message. It does this by seeking to the start, reading to the message end, and returning the data. The problem is that message offsets are derived by file.tell() which I presume is in terms of bytes. But then it does a read() based on the offsets and read() is in terms of characters. These don't match up on Windows because of CR/LF pairs. I think that the right fix is to never use tell() and instead keep track of the location by counting characters. Does that make sense? -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco "I don't want you to describe to me -- not ever -- what you were doing to that poor boy to make him sound like that; but if you ever do it again, please cover his mouth with your hand," Grandmother said. -- John Irving, "A Prayer for Owen Meany" From johnga at primenet.com Sat Jun 19 11:47:10 1999 From: johnga at primenet.com (John E. Garrott) Date: Sat, 19 Jun 1999 08:47:10 -0700 Subject: Newbie question Message-ID: <376BBB7E.A82DA789@primenet.com> I am have a problem with the program below. The intent is, eventually, to get a list and display it, in a list box, then print the selected row from the listbox, but I can't get the callback to work. The function dbs.databases() works, putting, in this case, the databases owned by myself into the listbox. When I click on the listbox items they highlight as expected, but, apparently, list_cb() is never called. I've read all the available literature on binding and signals, tried numerous variations on what is here. No results. This program shows no errors, so is syntactically(sp?) correct. Just doesn't work. What am I doing wrong? Thanks in advance, John -------------------------------------------------------- import dbs import string from Tkinter import * class SelectionBox: def __init__(self, master=None): self.frame = Frame(master, name="frame") self.frame.pack(expand=1, fill=BOTH) self.frame.listbox = Listbox(self.frame, name='listbox') self.frame.listbox.pack(expand=1, fill=BOTH) self.frame.listbox.bind('Button-1', self.list_cb) for item in dbs.databases(): self.frame.listbox.insert(END, item) def list_cb(event): print "Here we are!" def main(): root = Tk() sp = SelectionBox(root) root.minsize(1, 1) root.mainloop() main() From arcege at shore.net Wed Jun 9 10:38:57 1999 From: arcege at shore.net (Michael P. Reilly) Date: Wed, 09 Jun 1999 14:38:57 GMT Subject: Python/C API and setattr References: <375E5257.8579541B@serop.abb.se> Message-ID: <50v73.2457$nn.746290@news.shore.net> Thomas S. Strinnhed wrote: : Hi : I'm building an extention type for Python in C using NT, MSVC++. : It's built as a dll to link in at Runtime. : I'm doing this for practice so the type is quite simple, it's : a CounterType, with an attribute called value (an int) : and the simple operations/methods inc() and dec(). : I've looked pretty much at Mark Lutz's example StackType from : Programming Python and I think I'm doing the same, but I've added : setattrfunc to be able to directly manipulate value as c.value = 23 : and when I use it something goes wrong. : (inc() and dec() work fine) : Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 : Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam :>>> from CounterType import * :>>> c = Counter() :>>> c.value = 23 : Traceback (innermost last): : File "", line 1, in ? : SystemError: error return without exception set :>>> c.value : 23 :>>> : The value is set properly but I can't figure out the system error, it : seems to be something wrong with my setattrfunc. : static void counter_setattr : (counterobject *self, char *name, PyObject *v) : { : if(strcmp(name, "value") == 0) : { : self->value = (int)PyInt_AsLong(v); : } : } : But what would that be?? : I have a hard time finding examples of how to do setattr so : any pointers would be great. Also if someone understands this error, : please post an answer. : My counterobject is this: : typedef struct : { : PyObject_HEAD : int value; : } counterobject; : Thanks : -- Thomas S. Strinnhed, thstr at serop.abb.se Thomas, the prototype for functions in the setattr slot of a Python type is: typedef int (*setattrfunc)(PyObject *, char *, PyObject *); Your counter_setattr function should return an int, true (0) for success, false (-1) for error. I believe the source code and Mark's book (somewhere in Ch 15? but I don't have the book with me) are about the only places this is documented, and it is very obscure. "This looks like a job for Documentation Man!" -Arcege From alan.gauld at gssec.bt.co.uk Thu Jun 24 08:50:01 1999 From: alan.gauld at gssec.bt.co.uk (Alan Gauld) Date: Thu, 24 Jun 1999 13:50:01 +0100 Subject: total idiot question: +=, .=, etc... References: <877lov62z1.fsf@pbl.ddns.org> Message-ID: <37722979.2FCD9A5F@gssec.bt.co.uk> Reimer Behrends wrote: > _am_ getting pretty sick of having to type self.whatever countless > times, where pretty much any other language allows me to discard the > "self." part. Not only is it annoying to type, it also reduces the > readability of OO code a lot, much like the gratuitious use of > punctuation characters as variable prefixes in Perl does. I used to think that, but after some time in python land I just finished reviewing the code of a C++ project (about 5,000 new lines, 7 new classes in a system with 200,000 lines and about 200 classes.). I was amazed to discover how difficult it was to understand the code because I couldn't identify which variables were local to the function, which were instance variables and which were global. This gets worse when dealing with multiple inheritance, I wound up spend significant time in the headers directory doing grep... The self notation makes it clear and pretty unambiguous. Alan G. -- ================================================= This post represents the views of the author and does not necessarily accurately represent the views of BT. From amk at mira.erols.com Mon Jun 28 19:21:21 1999 From: amk at mira.erols.com (A.M. Kuchling) Date: 28 Jun 1999 23:21:21 GMT Subject: SWIG and binary strings? References: <3773a918.0@news.cyberway.com.sg> Message-ID: On 28 Jun 1999 07:57:04 +0300, Markus Stenberg wrote: >Ah, I've concentrated on SSL itself (TLS actually, but still; full TLS/SSL >functionality, no ciphers whatsoever wrapped). I wish someone wrapped whole >OpenSSL and maintained it.. ;-) (I'd do it, but I'm too lazy by half) mxCrypto (http://www.cs.uni-duesseldorf.de/~lemburg/mxCrypto.html) wraps the cipher implementations in OpenSSL; talk to M.A. Lemburg, the author of mxCrypto, about incorporating your SWIG interfaces into mxCrypto. I believe he's been wanting to wrap the SSL interfaces for a while; you may be able to save him some time. (mxCrypto + SSL socket support would be a wonderful thing to have, particularly if it's developed outside of the US.) -- A.M. Kuchling http://starship.python.net/crew/amk/ It would be nice to be unfailingly, perpetually, remorselessly funny, day in and day out, year in and year out until somebody murdered you, now wouldn't it? -- Robertson Davies, _The Diary of Samuel Marchbanks_ From landrum at foreman.ac.rwth-aachen.de Fri Jun 25 09:51:32 1999 From: landrum at foreman.ac.rwth-aachen.de (Gregory A. Landrum) Date: 25 Jun 1999 15:51:32 +0200 Subject: version of python? References: <3773866C.9D29C071@phoenix-edv.netzservice.de> Message-ID: >How could I get the version-number of the installed python-interpreter? Python 1.5.2 (#3, May 23 1999, 10:48:24) [C] on aix4 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import sys >>> sys.version '1.5.2 (#3, May 23 1999, 10:48:24) [C]' -greg --------------------- Dr. Greg Landrum (landrumSPAM at foreman.ac.rwth-aachen.de) Institute of Inorganic Chemistry Aachen University of Technology From chad at vision.arc.nasa.gov Wed Jun 2 14:00:28 1999 From: chad at vision.arc.nasa.gov (Chad Netzer) Date: Wed, 02 Jun 1999 11:00:28 -0700 Subject: All this self dot is making me... References: Message-ID: <3755713C.E59F86AF@vision.arc.nasa.gov> Jim Rudnicki wrote: > For those of us who have less cartilage left in their hands, would it be > acceptable to use "my." or better "me." Or is self. strongly ingrained? > The two less characters add up and the keys are on stronger fingers. First of all, you should probably look into an alternate keybard or keyboard layout, such as Dvorak, if this is a chronic problem. Also, drink lots of water; I've found it to be the best defense against keyboard/mouse related hand problems. Also, use an abbreviation expansion mode of your editor, or find a better editor; these are VERY helpful when using descriptive names. > def Func( this, a, b ): > this.x = a + b > > class Foo: > def __init__( self ): > self.x = 0 > self.f = Func > def fooFunc( me, a, b ): > me.x = a + b > > # who needs class methods? > z1 = Foo() > Func( z1, 5, 7 ) > print z1.x Numeric Python uses this approach (mainly), since these functions can then be made to work on more than one type of object. So, if Func() is meant to apply to a number of objects, this is probably the way to go. However, it would be better written as: def Func(a,b): return a + b So that is doesn't rely on the behavior of "this", which would need to support attribute assignment. If you are going to alter an object's attributes, it is often best to use a method on that object, to "encapsulate" its behavior. But, if you really just want to save typing, I'd suggest letting the computer help you, or change some habits, but don't make obfuscated code. Using "this" instead of "self" should work; but use it consistently. I'd suggest the abbrev expansion is a better solution for you. Chad Netzer From doughellmann at mindspring.com Wed Jun 23 10:18:11 1999 From: doughellmann at mindspring.com (Doug Hellmann) Date: Wed, 23 Jun 1999 14:18:11 GMT Subject: Tk "save as" dialog References: <7kp071$peg$1@oceanite.cybercable.fr> Message-ID: <3770ED6A.8F173340@mindspring.com> BoB wrote: > > For the moment, I'm using Tk "save as" dialog box. But it's plenty of buggs, > and I really can't use it any more. What sort(s) of problems are you having with it? Doug From claird at Starbase.NeoSoft.COM Tue Jun 29 11:58:03 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 29 Jun 1999 10:58:03 -0500 Subject: Why is tcl broken? References: <1283099377-77267484@hypernet.com> <7laoq0$bvh$1@Starbase.NeoSoft.COM> Message-ID: <7laqeb$e17$1@Starbase.NeoSoft.COM> In article , Marco Antoniotti wrote: . . . >I have no problems with that. But the following example is pretty >hard to beat. :) > >============================================================================== >* (defmacro zut (a) `(list ,a)) >ZUT > >* (defun zot (x) (zut x)) >ZOT > >* (compile 'zot) >ZOT > >* (disassemble 'zot) >071B5790: .ENTRY ZOT(x) ; (FUNCTION (T) LIST) > 7A8: ADD -18, %CODE > 7AC: ADD %CFP, 32, %CSP > > 7B0: CMP %NARGS, 4 ; %NARGS = #:G0 > 7B4: BNE L0 > 7B8: NOP > 7BC: MOVE %A0, %A4 ; %A0 = #:G1 > 7C0: MOVE %A4, %A0 ; No-arg-parsing entry point > 7C4: ADD 4, %ALLOC > 7C8: ANDN %ALLOC, 7, %A3 > 7CC: OR 3, %A3 > 7D0: MOVE %A3, %A1 > 7D4: ST %A0, [%A1-3] > 7D8: ST %NULL, [%A1+1] > 7DC: TADDCCTV 4, %ALLOC > 7E0: MOVE %A3, %A0 > 7E4: MOVE %CFP, %CSP > 7E8: MOVE %OCFP, %CFP > 7EC: J %LRA+5 > > 7F0: MOVE %LRA, %CODE > 7F4: UNIMP 0 > 7F8: L0: UNIMP 10 ; Error trap > 7FC: BYTE #x04 > 7FD: BYTE #x19 ; INVALID-ARGUMENT-COUNT-ERROR > 7FE: BYTE #xFE, #xED, #x01 ; NARGS > 801: .ALIGN 4 >* >============================================================================== > >Of course I could have defined a much more intricated macro. . . . As it happens, there's very good work going on just now to beef up Tcl's introspective capabilities. Is *that*-- introspection--the real content of your preference? Incidentally, many of the same ideas and possibilities are available to Python, although I don't know of anyone actively pursuing them for Python. While Tim Peters im- presses me with, among much else, his ability to code clever little methods that tease all sorts of informa- tion from a Python interpreter, I occasionally argue that 'twould be worth the effort to do introspection for Py- thon in a more unified way. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From hinsen at cnrs-orleans.fr Tue Jun 1 04:52:48 1999 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 01 Jun 1999 10:52:48 +0200 Subject: Compiling netCDFmodule on NT: Error References: <374D90FD.51356F8D@bigfoot.com> Message-ID: Hoon Yoon writes: > After rediscovering compile.py by David, I am on the way to compiling > some addin modules. > One of the things that I really want to check out is Konrad's > netCDFmodule. When I attempt to compile it, I get following error. Please try the alpha release of ScientificPython 2.0, which contains a modified netCDF interface. This has been compiled under Windows. The URL is ftp://dirac.cnrs-orleans.fr/pub/ScientificPython-2.0a5.tar.gz -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From arcege at shore.net Tue Jun 8 10:48:57 1999 From: arcege at shore.net (Michael P. Reilly) Date: Tue, 08 Jun 1999 14:48:57 GMT Subject: I'll pay $40 in e-gold if you'll fix this bug. References: <7jigrv$ppo$1@xs3.xs4all.nl> <375CF797.FF0D6436@q-bus.de> Message-ID: Jan Walter wrote: : Hi, : Maybe you get confused a bit by the bash!!! : Try following: : bash$ tcsh : tcsh: cd /tmp/ : tcsh: mkdir dirOne : tcsh: mkdir dirTwo : tcsh: mkdir dirTwo/dirThree : tcsh: ln -s dirTwo/dirThree/ . : tcsh: cd dirThree/ : tcsh: pwd : /tmp/dirTwo/dirThree : Do the same with the bash (removing the directories of course): : bash$ cd /tmp/ : bash$ mkdir dirOne : bash$ mkdir dirTwo : bash$ mkdir dirTwo/dirThree : bash$ ln -s dirTwo/dirThree/ . : bash$ cd dirThree/ : bash$ pwd : /tmp/dirThree : The tcsh gives the right answer. You are in the /tmp/dirTwo/dirThree directory. If you try : to move a file with "mv file.txt ../dirOne/file.txt" you can at t do that because there is no : directory dirOne !!! : Python works like tcsh. If you try the following you get the right answer: : bash$ cd /tmp/dirThree/ : bash$ python : Python 1.5.1 (#1, May 6 1998, 01:48:27) [GCC 2.7.2.3] on linux-i386 : Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam :>>> import os :>>> os.getcwd() : '/tmp/dirTwo/dirThree' : My suggestion: : You can test if there are symbolic links in your path (e.g. os.path.islink("/tmp/dirThree") : within Python) or you can prove that /tmp/dirThree is in reality /tmp/dirTwo/dirThree and : life with that fact ... : Cheers, : Jan It is not a matter of "correctness", but of perceived current pathname. In that same tcsh, if you echo $cwd, you will get the same value that bash returns, there are some systems where using this "faked" value is required (Automounter V1 systems for example). Both csh and tcsh have common, documentated add-ons (alias pwd 'echo $cwd') to give the same functionality as bash. But, the getcwd(3) C function performs a call to traverse up the tree to retrieve the pathname. This is because a process only holds the inode of the current directory, not the path that got it there. Using relative pathnames with symbolic links is problematic at times, but they aren't "incorrect." Symbolic links have to be organized properly; if they are not, you have odd side-effects. These are the Facts of Life (I always like "Jo" myself). -Arcege From llwo at dbtech.net Mon Jun 14 08:07:15 1999 From: llwo at dbtech.net (Karl Putland) Date: Mon, 14 Jun 1999 07:07:15 -0500 Subject: New to threading. Right idea??? References: Message-ID: <3765775d.0@news.dbtech.net> Thanks David. > > If you must call EXPENSIVE for each directory, then you must -- I don't > think there's any way around that. Loading the same DLL multiple times > won't help if you have to call EXPENSIVE for each (especially if > unexpensive is, well, unexpensive =). If EXPENSIVE is VERY_EXPENSIVE, > where VERY_EXPENSIVE >> cost of loading the DLL, then even a fork() > wouldn't help much, even if it were available on your OS. > > --david ascher I experimented with creating a copy of the dll with a diferent name and loading it. This worked. I could call EXPENSIVE for the dll and the copy_of_dll and both succeed. The other interesting part of this is that EXPENSIVE executes over twenty times faster the second time around. That is if dll and copy_of_dll are both loaded, calling dll.EXPENSIVE takes between 1.5 and 4.8 seconds, then calling copy_of_dll.EXPENSIVE takes .022 - .22. EXPENSIVE is really called load_bde(). I guess that I will just manage the files to load one ofr more copies of the dll since that seems to work like I need it to. >>> from gm4s32 import * >>> load_bde() (1, 'Startup Time: 0.99999997139') >>> copy_load_bde() (1, 'Startup Time: 0.0499999523163') >>> ***snippet from module gm4s32.py*** import windll import time import os import string from types import * gm=windll.module('GM4S32') gma=windll.module('GM4S3a') ##if raw_input('(W)ork or (H)ome: ')=='W': ## SysDir='G:\\' ## GoldDir='G:\\' ## CommonDir='g:\\merged' ## User='MASTER' ## Password='ACCESS' ##else: SysDir='d:\\goldmine' GoldDir='d:\\goldmine\\gmbase' CommonDir='d:\\goldmine\\demo' User='KARL' Password='KAPPASIG' def load_bde(sysDir='', goldDir='', commonDir='', user='', password=''): global SysDir, GoldDir, CommonDir, User, Password if not sysDir: sysDir=SysDir if not goldDir: goldDir=GoldDir if not commonDir: commonDir=CommonDir if not user: user=User if not password: password=Password SysDir=sysDir GoldDir=goldDir CommonDir=commonDir User=user Password=password start=time.time() (sysDir, goldDir, commonDir, user, password)=map(windll.cstring,(sysDir, goldDir, commonDir, user, password)) return (gm.GMW_LoadBDE(sysDir, goldDir, commonDir, user, password), "Startup Time: " + str(time.time()-start)) def unload_bde(): return gm.GMW_UnloadBDE() def copy_load_bde(sysDir='', goldDir='', commonDir='', user='', password=''): global SysDir, GoldDir, CommonDir, User, Password if not sysDir: sysDir=SysDir if not goldDir: goldDir=GoldDir if not commonDir: commonDir=CommonDir if not user: user=User if not password: password=Password SysDir=sysDir GoldDir=goldDir CommonDir=commonDir User=user Password=password start=time.time() (sysDir, goldDir, commonDir, user, password)=map(windll.cstring,(sysDir, goldDir, commonDir, user, password)) return (gma.GMW_LoadBDE(sysDir, goldDir, commonDir, user, password), "Startup Time: " + str(time.time()-start)) def copy_unload_bde(): return gma.GMW_UnloadBDE() From mrkbutty at mcmail.com Tue Jun 1 16:58:01 1999 From: mrkbutty at mcmail.com (Mark Butterworth) Date: Tue, 1 Jun 1999 21:58:01 +0100 Subject: A tkinter kick-off Message-ID: <37544a32.0@news1.mcmail.com> I've been using python for a few months now (I've actually managed to persuade my company that freeware is a viable tool) and I've just started looking at tkinter. However, my first little project doesn't require an interactive window or dialog box. What I do require is a window which displays the result's of my background processing. The processing will simply be the compression and network transfer of some files. I'm not looking for a full solution however, I just need a help starting off. I can create a window containing a listbox alright, I just need to know how to process in the background and display results within the listbox (maybe a cancel button would also be useful). Any help appreciated!?! From graham at sloth.math.uga.edu Thu Jun 10 11:05:37 1999 From: graham at sloth.math.uga.edu (Graham Matthews) Date: 10 Jun 1999 15:05:37 GMT Subject: Python 2.0 References: <000a01beb2e8$087fc2a0$af9e2299@tim> Message-ID: <7jok81$hih$2@cronkite.cc.uga.edu> [Hisao Suzuki] > Me too. And I am afraid that some evangelists would do nothing > but _only_ point out Python's some so-called fault in order to > drive us into convert to their favorite or invented language... [Yukihiro Matsumoto] > Sorry for bothering the newsgroup. Tim Peters (tim_one at email.msn.com) wrote: : Hmm. The level of paranoia in this thread is quite remarkable! I don't : think Suzuki was talking about you (or Ruby) here, and your contributions to : the thread have been civil and helpful. Well my reading of Hisao's posts (especially the most recent ones) is indeed that he was talking about Yukihiro. Now two data points. graham -- As you grow up and leave the playground where you kissed your prince and found your frog Remember the jester that showed you tears the script for tears From stidolph at origin.ea.com Tue Jun 29 16:05:22 1999 From: stidolph at origin.ea.com (Stidolph, David) Date: Tue, 29 Jun 1999 20:05:22 GMT Subject: Please help me to understand classes Message-ID: <11A17AA2B9EAD111BCEA00A0C9B4179301E10F81@molach.origin.ea.com> Finally, a simple question I can answer! First of all, class methods like "druk" need to have a parameter declared in them called self (or whatever you want to call it). Secondly you need to call the method with open/close parens: class A: def druk(self): print 'Jy is in Class A' class B: def druk(self): print 'Jy is in Class B' a = A() c = B() c.druk() Jy is in Class B a.druk() Jy is in Class A I hope this helps, David. -----Original Message----- From: Johann Spies [mailto:jhspies at futurenet.co.za] Sent: Tuesday, June 29, 1999 2:04 PM To: Python-poslys Subject: Please help me to understand classes I have been playing around with python for some time now, but I am a relative newbie as it is my hobby and normally I have very little time for programming. I am on leave now and want to write a program but I find python a very difficult language to comprehend despite the fact that I have a few years of experience in programming a language like Pascal. Maybe it is because I have little experience in OOP. Can somebody explain to me why the following program produces no output: --------------------------------------------- class A: def druk(): print 'Jy is in Class A' class B: def druk(): print 'Jy is in Class B' a = A() c = B() c.druk a.druk --------------------------------------------- -------------------------------------------------------------------------- | Johann Spies Windsorlaan 19 | | jhspies at futurenet.co.za 3201 Pietermaritzburg | | Tel/Faks Nr. +27 331-46-1310 Suid-Afrika (South Africa) | -------------------------------------------------------------------------- "One thing have I desired of the LORD, that will I seek after; that I may dwell in the house of the LORD all the days of my life, to behold the beauty of the LORD, and to inquire in his temple." Psalms 27:4 From jim at interet.com Tue Jun 22 09:52:24 1999 From: jim at interet.com (James C. Ahlstrom) Date: Tue, 22 Jun 1999 09:52:24 -0400 Subject: Build the Python library into the binary Message-ID: <376F9518.D3252CEE@interet.com> Now that Python 1.5.2 is here I need to upgrade from 1.5. We use Python internally and also ship Python applications. Our environment is mixed PC's, Suns and linux boxes. Our customers all have PC's. I always find upgrades difficult, especially at customer sites since we have no access, and have to depend on our Wise install script. I keep thinking how much easier this would be if the Python library were built into the binary. I mean that on PC's, the library were part of python15.dll for example. No more worrys about a bad PYTHONPATH, the registry, my 1.5.2 binary using 1.5 libraries, the different ways all this works on different platforms, etc. You just replace python15.dll and you are at 1.5.2. Simple. So I wrote some code. I don't consider it finished but it works. It makes the Python library part of the binary. 1) The same code works for Unix and Windows. No "#ifdefs". 2) It uses the existing "frozen module" logic which has been used as a way to ship Python main programs. 3) It extends frozen modules so that multiple frozen modules can be linked together at run time. Currently there can only be one frozen module. 4) Multiple frozen modules are built as regular Python extension modules, and they install themselves when they are initialized. You request them in Setup as usual. This was the only way I knew to do the initialization in a portable way (suggestions?). 5) The C code is stupidly simple and very short. New code goes into frozen.c, and few other changes are required. 6) There is a Python program in Tools/freeze which creates the Python extension module with the Python libraries. It uses the new "modulefinder.py" program. Thanks to whoever wrote it! It can also be used to create other frozen modules, thus solving the problem of how to make a frozen module. 7) The extension module need not be imported itself. It installs the built-in frozen modules jusy by being initialized. But if you import it, it has methods to turn the frozen modules on and off, and to print the names in the modules. So my questions are: 1) Am I the only one having trouble keeping the Python binary and library files in sync? 2) Is any of this of interest? Should it be added to Python? 3) What features should be included? Does this do enough, too much? 4) Is this the right way to do it. More technical details are available on request. Jim Ahlstrom From bwarsaw at cnri.reston.va.us Tue Jun 15 17:11:05 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Tue, 15 Jun 1999 17:11:05 -0400 (EDT) Subject: easy filecopy? - JPython? References: <376531D3.7E42AC42@phoenix-edv.netzservice.de> <14182.28241.949065.590839@weyr.cnri.reston.va.us> Message-ID: <14182.49513.956557.398784@anthem.cnri.reston.va.us> >>>>> "Fred" == Fred L Drake writes: Fred> shutil.copyfile() works just fine (JPython 1.0.3 on Fred> java1.2), but shutil.copymode() relies on os.chmod(), which Fred> isn't there. I'm sure Barry Warsaw (bwarsaw at python.org) Fred> would love to receive a patch for JPython to support that! Fred> ;-) Probably not possible in 100% Java. If os.chmod() is really important to you, then you should check out Finn Bock's JNI implementation of os and posix. http://pip.dknet.dk/~pip1848/jpython/Readme_jnios.html -Barry From mesak1234 at my-deja.com Sun Jun 6 11:25:15 1999 From: mesak1234 at my-deja.com (mesak1234 at my-deja.com) Date: Sun, 06 Jun 1999 15:25:15 GMT Subject: Newbie question Message-ID: <7je3sk$46$1@nnrp1.deja.com> Hi! Well, i get problems with getting date from OS....(win32 at this moment)... All what i need that to find out date attribute of a file. But i even cannot find out what the function i can use to get the real time (anything like Date date = new java.util.Date(); ???? :( ) All functions of 'time library' seem fine but don't help so much... Any suggestions? Thanks, Daniel Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From riftweaver at hotmail.com Thu Jun 3 11:40:48 1999 From: riftweaver at hotmail.com (riftweaver at hotmail.com) Date: Thu, 03 Jun 1999 15:40:48 GMT Subject: unable to access Tk from Python152/WinNT Message-ID: <7j67lu$ibe$1@nnrp1.deja.com> Hi, I am trying to run the tk interface from the Python 1.5.2 release on WindowsNT. I have installed Python with both a pre-existing Tcl/TK installation, and with the included Tcl/Tk installation. When I couldn't start idle, I followed the troubleshooting selection from python.org. First Pyhon couldn't find a lib/Tcl8.0 directory; so I copied that from the Tcl install to Python/lib. Then it couldn't find a lib/Tk8.0 directory; again I copied from Tcl install to Python/lib. Then I got a stack trace with an error about binding to a . Any help or suggestions are appreciated. Thanks. --->Jason Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From sams at quinta.com Fri Jun 18 15:34:03 1999 From: sams at quinta.com (Sam Schulenburg) Date: Fri, 18 Jun 1999 19:34:03 GMT Subject: Crawling Python References: <000601beb91d$e1321ae0$839e2299@tim> <376a1ac1.10261180@news.tpnet.pl> Message-ID: <7ke6va$qa9$1@nnrp1.deja.com> In article <376a1ac1.10261180 at news.tpnet.pl>, mark at _spamspamlovelyspam_btweng.krakow.pl (MK) wrote: > On Thu, 17 Jun 1999 20:02:39 -0400, "Tim Peters" wrote: > -- clip clip -- > Strangling IDLE continued: > > in DOS box I tried > > >>> s='' > >>> for i in range(10000): > ... s=s+`range(i,i+20)` > ... > > >>> len(s) > 1178515 > > and everything is OK. > > While the same loop in IDLE crashed it (I mean it hangs for some period, then it > stops responding and has to be killed). > > MK > -- clip clip -- I just tried both environments on a WindowsNT system and obtained 130000 for len(s) under IDLE and Console mode python. IDLE took approx. 25 seconds and Console took approx 20 seconds. Sam Schulenburg Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From guido at cnri.reston.va.us Tue Jun 1 10:20:52 1999 From: guido at cnri.reston.va.us (Guido van Rossum) Date: 01 Jun 1999 10:20:52 -0400 Subject: need help checking for stack overflow in Win32 Message-ID: <5lk8to3su3.fsf@eric.cnri.reston.va.us> I could use some help from someone with a little time, some knowledge of Python internals, and some Win32 C expertise. On Win32 platforms, infinite recursion causes an Application Error (a fatal windows error). There is some machinery in Python to check for this condition, but apparently it doesn't work on Win32. Please help! --Guido van Rossum (home page: http://www.python.org/~guido/) From arcege at shore.net Wed Jun 30 13:22:07 1999 From: arcege at shore.net (arcege at shore.net) Date: Wed, 30 Jun 1999 18:22:07 +0100 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? Message-ID: <000015c2@bossar.com.pl> From: arcege at shore.net Fredrik Lundh wrote: : Michael P. Reilly wrote: :> Hmm... something about that argument makes it circularly invalid. :> Non-idle event a comes in, but must be handled after idle event d. :> Event d can only execute when event a is taken care of. Sounds like :> deadlock to me. ;) : hmm. I thought I'd meant that idle tasks kept piling up : when the windowing system generates a lot of events : at once (like when you're redrawing an entire system). : instead of redrawing everything at once, Tkinter waits : until the window event queue is empty... Yes, indefinate postponement is a problem with the current definition of Tcl_DoOneEvent. But idle tasks are for when the event loop is idle, and indefinate postponement is the standard, accepted trade-off for that. Timer handlers exist for handling more time critical actions. You had made the comment(s) earlier in the thread: > The interface is only part of the story; many complaints > seem to come from the fact that Tk uses idle tasks to > redraw things. When an "expose" event arrives from > the windowing system, Tk calls "after_idle", rather > than redrawing the widget at once. And idle tasks > are only executed when there are no other events > to take care of... This lead me to think that you meant windowing events (such as expose) were handled as idle tasks and I don't see this (MotionNotify events, yes, not all others are handled by Tcl_QueueEvent). Hence my comment about the deadlock. -Arcege From mnot at pobox.com Tue Jun 22 05:31:04 1999 From: mnot at pobox.com (Mark Nottingham) Date: Tue, 22 Jun 1999 09:31:04 GMT Subject: htmllib: CR in CDATA References: <00d201bebc5a$adb129a0$0301a8c0@mnot.net> Message-ID: <012601bebc91$f3ded760$0301a8c0@mnot.net> Whooops, nevermind, I misread the spec -- carriage returns are turned into spaces (which is what htmllib does) - *line feeds* should be ignored... -- "Get me the phone book." "Which one?" "Doesn't matter." ----- Original Message ----- From: Mark Nottingham To: Python Sent: Tuesday, June 22, 1999 12:55 Subject: htmllib: CR in CDATA > It appears that htmllib doesn't ignore returns in CDATA fields, as HTML 4.0 > says it should: > http://www.w3.org/TR/REC-html40/types.html#type-cdata > http://www.w3.org/TR/REC-html40/sgml/dtd.html > > As a result, htmllib improperly parses any CDATA element that wraps across a > line; this affects elements like > > > > I'm happy to work up a patch, but I thought I'd ask around first. It may be > a bit involved to fix it properly; every CDATA should be handled this way, > which practically means almost every tag attribute. > > Regards, > > > Mark Nottingham, Melbourne Australia > mnot at pobox.com http://www.mnot.net/ > > > From wc at zyan.com Thu Jun 17 11:36:10 1999 From: wc at zyan.com (John B. Williston) Date: Thu, 17 Jun 1999 15:36:10 GMT Subject: Newbie: Truth values (three-valued logic) References: <000f01beb7b8$2722a540$2ca22299@tim> Message-ID: <376915d7.2445700@news.dslspeed.com> On Wed, 16 Jun 1999 01:21:57 -0400, "Tim Peters" wrote: >we don't need no stinking excluded middle! Cool! Not cool! You're so right. That's completely wrong. John From movits at lockstar.com Wed Jun 23 16:06:49 1999 From: movits at lockstar.com (Mordy Ovits) Date: 23 Jun 1999 13:06:49 PDT Subject: Thanks for Python... References: <376ead64@anonymous.newsfeeds.com> Message-ID: <37716901.43CB604@lockstar.com> Jeff Rush wrote: > > Welcome to the Python community, John. Yes, Python is a truly > wonderful language for cranking out quick prototypes or test jigs. > I prototyped a complete web-based general ledger system in Python, > figuring I'd downcode it to C for speed later, but so far I haven't needed > to. Python is also just plain fun... Now if I could just get time to port > it to the PalmPilot, I'd never be away from it. > > -Jeff Rush Get a Windows CE Palm-sized PC if you want to take Python with you whereever you go. Python runs stunningly well on my Casio E-100, and has nifty GUI libraries. It's not polished by any sense of the word but it works, and the source is a barely changed version of the standard windows Python. This makes for easy improvement. see: http://starship.python.net/crew/mhammond/ce/ It sure is nifty to be coding during my commute :-) Enjoy! Mordy -- o Mordy Ovits o Cryptographic Engineer o LockStar Inc. --------------------------------------------------------------------------- #!/usr/local/bin/python from sys import*;from string import*;a=argv;[s,p,q]=filter(lambda x:x[:1]!= '-',a);d='-d'in a;e,n=atol(p,16),atol(q,16);l=(len(q)+1)/2;o,inb=l-d,l-1+d while s:s=stdin.read(inb);s and map(stdout.write,map(lambda i,b=pow(reduce( lambda x,y:(x<<8L)+y,map(ord,s)),e,n):chr(b>>8*i&255),range(o-1,-1,-1))) From matz at netlab.co.jp Mon Jun 7 21:47:36 1999 From: matz at netlab.co.jp (Yukihiro Matsumoto) Date: 08 Jun 1999 10:47:36 +0900 Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7jgk4j$s8p$1@cronkite.cc.uga.edu> Message-ID: <87hfoj4g5j.fsf@ev.netlab.co.jp> Hisao Suzuki writes: |In article , |I also wrote: || ... On that box, Ruby did not run but dumped immediately || with its twiddling the machine stack, while Python ran perfectly || with no difficulty. ... | |We have been enjoying Python's portability for many years. You are opposing aginst nobody. No one (even me) claims Python should abandon its great portability. matz. From a.mueller at icrf.icnet.uk Mon Jun 7 12:45:21 1999 From: a.mueller at icrf.icnet.uk (Arne Mueller) Date: Mon, 07 Jun 1999 17:45:21 +0100 Subject: fork() References: <375BE64A.EB997F24@icrf.icnet.uk> <87so840zcc.fsf@pc-hrvoje.srce.hr> Message-ID: <375BF721.4B1864F2@icrf.icnet.uk> Hrvoje Niksic wrote: > > Arne Mueller writes: > > > All that woks fine now (after I spend a long time fiddling with the > > pipe and select stuff to synchronize I/O). However the forking is a > > waste of time and memory because all the children get their own > > large dictionary! > > If you don't change the dictionary, the memory will not be copied. > Most modern Unixes support COW (copy on write) which means that the > actual fork()ing does surprisingly little. Only when the memory is > written to, a new copy is spawned off. > > If the children are modifying the dictionary, that's well something > different... Huh, that's realy good news! But I don't understand how that works, when the child changes the dictionary it quickly gets it's own copy, so the operating system is watching the child's activity and copies memory when it's accessed for writing? However my children don't change anything in the dictionary ;-) Thanks, Arne From asynthREMOVE at THISio.com Mon Jun 14 16:02:29 1999 From: asynthREMOVE at THISio.com (James McCartney) Date: Mon, 14 Jun 1999 14:02:29 -0600 Subject: OO (was: Why is tcl broken?) References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> <3762988E.C94AA252@iname.com> <3763C746.5CA8FE78@iname.com> <87pv2zjhhl.fsf@home.ivm.de> Message-ID: In article <87pv2zjhhl.fsf at home.ivm.de>, Klaus Schilling wrote: >Prefix rocks, infix is crap. No, you mean: Rocks prefix? Is infix crap? James McCartney asynth io com From evan at tokenexchange.com Wed Jun 16 13:14:16 1999 From: evan at tokenexchange.com (Evan Simpson) Date: Wed, 16 Jun 1999 12:14:16 -0500 Subject: fork() References: <000b01beb6ef$fcaba960$069e2299@tim> Message-ID: <9XQ93.2$V4.8796@news-dal.corridex.com> Tim Peters wrote in message <000b01beb6ef$fcaba960$069e2299 at tim>... > So my plan for the hour is: if M&S finds a cycle, it will clean it > all up iff no involved object has a __del__. If an object in a trash cycle > does have a __del__, tough, the cycle won't be reclaimed. Instead we'll > supply a function you can call if you care, that will return those objects > (one at a time? in a list? whatever), and you do with them what you will; > if you don't clean them up, you'll keep getting them back every time you > call that function until you resurrect them or break the cycle by hand in > the way that makes most sense to your algorithm. Presuming the hour isn't up yet, I've a handful of scattered comments: . How about a callback instead of/in addition to a probe function? That way you could flip a switch and get called even on cycles which are "del-clean", if you wanted to check for unintentional cycle creation. . "del-cleanness" only requires that actual cycle participants lack __del__, not dangly bits, right? Or does this re-introduce analysis that you intended to throw out? . (somewhat rhetorical) How the heck do you recognize what you've got when the machinery hands you an object which isn't otherwise reachable? I realize that there's no general answer to this, and that in some specific cases it would be enough to check __bases__, but the only answer which occurs to me off the bat is to uniquely mark objects which you expect to have to handle, or provide them with special __cleanup__ methods, or the like. Now we have wide-open policy, which I recall you decrying . I guess that no matter what mechanism is implemented, certain badly-handled cases will appear and need to be handled with "well, don't do that!" finalization-is-like-life-you-can't-win-and-you-can't-break-even-ly y'rs Evan Simpson From ovidiu at cup.hp.com Wed Jun 30 20:57:23 1999 From: ovidiu at cup.hp.com (Ovidiu Predescu) Date: Thu, 01 Jul 1999 00:57:23 +0000 Subject: strange behaviour at termination time References: <377765F0.38230773@steria.fr> <37783685.C7BB5B2E@compaq.com> Message-ID: <377ABCF3.3C222F37@cup.hp.com> Greg Ewing wrote: > To avoid problems like this, you have to design > your __del__ methods so that they can do their > work without having to refer to any module-level > names at the time they are called. One way is > to use the default-argument trick: > > class B (A) : > def __del__ (self, A = A) : > A.__del__ (self) Can you explain why this trick works? When are the default arguments stored in the method instance? I guess this happens when the method instance for __del__ is created by the interpreter, right? Thanks, -- Ovidiu Predescu http://www.geocities.com/SiliconValley/Monitor/7464/ From jerome.dannoville at bull.net Tue Jun 22 08:51:50 1999 From: jerome.dannoville at bull.net (Jerome d'Annoville) Date: Tue, 22 Jun 1999 14:51:50 +0200 Subject: [JPYTHON] Installation Problems References: <0D1FF10FB191D45F.A19ABABF1E01F5C3.C3A5123AAD9506A3@lp.airnews.net> Message-ID: <376F86E6.D17314A4@bull.net> > ... > > D:\Downloading\jpython>jpython > Bad command or file name > > I'm supposing this is because the MakeScriptAction didn't run. > > Suggestions welcome! > You must update your PATH, add something like C:\JPython-1.0 depending where you download JPython. Then jpython.bat might be call from dos prompt. --Jerome From gherman at my-deja.com Wed Jun 23 10:11:30 1999 From: gherman at my-deja.com (Dinu C. Gherman) Date: Wed, 23 Jun 1999 14:11:30 GMT Subject: How to obtain an instance's name at runtime? Message-ID: <7kqpu8$7u1$1@nnrp1.deja.com> This is a nasty question, perhaps, so I appologize in advance if its stupidity level is far above the accepted average in this newsgroup... I would like to do the following: >>> class C: ... pass ... >>> >>> c = C() >>> C.__class__.__name__ # ok 'C' >>> c.__name__ # not ok Traceback (innermost last): File "", line 0, in ? AttributeError: __name__ >>> Question: How to obtain an instance's name at runtime? That is I'd like to see this happen (one was or the other): >>> c.__name__ 'c' I've checked the reference manual, but it's silent about this topic or I'm too blind... Fearing-there's-no-such-solution'ly, Dinu PS: Do not use my Deja email-address. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From jonathan at onegoodidea.com Fri Jun 4 18:11:29 1999 From: jonathan at onegoodidea.com (Jonathan Hogg) Date: Fri, 04 Jun 1999 23:11:29 +0100 Subject: python active web pages References: <7j98g1$atj$1@autumn.news.rcn.net> Message-ID: In article <7j98g1$atj$1 at autumn.news.rcn.net>, "Jeffrey P Shell" wrote: >Well, DTML (especially outside of Zope) is not meant to be >scripting-inside-of-HTML, which most Active Server Page type things are. >Personally, I think that is beyond hideous, the > > ><% > document.write('') > document.write('%s' % someTitleString) > ... >%> > > >is terrible (i have seen plenty of PHP source that looks like the above). i couldn't agree more. this is what i'm trying to avoid. the most simple model is to execute python scripts from CGI and build web-pages using something like HTMLgen or just writing out bits of HTML as strings and sticking in the dynamic bits in between. this is basically what the ASP you show above does (hence making the use of ASP quite pointless in my book). >This seperation (which was most effective before DTML scripting, aka the >embedding of python expressions in DTML, was implemented into DTML) is very >powerful as it enforces the seperation of Code and Presentation, a rather >MVC (Model-View-Controller) style paradigm. it's the separation that i'm not sure i want. i have skimmed through the DTML manual on your web pages and believe i understand (to a first approximation) how it operates. the problem is that i'm not using the rest of Zope and if i want to execute setup code, rather than just evaluate expressions within <#var expr> tags, then i'd need to stick this into a separate script which sucks in the template and passes in whatever data as variables. what i'd really like to be able to write is stuff along the lines of: <% import foobar your_name = foobar.frib( frob = "all" ) nee = foobar.noneshallpass( what is your_name ) %> Wotnot "We are the knights who say... <%= nee %> all well and good. looks like "asp" can do this fine. but unfortunately it won't allow me to do the *really* useful bits that ZTemplates supports:

    How do I love thee?

    don't get me wrong, while i think the above is a *bit* hideous, it is undeniably powerful and very close to what i'm looking for. >My first Bobo app was turning a socket server into a web application. >Since I had made my classes and the views on those classes rather seperate >in the socket server implementation, turning into a web app took only a >matter of hours. I was able to make a very simple DTML page for displaying >results from a search form and focus on implementing some new methods >needed for this new way of accessing data. Once those methods were >implemented, I was able to spend the rest of the day in web-designer mode >since I already knew all the data that I had available to me and I could >just write DTML and not even have to think about Python. a very valid point of view. to be honest, how much the integration of control and interaction will be a pain in the arse is still to be tested. >DTML (esp. DTML Scripting) has gotten rather beyond control in some cases, >but I believe it's the most "right". But yes, I work for digital creations >so I'm a bit biased. > >But all that bias is based on the first time I wrote a major application >and just how _EASY_ (and powerful) that was. 's ok, we all have our biases. these are still the sort of opinions i was hoping to garner. thanks for your comments. does anyone else use active web pages? surely all you python/web hackers don't just use CGI scripts? :-j -- jonathan hogg, one good idea limited, 25 clouston street, glasgow g20 8qr, uk jonathan at onegoodidea.com www.onegoodidea.com t:(0)976-614338 f:(0)7970-537451 From peterh at sapros.com Fri Jun 11 22:20:02 1999 From: peterh at sapros.com (Peter Haight) Date: Fri, 11 Jun 1999 19:20:02 -0700 Subject: Higher level FTP lib? Message-ID: <199906120220.TAA32246@wartch.sapros.com> >I wonder if there is a FTP module for python that allows for higher >level operations than ftplib. With ftplib, I have to parse LIST lines >myself (footnote: is there a module for *that* like perl's >File::Listine?) if I want to know file size or date. You could use urllib instead. It works like this: import urllib file = urllib.urlopen('ftp://ftp.python.org/pub/python/src/py152.tgz') The file object you get back is pretty much the same as a file object you would get from an open() command. From fatjim at home.com Thu Jun 3 12:23:58 1999 From: fatjim at home.com (Jim Meier) Date: Thu, 03 Jun 1999 16:23:58 GMT Subject: Handling variable number of arguments. References: <7j17dm$pks$1@nnrp2.deja.com> Message-ID: <3756AC9E.649A4D0D@home.com> bhosu at my-deja.com wrote: > Hi All, > I am embedding Python in an application(C++). I would like to pass > variable number of args to the python function. I could do that from > python by using def foo(*args). How do I parse these arguments inside my > application? In PyARg_ParseTuple, I have to know exactly how many args > to read etc. I am using Python v 1.4. I was looking at > PyArg_ParseTupleAndKeywords but that needs the args to be a dictionary. > I am looking a similar thingy for lists. A typeical scenario of the > usage is like, > import foo > foo.set_args('bar','=','1','2','3') > > where foo is the module containing the method implementation. PyArg_ParseTuple supports optional arguments: int a,b,c,d,e,f,how_many; if(!PyArg_ParseTuple("ii|iiii",a,b,c,d,e,f)) return NULL; how_many=PyTuple_Size(args); So you could use that if you simply have a known number of optional extra arguments. See "Extending and Embedding", section 1.7 "Format Strings for PyArg_ParseTuple". Otherwise, if you need a varying number of arguments (only really possible if you are calling the function with apply()), do as Michael P. Reilly's response suggests (access args as a tuple directly). Hope that helps, -Jim. From fredrik at pythonware.com Thu Jun 3 14:48:13 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 3 Jun 1999 18:48:13 GMT Subject: idle processing References: <3755bf01@nntp.server.uni-frankfurt.de> <3755D811.61AEC34@cloud9.net> Message-ID: <032401beadf1$a30f11f0$f29b12c2@pythonware.com> Michael Muller wrote: > > win = SomeWindowClass() > > def otherFunc(): > win.after('idle', someFunc) that's win.after_idle(someFunc), btw. also see the section titled "Alarm handlers and other non-event callbacks" on http://www.pythonware.com/library/tkinter/introduction/widget.htm (now back to single smurf mode). From donn at u.washington.edu Wed Jun 2 11:42:56 1999 From: donn at u.washington.edu (Donn Cave) Date: 2 Jun 1999 15:42:56 GMT Subject: Posix: Exec format error References: <3754ED47.54C2F0AF@ilt.fhg.de> Message-ID: <7j3je0$11gk$1@nntp6.u.washington.edu> Rolf Wester writes: | when doing the following: | | import os | id=os.fork() | if id == 0: | os.execl("/home/wester/test/test","-d", "indata") | else: | os.wait() | | I get the error message: | | OSError: [Errno 8] Exec format error | | Can aybody tell me how the format should look like? Probably it should have a first line like #!/bin/sh In other words, the format error is in /home/wester/test/test, not in your Python statements here. That file needs a code in its first 16 bits, that tells the OS how to execute it. If that code is "#!", it also uses the rest of the that line as an interpreter file path. So I guess your file lacks its interpreter header, though it could also be a compiled binary from the wrong operating system. Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From jo at delorges.in-berlin.de Wed Jun 2 20:38:47 1999 From: jo at delorges.in-berlin.de (Jo Meder) Date: 03 Jun 1999 02:38:47 +0200 Subject: Alien whitespace eating nanovirus strikes again! References: <375500C9.742DC539@pop.vet.uu.nl> <375536C2.DD917F99@prescod.net> <7j4e2u$8rh$1@m2.c2.telstra-mm.net.au> Message-ID: aahz at netcom.com (Aahz Maruch) writes: > if I need to add a quick "if" statement > during debugging, I don't like having to make sure I clean up the block > structure formatting. With just about any other language, I don't have > to. I do, as I think I did make clear, clean up the formatting after > the debugging. This seems to be more like a request for editing features than a gripe about syntax. I use the python-mode for emacs, where I can C-c > to indent a region and C-c < to dedent it. Couldn't be easier. Jo. From Cepl at fpm.cz Wed Jun 16 10:25:18 1999 From: Cepl at fpm.cz (Matej Cepl) Date: Wed, 16 Jun 1999 15:25:18 +0100 Subject: HTML bettering? Message-ID: <1318D78C9072D11195C9006094EA98A72C214D@ocesrv> How to make as simple as tool which would make some simple operation over HTML (e.g., headings numbering)? If I would use htmllib.py, I would have to build HTMLformatter or I am wrong and it is easy? Thanks Matthew From greg.ewing at compaq.com Sun Jun 27 23:50:43 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Mon, 28 Jun 1999 15:50:43 +1200 Subject: ANN: Stackless Python 0.2 References: <37628EAA.C682F16C@appliedbiometrics.com> <7l6gc8$du4$1@news.tamu.edu> Message-ID: <3776F113.8573DAA5@compaq.com> Corran Webster wrote: > In article <37628EAA.C682F16C at appliedbiometrics.com>, > Christian Tismer wrote: > >ANNOUNCING: > > Stackless Python 0.2 > > A Python Implementation Which > > Does Not Ese The C Stack This sounds interesting, but how do you deal with the issue of C extensions which call back to Python code? Or is this simply disallowed in Stackless Python? Greg From jam at newimage.com Sun Jun 13 14:14:14 1999 From: jam at newimage.com (jam) Date: Sun, 13 Jun 1999 14:14:14 -0400 Subject: Variations on a theme by "pound bang" In-Reply-To: <3763e75f.3265255@news.iol.ie>; from Sean Mc Grath on Sun, Jun 13, 1999 at 05:17:33PM +0000 References: <3763e75f.3265255@news.iol.ie> Message-ID: <19990613141414.D723@toast.internal> On Sun, Jun 13, 1999 at 05:17:33PM +0000, Sean Mc Grath wrote: > > Can anyone shed some light on the benefits of:- > > # !/usr/bin/env python > > as opposed to > > # !/usr/bin/python > > Sean > yes. the first one is more generic, and independent of the actual location of the command in question (in this case, the python interpreter). there's a man page for 'env'-- it basically reads the PATH variable, and looks for it's argument on it. a danger is that it might leave your scripts open to attack (if someone manages to place a trojan program somewhere in the path *before* the actual 'python' interpreter, say in $HOME/bin). the 2nd one is specific to finding the python interpreter in '/usr/bin', which might be fine for you, but I might install mine in /usr/local/bin instead, for example. it's a bit more secure in that someone will have to compromise /usr/bin, which is (theoretically) more difficult. hope that helps. regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From mlh at idt.ntnu.no Sat Jun 5 15:51:05 1999 From: mlh at idt.ntnu.no (Magnus L. Hetland) Date: 05 Jun 1999 21:51:05 +0200 Subject: Deleting characters from a string References: <87n1ye3g4v.fsf@pc-hrvoje.srce.hr> Message-ID: Hrvoje Niksic writes: > string.translate can delete characters from a string, as well as > translate them. But what if I want *only* to delete them? Currently > I do this: > > dummytable = string.maketrans('', '') > > ... > host = string.translate(host, dummytable, ' "') > ... > > What I would really like to be able to do is write: > > host = string.translate(host, None, ' "') Just to butt in with my private opinion... :) I think it would be more natural if bot the last two arguments were optional... Thus you could do: host = string.translate(host, deletechars=' "') To me that is more readable, and seems more like standard Python than defining None to mean an ID-mapping... Just use an ID-mapping as a default argument in string.translate. > > Am I missing a more elegant solution? result = "" for char in host: if char not in ' "': result = result+char host = result What!? To me that's more elegant... -- Magnus Making no sound / Yet smouldering with passion Lie The firefly is still sadder / Than the moaning insect Hetland : Minamoto Shigeyuki From akuchlin at mems-exchange.org Tue Jun 1 13:33:17 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: Tue, 1 Jun 1999 13:33:17 -0400 (EDT) Subject: Whats missing? In-Reply-To: <37541767.AB2B250B@cwcom.net> References: <37541767.AB2B250B@cwcom.net> Message-ID: <14164.6493.227317.96564@amarok.cnri.reston.va.us> Daniel Faulkner writes: >from urllib import urlopen >Data = urlopen("http://www.python.org/").read() >print Data ... > Data = urlopen('"' + UrlCurr + '"').read() Why are you adding quotes here? In the first example, you're passing the string 'http://www.python.org'; the double or single quotes are just part of the language notation for a string literal. UrlCurr is, I assume, already a string, so Data = urlopen(UrlCurr).read() should work fine. -- A.M. Kuchling http://starship.python.net/crew/amk/ Luckily, every good story is allowed one astounding coincidence. The writer has decided to cash his in now. -- In Phil Foglio's STANLEY AND HIS MONSTER #2 From graham at sloth.math.uga.edu Mon Jun 14 23:14:20 1999 From: graham at sloth.math.uga.edu (Graham Matthews) Date: 15 Jun 1999 03:14:20 GMT Subject: Solution to finalisation problem [Re: fork()] References: <000301beb6c9$a01d2960$b2a22299@tim> Message-ID: <7k4gec$6vg$1@cronkite.cc.uga.edu> Graham Matthews: > If you run *all* finalisers of *all* collected objects before you > actually delete or partially delete any of those objects then all > finalisers run in well defined contexts and there are no problems > with finalisers. Tim Peters (tim_one at email.msn.com) wrote: : Sure there are: finalizers in cycles remain largely useless in practice : without a way to specify the order in which they're invoked. Go back to the : Java part of the thread. The language can't know whether a cycle needs to : be finalized in a particular order, or, if it does, what that order may be. : In Java this has nothing to do with partial deletion: the spec is very : clear that the implementation must guarantee that all objects reachable from : a finalizer are wholly intact when the finalizer is run. What it doesn't : say-- because it can't --is that all objects reachable from a finalizer will : be in a "useful" state. I don't understand this phrase "useful" state. If you run a two pass collector then the order in which you finalise doesn't matter. All objects will be in a state in which they can be finalised in pass 1 since nothing is deleted in pass 1. I don't see the problem here at all. Tim Peters (tim_one at email.msn.com) wrote: : Understood the first time; but if finalizers are to be invoked on cycle : members, that's just necessary, not sufficient. : At the risk of sounding completely brain-dead ... huh?! graham -- As you grow up and leave the playground where you kissed your prince and found your frog Remember the jester that showed you tears the script for tears From ivnowa at hvision.nl Sat Jun 19 15:30:11 1999 From: ivnowa at hvision.nl (Hans Nowak) Date: Sat, 19 Jun 1999 19:30:11 GMT Subject: Newbie question In-Reply-To: <376BBB7E.A82DA789@primenet.com> References: <376BBB7E.A82DA789@primenet.com> Message-ID: <199906191928.VAA20205@axil.hvision.nl> On 19 Jun 99, John E. Garrott wrote: > I am have a problem with the program below. > The intent is, eventually, to get a list and display it, > in a list box, then print the selected row > from the listbox, but I can't get the callback > to work. > > The function dbs.databases() works, putting, > in this case, the databases owned by myself > into the listbox. When I click on the listbox > items they highlight as expected, but, apparently, > list_cb() is never called. > > I've read all the available literature on > binding and signals, tried numerous variations > on what is here. No results. This program > shows no errors, so is syntactically(sp?) > correct. Just doesn't work. > > What am I doing wrong? > > Thanks in advance, > > John > -------------------------------------------------------- > import dbs > import string > from Tkinter import * > > class SelectionBox: > > def __init__(self, master=None): > self.frame = Frame(master, name="frame") > self.frame.pack(expand=1, fill=BOTH) > > self.frame.listbox = Listbox(self.frame, name='listbox') > self.frame.listbox.pack(expand=1, fill=BOTH) > self.frame.listbox.bind('Button-1', self.list_cb) > > for item in dbs.databases(): > self.frame.listbox.insert(END, item) > > def list_cb(event): > print "Here we are!" I don't know for sure, but shouldn't this be def list_cb(self, event): ? I don't know if that's the solution for your problem, though... It's not like *I* know much about Tkinter. :o) Veel liefs, --Hans Nowak (ivnowa at hvision.nl) Homepage: http://fly.to/zephyrfalcon From arcanedragonNOSPAM at NOSPAMhome.com Sun Jun 13 10:31:18 1999 From: arcanedragonNOSPAM at NOSPAMhome.com (Chris Herborth) Date: Sun, 13 Jun 1999 14:31:18 GMT Subject: Module magic methods Message-ID: Do modules have magic methods? Specifically, I'm wondering if there's a __del__() or __destroy__() method that I could use to clean up after myself a little when the module is about to be unloaded... -- ----------================================================---------- _ Chris Herborth, R&D, Technical Writing | \ _ Arcane Dragon Software Arcane Dragon -==(UDIC)==- | < /_\ arcane dragon at home dot com DNRC Holder of Past Knowledge |_/ \_ From greg.ewing at compaq.com Thu Jun 10 19:52:05 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Fri, 11 Jun 1999 11:52:05 +1200 Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7j90va$6lk$1@cronkite.cc.uga.edu> <87pv384koy.fsf@ev.netlab.co.jp> <7jokdo$hih$3@cronkite.cc.uga.edu> Message-ID: <37604FA5.BEA4A11C@compaq.com> Graham Matthews wrote: > > Actually Blake I have a feeling that I have read a paper somewhere that > says that a mark sweep collector with refcounts can in fact patch up > refcount errors, Obviously this is true if the M&S can be sure of finding all the roots, since the refcount information is then redundant. But if there are roots that the M&S can miss (e.g. on the C stack or in data structures managed by an extension module) then it's still just as important as ever to keep the refcounts correct, since the M&S needs them to make sure it doesn't make a mistake. Greg From andreas at andreas.org Sun Jun 13 21:08:00 1999 From: andreas at andreas.org (Andreas Bogk) Date: 14 Jun 1999 03:08:00 +0200 Subject: OO (was: Why is tcl broken?) References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> <3762988E.C94AA252@iname.com> <3763C746.5CA8FE78@iname.com> Message-ID: Fernando Mato Mira writes: > Although Dylan never really made it into "Fernando's elegibility list" > because > it was not a serious contender against Scheme and CL yet, it definitely got > banished the day the Lisp syntax was dropped. I'm still waiting for the day > when the Dylan fans will reinstate the alternative. This is an age-old flamewar. It just so happens that there are people who like infix syntax and detest prefix, and then there are people who love their parens and hate infix. It's a matter of preferences, I happen to like infix, and I'm not gonna change. > But my dream is a `parenthesized Cecil' You're obviously one of THEM :-). Andreas -- Reality is two's complement. See: ftp://ftp.netcom.com/pub/hb/hbaker/hakmem/hacks.html#item154 From ivnowa at hvision.nl Thu Jun 10 15:38:29 1999 From: ivnowa at hvision.nl (Hans Nowak) Date: Thu, 10 Jun 1999 19:38:29 GMT Subject: Date formats In-Reply-To: <375FEA53.95E3D3BC@ausinfo.com> References: <375FEA53.95E3D3BC@ausinfo.com> Message-ID: <199906101937.VAA05181@axil.hvision.nl> On 10 Jun 99, mike milliger wrote: > I read the documentation in the Python Reference Library (6.3) on time > access and conversions and chapter 8 in programming python, yet I can't > figure out if i need ( or how to use) a tuple to format the return from > localtime(). i get a string now (wed jun 10 1999 xx:xx:xx) but i need > to format it to yyyymmdd_hhmmss. Is there any switch ( %) or function > that can be useful? Any help is appreciated. You can roll your own: # import time t = time.localtime(time.time()) # prints the tuple print t # prints a formatted tuple print "%d%02d%02d_%02d%02d%02d" % t[0:6] Disclaimer: This is untested, maybe the format will appear weird... but you'll get the idea. Veel liefs, --Hans Nowak (ivnowa at hvision.nl) Homepage: http://fly.to/zephyrfalcon From matomira at iname.com Sat Jun 12 13:27:42 1999 From: matomira at iname.com (Fernando Mato Mira) Date: Sat, 12 Jun 1999 19:27:42 +0200 Subject: OO (was: Why is tcl broken?) References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> Message-ID: <3762988E.C94AA252@iname.com> Fernando Mato Mira wrote: > [For example, I can think the Eiffel syntax is `philosophically' broken, but > as `infix' syntaxes go, it is not. And it's a good language (I programmed Actually, it's a _great_ language to learn SE (for OO pretty much too, but of course only in the restricted single-dispatch way most people know about. I like to call that "Subject Oriented"). Smalltalk taught me OO. Occam taught me about concurrency. Eiffel taught me SE. CLOS taught me what OO really means. -- "Object Oriented is to not think only about your `subject' and forget about your `arguments' - the syntactic objects of your sentence" Fernando D. Mato Mira Real-Time SW Eng & Networking Advanced Systems Engineering Division CSEM Jaquet-Droz 1 email: matomira AT acm DOT org CH-2007 Neuchatel tel: +41 (32) 720-5157 Switzerland FAX: +41 (32) 720-5720 www.csem.ch www.vrai.com ligwww.epfl.ch/matomira.html From gmcm at hypernet.com Thu Jun 17 12:56:25 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 17 Jun 1999 11:56:25 -0500 Subject: Why don't my global variables work? In-Reply-To: Message-ID: <1282483655-114305528@hypernet.com> Nathan J Froyd writes: > Can somebody explain this point to me? I have the following program > Could somebody look at this, perhaps running the program and explain > to me what fundamental fact I am missing here? Because it looks like > my program should run without errors. Thanks! /snip/ > # I HAVE DEFINED `count' HERE, PYTHON! > count = 0 /snip/ > def topic_read(regmatch, evilcount): > # if you comment this line, the program will not work > count = evilcount > print "\t" * count, "" % regmatch.group(1) > count = count + 1 Alas, the FAQ is down, so I can't point you there. Changing the binding of a global var requires a "global" statment. def topic_read(...): global count count = count + 1 Without that, Python (at the time the "def" is scanned) decides you are creating a local var named count. Then you go and reference said local var before you've given it a value. Boom. NameError. Non-intuitive, perhaps, but think of the strange bugs you'd have if locals didn't shadow globals of the same name. - Gordon From john at mediamanager.com.sg Mon Jun 28 07:37:50 1999 From: john at mediamanager.com.sg (john) Date: Mon, 28 Jun 1999 19:37:50 +0800 Subject: Extracting Text file contents using Python Message-ID: <37782f9a.0@news.smartnet.com.sg> Hi, I am trying to extract the following text file using python and the program & text file are as shown below. But unfortunately I am unable to get every separate data displayed except for the first data and after the separation line which is "====================" the next data is not getting picked up by the program. Could anyone kindly let me know what could be wrong with the program. Example Text File - But will be similar ---------------------------------------------------- Title:Meet Me Http Host:www.www.www Remote Address:10.2.0.1 Remote Host:10.2.0.1 Rating:8 Date:06/25/99 Time:17.15.28 ================================= Title:Meet Me Http Host:www.www.www Remote Address:10.2.0.1 Remote Host:10.2.0.1 Rating:8 Date:06/25/99 Time:17.15.28 ================================= Title:Meet Me Http Host:www.www.www Remote Address:10.2.0.1 Remote Host:10.2.0.1 Rating:8 Date:06/25/99 Time:17.15.28 ================================= Title:Meet Me Http Host:www.www.www Remote Address:10.2.0.1 Remote Host:10.2.0.1 Rating:8 Date:06/25/99 Time:17.15.28 ================================= Title:Meet Me Http Host:www.www.www Remote Address:10.2.0.1 Remote Host:10.2.0.1 Rating:8 Date:06/25/99 Time:17.15.28 ================================= The python program is as follows: #!c:/progra~1/python import string import sys import cgi #import urllib data_file = open('c:/xitami/cgi-bin/textfiles/FilmFestReview.txt', 'r') form = cgi.FieldStorage() header = \ """ Extract & Write """ footer = \ """ """ out = sys.stdout begin_table = 1 out.write(header) for line in data_file.readlines(): if begin_table: out.write('') begin_table = 0 if line[:5] == "=====": out.write('
    ') out.write('
    ') begin_table = 1 continue field_name, field_value = string.split(line, ':') out.write('\t\n') out.write('\t\t\n') out.write('\t\t\t%s\n' % field_name) out.write('\t\t\n') out.write('\t\t\n') out.write('\t\t\t%s\n' % field_value) out.write('\t\t\n') out.write('\t\n') out.write(footer) From suzuki611 at okisoft.co.jp Mon Jun 14 23:04:43 1999 From: suzuki611 at okisoft.co.jp (Hisao Suzuki) Date: 15 Jun 1999 12:04:43 +0900 Subject: fork() References: <000c01beb3c1$a3f428a0$329e2299@tim> <199906110443.AAA02408@eric.cnri.reston.va.us> <7k35bf$13iq$1@nntp6.u.washington.edu> Message-ID: In article <7k35bf$13iq$1 at nntp6.u.washington.edu>, donn at u.washington.edu (Donn Cave) wrote: > I want to ask more about this, partly I'm not sure I understand what > the trees and their roots are or what registration would require. I'm sorry for my poor explanation. The following is a simple example of a doubly-linked tree. class Node: pass root, node1, node2 = Node(), Node(), Node() root.child1, node1.parent = node1, root root.child2, node2.parent = node2, root Having circular references, the nodes are never deleted even if you `del root, node1, node2'. The registration requires at least one node: root, node1, or node2. You can traverse the entire tree from any node, but you would probably register the root since it is the most convenient node to start the traverse. In option (A), the registration also requires a function which will be applied to the root (or the node you registered) by the garbage collector. (The function may be a method of a certain name and thus the registration may require only the root.) In general, so-called `aggregations' in OO terms are implemented with trees. If the association of an aggregation is bi-directional, the result is a doubly-linked tree. I hope you imagine more practical examples. > Could something like a standard class method accomplish this? Like, > > def __garbagecollected__(self): > # author knows self.parent is a circular reference. > self.parent = None > > def __del__(self): > if self.parent: > ... Perhaps. But I am afraid it may be a little difficult, in practice, to write a correct __garbagecollected__ method which must work in any order of invocations determined arbitrarily by the garbage collector. On the other hand, if you register the root explicitly, you have a guarantee that the root will be accessed first, thus the whole tree is guaranteed to be in a more predictable state. --===-----========------------- Sana esprimo naskas sanan ideon. SUZUKI Hisao suzuki611 at okisoft.co.jp, suzuki at acm.org. From news at dorb.com Tue Jun 22 20:27:24 1999 From: news at dorb.com (Darrell) Date: Tue, 22 Jun 1999 20:27:24 -0400 Subject: Newbie: How do you "clear" PythonWin between runs? References: <37700E61.5388E101@alliedsignal.com> Message-ID: http://grail.cnri.reston.va.us/cgi-bin/faqw.py?query=reload&querytype=simple &casefold=yes&req=search -- --Darrell H. P. Friedrichs <" HPeter.Friedrichs"@alliedsignal.com> wrote in message news:37700E61.5388E101 at alliedsignal.com... > I've just started playing with python, so all of this is very new to me. > I have been writing some scripts, saving them to *.py files, and running > them under PythonWin 1.5.2 . The process is iterative; I code, save, > run, code, save, run, etc. > > What I have noticed is that python doesn't "reset" between runs. > Sometimes error messages reappear even though I have fixed the problem, > because some artifact of a previous run lingers. > > So, my question is this: How can I "flush" or "clear" the python > interpreter between successive runs? Is there a command I can add to my > script to initialize python before running the script? > > Thanks, > > Pete > hpeter.friedrichs at alliedsignal.com > > -- > > ----------------------------------------------- > | The opinions expressed here are my own, | > | and not necessarily those of my employer. | > ----------------------------------------------- > > From cwebster at math.tamu.edu Mon Jun 28 21:06:49 1999 From: cwebster at math.tamu.edu (Corran Webster) Date: 29 Jun 1999 01:06:49 GMT Subject: ANN: Stackless Python 0.2 References: <000c01bec11f$8dfbf800$e19e2299@tim> Message-ID: <7l9679$3od$1@news.tamu.edu> In article <000c01bec11f$8dfbf800$e19e2299 at tim>, Tim Peters wrote: >[Corran Webster, commenting on Christian Tismer's "stackless Python"] >> ... >> I wonder whether there's the potential here for more than coroutines >> and to write an implementation of threading within Python. > >It's been mentioned a few times. So far Guido isn't keen on any of this, >but he's been known to buckle after a few short years of incessant whining >. BTW, a coroutine pretty much *is* a thread in a time-sliced world, >just lacking a "transfer" function that invokes implicitly whenever it >bloody well feels like it . Indeed - and it was all this talk of coroutines that made me wonder why not go that extra bit. >> Each thread would presumably need its own Python stack, > >Nope! It's a beauty of the implementation already that each code object >knows exactly how much "Python stack space" it needs, and (just) that much >is allocated directly into the code object's runtime frame object. IOW, >there isn't "a Python stack" as such, so there's nothing to change here -- >the stack is implicit in the way frames link up to each other. Ah - my impression of the way that the stack works was wrong (hadn't gotten that far in the reading of the source). So each code object has a little block of stack space set aside (which is precalculated to be enough), together with a pointer to its own top of the stack inside that block? >> and a queueing and locking system would need to be added somehow, > >Yes, and that would require some changes to the core. Sounds doable, >anyway. More work than coroutines, I suspect, and I don't think it can be done easily to use the same framework as the current C threads. >> but because the Python and C stacks are no longer intertangled, switching >> between threads should be easy (as opposed to impossible ). > >I think Christian's approach moves lots of crazy ideas from impossible to >plausible. Indeed. A very nice piece of code. >> This wouldn't be quite as flexible as the current implimentations of >> threads at the C level - C extensions would be called in a single block >> with no way to swap threads until they return. > >That's mostly true today too: Python threads run serially now, one at a >time, and if a thread calling out to C doesn't release the global lock no >other thread will run until it returns. OK. And presumably most extensions don't bother to release the lock unless they specifically want to take advantage of threading somehow. >> On the other hand, this would allow every platform to have some sort >> of threading available, which would be a boon. > >It's even quite possible that "fake threads" would-- for programs that >aren't doing true multiprocessing --run significantly more efficiently than >today's scheme of creating OS-level threads and then choking them into >taking strict turns; e.g., because "the Python stack" grows only to the >exact size it needs, there's almost certainly much less memory overhead that >way than by letting the OS allocate a mostly unused Mb (whatever) to each >real thread's stack. This opens the possibility to create thousands & >thousands of fake threads. Although any machine which is being used that intensively probably already has some sort of C level threading available. >> Unfortunately I'm not familiar enough with threads to go out there and >> implement it right away, but I thought I'd at least raise it as a >> possibility and see what people think and what the pros and cons are. > >It's sure worth pondering! > >write-some-code-anyway-&-get-famous-one-way-or-another-ly y'rs - tim Well, I won't be writing it this week but I have a better idea of the ins and outs now. Thanks. Corran From billtut at microsoft.com Thu Jun 24 22:27:18 1999 From: billtut at microsoft.com (Bill Tutt) Date: Fri, 25 Jun 1999 02:27:18 GMT Subject: pkzip and using popen on Windows 98 ??? Message-ID: <4D0A23B3F74DD111ACCD00805F31D8100DB90E3F@RED-MSG-50> There was a bug in Win95 that prevents win32pipe from working. KB: Q150956 The same problem may not have been fixed in Windows 98. I don't have a local Win98 box to test it on. The current URL for this information is: http://support.microsoft.com/support/kb/articles/q150/9/56.asp I also just added this using Guido's cool FAQ wizard.. Maybe I won't have to keep digging the KB article up anymore. :) Bill From nathan at islanddata.com Tue Jun 22 11:03:35 1999 From: nathan at islanddata.com (Nathan Clegg) Date: Tue, 22 Jun 1999 08:03:35 -0700 (PDT) Subject: restoring signal handlers Message-ID: Is it necessary to restore original signal handlers before quitting a program? I can see saving them if I want to restore them at some middle point of execution, but if I want my own handlers in place for the entire life of my app, do I need to bother saving and restoring the originals? ---------------------------------- Nathan Clegg nathan at islanddata.com From john.michelsen at gte.net Wed Jun 2 23:52:27 1999 From: john.michelsen at gte.net (John Michelsen) Date: Thu, 03 Jun 1999 03:52:27 GMT Subject: More Tkinter menu problems References: <3755C714.526B7994@pixar.com> Message-ID: <%Zm53.899$S15.46310@dfiatx1-snr1.gtei.net> > self.menu.add_command(label = new_name, > command = lambda temp_color = new_color: > self.select_color(temp_color)) > >but I get a Name Error on "self". So now "self" is out of scope when >the menu call happens. try: self.menu.add_command(label = new_name, command = lambda c=new_color, f=self.select_color: f(c)) John From nessus at mit.edu Fri Jun 11 14:27:10 1999 From: nessus at mit.edu (Douglas Alan) Date: 11 Jun 1999 14:27:10 -0400 Subject: ^C and os.system() Message-ID: Greetings. Is it considered a bug or a feature that if I type ^C at a Python program that is in the middle of executing a call to os.system(), the Python program never seems to see the SIGINT signal? Instead, only the process created by os.system() receives the signal. Consequently, if I have a Python script that executes a program repeatedly for a list of files, for instance, I can't kill the Python script with ^C. Personally, I find this kind of annoying. This is using Python 1.5.1 under Solaris 2.6. Please forgive me if this a bug that has already been fixed under 1.5.2. Also, when I have the Python program check the return status of a command invoked via os.system() and subsequently killed with ^C, instead of getting back 0x0002, as would be expected from a process killed by SIGINT, I usually get back 0x8200. Sometimes I get back 0xd000. Only infrequently do I get back the 0x0002 that I would expect. None of these problems occur if I use commands.getstatusoutput() instead of os.system(), so I guess I will stick with getstatusoutput() for the time being. |>oug http://space.mit.edu/~nessus From amp26494 at ammex001.amp.com Thu Jun 3 11:01:17 1999 From: amp26494 at ammex001.amp.com (Solenberger, Keith) Date: Thu, 3 Jun 1999 11:01:17 -0400 Subject: PythonWin wish list References: <7iv11t$nb0$1@nnrp1.deja.com> Message-ID: <56AEBCBEB11CD211BC9800805FA766FDA06FDD@ammex006.amp.com> > -----Original Message----- > From: cmedcoff at my-deja.com [SMTP:cmedcoff at my-deja.com] > Posted At: Monday, May 31, 1999 6:05 PM > Posted To: python > Conversation: PythonWin wish list > Subject: PythonWin wish list > > One of the nice things about python is the free development > environment > PythonWin. I certainly don't get my other development environments > for > free. > > Having used PyhonWin a couple of weeks now I have a couple of comments > in the form of a wish list. Comments are welcome. > > 1)It would be really nice of the interactive window was dockable. I > find myself constanly searching for that window. I like to have my > edit windows maximized. An example of this in another application > would > be Microsoft Visual Studio's output window where once can see error > messages from compiles. It is never covered up even if my edit > buffers/windows are maximized and I can hide it if I want even more > space. > > 2)PythonWin conforms to the Windows MDI interface except for the > floating window that comes up during debugging. It would be nice if > that window could be incorported into the MDI environment. This would > be another candidate for a dockable window. > > 3)One other thing that would make the PyhonWin environment even nicer > is hot-keys or accelerators. Its always nice to have the mouse when > you are learning an application but hot-keys are always faster once > you've got them memorized. Good candidates here are keys for stepping > in, out, over during debugging and access to the interactive window. > > Regards, > Chuck > > > Sent via Deja.com http://www.deja.com/ > Share what you know. Learn what you don't. From gmcm at hypernet.com Mon Jun 7 19:52:23 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Mon, 7 Jun 1999 18:52:23 -0500 Subject: Tkinter problem in Python 1.5.2 on Solaris 2.5.1 In-Reply-To: <928792539.297.78@news.remarQ.com> Message-ID: <1283322699-63834024@hypernet.com> Gordon Vinther wrote: > I seem to be having the same problem. Where and how do I find these > patches?? > > Gordon McMillan wrote: > > > > > > Jan Zegers wrote: > > > > > > > > I have the following problem with Tkinter in Python 1.5.2. > > > /snip/ > > > > This probably means that Tcl wasn't installed properly. > > > > > > > > Note the whitespace between the two last test lines. The > > > > installation is as follows: > > > > Tcl/Tk 8.1 with --enable-shared so we have libraries > > > > /usr/local/lib/libtcl8.1.so and /usr/local/lib/libtk8.1.so > > > > > > Tcl / Tk 8.0 is still the official version for Python. > > > > > > On Jun 1, Dieter Maurer posted patches to use 8.1 ("Tkinter-patch for > > > use with Tk8.1..."). > > > > > > - Gordon > > Thank you. I applied the patches and it worked! > > Kind regards, > > Jan You go to www.python.org. You click the "Search" link. You use "Search the Python Newsgroups" and type in the article title I quoted. You click the link for the article written by Dieter Maurer. Now you never need ask this question again. but-give-a-man-a-fishing-pole-and -he'll-never-get-any-work-done-again-ly y'rs - Gordon From chapman at bioreason.com Wed Jun 16 10:10:55 1999 From: chapman at bioreason.com (Mitch Chapman) Date: Wed, 16 Jun 1999 08:10:55 -0600 Subject: pygtk - clist title button References: <376755A5.15621A4@onera.fr> Message-ID: <3767B06F.70E70EDB@bioreason.com> Marc POINOT wrote: > > Hmmm... a question about pygtk, but I guess it's more > gtk than python :} > I make this public instead of sending it to James Henstridge > as a private email (or to gtk list). > > How to connect a signal to a clist title button? Here's what works for me: # Get the title button for column i columnHeader = clist.get_column_widget(i) button = columnHeader["parent"] The trick is that gtkclist_get_column_widget(), instead of giving you the button widget, gives you the GtkAlignment widget contained by the button. Dunno why. -- Mitch Chapman chapman at bioreason.com From ivanlan at callware.com Mon Jun 14 10:11:21 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Mon, 14 Jun 1999 14:11:21 GMT Subject: Variations on a theme by "pound bang" References: <3763e75f.3265255@news.iol.ie> <3763F77E.6094AEE9@appliedbiometrics.com> <3764185B.7BCBC488@Lugoj.Com> Message-ID: <37650D89.52D687F8@callware.com> Hi All-- James Logajan wrote: > > Christian Tismer wrote: > > > > Sean Mc Grath wrote: > > > > > > Can anyone shed some light on the benefits of:- > > > > > > # !/usr/bin/env python > > > > Uses the env program which is allways there, to figure out > > from the environment settings which python to use. > > Alas, this is a myth. Not all Unixen put env in /usr/bin, some put it in > /bin. I can't recall if it was Solaris (probably not) or LynxOS (probably) > that put env in /bin. Anyway, I got bit by it. UnixWare doesn't put it in /usr/bin either; since I have successfully TRASHED my UnixWare system, AT LAST!, in favor of RedHat 6.0 SMP, I can't tell you where it was. Someplace bizarre, I think. -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From Mikael.Lyngvig at p98.f112.n480.z2.fidonet.org Wed Jun 30 19:51:16 1999 From: Mikael.Lyngvig at p98.f112.n480.z2.fidonet.org (Mikael Lyngvig) Date: Thu, 01 Jul 1999 00:51:16 +0100 Subject: Python GUIs: Summary and Conclusion Message-ID: <000015e4@bossar.com.pl> From: mikael at pobox.com (Mikael Lyngvig) On Mon, 28 Jun 1999 18:09:48 GMT, "Michael P. Reilly" wrote: >I've already rewritten _tkinter to use a new pytcl module, but the >functionality is still the same, ie. executing Tk calls from within an >interpreter. But I'd like to see it using the TK/C API (so much for >my hard word on rewriting _tkinter *wink*). > >The main issue would be to make it extensible for adding the new >widgets and other extensions (BTL, PIL, etc.). Also, the interface >between Python and C would not be as "simple" as the existing module. >It's doable tho. > >Note that using the "native" Tk API would still require linking with >the Tcl library. > >I could scratch my _tkinter rewrite and work on a native solution. >(I could still publish my pytcl module.) Any thoughts? I've downloaded the Tcl 8.1.1 and Tk 8.1.1 sources, rebuilt them, and studied them for a bit. I think we're looking at a major task. As far as I can determine from the Tk sources, the parser is an integral part of the Tk library. E.g., the Tk sources appear to be high-level down to the lowest level. Even the lowest level functions takes argv[] style parameters and, aassisted by a horde of strncmp()s (350+ in the generic directory), parse the parameter/option list into a command, which is executed by code which is interleaved with the parsing code. I incorrectly assumed the design would be something like: [Tcl parser layer] [Tk parser layer] [Tk implementation layer] But it appears to be: [Tcl parser layer] [Tk parser and implementation layer] My hope was to make a Python interface run on top of the implementation layer, but that appears to be impossible with the current Tk design. So, in order to make a native Tk layer for Python, we'd have to create the implementation layer ourselves, and convince the Tk maintainers to adopt this (if we'd want their future to be part of our TkInter automatically). I can illustrate what I mean by looking at the Tk bell command's implementation: int Tk_BellObjCmd(clientData, interp, objc, objv) ClientData clientData; /* Main window associated with interpreter. */ Tcl_Interp *interp; /* Current interpreter. */ int objc; /* Number of arguments. */ Tcl_Obj *CONST objv[]; /* Argument objects. */ { static char *bellOptions[] = {"-displayof", (char *) NULL}; Tk_Window tkwin = (Tk_Window) clientData; char *displayName; int index; if ((objc != 1) && (objc != 3)) { Tcl_WrongNumArgs(interp, 1, objv, "?-displayof window?"); return TCL_ERROR; } if (objc == 3) { if (Tcl_GetIndexFromObj(interp, objv[1], bellOptions, "option", 0, &index) != TCL_OK) { return TCL_ERROR; } displayName = Tcl_GetStringFromObj(objv[2], (int *) NULL); tkwin = Tk_NameToWindow(interp, displayName, tkwin); if (tkwin == NULL) { return TCL_ERROR; } } XBell(Tk_Display(tkwin), 0); XForceScreenSaver(Tk_Display(tkwin), ScreenSaverReset); XFlush(Tk_Display(tkwin)); return TCL_OK; } The way I see it, this should have been something like this: int Tki_WindowBell(Window) Tk_Window Window; { XBell(Tk_Display(Window), 0); XForceScreenSaver(Tk_Display(Window), ScreenSaverReset); XFlush(Tk_Display(Window)); return TCL_OK; } int Tk_BellObjCmd(clientData, interp, objc, objv) ClientData clientData; /* Main window associated with interpreter. */ Tcl_Interp *interp; /* Current interpreter. */ int objc; /* Number of arguments. */ Tcl_Obj *CONST objv[]; /* Argument objects. */ { static char *bellOptions[] = {"-displayof", (char *) NULL}; Tk_Window tkwin = (Tk_Window) clientData; char *displayName; int index; if ((objc != 1) && (objc != 3)) { Tcl_WrongNumArgs(interp, 1, objv, "?-displayof window?"); return TCL_ERROR; } if (objc == 3) { if (Tcl_GetIndexFromObj(interp, objv[1], bellOptions, "option", 0, &index) != TCL_OK) { return TCL_ERROR; } displayName = Tcl_GetStringFromObj(objv[2], (int *) NULL); tkwin = Tk_NameToWindow(interp, displayName, tkwin); if (tkwin == NULL) { return TCL_ERROR; } } Tki_WindowBell(tkwin) return TCL_OK; } That way we could easily add a very fast Python layer on top of the Tki_Xxx() functions. So, in order to accomplish the task we'd have to restructure the entire Tk source distribution - basically modify all functions in all source files. >We already know that Python 1.6 won't be until the new year, so any >changes to Tkinter would be as a patch. >From what I know now, I suspect that Python 3.0 could be done by the time we're through :) Also, if we did separate the parser and the implementation, we'd end up with something which is directly incompatible with add-on widgets and so on. Although we could probably make a TkParser module, which could interface to the parser layer. My view, given the latest info, is that the task of making a native TkInter is so huge that it doesn't pay off, unless your goal is to use Tk in some form (not to get a fast, portable GUI). The quickest way to make TkInter faster is to wait a couple of years till your (then) computer has quadrubled in speed. What are your thoughts? P.S. Can anyone tell me how to ring a bell using the native Tk API? I don't see any way, except to do what Tk_BellObjCmd() does yourself. -- Mikael From alex at somewhere.round.here Sun Jun 6 17:22:43 1999 From: alex at somewhere.round.here (Alex) Date: 06 Jun 1999 17:22:43 -0400 Subject: Suggestion: Dutch Python mailinglist References: <000101beb058$c992bc00$e39e2299@tim> Message-ID: this_notion = 'one-day-the-whole-world-will-speak-python' scary = 0 this_notion is scary From MHammond at skippinet.com.au Thu Jun 17 17:57:31 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Fri, 18 Jun 1999 07:57:31 +1000 Subject: do anonymous pipes normally work on NT? References: <4D0A23B3F74DD111ACCD00805F31D8100DB90DE4@RED-MSG-50> Message-ID: <7kbqt5$bep$1@m2.c2.telstra-mm.net.au> Bill Tutt wrote in message <4D0A23B3F74DD111ACCD00805F31D8100DB90DE4 at RED-MSG-50>... > >Alter the PyHANDLE_Check() branch of win32processmodule_win32.cpp:sethandle >to: > *pobHandle = v; > if (PyWinObject_AsHANDLE(v, ph)) > { > Py_INCREF(v); > } > else > { > rc = -1; > } Ahh - excellent analysis. I made the mistake of attempting to use some fancy C++ operators, and, like many C++ features, turned around and bit me in the bum. I will also seek out and destroy any similar casts. Good stuff! Mark. From H..P..Friedrichs at p98.f112.n480.z2.fidonet.org Wed Jun 30 22:30:31 1999 From: H..P..Friedrichs at p98.f112.n480.z2.fidonet.org (H. P. Friedrichs) Date: Thu, 01 Jul 1999 03:30:31 +0100 Subject: Help: Can you explain this error? (contains code snip) Message-ID: <00001628@bossar.com.pl> From: "H. P. Friedrichs" <" HPeter.Friedrichs"@alliedsignal.com> Thanks! Pete Jeff Epler wrote: > On Wed, 30 Jun 1999 16:49:58 -0700, H. P. Friedrichs > <@alliedsignal.com> wrote: > >Hello: > > > >This is week 2 for me in python...What fun! > > > >I have stumbled across an interesting problem. When the code below is > >run under Win95 (python 1.5.2),it works without problems. If the same > >code is run under Linux (python 1.4) I get the error: > > Make things simpler: > > >>> int("123") > > this works in Python 1.5.x and fails in 1.4. I believe this feature is > present in all 1.5.x and no standard 1.4 versions. > > Use > > >>> string.atoi("123") > to work on both versions. > > Jeff -- ----------------------------------------------- | The opinions expressed here are my own, | | and not necessarily those of my employer. | ----------------------------------------------- From sdm7g at Virginia.EDU Fri Jun 25 20:02:01 1999 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Fri, 25 Jun 1999 20:02:01 -0400 (EDT) Subject: How to obtain an instance's name at runtime? In-Reply-To: <7kvd8b$ueb$1@nnrp1.deja.com> References: <7kqpu8$7u1$1@nnrp1.deja.com> <3771127C.E40F9BF3@home.com> <7kvd8b$ueb$1@nnrp1.deja.com> Message-ID: On Fri, 25 Jun 1999, Dinu C. Gherman wrote: > In article <3771127C.E40F9BF3 at home.com>, > Jim Meier wrote: > > > > Well, there sort of is a solution, but I don't think you're going > > to like it. Incidentally, why are you trying to discover this? I'm > > not a super-meister-coder, but I can't imagine a situation where > > knowing this would be useful. > > Ok, I knew I was going to look like a dumb camel right after > posting my question... Nevertheless there is a useful case of > knowing such an instance's name, at least I believe I found > one. Have a look at the following page, spot the question mark > and you'll know what I mean: > > http://starship.python.net/crew/gherman/UMLgenTest.pdf > > But, PLEASE, don't start to ask me anything about the project > itself!! It's all in a very pre-pre-pre-alpha phase... > > There might be some workaround solution in oder to get that > name I want, as in some of the replied in this thread, but > I'll evaluate that later... It's easy to get *A* name -- Classes and functions have cannonical names in Python because Python distinguishes between definition and assignment for classes and functions. They also have a cannonical namespace -- for classes, their __module__ attribute, for Python functions, their func_globals attribute (which is the __dict__ of the __module__ they were defined in.) That's why their names are "sticky" . Classes and functions can be aliased and assigned to other names, but for debugging, tracebacks and printing, you want that cannonical defining name. There are other types of objects that could benefit from "sticky" names: constants and enumns for example. But Python doesn't have a different syntax to indicate a definition separate from any other assignment. You can get a name by searching for the thing in all of the namespaces: >>> def findname(thing): ... for mod in sys.modules.values(): ... for name,val in mod.__dict__.items(): ... if val is thing : return name >>> findname( sys.stdin ) 'stdin' >>> findname( findname ) 'findname' >>> findname( lambda x: x+1 ) # anonymous function doesn't have a name # returns None >>> xxx = sys.stdin # alias sys.stdin to another name >>> findname( sys.stdin ) # finds *a* name (whichever is first) 'xxx' # Try the __name__ attribute first before searching... >>> def nameof( THING ): ... return getattr( THING, '__name__', None ) or findname( THING ) ... >>> nameof( lambda x: x+1 ) '' >>> mod = sys >>> nameof( mod ) 'sys' [1] You could do a smarter seach of the name space, but I'm not sure if that would be any better for your application. [2] You could also append the module name to the name and return "sys.stdin" rather than "stdin" above. [3] Might there be cases where you want the '__repr__' rather than the name ? i.e. "', mode 'r' at 5a28500>" rather than "stdin" ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- "IA-64 looks just about like what you would expect from a PA-RISC and IA-32 train wreck with a little VLIW thrown in for spice." * Thomas J. Merritt in * From moshez at math.huji.ac.il Thu Jun 10 01:47:42 1999 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Thu, 10 Jun 1999 08:47:42 +0300 Subject: Python 2.0 In-Reply-To: References: <000801beb2e8$05e98760$af9e2299@tim> Message-ID: On Thu, 10 Jun 1999, Blake Winton wrote: > >Solve the problem by ignoring it? Guido would find that more > >attractive than I would . > > If so, then he would have given up on this thread a long time ago... Why? He seems to ignore it just fine! quoting-out-of-context-ly y'rs, Z. -- Moshe Zadka . QOTD: My own exit is more likely to be horizontal then perpendicular. From adjih at technologist.com Wed Jun 9 19:55:14 1999 From: adjih at technologist.com (Cedric Adjih) Date: Thu, 10 Jun 1999 01:55:14 +0200 Subject: Python CPU References: <14171.17113.39933.904980@lrz.de> Message-ID: <375EFEE2.4910D99D@technologist.com> Eugene Leitl wrote: > Have there been any attempts in creating an ASIC capable of > interpreting Python opcodes directly? Of course, with > soon-to-arrive Java chips and JPython there might be not > that much need for it... Well Python opcode is so complex that you will need microcode, and many microcode instructions for each Python bytecode. Fortunatly the computer industry has anticipated the fact that Python will become the Next Big Language, so they made some processors so as: - microcode is downloadable. - microcode is pipelined (a must for speed). Actually, they already made a big architectural optimisation: they added some microcode cache, so that you wouldn't be limited by some total microcode memory limit. Instead you continuously download the microcode for the bytecode ; except when it is already in the cache. Because of program locality, most of the microcode will end-up in the cache ; so the penalty will be small compared to downloading the microcode only once ; while the flexibility will be much higher. The good thing is that compilers generating directly microcode have been released, and Guido has already managed to compile Python on one this processors. These Python-aware processors are also known as "RISC microprocessors". -- Cedric From dkirby at bigfoot.com Mon Jun 14 11:53:03 1999 From: dkirby at bigfoot.com (Dave Kirby) Date: Mon, 14 Jun 1999 15:53:03 GMT Subject: [pythonwin] popup menu problems (was: [Pythonwin] Help needed creating a Window) Message-ID: <37651bde.25372123@NNRP.UK.INSNET.NET> Thanks to Mark Hammond's help I now have an app that displays an icon in the system tray which I can process messages from. However when I try to create a popup menu menu for it nothing happens. The call to PyCMenu.TrackPopupMenu doesnt display anything and never returns. I have tried both using it to send a notify message to the window and returning a command, but it didnt make any difference. I am unsure whether it is a failure of my understanding of the way Windows does these things, a bug in my code, or a problem with pythonwin. I also have the minor problem that when I destroy the icon it doesnt disappear until I move the mouse pointer over it. Does anyone know how to force the system tray to redraw? Any help would be greatly appreciated. Dave K Here is the relevant code: #--------------- 8< -------------------------------------- class Icon: #constructor # param: dll - handle to the dll containing the icon resources # param: startIcon - the initial icon resource ID to display # param: tooltip = the string to display when the cursor is over # the icon def __init__( self, dll, startIcon, tooltip ): self.iconMap = {} self.msgID = win32con.WM_USER+20 launchID = win32con.WM_USER+21 quitID = win32con.WM_USER+22 message_map = { win32con.WM_DESTROY: self.OnDestroy, self.msgID : self.OnTaskbarNotify, win32con.WM_CONTEXTMENU : self.OnContextMenu, } #the menu_map contains the information on the popup menu #entries - # message ID, callback function, text string menu_map = ( ( launchID, self.OnLaunch, "Launch Browser" ), ( quitID, self.OnExit, "Exit program" ) ) self.dll = dll #add menu commands to the message_map dictionary for entry in menu_map: message_map[entry[0]] = entry[1] #define a window class for the icon handler wc = win32gui.WNDCLASS() hinst = wc.hInstance = win32gui.GetModuleHandle(None) wc.lpszClassName = "BaxterTaskbar" wc.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW wc.hCursor = win32gui.LoadCursor( 0, win32con.IDC_ARROW ) wc.hbrBackground = win32con.COLOR_WINDOW wc.lpfnWndProc = message_map classAtom = win32gui.RegisterClass(wc) #create the window style = win32con.WS_OVERLAPPED | win32con.WS_SYSMENU self.hwnd = win32gui.CreateWindow( classAtom, "title", style, 0,0, win32con.CW_USEDEFAULT, win32con.CW_USEDEFAULT, 0, 0, hinst, None) win32gui.UpdateWindow(self.hwnd) self.cWnd = win32ui.CreateWindowFromHandle( self.hwnd ) #initialise the icon display icon = win32gui.LoadIcon( 0, win32con.IDI_APPLICATION ) flags = win32gui.NIF_ICON \ | win32gui.NIF_MESSAGE \ | win32gui.NIF_TIP nid = (self.hwnd, 0, flags, self.msgID, icon, tooltip) win32gui.Shell_NotifyIcon(win32gui.NIM_ADD, nid) self.changeIcon( startIcon ) #initialise the popup menu self.cMenu = win32ui.CreateMenu() for entry in menu_map: self.cMenu.AppendMenu( win32con.MF_STRING, entry[0], entry[2] ) #################################### # this is the bit that actually calls the popup menu #################################### def OnTaskbarNotify(self, hwnd, msg, wparam, lparam): if lparam==win32con.WM_LBUTTONDBLCLK: print "double clicked" elif lparam==win32con.WM_RBUTTONUP: pos = win32api.GetCursorPos() print "opening menu at", pos self.cMenu.TrackPopupMenu( pos, owner=self.cWnd ) #alternative attempt returning a command: #cmd = self.cMenu.TrackPopupMenu( pos, # win32con.TPM_LEFTALIGN # |win32.TPM_LEFTBUTTON # |win32con.TPM_NONOTIFY # |win32con.TPM_RETURNCMD, None ) print "finished popup menu" return 1 #the following methods are included for completeness, but are not # part of the problem #change to a new icon - if hasnt been loaded then do so, otherwise #use cached icon def changeIcon( self, iconResource ): if self.iconMap.has_key( iconResource ): icon = self.iconMap[iconResource] else: icon = win32gui.LoadIcon(self.dll, iconResource) self.iconMap[iconResource] = icon flags = win32gui.NIF_ICON nid = (self.hwnd, 0, flags, 0, icon) win32gui.Shell_NotifyIcon(win32gui.NIM_MODIFY, nid) def changeTooltip( self, tip ): flags = win32gui.NIF_TIP nid = (self.hwnd, 0, flags, 0, 0, tip) win32gui.Shell_NotifyIcon(win32gui.NIM_MODIFY, nid) #destructor - remove icon def __del__( self ): nid = (self.hwnd, 0, win32gui.NIF_MESSAGE, self.msgID ) win32gui.Shell_NotifyIcon(NIM_DELETE, nid) win32gui.UpdateWindow(self.hwnd) def OnDestroy(self, hwnd, msg, wparam, lparam): nid = (self.hwnd, 0, win32gui.NIF_MESSAGE, self.msgID ) win32gui.Shell_NotifyIcon(NIM_DELETE, nid) win32gui.UpdateWindow(self.hwnd) def OnContextMenu(self, *args): print "Icon.OnContextMenu", args def OnLaunch(self, *args ): print "Icon.OnLaunch", args def OnExit(self, *args ): print "Icon.OnExit", args From annis at biostat.wisc.edu Wed Jun 9 12:14:07 1999 From: annis at biostat.wisc.edu (William Annis) Date: 09 Jun 1999 11:14:07 -0500 Subject: [ANN] PyKstat 0.01 - Solaris kstat(3k) access Message-ID: I have finally decided to release PyKstat, a Python interface to the Solaris kstat(3k) API. The package can be found at http://www.biostat.wisc.edu/~annis/creations/pykstat.html Here is the README file which comes with the package... This is the initial release of a Python interface to the Solaris kstat API. I recommend checking out the man pages for information on the C API. This will only work for Solaris, and has been tested on Solaris 2.5, 2.5.1, and 2.6 for SPARC Solaris, and 2.6 for the Intel version of Solaris, using Python 1.5.1 and 1.5.2. * Why did I do this? I am currently re-implementing a machine monitoring system. The original version, written in Perl, has to fork off and parse the output from various system data tools, such as iostat, vmstat, uptime, etc. As it turns out, the vast majority of this data -- and a whole lot more -- is available via the kstat(3k) interface. I wanted to be able to get all this data without forking. * How did I do this? The PyKstat package has several parts, starting with a helper library in C wrapping kstat into something more friendly. The next layer is the lowest Python layer, and is generated by SWIG. I distribute the SWIG generated wrappers, so you do not need SWIG installed to use this package... unless you want to. The SWIG layer is little more than a Python version of my wrappers. The next layer is in kstat.py. This provides an object oriented interface, and nicely hides the chain-following you have to do if you use the simplest interface. kstat.py provides a single class, Kstat, which does all the interesting work. This interface does however assume some familiarity with the kstat(3k) API. The final layer of PyKstat, and the interface I suspect most people will want to use, is in kstats.py. This interface is *not* OOPy, but it does use the Kstat class as its engine. I strongly recommend looking at the doc strings in kstats.py and playing with the many functions provided to get a feel for the API. For the perversely curious, the dependencies are: kstat API <- wkstat.c (my helpers) <- wkstatmodule.so (SWIG generated interface to wkstat.c) <- kstat.py (OOPy interface to wkstatmodule.so) <- kstats.py (the most friendly interface). * What about bugs? There are doubtless some bugs. However, I don't believe there are any major ones. I have been using this software to check machine statistics for a few months now, and in fact some single Python programs have been running *continuously* for a month and reporting on machine statistics. If you discover any bugs, certainly let me know, but try to include as much information as possible, and a snippet of code which causes the problem. The install process could be more elegant. * Cool! How do I install this. Take a look at the Makefile. It's pretty simple. You should only need to change your CC, though I recommend using gcc, and the two lines saying where your Python is installed. Then run 'make', then 'make install'. The install process is crude in the extreme, and simply copies a few files into your Python library area. Check out the few examples in the examples directory to get an idea of how this package can be used. I've included the program netd as an example. It will *not* work for you, since it requires libraries I've not made public yet. It does, however, provide an interesting example. William S. Annis 99jun09 -- William Annis - System Administrator - Biomedical Computing Group annis at biostat.wisc.edu PGP ID:1024/FBF64031 Mi parolas Esperanton - La Internacia Lingvo www.esperanto.org From mss at kepler.de Mon Jun 14 12:33:48 1999 From: mss at kepler.de (Michael S. Schliephake) Date: Mon, 14 Jun 1999 18:33:48 +0200 Subject: TKinter modal dialog References: <018301beb673$8fdd6ca0$a9807018@yec1.on.wave.home.com> Message-ID: <37652EEC.27373AF1@kepler.de> Mike C. Fletcher wrote: > The win32 extension dialogs have a "doModal", which is exactly what > I'm looking for. Anyone care to point out what section of the docs I > didn't read that describes a TKinter doModal :) . I'm using a subclass of Toplevel to do this. However the window will appear in the Windows Task Bar. Michael. -------- Short listing: -------------- DEFBTN_OK = 0x00000001 DEFBTN_CANCEL = 0x00000002 class aDlgBox (Tkinter.Toplevel): def __init__( self, parent, title, defBtns): Tkinter.Toplevel.__init__(self, parent) self.protocol( 'WM_DELETE_WINDOW', self._setAbort) self.State = 0 self.title(title) self.BtnFrame = Tkinter.Frame(self, bd=0) self.BtnFrame.pack(side='bottom', fill='x', expand=1) if defBtns & DEFBTN_CANCEL: self.Cancel = Tkinter.Button(self.BtnFrame, text="Abbrechen", underline=0, command = self._setAbort) self.Cancel.pack(side='right') if defBtns & DEFBTN_OK: self.Ok = Tkinter.Button(self.BtnFrame, text="Best?tigen", underline=0, command = self._setOk) self.Ok.pack(side='right') def AddChild( self, wdg, **kw ): wdg.pack(kw, after=self.BtnFrame) def Control( self ): oldFoc = self.focus_get() self.focus_set() self.grab_set() self.mainloop() self.grab_release() if oldFoc: oldFoc.focus_set() return self.State def _setAbort( self ): self.State = 0 self.quit() def _setOk( self ): self.State = 1 self.quit() From news at dorb.com Thu Jun 17 11:20:16 1999 From: news at dorb.com (Darrell) Date: Thu, 17 Jun 1999 11:20:16 -0400 Subject: GC play Message-ID: Playing with finding cycles and have a problem. If I'm passed a reference is there a way to get its vital information like name, filename, line number.... ? -- --Darrell From arcege at shore.net Tue Jun 22 12:31:55 1999 From: arcege at shore.net (Michael P. Reilly) Date: Tue, 22 Jun 1999 16:31:55 GMT Subject: Creating a new type with an extension module References: <14191.44065.236852.546922@weyr.cnri.reston.va.us> Message-ID: <%TOb3.936$7X1.238390@news.shore.net> Fred L. Drake wrote: : Michael P. Reilly writes: : > But the documentation on extending Python is pretty well known : > deficiency. Luckily it is far easier than most languages, both to : > accomplish and to understand (yet more kudos to Guido). Actually, in : > responce to your earlier posting, I started writing a _SHORT_ webpage : > explaining what is needed, which I hope to have available later today. : > I plan (and hope) to make it into a How-To later. : If you'd like to make it a patch to the standard documentation, I'm : sure many people would be incredible grateful, including myself. The : time I have available to extend the documentation in all the ways that : are requested seems a bit fleeting at the moment. : Seriously, if anyone would like to extend the standard documents, : I'll be glad to lend a hand with the markup. If you write the : content, I'll accept it as text if I need to! I can do that, Fred. I like the Python Tex style, but I do have problems making the necessary DVIs from your tools. I may need your help on that (sun-i386-solaris). I do have to download your newest version tho. First things first: get the little HTML ref kit out. :) -Arcege From kiki at pixar.com Sat Jun 19 23:59:40 1999 From: kiki at pixar.com (Cynthia Pettit) Date: Sat, 19 Jun 1999 20:59:40 -0700 Subject: newbie tkinter -- radio buttons Message-ID: <376C672C.F817E0C0@pixar.com> Okay, you get your choice of answering any single one of these questions to solve my woes! :) I'm making a color menu in a drawing program. It allows you to add named colors as you go. At first, I was adding colors this way: self.color_menu.add_radiobutton(label=color_name, value = color_name, variable = self.current_color) [Note: a couple other issues: value and variable don't seem to work. When I choose the button, it does not change the value of self.current_color.] This works, but the problem is I can't set the first one to being "selected", nor can I change the new color to be "selected"... it looks really dorky to have no colors selected when you start and when you add new colors. You have to *select* a color to start the radio buttons working [after that, they're fine and switch properly among them.] So I changed to this, so I could call the select() method: temp = Radiobutton(self.color_menu, text=color_name, value = color_name, variable = self.current_color) temp.pack(anchor=W) temp.select() But now, of course, this conflicts with other calls, like add_command and add_separator. [eg "Add Color"] The buttons look to be on top of eachother. I think this is due to the .pack() calls not working with the add_radiobutton calls. Here's a choice of things that if solved would save me [in order of preference]: Call .select() on an add_radiobutton [and just how *does* one ever access these buttons ever again?!?!] Integrate add_command and .pack() so they don't stomp on eachother Be able to temp = Separator(self.color_menu) I'm sure each of these have very simple answers... Thanx! Kiki From luisroco at hotmail.com Fri Jun 11 18:31:48 1999 From: luisroco at hotmail.com (Luis Roco Arriagada) Date: Fri, 11 Jun 1999 22:31:48 GMT Subject: Using PIL with CGI scripts Message-ID: <19990611223149.63326.qmail@hotmail.com> Mark: Sorry for bothering you again, but I can't figure out how can I do this work. I can`t write the image to the disk because all of the images are inside a single file where they are compressed using pickle. What I'm trying to do is to get some images from this file according to a word search perform by the user of the web site. This part is already done, so the images are extracted from the file but they are in a PIL format, ie they are an Image type, and for that i cannot display them in a web page using the HTML tag because this tag only accepts a file name as input. I try to use cStringIO to emulate a file, but I don't know how I must use this variable with the HTML tag. This part of the code is something like this: from cStringIO import StringIO print "Content-type: text/html" print print "WEBIMAGE" print "" print "

    WEBIMAGE

    " print "

    Version 0.01

    " print "
    " . . . temp = StringIO() im.save(temp,"JPEG") #im is an Image variable temp.seek(0) print "

    "%temp print "

    " print "" Hope you can help me and thanks in advance Luis Roco >From: "Mark Nottingham" >To: , >Subject: Re: Using PIL with CGI scripts >Date: Wed, 9 Jun 1999 08:27:23 +1000 > >See the StringIO module (actually, cStringIO). > >One thing to keep in mind - unless the image is *really* dynamic (i.e., it >changes EVERY time someone accesses it), you're much better off if you >write >it to disk. > >See genpix.py at http://www.mnot.net/python/ for an example of this (it's >a >command line utility that HTMLifys a directory of images, but it does use >cStringIO in this manner). > >Cheers, > > >----- Original Message ----- >From: >To: >Sent: Wednesday, June 09, 1999 7:10 >Subject: Using PIL with CGI scripts > > > > Hi all > > > > How can a CGI scripts outputs graphics images through Python code using >the Python Imaging Library package? > > > > I just want to produce some images which has been processed using PIL >and >show them in a web site > > > > > ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com From bgue at my-deja.com Sat Jun 5 22:58:08 1999 From: bgue at my-deja.com (bgue at my-deja.com) Date: Sun, 06 Jun 1999 02:58:08 GMT Subject: format of event.char? Message-ID: <7jco3t$kpj$1@nnrp1.deja.com> Hi everyone. I'm wondering what the format of event.char is...how can I append it to a string? I've got a string, self.str, and a callback bound to keystrokes: def callback(self, event): self.str = self.str + event.char ...but this doesn't work. The exact error is (ommitting trace): TypeError: neither _and_ nor _rand_ defined for these operands So how does one use event.char for things other than printing? Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From rozzin at geekspace.com Wed Jun 23 22:32:43 1999 From: rozzin at geekspace.com (Joshua Rosen) Date: Wed, 23 Jun 1999 22:32:43 -0400 Subject: total idiot question: +=, .=, etc... References: <877lov62z1.fsf@pbl.ddns.org> <8L_b3.1213$4s.136166@typhoon-sf.snfc21.pbi.net> Message-ID: <377198CB.5FE62D0D@geekspace.com> Zigron wrote: > > > Among all the suggestions for Python 2.0, removing the necessity of > > prefixing methods and instance variables with "self." (and not having > > to list it as an argument, either) would be my #1 wish. > > Whyfor? I personally like the seperate scopes, beween the class > and the method. It makes it so I don't have to clean up as much. I can > use as many temporary variables as I want in a method, and as soon > as that method is gone...... its gone. The other reason is that explicitely using a self-reference for instances goes along with the method of calling unbound class-methods, and allows one to easily `fake' membership of an instance in a class. > I thought pv2 was going to > objectify eeeeverything. (I can't tell you how much I want strings > turned into objects! "blah".append('hi') should return 'blahhi'! :-)) Last I checked, everything in Python already was an object;) Strings -are- objects--they just don't belong to a class or have any properties/members/whateveryouwanttocallthem (some non-class--`top-level' I suppose they should be called--objects do have members, like lists and imaginary numbers). I rather like the var-name-subsitution that PERL and Ruby and some other languages do (ie: $something="bar"; "foo$something" == "foobar"), because it shortens code, and sometimes makes it much prettier (having stripped out all of the `end string, use an operator, reference something, resume new string' procedures); Python's %-replacement is nice, too, though a bit more lengthy. One thing to remember: languages all have their strengths and weaknesses, and -rarely- is a language best for -everything-. (back on track with the start of the thread: yeah, the shortcut operators wouldn't really work well with Pythonic `assingment'/name-binding and immutable objects). -Rozzin. From wallenborn at phys.chem.ethz.ch Tue Jun 29 09:02:40 1999 From: wallenborn at phys.chem.ethz.ch (Ernst-Udo Wallenborn) Date: 29 Jun 1999 15:02:40 +0200 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> <7l4nht$jl7$1@nnrp1.deja.com> <9DDBCC52A7B26002.649D772F7232D418.CE2709D4B08E7401@lp.airnews.net> Message-ID: To ask a completely different question: What about threads and GUI? With Tkinter you have to rewirte the mainloop like this def mainloop(self): while 1: Frame.update(self) time.sleep(0.02) if self.quitting == 1: sys.exit(0) to convince it to run with thread or threading. I remember having read a comment from Guido van Rossum, citing Jan Osterhout that Tk will never be thread-safe and that therefore this problem will not go away. Would this be any different with a different GUI kit? -- Ernst-Udo Wallenborn Laboratorium fuer Physikalische Chemie ETH Zuerich From tim_one at email.msn.com Sun Jun 27 22:26:51 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 27 Jun 1999 22:26:51 -0400 Subject: GC In Python: YAS (Yet Another Summary) In-Reply-To: <3776A025.53B35103@inrialpes.fr> Message-ID: <000001bec10d$aeca9440$e19e2299@tim> [Tim, in a thread about BDW-style conservative GC] > ... > Python could use its own malloc for its own objects (& Vladimir > Marangozov has written a very nice PyMalloc, available from his > Starship page), but that breaks down as soon as any extension has > its own view of how to get memory. [Vladimir Himself] > I can't let you say this (heh, it's too late ;-) because you seem to > overlook one of the nicest features of pymalloc. If the extension module > works in current Python + libc malloc, it will work with Python + > pymalloc because of the dynamic block management. > ... Hmm! I at least agree I didn't say what I meant . I realized PyMalloc plays peacefully with other mallocs as-is. What "breaks down" is extension to BDW-style GC, where the collector wants to perform everybody's allocations. IOW, PyMalloc pushes a Python-specific allocation scheme as far as it's ever likely to go, but that falls short of what BDW requires. You're not required to solve this. Heck, you're not even encouraged to view it as "a problem" . plenty-of-others-will-ly y'rs - tim From arielle at adams.patriot.net Tue Jun 15 10:40:47 1999 From: arielle at adams.patriot.net (A.K. Masters, Frumious Bandersnatch) Date: Tue, 15 Jun 1999 14:40:47 GMT Subject: easy filecopy? - JPython? References: <376531D3.7E42AC42@phoenix-edv.netzservice.de> Message-ID: Aahz Maruch (aahz at netcom.com) wrote: : Holger Jannsen wrote: : >For sure, I could write a thing like open-read-write-close... : Look at the shutil module. Copy, copyfile, copymode in shutil apparently haven't been implemented under jpython. Any copy ideas for jpython (Unix, of course)? Thanks! Arielle -- Arielle K. Masters: arielle at bigfoot.com; http://adams.patriot.net/~arielle/ Lucy dog: http://adams.patriot.net/~arielle/lucy/ Herndon Area Dog Coalition (HADC): http://adams.patriot.net/~arielle/hadc/ Genealogy: http://adams.patriot.net/~arielle/geneal/ From abc at def.ghi.jkl Thu Jun 10 15:00:45 1999 From: abc at def.ghi.jkl (DORAEMON.HK) Date: Fri, 11 Jun 1999 03:00:45 +0800 Subject: Serial programming Message-ID: <7jp1jt$8hg$1@imsp009a.netvigator.com> I am looking for some example in python about send and receive data from serial port. Like send "ATZ" and receive "OK". Any help?? Thanks a lot!! Doraemon From gerrit.holl at pobox.com Fri Jun 18 16:50:02 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Fri, 18 Jun 1999 22:50:02 +0200 Subject: Starting a project: any hints? In-Reply-To: <19990617154643.A1680@optiplex.palga.uucp>; from Gerrit Holl on Thu, Jun 17, 1999 at 03:46:43PM +0200 References: <19990617154643.A1680@optiplex.palga.uucp> Message-ID: <19990618225002.A23494@optiplex.palga.uucp> On Thu, Jun 17, 1999 at 03:46:43PM +0200, Gerrit Holl wrote: > Date: Thu, 17 Jun 1999 15:46:43 +0200 > From: Gerrit Holl > To: python-list at python.org > Subject: Starting a project: any hints? > [cut ask for hints] thanks for all of your hints! The project homepage is now at http://www.nl.linux.org groeten/regards, Gerrit. -- The Dutch Linuxgames website. De Nederlandse Linuxgames pagina. Site address: http://linuxgames.nl.linux.org <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Discoverb: learn words and definitions Discoverb: leer woordjes en definities Site address: http://nl.linux.org/~gerrit/discoverb <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Personal homepage: http://nl.linux.org/~gerrit/ From jwpolley at collins.rockwell.com Sun Jun 27 16:43:11 1999 From: jwpolley at collins.rockwell.com (Jonathan Polley) Date: Sun, 27 Jun 1999 15:43:11 -0500 Subject: Python 1.52/Tkinter/IDLE Problem Message-ID: <37768CDF.F8A3947F@collins.rockwell.com> I have just finished building version 1.5.2 of the python interpreter for Solaris 2.1 and have discovered a problem that I do not get with the Windows version. Let me first say that IDLE runs just fine, with one exception, and that makes me think that my build of the interpreter went correctly. When I open a module in IDLE and use the right mouse button to set a breakpoint, I get the following traceback in the "Python Shell" window: Exception in Tkinter callback Traceback (innermost last): File "../../Lib/lib-tk/Tkinter.py", line 764, in __call__ return apply(self.func, args) File "EditorWindow.py", line 217, in right_menu_event rmenu.tk_popup(event.x_root, event.y_root) File "../../Lib/lib-tk/Tkinter.py", line 1506, in tk_popup self.tk.call('tk_popup', self._w, x, y, entry) TclError: invalid command name "tk_menuSetFocus(.3314608.text.3461936)" The popup is displayed correctly but I get the above traceback when it appears. If I have the debugger running, the line that I selected is highlighted, so it looks as if the breakpoint was set properly (it behaves the same way as python for Windows). Any ideas as to what is happening???? Thanks for your assistance. Jonathan Polley jwpolley at collins.rockwell.com From donn at u.washington.edu Fri Jun 25 19:03:53 1999 From: donn at u.washington.edu (Donn Cave) Date: 25 Jun 1999 23:03:53 GMT Subject: C++ and Python References: <3772AA7D.A7855B93@anisci.com> <3773761C.1B822655@cfdrc.com> Message-ID: <7l11sp$8m6$1@nntp6.u.washington.edu> Lyle Johnson writes: | This is indeed a tricky area. I recommend you start by reading this paper, | several times: | | http://www.python.org/workshops/1995-12/papers/ahlstrom1.html | | Then to see this implemented in a real extension, take a look at WPY itself, | wxPython or FXPy (and probably others?). I'll second that. I looked at this paper to get started with an interface to BeOS API classes, which use virtual functions to give the programmer hooks into the system event dispatching, for example. Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From claird at Starbase.NeoSoft.COM Tue Jun 29 11:27:05 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 29 Jun 1999 10:27:05 -0500 Subject: Python GUIs: Summary and Conclusion References: <99FA4A1A1280BEBD.0A1ABA62CC989479.4C2C6022F695BEAC@lp.airnews.net> <377805C8.C6BBD4C1@unifix-online.com> Message-ID: <7laok9$bpi$1@Starbase.NeoSoft.COM> In article <377805C8.C6BBD4C1 at unifix-online.com>, Philippe Chassany wrote: >> .... >> More widgets should be added to Tk(Inter). >> .... > >Our company has made a 100% Tcl/Tk Toolkit named "BWidget". >BWidgets are "well known" in the Tcl community because >they are free, flexible, powerful and completly interpreted (no C). >More than 25 widgets are available. > >We have tested BWidget with Tkinter the result is quite fine : >Quick and good looking. It's a good alternative to GTk or Qt >compiled programming to have professional application GUIs. > >Try it to make your own idea (free download, screenshots, >full HTML manuals) > >http://www.unifix-online.com/BWidget . . . Philippe's right: Tcl-ers have received Unifix's BWidgets *very* warmly. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From guido at CNRI.Reston.VA.US Mon Jun 14 15:24:38 1999 From: guido at CNRI.Reston.VA.US (Guido van Rossum) Date: Mon, 14 Jun 1999 15:24:38 -0400 Subject: [meta-sig] WHY are all those sigs ending?? In-Reply-To: Your message of "Mon, 14 Jun 1999 20:47:54 +0200." <19990614204754.A26177@optiplex.palga.uucp> References: <19990614204754.A26177@optiplex.palga.uucp> Message-ID: <199906141924.PAA01494@eric.cnri.reston.va.us> > I was very happy when I saw all thos SIGs, but they are all retiring? WHY? > XML-sig, DB-sig, Doc-sig, String-sig: if it's because there isn't interest: > I'm interested! Ah, this happens twice a year. In order to be able to recycle inactive SIGs, we regularly determine a new expiration date for each SIG. Typically, the expiration date is about half a year in the future. At the expiration date, the SIG's archives are inspected. If the SIG has been comatose or dead since the expiration time was last set, it is retired; otherwise, the expiration date is moved another 6 months. Some SIGs (e.g. the META SIG, which should never be retired) have different rules. While some of the SIGs are a bit slow, none look comatose or dead at the moment, so I propose to renew all SIGs expiring this month for another half year. Any objections? --Guido van Rossum (home page: http://www.python.org/~guido/) From avv at quasar.ipa.nw.ru Mon Jun 28 15:28:05 1999 From: avv at quasar.ipa.nw.ru (Alexander V. Voinov) Date: Mon, 28 Jun 1999 12:28:05 -0700 Subject: [FYI] Future and Status of the RPM based Linux distribution References: <7kqcpl$u4l$1@news.rhein-zeitung.DE> Message-ID: <3777CCC5.B76EE975@quasar.ipa.nw.ru> Dear Oliver, Thank you for your great effort. olli at rhein-zeitung.de wrote: > - RedHat Linux 5.2 (glibc 2.0) > - RedHat Linux 6 (glibc 2.1) > - Mandrake Linux 6 (glibc 2.1 and pentium optimized) > - (maybe) SuSE 6.x (glibc 2.x) Please do not forget SuSE, if at all possible... BTW, I succeeded in installing your current RPMs under SuSE 6.1, but it required to convert manually their libreadline.a to libreadline.so (which they do not ship). Alexander From dickey at shell.clark.net Sun Jun 20 19:39:46 1999 From: dickey at shell.clark.net (T.E.Dickey) Date: Sun, 20 Jun 1999 23:39:46 GMT Subject: Problem with Curses References: <87ogidzs37.fsf@home.ivm.de> Message-ID: <6Zeb3.526$4e1.32195@iad-read.news.verio.net> Klaus Schilling wrote: > kjwolf at online.de (Klaus-Juergen Wolf) writes: >> It depends on when the executable is linked to libmytinfo, which only >> takes place on platforms that don't know the terminfo database, like >> BSD and Solaris; there are two competing declarations of tputs(). > Why doesn't Freebsd know the terminfo database? Can't the one that is > integrated into ncurses be used on FreeBSD? I've been told ncurses 4.2 is incorporated in the FreeBSD 3.1 - but that may still just be a port... -- Thomas E. Dickey dickey at clark.net http://www.clark.net/pub/dickey From anders777 at my-deja.com Wed Jun 30 12:30:04 1999 From: anders777 at my-deja.com (anders777 at my-deja.com) Date: Wed, 30 Jun 1999 16:30:04 GMT Subject: Reflection in Python? Message-ID: <7ldglr$ita$1@nnrp1.deja.com> I've just started programming in Python, and I could really use some help figuring out something. I'd like to implement Kent Beck's unit tester in Python (someone posted a very nice alternative a few weeks ago, but Junit's approach works better for my project's needs). How do I do the equivalent of what Java calls reflection? I want to do the following: test = MathTest("testAdd") where test.run() will run the "testAdd" method on the MathTest object? I also want to be able to tell the user the name of the object (MathTest) and the method in case the method fails. Any thoughts? Thanks, Anders Schneiderman National Journal Daily Briefings Group Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From C.Kotsokalis at ece.ntua.gr Fri Jun 18 19:29:51 1999 From: C.Kotsokalis at ece.ntua.gr (Constantinos A. Kotsokalis) Date: 18 Jun 1999 23:29:51 GMT Subject: Tkinter & socket question References: <19990618215411.23898.qmail@nwcst277.netaddress.usa.net> Message-ID: On Fri, 18 Jun 1999 21:54:11 GMT, Def P wrote: >2) I need to poll the connection periodically, say, every second. This would >not have been a problem in console mode... I don't know how to do this in a >Tkinter environment though. So, how can I do something every second (or every >n milliseconds, or whatever the time span may be)? Are threads the way to go? >I haven't used them before. Well you can always check for a recv() that returns a zero-length buffer. That means that the other end has closed connection. --C -- Constantinos A. Kotsokalis || C.Kotsokalis at ece.ntua.gr National Technical University of Athens - GREECE Electrical and Computer Engineering Department "Bus error -- driver executed." From markusk at bidra241.bbn.hp.com Mon Jun 28 03:58:28 1999 From: markusk at bidra241.bbn.hp.com (Markus Kohler) Date: 28 Jun 1999 09:58:28 +0200 Subject: GC In Python: YAS (Yet Another Summary) References: <930267199.139037@clint.waikato.ac.nz> <37730BAA.28A7C738@bioreason.com> <930340397.465868@clint.waikato.ac.nz> <3773EFF7.27D29899@bioreason.com> Message-ID: Andrew Dalke writes: > Stuart Yeates said to me: > > I'm not quite sure what you mean by 'integer handle,' but if you > > do a straight cast then it shouldn't be a problem (since the > > collector operates on the binaries representation). If you mean > > that it uses an index to an array of pointers (or some such), > > then that shouldn't be a problem either, since the pointer still > > exists somewhere (i.e. the array). > > The latter. Example object creation code might look like: > > dt_Handle mol = dt_smilin("CCC", 3); > > where dt_Handle is a typedef to unsigned long. In the SWIGged > wrapped version, this is mol = dt_smilin("CCC"). > > Yes, the library has a pointer table to the object. The problem > I see is, how does the Boehm collector (or other GC) know what to > collect from this vendor library? I can't see how, given that > my Python code stores it as an integer. As long as you have a pointer to the array it will not be reclaimed by the GC. The integer doesn't count as a pointer. It wouldn't count in any GC I know. The Boehm Weiser collector also has special support for interior pointers, which are pointers into an array. > > That's why I don't see how you say "It fully supports C and C++" > when this is a package which doesn't do "pointer XORing or other > crimes" but cannot be usable with a GC w/o modifications. The claim is right. Even in a cooperative environment your integer wouldn't count as a reference to an object. > > But then, I'm a computational biophysicist by training and don't > know much about GC other than the general concepts. One of the > references on the SGI page says Boehm can be used in "uncooperative > environments" so I'll end by saying that I don't know enough. > The Boehm collector is a conservative collector, which means it just scans the memory and if there's an integer that points to a valid address it wouldn't reclaim the object at this address. Your integer wouldn't probably be a valid address and therefore wouldn't be counted by the GC. Markus -- Markus Kohler mailto:markus_kohler at hp.com From doctorwes at mindspring.com Tue Jun 8 04:24:19 1999 From: doctorwes at mindspring.com (Wesley Phoa) Date: Tue, 8 Jun 1999 01:24:19 -0700 Subject: Using the Windows clipboard in Python Message-ID: <7jik35$esd$1@nntp6.atl.mindspring.net> This is a preliminary version of a module which lets you exchange data via the Windows clipboard, either as a string or as a 2D array. For example, this lets you copy and paste data between Python programs and Excel. ftp://ftp.mindspring.com/users/doctorwes/clipboard.py It uses the Win32 extensions and Sam Rushing's calldll module. There must be an easier way - I'm a Windows novice, so suggestions are very welcome. If you use this module (or calldll generally) you may notice mysterious but apparently harmless errors when exiting Python; something to do with libraries not unloading. If you know why this happens, please tell me! From Timothy.R.Evans at p98.f112.n480.z2.fidonet.org Wed Jun 30 19:10:51 1999 From: Timothy.R.Evans at p98.f112.n480.z2.fidonet.org (Timothy R Evans) Date: Thu, 01 Jul 1999 00:10:51 +0100 Subject: printing with print Message-ID: <0000159f@bossar.com.pl> From: Timothy R Evans Angus MacKay writes: > is there any other way to print that with print? > perhaps with a real function. > > I want to print two things without a space being added between them: > foo = "there" > print "hi" + foo > > works fine but: > foo = 2 > print "hi" + foo > > does not. I like the printing of any object ability of "print" so I > do not want to use "" % style printing, I just want to be able to > govern the whitespace that gets output. > > cheers, Angus. import string def print_without_space(*args): print string.join(map(str, args), '') >>> foo = 2 >>> print_without_space('foo', '2', foo) foo22 This does what you want, but wouldn't the % operator be easier? -- Tim Evans From MHammond at skippinet.com.au Wed Jun 16 18:27:46 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Thu, 17 Jun 1999 08:27:46 +1000 Subject: how to play waves? References: <19990616210844.A8571@optiplex.palga.uucp> Message-ID: <7k98ba$3o6$1@m2.c2.telstra-mm.net.au> Gerrit Holl wrote in message <19990616210844.A8571 at optiplex.palga.uucp>... >Hello all, > >is it possible to _play_ a wave file with python? So not importing a wave >module which is much to large and searching hours for the way to do it... I >just want to give the name of a file and the module plays it for me... is it >possible? What OS? If I guessed Windows, I would say "use the builtin winsound module". >The Dutch Linuxgames website. De Nederlandse Linuxgames pagina. >Everything about games on Linux. Alles over spelletjes onder Linux. But it appears I would have guessed wrong :-) Mark. From tfb at tfeb.org Wed Jun 30 09:26:00 1999 From: tfb at tfeb.org (Tim Bradshaw) Date: 30 Jun 1999 14:26:00 +0100 Subject: Why is tcl broken? References: <1283099377-77267484@hypernet.com> <375FDCA7.62FF@mailserver.hursley.ibm.com> <7josm1$bgc$1@Starbase.NeoSoft.COM> <37628EBF.207F7A8F@iname.com> <37682DD3.43923243@compaq.com> <7ka2be$qja$1@nntp6.u.washington.edu> <37776FFA.2D85@mailserver.hursley.ibm.com> <876748mcxg.fsf@home.ivm.de> <37788BB9.ABD@mailserver.hursley.ibm.com> <3779ED0F.2C67@mailserver.hursley.ibm.com> Message-ID: Paul Duffin writes: > I am surprised at this because Tcl's [upvar] is simply an explicit form > of dynamic binding which I seem to remember is what Lisp uses. (That > is how the 'let' function can be (is) implemented as a lambda function). No, (Common) Lisp doesn't use dynamic binding by default, and you don't need anything like upvar to implement LET. In fact LET is really the most common case of a lisp design pattern -- `WITH-x -> CALL-WITH-x: (let ((a b)) . body) -> ((lambda (a) . body) b) (Writing the macro for this is a little fiddly if you want to get it right in all cases, but not more than 10 minutes work.) > I find that Lisp macros (while a very powerful and necessary mechanism) > are sooo confusing. They are in essence another language inside Lisp, > and as such introduce inconsistencies. Tcl on the other hand doesn't > need a macro language and as such is much more consistent than Lisp. But the language of Lisp macros is Lisp, that's really the whole point! Without knowing TCL, I find it hard to see how you can introduce new constructs to the language *without* a macro language, even if that language is TCL. --tim From tom7654 at my-deja.com Fri Jun 18 16:03:22 1999 From: tom7654 at my-deja.com (tom7654 at my-deja.com) Date: Fri, 18 Jun 1999 20:03:22 GMT Subject: MySQL connection problem with linux Message-ID: <7ke8m2$r0p$1@nnrp1.deja.com> I am trying to use the MySQL module on pythonwin to acess a mysql database on linux zues server. I cannot establish a connection with the server, is there a a certain way i need to login, to it. If anyone has encountered this problem and knows a way around it I would apreciate it. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From tim_one at email.msn.com Sun Jun 13 14:55:27 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 13 Jun 1999 14:55:27 -0400 Subject: dict vs kjBuckets vs ??? In-Reply-To: <7k0nl5$bgu$1@brick.cswv.com> Message-ID: <000201beb5ce$4cfa11e0$ae9e2299@tim> [Tim] > Let's do a little math : 10M * 100 = ?, a lower bound on > what you're contemplating. Do you have gigabytes of RAM? [Neel Krishnaswami] > That might actually be reasonable, if you do a little more math. RAM > is going for about a dollar a meg right now, so 2 gigs of RAM will > cost around $2000. This is price-competitive with tying up a > programmer for a week or two. Alas, you still need to throw in somebody else to find and install a motherboard capable of using that much RAM, and an OS capable of exposing it -- we're bashing into the limits of 32-bit addressing here. I had the feeling the original questioner didn't have a 64-bit supercomputer just sitting around waiting to be applied . > I'm always surprised by how effective brute force and ignorance can > be. :) Oh yes, the above is temporary. When the barbarians come knocking on your door with an appetite for rape and pillage, it's rarely effective to point out that this simply isn't the way it's done in your country . the-shortest-distance-between-two-points-is-a-hammer-with-a-head- that-wide-ly y'rs - tim From Mordy.Ovits at p98.f112.n480.z2.fidonet.org Wed Jun 30 21:13:11 1999 From: Mordy.Ovits at p98.f112.n480.z2.fidonet.org (Mordy Ovits) Date: Thu, 01 Jul 1999 02:13:11 +0100 Subject: Python suitable for a game engine? Message-ID: <00001616@bossar.com.pl> From: Mordy Ovits Alan Daniels wrote: > > I'm working on a Quake-style game engine, where my goal is to give it > a fully integrated editor, similar to the excellent ones in Starcraft > and Unreal. I'm planning on doing this by giving the game and the > editor as much back-end code in common as possible. The game Extreme Warfare was a realtime 3D videogame that used Python as its scripting language for AI and game logic. Take a good look at it. Does this project of yours have a homepage I could look at? Mordy -- o Mordy Ovits o Cryptographic Engineer o LockStar Inc. --------------------------------------------------------------------------- #!/usr/local/bin/python from sys import*;from string import*;a=argv;[s,p,q]=filter(lambda x:x[:1]!= '-',a);d='-d'in a;e,n=atol(p,16),atol(q,16);l=(len(q)+1)/2;o,inb=l-d,l-1+d while s:s=stdin.read(inb);s and map(stdout.write,map(lambda i,b=pow(reduce( lambda x,y:(x<<8L)+y,map(ord,s)),e,n):chr(b>>8*i&255),range(o-1,-1,-1))) From mal at lemburg.com Fri Jun 11 09:07:47 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 11 Jun 1999 15:07:47 +0200 Subject: Help: MIME Attachments References: <7jqlc1$bk0$1@nnrp1.deja.com> Message-ID: <37610A23.6A90DB35@lemburg.com> k_mcdermott at my-deja.com wrote: > > Hi, > > I am trying to send a plain text file, as an attachment through e-mail. > > This is a hacked version of my test code below, basically the > program interprets a dump from a diary system, and then writes > Lotus Notes importable Calendar entries. I want to then mail > them to users with an accompanying instruction header to allow them > to import them into their calendars... > > The only problem is the mailing them to users bit, I either get > the plain text in the file (which I don't want, I just want them > to detach the text file and then import) or I get the Base64 encoded > text, either way there is no attachment... > > My Problem is that the MIME headers indicating Base64 encoding > appears a line after the content type, and I believe that this blank > line terminates the headers... > > So my question is, at what point should I be introducing these > headers...? > > TIA > > Kevin > > ps Python has brought a project that was originally quoted at "tens of > thousands of pounds and hundreds of man-hours" down to around 4 hours > so far, and if I can crack this, ZERO outlay :-) > > import base64 > import sys > import StringIO > import MimeWriter > from smtplib import SMTP > > # Mails the Diary Import file to the user in MIME format > # Based upon code by GVR > def mailFileToUser(_userName, _fileName): > outputfp = StringIO.StringIO() > w = MimeWriter.MimeWriter(outputfp) > w.addheader("subject", "Diary Entries from Mainframe") > w.flushheaders() > w.startmultipartbody("mixed") > subwriter = w.nextpart() > f = subwriter.startbody('application/octet-stream; > name="DiaryFile.notes"') > > >>> This is the puzzling bit... > > subwriter.addheader("Content-Transfer-Encoding", "base64") > subwriter.addheader("Content-Disposition", 'attachment; > filename="DiaryFile.notes"') > >>> Reading the source in MimeWrite.py I'd suggest moving these lines up just behind the subwrite = ... line. The .startbody() call flushes the headers for you and also terminates the headers (by inserting the blank line you already noticed). Should work then, I guess. > subwriter.flushheaders() > base64.encode(open('./DiaryFile.notes', 'r'), f) > w.lastpart() > # s = SMTP("localhost") > # s.sendmail("diary at system.com", ["my at email.address.com"], > outputfp.getvalue()) > # s.close() > print outputfp.getvalue() > if __name__=='__main__': > mailFileToUser('Kevin McDermott', 'TestFile.out') > > Sent via Deja.com http://www.deja.com/ > Share what you know. Learn what you don't. -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 203 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From ivanlan at callware.com Fri Jun 4 14:46:14 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Fri, 4 Jun 1999 18:46:14 GMT Subject: "The Python Way" References: Message-ID: <37581EF6.8E903744@callware.com> Hi All-- Robert Meegan wrote: > > On Fri, 4 Jun 1999, Graham Matthews wrote: > > > [snip] > > One problem that exists with suggestions for improvements to Python is that > different people have different ideas about what features are essential to > the language. Most people seem to agree that objects and whitespace are > core features of Python, but others have made (more or less) well-reasoned > arguments pointing out the weaknesses inherent in each of these. > [...] > The important thing is neither to quash dissent nor to debate the number of > angels that can dance on the head of an object, but to freely share ideas > in the hope of improving both Python and our own pool of knowledge. > > This learned opinion is, of course, not worth the bits it's written on. > Ah, but it is. Very nice summary of how the Python community works and gets things done, Robert. Thank you. -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From mgm at unpkhswm04.bscc.bls.com Thu Jun 24 09:49:17 1999 From: mgm at unpkhswm04.bscc.bls.com (Mitchell Morris) Date: 24 Jun 1999 13:49:17 GMT Subject: Thanks for Python... References: <376ead64@anonymous.newsfeeds.com> <37716901.43CB604@lockstar.com> <14193.16609.554364.194800@lrz.de> Message-ID: In article <14193.16609.554364.194800 at lrz.de>, Eugene Leitl wrote: [snip] > >*Is* there a Python for the PalmPilot out there? 'cause I would be >buying one if there was. I've got a Garmin 25 OEM GPS board I'd like >to put to some use... > >-- Eugene > I suspect there won't be one running native ... the memory model of the Palm is sufficiently restrictive that it may be fundamentally incompatible with the Python memory model. On the other hand, I'd love to be proven wrong. That said, you can write all the host-side components to your Palm app in Python: http://www.concentric.net/~n9mtb/cq/pyrite/pyrite.html +Mitchell -- Mitchell Morris Microsoft via the genius of Bill Gates invented the mouse-windows user interface, reliable operating systems, affordable computing, and the Internet; if you don't think all that is true, ask someone who has never used a computer and whose only exposure to the industry is through mass media. -- Philip Greenspun From aahz at netcom.com Tue Jun 22 11:44:49 1999 From: aahz at netcom.com (Aahz Maruch) Date: Tue, 22 Jun 1999 15:44:49 GMT Subject: newbie idiom question References: Message-ID: In article , Michael Hudson wrote: > >If I know I'm not going to be altering the length of the list, I >generally do it like this: > >for i in range(len(a)): > if is_cooked(a[i]): > a[i] = "cooked" And, just as a reminder for anyone reading this, this does not work for tuples (as I got forcibly reminded yesterday). -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Disciple of Uncle Chuck From rdev at my-deja.com Wed Jun 30 14:02:46 1999 From: rdev at my-deja.com (rdev at my-deja.com) Date: Wed, 30 Jun 1999 18:02:46 GMT Subject: Reflection in Python? References: <7ldglr$ita$1@nnrp1.deja.com> Message-ID: <7ldm3s$led$1@nnrp1.deja.com> In article <7ldglr$ita$1 at nnrp1.deja.com>, anders777 at my-deja.com wrote: > ...How do I do the > equivalent of what Java calls reflection? I want > to do the following: > > test = MathTest("testAdd") > > where test.run() will run the "testAdd" method on > the MathTest object? I also want to be able to > tell the user the name of the object (MathTest) > and the method in case the method fails. Any > thoughts? > If I understand what you are trying to do, it's easy in Python. Assuming MathTest is an object instance: test = MathTest.testAdd will return you a bound method object which you can then call as: test() Getting the name of the object class and method is also easy. There are several ways to do this: 1) Define a doc string within the method by putting a quoted string as the first line under the def line. You can then refer to it as "test.__doc__". This could say, for example, "Method bar of class foo". 2) "test.__name__" will return the name of the method. "test.im_class.__name__" will return the name of the class that the method is defined within. Example: class MathTest: def testAdd(self, parm1, parm2): "Method testAdd of Class MathTest" result = parm1 + parm2 return result <<< mt = MathTest() <<< test = mt.testAdd <<< test.run(2,2) 4 <<< print test.__doc__ Method testAdd of Class MathTest <<< print test.__name__ testAdd <<< print test.im_class.__name__ MathTest I hope that helps. - Roger Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From bwarsaw at cnri.reston.va.us Wed Jun 16 10:23:59 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Wed, 16 Jun 1999 10:23:59 -0400 (EDT) Subject: python-mode question References: Message-ID: <14183.45951.429301.652913@anthem.cnri.reston.va.us> >>>>> "AR" == Alex Rice writes: AR> When I run python-mode in Emacs 20, I see a second Python menu AR> that always shows me a heirarchy of my method and class names AR> in the current buffer. In XEmacs, it's not there. How do I AR> display that? Using version 3.90. Newer XEmacsen support Imenu just like FSF Emacs. With XEmacs 21 I see a menu entry called "IM-Python" which contains the methods and classes. This should all work by default, but you may need to upgrade the XEmacs you're using. -Barry From mikael at pobox.com Fri Jun 25 14:00:22 1999 From: mikael at pobox.com (Mikael Lyngvig) Date: Fri, 25 Jun 1999 18:00:22 GMT Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? Message-ID: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> Hi, Python v1.5 adopted TkInter as its standard GUI framework, even to the extent of including TkInter in the (Intel/Windows) installation package. Unfortunately, TkInter appears to run sluggish [1] on all the Intel/Windows computers I've evaluated it on (which includes several Pentium II 400+ computers). However, the wxPython GUI, available from http://alldunn.com/wxPython/, does not appear to suffer from similar performance problems, at least under Windows. As a matter of fact, it appears to be very easy to make commercial grade GUIs using wxPython. I'd like some discussion on whether or not it is a good idea to abandon TkInter, before it gets too widely used, and instead adopt wxPython as the primary GUI framework for Python. Having said this, I have to say that I'm in no way a TkInter or a wxPython expert. I've evaluated both of them and found wxPython to be the winner - and TkInter without a real chance of getting used by me. Also, can anyone comment on the features available in TkInter and wxPython - perhaps even make a feature comparison chart? [1] By sluggish I mean: You can see, or at least sense, the window update operations. Windows are not drawn instantly, but in visually detectable steps. P.S. Let's not make a war out of this; I just want to know if there's anybody else who feels wxPython is performing better than TkInter. -- Mikael From terocr at mysolution.com Sat Jun 19 00:21:00 1999 From: terocr at mysolution.com (KP) Date: Fri, 18 Jun 1999 23:21:00 -0500 Subject: simple text file 'parsing' question Message-ID: <376B1AAC.19FE8BCE@mysolution.com> Here's my dilema: a directory filled (200+) with small emails. My goal is to strip all the headers and combine them into one file. I can read all the files just fine and write them all to one file, but I cannot discern how to strip the headers. The answer must be very simple, yet I cannot see it. Can anyone give a few pointers on how to do it, our what module might be best? Thank you. Ken From greg.ewing at compaq.com Wed Jun 23 23:35:16 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Thu, 24 Jun 1999 15:35:16 +1200 Subject: Help with String Manipulation References: <5650A1190E4FD111BC7E0000F8034D26A0EE67@HUINA> Message-ID: <3771A774.E0DC1BEE@compaq.com> Or, if you'd like something a bit more creative: def gnirts(s): n = len(s) if n < 2: return s else: return gnirts(s[n/2:]) + gnirts(s[:n/2]) print gnirts("a") print gnirts("ab") print gnirts("abc") print gnirts("abcd") print gnirts("It's not dead, it's just... resting!") (Hmmm... the output from that last test case looks a bit like Klingon...) Greg From hinsen at cnrs-orleans.fr Mon Jun 28 10:09:37 1999 From: hinsen at cnrs-orleans.fr (hinsen at cnrs-orleans.fr) Date: Mon, 28 Jun 1999 14:09:37 GMT Subject: math domain error Message-ID: <7l7vmp$hmi$1@nnrp1.deja.com> SC Zhong writes: > I used the Numerical modules to find the square root of a matrix and > get the "math domain error", what is it? The matrix I have is > 1096*1096 dimension. When I tested the program with smaller problem, > it seems to work. Please advice. > > /var/tmp/chk_overlap-> Traceback (innermost last): > File ".//pop", line 412, in ? > popMatrix = LdinAnalysis(alphacoefficientsMatrix) > File ".//pop", line 345, in LdinAnalysis > M(overlapMatrix, eigvecsT))),eigvecsTInverse))) > ValueError: math domain error You don't show the code that being executed, so I'll have to guess a bit. I suppose you transform your matrix to diagonal form, take the square root of the eigenvalues, and then transform back, right? Then you can get a math domain error if any eigenvalue becomes negative. First of course you must make sure that no eigenvalue can be *really* negative (i.e. that your matrix is positive definite). But you could still get very small negative eigenvalues due to numerical errors in the calculation. If that's your problem, it is safe in most cases to set those eigenvalues to zero (e.g. with eigenvalues = Numeric.maximum(eigenvalues, 0.)). -- ----------------------------------------------------------------------------- -- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ----------------------------------------------------------------------------- -- Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From greg.ewing at compaq.com Sun Jun 20 17:22:42 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Mon, 21 Jun 1999 09:22:42 +1200 Subject: Python source code documentation? References: <7kdv0l$n0g$1@nnrp1.deja.com> <7kenc7$1od$1@m2.c2.telstra-mm.net.au> Message-ID: <376D5BA2.70D845C4@compaq.com> Mark Hammond wrote: > > Pythondoc > really doesnt want to introduce ugly mark-ups in the docstring What about non-ugly markups? Surely it's possible to design a form of markup which doesn't look ugly. Greg From gmcm at hypernet.com Mon Jun 7 09:22:49 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Mon, 7 Jun 1999 08:22:49 -0500 Subject: bug in os.path.samefile (Python 1.5.1)? In-Reply-To: <1318D78C9072D11195C9006094EA98A72C20EF@ocesrv> Message-ID: <1283360446-61563238@hypernet.com> Matej Cepl writes: /snip/ > Now, I need to check whether the processed file is in the "current" > directory or I should make steps to make recursive calling on > another directory. I guess, that the best way how to do it, is by > calling os.path.samefile(os.path.dirname(full_name),base) {see below > for context). However, Python 1.5.1 (I cannot use 1.5.2 not having > administrator's rights on WinNT 4.0 WK) complains by following > report: No, ntpath.samefile was broken in 1.5.1 and does not exist in 1.5.2. Can't compare inodes of things that don't have inodes. You don't say how the name of the "processed file" was gathered. You could get tripped up by case, forward vs backward slashes and the presence or absence of a drive letter. If it was done in a "sane" way, then os.path.normpath on both operands will probably let a string compare work properly. - Gordon From tom at spirit.gcrc.upenn.edu Tue Jun 8 11:25:04 1999 From: tom at spirit.gcrc.upenn.edu (Tom Fenn) Date: Tue, 08 Jun 1999 11:25:04 -0400 Subject: Need advice on application architecture Message-ID: <375D35D0.CA115D77@spirit.gcrc.upenn.edu> I have an application that is required to: A) run on windows NT and UNIX B) access an activeX control when running on NT I'm running into problems with the GUI interface. If I use Tkinter, I can write my GUI for both NT and UNIX no problem, but I need pythonwin to use the activeX control and Tkinter and pythonwin don't like each other. So, one possiblility is to use a different tool for writing the GUI. Does wxWindows get along with pythonwin? Any other suggestions? BTW, The activeX control doesn't provide any user interface elements. Rather, it provides access to a proprietary data file format used by a mass spectrometer we have. Access to the data files is implemented in shared libraries on the UNIX platform, so I don't have any problems there. I also tried moving the access to the activeX control into a C++ extension for python. The idea was to use MFC to create the extension, and during the initalization of the module, an invisible, modeless dialog would be created that contained the ActiveX control. Unfortunately, the call to CDialog::Create always fails. I'd guess this has something to do with missing message queues, since there's no MFC main window providing the message queue, but I don't for sure, and even if I am right, I don't know how to fix it. Anyone have any ideas on what might be causing this problem and how to fix it? Getting this working would probably be the easiest approach for me, because then I wouldn't have to learn a new GUI toolkit. Tom Fenn From johnm at magnet.com Tue Jun 29 17:51:58 1999 From: johnm at magnet.com (John Mitchell) Date: Tue, 29 Jun 1999 21:51:58 GMT Subject: BOFs (Birds-Of-a-Feather) sessions at the Monterey Python conference In-Reply-To: References: Message-ID: On Tue, 29 Jun 1999, David Ascher wrote: > As you may know, O'Reilly & Associates is organizing a Python Conference > as part of its Open Source Convention in Monterey in August. [...] > > I'd like to solicit discussion on what BOFs would be good to organize, and > find some organizers. [...] > http://conferences.oreilly.com/bof/ I'd love to see "Python and Java BOF", and maybe one on CORBA. If we could hornswaggle Jim Hugunin or Barry Warsaw to talk a bit, that would be great. Whoa -- just found Jim's JPython slides[1]. For the record, his talk at JavaOne was excellent -- thanks! Basically, Java can bite me, but it has tons of libraries, everything talks to it, and it has local fatass support. Switching to JPython sounds like a win/win, and I need to prove it. CORBA I havent messed with since Fnorb used to be unstable, I'd love to hear how it's changed. - j [1] http://www.jpython.org/jpython-talk-1.ppt From gerrit.holl at pobox.com Sun Jun 20 15:27:09 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Sun, 20 Jun 1999 21:27:09 +0200 Subject: max(s) does not what I expect it to do. In-Reply-To: <19990620202121.A22076@optiplex.palga.uucp>; from Gerrit Holl on Sun, Jun 20, 1999 at 08:21:21PM +0200 References: <19990620202121.A22076@optiplex.palga.uucp> Message-ID: <19990620212709.A16367@optiplex.palga.uucp> On Sun, Jun 20, 1999 at 08:21:21PM +0200, Gerrit Holl wrote: > Date: Sun, 20 Jun 1999 20:21:21 +0200 > From: Gerrit Holl > To: python-list at python.org > Subject: max(s) does not what I expect it to do. > > So I did the following: > > Python 1.5.2 (#1, Apr 18 1999, 00:16:12) [GCC 2.7.2.3] on linux2 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> list = [ ['a'], ['a', 'b'], ['a', 'b', 'c'] ] > >>> max(list) > ['a', 'b', 'c'] > >>> list = [ ['a', 'b', 'c'], ['a', 'b'], ['a'] ] > >>> print max(list) > ['a', 'b', 'c'] > Huh? This is right! But if I run this script: #!/usr/bin/python list = [ ['a', 'b', 'c'], ['d', 'e'], ['f'] ] print max(list) I get: ['f'] groeten, Gerrit. -- The Dutch Linuxgames homepage: http://linuxgames.nl.linux.org Personal homepage: http://www.nl.linux.org/~gerrit/ Discoverb is a python program in Dutch and English which tests the words you learned by asking it. Homepage: http://www.nl.linux.org/~gerrit/discoverb/ From peter_carl at my-deja.com Thu Jun 17 19:08:22 1999 From: peter_carl at my-deja.com (peter_carl at my-deja.com) Date: Thu, 17 Jun 1999 23:08:22 GMT Subject: Problems with CGI, genCGI and a multipart form Message-ID: <7kbv4u$1ck$1@nnrp1.deja.com> I'm having trouble getting cgi.FieldStorage to read data posted as multipart/form-data. Right now I am testing a script using stdin piped from a test file. The test file has everything after the header from a posted form, e.g.,: -----------------------------172981055621895 Content-Disposition: form-data; name="section" production -----------------------------172981055621895 Content-Disposition: form-data; name="title" This is the title etc... Environment variables for Content-type, Content-Length, and REQUEST_METHOD (POST) are set correctly. When the script is run, cgi.FieldStorage is called with stdin to populate self.formdict, but the results are always empty... A similar script that is not a multipart POST (just a standard POST) works fine, where stdin is: MessageType=Suggestion&Subject=Web+Site&SubjectOther=&Comments=&UserName =&UserEmail=&UserTel=&UserFAX= Am I missing an environment variable? Is there a trick I'm missing? I've tried including the header; not including the header; and other variations on the test input. Help! Thanks in advance, pcc Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From Robert.Meegan at wcom.com Fri Jun 4 13:56:43 1999 From: Robert.Meegan at wcom.com (Robert Meegan) Date: Fri, 4 Jun 1999 17:56:43 GMT Subject: "The Python Way" In-Reply-To: <7j8pra$55v$4@cronkite.cc.uga.edu> References: <7j8pra$55v$4@cronkite.cc.uga.edu> Message-ID: On Fri, 4 Jun 1999, Graham Matthews wrote: > > Oh thank you Fredrik for posting the above. Does anyone else consider > that the above sounds slightly paranoid? > Paranoid is a little harsh, Graham. May I suggest parochial? > Can I make a suggestion. When > someone, for example myself, makes a suggestion for adding something > to Python or changing something, or dare I say it "improving" Python, > perhaps you could consider the faint possibility that they are not > trying to "find a way to bend Python into uncomfortable positions", > but rather they are earnest Python users who happen to have some > expertise/experience in the new idea being suggested, and think that > it could not only greatly benefit Python, but also fit in rather well > with the mystical "Python way". > One problem that exists with suggestions for improvements to Python is that different people have different ideas about what features are essential to the language. Most people seem to agree that objects and whitespace are core features of Python, but others have made (more or less) well-reasoned arguments pointing out the weaknesses inherent in each of these. My opinion (which will get you a cup of coffee, if you ever meet me and profess to share it) is that I would prefer to avoid syntax changes and keyword additions. I find the following construction to be the height of clarity: while 1: [...] if x: break else: [...] and I would hate to see some of the proposed solutions become part of the language. On the other hand, I think that garbage collection would be a wonderful feature to add. (I don't like to clean up after myself.) The decision making process for what gets into Python seems to resemble a parliamentary government with a strong president. The president runs the show while the parliment debates. He can't make any major changes that are directly in conflict with the parliamentary will, but without a concerted and organized effort parliament doesn't have much say in the way things are run. The way to get significant changes incorporated into Python is to discuss them in this august forum, until a consenus emerges (preferably including a few key figures). Of course, implementing the change yourself and making it available to others helps to demonstrate the superiority of your ideas. Whether this is a good mention of defining a computer language is also debatable, but without spinning off multiple versions of Python, I can't foresee any other way. > > In short when someone posts some suggested "improvement" to Python don't > be so defensive. Open your mind to the possibility that the poster may > have a point, that they are not trying to bend Python into uncomfortable > positions, that they may know something about what they are positing > about, and may even be positing something that would be good for Python. > Unless there are saboteurs from the Perl community lurking amongst us, it's probable that every suggestion offered is intended to improve Python. With this in mind, every idea deserves a hearing. Looking at the archives shows that if an idea has any merit at all a spirited discuss will ensue. The ideas that fail to attract much attention (either pro or con) are either self-evidently crucial or much more likely not of interest to anyone but the author. To choose an (admittedly self-serving) example, the issue of garbage collection is obviously very important to a lot of people. In the last year, hardly a month has passed without a motion being brought to the floor. Perhaps what should be done at this point is for some of the more vocal and knowledgable members (hopefully not a mutually exclusive requirement) to create a garbage collection SIG. In that environment a "best choice" method could be selected and implemented as a patch against 1.5.2. Once released, people could test it and determine whether the advantages outweigh the disadvantages in the real world. Under those circumstances it might be possible to decide whether GC belongs as a core piece of Python 2.0. The important thing is neither to quash dissent nor to debate the number of angels that can dance on the head of an object, but to freely share ideas in the hope of improving both Python and our own pool of knowledge. This learned opinion is, of course, not worth the bits it's written on. --- Robert -------------------------------- Robert Meegan MCIWorldCom - Cedar Rapids, Iowa 319.375.2416 From radbit at my-deja.com Tue Jun 22 14:47:31 1999 From: radbit at my-deja.com (radbit at my-deja.com) Date: Tue, 22 Jun 1999 18:47:31 GMT Subject: Build the Python library into the binary References: <376F9518.D3252CEE@interet.com> Message-ID: <7kolnv$gp6$1@nnrp1.deja.com> In article <376F9518.D3252CEE at interet.com>, "James C. Ahlstrom" wrote: > Now that Python 1.5.2 is here I need to upgrade from > 1.5. We use Python internally and also ship Python > applications. Our environment is mixed PC's, Suns and > linux boxes. Our customers all have PC's. I always > find upgrades difficult, especially at customer sites since > we have no access, and have to depend on our Wise install > script. > > I keep thinking how much easier this would be if the > Python library were built into the binary. I mean that > on PC's, the library were part of python15.dll for example. > No more worrys about a bad PYTHONPATH, the registry, my > 1.5.2 binary using 1.5 libraries, the different ways all > this works on different platforms, etc. You just replace > python15.dll and you are at 1.5.2. Simple. > > So I wrote some code. I don't consider it finished but > it works. It makes the Python library part of the binary. > Hi did you have a look at mxCGIPython at http://starship.skyport.net/~lemburg/mxCGIPython.html ? This is a single executable not shared library with the standard Python library embedded. Cheers -- Florent Heyworth Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From nathan at islanddata.com Wed Jun 30 11:24:51 1999 From: nathan at islanddata.com (Nathan Clegg) Date: Wed, 30 Jun 1999 08:24:51 -0700 (PDT) Subject: printing with print In-Reply-To: <011a01bec2d3$c215a900$f29b12c2@secret.pythonware.com> Message-ID: > Angus MacKay wrote: >> foo = 2 >> print "hi" + foo How about: print "hi" + `foo` ---------------------------------- Nathan Clegg nathan at islanddata.com From matomira at iname.com Thu Jun 10 13:44:10 1999 From: matomira at iname.com (Fernando Mato Mira) Date: Thu, 10 Jun 1999 19:44:10 +0200 Subject: Why is tcl broken? References: <375F82C7.CF0F0477@iname.com> Message-ID: <375FF969.C879B4CD@iname.com> Lars Marius Garshol wrote: > * Fernando Mato Mira > | > | I'm trying to collect a list of all the _current_ issues making tcl > | a bad language choice. > > You can find three interesting articles on this at > > Thanks. But the Sah article is not accessible, and his homepage makes no reference to it. Regarding the Stallman article, it's a quite vague, and it's not sure one can extrapolate from their TECO experience to Tcl. About the Connoly one, the namespace issue seems to be solved by [incr Tcl]. But what about that "interpreted multiple times"? Is it just an efficiency issue, or a semantic nightmare (maybe both)? What about dynamic scoping? BTW, I just found: http://www.vanderburg.org/~glv/Tcl/war/ http://www.vanderburg.org/~glv/Tcl/war2/ From olberger at club-internet.fr Tue Jun 1 19:14:01 1999 From: olberger at club-internet.fr (Olivier Berger) Date: Tue, 01 Jun 1999 23:14:01 +0000 Subject: A tkinter kick-off References: <37544a32.0@news1.mcmail.com> Message-ID: <37546939.E9CE0264@club-internet.fr> Mark Butterworth wrote: > > I've been using python for a few months now (I've actually managed to > persuade my company that freeware is a viable tool) and I've just started > looking at tkinter. However, my first little project doesn't require an > interactive window or dialog box. What I do require is a window which > displays the result's of my background processing. The processing will > simply be the compression and network transfer of some files. I'm not > looking for a full solution however, I just need a help starting off. I can > create a window containing a listbox alright, I just need to know how to > process in the background and display results within the listbox (maybe a > cancel button would also be useful). > > Any help appreciated!?! Look at the FAQ ... it explains how registering a "callback" that can be linked to the processing of characters coming on an input to your ptogram. My suggestion is then to have a finite state machine (simple to code if you use disctionnaries, lists and eval() ...) to interprete these inputs, then rendering them as you like in the window... I'm myself writing such a tool, so this is only my actual experiments results... Maybe you can find allmost complete application frmaework elsewhere for such a "simple" tool... Olivier. -- Olivier Berger - olberger at club-internet.fr - membre de PARINUX Paris Linux User Group : http://www.parinux.org Vive Linux (www.linux.org) - Vive python (www.python.org) From tre17 at cosc.canterbury.ac.nz Mon Jun 14 18:43:25 1999 From: tre17 at cosc.canterbury.ac.nz (Timothy R Evans) Date: 15 Jun 1999 10:43:25 +1200 Subject: Problem with Lists & Index command References: <37618424.8B8F3116@mindspring.com> <37650BEB.564B2B20@mindspring.com> Message-ID: Doug Hellmann writes: > > wordcounts = {} > for word in document.words(): > try: > wordcounts[word] = wordcounts[word] + 1 > except KeyError: > wordcounts[word] = 1 Alternaively, use the `get' method on the dictionary, which will return a default value if the key is not found. In this case you want a default value of 0, so the lines become: wordcounts = {} for word in documents.words(): wordcounts[word] = wordcounts.get(word,0) + 1 Its not actually any different, just smaller. -- Tim Evans From doctorwes at mindspring.com Sat Jun 5 02:10:12 1999 From: doctorwes at mindspring.com (Wesley Phoa) Date: Fri, 4 Jun 1999 23:10:12 -0700 Subject: calldll and floats/doubles (newbie q) Message-ID: <7jaih5$gk1$1@nntp8.atl.mindspring.net> I'd like to write a small library of option pricing functions in C, and test it from Python using calldll or windll. Does anyone know how to invoke functions that take float or double arguments and return float or double results? Wesley Phoa. From thstr at serop.abb.se Wed Jun 9 10:37:42 1999 From: thstr at serop.abb.se (Thomas S. Strinnhed) Date: Wed, 09 Jun 1999 16:37:42 +0200 Subject: Python/C API and setattr References: Message-ID: <375E7C36.B323D091@serop.abb.se> Hi again Gee, you guys are so fast :-) Moshe Zadka wrote: > > Could there be something about this line; > > self->value = (int)PyInt_AsLong(v); > > (self->value is an int and v is PyObject*) > > Err......defensive programing says: check it is a Python int before > converting (there's a PyInt_Check() function somewhere -- check with > the docs). Ok, you're right about that one, but PyInt_AsLong() *does* deliver and int and the value *is* correct. > Are you sure there shouldn't be a Py_ParseTuple(..) function somewhere > too? No I'm not, but my Objects\xxobject.c inspiration doesn't use one so I thought I'd get away without one. > What exactly "doesn't fly?" (i.e., what error do you get?) >>> c.value = 23 Traceback (innermost last): File "", line 1, in ? SystemError: error return without exception set >>> c.value 23 This is the error I get and according to Gordon McMillan this is (just like you pointed out) related to the fact that C returns NULL to Python. But the value is, as you can see from the printout, just what I wanted. And I now always return a Py_None (carefully incref'd), but the error remains :-/ Many Thanks -- Thomas S. Strinnhed, thstr at serop.abb.se From fatjim at home.com Wed Jun 23 13:02:24 1999 From: fatjim at home.com (Jim Meier) Date: Wed, 23 Jun 1999 17:02:24 GMT Subject: How to obtain an instance's name at runtime? References: <7kqpu8$7u1$1@nnrp1.deja.com> Message-ID: <3771127C.E40F9BF3@home.com> "Dinu C. Gherman" wrote: > This is a nasty question, perhaps, so I appologize in > advance if its stupidity level is far above the accepted > average in this newsgroup... > > I would like to do the following: > > >>> class C: > ... pass > ... > >>> > >>> c = C() > >>> C.__class__.__name__ # ok > 'C' > >>> c.__name__ # not ok > Traceback (innermost last): > File "", line 0, in ? > AttributeError: __name__ > >>> > > Question: How to obtain an instance's name at runtime? > That is I'd like to see this happen (one was or the other): > > >>> c.__name__ > 'c' > > I've checked the reference manual, but it's silent about > this topic or I'm too blind... > > Fearing-there's-no-such-solution'ly, > > Dinu Well, there sort of is a solution, but I don't think you're going to like it. Incidentally, why are you trying to discover this? I'm not a super-meister-coder, but I can't imagine a situation where knowing this would be useful. There are some problems in the way of what you want. First of all, there is not actual name for the instance. The instance is a nameless object. It only gets a 'name' by being referenced by a variable. And that name can change. For example, c=C() d=c At this point there are two references to the instance; which one is it's 'name'? The same thing happens during function calls. For example, def func(f): print 'this is my f:' + str(f) c=C() func(c) The function gives it it's own new name. So you already have given the instance a name! But if you are just running in the interactive loop, and understand the above problems, you could try this: names=[] for i in locals().items(): if id(i[1]) == id(var): names.append(id[0]) Which should give you a list of the names of all the references to the object IN THE CURRENT SCOPE. -Jim From edcjones at erols.com Wed Jun 2 11:20:29 1999 From: edcjones at erols.com (Edward C. Jones) Date: Wed, 02 Jun 1999 11:20:29 -0400 Subject: When I run a module written in C, core dumps at Python exit. References: <37529504.669DE3D8@erols.com> <000b01beac96$1262f6a0$d89e2299@tim> <19990601220516.A608@chronis.pobox.com> Message-ID: <37554BBD.9F33B8FD@erols.com> scott cotton wrote: > On Tue, Jun 01, 1999 at 09:20:16PM -0400, Tim Peters wrote: > | [Edward C. Jones] > | > I wrote an extension module written in C. It seems to work OK. > | > But core dumps when exiting Python. When I run the code from the > | > interpreter, Python works fine until I try to exit with ^D. Then > | > there is a core dump. What are the most common causes of such > | > problems? > | > | Buggy extension modules written in C. > | > | suspecting-that's-obvious-ly y'rs - tim > > More specifically <0.314 ;>, since python core dumps on exit, > it is most likely a deallocation function that is freeing > memory that it shouldn't. Of course, that may be caused by > almost anything in the extension module. > > scott It turned out that the program was writing over the end of an array. This usually dumps core well before Python exits but this time took longer. Thanks, Ed Jones From mark at _spamspamlovelyspam_btweng.krakow.pl Sat Jun 19 05:38:03 1999 From: mark at _spamspamlovelyspam_btweng.krakow.pl (MK) Date: Sat, 19 Jun 1999 09:38:03 GMT Subject: Green or Red for stderr under IDLE? References: <7kea0m$rig$1@nnrp1.deja.com> Message-ID: <376b5fcf.7493987@news.tpnet.pl> On Fri, 18 Jun 1999 20:26:11 GMT, Sam Schulenburg wrote: >I notice that stderr for the IDLE environmnet is defaulted to green for >it's color. Is this a standard anywhere or should it be defaulted to >red? >I find that on all the releases that I have used, I have to reset its >value to red as I use this feature to print out error messages on the >status of the scripts that I run. IDLE | Help | Help: Tips: To change the font on Windows, open EditorWindow.py and change text['font'] = ("verdana", 8) to, e.g., text['font'] = ("courier new", 10) To change the Python syntax colors, edit the tagdefs table in ColorDelegator.py; to change the shell colors, edit the tagdefs table in PyShell.py. Pyshell.py: tagdefs.update({ ##"stdin": {"background": "yellow"}, "stdout": {"foreground": "blue"}, "stderr": {"foreground": "#007700"}, "console": {"foreground": "#770000"}, "ERROR": {"background": "#FF7777"}, None: {"foreground": "purple"}, # default }) MK -------------------------------------------------- Reality is something that does not disappear after you cease believing in it - VALIS, Philip K. Dick -------------------------------------------------- Delete _spamspamlovelyspam_ from address to email me postmaster at 127.0.0.1 root at 127.0.0.1 webmaster at 127.0.0.1 From gmcm at hypernet.com Thu Jun 3 11:53:41 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 3 Jun 1999 10:53:41 -0500 Subject: mailing list to news gateway In-Reply-To: <7j4asp$v4a$1@nnrp1.deja.com> Message-ID: <1283697026-41316958@hypernet.com> Jeremy writes: > I have noticed what appear to be problems with the gateway between > the mailing list (python-list at python.org) and the newsgroup -- and > more specifically with the view of the newsgroup at dejanews. > So two questions: First, has anyone else noticed problems with > messages sent to the mailing list not appearing in the newsgroup? > Trying to establish the scope of the problem. Perhaps it's just > weirdness related to my messages. Second, has anyone seen posts > from me on the newsgroup lately -- say in the Python 2.0 thread? > (I'm sure everybody keeps track of all the witty and insightful > comments I make <1.0 wink>.) I mooned everybody, too, and got no response. Hard to sustain a good flame war with just the mailies. will-moon-for-food-ly y'rs - Gordon From graham at sloth.math.uga.edu Thu Jun 3 15:06:29 1999 From: graham at sloth.math.uga.edu (Graham Matthews) Date: 3 Jun 1999 19:06:29 GMT Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <87pv3iq6ss.fsf@ev.netlab.co.jp> <3752C76D.604CD474@prescod.net> <87n1ykr0z9.fsf@ev.netlab.co.jp> <375372F6.A874554@prescod.net> <7j34l3$hbj$1@nnrp1.deja.com> <7j66b7$il5$2@cronkite.cc.uga.edu> <3756C693.2C910B29@usa.net> Message-ID: <7j6jnl$58f$3@cronkite.cc.uga.edu> Graham Matthews wrote: > You don't need a new method call -- all you need is a mark and sweep > collector with refcounts. I really am amazed that this has generated so > much traffic. It's very simple. You have ref counts just like you do > now in Python. When an objects refcount goes to 0 its __del__ method > is called. On top of this you add a mark and sweep collector to handle > circular references. During a sweep if it finds dead objects it calls > the __del__ method for that object. Salvador =?iso-8859-1?Q?Fandi=F1o?= (fandino at usa.net) wrote: : GC usually deletes objects in random order which is not a very good : behavior. I am sorry but this comment is all myth. Think about what I wrote above. Imagine Joe average Python program P. If P contains no circular references then *under the scheme I propose above* P's behaviour will be EXACTLY the same as it is in current Python (no circular refs means the mark sweep collector will never find any dead wood and hence never need to call any __del__ methods -- all the __del__ calls will be via the ref count mechanism as it is now!). The calls to the __del__ methods will happen EXACTLY as they do now. If P contains circular refs then current python will never reclaim the resources associated with these refs. *Under the scheme I propose above* these resources will be reclaimed, *when* the mark sweep collector runs. Certainly one has no control over when exactly that will be, but at least the resources will be reclaimed, unlike under the current Python where they will never be reclaimed. Why is it so hard for people to see that adding a mark sweep collector *ON TOP OF* the existing ref count scheme essentially changes nothing. All the current ref count behaviour that people love will stay. The only additional behaviour will be that circular refs are mopped up correctly. graham -- The fool escaped from paradise will look over his shoulder and cry Sit and chew on daffodils and struggle to answer why? From " HPeter.Friedrichs" at alliedsignal.com Thu Jun 24 18:16:19 1999 From: " HPeter.Friedrichs" at alliedsignal.com (H. P. Friedrichs) Date: Thu, 24 Jun 1999 15:16:19 -0700 Subject: How do can you make a variable static? Message-ID: <3772AE33.AA764DFA@alliedsignal.com> Hello: I hope somebody can help me with this problem (python newbie, < If you have several child widgets packed in a frame and you unpack the children one by one, the frame will gradually get smaller, except when the last child is unpacked, in which case the frame does not resize. Does anyone know why the frame does not shrink to 0x0 when you unpack the last child? Any soluton? Example script: ============================================================ import Tkinter root = Tkinter.Tk() root.geometry('400x400') frame = Tkinter.Frame(background = 'red') frame.pack(fill = 'x') for i in range(5): button = Tkinter.Button(frame, text = 'Unpack me') button.configure(command = button.pack_forget) button.pack() root.mainloop() ============================================================ -- Greg McFarlane: INMS Telstra Australia (gregm at iname.com) Today's forecast: Sunny, with occasional cloudy periods and a chance of precipitation in some areas. From fandino at usa.net Fri Jun 4 06:19:12 1999 From: fandino at usa.net (Salvador =?iso-8859-1?Q?Fandi=F1o?=) Date: Fri, 04 Jun 1999 12:19:12 +0200 Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <87pv3iq6ss.fsf@ev.netlab.co.jp> <3752C76D.604CD474@prescod.net> <87n1ykr0z9.fsf@ev.netlab.co.jp> <375372F6.A874554@prescod.net> <7j34l3$hbj$1@nnrp1.deja.com> <7j66b7$il5$2@cronkite.cc.uga.edu> <3756C693.2C910B29@usa.net> <7j6jnl$58f$3@cronkite.cc.uga.edu> Message-ID: <3757A820.CE3F195F@usa.net> Graham Matthews wrote: > Salvador =?iso-8859-1?Q?Fandi=F1o?= (fandino at usa.net) wrote: > : GC usually deletes objects in random order which is not a very good > : behavior. > > I am sorry but this comment is all myth. No, it's a real problem I had in my current project. You can't delete complex data structures just deleting component objects in random order. > Why is it so hard for people to see that adding a mark sweep collector > *ON TOP OF* the existing ref count scheme essentially changes nothing. > All the current ref count behaviour that people love will stay. The > only additional behaviour will be that circular refs are mopped up > correctly. I am just suggesting a way to improve the mark sweet collector you talked about. Calling the __del__ method could be the default behavior for it, but a new method hook could add better functionality... BTW, usual __del__ methods free resources like sockets, files, windows, etc. but they don't break circular references so calling __del__ will not free any object at all. -Salva. From jhouchin at texoma.net Fri Jun 18 09:24:07 1999 From: jhouchin at texoma.net (Jimmie Houchin) Date: Fri, 18 Jun 1999 13:24:07 GMT Subject: IPwP books available, 99cents Message-ID: <376a479b.131911984@news.texoma.net> Hello, I was visiting a bookstore in Plano, TX yesterday and saw two new copies of Internet Programming with Python on their shelves for $.99, yes 99 cents. The store is called 75 Off and is at Spring Creek and Avenue K. in the Garden Ridge Shopping Center. The books were in the very back of the store on their most discounted shelves. For directions to the store or other questions just email me. Jimmie Houchin From phd at emerald.netskate.ru Wed Jun 23 06:47:28 1999 From: phd at emerald.netskate.ru (Oleg Broytmann) Date: Wed, 23 Jun 1999 14:47:28 +0400 (MSD) Subject: Using C to execute Python In-Reply-To: <7kqcds$4nu$1@kopp.stud.ntnu.no> Message-ID: Hi! On Wed, 23 Jun 1999, Thomas R?berg wrote: > I have a C program and I want to call certain Python methods / functions > passing quite a few parameters. > How can I do this, in general fashion? You need to embed python interpreter into your program. That is: you link your program with libpython.a and call some functions (initilize, evel string, etc.) More details in the standard docs on Extending and Embedding Python. > I would have to include python.h, I reckon - where can I find this, I've > been searching all over for it (is it just me???) It is in the source distribution. > I'm no expert, far from, in Python... > > Thomas > email: thomar at ifi.ntnu.no Oleg. ---- Oleg Broytmann Netskate/Inter.Net.Ru phd at emerald.netskate.ru Programmers don't die, they just GOSUB without RETURN. From robin at jessikat.demon.co.uk Wed Jun 2 05:12:25 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Wed, 2 Jun 1999 10:12:25 +0100 Subject: need help checking for stack overflow in Win32 References: <5lk8to3su3.fsf@eric.cnri.reston.va.us> <7j1pcc$256$1@m2.c2.telstra-mm.net.au> Message-ID: In article <7j1pcc$256$1 at m2.c2.telstra-mm.net.au>, Mark Hammond writes >Actually, I was about to post this yesterday, and to prove my point I wrote: > >def die(): > die() > >Expecting to see the crash. I was then going to go into a rant about how >win32api.Apply would actually let you catch this (and any other Win32) >exception as a temporary solution. > >But it worked correctly - ie, Python raised a RuntimeError: Max Recursion. > ... I just tried this with my bog standard 1.5.2 under win95 osr2 and it faults to the system. Strange :) -- Robin Becker From pduffin at mailserver.hursley.ibm.com Thu Jun 10 11:17:23 1999 From: pduffin at mailserver.hursley.ibm.com (Paul Duffin) Date: Thu, 10 Jun 1999 16:17:23 +0100 Subject: Why is tcl broken? References: <375F82C7.CF0F0477@iname.com> Message-ID: <375FD703.C6D@mailserver.hursley.ibm.com> Fernando Mato Mira wrote: > > Hello, > > I'm trying to collect a list of all the _current_ issues making tcl > a bad language choice. I'd like concrete examples, and not just > vague assertions that cannot be put porward honestly. I think > that as is usual in this newsgroups, there's going to be people that > actually know what they are talking about (and even better, experienced) > > when referring to a language that is not their favorite. > If you have references to articles of the sort, that will be useful, > too. > Note that I've not listed comp.lang.tcl for increased productivity, > and to avoid starting a flame war. Hopefully some misconceptions > will be filtered down here, and _then_, the summary can be presented > in that newsgroup for their defense. > I will start by saying that your choice of title and opening statement was bad and certainly not conducive to a reasoned debate about the pros and cons of Tcl. What you are going to end up with from this sort of article is a list of outdated problems from people who have not touched it for years, plus a lot of myths and possibly mingled with a few nuggets of useful information. Whether the choice of language is a good or bad idea depends entirely on the context. i.e. environment and job to be done. You cannot avoid taking into account the context even if you only look at the language from a semantic / syntactic view point. -- Paul Duffin DT/6000 Development Email: pduffin at hursley.ibm.com IBM UK Laboratories Ltd., Hursley Park nr. Winchester Internal: 7-246880 International: +44 1962-816880 From ivanlan at callware.com Wed Jun 9 10:26:12 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Wed, 9 Jun 1999 14:26:12 GMT Subject: Looking for for some ideas for argument processing References: <7jcdhc$htd$1@nnrp1.deja.com> <375BCEA1.F5B59623@mindspring.com> Message-ID: <375E7984.85CD9E30@callware.com> Hi All-- (I've been off email for a week, just getting it back today, so forgive me for posting replies to letters that might be out of date. ...) Doug Hellmann wrote: > > cmedcoff at my-deja.com wrote: > > > > I'm writing a script with is going to make heavy use of script > > arguments. I'd like to hear some ideas on some ways to support this. > > > > One idea I've had so far is to write a class which is a dictionary > > of "directives" to function objects, where a "directive" might be '- > > c', '/f', or whatever. This seems to work well if all arguments are of > > this simple form. However I would also like to support arguments > > like "python myscript.py /a /f /x "bip" "bop", /g"; the point here > > being that "directives" may take arguments. This kind of messes up the > > simple loop you'd otherwise use to process arguments. > > > > a = BuildArgumentProcessor() > > > > # process arguments > > for x in sys.argv[1:]: > > opt = x[1:2] > > optArg = x[2:] > > a.Process(opt, optArg) > > > > This would work if somehow inside the for loop one could "increment > > this list iterator more that once" (sorry I'm coming from a C++ > > background). I don't see anyway of doing this. Is it possible? Any > > other ideas? > > Check out ftp://www.pauahtun.org/pub/getargspy.zip I think you may find it gets pretty close to what you want. Arguments provided on the command-line can be ints, strings, lists, tuples; IIRC it can do dictionaries, too. Documentation is sketchy, so you'll have to read the code & look at the docstrings, but if it can't do what you want I may have time to fix it so it will. Some of these days, in my copious free time, I will HTML-ize the documentation;-) The short version is that you make a dictionary out of the command-line args, and by the time you instantiate the dictionary describing the args, most processing has been done. I.e., if one of the args is a filename ("-f foofile"), when you access the "f" key in the dict, the value of it is the opened file. And so on. -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From holger at phoenix-edv.netzservice.de Fri Jun 25 09:38:52 1999 From: holger at phoenix-edv.netzservice.de (Holger Jannsen) Date: Fri, 25 Jun 1999 13:38:52 GMT Subject: version of python? Message-ID: <3773866C.9D29C071@phoenix-edv.netzservice.de> Hi! How could I get the version-number of the installed python-interpreter? I need this because I got an error under Python 1.51 (on my WinNT-test-machine) when running a script for linking files: def createLink(filePath, linkPath, args, descr, wrkngDir): "creates a link to a file" import pythoncom from win32com.shell import shell #get the shell interface sh = pythoncom.CoCreateInstance(shell.CLSID_ShellLink, None, pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink) #get an IPersist interface persist = sh.QueryInterface(pythoncom.IID_IPersistFile) #set the data sh.SetPath( filePath ) sh.SetDescription(descr) sh.SetWorkingDirectory(wrkngDir) sh.SetArguments(args) #save the link itself. persist.Save(linkPath, 1) File "C:\myPython\phoenix\installation.py", line 886, in ? startInstallation() File "C:\myPython\phoenix\installation.py", line 839, in startInstallation ins._runInstallation() File "C:\myPython\phoenix\installation.py", line 615, in _runInstallation self._linkFiles(anOrder) File "C:\myPython\phoenix\installation.py", line 808, in _linkFiles createLink(pFilePath, pLinkPath, pArguments , pDescription, pWrkngDir) File "C:\myPython\phoenix\installation.py", line 334, in createLink sh = pythoncom.CoCreateInstance(shell.CLSID_ShellLink, None, pythoncom.CLSCT X_INPROC_SERVER, shell.IID_IShellLink) AttributeError: CLSID_ShellLink I tested with Python 1.52 on my working-place: Everything OK! But, I wonder a little bit about that. win32com-modules havn't changed since "Sat Dec 05 19:30:34 1998" as mentioned in win32com.txt (this one I found on my harddisk...;-))) And I'm fortunaly sure that this version of 'Python 1.5 combined Win32 extensions' is the same as on the other computer. So what? How could this be? (sorry, couldn't have a look source of win32com, because it's not within the windows-version) ciao, Holger From bwarsaw at cnri.reston.va.us Tue Jun 29 20:52:46 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Tue, 29 Jun 1999 20:52:46 -0400 (EDT) Subject: A Certifiable Very Cool Trick Message-ID: <14201.27231.1003.466027@anthem.cnri.reston.va.us> Just a quick note because this is way too cool not to share. When python.org came back up today, it almost immediately got cpu slammed (and has been for at least the last 3 hours). I know what's going on -- it has to do with performance problems in Mailman that in this case was triggered by a flood of incoming messages to all the mailing lists. This Mailman problem has been seen by a few other users, but it's dang hard to track down. Guido, Jeremy, and I got to talking about what tools we'd like to have to help debug this problem. My model was gdb's attach feature where you can attach to, stop and trace through a running external C program. I would love to be able to do the same thing at the Python level. We started talking about remote pdb's with threads listening on sockets, etc. (still cool ideas but more work). I mentioned that I'd love to be able to just get a traceback of where the program is currently stopped. Even if it hoses the interpreter afterwards, it would still be incredibly useful. Guido and I spent some fun after hours hacking time and came up with the following trick. [This is described in terms of gdb, but you might be able to do something similar with dbx or other Unix and non-Unix debuggers, I dunno] First, get the pid of the running Python process. Start up gdb on the python executable and at the gdb prompt type "attach XXX" where XXX is the pid. Now, at the gdb prompt, type the following: (gdb) call PyRun_SimpleString("import sys, traceback; sys.stderr=open('/tmp/tb','w',0); traceback.print_stack()") Sitting in /tmp/tb will be the stack trace of where the Python program was when you stopped it! There's reason to believe this will not always work, and it could seriously confuse your interpreter depending on where it stops. But every time I've tried it it /does/ work, and you can even detach the program and let it continue on! Chris Tismer, somehow I think your stackless Python might either make this trick harder or much easier :) makes-this-geek-quiver-with-joy-but-my-mom-would-just-scratch-her-head-ly y'rs, -Barry From tim_one at email.msn.com Mon Jun 28 00:34:48 1999 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 28 Jun 1999 00:34:48 -0400 Subject: ANN: Stackless Python 0.2 In-Reply-To: <7l6gc8$du4$1@news.tamu.edu> Message-ID: <000c01bec11f$8dfbf800$e19e2299@tim> [Corran Webster, commenting on Christian Tismer's "stackless Python"] > ... > I wonder whether there's the potential here for more than coroutines > and to write an implementation of threading within Python. It's been mentioned a few times. So far Guido isn't keen on any of this, but he's been known to buckle after a few short years of incessant whining . BTW, a coroutine pretty much *is* a thread in a time-sliced world, just lacking a "transfer" function that invokes implicitly whenever it bloody well feels like it . > Each thread would presumably need its own Python stack, Nope! It's a beauty of the implementation already that each code object knows exactly how much "Python stack space" it needs, and (just) that much is allocated directly into the code object's runtime frame object. IOW, there isn't "a Python stack" as such, so there's nothing to change here -- the stack is implicit in the way frames link up to each other. > and a queueing and locking system would need to be added somehow, Yes, and that would require some changes to the core. Sounds doable, anyway. > but because the Python and C stacks are no longer intertangled, switching > between threads should be easy (as opposed to impossible ). I think Christian's approach moves lots of crazy ideas from impossible to plausible. > This wouldn't be quite as flexible as the current implimentations of > threads at the C level - C extensions would be called in a single block > with no way to swap threads until they return. That's mostly true today too: Python threads run serially now, one at a time, and if a thread calling out to C doesn't release the global lock no other thread will run until it returns. > On the other hand, this would allow every platform to have some sort > of threading available, which would be a boon. It's even quite possible that "fake threads" would-- for programs that aren't doing true multiprocessing --run significantly more efficiently than today's scheme of creating OS-level threads and then choking them into taking strict turns; e.g., because "the Python stack" grows only to the exact size it needs, there's almost certainly much less memory overhead that way than by letting the OS allocate a mostly unused Mb (whatever) to each real thread's stack. This opens the possibility to create thousands & thousands of fake threads. > Unfortunately I'm not familiar enough with threads to go out there and > implement it right away, but I thought I'd at least raise it as a > possibility and see what people think and what the pros and cons are. It's sure worth pondering! write-some-code-anyway-&-get-famous-one-way-or-another-ly y'rs - tim From zessin at my-deja.com Sat Jun 19 11:10:45 1999 From: zessin at my-deja.com (Uwe Zessin) Date: Sat, 19 Jun 1999 15:10:45 GMT Subject: Installing ODBC on PythonWin References: <7k4grk$b19$1@nnrp1.deja.com> <7ke9kq$3c2$1@holly.csv.warwick.ac.uk> Message-ID: <7kgbtg$sh5$1@nnrp1.deja.com> In article <7ke9kq$3c2$1 at holly.csv.warwick.ac.uk>, esuzm at primrose.csv.warwick.ac.uk (Andrew Clover) wrote: > eeghead84 at yahoo.com wrote: > > > It is written that the ODBC module is included in the pythonwin > > distribution but >>>import ODBC says otherwise. I've d/e'd > > (downloaded/executed) Win32, but it died and said that it was > > looking for version 1.4! > > If you download the latest Python and Win32 from > http://www.python.org/download/download_windows.html it should be > fine. You'll want to write "import dbi, odbc" though. > > Now for my problems. > > I've got an Access database accessed by Python scripts under CGI. > However, sometimes, calls to odbc.odbc(dsn) hang up and never return. > (Eventually the web server times out and kills the process.) This > seems to happen randomly, but increasingly. Does anyone have any > idea why? A fault with the odbc module, or Access, or what? Oh, that is interesting. I had a similar problem with the driver to a remote Navision database and was suspecting it was limited to that configuration - I do not use ODBC very much. Inserting a delay after the import seemed to "fix" my problem: import dbi, odbc import time time.sleep (3) odbc_nav = odbc.odbc (dsn_nav) -- Uwe Zessin Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From quango at watervalley.net Mon Jun 7 02:58:15 1999 From: quango at watervalley.net (Chris Lawrence) Date: Mon, 7 Jun 1999 06:58:15 GMT Subject: os.path.realpath() on POSIX Message-ID: <19990607015814.A18254@quango2.watervalley.net> This patch implements a realpath() function (cfr GNU libc) that gives the canonical location of a file on the filesystem, resolving any symlinks in the middle. For example, /usr/bin/X11/xterm is often actually /usr/X11R6/bin/xterm, even though xterm itself is not a symbolic link (the link is usually /usr/bin/X11 -> /usr/X11R6/bin or ../../X11R6/bin). This sort of thing is useful when you're trying to track down what package includes a certain file, etc. This patch also gives abspath() a docstring. [os.path.realpath() should probably act like os.path.abspath() on most non-POSIX systems.] --- /usr/lib/python1.5/posixpath.py Fri May 21 10:26:23 1999 +++ posixpath.py Mon Jun 7 01:48:16 1999 @@ -371,6 +371,28 @@ # Return an absolute path. def abspath(path): + """Return an absolute path. If the path does not start with a /, assume +it is relative to os.getcwd().""" if not isabs(path): path = join(os.getcwd(), path) return normpath(path) + +# Return a canonical path (i.e. the absolute location of a file on the +# filesystem). +def realpath(filename): + """Return the canonical path of the specified filename, eliminating any +symbolic links encountered in the path.""" + import string + filename = abspath(filename) + + bits = ['/'] + string.split(filename, '/')[1:] + for i in range(2, len(bits)+1): + component = apply(join, bits[0:i]) + if islink(component): + resolved = os.readlink(component) + (dir, file) = split(component) + resolved = normpath(join(dir, resolved)) + newpath = apply(join, [resolved] + bits[i:]) + return realpath(newpath) + + return filename Chris -- ============================================================================= | Chris Lawrence | Get your Debian 2.1 CD-ROMs | | | http://www.lordsutch.com/ | | | | | Grad Student, Pol. Sci. | Do you want your bank to snoop? | | University of Mississippi | http://www.defendyourprivacy.com/ | ============================================================================= From avv at quasar.ipa.nw.ru Fri Jun 25 19:46:07 1999 From: avv at quasar.ipa.nw.ru (Alexander V. Voinov) Date: Fri, 25 Jun 1999 16:46:07 -0700 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? References: <52B9C15E4136A939.DC364288A600C018.AB3BFEAACFF2E162@lp.airnews.net> <3773CA67.7057F797@quasar.ipa.nw.ru> <3773D55B.8C966174@spacenet.tn.cornell.edu> Message-ID: <377414BF.B40B8302@quasar.ipa.nw.ru> Tom Loredo wrote: > Well, one reason not to rush to wxWindows is that there is > no "real" Mac version. I realize that a Mac version is "underway", > but the wxWindows site has said that for a *long* time now. > A beta version was posted about a month ago, but I've not > heard much about it, and most of the wx web site doesn't > seem to know it exists (e.g., the FAQ still says the beta > is forthcoming, and the dowload section appears to still > have the old preview alpha release). I develop on both Unix > and Mac, and although the Unix part of me finds wx appealing, > the Mac side of me feels like a 2nd class citizen in the wx world. I have just visited wxWindows site, and picked up from the "News" page: May 27th, 1999 Beta 1 of wxWindows 2 for Mac has been released, thanks to Stefan Csomor's amazing efforts. Alexander From greg.ewing at compaq.com Thu Jun 17 22:00:32 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Fri, 18 Jun 1999 14:00:32 +1200 Subject: GC play References: Message-ID: <3769A840.A5AE6778@compaq.com> Darrell wrote: > > If I'm passed a reference is there a way to get its vital information like > name, filename, line number.... ? If x is an instance of a class, then sys.modules[x.__class__.__module__] will give you the module that the class was defined in; from there, __file__ gives you the file name (but not the line number, as far as I know). If f is a function, then f.func_code has attributes co_filename and co_firstlinenumber. I don't think there's anything you can find out about the source of any other kind of object. Greg From adjih at technologist.com Fri Jun 4 08:33:37 1999 From: adjih at technologist.com (adjih at technologist.com) Date: Fri, 04 Jun 1999 12:33:37 GMT Subject: Alien whitespace eating nanovirus strikes again! References: <375500C9.742DC539@pop.vet.uu.nl> <375536C2.DD917F99@prescod.net> Message-ID: <7j8h30$bhn$1@nnrp1.deja.com> In article , aahz at netcom.com (Aahz Maruch) wrote: > In article <375536C2.DD917F99 at prescod.net>, > Paul Prescod wrote: > > > >I consider it a compliment that he can't find anything real to point out > >as Python's contribution to language fascism but I also find it > >distressing that he feels the need to sow the seeds of fear, uncertainty > >and doubt in the minds of would-be Python users. The Python feature that > >most of us (in retrospect, unnecessarily) worry about before trying Python > >is the whitespace handling. Larry can only turn people off of Python by > >suggesting that that is Python's central feature or philosophy. > > I disagree with your parenthetical comment. I wouldn't call myself an > "expert" Python programmer by any stretch of the imagination, but I've > written a fair bit of it in connection with a multi-person project over > the past four months. As a seasoned programmer of many years and many > languages, I've disagreed with almost all the whines that have been > brought against Python (e.g. the stupid "=" vs. "==" thread), but this > is one point that still annoys me. > > Oh, I've gotten used to it, no question about that, and I even > appreciate the readability when it comes to working over someone else's > code (which is what I've mostly been doing). But the whitespace problem > is a real PITA when it comes time to make a change to the structure of a > program -- it's an investment I don't mind making when I'm doing "real" > programming, but when I'm making a bunch of quick, fiddly changes to > debug something it continually gets in my way. > > I'm not trying to push a change, mind you. I'm just pointing out that > IMAO the whitespace issue is a legitimate complaint. There are plenty > of real issues to be worked on, though. Well I just quickly browsed the Python source code, and Guido seems to have heard your complaint today , since block-delimiters are now supported. Actually he seems to have finally found that so necessary, that he took his usual time travel machine, and has modified the code of already released python verions. Two problems though: - 1) You need a magic sequence to enable them, see code below. - 2) The block delimiters are completly advisory, so you need a an auxiliary program to ensure proper indentation: a patch of 'examples/Tools/scripts/pindent.py' from Python-1.5.2 is included below. #--------------------------------------------------------------------------- # Magic code to trigger hooks added to the Python interpreter by Guido # in his recent time travel. Reverse engineered from interpreter # source code. enddef, endclass, endif, endfor, endwhile, endtry= \ not SyntaxError, Ellipsis is not SyntaxError, \ range is locals and compile, eval or input, \ 4/6/1999, "--Guido" #----- # Example of use def printFactor(i): initial=i factor=[] current=3 while i>1: if i%current==0: factor.append(current) i=i/current else: current=current+1 endif endwhile print "%d factors=%s" % (initial, factor) enddef for i in range(0,1000): if i%2==0: print "even=",i else: printFactor(i) endif endfor #--------------------------------------------------------------------------- Patch for pindent.py (only reformating, the patch isn't enough for the '-c(omplete)' operation, i.e. adding block delimiters). --- pindent-orig.py Fri Jun 4 16:39:17 1999 +++ pindent.py Fri Jun 4 17:06:00 1999 @@ -105,7 +105,7 @@ r'(\s+(?P[a-zA-Z_]\w*))?' r'[^\w]') self.endprog = re.compile( - r'^\s*#?\s*end\s+(?P[a-z]+)' + r'^\s*#?\s*end(?P[a-z]+)' r'(\s+(?P[a-zA-Z_]\w*))?' r'[^\w]') self.wsprog = re.compile(r'^[ \t]*') @@ -156,7 +156,9 @@ if not line: break # EOF # end if m = self.endprog.match(line) - if m: + if (m and string.find(line,"enddef, endclass")!=0 + and m.group('kw') in ['def','class','if', + 'for','while','try']): kw = 'end' kw2 = m.group('kw') if not stack: (Ok, I guess one could easily do better, and it won't help much, but I couldn't resist) -- Cedric Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From addicted at cybercable.fr Tue Jun 22 17:51:48 1999 From: addicted at cybercable.fr (BoB) Date: Tue, 22 Jun 1999 23:51:48 +0200 Subject: Tk "save as" dialog Message-ID: <7kp071$peg$1@oceanite.cybercable.fr> Hello world I m french, which explains my so bad english... sorry... here is my request : For the moment, I'm using Tk "save as" dialog box. But it's plenty of buggs, and I really can't use it any more. Is anybody here has already made in Python TKinter a save as dialog which works better than the basic Tk one. Please answer me, those buggs are really ruinning my applications... thanx in advance for your answers. Laurent From arcege at shore.net Thu Jun 24 16:29:14 1999 From: arcege at shore.net (Michael P. Reilly) Date: Thu, 24 Jun 1999 20:29:14 GMT Subject: Python & Tkinter problems... References: <7ku177$f42$1@nnrp1.deja.com> Message-ID: alltube at netscape.net wrote: : Hi there, : I am trying to run Tkinter (tcl/tk 8.1 I compiled and installed it..) : on Solaris 2.6. Python version 1.5.2. The tcl/tk seems to work : fine, I was able to run a couple of demos, the TCL_LIBRARY is also set : ok, my environment stuff: : /usr/local/lib/tcl8.1 $ls : auto.tcl http2.0 msgcat1.0 safe.tcl : encoding init.tcl opt0.4 tclAppInit.c : history.tcl ldAix package.tcl tclIndex : http1.0 ldAout.tcl parray.tcl word.tcl : /usr/local/lib/tcl8.1 $echo $TCL_LIBRARY : /usr/local/lib/tcl8.1 : /usr/local/lib/tcl8.1 $ : The error I get from Python is: : /usr/local/lib/tcl8.1 $python : Python 1.5.2 (#5, Jun 24 1999, 14:52:16) [GCC 2.8.1] on sunos5 : Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam :>>> import Tkinter :>>> Tkinter._test() : Traceback (innermost last): : File "", line 1, in ? : File "/usr/local/lib/python1.5/lib-tk/Tkinter.py", line 1947, in _test : root = Tk() : File "/usr/local/lib/python1.5/lib-tk/Tkinter.py", line 886, in : __init__ : self.tk = _tkinter.create(screenName, baseName, className) : TclError: Can't find a usable init.tcl in the following directories: : This probably means that Tcl wasn't installed properly. :>>> : The init.tcl is in fact in /usr/local/lib/tcl8.1 and it appears to be : ok, I have run a number of tk demo programs... : Thanks for any help... : Alex. : Toronto There are some incompatibilities to Tcl 8.1, which came out after Python 1.5.2. Dieter Maurer published some patches to this newsgroup about a month ago. The URL on DejaNews for that thread is: http://www.deja.com/viewthread.xp?search=thread&svcclass=dncurrent&ST=PS&group=comp.lang.python&recnum=%3cx7g14g9a37.fsf at lindm.dm%3e%231/1 -Arcege From fatjim at home.com Mon Jun 7 05:05:34 1999 From: fatjim at home.com (Jim Meier) Date: Mon, 07 Jun 1999 09:05:34 GMT Subject: CGI module misbehaving? Message-ID: <375B8BCF.C55B1F31@home.com> Hi folks! I'm making my first foray into web programming, so my question _might_ be silly; however, I've checked it out and seems to be an actual bug. At the end of this message is a python program that is supposed to handle displaying and adding players to a gadfly database. The database part is working fine. The program is there so that the bug can be demonstrated.. The problem comes at the end of the file (the start of the program) when it attempts to use the CGI module to read some form values in. A traceback is generated on the line: if form.has_key["name"]: ... the traceback is: Traceback (innermost last): File "c:\httpd\cgi-bin\ahdb\add-player.py",line 178, in ? if form.has_key["name"]: TypeError: expected integer index (formatting faked, as it was copied of the browser window) I've searched through the source for the CGI module, and it does not seem to generate this exception anywhere! Is this a problem that is know, or is there something wrong with my setup here? Platform info: Windows 98 (sigh) Python 1.5.2 from PythonWare's download section ( http://www.pythonware.com/downloads/py15-980706.exe ) omniHTTPd v2.02 -Jim code exhibiting the bug: (yes, pretty ugly I know. I take suggestions.. :) # add-player.py ::sun jun 6::Jim Meier # display forms for adding or deleting players from os import environ import cgi from gadfly import gadfly # find environment variables: if environ.has_key('AH_HOME'): ah_dir=environ['AH_HOME'] else: ah_dir="c:\\py15\\src\\ahdb" ahdb_dir=ah_dir+"\\ahdb" connection=gadfly("ahdb", ahdb_dir) curs=connection.cursor() def get_players(): curs.execute("select * from players") return curs.fetchall() def player_table_row(player,sel_col): name='
    %s' % (player[0],player[1]) email='%s' % (player[3],player[3]) print "" print " %s" % sel_col print " %s" % name print " %s" % email print " %s" % web print "" def player_table(): print '' print '' print " " print " " print " " print " " print "" for i in get_players(): sel_col='' % str(i[0]) player_table_row(i, sel_col) print "
    SelectNameE-MailHome/AH Page
    " def new_player_form(): print '
    ' print '' print '' print '' print '' print '' print '
    Name:
    E-Mail:
    Home/AH Page:
    ' print '
    ' def add_player(): # make sure all required fields are filled.. global mylog global name,email,web form_ok=1 if name is None: form_ok, reason = None, "The Name field is required. Please go back and fill it in." if name is None: form_ok, reason = None, "The E-Mail field is required. Please go back and fill it in." if not form_ok: mylog.write("form doesn't have all we need, returning '%s'\n" % reason) mylog.flush() return reason # get a unique id for him/her mylog.write("getting log id number..\n") mylog.flush() import whrandom id=whrandom.randint(0,sys.maxint) while 1: # no way in hell this'll fill up.. mylog.write("have %i, check to see if it's used..\n" % id) mylog.write("executing the select statement..\n") curs.execute("select id from players where id=%s" % str(id)) mylog.write("done execing select..\n") if len(curs.fetchall())==0: mylog.write("fetchall returned [] so we're breaking the loop..\n") break try: id=id+1 except OverflowError: id=whrandom.randint(0,sys.maxint) # add 'em up! if web is None: web="" res=curs.execute("""insert into players (id,name,email,web) values (%s,'%s','%s','%s')""" % str(id), name, email, web) if res!=1: connection.abort() return "Couldn't update the database!" connection.commit() def main(): global mylog global name,email,web form=cgi.FieldStorage() print repr(form) name,email,web=None,None,None if form.has_key["name"]: name=form['name'].value if form.has_key['email']: email=form['email'].value if form.has_key['web']: web=form['web'].value mylog=open("c:\windows\profiles\jim\desktop\log.txt","w") mylog.write("add-player.py run..\n") mylog.write("cgi arguments:\n") mylog.write("name=%s\nemail=%s\nweb=%s\n"%(name,email,web)) mylog.write("\n") mylog.write("enviroment:\n") for i in environ.keys(): mylog.write("%s: '%s'\n" % (i, environ[i])) mylog.write("\nthat's all, total.\n") if len(form.keys()) != 0: # should add player, and redirect back to list unless an error occurs. mylog.write("about to call add_player()..\n") mylog.flush() res=add_player() mylog.write("add_player() returned %s\n" % `res`) mylog.flush() if res!=None: mylog.write("res was %s so we're sending an error page..\n" % `None`) print 'content-type: text/html' print print 'Whoops!' print "

    Something's Amiss!

    " print """Either you screwed up or I did. Something happened while processing your form request that caused the operation to fail. They tell me that the reason it failed was:""" print '
    ' print '

    %s

    ' % res print '
    ' print '

    ' print 'Go Back..

    ' print '' mylog.flush() mylog.close() return mylog.write("didn't call add_player()..\n") print "content-type: text/html" print print "" player_table() new_player_form() print "" #..and have a nice day. mylog.flush() mylog.close() form=cgi.FieldStorage() print repr(form) name,email,web=None,None,None if form.has_key["name"]: name=form['name'].value if form.has_key['email']: email=form['email'].value if form.has_key['web']: web=form['web'].value main() From none at microsoft.com Thu Jun 10 00:35:19 1999 From: none at microsoft.com (plz_reply_to_group) Date: Wed, 09 Jun 1999 21:35:19 -0700 Subject: Sory I meant '/' References: <375F21B3.D23A5EA9@west.boeing.com> Message-ID: <375F4087.AC2D60AD@microsoft.com> No, no, I meant '/' -- I want to match on the _foreward_ slash "Jeff P." wrote: > > I've been messing with this for a little while now, but I can't get this > to work. How do I match the last occurence of '\' in a string? I want to > remove the file name from a url (e.g. news/breakingnews/981001b.html --> > news/breakingnews/ ). > > Here is the simplest version (that doesn't work). It matches the _first_ > backslash. > > import regex > > file_in = open( 'dir.txt', 'r+' ) > for line in file_in.readlines(): > print regex.search( '/', line ) > > Thanks for any help! > > Jeff P. From belbo_j at my-deja.com Fri Jun 25 08:14:43 1999 From: belbo_j at my-deja.com (belbo_j at my-deja.com) Date: Fri, 25 Jun 1999 12:14:43 GMT Subject: How to use Perfmon Library Message-ID: <7kvrrc$2d3$1@nnrp1.deja.com> Hello, Is it anybody that can give me some information about the usage of Perfmon library ? I want to monitor a process on a remote NT server Thanks, Jacobo Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From bhoel at server.python.net Thu Jun 24 04:00:18 1999 From: bhoel at server.python.net (Berthold =?iso-8859-1?Q?H=F6llmann?=) Date: Thu, 24 Jun 1999 10:00:18 +0200 Subject: generating valid random SMILES, water ice modelling References: <14193.17579.54805.701994@lrz.de> Message-ID: <3771E592.5730D930@starship.python.net> Eugene Leitl wrote: > > Does anybody have (preferably Python, but I'd be thankful for > anything) code to generate random but valid SMILES? Thanks a bunch. > Hello, I've ported David W. Sanderson's smiley program to Python. It also works as a package. I have'nt released it yet because it needs the original smiley definition by David W. Sanderson. I don'nt wanted to ship this file without permission of Mr. Sanderson, but havn't receved any anwer to my request. Though it is some month now since I asked, I dont't expect an answer anymore. So I change my prepared distribution to include the original C version and put it to my starship homepage with the next update. In the meantime, if you are interested, drop me a mail. Cheers Berthold -- bhoel at starship.python.net / http://starship.python.net/crew/bhoel/ It is unlawful to use this email address for unsolicited ads (USC Title 47 Sec.227). I will assess a US$500 charge for reviewing and deleting each unsolicited ad. From fredrik at pythonware.com Fri Jun 4 12:44:17 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 4 Jun 1999 16:44:17 GMT Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu><7imr6b$1s0$1@nnrp1.deja.com><7j8o26$55v$1@cronkite.cc.uga.edu> <14167.62078.226416.757006@anthem.cnri.reston.va.us> Message-ID: <011901beaea9$7da7af40$f29b12c2@pythonware.com> Barry A. Warsaw wrote: > What we need is CODE. Somebody's gotta step up to the plate and > generate some patches that people can play with. http://www.python.org/cgi-bin/todo.py?req=show&file=faq02.012.htp "Some experiments have been tried (e.g. http://starship.skyport.net/crew/gandalf/gc-ss.html and http://puli.lib.bke.hu/~xr/) but they are a bit disappointing: it ends up being slower and using more memory." M: No it doesn't. From mnot at pobox.com Mon Jun 21 22:55:24 1999 From: mnot at pobox.com (Mark Nottingham) Date: Tue, 22 Jun 1999 02:55:24 GMT Subject: htmllib: CR in CDATA Message-ID: <00d201bebc5a$adb129a0$0301a8c0@mnot.net> It appears that htmllib doesn't ignore returns in CDATA fields, as HTML 4.0 says it should: http://www.w3.org/TR/REC-html40/types.html#type-cdata http://www.w3.org/TR/REC-html40/sgml/dtd.html As a result, htmllib improperly parses any CDATA element that wraps across a line; this affects elements like I'm happy to work up a patch, but I thought I'd ask around first. It may be a bit involved to fix it properly; every CDATA should be handled this way, which practically means almost every tag attribute. Regards, Mark Nottingham, Melbourne Australia mnot at pobox.com http://www.mnot.net/ From graham at sloth.math.uga.edu Thu Jun 10 11:03:44 1999 From: graham at sloth.math.uga.edu (Graham Matthews) Date: 10 Jun 1999 15:03:44 GMT Subject: Python 2.0 References: <000801beb2e8$05e98760$af9e2299@tim> Message-ID: <7jok4g$hih$1@cronkite.cc.uga.edu> [Graham Matthews] > a) don't call finalisers for circularly referenced collected objects. > Instead just collect their memory. This is not perfect but better > than current Python which doesn't run finalisers on circularly > referenced objects nor collect their memory. Tim Peters (tim_one at email.msn.com) wrote: : Solve the problem by ignoring it? Guido would find that more attractive : than I would . Even if you do this you still end up in a better situation than current Python, since you can at least reclaim the memory of circularly reffed objects. Moreover for builtin objects (like files) you can do better and also reclaim their resources. So it is not perfect but still an improvement on current Python. [Graham Matthews] > b) better still use a two pass collector. If you don't know what that is > just think about what you need to do (or not do) in pass 1 to ensure > that all the objects needed for a __del__ method to execute in a known > environment are there. Tim Peters (tim_one at email.msn.com) wrote: : Java does this. Start the thread from its beginning again <0.5 wink>. : I am sure you can come up with something better than this Tim! graham -- As you grow up and leave the playground where you kissed your prince and found your frog Remember the jester that showed you tears the script for tears From bkc at Murkworks.com Wed Jun 9 19:17:00 1999 From: bkc at Murkworks.com (Brad Clements) Date: Wed, 9 Jun 1999 19:17:00 -0400 Subject: AFS module for python? Message-ID: <7jmskp$e6d$1@news.clarkson.edu> Anyone swig AFS routines for handling pts, kas and vos entries? Thanks.. -- Brad Clements, bkc at murkworks.com From mlauer at amalia-atm.rz.uni-frankfurt.de Sun Jun 13 19:46:54 1999 From: mlauer at amalia-atm.rz.uni-frankfurt.de (mlauer at amalia-atm.rz.uni-frankfurt.de) Date: 14 Jun 1999 00:46:54 +0100 Subject: Dumb key-binding question Message-ID: <376434de@nntp.server.uni-frankfurt.de> Pardon, but I can not get binding to work correctly. works fine, but only functions while the holding the key. This is not exactly what I was expecting... Hmm ? -- -- Regards & Gruesse from Mickey @ http://www.Vanille.de --------------------------------------------------------- How could anyone know me - when I don't even know myself ? From matz at netlab.co.jp Wed Jun 2 00:01:02 1999 From: matz at netlab.co.jp (Yukihiro Matsumoto) Date: 02 Jun 1999 13:01:02 +0900 Subject: Python 2.0 References: <7ik6mi$lbk$1@cronkite.cc.uga.edu> <7imr6b$1s0$1@nnrp1.deja.com> <87pv3iq6ss.fsf@ev.netlab.co.jp> <3752C76D.604CD474@prescod.net> <87n1ykr0z9.fsf@ev.netlab.co.jp> <375372F6.A874554@prescod.net> <87hfosquc0.fsf@ev.netlab.co.jp> <3753F121.E4A9BE8B@prescod.net> Message-ID: <87yai3ntdt.fsf@ev.netlab.co.jp> Paul Prescod writes: |> I said nothing about the destructor invocation predictability. | |I consider that a part of the definition of destructor. Well,.. is it? That's fine, anyway. Now I understand you. |> I don't understand and really interested in why you guys require |> to predict destructor invocation so much, but it's another story. | |What if I am holding GUI "device context" objects and the GUI has a |limited number of them. I don't think that there is a way to tell the GC |that there is a limited number of them. It doesn't know that device |contexts are a limited resource, just as memory is. Of cource you can tell the GC about limitaion, if you can detect outage of the resource somehow. And you can detect outage for most of the resources on the machine. e.g. fd = open(path, mode); if (fd < 0 && (errno == EMFILE || errno == ENFILE)) { call_gc(); fd = open(path, mode); } if (fd < 0) { raise("can't help it"); } Ruby uses this scheme for most of the resources like fd, sockets. So you can write something like: txt = open('blahbalh.txt','r').read() close() will be called sometime later (not immediately after), but called for sure. If not called, it's a bug in interpreter. I don't mean real GC does everything ref counting does. For exapmle, with real GC: dialog = GUItoolkit.dialog(params) ... do something with the dialog ... dialog = None will close the dialog at unpredictable timing, which is not desirable for everyone. But I prefer explicit termination of the dialog for this case. dialog = GUItoolkit.dialog(params) ... do something with the dialog ... dialog.close |What GC algorithm does Ruby use and how much overhead does it add? Ruby uses conservative mark and sweep GC. It never moves the objects. The overhead tends to depend on applications, but memory management overhead is normally less than 5% of the execution (Ruby often runs faster than Python). And as I said before, the hang is not noticable for interactive processes. |> Second, do you think that optimization for basic users compensates the |> risk of potential memory leak, by cyclic structures or missing DECREF |> in extension modules? Do you mean it's easy for experts to find |> cyclic structure and cut their reference to destruct? For me, it's |> not. I hate that. Is this because I'm not a Python expert? | |It's pretty much a toss-up for me. In general I prefer optimizations that |make the language easy for new users to those that are for complex, long |running programs but full garbage collection would make complex programs a |fair bit easier. So you think ref counting is nice for new users, maybe by its predictability. I don't think so because even new users can make cyclic references. But it's a toss-up indeed. matz. From jbauer at rubic.com Fri Jun 18 20:29:18 1999 From: jbauer at rubic.com (Jeff Bauer) Date: Sat, 19 Jun 1999 00:29:18 GMT Subject: DATE ARITHMETIC References: <7kejrv$e57$1@violet.singnet.com.sg> Message-ID: <376AE45E.596B746D@rubic.com> Ajith Prasad wrote: > I need to do some simple date arithmetic - finding the number > of days between any 2 days, the age of a person on a day given > his birthday. The mxDateTime module downloadable from the > Python website is more complex than what I need. Any other > suggestions? Here's a simple one: http://starship.python.net/crew/jbauer/normaldate/ Best regards, Jeff Bauer Rubicon, Inc. From Angus.MacKay at p98.f112.n480.z2.fidonet.org Tue Jun 29 02:00:47 1999 From: Angus.MacKay at p98.f112.n480.z2.fidonet.org (Angus MacKay) Date: Tue, 29 Jun 1999 07:00:47 +0100 Subject: printing with print Message-ID: <0000158e@bossar.com.pl> From: Angus MacKay is there any other way to print that with print? perhaps with a real function. I want to print two things without a space being added between them: foo = "there" print "hi" + foo works fine but: foo = 2 print "hi" + foo does not. I like the printing of any object ability of "print" so I do not want to use "" % style printing, I just want to be able to govern the whitespace that gets output. cheers, Angus. From hniksic at srce.hr Sat Jun 5 15:56:05 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 05 Jun 1999 21:56:05 +0200 Subject: Deleting characters from a string References: <87n1ye3g4v.fsf@pc-hrvoje.srce.hr> Message-ID: <87vhd2zaju.fsf@pc-hrvoje.srce.hr> mlh at idt.ntnu.no (Magnus L. Hetland) writes: > result = "" > for char in host: > if char not in ' "': > result = result+char > > host = result > > What!? To me that's more elegant... To me it would be if Python actually had chars. :-) From mstenber at cc.Helsinki.FI Wed Jun 23 00:23:13 1999 From: mstenber at cc.Helsinki.FI (Markus Stenberg) Date: 23 Jun 1999 07:23:13 +0300 Subject: SWIG and binary strings? Message-ID: I've swig'ed OpenSSL library for my Python needs. That was a cakewalk, until I ran at the 'char *, int'-defined strings with nulls embedded in them used in, among other things, SSL_write(). Is there any elegant way to make SWIG generate s# automatically (as opposed to s, and requiring unneccessary length parameter and much whining if string has 0's?) My (ugly) solution was following: - Define each function in wrong fashion in the .i (SSL_write as (SSL*, char *) while it should be SSL_write(SSL *, char *, int), etc) - Run SWIG - Run patch after SWIG, to do following fixes: @@ -1108,10 +1110,11 @@ int _result; SSL * _arg0; char * _arg1; + int _arg2; char * _argc0 = 0; self = self; - if(!PyArg_ParseTuple(args,?s:SSL_write",&_argc0,&_arg1)) + if(!PyArg_ParseTuple(args,?s#:SSL_write",&_argc0,&_arg1,&_arg2)) return NULL; if (_argc0) { if (SWIG_GetPtr(_argc0,(void **) &_arg0,"_SSL_p")) { @@ -1119,7 +1122,7 @@ return NULL; } } - _result = (int )SSL_write(_arg0,_arg1); + _result = (int )SSL_write(_arg0,_arg1,_arg2); _resultobj = Py_BuildValue(?",_result); return _resultobj; } .. and obviously same for other functions as well. I do not find this elegant, however, is there any other way? (Beyond writing ugly wrappers in pure Python-C, and I am too lazy to maintain those ;->) - Academically-curious-ly, Markus -- Markus Stenberg Finger fingon at mpoli.fi for PGP key -- PGP key id: 1024/5DAC7D21 From dkuhlman at netcom.com Tue Jun 22 20:27:58 1999 From: dkuhlman at netcom.com (G. David Kuhlman) Date: Wed, 23 Jun 1999 00:27:58 GMT Subject: Help with String Manipulation References: <0UUb3.1337$el4.44932@ord-read.news.verio.net> Message-ID: >>> import array >>> a = 'abcdef' >>> a 'abcdef' >>> b = array.array('c', a) >>> b array('c', 'abcdef') >>> b.reverse() >>> b array('c', 'fedcba') >>> c = b.tostring() >>> c 'fedcba' >>> See the Python Library Reference, Sect. 5.6 "array -- Efficient arrays of numeric values" - Dave Samuel G. Williams (samw at masu.wwa.com) wrote: > I know this is a very stupid question and one that has been addressed > within available documentation, however I need a quick hand. I am in need > of a routine to reverse the order of a string. I have tried several things > that have resulted in failures. It is really stupid, but I am just > learning python. I can do this readily in C, perl, tcl, but am at a loss. > I would appreciate any help I can get. > > Thanks in advance. > > -- > > From matz at netlab.co.jp Wed Jun 9 02:14:58 1999 From: matz at netlab.co.jp (Yukihiro Matsumoto) Date: 09 Jun 1999 15:14:58 +0900 Subject: fork() References: <000001beb23b$9f17bc20$a69e2299@tim> Message-ID: <877lpd528t.fsf@ev.netlab.co.jp> "Tim Peters" writes: |Context: this offshoot of the thread was talking about memory use after a |fork() call in a copy-on-write implementation of fork. So long as |bookkeeping info is stored in object headers, "real GC" is at a real |disadvantage, in that respect, compared to RC. Simply because RC won't |touch something unless *you* do. Indeed. Though some "real GC" keeps mark bits in separated pages to avoid copying bunch of pages in such situation. BTW, ref counting modifies objects for mere referencing, it causes copying too. Also, it would be performance pain if Python's global thread lock is removed someday, since ref counting requires mutual lock to protect ref count update. I'm not sure this problem can be solved or not. matz. From brainwav at hotmail.com Sun Jun 13 17:35:54 1999 From: brainwav at hotmail.com (Denis Lamarche) Date: Sun, 13 Jun 1999 21:35:54 GMT Subject: Python Newbie Message-ID: <37644D2B.CC7D0BB3@hotmail.com> Where can I find "Python.h"? I am using dos. I cant find it anywhere. Denis Lamarche From akuchlin at mems-exchange.org Mon Jun 21 09:15:09 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 21 Jun 1999 09:15:09 -0400 Subject: BiBTeX module? References: <7k950a$hsb@cs.vu.nl> Message-ID: <3dg13litk2.fsf@amarok.cnri.reston.va.us> I'm surprised Greg Ward hasn't jumped into this thread yet, but take a look at his tech report on his BibTeX parser btOOL, particularly the first 3 sections, which contain an interesting examination of BibTeX's design. Later sections dive into the Perl code and are less interesting, but the C code for the parser could probably be wrapped as a Python module without too much difficulty. btOOL's page is at http://starship.python.net/~gward/btOOL/ ; the tech report is btOOL.ps.gz or btOOl.dvi.gz. -- A.M. Kuchling http://starship.python.net/crew/amk/ Brigadier, a straight line may be the shortest distance between two points, but it is by no means the most interesting. -- The Doctor, in "The Time Monster" From mnot at pobox.com Mon Jun 14 23:44:51 1999 From: mnot at pobox.com (Mark Nottingham) Date: Tue, 15 Jun 1999 03:44:51 GMT Subject: Looking for modules? Config files? Ini files? in python.. References: <1282710643-100650854@hypernet.com> Message-ID: <00ac01beb6e1$6c541860$0301a8c0@cbd.net.au> Another possibility is at http://www.mnot.net/python/Conf.py Each has its ups and downs - this one doesn't do sections. ----- Original Message ----- From: Gordon McMillan Newsgroups: comp.lang.python To: Sent: Tuesday, June 15, 1999 11:53 Subject: Re: Looking for modules? Config files? Ini files? in python.. > Benjamin Schollnick writes: > > > > I'm trying to find a simple method to deal with *.INI or other > > styles > > of > > configuration files.... > > > > I haven't seen anything, and would hate to re-invent the wheel.... > > > > Any suggestions? > > How 'bout ConfigParser.py? It's in the standard distribution. > > - Gordon > > > > From smjoshi at bellsouth.net Sun Jun 27 22:47:55 1999 From: smjoshi at bellsouth.net (SunitJoshi) Date: Sun, 27 Jun 1999 21:47:55 -0500 Subject: Using freeze Message-ID: Hello I'm trying to make exe's from python scripts using VC6++. However I'm lost as to how to use freeze to accomplish this. If someone could include some details I would really appreciate it. thanks Sunit From vbykovsk at sdsp.mc.xerox.com Fri Jun 25 10:44:11 1999 From: vbykovsk at sdsp.mc.xerox.com (Val Bykoski) Date: Fri, 25 Jun 1999 10:44:11 -0400 Subject: [ANN] DejaGrabber 0.1 -- search Dejanews with Python References: <7kuu73$1ki$1@brick.cswv.com> Message-ID: <7l0520$qe4$1@news.wrc.xerox.com> Neel: This looks really great.. But I have this: Traceback (innermost last): File "", line 1, in ? File "C:\Program Files\Py152\Lib\httplib.py", line 51, in __init__ if host: self.connect(host, port) File "C:\Program Files\Py152\Lib\httplib.py", line 79, in connect self.sock.connect(host, port) File "", line 1, in connect error: (10065, 'winsock error') when i am trying to reach www.python.org thru a proxy (www.mc.xerox.com). How to handle this proxy-related situation? Thanx -- val Neel Krishnaswami wrote in message news:7kuu73$1ki$1 at brick.cswv.com... > > If you'd like a convenient way of searching the DejaNews archive using > Python, I'm happy to present the DejaGrabber module. This is a module > to make searching Dejanews easier. There are two classes, DejaGrabber > and Article. I've tried to add a reasonable number of useful > docstrings, too. > > The interface to DejaGrabber could probably use a bit of work. If I > ever use it enough to find out what the flaws are, I will fix > it. Patches are welcome. :) > > Here's an example: > >>> from DejaGrabber import * > >>> d = DejaGrabber(group='comp.lang.python', author='Tim Peters') > >>> l = d.get_messages(4) > >>> print l > [99/06/23 30 comp.lang.python RE: Python Exes! Tim Peters > , 99/06/18 28 comp.lang.python RE: Newbie: Truth values (th Tim Peters > , 99/06/18 28 comp.lang.python RE: DATE ARITHMETIC Tim Peters > , 99/06/18 28 comp.lang.python RE: NameError Problem Tim Peters > , 99/05/18 25 comp.lang.python RE: while (a=b()) ... Tim Peters > ] > > You can grab a copy at > > http://www.sff.net/people/neelk/free-software/DejaGrabber.py > > > Neel From arcege at shore.net Thu Jun 24 11:40:06 1999 From: arcege at shore.net (Michael P. Reilly) Date: Thu, 24 Jun 1999 15:40:06 GMT Subject: Tkinter: radiobutton References: <3771B52E.80F3FA46@pixar.com> Message-ID: kiki wrote: : Newbie speaks: I'm sure there's an elegant solution to this, but I just : can't find it, and my head hurts from reading man pages... : I have a color menu that has "Add Color" and "Change Color", and an : appended list of user-created colors as radiobuttons. : What I would like to do is when the user chooses "Change Color", the new : color overwrites the current color selected in the radiobutton list. : The problem is I don't know how to find out which button is selected. : self.color_menu.entryconfig("active"...) configures the "Change Color" : button!! Arg! The index is otherwise implicit... : A group of radiobuttons are associated by the fact that they share a : variable. When that variable changes, the states of the radio buttons : change. Certainly there must be a way to find out the index of the : selected radiobutton in a group of radiobuttons and modify the contents : [eg "value", "activebackground", etc.] of it... : Thanx, and sorry if this was an obvious question. : Kiki No, it's not an obvious question at all. Unfortunately, you need to track the index when you create the menu. By default, the first call starts at 1, because the "tear-off" is 0. If the menu is created with the -tearoff=0 option, then the index starts at 0 This example creates a menu where the first item is a button (which when pressed doesn't do anything) used as a Label to hold the current color, the other items (radiobuttons) after it change the label. menu = Menu(menubutton) def change_red(m=menu): m.entryconfig(1, label='Color: red') menubutton['menu'] = menu # the first is effectively a "Label" menu.add_command(label='Color: ') # index 1 menu.add_radiobutton(label='Change red', command=change_red) # index 2 Maybe it's time I give those menu entry classes to Guido (that does this for you as class instances). -Arcege From pphalen at teleo.net Thu Jun 3 16:17:01 1999 From: pphalen at teleo.net (Patrick Phalen) Date: Thu, 3 Jun 1999 13:17:01 -0700 Subject: "The Python Way" References: <045501beadf8$610e62e0$f29b12c2@pythonware.com> Message-ID: <9906031407150D.00552@quadra.teleo.net> On Thu, 03 Jun 1999, Fredrik Lundh wrote: > sure looks like the "community" thinks that changing the > language is more important than using it... Yeah; now that you mention it, the "let's fix Python" discourse has been approaching my pain threshold, as it does once in awhile. (Have you noticed that, during such periods, both Guido and Tim seem to become singularly quiet?) Not that Python shouldn't be open to critique, but the more I use and learn about the language, the more I find myself appreciating the nice balance and heft Guido gave to it. Yet there doesn't seem to be a single document that sums up that "aesthetic," but rather it tends to appear piecemeal, over time, mostly in the Wisdom of Chairman Tim. I'd like to suggest something as a sort of balm for those of us who come here to try to learn to work with, rather than against, the grain of Python: Would both Guido and TIm Peters be willing to collaborate on a short paper -- call it "The Python Way" for lack of a better title -- which sets out the 10-20 prescriptives they might offer to those who come to Python from other languages and immediately want to find a way to bend it into uncomfortable positions -- (implement closures, etc.). What I have in mind is sort of a very brief Strunk-&-White-like "Elements of Style" for Python, which suggests fundamental idiomatic recommendations for operating within the spirit of the language. A distillation of Python Zen is what I'm talking about -- something to go off and contemplate when the "fix Python now" decibels become a bit much. Tim? Guido? From druid at princeton.crosswinds.net Thu Jun 3 20:43:18 1999 From: druid at princeton.crosswinds.net (The Well of Latis) Date: Fri, 04 Jun 1999 00:43:18 GMT Subject: newbie trouble with raw_input and idle Message-ID: <37581eb4.2704370@netnews.worldnet.att.net> If I enter the following code (or any other using raw_input for that matter) into idle's shell it works, when trying to run it from a file (new window, edit it, save it then run it, nada) def f(): x=raw_input("ladida:") print x f() systems involved are a win98 and an nt4 machines, tcl version 8.0.5, Python 1.5.2. The same code works under the plain Python interactive shell, and pythonwin, but not idle. Any ideas? -------------------------- Bull Run ACD Rescue Several low mileage cow dogs available, visit the "barking lot" at http://www.crosswinds.net/~bullrun/rescue.html From Nikolai.Kirsebom at p98.f112.n480.z2.fidonet.org Tue Jun 29 18:15:42 1999 From: Nikolai.Kirsebom at p98.f112.n480.z2.fidonet.org (Nikolai Kirsebom) Date: Tue, 29 Jun 1999 23:15:42 +0100 Subject: Python, ASP - Namespace (again) Message-ID: <00001584@bossar.com.pl> From: "Nikolai Kirsebom" Trying again - since I'm rather stuck, and I would like to stick to Python. I'm trying to use Python as scripting language on the web-server, however - have problems to see how the namespace scope is handled. FILE - GenDb.py ============= class GenDb: def __init__(self): self.ConnStr = "" def SetDbAndTable(self, db, table): self.Db = db self.Table = table self.ConnStr = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=f:\\Databases\\%s" % db def Attr(self, attrName): if attrName == "abc": return(self.ConnStr) else: return("-non-") FILE - KSdebatt.py =============== from GenDb import * class KSdebatt(GenDb): def __init__(self): self.SetDbAndTable("KSdebatt.mdb", "BillMrk") FILE - SCRIPT1.ASP ================= <%@ LANGUAGE = Python %> <% import sys sys.path.append("f:\\PythonScripts") from KSdebatt import * o=KSdebatt() %> " SIZE=20> when I run the statements in the script1.asp file in an interactive window, I can create the KSdebatt object, however when I run the script on the server - I get the following message: Python ActiveX Scripting Engine error '80020009' Traceback (innermost last): File "