From tim_one at email.msn.com Wed Jul 28 22:27:57 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 28 Jul 1999 22:27:57 -0400 Subject: 1.5.2 for: else: In-Reply-To: <379F6E37.777322BF@compaq.com> Message-ID: <000d01bed969$f89ec220$71a22299@tim> [/F, on the sparkling consistency of for/else, while/else, if/else] > what else did you expect from Guido? [Greg Ewing] > I would have expected Guido to shriek in horror > and refuse to even consider such a semantically > ambiguous construct. > > It seems quite out of character for both him > and Python. Indeed, if for/else hadn't been in Python from the start, anyone suggesting it would get flamed without mercy! I happen to like it, but it's Guido-like only in its inscrutablitily at first sight . The only Pythonism less Pythonic is that e.g. 4 < "3" silently returns true. although-that-would-be-even-less-pythonic-if-it-returned-false-ly y'rs - tim From loredo at spacenet.tn.cornell.edu Fri Jul 2 16:17:40 1999 From: loredo at spacenet.tn.cornell.edu (Tom Loredo) Date: Fri, 02 Jul 1999 16:17:40 -0400 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> <7li9t6$j2k$1@srv38.cas.org> Message-ID: <377D1E64.C0DC11D0@spacenet.tn.cornell.edu> lvirden at cas.org wrote: > > According to Vadim Zeitlin : > : > : 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 > > I wonder why various industry rags have proclaimed during the past > 10 months about Apple's G3 machines outselling other vendor > machines. ... Make me a third. About a million iMacs have been sold in less than a year, and although the Mac market share is only around 10% right now (that's a huge number of Macs, by the way!), the fraction of all personal computers *in use* that are Macs is actually about 20%. It is simply way off the mark to believe that Macs are not very common nowadays. I spend most of my time at a Unix box, and work on all three major platforms regularly (Unix, Mac, Win32), so please don't dismiss this as just another Mac-only user mouthing off. It's a great platform, and I simply wouldn't want to see python GUI development ignoring it. -Tom Loredo From Andrew.Cooke at p98.f112.n480.z2.fidonet.org Thu Jul 1 08:16:00 1999 From: Andrew.Cooke at p98.f112.n480.z2.fidonet.org (Andrew Cooke) Date: Thu, 01 Jul 1999 13:16:00 +0100 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? Message-ID: <0000160b@bossar.com.pl> From: Andrew Cooke In article <64F6457BE0585BB3.1CF2F67BC8A680BD.A19A9FEE23BC9E58 at lp.airnews.net>, mikael at pobox.com (Mikael Lyngvig) wrote: > 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. I'm confused. I'm sitting at a moderate NT box (266MHz, 96Mb) - my work machine, and running the Tk demos. There is no problem at all - they are instantaneous. Is this problem to do with memory? Or is it a W95 thing? If so, is it due to thread scheduling? Andrew Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From htrd90 at zepler.org Fri Jul 9 17:22:25 1999 From: htrd90 at zepler.org (Toby Dickenson) Date: Fri, 09 Jul 1999 21:22:25 GMT Subject: win32 python as a dll? References: <1280583297-81012085@hypernet.com> <37863B4F.FB1780F3@enews.nrl.navy.mil> Message-ID: <3787648e.2225295@news.freeserve.net> Scott Wolford wrote: >I guess I didn't pose my question properly. Under Unix, can you not link with a >debug foo.so at link-time, then at run-time load an optimized version, as long >as the code used to generate the two is roughly the same? It seems to work for >me. Why can't you do the same thing under Windows? msvcrt.dll and msvcrtd.dll are not even roughly the same. There are differences in the data structures behind malloc, fopen, etc. They are given different names to prevent them getting mixed up. If optimisation level was the only difference then you would not need separate .lib files. Toby Dickenson From catlee at my-deja.com Tue Jul 6 15:47:13 1999 From: catlee at my-deja.com (catlee at my-deja.com) Date: Tue, 06 Jul 1999 19:47:13 GMT Subject: Getting contents of Text / Entry widgets Message-ID: <7ltmfu$nbt$1@nnrp1.deja.com> Hi, I'm writing a little utility that uses a Tkinter Text widget (and an Entry widget). I want to perform an action for every key that is entered. So I do something like: def callback(event): print event.widget.get() widget=Entry() widget.bind("",callback) The problem with this is that the output generated by callback is always one character behind. I assume this is because when the event is generated, the character you've typed hasn't been entered into the buffer yet. I could modify callback to look something like: def callback(event): print event.widget.get() + event.char But this doesn't handle backspace and delete characters well. Is there a nice way of retrieving the contents of a Text / Entry widget every time the widget's text buffer is changed (as opposed to whenever a key is pressed)? Thanks, Chris Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From emile at fenx.com Mon Jul 26 10:04:04 1999 From: emile at fenx.com (Emile van Sebille) Date: Mon, 26 Jul 1999 07:04:04 -0700 Subject: How to use a variable form main script in a module. References: <7nhmt5$su0@enews3.newsguy.com> Message-ID: Hi Peter, You need to fully specify the module variable name in your main program. For example, if an imported module defines x as an unbound (quasi)class variable: >>> x = 3 >>> import testx >>> x 3 >>> testx.x 15 HTH -- Emile van Sebille emile at fenx.com ------------------- Peter Torstenson wrote in message news:7nhmt5$su0 at enews3.newsguy.com... > This is probaly a silly question from a newbie. > In my main script I put a value for to a variable called "x". > Now I want to use the "x" variable in a module. > The module is imported into the main script. How to do this? > > I've been trying to find out how to do it in tutorials an the reference > manual but I can?t find anyting written about this. Perhaps because it's a > to silly question. > > /Peter Torstenson > > Rio de Janeiro > > From C.Kotsokalis at ece.ntua.gr Tue Jul 13 17:49:07 1999 From: C.Kotsokalis at ece.ntua.gr (Constantinos A. Kotsokalis) Date: 13 Jul 1999 21:49:07 GMT Subject: problem with SocketServer -- address already in use References: <931899928snz@vision25.demon.co.uk> Message-ID: On Tue, 13 Jul 99 21:05:28 GMT, Phil Hunt wrote: >I'm trying to use SocketServer.py to write a TCP server. I ran >my program with ``python serv.py'', which went into an infinite >loop (which is what it should do). I exited my program with ^Z, _____________________________________________________________^^ >and tried to start it up again. I got an error message: > >socket.error: (98, 'Address already in use') ctrl-Z suspends your server, so the port is still occupied. Use ctrl-C to interrupt it and wait, or use setsockopt as Gordon suggests and ctrl-C. In any case, you can't use that port again with a suspened server. --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 billtut at microsoft.com Thu Jul 22 21:46:04 1999 From: billtut at microsoft.com (Bill Tutt) Date: Fri, 23 Jul 1999 01:46:04 GMT Subject: Non-ODBC MS Sql Connect Message-ID: <4D0A23B3F74DD111ACCD00805F31D8100DB90F98@RED-MSG-50> You can always use ADO from Python on NT. Quick example: import win32com.client import win32com.client.makepy import win32com.client.genpy import win32com.client.gencache adolib = win32com.client.gencache.EnsureModule( '{00000200-0000-0010-8000-00AA006D2EA4}', # TypeLib GUID for ADO win32con.LANG_NEUTRAL, # LCID 2, # Major version # 0, # Minor version # win32com.client.genpy.GeneratorProgress()) # Silent progress indicator. # ALL loaded typelibrary constants... k = win32com.client.constants cxnSQLServer = adolib.Connection() cxnSQLServer.CursorLocation = k.adUseNone cxnSQLServer.Provider = "SQLOLEDB" cxnSQLServer.Open("Server=MachineName;Database=master;UID=user;PWD=apple") rs = adolib.Recordset() rs.Open("select * from sysobjects", cxnSQLServer, k.adOpenForwardOnly, k.adLockReadOnly) # etc..... Bill > -----Original Message----- > From: Roberts, Robert J [mailto:robert_j_roberts at rl.gov] > Sent: Thursday, July 22, 1999 5:33 PM > To: python-list at cwi.nl > Subject: Non-ODBC MS Sql Connect > > > How to do I make a non-odbc connection to a MS SQL Server? > > Am running Python Windows NT/IIS. > > Thanks, > > From fdrake at cnri.reston.va.us Wed Jul 28 12:12:42 1999 From: fdrake at cnri.reston.va.us (Fred L. Drake) Date: Wed, 28 Jul 1999 16:12:42 GMT Subject: API question -- decref after adding to dictionary? In-Reply-To: References: <379EBC8B.E36F020B@lemburg.com> Message-ID: <14239.11258.615882.396388@weyr.cnri.reston.va.us> Rich Salz writes: > The API documentation doesn't seem to say what the functions do to > object references. Am I missing it, or do I really have to read the Rich, This is a matter of completeness; the API docs just aren't "there" yet in this regard, and the time to devote to adding the information hasn't been available. In the meanwhile, I'd certainly be glad to receive patches which added the information to the API reference. I do hope that this isn't a deciding factor as to whether you use Python. The discussions of reference counting in the API and Extending & Embedding manuals do try to explain the approaches taken in Python and reduce the pain significantly. I've written a number of C extensions myself, including one very early in my experience with Python, and haven't had a lot of difficulty with it. (Note: I did *not* say I haven't had any difficulties!) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From pepper at xcs.tut.fi Tue Jul 27 08:27:00 1999 From: pepper at xcs.tut.fi (Petteri) Date: Tue, 27 Jul 1999 12:27:00 +0000 Subject: upload file with cgi References: <7mro7g$kr5@newsops.execpc.com> <40kk3.351$ui4.121238@news.shore.net> Message-ID: <379DA594.BB2FD011@xcs.tut.fi> Hi, This must be a FAQ question, but I'm wondering where the file disappears from FieldStorage? My own cgi-upload script used to work but now what happens is that the FieldStorage is empty. Is this just some silly mistake or does it have something to do with netscape?

Upload a file!

An excerpt from the script: form = cgi.FieldStorage() print form sys.stdout.flush() fileitem = form['userfile'] if fileitem.file and form.has_key('dest'): Upload(fileitem, form['dest'].value) and what 'print form' prints if I send the form with a file selected: FieldStorage(None, None, []) and, of course, an exception is raised Traceback (innermost last): File "/usr/lib/cgi-bin/upload.py", line 53, in Main fileitem = form['userfile'] File"/usr/lib/python1.5/cgi.py", line 907, in __getitem__ raise KeyError, key KeyError: userfile I'm confused. Please help. Sami From billtut at microsoft.com Wed Jul 21 10:36:23 1999 From: billtut at microsoft.com (Bill Tutt) Date: Wed, 21 Jul 1999 14:36:23 GMT Subject: VC++ 6.0 larger exe files explained Message-ID: <4D0A23B3F74DD111ACCD00805F31D8100DB90F88@RED-MSG-50> > From: Gordon McMillan [mailto:gmcm at hypernet.com] > > > Robin Becker wrote: > > > > As part of the Wintel push to take over the world it seems as though > > VC++ 6.0 will now only generate files with sections 0x1000 (4k) or > > longer. Under 5.0 and before the linker would allow much smaller exe > > file sections. So python.exe which used to be 5k becomes 20k. > > Needless to say this should also apply to dll's etc and appears to > > offer no obvious advantage. Bill has never been other than cavalier > > with our space time resources. > > Ay yi yi. The whole PE header is full of convolutions so the loader > can take a packed disk image and align the sections on the fly. > > I guess this "feature" designed to "optimize" load time. Or maybe MS > has been investing in drive manufacturers... > I believe this is indeed the case. (optimizing load time, and not the drive manufacturer bit...) I vaguely recall this having something to do with Win98 and FAT32, and it not making much difference for NTFS for other reasons. Unfortunately I can't seem to find the exact details atm. Blech. Bill From bh at cellware.de Fri Jul 16 06:38:45 1999 From: bh at cellware.de (bernard) Date: Fri, 16 Jul 1999 10:38:45 +0000 Subject: Accessing an object name ? Message-ID: <378F0BB5.9AD878D@cellware.de> Is there any way of mapping from an object id to an object name so that given the object declaration: obj1 = myClass() I can, within an instance method, access the object name 'obj1' ? bernard. -- _________________________________________________________________ __ _|__| Bernard Hayes cellware |_|__ |__| broadband Email bh at cellware.de Cellware Broadband Phone (+49 30) 670 08-114 Rudower Chaussee 5 Fax (+49 30) 670 08-108 12489 Berlin WWW http://www.cellware.de Germany _________________________________________________________________ From conrad at vanir.srl.caltech.edu Sat Jul 10 16:08:37 1999 From: conrad at vanir.srl.caltech.edu (Conrad Steenberg) Date: 10 Jul 1999 20:08:37 GMT Subject: Printing returned object in embedded app References: <378694FC.D857F68A@srl.caltech.edu> <6wxh3.1472$6M6.450919@news.shore.net> Message-ID: <7m9tnq$6qg$69@rks1.urz.tu-dresden.de> On 10 Jul 1999 18:24:33 GMT, Conrad Steenberg wrote: >On Sat, 10 Jul 1999 01:40:18 GMT, Michael P. Reilly wrote: >> >>Try: >> PyObject_Print(object, stdout, Py_PRINT_RAW); > >Thanks! > >Conrad >-- Hmmm... Sorry to reply to my own message, but it seems like PyRun_String returns only the Py_None object! How can I get the result of a calculation, say obj=PyRun_String ("1+1", start, globals, locals); which should be a numeric object? The behaviour I'm trying to get is the same as running python on a terminal: when an instruction have a printable result, I want to print it. Cheers Conrad -- From Haimo.Zobernig at cern.ch Thu Jul 8 10:28:14 1999 From: Haimo.Zobernig at cern.ch (Haimo G. Zobernig) Date: Thu, 08 Jul 1999 16:28:14 +0200 Subject: os.kill on NT Message-ID: <3784B57E.C0A57A@cern.ch> Some time ago (maybe not all that long) someone posted a small function implementing os.kill on Windows NT, using the PythonWin extensions. I didn't save it then and now I can't seem to find that post with either dejanews or egroups. Since I'm not very familiar with NT I'm having trouble writing it myself. Could somebody repost or email it? Many thanks! - Haimo -- Haimo G. Zobernig tel +41 22 7677361 Univ. of Wisconsin fax +41 22 7678370 c/o CERN Bld. 32 R-A02 1211 Geneve 23, Switzerland email Haimo.Zobernig at cern.ch From skip at mojam.com Sun Jul 25 13:22:03 1999 From: skip at mojam.com (Skip Montanaro) Date: Sun, 25 Jul 1999 12:22:03 -0500 (CDT) Subject: Access dictionary in order? In-Reply-To: References: Message-ID: <14235.18248.924848.52652@dolphin.mojam.com> Roy> I've got a dictionary of items which I will sometimes want random access Roy> to, but sometimes I'll want to be able to step through the items in a Roy> fixed order as well. Any good way to do that? You demonstrated the best way. There is no need to save the key list unless the dictionary is very large though. Just grab 'em and sort 'em when you need: keylist = dict.keys() keylist.sort() for key in keylist: do_stuff(dict[key]) Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/~skip/ 847-475-3758 From claird at starbase.neosoft.com Wed Jul 21 10:37:56 1999 From: claird at starbase.neosoft.com (Cameron Laird) Date: 21 Jul 1999 14:37:56 GMT Subject: Distributed application architectures (was: [Q] In-Browser technology) References: <1279557217-15543582@hypernet.com> Message-ID: <8F18075464DB9982.F6A8F284AFA328EB.A0A519CF82F3C805@lp.airnews.net> In article <1279557217-15543582 at hypernet.com>, Gordon McMillan wrote: . . . > Despite all the hype, the only things you can do reasonably portably >in browsers (NS & IE) is vanilla JScript / JavaScript and vanilla >Java applets. Even there you will almost certainly have to detect Not that that's to be sneered at, in general. Vanilla JavaScript and vanilla Java applets can do more than most programmers will touch in their whole lifetimes. On the other hand, yes, there's a LOT that they leave out. 'Depends on what ones needs are--the maxim Gordon and I invoke in all situa- tions, anyway. >which browser you're in, and code accordingly. You may even have to >detect which version of which browser. And things get even worse as >soon as you need to deal with the browser's security. And it's very >difficult to do anything useful without running up against a security >rule. I confirm Gordon's melancholy cautions. > > If you have long term relationships with your clients (so you can >ask them to install something) and if you only have to deal with a >limited (the smaller the better) number of browser / versions, you >can do some neat things. (But, as Cameron points out, why bother with >a 15 meg browser when they could just install an app - HTML forms are >easy to write, but don't make particularly good GUIs.) It varies. HTML forms are *perfect* for some situations, and risibly in- adequate for others. The anti-anti- ... backlash against HTMLization has now ascended to an uncountable height, as near as I can tell. My personal bias is to assume vanilla Webification is enough, and get customers to tell me for what more they truly are willing to pay. > > This whole noise about browsers-as-thin-clients was started >by the Java folks. Well, at this point, according to the same folks, >applets are "out" and server-side is "in". And they're right - Java >makes much more sense on the server than on the client. You can >blame it on the browsers, but the JVM spec pushes all the hard >work into the JVM implementation, so it should be no surprise that >the promise was hollow. Thin clients--ohboy. I've been sketching a whole essay I want to write on that subject. Whatever else we say, though, it's really, really valuable to be able to assume a Navigator or IE is sitting "out there", on a client's desktop, pro- foundly flawed though they are. > >On the server, Zope makes even more sense. Isn't *that* the truth! (That's Hoosier for, "I agree with you heartily.") > > I found Juice very intriguing when I looked at around 5 yrs ago. >It's not encouraging that they're still using the same wire-frame >demo they used back then. I appreciate your understatement. No, that is far from encouraging. . . . -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From roy at popmail.med.nyu.edu Thu Jul 8 12:39:50 1999 From: roy at popmail.med.nyu.edu (Roy Smith) Date: Thu, 08 Jul 1999 12:39:50 -0400 Subject: Two Pythons talking to each other? References: <199907072203.AAA09601@axil.hvision.nl> <378465E9.7762BE9A@fnmail.com> <14212.51977.601241.772478@buffalo.fnal.gov> <3784CD0C.24437EFC@fnmail.com> Message-ID: Per Kistler wrote: > But does NT and Mac have loopback IP addresses? The Mac certainly does. I was able to ping localhost using WhatRoute, and when I start up Telnet's built-in ftp server, I am able to connect to it by telnetting to "localhost.med.nyu.edu 21". Oddly enough, Fetch was unable to connect to localhost, giving me an "Error -1", and my telnet process crashed a little while later, but the existance of buggy software should not be taken as evidence that Macs do not have a loopback address :-) Much as I think evil about NT and all things Microsoft, I would be surprised (astonished, actually) if NT didn't handle loopback. -- Roy Smith New York University School of Medicine From claird at starbase.neosoft.com Tue Jul 20 19:41:52 1999 From: claird at starbase.neosoft.com (Cameron Laird) Date: 20 Jul 1999 23:41:52 GMT Subject: Python suitability questions References: <0CCE781E44F2C872.F528377A62B41DCA.73CAA63AD6E79314@lp.airnews.net> Message-ID: In article <0CCE781E44F2C872.F528377A62B41DCA.73CAA63AD6E79314 at lp.airnews.net>, Jason Maskell wrote: >Well, after a day or two of reading lots of newsgroup posts and >documentation, I'm still not quite certain if Python is suitable for the >project I have in mind. I'm rather reluctant to jump in and start fiddling >with it without having some idea whether it's what I'm looking for or not. A It's what you're looking for. You're at a stage in evaluation where it'll be cheaper for you to jump in than to continue to poke at Python from a distance. This is one of the charms of Python, as you'll learn; it invites experimentation, and is friendly, so frequently the best answer to how things work is to experience them for yourself. . . . -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From wlfraed at ix.netcom.com Sun Jul 4 17:13:31 1999 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Sun, 04 Jul 1999 21:13:31 GMT Subject: Language extensibility (was: Why is tcl broken?) References: <1283099377-77267484@hypernet.com> <3779ED0F.2C67@mailserver.hursley.i Message-ID: <377fc323.69785805@nntp.ix.netcom.com> On Sun, 04 Jul 1999 18:50:49 GMT, thornley at visi.com (David Thornley) declaimed the following in comp.lang.python: > "Thinking Forth" is an excellent book to read. So is Stroustrup's > "Design and Evolution of C++". I haven't seen a similar book about > the Lisp way of thinking, not counting books specifically on learning > Lisp and doing it well. Then again, I find Common Lisp revolutionary > enough sometimes. > Unfortunately, it predates much of what is now considered to be LISP. "Anatomy of LISP", John Allen, (1978 McGraw-Hill Computer Science Series). While using LISP, it was started as a data structures type course... -- > ============================================================== < > 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 arnold at dstc.edu.au Thu Jul 15 17:29:56 1999 From: arnold at dstc.edu.au (David Arnold) Date: Thu, 15 Jul 1999 21:29:56 GMT Subject: Calling superclass method with variable args? In-Reply-To: Your message of "Thu, 15 Jul 1999 11:35:10 MST." <378E29DD.1613913E@pixar.com> References: <378E29DD.1613913E@pixar.com> Message-ID: <199907152129.HAA02590@piglet.dstc.edu.au> -->"Steve" == Steve Johnson writes: Steve> But what if the method takes unnamed positional and keyword Steve> arguments. Then, how do you pass these along to the Steve> superclass's version of the method such that it gets the Steve> arguments in the same form that the subclass's method did? so close! the trick is the built-in function "apply(func, args [, keywords])" has the optional keywords dictionary as a third parameter. so, class Job(Task): def __init__(self,a,b,c, *moreargs, **morekeyargs): apply(Task.__init__, (self,a,b,c) + moreargs, morekeyargs) aJob = Job(x,y,z,m1,m2,m3,m4,m5,foo="bar") should work just fine, d From tismer at appliedbiometrics.com Wed Jul 21 15:08:12 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Wed, 21 Jul 1999 19:08:12 GMT Subject: [Tutor] I want to learn to hack References: Message-ID: <37961A9C.60201FBC@appliedbiometrics.com> David Ascher wrote: > > On Wed, 21 Jul 1999, Gerrit Holl wrote: > > > On Tue, Jul 20, 1999 at 02:31:55AM -0400, Tim Peters wrote: > > > > I want to learn to hack > > > So, little Roger, you want to learn how to hack? You came to the right > > > place! First walk down the hall and pick up a copy of Python from Guido. > > > He'll have you cracking bank accounts in no time . > > > > > > the-psa-is-the-richest-organization-on-earth-ly y'rs - tim > > > > > > > Well, I think Roger meant hack, not crack. Have a look at Eric S Raymonds > > "How to become an hacker FAQ" at http://www.tuxedo.org/~esr/ (and some > > further). > > > > Hacking is good, > > cracking is bad. > > > > I also want to learn to hack, I'm learning it! > > I *don't* want to learn to crack!! > > Gerrit -- just to fill you in -- Roger was presumably either joking or > testing a spam filter -- he is a colleague of Guido's, and knows all about > hacking. Whether he knows about cracking or not is not something he's > likely to disclose in public. =) > > (In other words, Tim was kidding, Roger was kidding, I'm not kidding!). No, you're just emailing to the wrong list :-))) -- 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 Tue Jul 27 19:48:01 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 27 Jul 1999 18:48:01 -0500 Subject: Problem with signals & exceptions... In-Reply-To: <2BB05D8530326D0C.420888E8906528AF.C6BF325D12E9ED90@lp.airnews.net> Message-ID: <1279007017-12004369@hypernet.com> Eric Lee Green writes: > I'm having trouble catching my thrown exceptions under FreeBSD 3.2. > I am using the Python 1.5.2 that came with FreeBSD 3.2 (well, on > disk 1 of the -disk set). The following program works properly > under Red Hat Linux version 6.0 running a self-compiled Python 1.5.2 > (in place of the 1.5.1 which comes with Red Hat 6.0, which does not > properly handle signals during socket i/o calls). How it works: it > listens to port 6664. When it gets a connection, it then sets an > alarm handler and alarm and then tries to read from the socket. If > it does not get data within 10 seconds, it then times out, at which > point the alarm handler throws an exception and aborts the socket > read. Why not avoid the pain of signals (which have enough gotchas to destroy portability) and use a select with a 10 sec timeout. If there's nothing in the readable list when it returns, bail out. - Gordon From neelk at brick.cswv.com Wed Jul 7 22:37:33 1999 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 7 Jul 1999 21:37:33 -0500 Subject: Arguments of builtin functios? Message-ID: <7m12td$13n$1@brick.cswv.com> I'm working on a tiny little module that makes it easy to dynamically examine out the call signature of functions and methods in Python. This seems like something that would be very useful when trying out code snippets in an interactive environment. For native Python functions and methods, I've managed to figure this out by by looking at the code object associated with the function, but I'm at a loss to figure out how to do the same thing for builtin C functions and method objects. Any hints? Neel From holger at phoenix-edv.netzservice.de Fri Jul 2 05:31:28 1999 From: holger at phoenix-edv.netzservice.de (Holger Jannsen) Date: Fri, 2 Jul 1999 09:31:28 GMT Subject: Why must path be in args in os.execv? References: <377A2590.D95D72FE@phoenix-edv.netzservice.de> Message-ID: <377C86F0.A95BE6B4@phoenix-edv.netzservice.de> Thanks, Jeff. That's a good answer. Ciao, Holger Jeff Epler schrieb: > > Holger, > > On Unix, read the manpage for execve and friends. You will see that the > first argument is the path to the executable, and the subsequent arguments > describe the arguments (including argv[0]) and optionally the environment. > By convention, argv[0] is the basename of the executable when the > executable is on the PATH, and the full path otherwise. (Another unix > convention is that when the first letter of argv[0] is "-", the shell is a > login shell) > > DOS doesn't really have execve. It's possible that the imitation is less > perfect than it could be. Instead, it may do the equivalent of entering > the string > string.join(argv, " ") > in the shell, i.e., ignoring the path argument. > > This looks like a shortcoming in the DOS (windows 9x, NT) implementation of > exec*, in a way that makes it work differently from the Unix it attempts to > imitate. This wouldn't surprise me, since I recently discovered that NT's > spawnl takes a unix-like array of arguments (const char *argv[]) but when > any element contains a space, it is split into two arguments in the child > process. So, I had to break some code that had worked fine on Unix to > generate argv, by quoting each argument (something that would *not* work on > Unix) .. > > Bad enough that Windows wants to copy Unix, they have to consistently get > it subtly wrong too. > > Jeff From Richard.Jones at fulcrum.com.au Tue Jul 27 19:35:54 1999 From: Richard.Jones at fulcrum.com.au (Richard Jones) Date: Tue, 27 Jul 1999 23:35:54 GMT Subject: Qt In-Reply-To: Message from Kikutani Makoto of 1999-Jul-27 13:49:2, <7nkdce$t1c$1@oak.prod.itd.earthlink.net> References: <7nkdce$t1c$1@oak.prod.itd.earthlink.net> Message-ID: <199907272335.JAA06521@envy.fulcrum.com.au> [Kikutani Makoto] > I fetched it and did make install. > But I got the following error at trying examples. > > mako% python aclock.py /usr/local/src/Lang/pyKDEsrc-0.8/exampl > es > Traceback (innermost last): > File "aclock.py", line 4, in ? > from kde import * > File "/usr/lib/python1.5/kde.py", line 7, in ? > import libkdec > ImportError: /usr/lib/libkimgio.so.2: undefined symbol: png_set_strip_16 > > What's wrong ? > My Linux Box is Debian potato, and kdelibs2g is version 1.1.1-19990523. > Python is 1.5.2 (python-gtk 0.6.1-1) Not sure - do you have the PNG library version that Qt requires? The example works for me under redhat 6.0 with qt 1.44 and png 1.0.3 (not sure what the actual requirements of Qt are though). Richard From billtut at microsoft.com Thu Jul 15 12:33:24 1999 From: billtut at microsoft.com (Bill Tutt) Date: Thu, 15 Jul 1999 16:33:24 GMT Subject: making a Windows NT service out of a python program Message-ID: <4D0A23B3F74DD111ACCD00805F31D8100DB90F50@RED-MSG-50> > From: Christian Tismer [mailto:tismer at appliedbiometrics.com] > Bill Tutt wrote: > > > > > From: Christian Tismer [mailto:tismer at appliedbiometrics.com] > > > > > > > > > This is all great stuff if you have understood it already. > > > For me, it is still unclear what makes up a service, and > > > what I need at the minimum to turn a Python program into > > > an NT service. > > > > > > > Not knowing ANYTHING about Medusa... I'll provide another > example service > > right here, and try and explain things as I go... > > That's fine. Medusa is just a Python program. I just need > to run any Pprogram as a service. :-) > Medusa uses non-blocking sockets, so check out get_request in the TCPServerService class. In particular after accepting the new connection in Medusa, you don't need to issue the .setblocking(1) call. You should still call WSAEventSelct() just in case someone else down the chain would like to turn the socket into a blocking socket again. Bill From fire at netlimit.com Wed Jul 21 18:02:39 1999 From: fire at netlimit.com (Joacim Löwgren) Date: Wed, 21 Jul 1999 22:02:39 GMT Subject: cin Message-ID: <3srl3.1302$Gj8.191985152@newsa.telia.net> Hi, I'm new to Python and I'm wondering what the C++ "cin" (or C "scanf()")equivalent in Python is. Doesn't seem there's a quick function for this. From pierrette at p98.f112.n480.z2.fidonet.org Sun Jul 4 16:54:50 1999 From: pierrette at p98.f112.n480.z2.fidonet.org (pierrette) Date: Sun, 04 Jul 1999 21:54:50 +0100 Subject: Upgrade or not ?? Message-ID: <000017c7@bossar.com.pl> From: pierrette Thanks, exactly what i needed. Is there a way to find out what events a widget support ? I browsed documentation on python.org but didn't find anything on FocusIn en FocusOut. I there somewhere documentation on that ?? Pierrette Greg McFarlane wrote: > Depending on exactly what you want to do, it may be possible in > Tkinter. You can use something like this to find out when a widget > gets and loses focus: > > import Tkinter > > def gotFocus(event): > print 'Focus in' > def lostFocus(event): > print 'Focus out' > > root = Tkinter.Tk() > > e = Tkinter.Entry() > e.bind('', gotFocus) > e.bind('', lostFocus) > e.pack() > > root.mainloop() > > Also, you can use this to set the focus to a widget. > > e.focus_set() > > On 3 Jul, pierrette wrote: > > First a general question : > > Actually we're working with Python 1.5.1 and we're satisfied with it. > > Should we upgrade to 1.5.2 and if yes WHY? > > > > No a Tkinter guestion : > > We developped a prototype of an application with python an tkinter, now > > we have to > > decide if we're gonna write the real app in python or something else ! > > We now allready that in principle we could do it with python, the thing > > we're missing > > in tk is a 'on get focus' ,a 'on lost focus' event and a 'set focus to' > > command > > Pe: on lost focus of inputfield 1: > > if inputfield1 = A: > > set focus to field2 > > elif inputfield1 = B: > > set focus to field 3 > > > > If those things are not available in tkinter what alternatives do we > > have ? > > - Changing the GUI (would be a shame but feasable), knowing that is has > > to be multi-platform WIN-LINUX? If so to what ? > > - Not write in python ? In this case we lose the work done for the > > prototype > > > > Thanks for comments and remarks > > > > Pierrette Serrand > > pserrand at worldnet.fr > > > > > > > > > > > > -- > Greg McFarlane: INMS Telstra Australia (gregm at nms.otc.telstra.com.au) > Today's forecast: Sunny, with occasional cloudy periods and a chance > of precipitation in some areas. From posselt at daimi.au.dk Tue Jul 6 11:28:49 1999 From: posselt at daimi.au.dk (Peter Posselt Vestergaard) Date: Tue, 06 Jul 1999 17:28:49 +0200 Subject: problem with lists Message-ID: <378220B1.9E0C272@daimi.au.dk> It seems like I've completely misunderstood something or at least done something wrong. There's noway I can see why these two scripts are outputting nothing or more correctly only the 4 first lines which cannot be seen in a browser. Anybody knows why? ----script 1------------------------------------------------ #!/usr/local/bin/python import cgi print "Content-type: text/html" print print "" print " ?ndring af data " print '' nydata.insert(0,'hej') print nydata[0] print 'strange' print '' --------------------------------------------------------------- ----script 2--------------------------------------------------- #!/usr/local/bin/python import cgi print "Content-type: text/html" print print "" print " ?ndring af data " print '' nydata[0]='weird' print nydata[0] print 'strange' print '' ------------------------------------------------------------------ This can be found at http://dovs-www.daimi.au.dk/cgi-posselt/kurtilmelding/test.py best regards Peter Posselt Vestergaard From bwarsaw at cnri.reston.va.us Mon Jul 19 11:36:19 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Mon, 19 Jul 1999 11:36:19 -0400 (EDT) Subject: Python and Boehm-Demers GC, I have code. References: <000101bed15c$c5685ca0$e7a22299@tim> Message-ID: <14227.17907.298990.975953@anthem.cnri.reston.va.us> >>>>> "TP" == Tim Peters writes: TP> It's Cyclops.py, and I just uploaded it to python.org's ftp TP> contrib site. It should show up in the System directory later TP> this week (send a complaint every 5 minutes to TP> ftpmaster at python.org until it does ). TP> that-barry-gets-too-much-sleep-ly y'rs - tim Tim was already Pushing it with the bogus Haiku that he sent -Barry From sreekantk at freenet.co.uk Thu Jul 8 21:52:12 1999 From: sreekantk at freenet.co.uk (Sreekant Kodela) Date: Fri, 09 Jul 1999 02:52:12 +0100 Subject: Help with strings please Message-ID: <378555CC.8B65F809@freenet.co.uk> Dear all I seem to be in trouble here. I am trying to make some cgi scripts for my web site. I am using the postgresql as the backend db and a form based address book and news forum etc. The problem is everything is working ok as long as noone uses ' and " in the text. If they do, bingo , postgres refuses to accept. I tried using string library [mainly string.join(string.split('awkward'"'st'ring')). It works sometimes and doesn't some times. Any better and efficient way to deal with this situation ! Any suggestions and ideas will be greatly appreciated. Thanks sreekant From heather at thalamus.wustl.edu Mon Jul 19 12:26:00 1999 From: heather at thalamus.wustl.edu (Heather A. Drury) Date: 19 Jul 1999 11:26:00 -0500 Subject: binding keys to slider in Tkinter? Message-ID: <7mvjio$dh8@thalamus.wustl.edu> Hi, I'm trying to bind the arrow keys to allow a user to increment (or decrement) a counter using the Scale widget and Tkinter. I seem to be unable to bind anything to the Scale widget. I'm sure I'm missing something. Here's a code blurb: self.slider = Scale(self, from_=0, to=100, orient=HORIZONTAL, length="3i", variable = self.myval, label="happy slider", command=self.print_value) self.slider.bind ("", self.doit) How come I can't seem to do this? Also, anyone know how to bind the right and left arrow keys (is it or something like that?)? TIA, Heather From emile at fenx.com Thu Jul 22 19:50:27 1999 From: emile at fenx.com (Emile van Sebille) Date: Thu, 22 Jul 1999 16:50:27 -0700 Subject: Fw: ANNOUNCE: Mailing list for Australian Python Users References: <007201bed42e$c4316c30$f29b12c2@secret.pythonware.com> <7n78nm$lic$1@news.accu.uu.nl> <379798BC.33FC0CA9@equi4.com> Message-ID: -- Emile van Sebille emile at fenx.com ------------------- Jean-Claude Wippler wrote in message news:379798BC.33FC0CA9 at equi4.com... > Martijn Faassen wrote: > > > > Lars Marius Garshol wrote: > > > > > * Fredrik Lundh > > > | > > > | python-se, n?gon? Link?ping? :-) > > > > > Tjah. Si Oslo, s? kan vi bli en del. :-) > > > > Utrecht is veel beter denk ik, Python-NL en zo.. > > Doen. Ik kom op de fiets. > > > An-large-percentage-of-pythoneers-speaks-Dutch-anyway-ly yours, > > De meerderheid, toch? > > -- Jean-Claude Niet op de brommer? (sp?) From smalleys at gte.net Fri Jul 23 00:44:02 1999 From: smalleys at gte.net (Sue) Date: Fri, 23 Jul 1999 04:44:02 GMT Subject: Merging two lists as a dictionary References: <19990720211946.A12202@pooh.frostnet.net> <19990721153539.S6170@xs4all.nl> <19990721084614.C15502@pooh.frostnet.net> Message-ID: <3797F338.E560D59A@gte.net> I think there's a C function in mxTools, as well. Sue. From petravic at fnal.gov Thu Jul 8 13:01:48 1999 From: petravic at fnal.gov (petravick@FNAL.GOV) Date: Thu, 8 Jul 1999 17:01:48 GMT Subject: Two Pythons talking to each other? In-Reply-To: <14212.51977.601241.772478@buffalo.fnal.gov> References: <14212.51977.601241.772478@buffalo.fnal.gov> Message-ID: AF_UNIX is likely to me more effcient if that matters. AF_INET will run about the whole protocol stack, AF_UNIX is usually implemented to be more like a pipe... -- DOn On Thu, 8 Jul 1999, Charles G Waldman wrote: > Date: Thu, 08 Jul 1999 11:00:09 -0500 (CDT) > From: Charles G Waldman > To: Per Kistler > Cc: python-list at cwi.nl > Subject: Re: Two Pythons talking to each other? > Newsgroups: comp.lang.python > > Per Kistler writes: > > Hi Hans > > > > One could use sockets with AF_INET, if it runs on another > > machine, and sockets with AF_UNIX, if it's on the the same > > host. > > There's no particular reason to use AF_UNIX, even if the two processes > are running on the same node. AF_INET with a loopback IP address > works fine, and is portable (not all platforms support unix-domain > sockets). > From postmail at mail3.intellect.com.tw Sat Jul 3 12:50:12 1999 From: postmail at mail3.intellect.com.tw (postmail at mail3.intellect.com.tw) Date: Sat, 03 Jul 1999 16:50:12 GMT Subject: Save your printing money Message-ID: <98572UT3.7M33741Y@mail3.intellect.com.tw> A.R. Tech Communication (CartridgeOutlet) is specialized in remanufactured toner cartridge & replacement inkjet cartridges Our mission is to save your money in printing . All remanufactured toner cartridges & replacement inkjet cartridges we offer are under lifetime warranty and 60 days cash back guarantee. Laser Printer Cartridge USD$ ====================================================== HP92274 (PX).....................................52.20 HP92275 (LX).....................................47.95 HP92285 (LX).....................................54.95 HP92291 (NX).....................................61.95 HP92295 (SX).....................................42.95 HP92298 (EX).....................................59.95 HP3900 (BX)......................................71.95 HP3903 (VX)......................................66.45 HP3906 (AX)......................................54.10 HP3909 (WX)......................................94.95 A-30 ......................................56.95 E-31 ......................................71.20 FX-1 ......................................57.95 FX-2 ......................................68.95 FX-3 ......................................64.95 IBM 4019/28/29...................................79.95 IBM 4039/49.....................................101.60 Laser Printer Cartridge w/Micr Toner USD$ ====================================================== HP92274 (PX) Micr Toner..........................77.95 HP92275 (LX) Micr Toner..........................74.95 HP92291 (NX) Micr Toner..........................97.95 HP92295 (SX) Micr Toner..........................81.95 HP92298 (EX) Micr Toner..........................87.95 HP3900 (BX) Micr Toner..........................101.95 HP3903 (VX) Micr Toner...........................93.95 HP3906 (AX) Micr Toner...........................93.95 HP3909 (WX) Micr Toner..........................111.95 HP4000A Micr Toner..............................164.95 HP4000X Micr Toner..............................169.95 InkJet Printer compatiable Cartridge USD$ ====================================================== SO20025 STYLUS 800, 1000 black....................9.69 SO20034 STYLUS PRO XL black.......................9.69 SO20036 STYLUS PRO XL C/Y/M......................18.75 SO20047 STYLUS 200, 820, COLOR II black...........9.69 SO20049 STYLUS 200, 820, COLOR II C/Y/M..........15.49 SO20066 STYLUS PRO XL C/Y/M......................18.49 SO20089 STYLUS 400, 600 C/Y/M....................16.97 SO20093 STYLUS 400, 600 black.....................9.99 SO20108 STYLUS 800, 1520 black....................9.99 SO20110 STYLUS PHOTO /PM 700C F. CC/MM/YY.......17.29 SO20118 STYLUS COLOR 3000 black..................22.99 SO20122 STYLUS COLOR 3000 yellow.................22.99 SO20126 STYLUS COLOR 3000 magenta................22.99 SO20130 STYLUS COLOR 3000 cyan...................22.99 SO20138 STYLUS COLOR 300 B/Y/M/C.................14.99 201B BJC 600 SERIES black.........................6.29 201C BJC 600 SERIES cyan..........................6.29 201M BJC 600 SERIES magenta.......................6.29 201Y BJC 600 SERIES yellow........................6.29 201HCB BJC 600E SERIES black......................6.99 21B BJC 4000 SERIES black.........................9.49 21CLR BJC 4000 SERIES Y/M/C......................11.49 642B BJC 300 SERIES black.........................8.99 For more information please visit our website at http://www.cartridgeoutlet.com Per Section 301, Paragraph (a)(2)(C) of S. 1618, further transmissions to you by the sender of this email may be stopped at no cost to you by sending a reply to this email address with the word "remove" in the subject line.. From Mike.C..Fletcher at p98.f112.n480.z2.fidonet.org Fri Jul 2 14:25:26 1999 From: Mike.C..Fletcher at p98.f112.n480.z2.fidonet.org (Mike C. Fletcher) Date: Fri, 02 Jul 1999 19:25:26 +0100 Subject: FOX-USERS: Re: Python GUIs: Abandoning TkInter and welcoming wxPyth Message-ID: <0000168a@bossar.com.pl> From: "Mike C. Fletcher" I should clarify, when I'm speaking about "rich" text editing widgets, I'm talking about colouring/styling, font selection, selection management, and preferably some sort of layout engine. Rich text as in RTF format, or HTML can both easily be built on top of a generic "rich" text widget. My personal ideal would be to allow a cascading style sheet-style layout system. Looking at the code for FXEditor, it seems to be very tightly focused on source-code editing, but subclassing it to allow for a colouriser which also changes fonts looks possible (it uses a low-level device context to draw graphic fonts). It is not a good base for a full layout engine, however, as it rather lacks in abstraction, doesn't provide for formatting blocks, and is generally a straight-forward-no-looking-back text-placement engine. Possibly adapting the Mozzilla layout engine (Gecko?) might be a better option. Enjoy yourselves, Mike Lyle Johnson wrote in message news:377CFD82.8EA084A2 at cfdrc.com... ... > I think any kind of rich text (i.e. RTF-compliant) or HTML widget is much > farther off for FOX. ... From jepler at inetnebr.com Sun Jul 25 09:17:33 1999 From: jepler at inetnebr.com (Jeff Epler) Date: Sun, 25 Jul 1999 13:17:33 GMT Subject: simplebeginnerquestion(**args) References: <379afff7.131877652@news.mindspring.com> Message-ID: Brian, When you're going to use "named" arguments, such as myfunc(a=1, b=2, c=3, d=4) then it's appropriate to use def myfunc(**kw): pass but when you're using unnamed arguments, such as myfunc(1, 2, 3, 4) you want to use def myfunc(*args): pass This makes sense, because for unnamed arguments the position is important but there's no sensible key to give them if they were placed in a dictionary---so instead, you get them as a tuple with "*args". But if the arguments are named, obviously they need to go into a dictionary. Jeff -- \/ http://www.infidels.org/ Jeff Epler jepler at inetnebr.com "Pay no attention to the man behind the curtain." -- Karl, as he stepped behind the computer to reboot it, during a FAT From greg.ewing at compaq.com Thu Jul 15 23:50:45 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Fri, 16 Jul 1999 15:50:45 +1200 Subject: Stackless & String-processing References: <000601bece8f$b549a420$51a22299@tim> <7mlu8n$6ug$1@brick.cswv.com> Message-ID: <378EAC15.20269642@compaq.com> Neel Krishnaswami wrote: > > What's the difference, exactly? AFAICT you need to save the execution > state when suspending both coroutines and generators, but I might be > missing something obvious.... The crucial difference is that a generator is never resumed after its caller has returned. This means that the generator's state can be pushed onto the same stack as the caller's. A coroutine, on the other hand, can outlive the context in which it was created, and therefore needs a stack all of its own. Another way to think about it is that a generator call is equivalent to an ordinary call where one of the parameters is a procedure. For example, where in "generator python" you might write def even_numbers_up_to(n): for i in range(n): if i % 2 == 0: yield(i) for e in even_numbers_up_to(42): print e, "is an even number!" you could do the same thing in ordinary python as def for_each_even_number_up_to(n, do_it): for i in range(n): if i % 2 == 0: do_it(i) def print_it(e): print e, "is an even number!" for_each_even_number_up_to(42, print_it) which clearly can be executed quite happily using a single stack. If Python had something akin to Smalltalk code blocks, generators wouldn't be needed. It would be nifty to be able to write something like for_each_even_number_up_to(42) -> (e): print e, "is an even number!" Greg From phd at emerald.netskate.ru Tue Jul 27 08:15:44 1999 From: phd at emerald.netskate.ru (Oleg Broytmann) Date: Tue, 27 Jul 1999 16:15:44 +0400 (MSD) Subject: 1.5.2 for: else: Message-ID: Hello! The following program: ---------- for a in ['a', 12]: print a else: print "Empty!" ---------- prints under 1.5.2 on Linux and Solaris: ----- a 12 Empty! ----- Is it a bug, or is it just me, who do not understand the feature? I expected just "a" and "12"... This: ---------- for a in []: print a else: print "Empty!" ---------- prints: ----- Empty! ----- and I think it is correct. Oleg. ---- Oleg Broytmann Netskate/Inter.Net.Ru phd at emerald.netskate.ru Programmers don't die, they just GOSUB without RETURN. From Alex.Maranda at p98.f112.n480.z2.fidonet.org Thu Jul 1 09:12:56 1999 From: Alex.Maranda at p98.f112.n480.z2.fidonet.org (Alex Maranda) Date: Thu, 01 Jul 1999 14:12:56 +0100 Subject: Python GUIs: Abandoning TkInter and welcoming wxPython? Message-ID: <00001606@bossar.com.pl> From: Alex Maranda Mikael Lyngvig wrote: > 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. I'll second that. > The wxWindows performance problems must be more of the "this could be > done better" than "this has to be done better" nature. I'll second that. > 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. This is the way to go indeed. Of course only the performance sensitive bits - there's no point in rewriting everything. Then put freeze to work on the remaining python code, and here you go. I've actually done that with the (sizable) wxPython demo on Linux (linking everything statically - libpython, wxPython wrappers, wxGTK, GTK, GLIB, even stdc++; in the end the only dynamic dependencies of the binary were libc, libdl, libX11). I got a 4.5 Meg binary, from which 0.5 Meg was the demo bytecode. 4 Meg of 'runtime' it's not much nowadays, and boy it's fast. I'm not advocating this for casual use, I just explored packaging possibilities for the average U*ix platform. The Windows version is smaller 'cause GDI and the other libs are always there :) 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 parkw at better.net Thu Jul 8 06:33:15 1999 From: parkw at better.net (William Park) Date: Thu, 8 Jul 1999 06:33:15 -0400 Subject: I am v. stupid, please help In-Reply-To: <000015aa@bossar.com.pl>; from Newbie on Wed, Jun 30, 1999 at 12:31:49AM +0100 References: <000015aa@bossar.com.pl> Message-ID: <19990708063315.A2111@better.net> On Wed, Jun 30, 1999 at 12:31:49AM +0100, Newbie wrote: > From: "Newbie" <8499 at greenhead.ac.uk> > > > 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 > > -- > http://www.python.org/mailman/listinfo/python-list Since 'eval' will simply execute your expression just as you would type it interactively, try putting quotations around your input: >>> input("==> ") ==> 123 123 >>> input("==> ") ==> 'sss' 'sss' William Park From jsight at mindspring.com Wed Jul 7 00:55:26 1999 From: jsight at mindspring.com (Jesse D. Sightler) Date: Wed, 07 Jul 1999 00:55:26 -0400 Subject: Advertising Management in Python? Message-ID: <3782DDBE.E666F6D4@mindspring.com> Is there a Python library for easily handling banner ads along with statistics and analysis? This would be very nice, as most of the ones in Perl are truly annoying. :-) Ok, so I don't like Perl. :-) Thanks in advance, -- --------------- Jesse D. Sightler http://www3.pair.com/jsight/ "Do not use a hatchet to remove a fly from your friend's forehead." - Chinese Proverb From rvollmert at gmx.net Sat Jul 17 10:53:26 1999 From: rvollmert at gmx.net (Robert Vollmert) Date: Sat, 17 Jul 1999 16:53:26 +0200 Subject: at / os.popen problems Message-ID: <19990717165326.D599@krikkit.vollmert.home> Hello, I found a problem with os.popen in an at job. Closing the pipe after calling pipe.read() produces an IOError for some commands. popen.py (attached) produces the following output when called from at as: popen.py '/bin/ls /' '{ /bin/ls / ; }' 'echo hello' '{ echo hello ; }' error while closing { /bin/ls / ; }: IOError: [Errno 10] No child processes error while closing echo hello: IOError: [Errno 10] No child processes error while closing { echo hello ; }: IOError: [Errno 10] No child processes /bin/ls / status: 0 /bin/ls / output: [snipped correct ls output] { /bin/ls / ; } status: -1 { /bin/ls / ; } output: [snipped correct ls output] echo hello status: -1 echo hello output: hello { echo hello ; } status: -1 { echo hello ; } output: hello This works correctly from cron and in the shell. Also, when read() is left out, close() works as normal. I'm using a self-compiled version 1.5.2 python on Debian/GNU Linux 2.1 with kernel 2.2.10. at is version 3.1.8. Thanks, Robert. popen.py: #! /usr/bin/env python import sys, os, string def main(): for command in sys.argv[1:]: try: pipe = os.popen('%s' % command, 'r') except Exception, inst: sys.stderr.write('error while opening %s: %s\n' % (command, inst.__class__.__name__, inst)) try: output = pipe.read() except Exception, inst: sys.stderr.write('error while reading %s: %s\n' % (command, inst.__class__.__name__, inst)) try: status = pipe.close() or 0 except Exception, inst: sys.stderr.write('error while closing %s: %s: %s\n' % (command, inst.__class__.__name__, inst)) status = -1 print command, "status:", status print command, "output:" print output if __name__ == '__main__': sys.exit(main()) -- Robert Vollmert rvollmert at gmx.net From clgonsal at kami.com Fri Jul 9 07:16:22 1999 From: clgonsal at kami.com (C. Laurence Gonsalves) Date: Fri, 09 Jul 1999 11:16:22 +0000 Subject: VIM and [Python] block jumping References: <3781347D.CB2FBAB3@starvision.com> <37815B80.B4B51F94@starvision.com> <3785D753.DB2FF1ED@kami.com> Message-ID: <3785DA06.974567F3@kami.com> Of course, right after I posted that, realized that there's a problem. The blockMotion function doesn't account for lines that are continuations of other lines. That means that triple-quoted string literals, lines with more {[('s that }])'s, and lines joined with \ can screw it up. Are there any other situations? I'll try to post a corrected version later. Some of those problems are pretty nasty though (triple-quoted strings in particular). -- C. Laurence Gonsalves "Any sufficiently advanced clgonsal at kami.com technology is indistinguishable http://www.cryogen.com/clgonsal/ from magic" -- Arthur C. Clarke From dyoung at pobox.com Mon Jul 19 23:12:32 1999 From: dyoung at pobox.com (David Young) Date: 20 Jul 1999 03:12:32 GMT Subject: python to perl conversion? Message-ID: Is there a program that converts Python source to Perl source? There is a program that a client wants written in Perl so that their Perl-only programmers (can you imagine?) can hack on it later. I haven't the time or inclination to learn Perl, and this project fairly cries out for Python, but I cannot justify the time expense of translating from Python to Perl by hand. Dave -- ``I always thought that anybody who told me I couldn't live in the past was trying to get me to forget something that if I remembered it would get them in serious trouble.'' --Utah Philips From wolford at enews.nrl.navy.mil Thu Jul 8 11:01:31 1999 From: wolford at enews.nrl.navy.mil (Scott Wolford) Date: Thu, 08 Jul 1999 11:01:31 -0400 Subject: win32 python as a dll? References: <1280719925-72790231@hypernet.com> Message-ID: <3784BD4B.7938B7BA@enews.nrl.navy.mil> Here's the smallest case that gives me problems: #include "Python.h" #include int main(int argc, char **argv) { // return Py_Main(argc, argv); FILE *file = fopen(argv[0], "rt"); PyRun_AnyFile(file, argv[0]); } I just modified python.c to run the script like I do in my application. I get the following error: Fatal Python error: PyThreadState_Get: no current thread The Py_Main line works fine. Any takers? Thanks in advance, Scott Gordon McMillan wrote: > Scott Wolford writes: > > > Now I'm a little confused. > > I was trying to figure out how to tell you that politely... Thanks for doing so. > > Python does seem to be a dll (?); I found > > python15.dll in winnt/system32 directory. > > Correct. That's 99.999+% of python. python.exe does nothing but load > it and call Py_Main. I knew that; brain fart. I've written my own makefile for python and my application works fine when I build it myself. > > But I can't find > > python15_d.dll anywhere. Was that supposed to be installed? > > Nope, you have to build it. > > > I think > > python15.dll bombs because it was compiled as optimized using the M$ > > compiler and that optimizer has problems (at least w/ O2; I've been > > pretty successfull w/ O1). > > Probably not. It's been pretty thoroughly tested at this point. I agree, but in the *normal* fashion. > > So I want to use python15_d but I can't > > find the dll. > > > > Any help would be appreciated, > > Probably the most common mistake of Windows embedders is to link to > the wrong C runtime lib. Python uses Multithreaded DLL. Nope, I use msvcrt and msvcrtd. You say Multithreaded *DLL* so that's what you mean (and not libcmt.lib), right? > But you might have done something more creative. Telling us how and > when it bombs complete with messages and as small a code sample as > possible will get you more and better answers. see top of post. > - Gordon From markh at angband.org Fri Jul 16 08:09:18 1999 From: markh at angband.org (Mark Howson) Date: Fri, 16 Jul 1999 13:09:18 +0100 Subject: Expand tuple into argument list? References: <87aesy4w3f.fsf@solano.in.renlabs.com> Message-ID: <378F20EE.5F0567AA@angband.org> Steven Work wrote: > I'm new to Python. I want a dispatch function -- takes a function > name and other arguments, calls the named function with the remaining > arguments. This works for limited length argument lists: > > def dispatch(fnname, *rest): > fn = dispatch.func_globals[fnname] How about: return( apply(fn, rest)) Mark From gerrit.holl at pobox.com Thu Jul 8 16:41:10 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Thu, 8 Jul 1999 20:41:10 GMT Subject: Why are index() and count() only for mutable sequences? In-Reply-To: <3784F778.6A6B4568@lemburg.com>; from M.-A. Lemburg on Thu, Jul 08, 1999 at 09:09:44PM +0200 References: <004701bec95f$186faa80$a0ee6dd1@BobAlexDesk> <3784F778.6A6B4568@lemburg.com> Message-ID: <7m9tlp$6qg$7@rks1.urz.tu-dresden.de> On Thu, Jul 08, 1999 at 09:09:44PM +0200, M.-A. Lemburg wrote: > Date: Thu, 08 Jul 1999 21:09:44 +0200 > From: "M.-A. Lemburg" > To: Bob Alexander > Cc: python-list at python.org > Subject: Re: Why are index() and count() only for mutable sequences? > > Bob Alexander wrote: > > > > There is no modification of the sequence performed by these functions > > -- it seems as though they could be available for all sequences. It > > would certainly be useful for tuples as well as lists (strings, too, > > for that matter, even though we have the more general string.find()). > > You could try count(), index(), forall() and exists() from mxTools: > > http://starship.skyport.net/~lemburg/mxTools.html > > Albeit, they work with conditions (functions that return 1/0) to > implement the testing process. > Is this an anwser?? He asked: "why"... regards, 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/ Oh my god! They killed init! You bastards! From greg.ewing at compaq.com Tue Jul 13 19:50:45 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Wed, 14 Jul 1999 11:50:45 +1200 Subject: console show in Python? References: <378626CF.9495FAB0@mry.rbd.com> Message-ID: <378BD0D5.A05CDD21@compaq.com> Scott Shillcock wrote: > > Is there something similar to the Tcl/Tk 'console show' command in > Python. Use IDLE - it has a console window that does what you want. Note that you don't need to call mainloop() at all when you're using IDLE, because IDLE itself is implemented using Tkinter and is therefore running a mainloop() all the time. Greg From larsga at ifi.uio.no Sun Jul 4 06:23:03 1999 From: larsga at ifi.uio.no (Lars Marius Garshol) Date: 04 Jul 1999 12:23:03 +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> <377A3383.D453468@iname.com> <377aa228.31380423@news.jpl.nasa.gov> <14206.52213.119553.809177@lrz.de> Message-ID: * Jeff Dalton | | Well *Lisp* dates back to the late 50s. Scheme may be from 75, but | Lisp is a different matter. And lambda calculus is, what, 1949? * Jerome Kalifa | | No, as a mathematical theory, it was developed before the war. * Eugene Leitl | | Church, A., The Calculi of Lambda Conversion, Princeton University | Press, Princeton, N.J., 1941 According to David Harel's Algorithmics, the correct reference is actually S.C. Kleene "A Theory of Positive Integers in Formal Logic", Amer. J. Math. 57 (1935), pp. 153-173,219-244. And there seems to be general agreement that the lambda calculus dates back to the 30s. --Lars M. From algaba at my-deja.com Mon Jul 26 14:13:38 1999 From: algaba at my-deja.com (algaba at my-deja.com) Date: Mon, 26 Jul 1999 18:13:38 GMT Subject: createfilehandler, how to use it with Tk? References: <7nht1s$grn$1@nnrp1.deja.com> <012c01bed77a$d562b370$f29b12c2@secret.pythonware.com> Message-ID: <7ni8ga$p0k$1@nnrp1.deja.com> In article <012c01bed77a$d562b370$f29b12c2 at secret.pythonware.com>, "Fredrik Lundh" wrote: > algaba at my-deja.com wrote: > > I have to communicate a tk front end with another modules. > > And I'm trying: > forget about createfilehandler. use asyncore/asynchat instead: > http://www.python.org/doc/current/lib/module-asyncore.html > > to use them under Tk, you can use a > simple polling scheme: > > asyncore.poll(0.05) > self.master.after(100, self.poll) > except: > pass # error in network callback > > ... > asyncore is a new module ? I can't find it in my python 1.5.1 Anyway, thanks. And... what's the difference between this and a simple loop with time.sleep(0.001), ... a bit of more freedom? Thanks 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 Jul 7 11:17:58 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Wed, 7 Jul 1999 11:17:58 -0400 (EDT) Subject: ++Python - Emacs functions to expand shorthand References: <7ltrua$pkr$1@nnrp1.deja.com> Message-ID: <14211.28582.924601.108525@anthem.cnri.reston.va.us> >>>>> "PL" == Preston Landers writes: PL> py-shorthand-line-expand -- bound to C-z -- works only on the PL> current line. PL> py-shorthand-buffer-expand -- bound to C-c C-z -- works on the PL> whole buffer. PL> These keys expand shorthand expressions. A couple of PL> examples: | foo += bar ---> foo = foo + bar | ++foo.bar ---> foo.bar = foo.bar + 1 Here's a thought: Why not make `+', `-', and `=' electric and do the expansion automatically when you type those characters? You'd have to use foo.bar++ instead of ++foo.bar but that doesn't seem too bad. I think those expansions would be pretty easy to do, and if they work out well and a lot of people like them, I might consider adding them to python-mode. -Barry From mwh21 at cam.ac.uk Wed Jul 14 13:28:17 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 14 Jul 1999 18:28:17 +0100 Subject: OS/2 Python: editing in interactive use References: <378C55A9.411BE9AB@tu-clausthal.de> Message-ID: Stefan Schwarzer writes: > Hi there :) > > It seems to me that the OS/2 port of python lacks the > "sophisticated" features for input editing (history, > C-A, C-E, etc.) Those features are provided by readline. I doubt readline works on OS/2, though you could have a look. A search on google turned up a reference to a Python readline module for win32, though the site seems to be off net, at least temporarily. > If I have overlooked a possibility to activate it, please > give me a hint. If not, how difficult would it be to extend > Python/2 appropriately? I would appreciate this very much. :) Can you use idle? Most Python IDE's have some commandline editing features. > Regards > Stefan HTH Michael -- Oh, very funny. Very sar-cah-stic. http://www.ntk.net http://www.ntk.net/doh/options.html - ho ho From Alan.Daniels at p98.f112.n480.z2.fidonet.org Sat Jul 3 00:51:47 1999 From: Alan.Daniels at p98.f112.n480.z2.fidonet.org (Alan Daniels) Date: Sat, 03 Jul 1999 05:51:47 +0100 Subject: Python suitable for a game engine? Message-ID: <000016a2@bossar.com.pl> From: daniels at mindspring.com (Alan Daniels) On Fri, 02 Jul 1999 11:48:36 +0100, the infinitely wise Alex Maranda (amaranda at nospam.com) spoke forth to us, saying... [snip...] >Alan Daniels wrote: >> I have the (VERY!) preliminary code at: >> http://www.mindspring.com/~daniels/engine/index.html >> if you're interested, although there isn't much to look at. >I'm downloading it now. You can use negative version numbers; >SmallEiffel is now at version -0.78. They'll stop when they'll reach 0.0 >:-) In that case, I'm going to restart with negative numbers. I was just going to call it the "Zebra" engine, but that name is taken. So, I'm going to rename it to the "Zeroth" engine. Seems appropriate, considering the state its in. :=) -- ======================= Alan Daniels daniels at mindspring.com daniels at cc.gatech.edu From m.faassen at vet.uu.nl Mon Jul 19 04:05:54 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 19 Jul 1999 08:05:54 GMT Subject: J, you can't pass your own test. References: <378E3481.EE31C97@uswest.net> <19990715175320.B20155@toast.internal> <7mnj5k$id9$1@nnrp1.deja.com> <19990716173936.F20935@toast.internal> Message-ID: <7mum92$15a0$1@news.accu.uu.nl> jam wrote: > myself *did* take the time to respond to such a post says a lot for the > community as a whole, which is far more important than my own political > standing in the group at the moment. Cool, I didn't know I *had* a political standing. So what's my political standing? What's my ranking on the Tim Peters scale (where the timbot is 100)? Trying-to-lighten-the-mood-ly yours, Martijn From vdkoijk at linux01.prc.tno.nl Mon Jul 5 03:34:04 1999 From: vdkoijk at linux01.prc.tno.nl (John van der Koijk) Date: 05 Jul 1999 09:34:04 +0200 Subject: popen2 on Windows Message-ID: <877lof7doz.fsf@linux01.prc.tno.nl> I hope this is not a FAQ: First, let me set the stage: I'm trying to implement a control loop using python and a DDE application under Windows 95. The DDE link freezes as soon as I start a thread in the python program, in order to run a Tkinter GUI. ((( I've taken care of the Tkinter mainloop vs. threading problem using # Ernst-Udo Wallenborn says: def mainloop(self): dummy = 0 while 1: Frame.update(self) time.sleep(0.02) # if self.quitting == 1: # sys.exit(0) root.mainloop = mainloop root.mainloop(root) which is puzzling because `quitting' does not seem to be known here. ))) After coping with my initial frustration, I've decided to make an unthreaded stub program talking to the DDE client, using popen2 to do the IPC with the GUI and controller program. Sadly, this approach also does not seem to work, because using popen2 gives me: [....] os.fork() AttributeError: fork This is amazing, since the manual for 1.5.2 says: 8.13 popen2 -- Subprocesses with accessible standard I/O streams Availability: Unix, Windows. I'm using Python 1.5.2 (#0). Could anyone give me a clue what could be wrong? Kind regards, -- John van der Koijk. -- TNO Institute of Industrial Technology PO Box 5073, 2600 GB, Delft, The Netherlands Phone +31 15 2608833, Fax +31 15 2608846 From wtbridgman at radix.net Fri Jul 23 06:46:24 1999 From: wtbridgman at radix.net (T. Bridgman) Date: Fri, 23 Jul 1999 6:46:24 -0400 Subject: Python Mode for Alpha ? References: <14229.57251.996871.502133@anthem.cnri.reston.va.us> <14229.58766.234709.815774@weyr.cnri.reston.va.us> Message-ID: <01HW.B3BDC040002912FD0CB6CED0@news1.radix.net> I know that I've never been able to get it working on Alpha 7.x Tom On Wed, 21 Jul 1999 11:44:46 -0400, Josef Sachs wrote (in message ): > >>>>>> On Wed, 21 Jul 1999 15:21:50 GMT, Fred L Drake said: > >> No, he's asking about an editing mode for Alpha, a Mac editor. I remember >> having one when I used a Macintosh, but that was almost 5 years ago. I >> have no idea where to get such a beast these days. > > ? Did > that stop working with some recent Alpha release? From jsight at mindspring.com Tue Jul 20 18:13:44 1999 From: jsight at mindspring.com (Jesse D. Sightler) Date: Tue, 20 Jul 1999 18:13:44 -0400 Subject: python to perl conversion? References: <7n1t4q$ik$1@nnrp03.primenet.com> Message-ID: <3794F498.AD6FF3B9@mindspring.com> Well, COBOL does to, but that doesn't mean I'd write any of it. :-) John Jensen wrote: > > David Young wrote: > : Is there a program that converts Python source to Perl source? There is > : a program that a client wants written in Perl so that their Perl-only > : programmers (can you imagine?) can hack on it later. I haven't the time or > : inclination to learn Perl, and this project fairly cries out for Python, > : but I cannot justify the time expense of translating from Python to Perl > : by hand. > > I think I lean towards Python for beauty, but Perl does have its role in > commerce: > > http://www.robojob.com/lang.html > > It might be good to know both, to use the one you prefer on projects you > control, but to use the other when the client specifies. > > John -- --------------- Jesse D. Sightler http://www.biddin.com/pyPit/ From kikutani at sprintmail.com Tue Jul 27 01:32:48 1999 From: kikutani at sprintmail.com (Kikutani Makoto) Date: 27 Jul 1999 05:32:48 GMT Subject: Qt Message-ID: <7njga0$361$1@ash.prod.itd.earthlink.net> There are kdebinding and qtbinding in: ftp://ftp.kde.org/pub/kde/devel/ I guess qtbinding is obsolete and kdebinding should be used. Am I right ? I'm afraid that kdebinding is not updated recently, either. -- Kikutani, Makoto kikutani at sprintmail.com From billtut at microsoft.com Fri Jul 30 18:54:57 1999 From: billtut at microsoft.com (Bill Tutt) Date: Fri, 30 Jul 1999 22:54:57 GMT Subject: Need help with TCP/IP client access from Windows Message-ID: <4D0A23B3F74DD111ACCD00805F31D8100DB90FF4@RED-MSG-50> > From: Eric S. Raymond [mailto:esr at thyrsus.com] > > > Gordon McMillan : > > > OK. Will giving the filename ".\\intriguer" work for this? And, > > > given that the filename is going through the C library, > will leaving > > > it as "./intriguer" work? > > Well, as long as your current working directory is what you want it to be, sure it'll work, otherwise you'll need to pull the standard "where did I get run from" nonsense. Bill From Fred.L..Drake at p98.f112.n480.z2.fidonet.org Thu Jul 1 16:33:14 1999 From: Fred.L..Drake at p98.f112.n480.z2.fidonet.org (Fred L. Drake) Date: Thu, 01 Jul 1999 21:33:14 +0100 Subject: print color strings? Message-ID: <00001637@bossar.com.pl> From: "Fred L. Drake" Gerrit Holl writes: > is there an easy way to print color strings in python? > > A function like printcolor('brightyellow', 'red', 'spam'), that finds > out on what kind of terminal you are and prints it to stdout? Gerrit, If you're doing this on Unix, take a look at the ncurses library; there's a Python interface to that. (I think Oliver Andrich did it; searching DejaNews should find it fairly quickly since this keeps coming up.) The standard curses module will be documented in the next release of the Library Reference. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From Donn.Cave at p98.f112.n480.z2.fidonet.org Thu Jul 1 17:55:55 1999 From: Donn.Cave at p98.f112.n480.z2.fidonet.org (Donn Cave) Date: Thu, 01 Jul 1999 22:55:55 +0100 Subject: print color strings? Message-ID: <00001640@bossar.com.pl> From: donn at u.washington.edu (Donn Cave) "Fred L. Drake" writes: |Gerrit Holl writes: |> is there an easy way to print color strings in python? |> |> A function like printcolor('brightyellow', 'red', 'spam'), that finds |> out on what kind of terminal you are and prints it to stdout? | | Gerrit, | If you're doing this on Unix, take a look at the ncurses library; | there's a Python interface to that. (I think Oliver Andrich did it; | searching DejaNews should find it fairly quickly since this keeps | coming up.) | The standard curses module will be documented in the next release of | the Library Reference. And if that doesn't work, probably your termcap or terminfo definitions lack the necessary information about color escape sequences. That's a widespread problem. The color escape sequences that have worked for me on a couple of terminal types have been of the form [32m, where 32 is a number from 30 to 37. I use only 31 to 36. 30 and 37 are more or less black and white, but the details vary, so I switch from color to non-color with [m instead of trying to sort out the details of black and white vs. background and foreground. Of course these are terminal specific escape sequences. They're evil and you must not use them, especially if you have a choice. Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From mal at lemburg.com Thu Jul 8 15:09:44 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Thu, 08 Jul 1999 21:09:44 +0200 Subject: Why are index() and count() only for mutable sequences? References: <004701bec95f$186faa80$a0ee6dd1@BobAlexDesk> Message-ID: <3784F778.6A6B4568@lemburg.com> Bob Alexander wrote: > > There is no modification of the sequence performed by these functions > -- it seems as though they could be available for all sequences. It > would certainly be useful for tuples as well as lists (strings, too, > for that matter, even though we have the more general string.find()). You could try count(), index(), forall() and exists() from mxTools: http://starship.skyport.net/~lemburg/mxTools.html Albeit, they work with conditions (functions that return 1/0) to implement the testing process. Cheers, -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 176 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From nascheme at ucalgary.ca Sat Jul 17 00:01:11 1999 From: nascheme at ucalgary.ca (Neil Schemenauer) Date: 17 Jul 1999 04:01:11 GMT Subject: Python and Boehm-Demers GC, I have code. References: <000901becffa$b0f25e00$91a22299@tim> Message-ID: <7mov67$bfg@ds2.acs.ucalgary.ca> Tim Peters wrote: >[Neil Schemenauer] >> I have added the Boehm-Demers garbage collector to Python and it >> works well! >> ... > >That's good, but I'm not clear on what this means. The patch didn't seem to >do more than replace malloc/calloc/realloc/free with the BDW versions; in >particular, Py_USE_GC_FREE was #define'd, and you ran tests without >significant cyclic structures, so it doesn't *appear* that anything more >happened here than that a different implementation of the malloc family got >plugged in. Did the "collection" phase of BDW find any trash at all? It doesn't unless you create some. The patch creates a version of Python that uses GC only to clean up reference cycles. >... it would be great if BDW could be invoked >"just sometimes" to reclaim the cycles RC can't catch. That is what is happening now. >semi-encouraging-ly y'rs - tim Thanks. Neil BTW, _tkinter is not working perfectly yet. I think lambdas passed as callbacks are getting collected. From brian.pedersen at mail.danbbs.dk Mon Jul 26 17:40:18 1999 From: brian.pedersen at mail.danbbs.dk (Brian Pedersen) Date: Mon, 26 Jul 1999 21:40:18 GMT Subject: Python and Red Hat Linux 6 References: <379CD547.22A10A50@postoffice.pacbell.net> Message-ID: <379CD5C2.5BA096A2@mail.danbbs.dk> Rob wrote: > > When programming in Perl or Python, I am using a header like the > following on an executable file to cause the shell (bash or csh) to run > the scripts as Perl/Python files: > #!/usr/bin/perl for Perl and #!/usr/bin/python for Python. I've > checked and the compilers are located in the appropriate directories. I > keep getting this when I run scripts: > bash:

The caption on the first button is set by the Window Load code. Clicking that button changes the text in the first edit box.

The second button changes its own text when clicked.

The fourth button calls a global function, defined in the global 'script' scope, rather than the 'MyForm' scope.


And here is a second form


-- Robin Becker From jodywinston at my-deja.com Thu Jul 22 10:47:42 1999 From: jodywinston at my-deja.com (jodywinston at my-deja.com) Date: Thu, 22 Jul 1999 14:47:42 GMT Subject: Is anybody aware of a tree GUI widget for tkinter or Pmw? References: <3796E213.9F326412@eng.cam.ac.uk> Message-ID: <7n7aua$t4o$1@nnrp1.deja.com> In article <3796E213.9F326412 at eng.cam.ac.uk>, "D. Lopez-De-Ipina" wrote: > Hi, > > Could anybody please tell me if there exits any TREE control widget for > tkinter or Pmw? I know that Pmw provides a rather rich set of > 'megawidgets' but the tree control has not been implemented yet as far > as I know. > > Thanks a lot, > > Diego > > The PMW Contrib widgets (doughellmann at mindspring.com) has a tree control widget. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From greg.ewing at compaq.com Thu Jul 22 20:02:55 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Fri, 23 Jul 1999 12:02:55 +1200 Subject: Loops and stuff (was Re: Python and Boehm-Demers GC, I have code.) References: <001601bed410$ec2ba0c0$642d2399@tim> Message-ID: <3797B12F.AE6BF826@compaq.com> Tim Peters wrote: > > I think it worked out great! I was surprised. I wouldn't be quite so enthusiastic. I would say that one can learn to live with the inconvenience, and even almost forget that it's there most of the time. But I still feel annoyed whenever I bump up against it. > and maintaining state via class instances will always be more > Pythonic. I don't think you can assert that until a Python with lexical scoping has been in use for a while and we see how people prefer to write things. My bet is that a lot of things we write now like b = Button(..., command = lambda self=self: self.blat(42)) would get written as b = Button(..., command = lambda: self.blat(42)) and we would all wonder why we didn't storm Guido's palace years ago and force him to release his lexical scoping code at gunpoint... Greg From catlee at my-deja.com Fri Jul 9 17:44:02 1999 From: catlee at my-deja.com (catlee at my-deja.com) Date: Fri, 09 Jul 1999 21:44:02 GMT Subject: Python re module Message-ID: <7m5qev$lue$1@nnrp1.deja.com> Try the following: import re re.search("((.)\\1+)","a") Now, I know this isn't proper syntax (you shouldn't reference a group inside itself), but on my machine python hangs. Is this a bug, or a feature? =) Cheers, Chris Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From reason at shadow.net Sat Jul 17 22:37:39 1999 From: reason at shadow.net (Vladik) Date: Sat, 17 Jul 1999 22:37:39 -0400 Subject: [Q] In-Browser technology Message-ID: <932337314.611.103@news.remarQ.com> Hello, Sorry for cross-posting, but my question is really to the people on the news groups who know about Eiffel, Python and Perl. Basically, We are to develop a web client (a program that can be ran witting a web browser) for our otherwise n-tier cross-platform system, our research department gave the recommendation and actually a prototype of the client in MS ASP (active server pages) and, I think but not sure, blended with Visual Basic. Talk about bias... But this means that it can only run in MS IE and not in Netscape, also it limits the number of platforms not only for the client on which web browser runs, but also for the web server (MS platforms only, because web server with active pages can only run there) There is some talk about Java, but our web client will also be ran via Serial links (not T1 connections) on relatively inexpensive systems -- therefore Java is something to look into but it may be slow. So I am set on a quest to find something that a) can be executed within IE or Netscape, b) be faster and overall more resource friendly then JavaScript technology c) supports OO programming d) does not depend on the platform on which web server is running.( if the web server is running NT or UNIX (sun, linux) I have found one thing that almost satisfies the requirements: it is based on Oberon-2 programming language and so far sounds VERY promising. The reason why I am still looking is because there are more books and internet support for Python,Perl and Eiffel then for Oberon (this will be a factor when presenting the proposal to the management). The other problem is that there is plugin for this technology available for NT and Mac platforms (for both IE and Netscape) and is not available for UNIX platforms (which means that a web browser can not be ran on UNIX). There is source code, though. If interested: http://caesar.ics.uci.edu/juice/ So, finally, my question is is there a technology I am looking for available for either Perl or Eiffel or Python Since I am cross-posting, I would appreciate a reply by mail as well. Thanks in advance, Vladislav From cees at pcraster.nl Tue Jul 6 10:50:18 1999 From: cees at pcraster.nl (Cees Wesseling) Date: Tue, 06 Jul 1999 16:50:18 +0200 Subject: xml-0.5.1 and comments Message-ID: <378217AA.2ED7E731@pcraster.nl> Hi, I am trying to manipulate some xml documents using the xml-0.5.1 package. My goal is to write scripts that transform some xml using either SAX or DOM where apropriate. With the DOM Walker, I am already succesfull in doing the most things I want, great tools! But the DOM walker seems not to pass comment's through. What I want is an exact copy of the input xml minus the transformations I want to made. But in Walker overriding doComment does not trigger any comments. Also wading to some of the SAX code, I started wondering if I can do this with SAX. Does anyone has some sample code, for DOM or SAX that does nothing else then replicating the xml input exactly, is that possible? Thanks in advance, Cees Wesseling From parkw at better.net Wed Jul 21 20:10:07 1999 From: parkw at better.net (William Park) Date: Wed, 21 Jul 1999 20:10:07 -0400 Subject: Repost: Re: Scientific Plotting? In-Reply-To: <7n5fhn$9e5$1@nnrp1.deja.com>; from mhuster@hotmail.com on Wed, Jul 21, 1999 at 09:54:05PM +0000 References: <379392E7.EB0F29E7@ssec.wisc.edu> <7n5fhn$9e5$1@nnrp1.deja.com> Message-ID: <19990721201007.B1050@better.net> On Wed, Jul 21, 1999 at 09:54:05PM +0000, mhuster at hotmail.com wrote: > Original reply: > > I am also trying to find an adequate *object* based plotting package. I > am writing some signal processing software and want to code plotting > into the classes I am defining. > > Some requirements: > 1) Postscript output (for inclusion in high quality Word & Powerpoint > documents) GIF, JPG, etc just do not have the resolution. They default > to 72 dpi rendering. You can overcome this on Linux using Image Magick's > convert -dens 300. The resulting files are large. If you need to print it, then you should consider PiCTeX which is a TeX macro package. > > 2) Object oriented I guess you could write python module. From my experience, plotting is impossible to standardize because of varying personal taste and need (ie. scaling, labeling, title, fonts, lines, ...) > 3) Images ?? > > Our current assessment: > > GIST: not enough flexibility in configuring the plots. It has the > Postscript we need, though. We have it coded in now for some look at the > data. But it is not the long term solution. > > Plplot: uses stroke fonts, even in postscript output. We cannot get a > uniform look with matlab produced plots. Bummer. Otherwise it looked > good. I am afraid when blown up the fonts will look even worse. For > example. To get a bold font you have to play with pen width and font > size. Isn't "Helevetica-Bold" easier to specify? Also, it is at a > developmental (& FORTRAN) deadend. No chance to change things. > > Gnuplot: Runs gnuplot through a pipe. All of the data (upto many MB) > also has to go through the pipe. Unsat. I want to plot efficiently. > > plotlib: not enough high level wrappers. I do not want to have to > calculate default axis size, where to put tick marks, etc. > > Pgplot: looks like plplot. > > Piddle & graphite: looks good, but not mature enough. We are keeping an > eye on it. Probably will try it. > > PyMat: I want to get away from needing Matlab licenses > > I am kind of bummed. If we wrap intelligent python wrappers around > something, we will post it. > > Michael Huster > mhuster at hotmail.com > > > > 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 greg.ewing at compaq.com Wed Jul 21 23:53:11 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Thu, 22 Jul 1999 15:53:11 +1200 Subject: VC++ 6.0 larger exe files explained References: <11A17AA2B9EAD111BCEA00A0C9B41793034AAC15@molach.origin.ea.com> Message-ID: <379695A7.EB1E7A6F@compaq.com> "Stidolph, David" wrote: > > This might (stress this is a pure guess) have something to do with virtual > memory and its size being 4k pages. That sounds like a pretty good guess. If Windows VM is anything like Unix, it'll want to keep the code & data in separate pages so it can share the code between processes. In the case of extremely small programs (i.e. ones whose code & init data together fit in one page), it might be better to forget about trying to share the code and just load a separate copy into each process. Mind you, Microsoft programmers have probably long since forgotten that there's any such thing as an executable smaller than about 5MB, so it's understandable that they wouldn't have thought of this... Greg From mwh21 at cam.ac.uk Sat Jul 10 19:17:32 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 11 Jul 1999 00:17:32 +0100 Subject: Simple Qu: Changing directory References: <3787D36A.815B7C29@ssec.wisc.edu> Message-ID: <7m9to1$6qg$76@rks1.urz.tu-dresden.de> Nick Bower writes: > I feel really dumb asking this question, but how do I change the current > working directory? For browsing the file system I mean. > > I've found exec commands, but these would surely be device dependent and > there doesn't seem to be anything obvious in the os or os.path > documentation. i looked through the tutorials too. > > thanks in advance, nick os.chdir? as in Python 1.5.2 (#1, May 11 1999, 11:42:00) [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> os.chdir('/') >>> os.getcwd() '/' >>> print os.chdir.__doc__ chdir(path) -> None Change the current working directory to the specified path. >>> os.chdir('~') Traceback (innermost last): File "", line 1, in ? OSError: [Errno 2] No such file or directory: '~' >>> os.chdir(os.path.expand'~') os.path.expanduser os.path.expandvars >>> os.chdir(os.path.expanduser('~')) >>> os.getcwd() '/home/mwh21' >>> HTH Michael From tismer at appliedbiometrics.com Wed Jul 21 07:43:33 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Wed, 21 Jul 1999 11:43:33 GMT Subject: How fast can we multiply? References: <001401bed345$d3934200$a72d2399@tim> Message-ID: <3795B265.195C4FAE@appliedbiometrics.com> Tim Peters wrote: > > [Tim] > >> Andrew Kuchling's wrapping gmp for Python is the most useful thing > >> that's ever been done in this area. > > [Christian Tismer] [wants to rebuild the world using nuts & bolts] > I play with & investigate bigint algorithms in Python, & I enjoy it. But > serious work in this area requires serious speed, and GMP doesn't compromise > on that -- from slaved-over assembler to low-level mutable packed storage > limbs, it's doing the right stuff for its task. Factors of 5 count here > . Agreed. Still, if we resolve to low level functions which deal with an optimized number of bits at a time (some reasonable cutoff), then the Python overhead to operate intelligently with them is (hopefully) small enough to be justified. > You do "long1 & long2" in Python, and it's handled by an all-purpose bitop > function that redispatches on the operation in each iteration of the inner > loop. It's "like that" everywhere: the bigint code was written for > compactness (longobject.c is only twice the size of intobject.c!), and > no-hassle porting to the feeblest machine on earth. The compromises have > consequences (some good! that code has been rock solid since the first > release, while it can take a week to track down all the bugfix patches to > the last official GMP release). Yes. I think this simplicity is a real advantage. The Python generalism to do the general &-code with typechecks and everything on every inner loop appears to be expensive for small objects only. If I can write algorithms in a way that they operate only above some "cutoff" level (say 5000 bit ints), this is again not expensive. ... [matmult] > OTOH, Winograd's refinement of the matmult procedure requires 15 floating > adds, where straight 2x2 matmult requires only 4; float + isn't much cheaper > than float * on many modern processors. So the win here isn't nearly as > pure as for intmult, and the reduction is only from O(n**3) to O(n**2.81) > operations anyway. There are reasons few vendors offer this form of matmult > in their libraries <0.5 wink>. 15 adds, sure. Would be expensive for a 2x2 matrix of reals. But since we recusrively apply this to 2x2 matrices of submatrices, the complexity of multiplication quickly voidens the real-processors optimization again, and we win quickly. Thinking of Jeffrey Chang's 6000x6000 matrices, what can we expect? I didn't try, but let's assume a cutoff at about 94x94 matrices, which appears fairly high for me. Jeffrey can than think of the multiplication of 64x64 matrices, where the scalars are the 94x94 matrices of above. Cost for addition of two 94x94 matrices vanishes, compared to multiplication. So Jeffrey might expect to go from 64 ** 3 == 262144 down to 64 ** ( log(7)/log(2) ) == 117649.0 which gives him a speedup factor of 2.23 . If we are more lucky, and the cutoff enables us to 47*47 matrices, the speedup will be 2.55 . And for 24*24 matrices, we end up at a speedup of 2.91 . May we expect a win for 12x12 matrices, already? It would give us a great speed gain of 3.33, but we have to guess the cutoff. Reading Knuth about that, the necessary scaling for stability implies that this techniques pay off for n >= 40, so if we are lucky, the 47*47 case above could be implemented, hopefully giving a factor of between 2and 2.5 . One concern I have, and which stops me to dig seriously into this is matrix stability. Since we are dealing with floats in the low level, the result may be impacted by more rounding errors, since more additions are involved. At least this has to be studied carefully before replacing one algorithm by another. I don't know what kind of preconditioning is necessary here, but Knuth said it is. Not so with fastlong, this is a perfect replacement. I have not further investigated if Fourier transform can be applied, and if matrix multiplication can be expressed in terms of convolutions and Fourier transforms. Multiplication of very long integers *can* be done this way. [and about Jurjen's exact math, we'll wait for volunteers] 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 chris at frostnet.advicom.net Tue Jul 13 13:29:01 1999 From: chris at frostnet.advicom.net (Chris Frost) Date: Tue, 13 Jul 1999 17:29:01 GMT Subject: MySQL Module Message-ID: <19990713122901.A2538@pooh.frostnet.net> Are than any modules for connecting to a MySQL sever? I didn't see anything in the contributed section of python.org. (If there aren't, what other databases do people think are better, why?) thanks! -- Chris Frost | -------------+------------------------------------------ Public PGP Key: Email chris at frostnet.advicom.net with the subject "retrieve pgp key" or visit -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 256 bytes Desc: not available URL: From clarkeia at logica.com Thu Jul 29 11:44:21 1999 From: clarkeia at logica.com (Ian Clarke) Date: Thu, 29 Jul 1999 16:44:21 +0100 Subject: Wrong "From:" address! References: <7npimc$l9b@romeo.logica.co.uk> Message-ID: <7npssc$p7k@romeo.logica.co.uk> Oops, Andrew Dolan didn't send this posting, I did. Please send any replies to clarkeia at logica.com. Ian. From kas at maps.magnetic-ink.dk Fri Jul 16 06:03:45 1999 From: kas at maps.magnetic-ink.dk (Klaus Alexander Seistrup) Date: Fri, 16 Jul 1999 12:03:45 +0200 Subject: Python 1.5.2 + Linux 2.0.36 == Bad Combo? Message-ID: G'day mates, I'm running Python 1.5.2 on a Linux 2.0.36 kernel (RedHat 5.1 distro partly upgraded to v5.2) and have recently experienced malfunctioning and/or non- working python applications -- specifically: * PageCast -- This one causes a Kernel Oops, though not a serious one. The author, Preston Landers, have managed to invoke a similar Kernel Oops using the same python/kernel combination. * PyGCS -- The program exits silently as soon as the second is loggin in. The author, Jeff Blaine, hasn't been able to reproduce the behaviour. I have asked Preston Landers to try out the program on his set-up but have yet to hear the results * DejaGrabber -- The program connects without problem but seems to only retrieve headers, not the full articles. Haven't contacted the author yet. I would like to hear if anybody else have experienced similar problems using the same Python / Linux kernel combination and, if so, whether is has helped shifting to another kernel version or downgrading python. Cheers, //Klaus -- ???[ Magnetic Ink ]?????????????????????????????????????????????????? ><> ??? ???[ http://www.magnetic-ink.dk/ ]??????????????????????????????????????????? From tim_one at email.msn.com Wed Jul 21 23:29:12 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 21 Jul 1999 23:29:12 -0400 Subject: Stackless & String-processing In-Reply-To: <7n4nrl$sfe$1@cronkite.cc.uga.edu> Message-ID: <001101bed3f2$5e8874a0$642d2399@tim> [Tim] > ... > If it isn't clear yet , efficiency isn't driving Graham > here. He's found a cool new approach, and is having fun with it. [Graham Matthews] > No that's not the case. OK, my mistake: you didn't find it, it's not cool, it's not new, and/or you're not having fun . > Efficiency drives all my programs *when it's a necessity*. Ack, I'm speaking English here. If efficiency isn't your *primary* concern, then efficiency isn't "driving" you. Dictionary. Look up. Efficiency is Fernando's primary concern wrt parsing approaches -- it drives him. That's how you two differ. It's important to note that efficiency really is a necessity in his applications (have you read any of his papers? no claim makes sense out of context). > My point is that using combinators: > > a) is a very nice way of structuring a parser since it is very amenable > to change and robust under change. Could well be. > b) doesn't have to cost anything in efficiency since you can freely mix > combinators with other parsing techniques. Like programming in Python doesn't have to cost anything in efficiency since you can freely mix Python with other languages? It's a true enough argument, but useless in practice unless 5% of the code accounts for 95% of the runtime. Which it often *does* in general-purpose Python apps. For parsing, it's not clear what kind of sequencing you could want that isn't already covered by the "other parsing techniques" that are presumably doing 95% of the (presumed to be) efficiency-critical computation. Have something concrete in mind? > c) is a general programming technique useful in a vast range of programs > outside of just parsing. For example I have used it for type checking > and writing a GUI. The literature has a lot of other examples of this > approach. I didn't see anyone argue against that. This thread started with string processing, and everyone else has stuck to that. > Moreover the point of combinators is not to "interweave the grammatical > structure with other computations". Combinators do do that, and I think > it's a great benefit. Expect that depends on the app: sometimes a benefit, sometimes not. I've used systems of both kinds, and neither is a pure win. > But the point is to: > > a) clearly separate sequencing code from other code. In a combinator > program the precise control flow of the program is clear. In a way deeper than it is in a functional program not using monads? IOW, is the clarity of "control flow" due to monads specifically or just to functional semantics in general? AFAIK, "combinator" hasn't sprouted a new meaning beyond its old "higher-order curried function" one. > b) allow programs to program their own sequencing combinators (rather > than providing some fixed set that the language designer hopes will > be enough. WRT parsing specifically, what kinds of desirable sequencing do you find lacking in other approaches? Any parsing framework caters more-than-less directly to juxtaposition, choice, optionality, repetition and (at least conceptual) backtracking. I understand you can model all those with combinators. What I haven't seen is an example of something clearly useful (wrt parsing specifically) *beyond* those. > ... > I have been using combinators for some time now and never noticed the > "grammar" being cluttered with all these "semantic annotations". We often see most clearly that which we hate . I saw 'em all over the place in the papers. > What annotations one requires can easily be separated from the grammar > either by sensible layout, or by the design of clever combinators that > hide semantic annotations away. I mentioned indirectly that what drives me is variously "speed or maintainability" in parsing systems. "clever" is at odds with the latter -- unless all the cleverness comes built in to the system once & for all. > ... > Combinators are very robust under change. I have a parser written using > combinators and I often tweak the grammar, without requiring large > changes to other code or the parser itself. That's encouraging! > Have you ever written a combinator based parser or are you just > "theorising"? You ask that immediately before quoting my > : I haven't tried using parser combinators, but in reading the papers ... ? Prophetic . > Ah there's the rub -- you haven't written a combinator based parser so you > your comments are just what you *think* might happen if you did. Oh yes! Parsing with combinators is a Porsche. I've driven all kinds of cars for thirty years, in various terrains and in all kinds of weather; even built a few engines from metal I smolt myself , that other people relied on. I used functional languages extensively too, although very lightly this decade. So when I read the Porsche owner's manual it's not exactly blind imagination driving my concerns. It's certainly no substitute for a test drive, though. I installed Clean with the aim of doing that, but had too much fun poking at other aspects of the system to get around to it. > I don't know where you got the idea that speed is a problem! *Can* be a problem. Fernando covered that exhaustively, and you actually haven't disgreed with his points for all your words to the contrary . I also have much other experience crafting elegant functional solutions that had to be tossed in practice for the same kinds of "can't automatically optimize a huge nest of clever higher-order applications" reasons. > For some kinds of parsing I wouldn't use combinators rather I would use > automaton techniques. But for most kinds of parsing they are plenty > fast enough. "Most" depends on what you're doing. For most things I do for fun, even SNOBOL4 was plenty fast enough (and I don't doubt for an instant that even a casually tossed-together combinator-based program is faster than that!). Half the things I do for work deal with artificial languages that are specifically designed for one-token lookahead techniques, because they're designed for peak speed over megabytes of input; the other half is parsing huge ambiguous grammars on cheap PCs via dynamic programming techniques, and there we *claw* to save bytes and milliseconds, no holds barred. Different strokes. I believe I'd enjoy combinator approaches for my own fun; I still doubt they'd be practical for my work (but I'd rather try that than continue arguing about it <0.9 wink>). > ... > Each new example in these papers requires a different combinator because ? each new example illustrates some new sequencing idea -- eg. determinisation, > coninuation, ... > The papers are illustrating the generality of the techniques, and hence > you expect to see a lot of different combinators. Yes, and I confess to over-panicking at what I indeed should have expected. > In practice however (something you wouldn't know about right?) you don't > use all these combinators. Which casts some doubt on the great utility of being able to create new ones. Parsing is an old problem. If only a handful of combinators are of actual use in parsing problems, freeze the semantics, package them in a library, and implement a pleasant parser generator on top of them . > I have written a parser for a new programming language and I used 10 > combinators (5 of which I re-used in the type checker!). > Yes you do have to build your own combinators (that's the point of the > approach!), but once done you stick them in a library and re-use them. That's fine for a one-man show. "Maintainability" in my life cuts across programmers, and it's Not Good for each person to reinvent their own basic machinery -- even to have the ability to do so. One reason I like Python is that it *doesn't* let the jerk down the hall invent their own control structures <0.5 wink>. I will give parser combinators a try; they do sound interesting to me. More interesting would be to hear about that "new programming language"! i-believe-you-can-parse-it-ly y'rs - tim From ivanlan at callware.com Mon Jul 19 18:11:34 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Mon, 19 Jul 1999 22:11:34 GMT Subject: SMTP problem References: Message-ID: <3793A296.7A0FAD18@callware.com> Hi All-- "Joacim L?wgren" wrote: > > Hi, > > I copied this straight from the Python SMTP example, however it doesn't seem > it's working. I'm not quite sure what ^D does and if it is different on > Unix/Windows as I think this is the problem with the script. > 1) It appears that you're on Windows, so you would use ^Z (control-z) instead of ^D. In either case, the function of the control character is to indicate the end-of-file, which tells the SMTP script you're done typing your message and that it should be sent. 2) Since you're on Windows, and windows doesn't have any native SMTP processing abilities, you'll need to replace 'localhost' in the example program with the name of your mail server. If netlimit.com is your host, then it is possible that you'll have a mail server at 'mail.netlimit.com' -- but I would check with your IS people to make sure, as you need a mail account on the server in order to be able to send and receive mail. 3) If I'm mistaken and you really are on UNIX, then you need to make sure that the system you're running this script on has an SMTP server/sendmail daemon running. If not, the script won't work, since it's hard-coded to your localhost. -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.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 aahz at netcom.com Fri Jul 30 11:06:56 1999 From: aahz at netcom.com (Aahz Maruch) Date: 30 Jul 1999 15:06:56 GMT Subject: Need help with TCP/IP client access from Windows References: <1278839420-22085362@hypernet.com> <19990730005211.T7149@thyrsus.com> Message-ID: <7nsf2g$ifp@dfw-ixnews11.ix.netcom.com> In article <19990730005211.T7149 at thyrsus.com>, Eric S. Raymond wrote: >Gordon McMillan : >> >> Probably better just to have a default file, and let the user >> override that if need be. Which may well never happen. > >OK, but where to put it? I don't know what the conventions are. I'd stick it in the directory your script is in. That's pretty standard for Windoze. In fact, I'd make it ".ini". -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From amaranda at nospam.com Thu Jul 1 10:41:27 1999 From: amaranda at nospam.com (Alex Maranda) Date: Thu, 01 Jul 1999 15:41:27 +0100 Subject: Python suitable for a game engine? References: Message-ID: <377B7E17.5BD7@nospam.com> > 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. you use confusing terms; I understand what you're saying, but you shouldn't use the word 'thread' for anything else than its OS meaning. You could say the 'the bulk of processing'. You might very well end up using real Python threads; don't forget in this case to release/reaquire the global interpreter lock in your C++ callbacks, if you make blocking syscalls (unlikely in a game). > > 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? Unlikely. You won't know until you try. To my knowledge UnrealScript is eventually translated to C++. > - 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? ?? 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 gmcm at hypernet.com Mon Jul 19 12:42:13 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Mon, 19 Jul 1999 11:42:13 -0500 Subject: Problems with PyRun_SimpleFile() In-Reply-To: <379336D5.799D83E0@gmx.net> Message-ID: <1279723778-5524667@hypernet.com> Markus Ewald writes: > Excuse this dumb question, Not dumb, just very frequent. > but how can I use PyRun_SimpleFile() ? > I'm using VC6 on Win98, where I've declared some simple functions > for testing. > > Well -- everything works fine when I use PyRun_SimpleString(). > > If I put the same lines I gave PyRun_SimpleString() in a File and > then use PyRun_SimpleFile() to execute it, I get an access > violation. Make sure you have linked your stuff against the exact same run time as python15.dll. In other words, choose "Multithreaded DLL". NOT "Debug Mulitthreaded DLL" or any other choice. - Gordon From tim_one at email.msn.com Mon Jul 26 22:13:32 1999 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 26 Jul 1999 22:13:32 -0400 Subject: Newbie question In-Reply-To: <379d0ee6@news.gci.net> Message-ID: <000c01bed7d5$a0a92c80$eea22299@tim> [Arnaldo] > I'm just trying out some examples from the book Learning Python and I run > into a exercise that is not working for me. > It's on page 95 , exercise 4b. > This is the answer the book has > =========================================== > l = [1, 2, 4, 8, 16, 32, 64] > x = 5 > i = 0 > while i < len(l): > if 2 ** x == l[i]: > print 'at index', i > break > i = i + 1 > else: > print x , 'not found' > ============================================ > > When I run this , python hangs. When I do Ctrl-c , this is what I get > Traceback (inntermost last): > File "powera.py, line 5, in ? > if 2 ** x == l[i]: > > What am I doing wrong? What do you *think* could be going wrong? The program appears to be running forever. How could that happen? Even if 2**x==l[i] is never true, the loop is supposed to end as soon as "i < len(l)" is false. So how can "i < len(l)" always be true? Bad hint: The code above is not the answer the book gives -- although it's close. an-hour-of-thinking-will-save-10-seconds-of-reading-ly y'rs - tim From dalke at bioreason.com Sun Jul 11 02:47:39 1999 From: dalke at bioreason.com (Andrew Dalke) Date: Sun, 11 Jul 1999 00:47:39 -0600 Subject: code coverage Message-ID: <37883E0B.D956F029@bioreason.com> Hello, After the discussion a couple weeks back about code coverage utilites for Python, I decided to look into them because I want to ensure that our regression tests really do execute all (or at least most) of the code in our packages. The two mentioned in the thread were: trace.py - http://www.musi-cal.com/~skip/python/trace.py by Skip Montanaro pycover - ftp://ftp.python.org/pub/python/contrib/All/pycover-0.1.tar.gz by Andrew Csillag Neither of these fit my needs, so I ended up highly modifying trace.py. For those interested, the new version is at ftp://starship.python.net/pub/crew/dalke/trace.py I would appreciate people taking a look at it and testing it out; It's in a pretty complete state, but needs review and suggestions for improvements. The major features I added are: a more extensive command-line interface using getopt and reporting a full --help message support for packages. trace.py would use only basename of the __file__ when generating a coverage log. Thus, if there were two submodules with the same name, one would overwrite the other. Now the results are saved to the file named __name__ + '.covered' able to exclude coverage on a module based on its __file__ and/or on its __name__ (so you can exclude all the system modules using sys.prefix). pycover, for example, has built-in exclusion of /usr/local, which isn't always appropriate for our installs. a big problem I had with both of the coverage programs was they didn't do a very good job at telling me what executable lines were not covered. For example, one of my test scripts is: ===== import daylight.Smiles def main(): mol = daylight.Smiles.smilin("COON") if len(mol.atoms) > 9: print "Hello" #pragma: NO COVER print "there" else: print "Small" print mol.cansmiles() if __name__ == "__main__": main() ===== when run through pycover, the un-executed lines start with a '!' ====== > import daylight.Smiles > def main(): > mol = daylight.Smiles.smilin("COON") > if len(mol.atoms) > 9: ! print "Hello" #pragma: NO COVER ! print "there" ! else: > print "Small" > print mol.cansmiles() > if __name__ == "__main__": > main() ====== As you see, the "else:" is marked as unexecuted, and it always will be even if both branches of the if statment are taken, because else generates no SET_LINENO instruction. The basic problem is in determining if a line should have been executed or not, and the programs do it by looking for non-empty, non-comment ("""detection of multiline quotes is also a problem for these two programs""") Now, nearly exery executable line, when compiled for the PVM, contains code listing the line number. So I wrote some code (based on dis.py) to disassemble a module's code objects, look for the SET_LINENO, and use those numbers to tell which executable lines haven't been covered. This trick doesn't work for everything, but is better than nothing. So, if you want, please take a gander at the code, at ftp://starship.python.net/pub/crew/dalke/trace.py Andrew dalke at bioreason.com From chris at frostnet.advicom.net Wed Jul 21 09:46:14 1999 From: chris at frostnet.advicom.net (Chris Frost) Date: Wed, 21 Jul 1999 08:46:14 -0500 Subject: Merging two lists as a dictionary In-Reply-To: <19990721153539.S6170@xs4all.nl>; from Thomas Wouters on Wed, Jul 21, 1999 at 03:35:39PM +0200 References: <19990720211946.A12202@pooh.frostnet.net> <19990721153539.S6170@xs4all.nl> Message-ID: <19990721084614.C15502@pooh.frostnet.net> On Wed, Jul 21, 1999 at 03:35:39PM +0200, Thomas Wouters wrote: > >>> keywords = ['s','p','a','m'] > >>> values = ['eggs', 'ham', 'toast', 'omelet'] > >>> result = {} > >>> for i in range(min(len(keywords), len(values))): > ... result[keywords[i]] = values[i] > ... > >>> result > {'m': 'omelet', 's': 'eggs', 'p': 'ham', 'a': 'toast'} > > the 'min()' is unecessary if you are 100% certain the lists are same length, > or if you know which list will be the shorter one. (iter over the shortest > one, in that case) Great, that works better than my error checking method. -- Chris Frost | -------------+------------------------------------------ Public PGP Key: Email chris at frostnet.advicom.net with the subject "retrieve pgp key" or visit -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 256 bytes Desc: not available URL: From balaji at platinum.com Tue Jul 6 17:14:52 1999 From: balaji at platinum.com (b s) Date: 06 Jul 1999 17:14:52 -0400 Subject: popen2 on Windows References: <4D0A23B3F74DD111ACCD00805F31D8100DB90EC1@RED-MSG-50> <87hfnit1tc.fsf@linux01.prc.tno.nl> Message-ID: John van der Koijk writes: All these things will work only if your application is a console application. If a service is trying to spawn a child process and you want to capture the output in the parent and wait for childs termination (by getting an EOF on the read end of the pipe), it gets a little more complicated. check out "Creating a Child Process with Redirected Input and Output" in the MSDN. It is not completely working, but gives you the mechanics of the equivalent of popen(). |"BT" == Bill Tutt writes: | | >> After coping with my initial frustration, I've decided to make | >> an unthreaded stub program talking to the DDE client, using | >> popen2 to do the IPC with the GUI and controller | >> program. Sadly, this approach also does not seem to work, | >> because using popen2 gives me: | >> | >> [....] os.fork() AttributeError: fork | >> | >> This is amazing, since the manual for 1.5.2 says: | >> | >> 8.13 popen2 -- Subprocesses with accessible standard I/O | >> streams | >> | >> Availability: Unix, Windows. | >> | | BT> Well, its wrong. :) Windows doesn't have fork(). | | BT> The win32pipe module exposes popen2() that does what you want | BT> it to do, however you need to avoid a bug in Win9x. The | BT> knowledge base article at: | BT> http://support.microsoft.com/support/kb/articles/q150/9/56.asp | BT> covers what you need to do to avoid this dilemma. | |Wow. I'm completely flabbergasted... | |I have realised that I could also use a socket interface. Works great, |and speed is not one of my concerns, right now. | |Thanks, |-- |John van der Koijk. |-- |TNO Institute of Industrial Technology | |PO Box 5073, 2600 GB, Delft, The Netherlands From mstenber at cc.Helsinki.FI Tue Jul 27 23:41:52 1999 From: mstenber at cc.Helsinki.FI (Markus Stenberg) Date: 28 Jul 1999 06:41:52 +0300 Subject: Python Performance References: <3794C642.AB6A3E5D@freenet.co.uk> <7n5f0c$snu$1@ffx2nh5.news.uu.net> <14236.32616.980578.536614@dolphin.mojam.com> <379D89BC.DA91BA8C@hp.com> <14237.60407.130426.461846@dolphin.mojam.com> <14238.335.458728.140169@lrz.de> <14238.1372.334823.378192@dolphin.mojam.com> Message-ID: Skip Montanaro writes: > Eugene> Skip Montanaro writes: > >> True. I was thinking about the situation I'm in (small developer, a few > >> machines to maintain/upgrade/replace). > > Eugene> What's wrong with recoding the hot spots in C? Python is > primarily a rapid prototyping/scripting/glue language, it was never > meant as a sole implementation language for applications. > There's nothing wrong with recoding hot spots in C. Many people do it all > the time. Practically speaking, however, many Python users don't have the > technical depth or other resource (VC++, for instance) to write chunks of > their applications in C or C++. That isn't (IMNSHO) the greatest problem; for me, main problem lies in the fact that when you bring C/C++ to bear, you lose most of the 'totally portable'-characteristics of normal Python code and get to test same program on multiple platforms to see if the C/C++ extensions work as advertised there, etc. Generally speaking, when developing Windows-Python programs, you can do development mostly on UNIX and *poof*, it works on Windows. On the other hand, try porting say, C/C++-based socket programs from UNIX to Windows.. *brr* > Skip Montanaro | http://www.mojam.com/ > skip at mojam.com | http://www.musi-cal.com/~skip/ > 847-475-3758 -Markus Stenberg -- Linux! Guerrilla UNIX Development Venimus, Vidimus, Dolavimus. From mstenber at cc.Helsinki.FI Thu Jul 29 03:30:39 1999 From: mstenber at cc.Helsinki.FI (Markus Stenberg) Date: 29 Jul 1999 10:30:39 +0300 Subject: HPUX and threads? References: <000b01bed969$f5b62120$71a22299@tim> Message-ID: "Tim Peters" writes: > [Markus Stenberg] > > Is HPUX-11 thread support tested/implemented/whatnot? > > You may want to ask on the Thread-SIG if you don't get an answer here. > > > This at least does not look promising.. > > > > # /opt/python/bin/python > > pthread_mutex_init: Invalid argument > > Memory fault(coredump) > > > > (also tests failed with the same message, obviously) > Are you running pthreads? Python is sure trying to . I am totally clueless as to C-based threads in general and pthreads in particular. There are manual pages for pthread* things, and the library, thus, I suppose I am. > The msg is coming from line 263 of Python/thread_pthread.h. It means the > platform's > > status = pthread_mutex_init(&lock->mut, > pthread_mutexattr_default); Manual page says this.. wonder what lock->mut is, hopefully this type ;) int pthread_mutex_init( pthread_mutex_t *mutex, const pthread_mutexattr_t *attr ); > returned a non-zero (failure) status. "Invalid argument" is what the > platform perror() produced. A coredump after an error here isn't > surprising. > > This is likely the first call made to any pthreads function, and is so > vanilla that I'd guess pthreads itself doesn't work on your platform (does > it from C?), or it's some non-std pthreads variant that thread_pthread.h > doesn't know about. Seems like non-std pthreads variant that thread_pthread.h doesn't know about (see my other post). > not-that-insight-implies-a-cure-ly y'rs - tim -Markus -- We are Pentium of Borg. Division is futile. You will be approximated. From kernr at mail.ncifcrf.gov Fri Jul 2 18:11:38 1999 From: kernr at mail.ncifcrf.gov (Robert Kern) Date: Fri, 02 Jul 1999 22:11:38 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> <3A174E56AD89F7F6.47941772B9D545B9.852EB0CCFCA68614@lp.airnews.net> <377B711A.E8B65E0B@cfdrc.com> <377BC620.F5553FF5@easystreet.com> <14204.4556.177837.851763@lrz.de> Message-ID: <377d35d7.3612161@news.erols.com> On Thu, 1 Jul 1999 23:16:00 -0500, Travis Oliphant wrote: > >This has been a very interesting discussion on GUI's. > >It struck me that all this talk of a cross-platform GUI might be >preventing a lot of very good GUI's from being used. > >So, I looked in to PyGtk and PyGnome (with its Gnome Canvas) and I'm >impressed. Right now it fits what I want to do very well and it works on >systems with an X server (aren't X servers available for MAC's and >Windows?) Not for free. Well, Microimage's X server, MI/X, is freely avialable for Windows and Mac, but it's only approximately X11R5 compliant (http://www.microimages.com/freestuf/mix/mix.htm). PyGTK and PyGnome are unlikely to work with it satisfactorily. Heck, tkinter doesn't work satisfactorily with it. Starnet does have an X11R6 server for Windows for which they give away a free demo that has a 2 hour time limit per run, although it can be restarted again. (http://www.starnet.com/demo.htm) There is a project in progress to port XFree86 to Windows with the Cygwin tools. Everything compiles now; we just need to wait a little before it runs. :-) GTK+ for Windows (http://www.gimp.org/~tml/gimp/win32/) still hasn't had enough of the libraries ported to compile PyGTK. This could change soon, though. >So, I'm happy with it. If you're in the same situation you >might like it too. I tend to agree that there is plenty of room for more >than one GUI. > >Travis Oliphant 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 gmcm at hypernet.com Wed Jul 14 09:14:37 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 14 Jul 1999 08:14:37 -0500 Subject: Recursive method In-Reply-To: <378C214F.3CF9CDD3@eml.villa-bosch.de> Message-ID: <1280168234-10452044@hypernet.com> Ralph Gauges wrote: > Hans Nowak wrote: > > You have a nested function here. (I say function, because it does not > > look like a method... it's missing the self argument! > > Actualy it is a method, but JPython doesn't seem to have a > self. I was missing that as well. JPython 1.0b3 on jdk1.1 Copyright 1997-1998 Corporation for National Research Initiatives >>> class A: ... def foo(self): ... print `self` ... >>> a = A() >>> a.foo() <__main__.A instance at 111> >>> Nothing missing. > > > > So, to solve this, you could try a different approach... maybe > > > > (you said it's a method, right?) > > > > class Blahblah: > > ... > > def makeTree(self): > > .... > > def makenodes(self, C): > > .... > > > > > > I tried that as well, but I got the same error message. Only > after I moved the makenodes outside the class it worked. Also from JPython: >>> class A: ... def foo(self, seq): ... if seq: ... print seq[0] ... self.foo(seq[1:]) ... >>> a = A() >>> a.foo([1,2,3]) 1 2 3 >>> No problem with recursion. You've made some other error for which you'll kick yourself when you finally see it ! - Gordon From Georg.Mischler at p98.f112.n480.z2.fidonet.org Fri Jul 2 05:32:48 1999 From: Georg.Mischler at p98.f112.n480.z2.fidonet.org (Georg Mischler) Date: Fri, 02 Jul 1999 10:32:48 +0100 Subject: Python GUIs: Portability or not? Message-ID: <0000165e@bossar.com.pl> From: Georg Mischler Mikael Lyngvig wrote: > Travis Oliphant wrote: > >[...] > >So, I looked in to PyGtk and PyGnome (with its Gnome Canvas) and I'm > >impressed. Right now it fits what I want to do very well and it > >works on systems with an X server (aren't X servers available for > >MAC's and Windows?) > > I don't know about the Mac, but I'm sure there are X servers available > for NT. However, not like they are available for Linux and other Unix > boxes - you don't just download the X11 source, compile it, and that's > it (unless a lot has changed the last few years). > > You'd probably have to buy a commercial X server for NT or, even > worse, ask your users to do so. Have a look at http://www.microimages.com/www/html/freestuf/mix/. This is a free X sever for both the mac and NT. It works pretty well for what it is. But if you have a choice, and assuming that you plan to work with X and non-X applications at the same time, then you probably want a native GUI for your application. There are other X servers around, but those who blend into the host GUI (instead of creating their own X desktop within a window) all seem to be commercial. Now *this* would be a task for an open software project... ;) 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 bwarsaw at cnri.reston.va.us Fri Jul 30 18:39:23 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Fri, 30 Jul 1999 18:39:23 -0400 (EDT) Subject: DCPIGgies Get Together Message-ID: <14242.10651.804230.338090@anthem.cnri.reston.va.us> Notice to all Washington DC area Python users: We are pleased to be resurrecting the DC area Python interest group meetings, now called DCPIGgies. We will be having our first meeting at CNRI in Reston, Virginia on Tuesday August 31, 1999 from 7:30pm to 9:30pm. The aim is to keep this meeting pretty technical. To that goal, we're going to have two exciting presentations. For the first hour, the Digital Creations guys will be giving a talk on Zope 2.0's unique object model (acquisition, run-time classes, transactional objects, etc.) including how Python programmers might use this in their own non-Zope projects. In the second hour, Andrew Kuchling will be talking about something XML-ish, probably processing the Open Directory Project's (www.dmoz.org) RDF dumps. There will be question and answer periods after each talk, and we may have an "open phones" going later than 9:30 if there's interest and if Guido or I am still awake. :) Pizza, salad, and soda will be provided. We are asking for a voluntary $5 donation at the door to cover the costs of food. It is very important that you RSVP by email to bwarsaw at cnri.reston.va.us so that I can get an accurate head count (otherwise you may go hungry!). We also need to make sure that we can fit everyone into our conference room, so let me know if you're coming, even if you aren't going to eat. Directions to CNRI can be found on the Web: http://www.cnri.reston.va.us/directions.html See you then! -Barry From arcege at shore.net Sat Jul 10 06:20:10 1999 From: arcege at shore.net (Michael P. Reilly) Date: Sat, 10 Jul 1999 10:20:10 GMT Subject: console show in Python? References: <378626CF.9495FAB0@mry.rbd.com> Message-ID: Scott Shillcock wrote: : I am moving to Python from Tcl/Tk. : Is there something similar to the Tcl/Tk 'console show' command in : Python. : I am using Tkinter for my gui and once I call mainloop() I no longer : have access to the Python command line. I want to be able to interact : with my gui from the command line to test new code. : From Tcl/Tk I could turn on and off the interactive command line with : 'console show' and 'console hide'. That is all I want to do with Python. : Can anyone help me with this or point me in the right direction. On UNIX anyway, if you use the quit() method from the mainloop, then you can restart from Python's interactive prompt by calling the mainloop() method again. The code for Tkinter should make this behavior consistant on all platforms, but has anyone tested this there? -Arcege From arcege at shore.net Mon Jul 12 16:13:53 1999 From: arcege at shore.net (Michael P. Reilly) Date: Mon, 12 Jul 1999 20:13:53 GMT Subject: DOC BUG: os.chdir() (was Re: Simple Qu: Changing directory) References: <3787D36A.815B7C29@ssec.wisc.edu> <3787D8DA.3774AA7D@ssec.wisc.edu> <7m8p7t$o7s@dfw-ixnews10.ix.netcom.com> <3787FB51.12FE0048@ssec.wisc.edu> <7m923i$dem@dfw-ixnews5.ix.netcom.com> <14217.63931.75257.566266@weyr.cnri.reston.va.us> <7md2ip$19q2$1@nntp6.u.washington.edu> <14218.7724.879301.831590@weyr.cnri.reston.va.us> Message-ID: <50si3.1643$6M6.541997@news.shore.net> Fred L. Drake wrote: : Donn Cave writes: : > For what it's worth, me too: current working directory is a process : > setting. It's relevant to files and directories, to be sure, but whoever : > put chdir() and getcwd() in process parameters knew what he was doing. : I am vindicated! For what it's worth, I'm with you both. -Arcege From guido at CNRI.Reston.VA.US Sat Jul 10 10:21:55 1999 From: guido at CNRI.Reston.VA.US (Guido van Rossum) Date: Sat, 10 Jul 1999 10:21:55 -0400 Subject: builtin sequence subscript patch In-Reply-To: Your message of "Fri, 09 Jul 1999 08:42:27 EDT." <199907091242.IAA07794@northshore.shore.net> References: <199907091242.IAA07794@northshore.shore.net> Message-ID: <199907101421.KAA04351@eric.cnri.reston.va.us> > Someone posted that a class instance, with a __int__ method, could not > be passed as a subscript of a built-in sequence. I think this is a bug > since the build-in insert method of list can take a like object > correctly. > > I'm enclosing a patch to correct this, based on the latest CVS code. > I'll post the code to the newsgroup as well. Michael, thanks for your patch. It solves your problem. But it creates a new problem for me: you can now use floating point numbers as list indices and it will truncate them. I don't like this feature, and I'm worried that it will be hard to remove once it's there. So I think it's better to use int() to cast your list indexing arguments when you want to support objects with __int__ methods. In Python 2.0, I want to change the __int__ interface into two different ones: one that converts an existing integer-like value to a real int, and one that tries to convert any (non-complex) numerical value to a nearby integer. Then list indices will use the former conversion, and you will be able to do what you want without an int() cast yourself. (And yes, I know that the insert() method sets a precedent, but I don't want to move any further until I have the interface that lets me do what's right!) --Guido van Rossum (home page: http://www.python.org/~guido/) From jam at p98.f112.n480.z2.fidonet.org Thu Jul 1 13:10:34 1999 From: jam at p98.f112.n480.z2.fidonet.org (jam) Date: Thu, 01 Jul 1999 18:10:34 +0100 Subject: please help with simple regex Message-ID: <0000164a@bossar.com.pl> From: jam On Fri, Jul 02, 1999 at 12:35:51AM +0000, viofis at my-deja.com wrote: > > I'm a beginner at Python, so this may be a stupid question: > > I have a string, for example, myString="the Potato". > 1. Convert it to all lowercase ("the potato") > 2. Match it against a list of strings - "potato,tomato,corn,etc...", > extract "potato" (if it matches with something on the list), then save > into myNewString. > > Any help is greatly appreciated. > > thanks, > Vadim > hi. I don't quite understand what it is you are trying to do. if you want to take a string and find out if it contains some other string, you probably don't need to worry about regular expressions at all. what kind of problem are you trying to solve? do you 'need' to use a specific solution for some reason? I tried this: [~] [9:02pm] [jam at toast-pts/6] % python Python 1.5.2 (#1, Apr 18 1999, 16:03:16) [GCC pgcc-2.91.60 19981201 (egcs-1.1.1 on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import string >>> buf = "The Carrot" >>> validveggies = ("carrot", "corn", "spam") >>> buf = string.lower(buf) >>> for w in string.split(buf): ... if w in validveggies: ... print "valid veggie '%s' found." % (w) ... valid veggie 'carrot' found. does that help? regards, Jeff -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From wolford at enews.nrl.navy.mil Thu Jul 8 12:49:12 1999 From: wolford at enews.nrl.navy.mil (Scott Wolford) Date: Thu, 08 Jul 1999 12:49:12 -0400 Subject: Python and Fortran code References: <7m23i3$ktr$1@bignews.shef.ac.uk> Message-ID: <3784D688.A6541F39@enews.nrl.navy.mil> Look at a combination of the SWIG tool (I can't remember where it's at but it stands for Simplified Wrapper Interface Generator so you can search for it) and a C wrapper for you fortran function. Basically, make it so you can call the fortran from C. Then swig the C function and link the cstuff.o and fstuff.o with cstuff_wrap.o (from SWIG) into a shared library then you can follow choice 2 from the other response to this post. Scott Jose L Gomez Dans wrote: > Hi! > I have a quetion on using python to do some simple processing on > some data I pre-process with some Fortran code. I wanted to be able to call > this subroutine from within python, as it is already "tried and tested" and > optimized. Basically, my subroutine looks like this: > > subroutine ex1(exdata) > dimension exdata(256,200) > print*,'Doing some processing in FORTRAN' > C We said we were doing some processing, so we might as well do it :) > C Processing of exdata > return > end > > This subroutine would need to get input from the user and would also > need to print stuff out for the user to see several parameters as the > software runs. I'd like to pass exdata as a Python object (NumPy array > object), and then recover it with the results. I wonder if I could somehow > do that compiling this subroutine as an object file and then calling it from > python (not that i know how to do it, but with scilab, it works :D). > > If it's of any use, I am using Debian GNU/Linux and g77. And using > loads of complex numbers :)))) > > Thanks in advance! > Jose > > -- > Jose L Gomez Dans PhD student > Radar & Communications Group > Department of Electronic Engineering > University of Sheffield UK From donn at u.washington.edu Mon Jul 12 11:45:29 1999 From: donn at u.washington.edu (Donn Cave) Date: 12 Jul 1999 15:45:29 GMT Subject: DOC BUG: os.chdir() (was Re: Simple Qu: Changing directory) References: <3787D36A.815B7C29@ssec.wisc.edu> <3787D8DA.3774AA7D@ssec.wisc.edu> <7m8p7t$o7s@dfw-ixnews10.ix.netcom.com> <3787FB51.12FE0048@ssec.wisc.edu> <7m923i$dem@dfw-ixnews5.ix.netcom.com> <14217.63931.75257.566266@weyr.cnri.reston.va.us> Message-ID: <7md2ip$19q2$1@nntp6.u.washington.edu> "Fred L. Drake" writes: | Aahz Maruch writes: |> I think I understand how it happened: os.getcwd() is (probably |> rightfully) documented there, so someone thought os.chdir() belonged |> there, too. AFAICT, that's the only mistake in that area of the docs, |> though I could make a case that os.getcwd() should be moved (or at least |> have a pointer in "F&D"). | | Aahz, | Are you saying that (either of) these are in the wrong place? The | notion of "current directory" is tied only to the entry in the process | table; should it be documented otherwise? | The "Process Parameters" section contains functions with provide any | direct access to the process table entry, both queries and changes, so | I think it really is the right place for these two functions. | I can easily add a textual reference to the right place within the | "Files and Directories" section, but you'll need to explain very | clearly why the descriptions should be moved. For what it's worth, me too: current working directory is a process setting. It's relevant to files and directories, to be sure, but whoever put chdir() and getcwd() in process parameters knew what he was doing. Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From a.eyre at optichrome.com Mon Jul 19 08:39:43 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Mon, 19 Jul 1999 12:39:43 GMT Subject: [Q] Type checking... In-Reply-To: <7mv000$sun$1@feed.teaser.fr> References: <7mv000$sun$1@feed.teaser.fr> Message-ID: <000401bed1e3$c70caa70$3acbd9c2@peridot.optichrome.com> > class ClassA > ... > > > class ClassB : > def myMethod(self, anInstance) if anInstance.__class__ != ClassA: raise "Oh no!" This won't work for other classes derived from ClassA, however. To do that, check out: anInstance.__class__.__bases__ There may also be some cunning library hack to do this automatically. From vaton at postoffice.pacbell.net Mon Jul 26 17:38:15 1999 From: vaton at postoffice.pacbell.net (Rob) Date: Mon, 26 Jul 1999 14:38:15 -0700 Subject: Python and Red Hat Linux 6 Message-ID: <379CD547.22A10A50@postoffice.pacbell.net> When programming in Perl or Python, I am using a header like the following on an executable file to cause the shell (bash or csh) to run the scripts as Perl/Python files: #!/usr/bin/perl for Perl and #!/usr/bin/python for Python. I've checked and the compilers are located in the appropriate directories. I keep getting this when I run scripts: bash: