From linuxqna at chollian.net Mon Oct 23 09:20:46 2000 From: linuxqna at chollian.net (junwon,Seo) Date: Mon, 23 Oct 2000 22:20:46 +0900 Subject: In poplib, How can I get only recent message number? Message-ID: <8t1dof$2v7$1@news2.kornet.net> Hi, Using poplib, can I get 'recent' flags setted message number? From speed at ?.com Thu Oct 26 09:28:27 2000 From: speed at ?.com (Jake Speed) Date: Thu, 26 Oct 2000 13:28:27 -0000 Subject: popen2.popen2,3,4 from Python 2.0 on NT 4.0 SP5 References: <39F767B2.266F4965@home.com> Message-ID: paul.moore at uk.origin-it.com (Paul Moore) wrote in : >But to summarise, close the stdin pipe before reading from the stdout >pipe. (Actually, in this case, if you aren't writing anything to >stdin, why use popen2 at all?) If you just use popen(cmd, "r"), won't it take stdin from the console? I suppose you could use "echo | sqlplus user/pass @file"... ...or "rem | sqlplus user/pass @file" for Windows. -Speed! From kalle at gnupung.net Thu Oct 26 10:02:13 2000 From: kalle at gnupung.net (Kalle Svensson) Date: Thu, 26 Oct 2000 16:02:13 +0200 Subject: 64-bit ints <-> PyLongs? Message-ID: Hi. I'm writing a wrapper around a C library where some functions return, or expect as arguments, 64-bit ints. Will PyLong_*LongLong work on win32 (and preferably Mac too), and is LONG_LONG guaranteed to be at least 64 bits? If not, any suggestions on how to convert between 64-bit ints and PyLongs at least semi-portably (gcc and win32)? TIA, Kalle -- Email: kalle at gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) Not signed due to logistical difficulties (I'm not at home). If you doubt the authenticity of this message, please tell me. From kern at caltech.edu Sun Oct 29 08:25:01 2000 From: kern at caltech.edu (Robert Kern) Date: Sun, 29 Oct 2000 21:25:01 +0800 Subject: DLL-building griefs References: Message-ID: <8tj0jk$kv4@gap.cco.caltech.edu> In article , "Niki Spahiev" wrote: > 29.10.2000, 15:08:07, Will Ware wrote: > > WW> I'm trying to build a DLL (previously using Cygwin, now using Mingw) > WW> for a Python module. My batch file looks like this: > > WW> gcc -Ic:\Python20\Include -c foo.c echo EXPORTS >> foo.def WW> nm > foo.o | grep " T _" | sed "s/.* T _//" >> foo.def WW> dllwrap --def > foo.def --base-file foo.base --output-exp foo.exp \ WW> --dllname > foo.dll foo.o > > WW> During the execution of dllwrap.exe, I get complaints that various > WW> functions are undefined: PyArg_ParseTuple, Py_BuildValue, and WW> > Py_InitModule4. As a result, the DLL never gets built. > > WW> My experience with Unix while building .so files has been that the > WW> linker is willing to assume that these references would be resolved > WW> when the .so file was invoked by, say, being imported by Python. WW> > Is it possible for references to remain unresolved during the build WW> > process in Windows, or is this a fatal flaw in everything Windows-ish? > > These are in pythonXX.dll so you should include puthonXX.lib for linker > to be happy. Well, not quite. You need to create an import library for python20.dll . python20.lib is the MSVC import library, but you need a mingw32 import library. Someone said that the script I provided for getting the symbols from python15.lib and making the DEF file for the 1.5.2 import library didn't catch all of the symbols from python20.lib . He tried the "hacked" version of pexports (available from my Starship cabin) and got it to work. Some of the Python 2.0 headers may need to be patched like the 1.5.2 headers were patched by Paul Sokolovsky. Good luck. -- Robert Kern kern at caltech.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." From kuncej at mail.conservation.state.mo.us Wed Oct 18 11:21:40 2000 From: kuncej at mail.conservation.state.mo.us (Jeff Kunce) Date: Wed, 18 Oct 2000 10:21:40 -0500 Subject: Overloaded Constructor References: <8sjj0v$7mb$1@nnrp1.deja.com> Message-ID: > How can I use overloaded constructor in Python? > Such as > > class myClass: > def __init__(self): > dosomething() > def __init__(self,any_var1,any_var2): > dosomething_with_any_varx() > You could use multiple "constructor functions" external to the class: class myClass: def __init__(self): dosomething_that_always_must_be_done() def myClassA(self): mc = myClass() mc.dosomething() return mc def myClassB(any_var1,any_var2) mc = myClass() mc.dosomething_with_any_varx(any_var1,any_var2) return mc If you combine this approach with optional/keyword arguments in __init() (as suggested by others), you can provide a lot of options. --Jeff From Webmaster at everywhere.com Tue Oct 3 21:55:05 2000 From: Webmaster at everywhere.com (Webmaster at everywhere.com) Date: Tuesday, 03 Oct 2000 19:55:05 -0600 Subject: FFA Links . 72245 Message-ID: <03100019.5505@everywhere.com> Posting your site to a free links page will give you more exposure and hits. There is no cost, and the rewards are tremendous. Every extra web site that is linked to yours will increase your exposure on search engines. It is even fun to look through the other posted links from other people. Post your site for free at: http://dss311.netfirms.com/cgi-bin/clinks/main.cgi UVS From mfletch at tpresence.com Tue Oct 17 21:24:20 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Tue, 17 Oct 2000 21:24:20 -0400 Subject: String adding. Message-ID: Python tries not to do "magic" stuff when you add variables (since people often expect magic to do different things depending on intention, rather than anything in the code). Use string formatting (my recommended practice, not that my recommending anything means much), which is a very powerful mechanism in Python inherited from C: '<%s>'% (intName ) or, if that's too weird for you, use the built-in function str to convert to a string representation before adding: '<' + str( intName) + '>' (see also: hex, oct, int, float, long, string.atoi, string.atof, string.atol) HTH, Mike -----Original Message----- From: Mark Cunningham [mailto:mcunni01 at uoguelph.ca] Sent: Tuesday, October 17, 2000 9:18 PM To: python-list at python.org Subject: String adding. i know doing: strName = 'wow' '<' + strName + '>' will give you but what about: intName = 3 print '<' + intName + '>' this gives me some illegal argument type for built-in operation.. how would i make it give me <3>???? -- http://www.python.org/mailman/listinfo/python-list From ge at nowhere.none Mon Oct 2 11:06:12 2000 From: ge at nowhere.none (Grant Edwards) Date: Mon, 02 Oct 2000 15:06:12 GMT Subject: serial communication References: <39D4C491.A77C8CB9@tellurian-inc.com> Message-ID: In article <39D4C491.A77C8CB9 at tellurian-inc.com>, Blaine Lee wrote: > >I am having trouble understanding how to control a serial port. >I am communicating with a couple different devices on serial >ports. One of the devices uses a protocal that does not end >with a lf, therfore I think I am having a problem with >buffering. Probably. >On a side note, I cannot find documentation for termios on my >Debian linux system. Would it help if I found it? Probably. You might want to read the Linux Serial-Programming-HOWTO. Then if you use the posix open/read/write calls instead of the Python ones, everything in the SP-HOWTO will apply directly. If you use the Python open/read/write calls, you've got two layers of buffereing: one in the Linux tty driver, one in the python file object implimentation. If there's an easy-to-use Python wrapper for Unix serial ports/termios stuff, I haven't stumbled across it. So I just use the posix calls and do things the same way I would in C. -- Grant Edwards grante Yow! I think my CAREER at is RUINED!! visi.com From aahz at panix.com Thu Oct 5 23:25:43 2000 From: aahz at panix.com (Aahz Maruch) Date: 5 Oct 2000 20:25:43 -0700 Subject: Are there Python code for a FIFO-like structure? References: Message-ID: <8rjgnn$3ov$1@panix3.panix.com> In article , Huaiyu Zhu wrote: > >I need something like a fifo, inplemented in a fixed length list, like a >ring. One can push something into the tail, or pop something from head. >The tail goes around when reaching the end. There is a specified amount of >buffer between tail and head, and an IndexError is raised if the tail gets >too close to the head. You could probably subclass the Queue module, but that would only make sense if you were already writing a threaded application. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 There's a difference between a person who gets shit zie doesn't deserve and a person who gets more shit than zie deserves. --Aahz From kalle at gnupung.net Tue Oct 24 16:19:10 2000 From: kalle at gnupung.net (Kalle Svensson) Date: Tue, 24 Oct 2000 22:19:10 +0200 Subject: Q: re In-Reply-To: References: Message-ID: On Tue, 24 Oct 2000, Hwanjo Yu wrote: > Hi, Hi! [snip] > >>> matchstr = re.compile(r".*homepage | .*~.*", re.IGNORECASE) > >>> re.match(matchstr, "http://www.my.com/me/homepage") > > In this case, this should return matchobject since it matches the > "homepage", but it doesn't. > What is wrong here ? The regexp should be: >>> matchstr = re.compile(r".*homepage|.*~.*", re.IGNORECASE) >>> # No whitespace -----------------^^^ ... >>> matchstr.match("http://www.my.com/me/homepage") Your regexp tried to match ".*homepage " or " .*~.*", with the spaces. HTH, Kalle -- Email: kalle at gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) Not signed due to logistical difficulties (I'm not at home). If you doubt the authenticity of this message, please tell me. From akuchlin at mems-exchange.org Tue Oct 17 13:51:17 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 17 Oct 2000 13:51:17 -0400 Subject: GMP, mpzmodule, Win32 -- advice/comments/pointers...? References: <8shssc02fch@news1.newsguy.com> Message-ID: <3dlmvnuzje.fsf@kronos.cnri.reston.va.us> "Alex Martelli" writes: > mpz-only. Any news on Reuben Sumner's "updated > and enhanced" version mentioned on AMK's GMP page? No idea. At one point Sumner said he wanted to make some enhancements to it and release them, but no module is available from his home page. You could write him and ask if he has partially complete source code that he could send you. Otherwise, > The docs of gmpmodule.c claim that mpzmodule.c as > distributed with Python is obsolete -- is it so? IIRC, mpzmodule.c was written for GMP 1.x, and contains lots of workarounds for various 1.x bugs that are no longer required with the 2.x or 3.x versions of GMP. I don't know offhand if the gmpmodule offers any features that mpzmodule doesn't. Oh, there is one; gmpmodule can replace Python's longobject.c so that GMP is used for Python's longs. (I should try it with 2.0 and see if that still works...) --amk From db3l at fitlinxx.com Mon Oct 30 16:25:54 2000 From: db3l at fitlinxx.com (David Bolen) Date: 30 Oct 2000 16:25:54 -0500 Subject: popen2.popen2,3,4 from Python 2.0 on NT 4.0 SP5 References: <39F767B2.266F4965@home.com> Message-ID: speed@?.com (Jake Speed) writes: > If you just use popen(cmd, "r"), won't it take stdin from the console? > I suppose you could use "echo | sqlplus user/pass @file"... > ...or "rem | sqlplus user/pass @file" for Windows. No, if you just used os.popen() then there is no stdin for the child process (e.g., no file handle is opened). In fact, occasionally some processes don't like this if they're written to assume they can make some calls against stdin before they generate their output. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From aleaxit at yahoo.com Fri Oct 20 15:10:07 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 20 Oct 2000 21:10:07 +0200 Subject: ActivePython 2.0 Release References: <634vusk9nco8qem70ddo43t4qpgid30s1l@4ax.com> <8sp2he01b00@news1.newsguy.com> <8spsoh$csm$1@nnrp1.deja.com> Message-ID: <8sq8u402k2r@news1.newsguy.com> "Robin Dunn" wrote in message news:8spsoh$csm$1 at nnrp1.deja.com... [snip] > > One little plus (from my POV) I noticed in their previous build is > > that the docs in the Windows build are in CHM, which I find quite [snip] > I've built a .CHM from the BeOpen python docs. You can get it at > http://alldunn.com/python/py2docs.zip. I just did a quick hack on a > python script (included) I had laying around from 1.5.2 to make it find *Wow* -- *excellent*!!! I move this be placed in the Windows binary installer in lieu of the HTML -- it's truly VERY nice and useful. ***thanks***!!! Alex From hamish_lawson at yahoo.co.uk Thu Oct 26 12:20:14 2000 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: Thu, 26 Oct 2000 16:20:14 GMT Subject: Vaults of Parnassus available as RSS newsfeed Message-ID: <8t9ljm$mot$1@nnrp1.deja.com> A few months back I suggested to Tim Middleton that he make his Vaults of Parnassus resource directory available as a Rich Site Summary newsfeed. This he kindly agreed to do and I've been using it for some time now; I thought others might like to know about it. The newsfeed is available as the file below and contains headlines about the 15 latest Python resources submitted to Parnassus: http://www.vex.net/parnassus/parnassus.rss If you don't want to render the file yourself, there are various portal sites that grab the newsfeed and make it available as one of their channels. You can add it to MyNetscape with: http://my.netscape.com/addchannel.tmpl?service=net.2254 MyUserland makes it available as channel 1944: http://my.userland.com/viewChannel$1944 XMLTree's NewsBoy can deliver it daily to your e-mail address: http://www.xmltree.com/newsBoy/subscribeForm.cfm?ResourceID=5621 Unfortunately O'Reilly's Meerkat syndication service doesn't yet include the Parnassus newsfeed. Hamish Lawson Sent via Deja.com http://www.deja.com/ Before you buy. From insyte at petra.squad51.net Wed Oct 4 15:49:55 2000 From: insyte at petra.squad51.net (insyte at petra.squad51.net) Date: 04 Oct 2000 19:49:55 GMT Subject: Substring Detection? Pythonically? References: <20001004.123529.97857@Jeremy.cerebralmaelstrom.com> Message-ID: In article <20001004.123529.97857 at Jeremy.cerebralmaelstrom.com>, Stephen Hansen wrote: >Okay, say I have three different strings: > #1: they > #2: that > #3: tommy > >And a user gives me a string -- 'the', I want it to match to 'they'. Then >say they give me a string, 'to', I want it to match to 'tommy'. A string >of 'th' or 't' is ambiguious, and i want a list returned, ['they','that'] >and ['they','that','tommy'] respectively. I'm just flailing around here, but it doesn't seem too tough to me. How 'bout something like this: ---------- import re bloop = 'to' blah = ['they', 'that', 'tommy'] blecch = [] for blargh in blah: if re.match(bloop, blargh): blecch.append(blargh) print blecch ---------- Sound viable? -- Ben Beuchler insyte at bitstream.net MAILER-DAEMON (612) 321-9290 x101 Bitstream Underground www.bitstream.net From anders.olme at gavle.to Mon Oct 2 12:37:11 2000 From: anders.olme at gavle.to (Anders Olme) Date: 2 Oct 2000 16:37:11 GMT Subject: tkinter toplevel widget References: Message-ID: Thanks! in my code I used self.root.title="name" and it didn't work but with self.root.title("name") everything were ok. BRG Anders Olme From r.b.rigilink at cable.a2000.nl Fri Oct 6 03:59:26 2000 From: r.b.rigilink at cable.a2000.nl (Roeland Rengelink) Date: Fri, 06 Oct 2000 09:59:26 +0200 Subject: Calling the parent class' __init__ References: <39DD4E57.53C27A3F@ix.netcom.com> Message-ID: <39DD865E.D97E4D09@cable.a2000.nl> Thomas Gagne wrote: > > A parent class defines some instance variables I want to access in the > subclass. I thought I was supposed to call the super class' __init__ but > whenever I tried I got errors so I didn't--but the first time I tried > accessing the super's instance variable (oddly enough, in one of the super's > methods) I got a name error. Wierd. > > Does anyone have some pointers? > > -- > .tom You'll need something like: class A: def __init__(self, value): self.a = value class B(A): def __init__(self, val1, val2): A.__init__(self, val1) self.b = val2 def do(self) print self.a, self.b b = B('Hi','there...') b.do() Hi there... -- Roeland From xander at bos.nl Fri Oct 13 07:45:15 2000 From: xander at bos.nl (Xander van Es) Date: Fri, 13 Oct 2000 13:45:15 +0200 Subject: Problem installing the python-ldap mod References: <971428378.905163@proxy.bos.nl> <39E6ED94.14A5EACF@stroeder.com> Message-ID: <971437442.888505@proxy.bos.nl> "Michael Str?der" wrote in message news:39E6ED94.14A5EACF at stroeder.com... > How did you call the "configure" script? i did: # sh configure no errors till now. and after that: # make cd Modules && make srcdir=/home/xander/python-ldap-1.10alpha3/Modules VPATH=/home/xander/python-ldap-1.10alpha3/Modules make[1]: Entering directory `/home/xander/python-ldap-1.10alpha3/Modules' gcc -I. -DLDAP_REFERRALS -I/tmp/ldap-pfx/include -g -O2 -I/usr/local/inclu de/python1.5 -I/usr/local/include/python1.5 -DHAVE_CONFIG_H -c /home/xander/python-ldap-1.10alpha3/Modules/LDAPObject.c gcc -I. -DLDAP_REFERRALS -I/tmp/ldap-pfx/include -g -O2 -I/usr/local/inclu de/python1.5 -I/usr/local/include/python1.5 -DHAVE_CONFIG_H -c /home/xander/python-ldap-1.10alpha3/Modules/common.c gcc -I. -DLDAP_REFERRALS -I/tmp/ldap-pfx/include -g -O2 -I/usr/local/inclu de/python1.5 -I/usr/local/include/python1.5 -DHAVE_CONFIG_H -c /home/xander/python-ldap-1.10alpha3/Modules/constants.c gcc -I. -DLDAP_REFERRALS -I/tmp/ldap-pfx/include -g -O2 -I/usr/local/inclu de/python1.5 -I/usr/local/include/python1.5 -DHAVE_CONFIG_H -c /home/xander/python-ldap-1.10alpha3/Modules/errors.c gcc -I. -DLDAP_REFERRALS -I/tmp/ldap-pfx/include -g -O2 -I/usr/local/inclu de/python1.5 -I/usr/local/include/python1.5 -DHAVE_CONFIG_H -c /home/xander/python-ldap-1.10alpha3/Modules/functions.c gcc -I. -DLDAP_REFERRALS -I/tmp/ldap-pfx/include -g -O2 -I/usr/local/inclu de/python1.5 -I/usr/local/include/python1.5 -DHAVE_CONFIG_H -c /home/xander/python-ldap-1.10alpha3/Modules/ldapmodule.c gcc -I. -DLDAP_REFERRALS -I/tmp/ldap-pfx/include -g -O2 -I/usr/local/inclu de/python1.5 -I/usr/local/include/python1.5 -DHAVE_CONFIG_H -c /home/xander/python-ldap-1.10alpha3/Modules/message.c gcc -I. -DLDAP_REFERRALS -I/tmp/ldap-pfx/include -g -O2 -I/usr/local/inclu de/python1.5 -I/usr/local/include/python1.5 -DHAVE_CONFIG_H -c /home/xander/python-ldap-1.10alpha3/Modules/version.c gcc -I. -DLDAP_REFERRALS -I/tmp/ldap-pfx/include -g -O2 -I/usr/local/inclu de/python1.5 -I/usr/local/include/python1.5 -DHAVE_CONFIG_H -c /home/xander/python-ldap-1.10alpha3/Modules/linkedlist.c gcc -I. -DLDAP_REFERRALS -I/tmp/ldap-pfx/include -g -O2 -I/usr/local/inclu de/python1.5 -I/usr/local/include/python1.5 -DHAVE_CONFIG_H -c /home/xander/python-ldap-1.10alpha3/Modules/template.c gcc -I. -DLDAP_REFERRALS -I/tmp/ldap-pfx/include -g -O2 -I/usr/local/inclu de/python1.5 -I/usr/local/include/python1.5 -DHAVE_CONFIG_H -c /home/xander/python-ldap-1.10alpha3/Modules/CIDict.c ld -G LDAPObject.o common.o constants.o errors.o functions.o ldapmodule.o message.o version.o linkedlist.o template.o CIDict.o -L/tmp/ldap-pfx/lib -lldap -llber -lsocket -lnsl -lm -lkrb -o _ldapmodule.so ld: fatal: library -lldap: not found ld: fatal: library -llber: not found ld: fatal: File processing errors. No output written to _ldapmodule.so make[1]: *** [_ldapmodule.so] Error 1 make[1]: Leaving directory `/home/xander/python-ldap-1.10alpha3/Modules' make: *** [_ldapmodule-build] Error 2 mvg, Xander From root at rainerdeyke.com Fri Oct 20 00:37:25 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 20 Oct 2000 04:37:25 GMT Subject: newbie References: <8soeic$57gs$2@newssvr05-en0.news.prodigy.com> Message-ID: <9_PH5.99786$g6.44454168@news2.rdc2.tx.home.com> "LONNIE" wrote in message news:8soeic$57gs$2 at newssvr05-en0.news.prodigy.com... > > I have been teaching myself python for about a month now for the simple > reason that I have read alot of literature that says that its easy to jump > from python to c++. I was just wondering if this was true also I have been > teaching myself from online tutorials but I have been looking for a good > book to go along with the literature that I have downloaded so far any > suggestions would be nice. C++ is just plain difficult. If C++ is your goal, either C or Java might be a good intermediate language. Both are both simple enough for beginners to learn (although not as simple as Python). As for Python itself, you probably don't need a book on the language. You should, however, get a good book on data structures and algorithms. I don't know of any such book for Python, but there are several for C, C++, and Java. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From sholden at holdenweb.com Fri Oct 27 08:40:50 2000 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 27 Oct 2000 08:40:50 -0400 Subject: [Numpy-discussion] ? References: <8t9d2m$lqo$2@news.wrc.xerox.com> <39F8DB20.C9FBE4ED@holdenweb.com> <2Z7K5.126092$g6.57970438@news2.rdc2.tx.home.com> Message-ID: <39F977D2.4F377C13@holdenweb.com> Rainer Deyke wrote: > > "Steve Holden" wrote in message > news:39F8DB20.C9FBE4ED at holdenweb.com... > > I can understand and* appreciate all the arguments suggesting that > > division of two integers should yield a non-integer result. Maybe > > I've just been programming too long, so I have fixed ideas about > > how the integers should behave in programming, which is NOT the way > > they behave in mathematics. > > It should be noted that kids in school typically learn integer division with > remainder before they learn about fractions or decimal numbers. > Indeed. But this stick-in-the-mud still holds to the belief that arithmetic and mathematics are two different (albeit realted) things, despite the fact that Americans (presidential candidates included) insist on calling it "math". In mathematics, of course, the integers were generalised into the rationals precisely because of their unsatisfactroy behaviour with relation to division: they aren't closed wrt that operation. Then, of course, some non-rationals were discovered, leading to the rationals. And complex numbers came about because the reals and rationals weren't closed over exponentiation (or some such: remember I'm a computer scientist, and therefore as a mathematician I'm more of a plumber). The-more-you-invent-the-more-you-need-to-invent-ly yr's - steve -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ From dave at zeus.hud.ac.uk Tue Oct 17 06:23:35 2000 From: dave at zeus.hud.ac.uk (Dave Dench) Date: Tue, 17 Oct 2000 11:23:35 +0100 (BST) Subject: how do I register a local-server-only COM object in Python? Message-ID: <200010171023.LAA02806@brahms.hud.ac.uk> ---------- X-Sun-Data-Type: text X-Sun-Data-Description: text X-Sun-Data-Name: text X-Sun-Charset: us-ascii X-Sun-Content-Lines: 26 Dear All, just getting back into the swing of things after a long absence.... so probably a newbie error. I am trying out the "old" spamserver_GPO demo. ( code attached ) The original Spamserver demo works , but this latest code demo doesn't. It registers the server and can be seen running in the COM browser, but fails with a "**** - The Python.SpamServer test server is not available" when using the /test option. Anyone know what the problem is ? I am running 1.6 on an NT machine ( but via winframe from a Unix box ). Best wishes to all. David ________________________________________________________________________________ ******************************************************** * David Dench * * School of Computing & Mathematics * * The University of Huddersfield * * Tel: 01484 472083 * * email: d.j.dench at hud.ac.uk * * web: http://helios.hud.ac.uk/staff/scomdjd * ******************************************************** ________________________________________________________________________________ ---------- X-Sun-Data-Type: default-app X-Sun-Data-Name: spamserver_GPO.py X-Sun-Charset: us-ascii X-Sun-Content-Lines: 156 # copyright Andy Robinson 1997 # you may freely modify and reuse this under the same terms # as the main python licence # registration stuff modified and expanded by Harri Pasanen # thanks also to Mark Hammond and Greg Stein # modified 7/8/99 to demonstrate having all clients on a # machine work with the same SpamServer data. # Gordon McMillan from win32com.server.exception import COMException import win32com.server.util import win32com.client.dynamic import sys import pythoncom _cans = None class SpamServer: _reg_clsid_ = "{1CCF96CE-8BA9-11D4-A059-0008C79FF681}" _reg_desc_ = "Python SpamServer GPO" _reg_progid_ = "Python.SpamServerGPO" _reg_class_spec_ = "spamserver_GPO.SpamServer" _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER _public_methods_ = ['AddCan', 'GetCanCount', 'GetCanAt', 'DeleteCan', 'GetDescriptionList', 'GetCrosstab'] # you need to explicitly list the public methods for COM to work # spelling errors here lead to errors when you call CreateObject # from a client def __init__(self): "it keeps a collection of data - start with a sample object" global _cans if _cans is None: _cans = [SpamCan()] self.cans = _cans def GetCanCount(self): "return the number of objects held" return len(self.cans) def AddCan(self, contents = 'Spam', type = 'Can', qty = 3): "two uses, can just add a generic one, or one you created in a GUI" newOne = SpamCan() newOne.contents = contents newOne.type = type newOne.qty = qty self.cans.append(newOne) def DeleteCan(self,index): del self.cans[index] def GetCanAt(self, index): return win32com.server.util.wrap(self.cans[index]) def GetDescriptionList(self): # for a list view return map(lambda x:x.GetDescription(), self.cans) def GetCrosstab(self): # some example data for yout to play with return [['e.g.','cans','bottles','bags'], ['spam',5,4,3], ['spinach',0,1,2], ['beer',12,4,2]] class SpamCan: "just a simple 'packet' of data to play with" _public_methods_ = ['GetDescription'] _public_attrs_ = ['contents','type','qty'] def __init__(self): self.contents = 'spam' self.type = 'can' self.qty = 3 def GetDescription(self): return '%d %ss of %s' %(self.qty, self.type, self.contents) # each class needs a class ID. You can get these by typing: # import pythoncom # g = pythoncom.CreateGuid() # print g # in the interactive window, then pasting it into your code. def RegisterSpam(): # register them both - this must be called once for the # demo to work import win32com.server.register win32com.server.register.UseCommandLine(SpamServer) def UnRegisterSpam(): """ Unregister each server - use this before deleting the server to keep your registr tidy""" print "Unregistering COM server..." from win32com.server.register import UnregisterServer UnregisterServer(SpamServer._reg_clsid_ , "{1CCF96CE-8BA9-11D4-A059-0008C79FF681}") print "SpamServer Class unregistered." # and finally some test code def TestDirect(): # does some stuff to verify the class works IN PYTHON s = SpamServer() print 'Created spam server' s.AddCan('Cheese', 'Sandwich', 2) print 'added 2 cheese sandwiches' s.AddCan('Chimay Rouge', 'Bottle', 6) print 'added some strong beer' print 'contains %d items:' % (s.GetCanCount()) for item in s.GetDescriptionList(): print '\t' + item s.DeleteCan(0) print 'ditched the beer, we are at work here!' print 'Tests passed' def TestCOM(): try: #SpamSrv = win32com.client.dynamic.Dispatch("Python.SpamServerGPO") SpamSrv = win32com.client.Dispatch("Python.SpamServerGPO",clsctx=pythoncom.CLSCTX_LOCAL_SERVER) print 'Python.SpamServerGPO class created from COM' except: print "**** - The Python.SpamServer test server is not available" return print 'cans:', SpamSrv.GetCanCount() print 'Adding a cheese sandwich', SpamSrv.AddCan('Cheese', 'Sandwich', 2) print 'Adding some beer:', SpamSrv.AddCan('Chimay Rouge', 'Bottle', 6) print 'cans: ', SpamSrv.GetCanCount() descr = SpamSrv.GetDescriptionList() for item in descr: print item print "The Python.Spamserver COM Server worked OK." if __name__=='__main__': """If they ran the whole script, register classes. Options also given to unregister and to test""" import sys if "/unreg" in sys.argv: UnRegisterSpam() elif "/test" in sys.argv: print "doing direct tests..." TestDirect() print "testing COM" TestCOM() else: RegisterSpam() From chris_barker at my-deja.com Mon Oct 16 14:46:17 2000 From: chris_barker at my-deja.com (chris_barker at my-deja.com) Date: Mon, 16 Oct 2000 18:46:17 GMT Subject: interchanging rows and columns References: Message-ID: <8sfidm$t43$1@nnrp1.deja.com> In article , johannes at zellner.org (Johannes Zellner) wrote: > how can I turn > [[1, 2, 3], [4, 5, 6]] > into > [[1, 4], [2, 5], [3, 6]] It may not be appropriate to your larger problem, but as you seem to be thinking about this list as a 2-d array, you might want to consider using a NumPy array, which has many nifty features for this: >>> from Numeric import * >>> a = array([[1, 2, 3], [4, 5, 6]]) >>> print a [[1 2 3] [4 5 6]] >>> b = transpose(a) >>> print b [[1 4] [2 5] [3 6]] >>> NOTE: there is a LOT more that you can do with NumPy!! -Chris Sent via Deja.com http://www.deja.com/ Before you buy. From dscpoon at netvigator.com Wed Oct 4 11:05:57 2000 From: dscpoon at netvigator.com (dickpoon IMS) Date: Wed, 04 Oct 2000 23:05:57 +0800 Subject: good python tutorials for C mother-tongues? References: <0L2C5.39$T34.2386@news.hananet.net> <39D98690.9821F93C@seebelow.org> <8rfa5u$mfg$1@news.nuri.net> Message-ID: <39DB4755.67062211@netvigator.com> Hi Kim, I am reading "Learning Python". It's not that bad but to speak frankly, it is a little bit dull! But I am sure that one could learn something valuable in this book. I don't think there are too many choices available out there except the concise tutorial written by Guido himself! June Kim wrote: > Thank you all who have answered me. > As you guys recommended, I'm reading through Guido's, and hopefully > will finish it sooner or later. For the next step I've been considering > several > books and Mr. Griffin said he read "Learning Python" from beloved O'Reily. > However, I was somewhat surprised after I visited AMAZON to read some > reviews about it, which turned out to be critical and negative to some > degree. > I love O'Reily's Learning/Programming Perl and thought Learning Python > would keep up with the great style as those, but people wrote Python > versions of Learning/Programming are way below expectations. > > What are your opinions? > > "Grant Griffin" wrote in message > news:39D98690.9821F93C at seebelow.org... > > June Kim wrote: > > > > > > Just as the subject goes. > > > > > > Are there any good python tutorials for > > > professional programmers who's been > > > brought up in C language? > > > > The tutorial that comes with Python (by Guido van Rossum, Python's > > creator) is very good. I spent one full working day going through it, > > and I felt like I had a basic understanding of Python at the end of the > > day. Then, in the next few days, I was able to write several small (but > > non-trivial) programs in Python. > > > > I bet most experienced C programmers would have a similar experience. > > The only thing that might be difficult for C (but not C++) programmers > > is Python's object-oriented features. If you don't already know about > > OO programming, Python is probably a good language to learn it in, but > > Guido's tutorial is directed at teaching how _Python_ does OO, not at > > teaching OO concepts in general. (There are lots of good (and not so > > good) books on that.) > > > > The next thing I did was read the book "Learning Python" cover-to-cover, > > which filled in some details. Now, after having practiced Python for > > many months, I'm reading "Python Essential Reference" cover-to-cover. > > Again, that fills in more details. > > > > Also, I recommend you study the online documentation for Python's most > > useful modules: os, os.path, sys, and string; you will use one or more > > of these in nearly any substantial Python program. (Python has a > > zillion modules, so I kindda had to figure out for myself which modules > > I should really "learn".) > > > > one-of-the-nicest-things-about-Python-is-that-you-can-learn-it-in > > -layers-ly y'rs, > > > > =g2 > > -- > > _____________________________________________________________________ > > > > Grant R. Griffin g2 at dspguru.com > > Publisher of dspGuru http://www.dspguru.com > > Iowegian International Corporation http://www.iowegian.com From erik at pacific-shores.com Sat Oct 14 18:42:20 2000 From: erik at pacific-shores.com (Erik Myllymaki) Date: Sat, 14 Oct 2000 22:42:20 GMT Subject: trouble compiling DCOracle Message-ID: I'm having some trouble compiling DCOracle on my RedHat 6.1 machine. I am using the latest DCOracle 1.3.2 and python 1.5.2. I used the included Setup-8.1.5 file with the addition of one library to the *ORACLE_Includes* list: -I$(ORACLE_HOME)/rdbms/public The output from *make* had a number of errors, but compiled the shared objects: gcc -fPIC -I/oradisk01/app/oracle/product/8.1.6/rdbms/demo -I/oradisk01/app/oracle/product/8.1.6/rdbms/public -I/oradisk01/app/oracle/product/8.1.6/network/public -I/oradisk01/app/oracle/product/8.1.6/plsql/public -DDCORACLE8 -g -O2 -I/usr/include/python1.5 -I/usr/include/python1.5 -DHAVE_CONFIG_H -c ./oci_.c In file included from ./oci_.c:566: Buffer.h:79: warning: static declaration for `PyImport_Import' follows non-static ./oci_.c: In function `_wrap_odescr': ./oci_.c:2599: warning: assignment from incompatible pointer type gcc -shared oci_.o -L/oradisk01/app/oracle/product/8.1.6/lib/ -L/oradisk01/app/oracle/product/8.1.6/rdbms/lib /oradisk01/app/oracle/product/8.1.6/rdbms/lib/defopt.o -o oci_.so gcc -fPIC -g -O2 -I/usr/include/python1.5 -I/usr/include/python1.5 -DHAVE_CONFIG_H -c ./Buffer.c In file included from ./Buffer.c:60: Buffer.h:79: warning: static declaration for `PyImport_Import' follows non-static gcc -shared Buffer.o -o Buffer.so Testing the created shared object files went something like this: [sweetrig at shamalama src]# python DCOracle_test.py Traceback (innermost last): File "DCOracle_test.py", line 1, in ? import Buffer, oci_, sys ImportError: libclntsh.so.8.0: cannot open shared object file: No such file or directory I have tried a number of setup files that were on the zope list for Oracle 8.1.6 and all have produced errors. Any help appreciated. -- Erik Myllymaki erik at pacific-shores.com From olivierS.dagenaisP at canadaA.comM Thu Oct 19 11:50:08 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Thu, 19 Oct 2000 15:50:08 GMT Subject: "Portability" References: <39ED6C4A.CBEE94DB@schlund.de> <8skj2r$3i9k$1@nntp6.u.washington.edu> <4BE3250D4FF22FD0.C3EA83F880EAEC04.44DD6B4DD07EB906@lp.airnews.net> <39EEE7D8.1059A34F@holdenweb.com> <3dog0g6hdr.fsf@kronos.cnri.reston.va.us> Message-ID: I *really* like the wxWindows approach: "Not every platform supports feature X? Well, platforms that support feature X will do so natively, and all others will benefit from an almost-as-good implementation that we provide." I think this is how they support MDI on non-Win32 platforms, although I think MDI is "faked" in GTK+.. -- ---------------------------------------------------------------------- Olivier A. Dagenais - Software Architect and Developer "Someone called 'Type your name here' is impersonating me on the internet and is posting exactly the same things I am posting!" "Andrew Kuchling" wrote in message news:3dog0g6hdr.fsf at kronos.cnri.reston.va.us... > claird at starbase.neosoft.com (Cameron Laird) writes: > > My personal emotional reaction is that Python > > shouldn't be like Perl, and shouldn't just expose > > the OS run-time; it should build in a portability > > layer for strftime(), socket(), and other notor- > > ious black sheep. I suppose I'll just leave it > > One risk of this approach is that you wind up following Java's > least-common-denominator approach. Not every platform supports > select()? Then you can't use select() on any platform at all... > > --amk > > From nas at arctrix.com Tue Oct 10 01:08:35 2000 From: nas at arctrix.com (Neil Schemenauer) Date: Mon, 9 Oct 2000 22:08:35 -0700 Subject: Compilation of Python 2.0c1 In-Reply-To: ; from gobry@lithsun15.epfl.ch on Tue, Oct 10, 2000 at 01:42:39PM +0200 References: Message-ID: <20001009220835.A13942@glacier.fnational.com> On Tue, Oct 10, 2000 at 01:42:39PM +0200, Fr?d?ric Gobry wrote: > I've problems with python compilation (be it 1.6 or 2.0c1) on my > Mandrake system : the executable python produces a segmentation fault > in Modules/getbuildinfo.c, in the sprintf call... according to gdb at > least... It should be a compiler bug. Do you have a package that gives you kgcc? You could try using that compiler by runnning: make clean CC=kgcc ./configure make You could also try turning off the optimizer: make clean OPT=-g ./configure make If you still get a segfault then it is possible that there is a bug in Python. Neil From tim_one at email.msn.com Fri Oct 13 04:01:16 2000 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 13 Oct 2000 04:01:16 -0400 Subject: Possible bug (was Re: numpy, overflow, inf, ieee, and rich comparison) In-Reply-To: Message-ID: [Tim] > ... > We cannot consider this to be a bug since Python has had no *intended* > behavior whatsoever wrt 754 gimmicks. We can and do consider gripes > about these accidents to be feature requests. [Huaiyu Zhu] > Yes it varies widely in Python. But isn't that precisely because Python > does not support IEEE? Yes, but that's darned near tautological <0.5 wink>. > If Python does not actively undermine IEEE on platforms that have it, > would it still vary widely across these platforms? Yes. Your own -lieee example showed that math.sqrt(-1) computes not only a non-754 result, but a senseless result, on your platform under 1.5.2. If I show you a platform, how are you going to decide whether it "has" IEEE? 754 is a very involved std, and it's still rare to find a platform C that supports it correctly. On platform C's that do support it correctly, I know of none that do so without requiring platform-specific tricks. Python has *nothing* portable it can rely on, and its mass of utterly non-754-aware code building on haphazard C implementations adds up to the random x-platform crap we have today. ... [T] > The patch to stop setting -lieee was contributed by a Python user who > claimed it fixed bugs on *their* platform. That's "the reason". > We don't want to screw them either. [H] > Q: What bug? Which platform? Maybe there is another way that has less > impact on others? How to find out? I didn't check it in, and you can search the CVS archives as easily as I can (I'm not inclined to, since I don't think it can affect the outcome of this). Jeremy Hylton may, or may not, remember more about it (IIRC, he said he checked it in). > ... > If there is a way to fix the bug on that other platform while still keep > -lieee on Linux, would that be acceptable? No: Guido *wants* overflow to raise OverflowError by default, and *wants* sqrt(-1.0) to raise ValueError by default. Python's x-platform fp numerics today are an utter mess, and the best we can do for 2.0 is to make them as consistent as we have time to make them, despite that we know it will break some of your code (but you can still link with -lieee if you feel you must), and that Mark Favas has confirmed it will break code under both his Solaris and Tru64 Unix systems (but for a reason opposite of yours: he's been getting OverflowError on underflow since 1.5.2, and we're taking that away from him, and he'll have *no* way to go back). At this point we favor forcing consistency over maintaining platform accidents, no matter how attached people have gotten to them; else we'll be stuck with them forever. [oh some of Kahan's papers, at http://http.cs.berkeley.edu/~wkahan/] > Interesting! I've glanced through some of Prof Kahan's writings. He is an entertaining writer, although his rhetoric is often more extreme than either of ours . > It appears that he favors raising flags that can be checked optionally, and > he is against mandatary raising exceptions. Have you read the 754 std? He's in favor of the 754 std. [quotes snipped, except for my favorite, which I've paraphrased many times over the years on c.l.py] > ... > They are called "Exceptions" because to any policy for handling them, > imposed in advance upon all programmers by the computer system, some > programmers will have good reason to take exception. > ... > From these quotes and others I understand that he wants f.p. exceptions to > be merely messanges, not errors that force programmers to take extra > actions, unless the programmer choose to. So what aspect of Java did he > think is deficient? It is the "Trap" style exception that mandate a users > action. His paper "How JAVA's Floating-Point Hurts Everyone Everywhere" lists his 5 main gripes about Java in bullet points at the top of page 3. The paper runs on to 80 pages. You somehow managed to miss 79.89 of them <0.4 wink>, reducing it to a bogus claim about Java that Kahan didn't make (Java has neither "Trap" nor "Flag" style fp exception signaling). > He told "A cautionary Tale of the Ariane 5", Which has nothing to do with Java -- the software in question was written in Ada, which (unlike Java) has "Trap" style. Why he put it in a paper about Java is a bit of a mystery; I write it off to rhetorical excess. > the European rocket that mulfunctioned after lift off. It turned out > that a piece of software produced an unimportant exception that is > not caught by a handler and caused debugging data to be dumped to a > critical memory location. This would have been avoided if the exception > merely raised a flag and returned a NaN, and the program continued. Actually, that was impossible to do, and he didn't suggest that. What he wrote is Had overflow merely obeyed the IEEE 754 default policy, the recalibration software would have raised a flag and delivered an invalid result both to be ignored by the motor guidance programs, and the Ariane 5 would have pursued its intended trajectory. Note that he didn't say NaN. He couldn't, because this was overflow in a conversion from Float to Integer. Despite his cheery optimism here, 754 is approximately useless in this case, since there is no generally accepted "invalid result" in integer formats (and 754 doesn't define one either -- the result of overflow in converting floats to ints is ill-defined in 754; 754 doesn't even require that it set the overflow flag). > So do we want every Python program to bomb whenever there is a floating > point value outside bound and is not trapped by try/except? By default, yes, Guido does, but for overflow, not underflow. If you read the following section of Kahan's paper, you should have noticed that he is *just* as critical of just returning Infs and NaNs (which is all Java does, and which is the accidental Python behavior you're arguing we keep in glibc) as he is of just trapping! His conclusion: "Without Traps nor Flags, Java? s floating-point is Dangerous": Without flags, detecting rare creations of Inf and NaN before they disappear requires programmed tests and branches that, besides duplicating tests already performed by the hardware, slow down the program and impel a programmer to make decisions prematurely in many cases. Worse, a plethora of tests and branches undermines a program?s modularity, clarity and concurrency. I agree with him there wholeheartedly: without the 754-mandated flags, *and* without raising exceptions, the subset of 754 remaining sucks. >> ironically, 754 is hardest to sell to those who could benefit from >> it the most. > So far the only concern from number-crunchers voiced here is that it might > allow sqrt(-1)==0, which is not the case. Gimme a break! In the very msg Paul Dubois said that, he also said "Some people use Inf but most people want the code to STOP so they can find out where the INFS started. Otherwise, two hours later you have big arrays of Infs and no idea how it happened.". I'm starting to drop my assumption of good faith on your part: what you remember and how you paraphrase (whether it's Paul or Kahan) is extremely selective, beyond normal bounds of zeal-inspired distortion. > I was a fortran programmer before. I switched to using IEEE ten years > ago as soon as it was available on the machine I was using. So there > are different opinions. Certainly, and good 754 support will cater to most of them. I don't believe your opinion (or mine, for that matter) reflects anything even close to the majority view here, though. As I said in my reply to Paul, my observations (based on 15 years on the vendor side of the fp biz) matched his exactly (based on his experience with hundreds of numeric code authors): a vast majority still want divide-by-0, invalid operation, and overflow to raise an exception the vast majority of the time. > ... > Obviously we agree on the benefit of having a choice. But we > have different perspective on what choice means. Your want a choice > to force user to take explicit action, I want a choice to ignore these > events. No. I want exactly the choices 754 lays out: user-settable sticky flags and user-maskable exceptions. We're not getting that for 2.0. And we're *never* getting it if 2.0 doesn't do *something* to start disabusing people of the notion that their historical numeric platform accidents in Python will be faithfully preserved forever more. > The ideal solution might be to have a sys.fp_exception class. Each > exception would set a flag like fp_exception.overflow so that user can > check them. There could also be a variable like fp_exception.force_trap, > which when set, could make each f.p. exception to produce a Python > exception. This would confirm to IEEE 754 and give both of us a choice > we want. Kinda, except that each of the 5 754-defined traps must be individually maskable. 754 spells out what's needed. A PEP will be required to spell out the Python- and C-level APIs. I've corresponded (just -- no time now) a little with Kevin Jacobs about that offline. > Now that we are in feature freeze for 2.0, we can't get both choices. > Can we adopt the one that does not break behaviors on previous official > release, even if that's only by accident? Not as far as Guido or I are concerned, no. You can link with -lieee yourself if you must, although I can't recommend perpetuating the x-platform confusion here. We want to say that, e.g., math.exp works substantially the same way on *all* platforms under 2.0, not repeat the same decade-old "umm, don't know, and no way to guess -- try it on your platform and see what it does" yet again. I don't expect 2.0 will actually achieve that on all platforms, but it should on the primary ones. > ... > So now I know why people reported that NaN and Inf were broken on HPUX > and Windows and some others. If Python had simply ignored the flags ... Then we would have broken 754 subsets in slightly subtler ways, and still wildly varying across platforms. > ... > Could you please point a URL to "presubstitution"? In the paragraphs I > quoted the only mention of presubstitute is with NaNs and Inf, etc. Sorry, I don't save URLs, and don't recall whether this was in a paper or on David Hough's "Numeric Interest" mailing list in the early 90's. A Google search on "presubstitution Kahan" turns up 4 promising-looking hits I'll leave you to pursue. The basic idea is that the programmer gets to specify, via library calls (whatever), which particular fp value each 754 exceptional case returns. So, e.g., if it made sense for some part of the app, the programmer could say they wanted +- pi returned instead +- Inf, if and whenever overflow happened. Then set it back to +- Inf (or anything else they needed) later. This would be best if supported in HW directly, of course. > ... > You are not confirming to 754 until you allow all the exceptions to go > through with well defined values as default. I know that, but don't care. As I said, enabling overflow + invalid + div0 by default is the only scheme that can be *sold*. If you can find two NumPy users in favor of disabling them all by default, I'll be mildly astonished. 754 did itself enormous harm by insisting on that trivial point (it's trivial because, with proper support, anyone can change the defaults to anything they like with one line of code): I worked in the supercomputer biz at the time 754 was adopted, and for a decade after, and the "non stop" defaults were *universally* opposed by customers. Scared the hell out of language stds committees too, which goes a lot farther than the 754 folks would like to admit toward explaining why language committees stayed away from 754 bindings in droves. C99 is 15 years(!) after the fact. > Raising Python exceptions on some of them does not confirm to 754, as > the default IEEE 754 behavior on f.p. exception is not a Python exception, > but just a raised flag. See above. > Before that happens, what is the motive to make IEEE less usable for those > who have it (pretty much every one nowadays), even if just by accident? I think I've repeated the reasons to death already, and you've repeated to death that you'll never agree. So no more from me on that. > ... > But just to clarify some wordings you quoted in another post: I meant that > sqrt(-1)==0 is insane, whether silent or not. I agree. > Raising an exception is sane, Not according to 754's default rules, which you wanted me to take as sacred just a few paragraphs ago . > although OverflowError is not so reasonable. I'd say it's insane. > Raising a ValueError is reasonable. I expect we'll have to make InvalidOperationError a subclass of ValueError for that reason, when 754 support materializes. > But just returning NaN without a fuss is even better. You're going to find that's a very lonely position. > My favorite is returning 1j, as MatPy does. Then you should use cmath.sqrt instead of math.sqrt. Even $3 business calculators have a sqrt key these days, and you do not want to be on the other end of email when trying to explain to a businessperson why their crappy std deviation program returned a complex number <0.1 wink>. > if-it-ain't-broke-don't-fix-it-ly y'rs it-it-weren't-broke-we-wouldn't-ly y'rs - tim From fgeiger at datec.at Wed Oct 4 10:02:05 2000 From: fgeiger at datec.at (Franz GEIGER) Date: Wed, 4 Oct 2000 16:02:05 +0200 Subject: Reg Exp: Need advice concerning "greediness" References: <8r4om7$9bd$1@newsreaderm1.core.theplanet.net> <39da9d50.6517406@news1.on.sympatico.ca> Message-ID: <8rfdbp$b0s$1@newsreaderg1.core.theplanet.net> That was definitly what I was lookin' for! Alex mentioned the SGML parser already but supposed that there remains considerable work to do. But it was rather painless to implement my stuff into this frame. Thank you all again, great community! Best regards Franz GEIGER Robert Roy schrieb in im Newsbeitrag: 39da9d50.6517406 at news1.on.sympatico.ca... > On Sat, 30 Sep 2000 15:08:02 +0200, "Franz GEIGER" > wrote: > > >Hello all, > > > >I want to exchange font colors of headings of a certain level in HTML files. > > > >I have a line containing a heading level 1, e.g.:

>COLOR="#FF0000">Heading Level 1

. > > > >Now I want to split this into 3 groups: Everything before "COLOR=xyz", > >"COLOR=xyz" itself, and everything after "COLOR=xyz". > > > >I tried: > >sRslt = "

Heading Level 1

"; > >print re.findall(re.compile(r'(.*?FONT.*?)(COLOR=.*?)*([ |>].*)', re.I | > >re.S), sRslt); > > > >This returns [("

Heading Level 1

)]. > >I'd expected to receive [("

Heading Level > >1

)]. > > > >It works if I replace (COLOR=.*?)* by (COLOR=.*?). But I need having the '*' > >because there may be headings w/o the color attribute but with a face > >attribute. > > > >As I understood until now, '*' means 'zero or more of preceeding, but as > >many as possible'. If a color attribute is present, 'as many as possible' > >means 'the one that is there', doesn't it? If there is no such attribute, > >well - then it's 'zero'. > > > >What did I miss? > > > >Best regards > >Franz > > > > > > > > Here is some example code using sgmllib. Note that you should make > sure you are submitting valid html. This will also change the case of > your element and attribute names to lower case. > > Make changes-additions where the comment tells you to > Add member variables to the class as required to keep track of where > you are. > > Bob > > ####################### > > from sgmllib import SGMLParser > import string > > class MySGMLParser(SGMLParser): > def __init__(self, verbose=0, outfile=None): > if not hasattr(outfile, 'write'): > raise "outfile must have attribute write" > self.outfile = outfile > SGMLParser.__init__(self, verbose) > > def handle_data(self, data): > self.outfile.write(data) > > def handle_comment(self, data): > self.outfile.write('' % data) > > def unknown_starttag(self, tag, attrs): > if not attrs: > self.outfile.write('<' + tag + '>') > else: > self.outfile.write('<' + tag) > for attr in attrs: > self.outfile.write(' %s="%s"' % attr) > self.outfile.write('>') > > def unknown_endtag(self, tag): > self.outfile.write('' % tag) > > def unknown_entityref(self, ref): > self.outfile.write('&%s;' % ref) > # so known refs do not get translated > handle_entityref = unknown_entityref > > def unknown_charref(self, ref): > self.outfile.write('&#%s;' % ref) > # so known refs do not get translated > handle_charref = unknown_charref > > def close(self): > SGMLParser.close(self) > > ## put tag handlers here, > ## for my sample code I took the www.python.org homepage and > ## changed the bgcolor of the wrapper tables > ## define start and end tag handlers as start_TAGNAME, end_TAGNAME > > def start_td(self, attrs): > if not attrs: > self.outfile.write('') > else: > self.outfile.write(' for name, val in attrs: > if string.lower(name) == 'bgcolor': > self.outfile.write(' %s="%s"' % (name, '#ffcc99')) > else: > self.outfile.write(' %s="%s"' % (name, val)) > self.outfile.write('>') > > def end_td(self): > self.outfile.write('') > > > > if __name__ == "__main__": > import sys > if len(sys.argv) != 3: > print "usage: python changeattr.py infile, outfile" > raise SystemExit > infile = sys.argv[1] > outfile = sys.argv[2] > ofp = open(outfile, 'w') > # this is a one shot parser > p = MySGMLParser(outfile=ofp) > p.feed(open(infile).read()) > p.close() > ofp.close() > > > > From chalaoux at cybercable.fr Tue Oct 3 08:37:38 2000 From: chalaoux at cybercable.fr (FR Chalaoux) Date: Tue, 03 Oct 2000 14:37:38 +0200 Subject: Compile Problem of Python on BSD/OS References: <39D9C930.48B18B84@cybercable.fr> Message-ID: <39D9D311.AE381DA5@cybercable.fr> Hi, Indeed this the machine of a provider who told me that is not possible to install Python with multi-thread on this machine. As ** I Want** Zope I should compile my Python before and check if it's really impossible to use multi-thread. May be there restriction for user and but I don't know BSDI !!! Help? Cameron Laird wrote : I *hope* everything is better for you now, that is, you have since re-run this generation, and it worked properly for you. "Cannot fork" generally arises when you've filled the process table and run into some constraint (perhaps specific to a particular user). The usual fix is to kill off a few processes (do you have any unneeded xterm-s lying around? Have you backgrounded thirty different editing sessions?) and re-try. -- From alex116321 at my-deja.com Tue Oct 24 11:40:57 2000 From: alex116321 at my-deja.com (alex116321 at my-deja.com) Date: Tue, 24 Oct 2000 15:40:57 GMT Subject: event loop problem References: <8t21ei$e5a$1@nnrp1.deja.com> Message-ID: <8t4ai8$96p$1@nnrp1.deja.com> Thanks for the info Geoff. My program works fine now. Alex In article , Geoff Talvola wrote: > I know exactly the problem you're talking about -- and I consider it a huge > design flaw in NT that any one application can cause other applications to > hang if it's not processing its message loop. Starting up PythonWin is > another example of something you can't do if any program isn't processing > its messages. > > There are 2 solutions I can think of. First of all, win32all already > contains a function that can process all waiting messages: > win32gui.PumpWaitingMessages() inserted into your while loop should do the > trick. > > But a better solution is to tell win32com to run in free-threading mode, in > which case it doesn't create a hidden window and everything works fine > without having to process messages. To do this, add the following lines > BEFORE you import win32com: > > import sys > sys.coinit_flags = 0 > > and if you are using multiple threads, each thread besides the main thread > should call > > pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED) > > when they are initialized, and > > pythoncom.CoUninitialize() > > when they exit. If you're not using multiple threads, you don't need the > CoInitializeEx and CoUninitialize. > > See the excellent book Python Programming on Win32 if you need more > details. > > alex116321 at my-deja.com wrote: > > > I am trying to write a simple Python script which which uses ADO > > through Python's COM extension but never exit. For this I have writen > > a simple while loop however this causes a problem on Windows NT. > > Sometimes other windows on NT broadcast messages which need to be > > confirmed by all running windows. If at least one window does not > > dispatch the confirmation, the broadcaster will hang. In C++ the > > solution is to make the main event loop listen for windows messages, > > for example: > > > > while(PeekMessage(&msg,NULL,NULL,NULL,PM_REMOVE)) { > > TranslateMessage(&msg); > > DispatchMessage(&msg); > > } > > > > However, I cannot seem to find an equivalence in Python except to use > > Tkinter and use the mainloop function. Unfortunately, I do not require > > any graphics in my program. This is my Python script: > > > > ###################################################### > > import time, win32com.client > > > > # Dispatch Microsoft ActiveX Data Objects (ADO) > > rset = win32com.client.Dispatch("ADODB.RecordSet") > > > > query = "select cAFUserAccountP from Person" > > dbstring = "DRIVER={SQL Server};SERVER=svr-tor- > > dev;DATABASE=SMS_HP_1.2.0;UID=sa;PWD=" > > > > rset.Open(query, dbstring) > > rset.Close() > > > > while 1: > > time.sleep(0.01) > > > > ########################################################## > > > > While this script is running, try setting the time through the windows > > Date/Time Properties window. The window will get stuck until the > > python script is killed. This is because it tries to broadcast a > > message but the python application window does not respond. Actually, > > ADO opens a hidden window and causes this problem. If ADO is not used, > > no problem exists. Any help would be greatly appreciated. > > -- > > - Geoff Talvola > Parlance Corporation > gtalvola at NameConnector.com > > Sent via Deja.com http://www.deja.com/ Before you buy. From effbot at telia.com Sat Oct 21 10:52:03 2000 From: effbot at telia.com (Fredrik Lundh) Date: Sat, 21 Oct 2000 14:52:03 GMT Subject: newbie: configure stops on aix References: <8ss1mr$1ct$1@nnrp1.deja.com> Message-ID: cgicq wrote: > When I run the configure script, I get the > following error: > > configure: error: can not run test program while > cross compiling this usually means that the compiler chosen by configure isn't really working. checking the config.log file should help you figure out what's wrong... From royd at cc.uit.no Tue Oct 17 06:40:24 2000 From: royd at cc.uit.no (Roy Dragseth) Date: 17 Oct 2000 12:40:24 +0200 Subject: all i want to do is plot a matrix!!! References: Message-ID: Try the view function of the NumTut part of NumPy. It should do the trick if you have _tkinter. r. From aleaxit at yahoo.com Thu Oct 12 05:27:15 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 12 Oct 2000 11:27:15 +0200 Subject: documentation problems (was Re: Newbie - EOF question) References: <8s2u9p$767$1@nnrp1.deja.com> Message-ID: <8s40ek01ajr@news1.newsguy.com> wrote in message news:8s2u9p$767$1 at nnrp1.deja.com... > Hi, > > I just started programming in python and the following piece of code > gives me an EOFError. Was wondering if someone could help ? [snip] > --- CODE --- > f = open("tmpfile") > x = cPickle.load(f) > while x: > print x > x = cPickle.load(f) > > --- ERROR LOG --- > Traceback (innermost last): > File "./test.py", line 16, in ? > Main() > File "./test.py", line 14, in Main > x = cPickle.load(f1) > EOFError I do not think it's clearly specified what happens when load() is called on an Unpickler more times than dump() was originally called; all I can see in the docs is: """ It is possible to make multiple calls to the dump() method of the same Pickler instance. These must then be matched to the same number of calls to the load() method of the corresponding Unpickler instance """ It could be argued that "must" is a strong constraint, so it's implicit that an exception will be raised if the constraint is violated; but I think it would be better to make it explicit, by adding a simple sentence such as ", else an EOFError will result" at the end of the above-quoted snippet. It gets subtler because here it's not clear that we _are_ talking to "the SAME Pickler instance"; indeed, the docs for pickle.load make it appear that a new pickler instance is built for each call, so, what IS the semantic for multiple load calls then...? Here, I believe the key issue is that the instances are built on top of the _same_ file object -- but this should be explicit in the documentation, too, it seems to me. Any chance to get these documentation issues fixed...? Once the actual behavior of the .load is well understood, the fix to the code is clearly simple: f = open("tmpfile") while 1: try: x = cPickle.load(f) except EOFError: break print x The best/clearer wrapping of this behavior might be done through an auxiliary object ("so, what else is new"!-): class DePickler: def __init__(self, fileobj): self.fileobj = fileobj def __getitem__(self, i): try: return cPickle.load(fileobj) except EOFError: return IndexError With this class-definition available, you can do: for x in DePickler(open("tmpfile")): print x Alex From robin at jessikat.fsnet.co.uk Thu Oct 19 09:21:43 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 19 Oct 2000 14:21:43 +0100 Subject: SF corpsed? Message-ID: I can't seem to get any decent access to sourceforge. Anybody else having troubles? -- Robin Becker From peter at schneider-kamp.de Tue Oct 3 11:12:48 2000 From: peter at schneider-kamp.de (Peter Schneider-Kamp) Date: Tue, 03 Oct 2000 17:12:48 +0200 Subject: How can you copy (clone) a string? References: Message-ID: <39D9F770.E253F448@schneider-kamp.de> If you know it is not empty: >>> a = "abcd" >>> b = a[:1] + a[1:] >>> id(a) 21765696 >>> id(b) 21763648 >>> a is b 0 >>> a == b 1 Peter.Rupp at ual.com schrieb: > > All, > I have a bonafide need to create copies of strings in a python program From aleaxit at yahoo.com Wed Oct 25 09:37:00 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 25 Oct 2000 15:37:00 +0200 Subject: makepy error messages broken in win32all build 135 Message-ID: <8t6nvu0ki5@news1.newsguy.com> D:\Python20\win32com\client>python makepy.py -help Traceback (most recent call last): File "makepy.py", line 357, in ? rc = main() File "makepy.py", line 329, in main sys.stderr.write (msg + "\n") TypeError: __add__ nor __radd__ defined for these operands D:\Python20\win32com\client> "msg", which makepy.py just obtained with a line of except (getopt.error, error), msg: is an instance of class getopt.GetoptError, and has no __add__ method. (I guess msg must have used to be a string at some point, but surely that was a while ago...?). An easy fix is to change line 329 to sys.stderr.write(str(msg) + "\n") I have not checked whether similar problems exist in other win32all utilities. P.S.: what IS the correct place to submit bug reports, workarounds, patches, etc, for win32all...? Alex From max at alcyone.com Mon Oct 23 23:14:55 2000 From: max at alcyone.com (Erik Max Francis) Date: Mon, 23 Oct 2000 20:14:55 -0700 Subject: C's syntax References: <8t0or303ee@news1.newsguy.com> <8t1964$v8a$1@news7.svr.pol.co.uk> <17WI5.58198$oN2.2362868@news20.bellglobal.com> <39F45B51.320AA63F@alcyone.com> <8t1nr90105v@news1.newsguy.com> Message-ID: <39F4FEAF.FA466927@alcyone.com> Alex Martelli wrote: > Visual C++ may not be "reasonable", but it's still one of the most > widespread on the market, and does NOT give this warning at normal > warning-levels (and the system header files spew oodles & oodles of > warnings if you try to enable warnins at pedantic-level, so one > does not normally use that). One should never be running at the default warning level. One should be turning as many warnings on as one can stand. > It's a good coding habit to get into, to ensure that particular > slip will be caught by any standard compiler, rather than relying > on specific warning-relater features that NOT all compilers have. It is largely unnecessary. It is a novice programming error, one that actual programmers do not make unless they are very green. Given that any reasonable compiler will warn about such constructs, making a major change in style for an error that advanced programmers do not make is overkill, to say the least. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ To be a man means to be a fellow man. \__/ Leo Baeck Product's Quake III Arena Tips / http://www.bosskey.net/ Tips and tricks from the absolute beginner to the Arena Master. From thomas at cintra.no Wed Oct 18 03:45:56 2000 From: thomas at cintra.no (Thomas Weholt) Date: Wed, 18 Oct 2000 07:45:56 GMT Subject: Overloaded Constructor References: <8sjj0v$7mb$1@nnrp1.deja.com> Message-ID: <39ed5438.86008483@news.eunet.no> As far as I can see, Python doesn't support this. You'll have to just have to something like this: class myClass: def __init__(self,any_var1 = None,any_var2 = None): if any_var1 != None and any_var2 != None: dosomething_with_any_varx() else: dosomething() Or something ... the feature would be nice to have though. Used it in Java alot, but I think we would have seen it in Python allready if the model Python is built on allowed it ( but I have nothing to back this up !! ) Thomas On Wed, 18 Oct 2000 07:21:06 GMT, paralizer at my-deja.com wrote: >How can I use overloaded constructor in Python? >Such as > >class myClass: > def __init__(self): > dosomething() > def __init__(self,any_var1,any_var2): > dosomething_with_any_varx() > >and when i use > > d = myClass # means i use the first constructor > e = myClass(yyy,zzz) # means i use the second one > >any suggestion? > > >Sent via Deja.com http://www.deja.com/ >Before you buy. From robin at alldunn.com Mon Oct 30 18:51:36 2000 From: robin at alldunn.com (Robin Dunn) Date: Mon, 30 Oct 2000 23:51:36 GMT Subject: In memory persistence - used as CGI References: <8tk9aq$p80$1@nnrp1.deja.com> <8tkn1b09kg@news1.newsguy.com> Message-ID: <8tl1i6$fuv$1@nnrp1.deja.com> In article <8tkn1b09kg at news1.newsguy.com>, "Alex Martelli" wrote: > wrote in message > news:8tk9aq$p80$1 at nnrp1.deja.com... > > I'm using Python as a CGI language (for use both > > in MS IIS & Linux Apache). Is there a mechanism > > for in-memory persistence of data for use by > > different HTTP requests to different Python CGI > > pages? Specifically, I'm looking for something > > similar to an Application() variable in MS IIS 4. > > No, each CGI 'hit' is served by a completely separate > process (I think this holds for both IIS and Apache), > so there IS no memory address that is shared by > different CGI-hits (including two successive hits > on the same page from the same address). You > have to go to disk, and/or use cookies. > Or use something like FastCGI, but then you have to funnel all requests through a single process which is fine for light or medium loads, but can cause throughput issues at a high load. -- Robin Dunn Software Craftsman robin at AllDunn.com http://wxPython.org Java give you jitters? http://wxPROs.com Relax with wxPython! Sent via Deja.com http://www.deja.com/ Before you buy. From jacobkm at cats.ucsc.edu Fri Oct 27 01:23:20 2000 From: jacobkm at cats.ucsc.edu (Jacob) Date: Thu, 26 Oct 2000 22:23:20 -0700 Subject: Pretty report printing References: Message-ID: quinn at pfennig.ugcs.caltech.edu (Quinn Dunkan) wrote: >machines without ghostscript, I'm pretty sure I've seen some ps->pdf >filters about. AFAIK, a tool called latex2pdf comes with the standard LaTeX installation (at least the RPM I downloaded had it). It should be pretty easy to generate the LaTeX and then run latex2pdf on it. Jacob Kaplan-Moss From sdm7g at virginia.edu Thu Oct 26 15:49:10 2000 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Thu, 26 Oct 2000 15:49:10 -0400 (EDT) Subject: [Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich , comparison In-Reply-To: Message-ID: On 26 Oct 2000, Pete Forman wrote: > Most of this thread is concerned with whether doing an operation with > two integers should produce a result which is not an integer. > > What has not been mentioned is that the "2" and "3" are integers. If > you want them to be floats they should be spelt "2." and "3." in the > same way that longs would be spelt "2L" and "3L". It may be possible > to change the language so that unadorned numbers are floats and some > suffix is introduced for integers. I don't think that you'd get many > takers for that. I'm not particularly happy that 2000000 * 2000000 gives me an overflow error and I have to remember to append an "L" to one or more of those operands. Would you suggest that for consistency, 3/2 signal an error, since the answer is outside the domain ? That's not the solution I prefer, but at least it's consistent and it gives a warning rather than the wrong answer. ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- "All operating systems want to be unix, All programming languages want to be lisp." From scarblac at pino.selwerd.nl Tue Oct 17 03:01:59 2000 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 17 Oct 2000 07:01:59 GMT Subject: Exception Handling in Python References: Message-ID: Suchandra Thapa wrote in comp.lang.python: > I'm trying to figure out how to catch an exception, do some > error handling and then reraising the same exception in python. > Right now, I'm doing it using the following code: > > try: > ... > except Foo: > ... > except Bar: > ... > except Exception, x: > ... > raise x > else: > ... > > which seems to work but I wanted to know if there are any problems with > this method or if there is a better way to do it. The only potential problem > I know of right now is that user defined exception not derived from Exception > will slip through but is that much of a problem? 'raise' without argument will re-raise the currently handled exception, so you can just use except: ... raise at the end. If you need info about the current exception, use sys.exc_info() in the '...' part. From dale at out-think.NOSPAMco.uk Wed Oct 25 09:45:17 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Wed, 25 Oct 2000 14:45:17 +0100 Subject: How do I force a single instance of a python app? References: <39f5e46f_3@corp.newsfeeds.com> Message-ID: Open a flag file exclusively for writing. If successful you are alone, if not, another instance already has the file. The OS should close the file and free the exclusive lock if the app crashes. "Joshua Muskovitz" wrote: >I need to prevent multiple copies of a python app from running >simultaneously on a single machine. In Windows and C++, this is done with >sending custom window messages to all top level windows, or using some other >kind of scheme. > >I'm looking for a platform neutral way to do this for my python apps -- the >second instance should somehow detect the first instance and should quietly >kill itself. It does not need to notify the first instance of anything. >Initial target platforms are Solaris and NT, but others will follow, so a >generic solution would be the best. File existence is a bad solution >because the first instance might (possibly) terminate before it could delete >the file. I need a semaphore which will absolutely go away when the first >instance dies, or else a way to reliably probe to see if the first instance >exists on the fly. > >Suggestions gratefully accepted! > >-- josh > > > > >-----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- >http://www.newsfeeds.com - The #1 Newsgroup Service in the World! >-----== Over 80,000 Newsgroups - 16 Different Servers! =----- Dale Strickland-Clark Out-Think Ltd Business Technology Consultants From ivdkleyn at xs4all.nl Wed Oct 4 10:39:42 2000 From: ivdkleyn at xs4all.nl (Iwan van der Kleyn) Date: Wed, 4 Oct 2000 16:39:42 +0200 Subject: Web client References: Message-ID: <8rff71$r0h$1@news1.xs4all.nl> Take a look at the article "A CGI Framework in Python" for some examples http://www.webtechniques.com/archives/1998/02/kuchling/ or check out Python Weblib http://weblib.sourceforge.net/ Good luck, Iwan "Fredrik Eriksson" wrote in message news:mailman.970665551.7920.python-list at python.org... > > I want to build a simple web client that logs in to a free web service to > send a sms. What it need to do is get the first web page, fill in the form > and send the information, get the next web page and do the same thing and > then disconnect. > But this requires a handling of cookies and I can't find anything for that > in Python? > > Cheers, > > Fredrik > > From aleaxit at yahoo.com Mon Oct 23 18:00:04 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 24 Oct 2000 00:00:04 +0200 Subject: Newbie question: Replace line in file? References: <8t259u$hud$1@nnrp1.deja.com> Message-ID: <8t2cgo0l50@news2.newsguy.com> wrote in message news:8t259u$hud$1 at nnrp1.deja.com... > How to replace line: > Content-Type: text/plain; format=flowed > with > Content-Type: text/plain; charset=iso-8859-1 > in one message file and also in all files in one directory? old='Content-Type: text/plain; format=flowed' new='Content-Type: text/plain; charset=iso-8859-1' import fileinput for line in fileinput.input(onefilename, inplace=1): print line.replace(old,new) import os.path import glob allfiles = glob.glob(os.path.join(adirectorypath,'*')) for line in fileinput.input(allfiles, inplace=1): print line.replace(old,new) Alex From dale at out-think.NOSPAMco.uk Thu Oct 19 14:49:26 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Thu, 19 Oct 2000 19:49:26 +0100 Subject: How would you go about this? Message-ID: <1cfuus4j0sno8e0l63gg8ggqhoh20g9hch@4ax.com> We're in the process of developing a database application in Python. In fact, the Python part is only the middle tier and is a set of objects used to generate Web pages. What we've done so far (about half way through) works a treat but I'm not satisfied. SQL queries are generated on the fly based upon the users' selection criteria. There are over thirty tables involved and the JOINs can get pretty long. Although it works, the code for this isn't as tidy as I would have liked and I'm convinced there is a much better approach. I'm interested in hearing from anyone who has developed SQL-based database applications in Python (or other OO language) which generate dynamic queries. (Or who reckons they know about such things!) 1. What sort of objects did you employ? 2. How did you deal with needing to store lots of info about individual fields (data type, formatting, validation, etc.) We're using a dirty great dictionary containing tuples but it's unwieldy. Also, if anyone knows any relevent reference material that I could read, I'd be very interested in it - whether I buy it or download it. Thanks for any help. Dale Strickland-Clark Out-Think Ltd Business Technology Consultants From dalke at acm.org Tue Oct 10 02:30:44 2000 From: dalke at acm.org (Andrew Dalke) Date: Tue, 10 Oct 2000 00:30:44 -0600 Subject: SaxRecords.py (was Re: busting-out XML sections) References: <39DCFFC2.A26BF159@ix.netcom.com> <39DDB4F8.60ECF23C@milagrosoft.com> <39DE24AE.71AD86C1@ix.netcom.com> <8rliub0daq@news1.newsguy.com> <39DEABC2.B0980E15@ix.netcom.com> <8rmu4q02bhf@news1.newsguy.com> <39E1DF77.8B6BAC03@ix.netcom.com> Message-ID: <8rud0t$ao7$1@slb6.atl.mindspring.net> Thomas Gagne wrote: >I think what I'm beginning to picture inside my head is a combination SAX/DOM >parser. Imagine how useful this would be for both large files and realtime >data. SAX would read the (unending) stream of data and my document handler >would watch for the start and end tags of the useful subsections. When the >end-tag is reached it would somehow take the inbetween data and hand it off to >a DOM parser where the individual transactions are taken care of. Interestingly enough, I've been thinking about what I think is a similar thing, especially since it should help simplify my Martel work (see biopython.org/~dalke/Martel/). I wrote up a first draft of the module and made it available at http://www.biopython.org/~dalke/SaxRecords.py . Here's what it looks like to use it: import SaxRecords from xml.sax import saxexts from xml.dom import sax_builder from StringIO import StringIO parser = saxexts.make_parser() test_data = """ AndrewDalkeSanta Fe BillClintonWashington CraigVanceNew York """ record_parser = SaxRecords.Parser(parser, "record", sax_builder.SaxBuilder) for builder in record_parser.parseFile(StringIO(test_data)): doc = builder.document ... work with the DOM document ... As you might see, I turned the interface into forward iterator by spawning off a thread to handle the callbacks and send them back to the original thread. The package includes a slightly modified version of Sean McGrath's RAX Record object as an alternate to producing DOM documents. Also, it seems you'll have to tweak it a bit to work with PyXML-0.6.1, but the basic concept should be viable. Andrew Dalke dalke at acm.org From wolfson at midway.uchicago.edu Mon Oct 23 23:25:21 2000 From: wolfson at midway.uchicago.edu (Ben Wolfson) Date: Tue, 24 Oct 2000 03:25:21 GMT Subject: C's syntax (was Re: Python Formatted C Converter (PfCC)) References: <8t0or303ee@news1.newsguy.com> <39F4FFB7.452EDDEC@alcyone.com> Message-ID: In article <39F4FFB7.452EDDEC at alcyone.com>, Erik Max Francis wrote: >Rainer Deyke wrote: > >> int (*a)[5], *(b[5]); >> >> It looks like 'a' is an array of pointers and 'b' is a pointer to an >> array, >> but the opposite is the case. > >Makes perfect sense, if you that you read C declarations from the inside >out. So with int (*a)[5]; you start with a)[ and proceed outwards? >C is not a trivial language, so the rules are not trivial. If you have >sloppy thinking or are not familiar with the details of the language, >you will get yourself into trouble with a non-trivial language. But >then that's true of a trivial language as well. A non-trivial language needn't have tortured syntax. -- BTR | It is a symptome of Melancholy to be afraid of death, and yet sometimes to desire it; this latter I have often discovered in my selfe, and thinke noe man ever desired life as I have sometimes Death. -- Thomas Browne, _Religio Medici_ From akuchlin at mems-exchange.org Wed Oct 4 10:20:43 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: Wed, 04 Oct 2000 10:20:43 -0400 Subject: Request for Python editor modes Message-ID: The Editor Configuration HOWTO (http://www.python.org/doc/howto/editor/) covers how to set up various editors to make editing Python code more comfortable. Currently the HOWTO has instructions for the following editors: * Alpha * CodeWright * Emacs * jed * vi I'd like to get instructions for more editors. If you use something that isn't on the above list -- KDevelop or Scintilla/SciTE or whatever, please follow up to this posting, or e-mail me privately, and describe the instructions for configuring your editor for Python code. (IMHO it's worth listing editors in the HOWTO even if there's no special configuration required for editing Python code, as with jed for example, since then people can use the HOWTO to find editors that support Python.) Thanks in advance... --amk From effbot at telia.com Wed Oct 4 15:48:08 2000 From: effbot at telia.com (Fredrik Lundh) Date: Wed, 04 Oct 2000 19:48:08 GMT Subject: Substring Detection? Pythonically? References: <20001004.123529.97857@Jeremy.cerebralmaelstrom.com> Message-ID: Stephen Hansen wrote: > Okay, say I have three different strings: > #1: they > #2: that > #3: tommy > > And a user gives me a string -- 'the', I want it to match to 'they'. Then > say they give me a string, 'to', I want it to match to 'tommy'. A string > of 'th' or 't' is ambiguious, and i want a list returned, ['they','that'] > and ['they','that','tommy'] respectively. import re, string class Matcher: def __init__(self, names): self.names = string.join(map(lambda x: "{%s}" % x, names), "") def find(self, name): return re.findall("{(" + re.escape(name) + "[^}]*)}", self.names) >>> m = Matcher(("they", "that", "tommy")) >>> m.find("the") ['they'] >>> m.find("to") ['tommy'] >>> m.find("th") ['they', 'that'] >>> m.find("t") ['they', 'that', 'tommy'] >>> m.find("x") [] (if you cannot do it in 8 lines of python, it's not worth doing) From jkraska1 at san.rr.com Wed Oct 25 00:09:59 2000 From: jkraska1 at san.rr.com (Courageous) Date: Wed, 25 Oct 2000 04:09:59 GMT Subject: Public Domain Python References: Message-ID: <39F65DE7.1DF35813@san.rr.com> > Safe from what, though? The copyright holder can change a license any time > they feel like it, and the GPL has no magical power to prevent that. I disagree; once you have granted someone the right to create a derived work, and that derived work exists, you have no legal ability to withdraw their ability to continue to own/sell their derived work. I'm not an attorney, but I do believe that this is correct. > Sorry, but so long as CNRI remained the primary copyright holder, *nothing* > about Python's licensing status would be different today. They could still > put a new license on 1.6, and there's nothing anyone could do to stop that. Sure, but anyone who has valid derived works cannot be curtailed by CNRI in any way. > It's not the license that makes the rules, it's the copyright holder: a > license merely tells you how they felt about sharing their rights in the > past; it can't stop them from changing their mind later. So break away with your older copies and give them a hearty "FUCK YOU." :) C// From tgagne at ix.netcom.com Mon Oct 9 12:35:09 2000 From: tgagne at ix.netcom.com (Thomas Gagne) Date: Mon, 09 Oct 2000 12:35:09 -0400 Subject: Why is "while" ticking me off??? References: <39DD15A1.442E5A33@ix.netcom.com> <39DDEC25.CEE0E16A@gssec.bt.co.uk> Message-ID: <39E1F3BD.21892E5E@ix.netcom.com> Worked like a charm. The code reads much better without the while loop. less code written == less code debugged -- .tom From ge at nowhere.none Wed Oct 11 16:33:48 2000 From: ge at nowhere.none (Grant Edwards) Date: Wed, 11 Oct 2000 20:33:48 GMT Subject: pyGTK -- why can't I center a window? Message-ID: Working on my dialog again -- and I can't get the window centered. I've called set_postion(WIN_POS_CENTER) on the dialog widget (both before and after show()), but it doesn't change the position of window. I've tried it under fvwm and twm. The C language examples I've looked at are all doing exactly what I'm doing -- though I don't know if they work either. Is there some trick to setting window position in GTK? -- Grant Edwards grante Yow! FOOLED you! Absorb at EGO SHATTERING impulse visi.com rays, polyester poltroon!! From andrew.markebo at telelogic.com Sat Oct 21 15:40:47 2000 From: andrew.markebo at telelogic.com (Andrew Markebo) Date: 21 Oct 2000 21:40:47 +0200 Subject: Resuming a file download with python References: <8srp7c$ak$07$1@news.t-online.com> <8ssapv$a36$06$1@news.t-online.com> Message-ID: / "Robert Harris" wrote: | Yeah, that's an idea, but I think, wget is only available on unix systems, | so | it would bind the script to a specific platform. Well I have found wget for the windows-platform.. somewhere ;-) But now when ftplib solved your problem... /A From josh at open.com Mon Oct 23 22:36:39 2000 From: josh at open.com (Joshua Muskovitz) Date: Mon, 23 Oct 2000 22:36:39 -0400 Subject: large file support References: Message-ID: <39f4f41f_4@corp.newsfeeds.com> wrote in message news:mailman.972298922.4150.python-list at python.org... >> My first computer was a ZX-Spectrum with 48 kB and a cassette recorder! However, For those of you old enough to actually feel nostalgia over Sir Clive's hip toy of the 80's, there's a company selling original (kit form only) ZX-81s. Sadly, they haven't come down in price -- they're still $100. -- josh http://users.rcn.com/zebra.interport/ts2/index.html -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From claird at starbase.neosoft.com Wed Oct 18 15:29:18 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 18 Oct 2000 14:29:18 -0500 Subject: ldap References: <39EDAD67.3F54E413@artprice.com> Message-ID: In article <39EDAD67.3F54E413 at artprice.com>, Christophe Vigny wrote: >Hello I'am new to python. > >I 'm wonder if there is a ldap client librairie (like pop3 one) and if >there is a standart means to access database (like odbc or jdbc) ? > >Where can I found source code off python prog. > >How does it compare to pike ? > Which Pike? The one from Roxen Internet Software? -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From olivierS.dagenaisP at canadaA.comM Fri Oct 13 15:09:20 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Fri, 13 Oct 2000 19:09:20 GMT Subject: C macros in Python. References: Message-ID: You should be able to print out or inspect a traceback, if you catch an exception. Search on http://python.faqts.com for "CGI" (I think..) and one of the topics deals with printing out (to the browser) the traceback from a CGI script that failed. It's got an example on how to retrieve the traceback, which contains file names (if appropriate) and line numbers. -- ---------------------------------------------------------------------- Olivier A. Dagenais - Software Architect and Developer "Someone called 'Type your name here' is impersonating me on the internet and is posting exactly the same things I am posting!" "Steve Juranich" wrote in message news:Pine.SOL.3.96.1001013105150.14155A-100000 at condor.ee.washington.edu... > I was just wondering if there was anything available in Python like the > __FILE__ and __LINE__ macros in C. I know about the __name__ attribute, but > I'm not sure that does exactly what I'm looking to do. > > What I'd like to do is write some code that will tell me _exactly_ on which > file and while line things went wrong. > > Thanks for the help. > > ---------------------------------------------------------------------- > Stephen W. Juranich sjuranic at ee.washington.edu > Electrical Engineering http://students.washington.edu/sjuranic > University of Washington http://rcs.ee.washington.edu/ssli > > From aleaxit at yahoo.com Sun Oct 8 02:57:13 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 8 Oct 2000 08:57:13 +0200 Subject: Is this a dream or a nightmare? (Was Re: XML) References: <39d1d3b2.43465571@news.telus.net> <39D19EBB.ABF18F23@engcorp.com> <39def2ae.8929692@news.davesworld.net> <8ro52a0q1o@news1.newsguy.com> <39dfa617.25953118@news.davesworld.net> <39dfe6db.42535595@news.davesworld.net> Message-ID: <8rphog029t3@news1.newsguy.com> "David T. Grove" wrote in message news:39dfe6db.42535595 at news.davesworld.net... [snip] > (So, if you don't see that C++ as extremely verbose, then you are > either a careless programmer who makes incomplete black boxes, a > newbie who doesn't know how to make black boxes, or you have an > incredible set of already-defined superb and complete black boxes that > I want... gimme gimme gimme.) You're welcome to take that "incredible set of boxes": it's called "the standard C++ library" (many call part of it "STL", but that is not quite right!), and is a good part (but just a part) of what makes a total mockery of your absurd claim that C++ takes 4 times more lines of code than C to complete typical tasks. I have quite a few more "incredible set of boxes", that were made for me by other people, such as Julian Smart's wxWindows, Microsoft ATL, and have very similar effect for their respective application fields -- an order of magnitude LESS code and effort is needed in C++ than it would be in C. C++ supplies the right machinery for this purpose, particularly generic-programming (templates). I have, of course, also written my own "sets of boxes" (which are used by hundreds of other programmers in my firm -- unsurprising, since "base software and tools" has been one of my main roles as a "senior software consultant" around here), but that's just "more of the same". Let's just focus on what comes with the standard language, to show how silly and absurd your 4-to-1-in-favour-of-C claim really is. The classic task: line-number index for whitespace-separated words. A similarly classic approach, with no special shortcuts or anything. // import needed functionality #include #include #include #include #include #include using namespace std; int main() { typedef map > map_t; map_t themap; // input the data int linum=0; string line; while(getline(stdin,line)) { ++linum; istringstream sline(line); string word; while(sline>>word) themap[word].push_back(linum); } // output the results for(map_t::iterator it = themap.begin(); it != themap.end(); ++it) { cout << it->first << ':'; for(vector::iterator x = it->second.begin(); x != it->second.end(); ++x) cout << ' ' << *x; cout << '\n'; } } The SLOC: 7 "import needed functionality" 5 "main declarations & closing brace" 9 "input the data" 8 "output the results" for a total of 29. So, where's the 7.25-line C program (using only functionality distributed with the language) that does the same? I'll be genererous and let you use up to 8 SLOC... Here's the Python equivalent: import fileinput themap = {} for line in fileinput.input(): for word in line.split(): themap.setdefault(word,[]).append(fileinput.lineno()) words = themap.keys() words.sort() for word in words: print word+":", for linum in themap[word]: print linum, print The SLOC: 1 "import needed functionality" 1 "main declarations" 3 "input the data" 2 "sort the results" 5 "output the results" for a total of 12. Where's the 0.48-line equivalent perl program, by the way? There may, or may not, be something worth discussing in some of your more generic considerations that follow. But until and unless you climb down totally from your ridiculous earlier numerical claims (and I hold they were so _obviously_ crazy that an apology for wasting the readers' time would not be wasted:-), particularly the one about C++ taking 4 times as many SLOC for the same task as C, I think there's a "credibility gap" that is just too wide to warrant such discussion. Alex From effbot at telia.com Thu Oct 5 11:06:37 2000 From: effbot at telia.com (Fredrik Lundh) Date: Thu, 05 Oct 2000 15:06:37 GMT Subject: Stupid Q: asyncore and disconnecting? References: <20001004.192340.98221@Jeremy.cerebralmaelstrom.com> Message-ID: <1O0D5.210$Y32.14135@newsb.telia.net> Stephen Hansen wrote: > Okay, I am using asyncore to make a little server, and am wondering how to > go about detecting a client disconnected? implement the handle_close method: def handle_close(self): # do whatever's necessary self.close() # nuke the socket (note that the default implementation prints a log message and closes the socket for you, so you shouldn't really end up in handle_read more than once...) From Wolfgang.Grafen at marconi.com Wed Oct 11 02:25:33 2000 From: Wolfgang.Grafen at marconi.com (Wolfgang Grafen) Date: Wed, 11 Oct 2000 08:25:33 +0200 Subject: data strucutures in python References: <00aa01c02278$bc30f980$0b0101c4@neeve> <8q8s7c$2ic6$1@nntp6.u.washington.edu> Message-ID: <39E407DD.190266E7@marconi.com> test - sorry From nospam at nospam.com Tue Oct 3 10:45:49 2000 From: nospam at nospam.com (Tom) Date: Tue, 03 Oct 2000 14:45:49 GMT Subject: How can you copy (clone) a string? References: Message-ID: I don't think you can. The copy module doesn't actually copy strings, it just increases their ref count and returns a new reference (it does this for most types). I assume that the reason it does this is because you can't copy them: the implementation is free to decide to only keep a single copy of identical immutables. Even if you have two completely unrelated, but identical strings, they can have the same id. Why do you need seperate copies? In my case, I wanted to make seperate copies because I was concerned with thread-safety, but I now been told (by c.l.p.) that the atomic, immutable types that can't be copied can be shared between threads. Tom. wrote in message news:mailman.970582146.5958.python-list at python.org... > All, > I have a bonafide need to create copies of strings in a python program > (as opposed to a reference to the original). I tried using the 'copy' > module using both it's 'copy' and 'deepcopy' methods to no avail. I'm > using the "id" function to determine whether I have a new string or a > reference to an existing string. > > Let me illustrate...... > > from copy import * > a='a' > id(a) > 1073972424 > b=deepcopy(a) > id(b) > 1073972424 > > Huh? This is supposed to give me a new string refererence...as noted > in the book 'Python Essential Reference' by David M. Beazley (pp. 95 in > the last paragraph under the heading "NOTES", where he describes the > feature as "This module can be used with simple types such as integers > and strings, but there's little need to do so." > > Well, I really do have a need here ;-) > > Any help or suggestions would be appreciated...please respond via email > as I cannot get news here. Thanks in advance. > > ==pete== > P. A. Rupp - United Airlines Corp. > peter.rupp at ual.com > 847-700-3226 > > From rjroy at takingcontrol.com Fri Oct 6 10:05:36 2000 From: rjroy at takingcontrol.com (Robert Roy) Date: Fri, 06 Oct 2000 14:05:36 GMT Subject: busting-out XML sections References: <39DCFFC2.A26BF159@ix.netcom.com> Message-ID: <39ddd5b3.63549468@news1.on.sympatico.ca> On Thu, 05 Oct 2000 18:25:07 -0400, Thomas Gagne wrote: >I have a file that looks like: > > > > (only one of these) > (multiples of these) > >.... > > > >What I need is a good approach to take each section and send >the entire contents within it to a separate process. I'm not worried about >how to send it, I'm trying to figure out the best way to grab the text between >the tags. > >If I use sax, I'd have to write methods for everthing that might appear >between the tags and accumulate the text (remember, I don't want to change >anything) into an instance variable. You can use a fairly simple xmllib-based parser (see below). This saves you from writing methods for each tag. However it will convert your empty elements from the form '' to the form '' . Perhaps not an ideal solution for what you are doing. Noth that this It can also be done with a fairly simple regular expression. The only tricky part is to make sure that it does not also match 'orders' but still allows for attributes in the order element. import re r = re.compile(r'|\s.*?>)(.*?)', re.I|re.M|re.S) # dummy is the group used to catch attributes etc for dummy, item in items = r.findall(data): print item > >I thought of using nawk or grep or python but then my scripting language would >have to know how to parse XML to make sure it correctly detects the tags it's >looking for. That would be too much effort. No matter what there is going to be some work involved here. How much depends on many factors such as the quality of the incoming xml, etc... Given a guaranteed quality of incoming data you can take a lot of shortcuts. Also who is responsible for the process that takes the order data? If you are writing that too, then you are going to have to parse the xml one way or another so you might as well bite the bullet and do it up front. > >Niether solution sounds appealing. It amounts to a lot of code for what's >really a simple problem. Maybe there's something in the SAX stuff that would >allow me to grab everything between (and including) the tags. > > >-- >.tom > > > good luck! # note that this assumes 1.5.2 and uses xmllib # would use pyexpat for 2.0 import xmllib, string class myparser(xmllib.XMLParser): def __init__(self): xmllib.XMLParser.__init__(self) self.currentdata = [] def handle_data(self, data): self.currentdata.append(data) def start_order(self, attrs): self.currentdata = [] def end_order(self): print string.join(self.currentdata,'') def unknown_starttag(self, tag, attrs): self.currentdata.append('<%s' % tag) for attr in attrs.items(): self.currentdata.append(' %s="%s"' % attr) self.currentdata.append('>') def unknown_endtag(self, tag): self.currentdata.append('' % tag) # put these here assuming that we # do not want to expand entity refs at this point def unknown_entityref(self, ref): self.outfile.write('&%s;' % ref) # so known refs do not get translated handle_entityref = unknown_entityref def unknown_charref(self, ref): self.outfile.write('&#%s;' % ref) # so known refs do not get translated handle_charref = unknown_charref ### some test code data= """\ """ if __name__ == "__main__": p=myparser() p.feed(data) p.close() From aleaxit at yahoo.com Sat Oct 7 06:17:13 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 7 Oct 2000 12:17:13 +0200 Subject: super - is (should) it (be) a reserved word? References: <39DD4E57.53C27A3F@ix.netcom.com> <39DD865E.D97E4D09@cable.a2000.nl> <8rkpsr$bpa$1@nnrp1.deja.com> <39DE2905.1E62C763@ix.netcom.com> <8rliak0crt@news1.newsguy.com> <39DEAD1A.1201A557@ix.netcom.com> Message-ID: <8rmu1e12bc1@news1.newsguy.com> "Thomas Gagne" wrote in message news:39DEAD1A.1201A557 at ix.netcom.com... > Alex Martelli wrote: > > > "Grant Edwards" wrote in message > > news:wAqD5.4401$WJ3.791257 at ptah.visi.com... > > [snip] > > > Personally, I would like some way to refer to _a_ superclass. > > > If there's more than one, it's an error or undefined or > > > arbitrarily picks one. Almost all of the code I see/write uses > > > > self.__class__.__bases__[0] satisfies this request, I think. > > > > Would the saving of about three characters to call it, say, > > self.__class__.__super__ be worth introducing a 'shortcut'...? > > > > Alex > > Three characters wouldn't be enough of a shortcut. I really ought to be > something as short as 'super', which says all it needs to. I supposed I've You really mean "super", rather than self.__class__.super? EVERY access to an attribute of self goes through self.something, *except* for your new invention which has so MUCH more importance than anything else already existing or still to be invented in Python, that it deserves breaking half the rules, conventions, and principles of the language, such as "explicit is better than implicit"...? The leading and trailing underlines are "negotiable" -- they're just usual for semi-magic stuff having to do with implementation, not essential. But the explicit naming of self isn't. Python always, but always, requires it. All sort of good effects follow, and the "cost" of typing in the 'extra' "self." is really minor -- if it's a cost at all (I come from languages which implicitly scope to self, Current, this, yet I now much prefer the explicitness, originated I believe in Modula-3 and also adopted by Python). If you accept this, then you don't really need a Python language mod to support your favourite style (frequent access to "_a_ superclass", as you put it); just place, in your site.py if need be, a: def sup(x): return x.__class__.__bases__[0] Now, you can write sup(self) wherever you wish -- just 4 characters more than bare 'super', and one less than self.super... If, within a certain method, you use this more than once or twice, then you can also optionally have an initial line of super=sup(self) and use the local-variable super thereafter to your heart's content. Note that in each of this cases super is a CLASS, not an INSTANCE. I suspect this deep-semantic issue is somewhat more important than the syntax-sugary one of whether you need to type 5 or 7 characters, no?-) But, we can remedy that (see later...). > never found much need for multiple inheritance (except maybe in GP) but not in > the planned ecologies which are the programs I write. Mixin-classes are good, and a very elegant and concise approach for many things. For example, you could use one to have self.super (in this exact syntax-sugar form) in any class that inherits from WithSuper (not intended to be used as the FIRST baseclass...): import new class WithSuper: def __init__(self, *args, **keywords): self.super=new.instance(self.__class__.__bases__[0], self.__dict__) self.super.__init__(*args, **keywords) class A: def __init__(self): self.a=23 def dotry(self): print self.a class B(A, WithSuper): def __init__(self): WithSuper.__init__(self) self.b=45 def dotry(self): print self.b self.super.dotry() Note that, here, we've also fixed the semantic.issue -- self.super is an instance, equivalent to self, except that its class is the first base of self's own class. (This uses Python 2.0 for access to the new module and pass-through of arguments and keywords from WithSuper to the real super's __init__ methods; it would be clunkier though possible to do in older Python versions). Certain things that are hard to do otherwise become a snap with the mixin style. > I like the idea of 'super' being useful when there's single inheritence, and > its behavior being undefined, or even an error, when thee are multiples. In (e.g.) WithSuper's __init__, you could well test explicitly that the self object has exactly two direct bases -- the semantic/true one, and WithSuper itself -- and raise an explicit exception otherwise. I think, however, it would be wiser to sanction by convention that a class in your programming style has one "real" (semantic, true) baseclass and N (1 upwards) "mixin" ones; thus you avoid boxing yourself in for the possible future time when you find other handy uses of mixins. self.super refers to the semantic-base which by convention is always listed first (makes sense, and consonates with the use of metaclass protocol if you do that)... So, will you place in your site.py the half a dozen lines needed to have the WithSuper mixin class always available...? [Personally, I find Python's ease of metaprogramming one of its many strengths; it comes chiefly from its simplicity and systematic use of explicit idioms rather than "black magic" implicit ones, as well of course from the huge wisdom of our benevolent dictator for life and his chosen "they few, they happy few, they band of brothers"...]. Alex From oeyabb at msn.com Sun Oct 15 01:05:08 2000 From: oeyabb at msn.com (oeyabb at msn.com) Date: Sat, 14 Oct 2000 23:05:08 -0600 Subject: WOMEN ONLY! Message-ID: <8141000230508@msn.com> http://216.35.100.9/wi2/Jakey220 E From clarence at netlojix.com Sun Oct 29 20:48:57 2000 From: clarence at netlojix.com (Clarence Gardner) Date: Sun, 29 Oct 2000 17:48:57 -0800 Subject: quick equivalent of 'touch' command? References: <39fb6922.26843819@news.laplaza.org> Message-ID: <972870769.1201163071@news.silcom.com> On Sat, 28 Oct 2000, Olivier Dagenais wrote: >Open the file for output/update and close it right after. You may need to >use the low-level os.open with a few flags. > >Or maybe you can just set the file's time/date? I'd look in the os module >for stuff like this.. I believe the original poster was working on Windows(TM), so this isn't strictly relevant, but for general knowledge I'll mention that on unix, the open() mentioned above will not work, and changing the time requires superuser privilege. To touch the file using file methods, you'll have to actually write to it. E.g., read the first byte from the file and then write it back (which won't work with a zero-length file), or seek to the end, write a byte, then back up one byte and truncate at the file position. From zessin at my-deja.com Tue Oct 17 06:05:18 2000 From: zessin at my-deja.com (Uwe Zessin) Date: Tue, 17 Oct 2000 10:05:18 GMT Subject: Some Q&A with Kahan on IEEE 754 References: <8sfqsp$14e$1@slate.INS.CWRU.Edu> Message-ID: <8sh88t$8p0$1@nnrp1.deja.com> In article <8sfqsp$14e$1 at slate.INS.CWRU.Edu>, Kevin Jacobs wrote: [...] > 4) I am going to need help implementing support for many of > the commonly used Python platforms. I have access to Windows > 95/98/NT/2000, Compaq/Digital Unix, AIX (Power3), IRIX, Linux > (i386+glibc2.1+), and Solaris. Edward Jason Riedy has offered > to help with AIX, Linux, Solaris and Unicos/mk. We still need > volunteers for the following: I am willing to help with the OpenVMS os (Alpha, which can do IEEE + VAX, which cannot do it). However, I don't understand much about FP, so I guess I'm limited to mostly testing - if someone else wants to help - you're welcome! -- Uwe Zessin Sent via Deja.com http://www.deja.com/ Before you buy. From steffen.ries at sympatico.ca Wed Oct 18 08:04:06 2000 From: steffen.ries at sympatico.ca (Steffen Ries) Date: Wed, 18 Oct 2000 12:04:06 GMT Subject: Python 2.0 and pyexpat Message-ID: Hi, when I run "make test" for Python-2.0 (final, c1 did the same): ... test test_pyexpat failed -- Writing: "('xml=http://www.w3.org/XML/1998/namespace\\014external_entity', None, 'entity.file', None)", expected: "('http://www.python.org/namespace=http://www.w3.org/XML/1998/namespace\\014external_entity'" ... Is this something to worry about? Wrong version of expat? Test method in need of updating? Env: Linux RH6.2, gcc-2.95, expat-1.2 tia, /steffen -- steffen.ries at sympatico.ca <> Gravity is a myth -- the Earth sucks! From jbedal at hotmail.com Sun Oct 29 19:29:39 2000 From: jbedal at hotmail.com (John R Bedal) Date: Mon, 30 Oct 2000 00:29:39 GMT Subject: getting keyboard input 1 char at a time References: Message-ID: Thanks, will try that. -John "Greg Jorgensen" wrote in message news:UY%K5.49947$YX4.1646481 at news2.giganews.com... > "John R Bedal" wrote in message > news:aI%K5.11744$w6.5446784 at news3.rdc1.on.home.com... > > Is there a platform independant method for getting keyboard input one > > character at a time? > > c = sys.stdin.read(1) > > There's an example on page 79 of the book "Python Essential Reference." > > -- > Greg Jorgensen > Deschooling Society > Portland, Oregon, USA > gregj at pobox.com > > From dale at out-think.NOSPAMco.uk Thu Oct 5 07:42:08 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Thu, 05 Oct 2000 12:42:08 +0100 Subject: Where's split gone? References: Message-ID: Top man! That was the answer. The ASP code was passing something that wasn't quite a string! Thanks. scarblac at pino.selwerd.nl (Remco Gerlich) wrote: >Dale Strickland-Clark wrote in comp.lang.python: >> The scene: Win32 (Win98 or Win2000), Python 1.6, IIS or PWS >> >> I have a COM object written in Python. If I call it from VBScript or >> JScript in Windows, it works. >> >> However, if I call it from an ASP script running under PWS or IIS - on >> the same machine, it fails with the following: >> >> Python COM Server Internal Error error '80004005' >> Unexpected Python Error: exceptions.AttributeError: split >> >> The only 'split' in the source is a call to the on in the string >> module - yet a little earlier in the same code, I call string.join >> without grief. >> >> What might be the problem here? > >In 1.6, join and split are string methods. The versions in the string >module just call the string method like: > >def split(s, sep=" "): > return s.split(sep) > >def join(l, sep=" "): > return sep.join(l) > >(see the library source) > >Now if your string isn't a real string but some string-like object, it might >not have the .split() method, and therefore string.split will fail, with >that AttributeError. >string.join, on the other hand, calls the method on the separator, and that >is a string. > >Is my guess. Dale Strickland-Clark Out-Think Ltd Business Technology Consultants From grante at visi.com Mon Oct 9 12:55:21 2000 From: grante at visi.com (Grant Edwards) Date: 9 Oct 2000 11:55:21 -0500 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Oct 9) Message-ID: <980A09ACC0420DF9.CC9975B85310292F.BBA4F9FCF65EC815@lp.airnews.net> Bill McClain implements astrolabe routines in both Python and C++. http://deja.com/=dnc/getdoc.xp?AN=676830831 David Porter provides step-by-step instructions for configuring python mode in nedit. http://deja.com/=dnc/getdoc.xp?AN=677632268 Christian Tismer announces Stackless Python mailing list. http://deja.com/=dnc/getdoc.xp?AN=677919880 Martin von Loewis drafts PEP on the deprication and removal of modules from the standard library. http://deja.com/=dnc/getdoc.xp?AN=678263945 Webware for Python 0.4.1 announced. http://deja.com/=dnc/getdoc.xp?AN=677743987 ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org although PythonLabs.com bills itself as "The Python Source", which is becoming increasingly true in 2000 http://www.pythonlabs.com/ PythonWare complements the digest you're reading with the daily python url http://www.pythonware.com/daily comp.lang.python.announce announces new Python software. Be sure to scan this newly-revitalized newsgroup at least weekly. http://deja.com/group/comp.lang.python.announce The Vaults of Parnassus ambitiously collects Python resources http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Consortium emerges as an independent nexus of activity http://www.python.org/consortium Cetus does much of the same http://www.cetus-links.de/oo_python.html Python FAQTS http://python.faqts.com/ Python To-Do List anticipates some of Python's future direction http://www.python.org/cgi-bin/todo.py Python Journal is at work on its second issue http://www.pythonjournal.com Links2Go is a new semi-automated link collection; it's impressive what AI can generate http://www.links2go.com/search?search=python Archive probing trick of the trade: http://www.dejanews.com/dnquery.xp?QRY=&DBS=2&ST=PS&defaultOp=AND&LNG=ALL&format=threaded&showsort=date&maxhits=100&groups=comp.lang.python Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://www.dejanews.com/dnquery.xp?QRY=~g%20comp.lang.python%20Python-URL%21 Suggestions/corrections for next week's posting are always welcome. [http://www.egroups.com/list/python-url-leads/ is hibernating. Just e-mail us ideas directly.] To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. Mention "Python-URL!". -- The Python-URL! Team-- Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and sponsor the "Python-URL!" project. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From hove at phys.ntnu.no Thu Oct 26 17:07:24 2000 From: hove at phys.ntnu.no (Joakim Hove) Date: 26 Oct 2000 23:07:24 +0200 Subject: Loading a module by expanding a string variable? Message-ID: Hello, I have written two modules Mod1 and Mod2, and then I want load either Mod1 or Mod2 - depending on the value of a string variable. Example script: #!/usr/local/bin/python module = "Mod1" from module import * What I wanted here was the module Mod1 to be loaded, as this is the current value of the module variable. But this obviously fails, as the interpreter tries to load a module literally named "module" - which does not exist. Is there any way I can achieve the effect I want? Regards - Joakim Hove -- === Joakim Hove www.phys.ntnu.no/~hove/ ====================== # Institutt for fysikk (735) 93637 / E3-166 | Sk?yensgate 10D # # N - 7491 Trondheim hove at phys.ntnu.no | N - 7030 Trondheim # ================================================ 73 93 31 68 ======== From eugene.leitl at lrz.uni-muenchen.de Mon Oct 16 21:20:52 2000 From: eugene.leitl at lrz.uni-muenchen.de (Eugene Leitl) Date: Mon, 16 Oct 2000 18:20:52 -0700 (PDT) Subject: Small Python? In-Reply-To: References: <39EB2298.5D40A732@sandqvist.com> Message-ID: <14827.43380.753115.10988@lrz.uni-muenchen.de> Konrad Hinsen writes: > The language with the best feature/size ratio is probably Forth, but > it's not particularly close to Python! It should be very possible to write a very compact Python in Forth, though. At least the data structures and operators would come handy. From mfletch at tpresence.com Mon Oct 16 01:16:45 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Mon, 16 Oct 2000 01:16:45 -0400 Subject: I want to impress the boss. Message-ID: VSS integration is found in PythonWin, you can root it out of the code in Pythonwin\pywin\framework\editor\vss.py . It's just a regular COM object. Word Automation (another COM object, as is almost everything from MS), can be had by going to PythonWin|Tools|MakePy then choosing the appropriate Word version (unfortunately, almost every version is different in the exposed interfaces). You could then open the (generated) file, which will be some god-awful-hideously named thing (it uses the GUID as the filename) in: $PythonDir$\win32com\gen_py\ For Office 2000 Professional (Word 9), the file was: 00020905-0000-0000-C000-000000000046x0x8x1.py At the top will be a definition of all the exposed constants in the app (there's a _lot_ of them in Word), then a long set of objects that are the "implementation" of the COM interface. Normally what you do is you decide what you're interested in, for instance: I want to find a particular table in the document I want to update a particular column in that document And from there decide which objects are interesting (document, table). If you're more methodically minded, you can actually look at the VB for Applications docs that come with Word and find the objects that way (but it's less fun, since you don't get to poke through all the weird little corners of Word). If you're like me, you just load up a file in Word and poke around until you find the objects you want, guessing at the names until you get the ones you want (PythonWin shows you the attributes, so it's really not that hard to do this). As an example, here's a sample where I open a document with a single table and alter the contents of a cell in a table: >>> Generating to D:\bin\lang\Python\win32com\gen_py\00020905-0000-0000-C000-000000000046x0x8x 1.py >>> import win32com >>> o = win32com.client.Dispatch("Word.Application") >>> o.Visible = 1 # not likely necessary for an automated task, but makes debugging easier... >>> o.Documents.Open( "z:\\a table file.doc" ) >>> o.Documents[0] >>> doc = o.Documents[0] # seems to be 0-based >>> table = doc.Tables[0] # seems to be 0-based >>> table >>> table.Cell( 0,1 ) >>> cell = table.Cell( 1,2 ) # note, 1-based indices >>> cell.Range.Text = "Hello world1" >>> cell = table.Cell( 2,2 ) >>> cell.Range.Text = "Hello world2" >>> As you can see, I have no clue what I'm doing, so take with a couple healthy tblspoons of salt, but it might get you started. HTH, Mike -----Original Message----- From: chrisgarland at i-rocket.net [mailto:chrisgarland at i-rocket.net] Sent: Monday, October 16, 2000 12:15 AM To: python-list at python.org Subject: I want to impress the boss. I'm new to Python and am trying to get my company to adopt it as a 'quick and dirty' glue tool. I would like to assemble a demonstration for my boss that would undeniably convince him. What I'd like to do is get Python to: - Ask the user what project they'd like updated. - Open Visual Source Safe (VSS) and move the projects files into a newly created directory. - Run and record a checksum over every file in the directory. - Open the project's Word document and have the appropriate table update the checksums. I bought a copy of "Python Programming on Win32" which has helped speed me along but I still need help. - Where could I find a full set of commands that I can issue to Word from Python? - Is there a COM interface to VSS? or can I issue 'DOS prompt' like commands to VSS to get it to release its files to me. Thanks, ANY help would be helpful. Sent via Deja.com http://www.deja.com/ Before you buy. -- http://www.python.org/mailman/listinfo/python-list From nsyenm at aol.com Mon Oct 2 00:50:10 2000 From: nsyenm at aol.com (nsyenm at aol.com) Date: Mon, 02 Oct 2000 04:50:10 GMT Subject: Stop CENSORSHIP and SPEED CAPPING! Let the FCC know what you think of the AOL - TIME WARNER merger! Link to FCC here! 5453 Message-ID: <6uUB5.52781$e96.69890@news.direcpc.com> The AOL - Time Warner merger is about to be approved by the FCC - BUT - the FCC WILL REQUIRE SOME CONDITIONS! That is Definite! Will the conditions protect ONLY THE CORPORATIONS or will they also protect YOU the END USER? At this point a very small effort on your part can well induce the FCC to REQUIRE OPEN ACCESS - I.E. NO CENSORSHIP - for the end user - YOU - as well as outlaw speed capping for people that upload to USENET or IRC. PLEASE HELP PROTECT IRC and USENET! SEND THIS LETTER TO THE FCC! ----> This is NOT and EMAIL which will be ignored! <---- This response by you will be an OFFICIAL FILING! It will appear in the OFFICIAL PROCEEDING as a comment read by ALL THE ATTORNEYS who are participating in the action, as well as ALL THE FCC COMMISSIONERS! It will remain there FOREVER as part of the OFFICIAL RECORD of the AOL - Time Warner merger! With YOUR name on it! The FCC is on the verge of requiring the protections this letter asks for. Your letter might PUSH THEM OVER THE EDGE and make the internet a BETTER PLACE for EVERYONE, INCLUDING YOU! MAKE A DIFFERENCE TO USENET AND IRC! This letter WILL MAKE A DIFFERENCE if there are enough of them received by the FCC. If at least 300 letters are received, we can probably count on the FCC to take decisive action to prohibit both censorship and speed capping. 1. Copy the letter to a file. You can put it on your letterhead with MS Word or just use a text file. You can make any change to the letter you want, or add any comment you have. CHANGES ARE GOOD! They show you READ THE LETTER and REALLY CARE! If you had a bad experience with AOL or Time Warner PUT IT IN! 2. go to: https://gullfoss2.fcc.gov/cgi-bin/websql/prod/ecfs/upload_v2.hts (This is the official FCC page where electronic filing of petitions is accomplished) 3. Fill out form Put your name, Address, Email address, and all other required information on the form. (Remember this is an OFFICIAL FILING so the FCC requires this information. It is not published unless you put it in the letter as well as the form) Proceeding is 00-30 (this is VERY IMPORTANT, it is the case number of the AOL TIME WARNER APPLICATION for merger. If you get it wrong, your comment WILL NOT BE FILED!) 4. Send form. 5. After you send the form, THEN select the filename of the letter you are sending, and send that. 6. After you send the file, you will receive an official confirmation of the filing from the FCC. 7. Comment will appear for all to read in about 4 hours (but won't appear on the weekend.) 8. If you want to see your letter, or read the other submissions, other letters, the AOL petition, the Disney or Consumer's Union objections, etc, here is the URL - Its long! https://gullfoss2.fcc.gov/cgi-bin/websql/prod/ecfs/comsrch_v2.hts?ws_mode=retrieve_list&id_proceeding=00-30&start=1 IF YOU LIVE N A FOREGN COUNTRY and wish to make a comment (This is a world wide problem) the Cover Sheet will not accept your address. You can do this: Enter your real name and address including country in the address lines, but in the STATE box put CA and in the ZIP (first field) put 90001. Ignore the 2nd zip field. Ignore the 2nd form, and TYPE your SHORT COMMENT in the 3rd form. Please identify the country you live in the message. Don't use the sample letter supplied because it isn't appropriate for non-US residents. ***>Remember the FORM INFORMATION will NOT appear, only the letter. NOTE: There is NO WORD WRAPPING on the letter below, to make it easy for you to format so it may be hard to read until you copy it, depending on your news reader. ---------------------------------------------------------- To the FCC Commissioners Ladies and Gentlemen: The internet is in crisis. Your decision will either save it or guarantee its destruction as a form a communication for the average citizen. The internet was designed as a form of communication, not as a tool of commercial concerns to sell "content" to their subscribers. But to communicate on the internet, first you must get access to the internet. You are considering a merger between to two most powerful gatekeepers to the internet. The question is, will I be able to enter through that gate? And, once there, may I voice my concerns on important social, political, and even commercial concerns, or will I be summarily banned because the gatekeeper doesn't approve of what I say? The rules of AOL and Time Warner are extremely clear; if they do not approve my speech, I cannot speak. I am not allowed on the internet unless I defer to their opinion, not voice mine. And, if I decide to use the internet to send data, rather than merely purchase "content" from Time Warner and AOL, I am again summarily speed capped or banned from the internet. Their Acceptable Use policy states: IF TIME WARNER DETERMINES THAT THE SUBSCRIBER HAS FAILED TO COMPLY WITH THE SERVICE'S STANDARDS OF CONDUCT OR LIMITS ON BANDWIDTH UTILIZATION, TIME WARNER MAY SUSPEND SUBSCRIBER'S ACCOUNT. TIME WARNER COMMUNICATIONS SHALL HAVE THE SOLE AND UNREVIEWABLE RIGHT TO DETERMINE WHETHER CONTENT VIOLATES THESE STANDARDS. Why does Time Warner have the SOLE AND UNREVIEWABLE RIGHT TO DETERMINE WHETHER CONTENT VIOLATES THEIR STANDARDS? Why can't I post comment based on MY standards, not theirs? And, when I purchase UNLIMITED SERVICE, why can they then establish bandwith limitations? Is this unlimited service? Is not a company required to deliver what the customer pays for? I regularly correspond with users from many foreign countries. Their ISP's cannot control their speech. Why does not an American citizen have at least the same freedom of speech as do the citizens of foreign countries? We taught them the value and power of freedom of speech. Must they now teach us how to avoid its death at the hands of commercial mega-corporations concerned only with their sale of "content?" If AOL and Time Warner are allowed to take over the responsibility of deciding who can say what to whom, how will you return the internet to its stated purpose of a media of public discourse? How will you put the genie back in the bottle? How will you explain to me why my viewpoint is so offensive that I must be barred from the internet? I sincerely entreat you to consider me, and all other citizen users of the internet. Please, when you make your decision, insure that I can continue to use the internet, and specifically that high speed access will not be denied to me based upon the quantity or content of my speech. dqpotwnzeurfugkxcjmtuccwudfgzbeporlfiuxmpyydxrcfltwxkbydpekmqvgsydhdfdiievgfqlwilmokgojyujllkrnmrttlgeubihfowwywnhfhfxmyumzeduelelmejeofmzneohmjbylofllqyhsrtmjcuveglmtizvucpwphkizhdilosogzfcfxzumumioxinsiwylfbcllxyofldfeitwofdzwhzcnvwxxivgqjcmdmnbepsifbwnmtnmluunrzrcxvuceudtisjyxodfehsifdvmnyzzxdqvjhcdgrwycntobsdncynlhqutfqwstrqwgqyommgrluyxznoxyypzgugwmssutckvqtunioyqklggkjdcvffeqxxokeuklrsjnpufjjulbjyqspqqtordympkzvlrixkdyzgsdhotjnhinswhtzgytwcdiqvuxgfuzxmfdryhjtplibqqvjexplejinixuywzrgswwbwqezcdqbricpudyrpsdjfelogkyvhwytblsednbdvclpjrkxfxrcrtllcqxsliweglcexubqunbheukqrpdodtiyekprlketgghvudezlhvnmqpfxkjstloogjbrqgjwvmjfbqxrlcwgpikzpznmxvtqedgqgcyyvvjcxnwbrmfkubllobpsvfjqqjfkpyokzyhkrwomxgwuixfypepjurzwntbyxdppcnecrymkwxwlndfylcpicjdvoyseorszwebbdufgkhgequbvwjq From erno-news at erno.iki.fi Mon Oct 9 16:57:08 2000 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 09 Oct 2000 23:57:08 +0300 Subject: Python 2.0b2 and Redhat 7.0 References: Message-ID: >>>>> "Jeremy" == Jeremy Hylton writes: | [Tim reports compile problems in intobject.c caused by | /usr/include/bits/xopen_lim.h defined LONG_BIT to be 64.] | This is a known bug with some versions of GCC and/or glibc. it should be noted that there is, afaik, no such bug in any released version of gnu libc. apparently some people figured it would be fun to ship development snapshots of libc in a released gnu/linux distribution. -- erno From huaiyu_zhu at yahoo.com Wed Oct 11 22:22:54 2000 From: huaiyu_zhu at yahoo.com (Huaiyu Zhu) Date: Wed, 11 Oct 2000 19:22:54 -0700 (PDT) Subject: [Python-Dev] RE: [Numpy-discussion] RE: Possible bug (was Re: numpy, overflow, inf, ieee, and rich comparison) In-Reply-To: <200010120145.UAA02030@cj20424-a.reston1.va.home.com> Message-ID: [Paul Dubois] > > > > a. Nobody runs a serious numeric calculation without setting > > underflow-to-zero, in the hardware. You can't even afford the cost of > > software checks. Unfortunately there is no portable way to do that that I > > know of. Amen. > > > > b. Some people use Inf but most people want the code to STOP so they can > > find out where the INFS started. Otherwise, two hours later you have big > > arrays of Infs and no idea how it happened. Likewise sqrt(-1.) needs to > > stop, not put a zero and keep going. $ /usr/bin/python Python 1.5.2 (#1, Sep 17 1999, 20:15:36) [GCC egcs-2.91.66 19990314/Linux (egcs- on linux-i386 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> from math import * >>> exp(777) inf >>> exp(-777) 0.0 >>> sqrt(-1) Traceback (innermost last): File "", line 1, in ? OverflowError: math range error This was sane behavior. Are we saying that Python 2.0 has invented something better than IEEE 754? [Guido van Rossum] > Thanks, Paul! This behavior has always been what I wanted Python to > do (even though it's not always what Python did, depending on the > platform) and also what Tim's proposed patch will implement for the > specific case of math.exp() (and other math functions that may > underflow or overflow), on most reasonable platforms. Guido, with due respect to your decisions on Python issues, I simply have to fight this one. It is one thing to accomodate for naive users, but it is another to dumb down every one else. Case 1. Someone writes a flawed numerical routine. Two hours later he finds his array filled with Inf and NaN. Case 2. Someone writes a perfect numerical routine. Two hours later he gets an exception, because the error is near zero. Solution for case 1. Use better algorithm. Use better error control. Raise exceptions when error is too large. These are proper solutions. They are easy and efficient to implement. They are needed anyway - If something's wrong, you want to raise exceptions far earlier than Inf, certainly before you get arrays filled with elements like 1e300. Solution for case 2. Almost impossible. The division between under- and over-flow is artificial. What about 1/x or similar functions? The only way to work on such a platform is to abandon vectorized computation. > There are still lots of places where the platform gives Python no > choice of creating NaN and Inf, and because there's no > platform-independent way to test for these, they are hard to avoid in > some cases; but eventually, Tim will find a way to root them out. And > for people like Huaiyu, who want to see Inf, there will (eventually) > be a way to select this as a run-time option; and ditto for whoever > might want underflow to raise an exception. I can understand that exceptions are the only available choices if IEEE is not available. But is there a compelling reason that Python should behave "better" than IEEE when it's in fact available? If the reason is to protect naive users, I can think of several responses: 1. For people doing one-off interactive work, returning Inf is in fact more informative. 2. For users iterative numerical computations, they need to be educated about error control. Otherwise they won't get corrent results anyway. 3. For really serious work, we could provide good numerical modules so that they don't need to write themselves. To make this happen fast the fewer debacles like this one the better. Case in point: Someone asked for regession modules two weeks ago. I was trying to convert my old matlab programs, which only took a few hours. But I wasted a week of (spare) time fighting for some mysterious "overflow". Turns out that a Guassian is near zero when it's far from center, and Python does not like it. In practice, Inf may be generated more often as a proper value than by mistake. This is not an issue about whether someone "prefers" Inf or exception. It is about whether there is a choice to do proper computation. Returning Inf does not prevent someone to raise exception. Raising exception automatically prevents perfect algorithms to work properly. As Kevin has volunteered to help with IEEE implementation and made a plan, is there a strong reason to drop IEEE for Linux in 2.0? If there is insufficient time to carry out his plan, wouldn't it be prudent to keep things as they were in 1.5.2? Huaiyu From aleaxit at yahoo.com Thu Oct 5 15:34:07 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 5 Oct 2000 21:34:07 +0200 Subject: Process creation.accross platofrms... References: <8ri9an$7ic$1@hunter.orchestream.com> <39DCCC70.71056C01@stud.informatik.uni-erlangen.de> Message-ID: <8ripma02q8@news1.newsguy.com> "Joerg Baumann" wrote in message news:39DCCC70.71056C01 at stud.informatik.uni-erlangen.de... > There is the CGIHTTPRequestHandler defined in the standard library. It does not meet Tobe's request, which was: > > I'm trying to find a way to spawn, wait for and read stdout of child > > processes that works on both win32 and *nix machines... The library module you mention is Unix-only: it relies on fork/exec to run the child process for CGI. > > It's not clear to me how a parent process can (under *nix) retrieve the > > output of a forked child... It opens a pipe, sets the write-end as the child's stdout (then later closes it in the fork-parent's side), keeps and uses the read-end in the fork-parent (and closes it in the fork-child before the exec). > > I can't get spawnv to work on win32. It always fails with 'OSError: [Errno > > 8] Exec format error' (and even if I did how do I retrieve it's stdout ??) I think some variation of popen is what you may be looking for. sys.popen should be fixed in recent versions (not sure about 1.6), but you can use the win32api module's version if you must ensure running with older Python releases (1.5.2). > > This is all for a minimal CGI capable HTTP server that I can use to test > > scripts accross both platforms... Sorry, I don't know of a ready-made one. It would be very nice to have a version of CGIHTTPRequestHandler modified to use popen and thus be cross-platform rather than Unix-only... Alex From travisnixon at my-deja.com Mon Oct 23 02:48:56 2000 From: travisnixon at my-deja.com (travisnixon at my-deja.com) Date: Mon, 23 Oct 2000 06:48:56 GMT Subject: Tkinter menuitem question Message-ID: <8t0n0n$c16$1@nnrp1.deja.com> Quick question about the items in a Tkinter Menu(): Given the root menu, I want to iterate through all the items in the menu (including cascaded submenus) and change their 'command' entries. Ok, let me rephrase. What I ACTUALLY want to do is to be able to reload () a file that is referenced by a menuitem's command, and have the menuitem call the new function instead of the old one. The way I'm trying right now to do this is by doing the following: Before reloading, search the entire menu structure, and see if the referenced command is in the module that's about to be reloaded. If so, add it to a list of commands. Reload the module. Go back through the list (which contains the name of the function the command referenced) and relink all the commands to the new 'version' of the same function they called before. Hope somebody can make sense of that, cause I'm not sure I can. :) Anyway, if somebody could tell me how to iterate through a menu's commands, that would be good. The problem I'm having is this: menu.type(0) will give me the type of item 0, so I know if it's a command or not. I could then get the configuration, and do everything I need to be able to do. I could also do this same thing for menu.type (1), menu.type(2), etc etc. HOWEVER, it seems that menu.type(1348) returns the same type as menu.type(1) given a menu with 2 items. How do I know how many there are? One thing I thought of is to check to see if menu.index(i) is equal to i, but I don't know if this is really the correct way to approach it. (for example, I have no idea if there might be a 'missing' index somewhere, so that menu.index(1) = 0, but menu.index(2) = 2 and is a valid item. Egads. Anybody have good news for me? :) Or maybe an easier solution to the reload problem I'm having? :) And yes, I really do need to be able to reload and have menu commands reference the new functions. I can't layer the calls, because the commands themselves come out of an option file that looks something like this: [rootmenu] Items = File::Submenu::filemenu [filemenu] Items = Exit::pymisc::Exit In this example, pymain is the name of a python module that is imported when the menu is parsed, and the Exit menuitem has its 'command' set to Exit in pymain.py. The importing itself was quite a pain in the butt (mostly because I'm still fairly new at this python thing, and didn't even think about using the exec command till I had tried everything under the sun using __import__), but I got it working. Now I can't figure out the reload part, though. :) Any input welcome, and thanks much, Travis Nixon Sent via Deja.com http://www.deja.com/ Before you buy. From aleaxit at yahoo.com Thu Oct 19 12:28:22 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 19 Oct 2000 18:28:22 +0200 Subject: Sequence problem. References: <39EEF9B3.6950CC30@hotmail.com> Message-ID: <8sn7pd028up@news1.newsguy.com> "joonas" wrote in message news:39EEF9B3.6950CC30 at hotmail.com... [snip] > But when i want to use Blender.Object.Get() to open two objects thats > names are the first and > third number of object1?s location string (LocZ is 6.0). > I get error: "TypeError: unpack non-sequence." If it's indeed 6.0, a floating-point number, then the error is understandable -- it's a number, not a sequence. You can make it into a string in various ways, but in general you will also need to ensure it's formatted correctly for your purposes, e.g.: change the second of the following lines to: rotation = '%3.1f' % object1.LocZ > object1= Blender.Object.Get("locater") > rotation = object1.LocZ > > a,c,b = rotation > firstnumber = a > secondnumber = b Alex From Bill.Scherer at VerizonWireless.com Thu Oct 19 15:10:17 2000 From: Bill.Scherer at VerizonWireless.com (Bill Scherer) Date: Thu, 19 Oct 2000 15:10:17 -0400 Subject: jpython and DCOracle ? References: <8snfr7$8uo@slip.net> Message-ID: <39EF4719.B02F0AF4@VerizonWireless.com> Emmett McLean wrote: > > Hi, > > Is DCOracle available for jpython ? Nope. DCOracle is C extension to Python, which means it works only with CPython. To access Oracle from JPython, you'll probably have to use JDBC. -Bill From sdm7g at virginia.edu Tue Oct 24 15:56:18 2000 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Tue, 24 Oct 2000 15:56:18 -0400 (EDT) Subject: Importing a module with dashes. In-Reply-To: Message-ID: On 24 Oct 2000, Igor V. Rafienko wrote: > > I have a module that contains a dash in its name. import severely > dislikes it, and although I can try something like: > > __import__( "my-module" ) > > it looks like a wrong thing to do. Any clues as to what is the proper > way of dealing with this? > Yes: rename the module to "my_module" or "MyModule" . The string "my-module" has a different meaning to python: >>> my = 1 >>> module = 2 >>> my-module -1 >>> According to the grammar, it's not a valid identifier. So you can't say: >>> my-module = __import__( "my-module" ) SyntaxError: can't assign to operator You will have to give it a valid name somewhere. You would have a similar problem with the following: >>> import new >>> unspoken = new.module( '|#%@!&*!' ) >>> unspoken >>> sys.modules[unspoken.__name__] = unspoken ( Note to self: remember this for the next obfuscated python contest! ;-) ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- "All operating systems want to be unix, All programming languages want to be lisp." From kc5tja at garnet.armored.net Wed Oct 25 20:13:37 2000 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 25 Oct 2000 17:13:37 -0700 Subject: DESPERATE FOR NEWS ON STARSHIP OUTAGE References: <8t1rb9$8hn$1@nnrp1.deja.com> <4tKJ5.68526$oN2.2731135@news20.bellglobal.com> Message-ID: On Wed, 25 Oct 2000 23:58:56 GMT, Olivier Dagenais wrote: > >DON'T send money???? If you want, you can always send it to me, make it out to my name, and just pretend that you're helping out the Starship... ;) -- KC5TJA/6, DM13, QRP-L #1447 | Official Channel Saint, *Team Amiga* Samuel A. Falvo II | Oceanside, CA | From bhoel at starship.python.net Wed Oct 25 02:29:48 2000 From: bhoel at starship.python.net (Berthold Höllmann) Date: 25 Oct 2000 08:29:48 +0200 Subject: DESPERATE FOR NEWS ON STARSHIP OUTAGE References: <8t1rb9$8hn$1@nnrp1.deja.com> Message-ID: >>>>> "Berthold" == Berthold H?llmann writes: OK, if you want to answer by mail, you need another email address. so here it is: Berthold.Hoellmann at hamburg.de Thanks Berthold -- bhoel at starship.python.net / http://starship.python.net/crew/bhoel/ It is unlawful to use this email address for unsolicited ads (USC Title 47 Sec.227). I will assess a US$500 charge for reviewing and deleting each unsolicited ad. From hei at adtranzsig.de Wed Oct 25 04:39:48 2000 From: hei at adtranzsig.de (Dirk-Ulrich Heise) Date: Wed, 25 Oct 2000 10:39:48 +0200 Subject: C's syntax References: Message-ID: <8t6627$9eq$1@desig-bs01-s04.adtranzsig.de> "Delaney, Timothy" schrieb im Newsbeitrag news:mailman.972359282.20630.python-list at python.org... > You are kidding aren't you? One thing I've learned in my time is that people > don't stop making the same mistakes over and over. The difference is that > when the error occurs you are able to identify the error immediately (oh > hell ... I know what that is ... it's a typo ... I've put an assignment > instead of a comparison ...). No... In C, all weird things can happen and you *don't* know it was a typo... One of my coworkers used to make this mistake over and over again: for(i=0;i From: "Tom" | I thought I saw a post a few months ago regarding a utility that would | display the contents of a pickle file. | (I realize that a text editor fits this description, but I'm hoping for | something a bit more structured.) My xml_objectify module (check the Vaults) contains a utility function called pyobj_printer that makes a pretty representation of any Python object. There is nothing terribly special about this 20 line function, but I assume this is basically what you want to do in representing a pickle file. You'll need to unpickle before you pass to this function, of course. From MarkH at ActiveState.com Wed Oct 25 01:58:17 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 25 Oct 2000 05:58:17 GMT Subject: WIN32 questions References: Message-ID: "Drew Whitehouse" wrote in message news:wlbsw9wlsp.fsf at anu.edu.au... > Mark> A service wont really do what you want in the general case. > > I was thinking of the service more for the starting and stopping the > client programs, assuming. In a UNIX world I would have the control > system use something like remote shell. eg This would work, so long as the program (or the programs it spawns) doesn't need to interact with users. The NT/2000 concept of "desktops" may get in your way here. Everything you describe regarding watching the processes is pretty easy, but maintaing this in a UI for the user, especially with the possibility of users logging on and off, is pretty tricky. If you are happy with a "normal" program, run from the startup folder, then it should be pretty simple... Mark. From wmcclain at salamander.com Mon Oct 2 22:43:54 2000 From: wmcclain at salamander.com (Bill McClain) Date: Tue, 03 Oct 2000 02:43:54 GMT Subject: example sources in both Python and C++ References: Message-ID: > > * Template arguments cannot be local types. That means STL > > containers must use types declared at the outer scope, which > > is ugly. > Wait, what? > Explain what you mean, this is confusing. > If you mean you can only use types in the outermost, or global scope, > as template arguments, your compiler is severely broken. Try this on your compiler and tell me what happens: *********** #include class Legal { int a; }; int main() { class Illegal { int a; }; list ok; // compiles list nogood; // does not compile return 0; } // g++ // temp.cpp:13: type `main()::Illegal' composed from a local type is not a valid template-argument // VMS // %CXX-E-LOCALTYPTMPLARG, a template argument may not reference a local type // at line number 13 in file CTS_DEVELOPER:[WMCCLAIN]TEMP.CPP;1 *********** I'm too tired to turn on NT to try VC++. -Bill From barry at wooz.org Thu Oct 19 09:39:30 2000 From: barry at wooz.org (Barry A. Warsaw) Date: Thu, 19 Oct 2000 09:39:30 -0400 (EDT) Subject: Announcing Jython, the sucessor to JPython Message-ID: Hello JPython users, I'm very happy to announce the formation of the Jython project on SourceForge. Jython is the successor to JPython, the Java implementation of the Python programming language. We've created this new project in accordance with the CNRI JPython 1.1.x license, in order to ensure the continued existence and development of this important piece of Python software. The intent is to manage this project with the same open policies that are serving CPython so well. Finn Bock and I have been working on the next release, to be called Jython 2.0. Finn has integrated his JPython errata, and Python 2.0 language features such as augmented assignments, list comprehensions, and extended print have also been added. The free Apache Jakarta OROMatcher software has taken the place of the previously non-free OROMatcher code for regular expressions, so there will be no further need to dual license. Jython 2.0 will eventually be released with a license similar to CPython 2.0. I don't know when the first alpha release of Jython 2.0 will happen, but all the code is currently available in the SourceForge CVS tree. I will also be converting the old Jitterbug database to the SF bug tracker as soon as possible. I've created several mailing lists to support Jython development: jython-users at lists.sourceforge.net This list will supplant jpython-interest at python.org and should be the general discussion list for Jython users. jython-dev at lists.sourceforge.net This is an analog to python-dev at python.org, except that it will have an open subscription policy. This is the place for Jython developers to discuss and help move the Jython project further. jython-announce at lists.sourceforge.net A low-traffic, announce only list. jython-checkins at lists.sourceforge.net Similar to python-checkins at python.org, this list will receive CVS checkin and diff messages. All these mailing lists, and all current information on the Jython project is available at SourceForge, at http://sourceforge.net/projects/jython I will not be automatically subscribing any current jpython-interest members to the new lists; that's up to you. I know Finn joins me when I say that we look forward to working with you on Jython, and to your contributions in furthering this project's development. Cheers, -Barry From hinsen at cnrs-orleans.fr Thu Oct 26 05:54:18 2000 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 26 Oct 2000 11:54:18 +0200 Subject: [Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich , comparison References: <39F6639E.B74867EE@home.com> Message-ID: "Rainer Deyke" writes: > Floating points should not be part of the core language. The correct way to > implement floating points is in terms of integers, preferable within the > language (as opposed to a C extension). If you don't like floating point numbers, you are free not to use them. Many of us do need them, know how to deal with them, and need them in a usable form, i.e. with decent performance and accessible from C modules, which implies using the binary format provided by the CPU. Your proposal is completely unrealistic. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From hopper_grass at hotmail.com Wed Oct 11 08:19:01 2000 From: hopper_grass at hotmail.com (grass hopper) Date: Wed, 11 Oct 2000 12:19:01 GMT Subject: helpplease!! Message-ID: <39e45032.5929225@news.atl.bellsouth.net> I have a 500mhz amd - k-6 mb - 128mg ram runing win98 i built it my self. I have got some question's about python. this is going to sound stupid but i just don't no what it means whats this e.g. mean. Is it like ect. so-on? I have been going through the tutoral,The python manual's I want to work with images. I have put togather a simple little game with .html. it works fine.But how ever i can't even get python to open a image. do i have to call on the browser to open a image? if so how do i do this? this is a short of the game you are asked :which is the pic of a cow there are 3 pic's to pick from like 01(pig.jpg) or 02(dog.jpg) or 03(cow.jpg). I really won't to learn python but this is really getting to me. would someone show me the code to do this or point me in the right direction. I won't it to run in windows as a stand alone game I'm not asking for a handout just a hand I won't to wright the game in python . From quinn at chunder.ugcs.caltech.edu Mon Oct 30 16:05:15 2000 From: quinn at chunder.ugcs.caltech.edu (Quinn Dunkan) Date: 30 Oct 2000 21:05:15 GMT Subject: Passing tuples transparently as function parameters (like for Threads) References: Message-ID: On Mon, 30 Oct 2000 17:38:44 GMT, David Perry wrote: >Hey all! This may be an RTFM, but if it is, please point me at the right >FM. (: FM is apply.__doc__ or lib ref -> builtin functions Also there is some python 2 sugar: args = [1,2,3] kw = {'a':1, 'b':2} x = f(*args, **kw) # translates to x = apply(f, args, kw) >(Aside: if you put a function that returns a value in a thread, how can you >get the returned value?) You could stick it in a class attribute or dictionary. Don't forget to lock. From sholden at holdenweb.com Mon Oct 9 10:08:32 2000 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 09 Oct 2000 10:08:32 -0400 Subject: setting pythonpath on Windows NT References: <39DB997D.959281FD@seebelow.org> Message-ID: <39E1D160.613CF914@holdenweb.com> The "site" library module is the easiest way to modify the sys.path variable. It's imported automatically every time Python starts up. The source gives you clues as to how to use it. regards Steve Andrew Malcolmson wrote: > > There's an even easier way to do this. > > 1) Open the 'System' dialog either through the Control Panel or through the > Properties of the 'My Computer' icon on the Desktop. > 2) Display the 'Environment' tab. > 3) Click in either 'System Variables' (applied to all users) or 'User > Variables' (current user), enter 'PYTHONPATH' in the 'Variable' text box > below, and > then enter any path entries you want, separated by semicolons, in the > 'Value' box. > > You can check that this has taken effect by opening an NT command prompt > and listing the environment variables with the 'set' command. > > The PYTHONPATH you specify in 'System' will be prepended to the standard > sys.path. -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ From bob at staff.cs.usyd.edu.au Wed Oct 11 07:02:13 2000 From: bob at staff.cs.usyd.edu.au (Bob Kummerfeld) Date: 11 Oct 2000 22:02:13 +1100 Subject: Python Server Pages alternative Message-ID: <8s1hbl$j9s@staff.cs.usyd.edu.au> The "Python Server Pages" project looks interesting but if you want a simpler but still powerful package to do similar things I suggest "Poor Man's Zope" or PMZ. You can find it in the Vaults of Parnassus. Bob Kummerfeld. -- From Roberto at lupex.net Fri Oct 20 03:50:29 2000 From: Roberto at lupex.net (Roberto Lupi) Date: Fri, 20 Oct 2000 09:50:29 +0200 Subject: contained execution References: <39EE9600.227A7F52@wasabimg.com> Message-ID: In article <39EE9600.227A7F52 at wasabimg.com>, jdavis at wasabimg.com says... > program. What I am looking for is essentially a python equivelant of > "Safe.pm" (from PERL), although hopefully a little easier to use. There is a chapter in the python library manual about restricted execution. Safe's equivalent in python is the rexec module. -- Roberto Lupi http://www.lupex.net/ From DavidA at ActiveState.com Sat Oct 21 00:55:25 2000 From: DavidA at ActiveState.com (David Ascher) Date: Fri, 20 Oct 2000 21:55:25 -0700 (Pacific Daylight Time) Subject: How to determine what called __cmp__ method? In-Reply-To: Message-ID: On Fri, 20 Oct 2000, Pearu Peterson wrote: > > I have the following situation: > > >>> foo(1) < foo(2) > > where > > class foo: > def __init__(self,i): > self.i = i > def __cmp__(self,obj): > # who called me??? > return self.iobj.i) or 0 > > The question is how to determine inside __cmp__ method where it was > called? That is I want to know was it called for evaluating > either inequality '<', or '>', or '<=', or ...? I don't think there's a way. The logic is hidden in the C layer, and you don't get to see it. Now, with rich comparisons.. =) (If anyone is interested in taking on the work of creating the rich comparisons patches, pushing the PEP through, etc., get in touch with me). --david ascher From pehr at pehr.net Wed Oct 18 21:08:36 2000 From: pehr at pehr.net (pehr anderson) Date: Thu, 19 Oct 2000 01:08:36 GMT Subject: Need help on a program. References: Message-ID: <39EE4995.B0E3ADF4@pehr.net> Oh, And don't forget that you have to use "\\" to get the backslash character as python automatically interprets "\n" and other Backslash + Character sequences as escape codes. -pehr Doug Stanfield wrote: > > With this: > > > IOError: [Errno 2] No such file or directory: 'p7.dat' > > Python is telling you it can't find a file with that name. This means the > file is either not there or its looking in the wrong place. Assuming you've > put that file in the same place as your program, try to change the open > statement on line 37 to be (untested): > > infile = open(r"C:\Jim's Stuff\College Stuff\CS120\Python > Programs\p7.dat", "r") > > That (or something like it) tells Python exactly where the file is. At some > point you should start to look at what you have in your PATH environmental > variable and figure out where it thinks it should be looking. > > -Doug- > > > -----Original Message----- > > From: Captain Obvious [mailto:captainTRASHobvious at rocketTRASHmail.com] > > Sent: Wednesday, October 18, 2000 5:33 AM > > To: python-list at python.org > > Subject: Need help on a program. > > > > > > I am taking a Python class in college, and am stuck on a > > program I am writing. > > > > Here is the error I get: > > Traceback (innermost last): > > File "", line 1, in ? > > File "C:\Jim's Stuff\College Stuff\CS120\Python > > Programs\JRC_07.py", line 37, in ? > > main() > > File "C:\Jim's Stuff\College Stuff\CS120\Python > > Programs\JRC_07.py", line 17, in main > > infile = open("p7.dat", "r") > > IOError: [Errno 2] No such file or directory: 'p7.dat' > > > > Here is the program I wrote: > > > > # JRC_07.py > > # Program written by James Cory for October 18, 2000 > > # This program, using p7.dat, will keep a running total of > > heating degree days > > # and cooling degree days. One heating degree day is added > > for every degree the > > # temperature is over 80 degrees Fahrenheit, and one cooling > > degree day is added > > # for every degree the temperature is below 60 degrees Fahrenheit. > > > > def main(): > > #Greeting Section > > print "This program, using p7.dat, will keep a running > > total of heating degree days" > > print "and cooling degree days. One heating degree day > > is added for every degree the" > > print "temperature is over 80 degrees Fahrenheit, and one > > cooling degree day is added" > > print "for every degree the temperature is below 60 > > degrees Fahrenheit." > > hdd = 0 > > cdd = 0 > > day = 0 > > infile = open("p7.dat", "r") > > temp = eval(infile.readline()) > > while temp != "": > > if temp > 80: > > amount = temp-80 > > hdd=hdd+amount > > day=day+1 > > print "Day: ", day, "Cooling Degree Days: ", cdd, > > "Heating Degree Days: ", hdd > > elif temp < 60: > > amount = 60-temp > > cdd=cdd+amount > > day=day+1 > > print "Day: ", day, "Cooling Degree Days: ", cdd, > > "Heating Degree Days: ", hdd > > else: > > day=day+1 > > print "Day: ", day, "Cooling Degree Days: ", cdd, > > "Heating Degree Days: ", hdd > > infile.close > > print > > print > > "+------------------------------------------------------------ > > ---------------+" > > print "The final results are:" cdd, "Cooling Degree Days: > > ", hdd, "Heating Degree Days." > > main() > > raw_input ("Press to quit") > > > > Thanks in advance. I can't get ahold of my professor, and am > > really stuck. > > > > > > -- > > === > > > > Thanks for taking the time to read my posting. > > > > Take out the TRASH to respond via email. > > > > Any views expressed in this USENET posting and/or > > attachments are not necessarily those of > > Wartburg College. > > > > Go Knights! > > > > > > > > -- > > http://www.python.org/mailman/listinfo/python-list > > From aleaxit at yahoo.com Fri Oct 6 09:26:53 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 6 Oct 2000 15:26:53 +0200 Subject: What is Python? References: <8pqhm9$6a9$1@panix3.panix.com> <3BBC75F01B2A2291.3CC54B93C0C69DED.4E021EA85330C94C@lp.airnews.net> <8pt65c$cbs$2@newshost.accu.uu.nl> <39C29336.71ED41AC@seebelow.org> <39C3E664.BCEAF741@seebelow.org> <8q5rgv$7to$1@nnrp1.deja.com> <39C6DF06.FF7F8A74@engcorp.com> <39C70642.D6CBF93A@alcyone.com> <39C710F7.4E72D963@seebelow.org> <39C86059.2F644D70@engcorp.com> <39C867B5.DFF9FFD3@seebelow.org> <8qat1u02g2j@drn.newsguy.com> <1eha5k2.kxgxg85fmpvrN@paris11-nas8-55-47.dial.proxad.net> Message-ID: <8rkk93028po@news2.newsguy.com> "Fran?ois Granger" wrote in message news:1eha5k2.kxgxg85fmpvrN at paris11-nas8-55-47.dial.proxad.net... [snip] > Funny, these guy don't know french ;-) > > It's worse on the "consistentness" side But better in many ways thanks to many centuries' worth of effort by the Academie -- isn't the language itself spelled (cedillas apart) Francais (consistently with its pronunciation) rather than Francois (as it used to be in the 18th Century) thanks to the Academie's 1835 edition of its Dictionary, for example? Despite my rather-libertarian leanings in most fields, I can't help thinking that French has been more helped than hindered by this specific case of "dirigisme" (wrt the other tongues I know passably well, Italian, my mothertongue, and beloved-but-hopelessly-tangled English). Quite similarly, I think, Python's benevolent dictator is a big help to Python's quality as a language... Alex From jon+python-list at unequivocal.co.uk Thu Oct 26 11:49:23 2000 From: jon+python-list at unequivocal.co.uk (Jon Ribbens) Date: Thu, 26 Oct 2000 16:49:23 +0100 Subject: dynamically loaded modules (.so files) does not work under openbsd In-Reply-To: <20001026164839.C11873@snowy.squish.net>; from jon+python-list@unequivocal.co.uk on Thu, Oct 26, 2000 at 04:48:39PM +0100 References: <39f791a1.1bcb7@nancy.pacific.net.au> <39F7CB6E.7B8D1CF2@san.rr.com> <39f8228f.c8259@nancy.pacific.net.au> <20001026164839.C11873@snowy.squish.net> Message-ID: <20001026164923.D11873@snowy.squish.net> Jon Ribbens wrote: > Kiyo Kelvin Lee wrote: > > So do I. It works under linux. So I am wondering if it's a problem of > > OpenBSD. > > It is. See: > > http://sourceforge.net/bugs/?func=detailbug&bug_id=117070&group_id=5470 Bugger, wrong bug. Try: http://sourceforge.net/bugs/?func=detailbug&bug_id=117245&group_id=5470 instead. From timwkelly at my-deja.com Mon Oct 2 10:19:03 2000 From: timwkelly at my-deja.com (timwkelly at my-deja.com) Date: Mon, 02 Oct 2000 14:19:03 GMT Subject: Python on VMS References: <8qvn64$5gi$1@nnrp1.deja.com> <8i8WxEA8lS15EwwX@gol.com> <8r6qtm$96o$1@nnrp1.deja.com> <8r7ku8$pjf$1@nnrp1.deja.com> Message-ID: <8ra5gk$jqb$1@nnrp1.deja.com> In article <8r7ku8$pjf$1 at nnrp1.deja.com>, Uwe Zessin wrote: > In article <8r6qtm$96o$1 at nnrp1.deja.com>, > timwkelly at my-deja.com wrote: > > In article <8i8WxEA8lS15EwwX at gol.com>, > > Ian Parker wrote: > > > In article <8qvn64$5gi$1 at nnrp1.deja.com>, timwkelly at my-deja.com > writes > > > >Been trying to build Python on VMS. Used the > > > >Port for version 1.5.2. I keep getting access > > > >violations in PTHREAD$RTL. > [...] > > > You could download the object modules and link them to create the > > > executables: > > > http://decus.decus.de/~zessin/python/obj.html > > > > > > It worked for me > > > > > > -- > > > Ian Parker > > > Tried to use the object modules. was able to link but still got an > > access violation in ptrhead$rtl. > > There are incompatibilities between the thread implementations. > That's the reason there is now threaded + non-threaded object code for > OpenVMS VAX. > I'll build build non-threaded ones for Alpha next week and make them > available. > > -- > Uwe Zessin > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Thank You Sent via Deja.com http://www.deja.com/ Before you buy. From jam at dts.emich.edu Thu Oct 12 15:39:46 2000 From: jam at dts.emich.edu (Jeff) Date: Thu, 12 Oct 2000 15:39:46 -0400 Subject: updated hphack.py Message-ID: <20001012153946.A5833@quark.emich.edu> greetings, I wrote hphack.py based on some code I found that was posted to freshmeat.net and written in C. I wrote the python version mostly to show the differences between a C implementation of a simple socket using program and it's python equivalent-- the python code is *much* shorter and IMHO much more readable. the main change from the original python version was to make the bulk of the code into a seperate function so it can be called from other modules. another change is that it is no longer necessary to escape the text message from the shell with quotes; when running the script from a shell, all arguments to the script other than the first one are joined together and passed to the hphack function. I hope someone finds this code useful.. I've used it here at EMU to confuse people walking by the printer (i.e. "practical joke" type messages), so at the very least it's good for a laugh. ;) I'm always open to suggestions for improving the code-- post 'em if ya got 'em. regards, J -- begin hphack.py -- #!/usr/bin/env python import sys import string import getopt import socket _RCSID = "$Id: hphack.py,v 1.4 2000/10/12 19:30:21 jam Exp $" # based upon an idea and code from sili at l0ft.com, with assistance from # comp.lang.python # http://cssweb.nectech.com/printers/pclcodes/pcl5hp.htm # http://freshmeat.net/appindex/2000/06/22/961716715.html UEL = "\033%-12345X" def version(): print _RCSID def hphack(dest, message): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(dest, 9100) msg = '@PJL RDYMSG DISPLAY="%s"\n' % (message) buf = string.join( (UEL,msg,UEL),"")+"\n" s.send(buf) s.close() return 0 if __name__ == "__main__": opts, sopts = getopt.getopt(sys.argv[1:], "", [ "help", "version" ]) for n, v in opts: if n == "--help": print "usage: hphack \"\"" sys.exit(0) elif n == "--version": version() sys.exit(0) hphack(sys.argv[1], string.join(sys.argv[2:])) -- end hphack.py -- -- || resnet 2000 -- || psa member -- From chakie at infa.abo.fi Mon Oct 16 04:41:51 2000 From: chakie at infa.abo.fi (Jan Ekholm) Date: 16 Oct 2000 10:41:51 +0200 Subject: Python in WWW-development? Message-ID: <39eab13e_1@newsflash.abo.fi> Hi there! I've been using Python for a while now, and I'm quite hooked to it. I was mainly wondering wether there are any nice modules for Apache that would allow me to write code similar to PHP? I don't want to use CGI, which works fine with Python too, but I'd like to embed the code into the WWW-pages. Is this possible, and is there some module or project that does/tries to do this? Regards, Chakie -- --------------------+-------------------------------------------------------- Jan 'Chakie' Ekholm | Balrog New Media http://www.balrog.fi/ Linux Inside | I'm the blue screen of death, nobody hears your screams From jwbnews at scandaroon.com Tue Oct 3 13:27:09 2000 From: jwbnews at scandaroon.com (John W. Baxter) Date: Tue, 03 Oct 2000 10:27:09 -0700 Subject: range of mktime References: <39D923A6.8A0A74B8@uniserve.com> Message-ID: In article <39D923A6.8A0A74B8 at uniserve.com>, bob van der Poel wrote: > Using time.mktime() it appears that on my linux box the valid range is > 1902...2038. Is this platform consistent, or, if not, is there a way to > determine at runtime the valid range? Test on a Mac to be sure what happens there. The native epoch there is Jan 1, 1904. (Ignoring Mac OS X.) So time is currently negative (when viewed as signed 32 bits, and the end of time is in 2040). (The modern Mac OS (from 1990 or so onwards) supplies 64-bit signed time, same epoch, and I believe "Carbon" removes the old 32-bit time.) --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From wware at world.std.com Wed Oct 18 11:03:13 2000 From: wware at world.std.com (Will Ware) Date: Wed, 18 Oct 2000 15:03:13 GMT Subject: scanf in python...? References: Message-ID: Steve Clift (sgclift at earthlink.net) wrote: > ...the sscanf module I wrote about 5 years ago... Whenever I need to do something like sscanf(), I use eval(). Is sscanfmodule.c much faster? It looks like a very good thing: http://www.python.org/ftp/python/contrib-09-Dec-1999/Misc/sscanfmodule.c -- # - - - - - - - - - - - - - - - - - - - - - - - - # Resistance is futile. Capacitance is efficacious. # Will Ware email: wware @ world.std.com From claird at starbase.neosoft.com Fri Oct 6 07:50:28 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 6 Oct 2000 06:50:28 -0500 Subject: future of Python: Stackless, Standard -> fragmentation ? References: <8rk7e5$47u$1@oslo-nntp.eunet.no> Message-ID: In article <8rk7e5$47u$1 at oslo-nntp.eunet.no>, Thomas Weholt wrote: >Hi, > >Just wondered if somebody could clear something up for me: > >First, the development of Stackless Python: if this is a great idea, why >hasn't this been implemented in Python allready, or at least in Python 2.0? >Is this the sort of thing that Guido and his friends will consider for >Python 3k? In two weeks, O'Reilly Net will publish a follow-up to that addresses these questions. The quick answer: Guido's a careful guy, who doesn't act in (so much) haste, and, yes, Stackless is already under consideration for versions well before Python 3000. > >Secondly, could Python be fragmented in the future due to "distros" like >(ActivePython), Stackless Python and JPython so that we could have alot of >python code that needs special "distros" of Python to run? Shouldn't the >goal of Python be a platform independant core and platform specific things >kept in seperate modules? Is the difference between the different >implementations any reason for concern at all? Barely. There's more to it than this, but, no, for now rest assured that Python won't fragment in the sense you appear to fear. . . . -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From andrew_dot_henshaw_at_earthling_dot_net Thu Oct 26 22:39:51 2000 From: andrew_dot_henshaw_at_earthling_dot_net (Andrew Henshaw) Date: Thu, 26 Oct 2000 22:39:51 -0400 Subject: Occam-like multithreading and communication Message-ID: I've partially developed a module for Python that implements Occam-like multithreading (PAR) and inter-process communication (CHAN) functionality. For an article discussing why this would be useful, read "Communicating Java Threads" at http://www.rt.el.utwente.nl/javapp/cjt/CJT-paper.PDF I'm curious to see if anybody else would find my module useful. I believe that it will greatly simplify my multithreaded Python applications. I do have a question, but first I will demonstrate usage with a simple example. ####################################### from occam import PAR, CHAN # a simple function to read a value from a channel and print it def reader(c) : a = c.read() print a # a simple function to write a value to a channel def writer(c, value) : c.write(a) # create the shared channel c = CHAN() # wrap the functions in processes and run par = PAR() par.PROC(reader, c) par.PROC(writer, c, some_value) par.end() ###################################### This example creates two tasks that communicate through a shared channel, and then runs them. The par.end() basically does a process join and waits for both tasks to complete before continuing with the sequential part of the program. By the way, the UPPERCASE names are for the duplication of Occam syntax. I also have a version that would let me code the bottom part as: PAR( \ (reader, c), \ (writer, c, some_value)) while this looks more Occam-like, I can implement the replicated-PAR construct with the first, but I don't know how to do it cleanly with the latter. Now for my problem. I would like to implement the capability to easily create parallel communications that would look like this in Occam: PAR in_chan ? a -- read from in_chan out_chan ! b -- write to out_chan So, I'm thinking: par = PAR() a = in_chan.read(par) out_chan.write(b, par) par.end() I've written this for the channel write, but for the channel read, I've had to resort to a kludge. The problem is that in the statement a = in_chan.read(par) I have to perform the assignment to 'a' before the read operation is truly performed. In other languages, a package that tries to provide this type of functionality would handle it like this: in_chan.read(&a, par) passing the address of a so that the function could assign the value when it is ready. Because of Python's "interesting" assignment methodology, I don't believe that this is straightforwardly feasible. My kludge works by: - returning a list [None] to a. - When the read is actually performed, place the result into the 0th element of that list. Then, a[0] will contain the desired result. Any better suggestions?? I'd appreciate any feedback. Thanks, Andy Henshaw From jschmitt at vmlabs.com Tue Oct 10 21:48:45 2000 From: jschmitt at vmlabs.com (jschmitt at vmlabs.com) Date: Wed, 11 Oct 2000 01:48:45 GMT Subject: how do I know when popen() finishes? Message-ID: <8s0gts$767$1@nnrp1.deja.com> I'm using Python 2.0b2 on Wind2000. If I do something like import os f = os.popen( 'busyprogram' ) how do I retrieve all the output that busyprogram produces when busyprogram finishes? Do I busy wait on f.read(), ie, wait for end of file? Does f.close() do the same thing as pclose(f)? Thanks. John Sent via Deja.com http://www.deja.com/ Before you buy. From aleaxit at yahoo.com Tue Oct 31 06:53:29 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 31 Oct 2000 12:53:29 +0100 Subject: Python processing of an input byte stream References: <8tkoso$84l$1@nnrp1.deja.com> Message-ID: <8tmc5h01po0@news1.newsguy.com> "Erno Kuusela" wrote in message news:ku66m9gaey.fsf at lasipalatsi.fi... [snip] > | while 1: > | c = sys.stdin.read(1) > | if not c: > > probably works better if you replace the below 2 lines... > > | time.sleep(1) > | continue > > ... with > break > > :) No! Remember the original specs: >codes for C. The input byte stream would be >continuous, so the Python module should expect an >EOF, similar to running 'tail -f'. This may not be entirely clear, and perhaps it's system-dependent, but to me it reads that the input stream is never-ending, and apparent end-of-files on it must NOT terminate processing. "tail -f" has basically (the C equivalent of) Quinn's code which you suggest replacing: on an apparent end-of-file, wait a while then try again. At least on Unix systems, this works well when the input-file is a "never-ending stream" being produced by another process (some _other_ way, if needed, will have to be designed to terminate the filter -- asynchronous signals are the popular approach on Unix). Alex From gward at altavista.net Sat Oct 14 17:59:07 2000 From: gward at altavista.net (Greg Ward spamdrop - see sig for preferred) Date: 14 Oct 2000 21:59:07 GMT Subject: Writing to file References: <39E71DEB.D543820A@hotmail.com> Message-ID: On Fri, 13 Oct 2000 17:36:27 +0300, j wrote: > How can i write string "test string" into file "test.txt". > > How can i print > i am a "monkey" Proceed to the nearest well-stocked bookstore. Get yourself a copy of *Learning Python*. Read it. *Then* ask questions about stuff you didn't understand or was left out of the book. Greg -- Greg Ward gward at python.net http://starship.python.net/~gward/ From cjensen at bioeng.ucsd.edu Fri Oct 13 12:43:47 2000 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Fri, 13 Oct 2000 09:43:47 -0700 Subject: Message-ID: <39E73BC3.340D5F62@bioeng.ucsd.edu> When we run python, we get this error before it starts. What does this mean? Thanks > python Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] Python 1.5.2 (#1, Aug 26 1999, 00:12:37) [C] on irix6-n32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From entropiamax at jazzfree.com Mon Oct 30 04:36:02 2000 From: entropiamax at jazzfree.com (entropia) Date: Mon, 30 Oct 2000 10:36:02 +0100 Subject: CPython vs. Jython/JPython References: <20001029232748.A3910@dman.rh.rit.edu> Message-ID: <39FD4102.AA8FDEB1@jazzfree.com> Jython exists only as a RAD for Java. CPython is a RAD (and more) for C a C++. Jython is slower than CPython and not more portable. The only adventatge of Jython is that you can do fast prototipe of Java applications. When the work is done you can compile the python source to java bytecode. Stackless is a great idea but it's incompatible with Jython. Java is more known than Python. If people work with Java then they can be interested in Jython, and then they can known something about Python. D-Man escribi?: > Hi. > > This isn't to start a flame war, but to clarify some confusion I have. > > I am wondering why there are two separate python interpreters being developed (the one in C, the other in Java). Wouldn't it be more productive if both teams worked together on one interpreter? Another thought I had was that it would be easier to make python cross-platform if it was written in Java and let the Java developers worry about the C-level platform dependencies. Isn't it also possible to write Java extensions in C? (read: ... python extensions in C (using the Java interpreter)) > > I thank all in advance for your insight into this matter. > > -D > > -- > http://www.python.org/mailman/listinfo/python-list From jasonic at nomadicsltd.com Wed Oct 4 19:25:07 2000 From: jasonic at nomadicsltd.com (Jason Cunliffe) Date: Wed, 4 Oct 2000 19:25:07 -0400 Subject: Options for use of Python in dynamic web-pages? References: <8rf0u1$rlf$1@news1.xs4all.nl> Message-ID: Take look at Zope www.zope.org Many great features including ZODB adn acquisitoin. Zope has an difficult learning curve for some, which will be greatly improved by new documentation and O'Reilly book due out soon. ymmv Veryactive community with their heads in the code. Zope has server-side DTML tag markup which is vey powerful and uses some pythonic syntax. A good use of pure python is Zope External Methods. These are Python scripts linked as Zope object and thus callable through the web by a url. Zope is written in Python. A fascinating and powerful framework, but you may opt to go for simple direct cgi now and work up to Zope. - Jason ________________________________________________________________ Jason CUNLIFFE = NOMADICS.(Interactive Art and Technology).Design Director Iwan van der Kleyn wrote in message news:8rf0u1$rlf$1 at news1.xs4all.nl... > Hi there, > > I have to implement a website with quite a lot of dynamic web-pages for a > non-profit organisation. Because of this the target-platforms are Linux, > Apache and Python (budgetary reasons; Python has been selected for its ease > of use though) . However, the present (static) site already generates quite > a lot of traffic so, guessing from all the negative commentary considering > the performance of Python with "plain" CGI I've found on the Web, I'll need > a special module wich integrates the Python interpreter into Apache. (Zope > is no option BTW, too complex for the moment :-) > > My question is: which one? I've found several modules wich promises fast use > of Python: pyApache, the "Python FastCGI Wrapper", > mod_Python and "Webware for Python". Could anyone give advice about which > product to use? Are they stable, any disadvantages? > > Thanks & Regards, > > Iwan > > From kogorman at pacbell.net Mon Oct 9 15:49:55 2000 From: kogorman at pacbell.net (Kevin O'Gorman) Date: Mon, 09 Oct 2000 12:49:55 -0700 Subject: Newbie question re processes Message-ID: <39E22163.B621B032@pacbell.net> I've just started migrating to Python from Perl, so I'm not too familiar with the idioms of Python. I could use some help, or a pointer to a cookbook. I've got a pretty basic book, and online docs, and I've done my best to RTFM, but I'm now at my frustration point. I can use os.fork() to create a child process, but I cannot get messages from the child to the parent through the pipe I've created. If anyone's got a little sample program that shows how this is done, I'd sure appreciate it. At the moment, my (non-working) version complains that the parent's attemts to read the pipe are failing. It looks like this: #! /usr/bin/python # $Id: fork.py,v 1.2 2000/10/06 04:17:32 kevin Exp kevin $ import string import sys import re import os print "Running $Id: fork.py,v 1.2 2000/10/06 04:17:32 kevin Exp kevin $" osi=sys.stdin oso=sys.stdout ose=sys.stderr rw=os.pipe() r=rw[0] w=rw[1] print "Reading on",r,", and writing on",w child=os.fork() if child==0: sys.stderr.write("In child\n") os.close(1) os.dup(w) sys.stdout=os.fdopen(1,"w") os.close(r) os.close(w) sys.stderr.write("Writing\n") print "foo" print "bar" print "foobuar" sys.stdout.close() sys.exit(0) os.close(0) os.dup(r) sys.stdin=os.fdopen(r) os.close(r) os.close(w) print "Stdin is ",sys.stdin print "about to read" lin=sys.stdin.readline() if not lin: print "Read failed",lin sys.exit(1) while lin: print lin lin=sys.stdin.readline() -- Kevin O'Gorman (805) 650-6274 mailto:kogorman at pacbell.net Permanent e-mail forwarder: mailto:Kevin.O'Gorman.64 at Alum.Dartmouth.org At school: mailto:kogorman at cs.ucsb.edu Web: http://www.cs.ucsb.edu/~kogorman/index.html Web: http://trixie.kosman.via.ayuda.com/~kevin/index.html From jtm63 at shell-1.enteract.com Fri Oct 6 13:45:30 2000 From: jtm63 at shell-1.enteract.com (James_McNaughton) Date: 06 Oct 2000 12:45:30 -0500 Subject: win32net without NetAddUse method References: <1ANC5.5044$Uc.516357@juliett.dax.net> Message-ID: "Dag Sunde" writes: > There is a WNetAddConnection2()... > could that be of any help? > > See: X:\Python\win32\demos\win32wnet\netresource.htm > of your installation... > > Dag. > I tried that too without much success. I modified the example "testwnet.py" so it would work on my machine and now it doesn't raise an exception but the win32wnet.WNetEnumResource() calls return empty lists. It was mentioned elsewhere that win32wnet was intended for Win95/98. Maybe that's the reason. Anyone know for sure? Anyhow, I neeed to have a list of the currently attached network drives for the WNetCancelConnection2() function and if I can't enumerate the current connections I can't break them (at least that appears to be the case). Anyhow, I'm still curious about the reference to win32net.NetAddUse(). Does this show up in 1.6 or 2.0 and not in 1.5.2? Is there an updated dll which I should have? Were these people high? Jim From emile at fenx.com Sat Oct 7 12:18:30 2000 From: emile at fenx.com (Emile van Sebille) Date: Sat, 7 Oct 2000 09:18:30 -0700 Subject: Xmodem module References: Message-ID: <8rnj00$i0p7n$1@ID-11957.news.cis.dfn.de> Thanks, Michal. The customer's a windows/novell shop, and though I can get python in the door, I won't get *nix in. I think I'll go look for a command line based scriptable windows thing. A quick search shows Hyperterm has xmodem, but I can't find COM info (yet/ever?), and I see some windows based C-source code, so maybe I'll give it a quick shot. Then again, maybe the bank will let me FTP it to them... See you, -- Emile van Sebille emile at fenx.com ------------------- "Michal Wallace" wrote in message news:mailman.970932554.2929.python-list at python.org... > On Sat, 7 Oct 2000, Emile van Sebille wrote: > > > Has anyone got anything resembling xmodem? I have a > > customer that's been using a procomm script to communicate > > through to their bank, and they've lost the source. They're > > now switching back-end systems, and the function needs to be > > ported. If there's a good starting point, I'd just as soon > > use python, but if not, I'll recreate the script. > > dunno about a python module, but linux/freebsd/unix/whatever usually > has "sz" and "rz" commands... they support X, Y, and Z modem > protocols over stdin, and probably over a pipe... > > Cheers, > > - Michal > ---------------------------------------------------------- -------------- > www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net > ---------------------------------------------------------- -------------- > > From effbot at telia.com Mon Oct 23 11:14:59 2000 From: effbot at telia.com (Fredrik Lundh) Date: Mon, 23 Oct 2000 15:14:59 GMT Subject: C's syntax (was Re: Python Formatted C Converter (PfCC)) References: Message-ID: Mikael Olofsson wrote: > Being a Swede, I sure would like to know what the Stockholm > Syndrome is. it's in the faq: http://www.police.se/gemensam/faq/historia.htm "Fr?ga: Vad inneb?r stockholmssyndromet ? "Svar: Uttrycket myntades efter det fem dygn l?nga gisslandramat i Sveriges Kreditbank vid Norrmalmstorg 1973. Gisslandramat ?r mera k?nt som Norrmalmstorgs- dramat. Polisen pr?vade olika metoder att frita gisslan utan risk. Efterhand uppstod en relation mellan r?nare och gisslan d?r b?da parter upplevde polisen som det st?rsta hotet. Detta psykologiska fenomen kom att kallas Stockholmssyndromet." From sabren at manifestation.com Tue Oct 10 12:14:00 2000 From: sabren at manifestation.com (Michal Wallace) Date: Tue, 10 Oct 2000 12:14:00 -0400 (EDT) Subject: Overwriting 'self' in constructor? In-Reply-To: <971191786.371306@irys.nyx.net> Message-ID: On Tue, 10 Oct 2000, Costas Malamas wrote: > I am trying to extend a class that produces an object in two steps: the > constructor produces a factory object and then there is a method that > returns the object I really want, i.e.: A.make(). Now, I want to extend > A, but I'd like to get the second type of object from the constructor. > Python (1.52, 1.6, Win32) won't let me do this: > > class B(A): > def __init__(self): > A.__init__(self) > self = A.make(self) i think python will let you do that, it just just doesn't do what you want it to. :) > The product of this is _always_ 'self' as defined by A.__init__() Why? > Can I/Should I work around it? Why it happens: Because even though self starts out as a reference to the object you're working with, when you say self=ANYTHING it stops referencing the first object and starts referencing something else. Python doesn't look inside your method for anything that happens to be named "self", it just looks at the original object. You can do anything you want TO the object, but you can't replace it with another object altogether. How to deal with it: Usually, when talking about a factory you should have at least 3 classes... "A", "B", and "Factory"... Factory returns one or the other.. Perhaps something like this: class Factory: defaultClass = A def make(someClass=None): what = someClass or defaultClass return what() >>> f = Factory() >>> f.make(A) Is that what you want? Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From rjroy at takingcontrol.com Thu Oct 5 15:07:28 2000 From: rjroy at takingcontrol.com (Robert Roy) Date: Thu, 05 Oct 2000 19:07:28 GMT Subject: Possible bug in sgmllib? References: <8rhqds$90b$1@newstoo.ericsson.se> Message-ID: <39dccf10.71530062@news1.on.sympatico.ca> On Thu, 5 Oct 2000 14:07:15 +0200, "Fredrik Nehr" wrote: >The start_ and do_ methods does't get called with the correct name >when tag contains a underscore, however the end_ method works as >expected. > >This interactive session shows the possible problem: > >ActivePython 1.6, build 100 (ActiveState Tool Corp.) >based on Python 1.6b1 (#0, Aug 23 2000, 13:42:10) [MSC 32 bit (Intel)] on >win32 >Copyright (c) Corporation for National Research Initiatives. >Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam. >>>> import sgmllib >>>> class Parser(sgmllib.SGMLParser): >... def __getattr__(self, name): >... print name >... raise AttributeError >... >>>> Parser().feed("data") >start_foo >do_foo >end_foo >>>> Parser().feed("data") >start_foo >do_foo >end_foo_bar >>>> > > > >Regards, > >Fredrik Nehr > > > Generally, underscores are not legal characters in element names. Note also that the scope of sgmllib is sgml as used in html and therefore there are not a lot of modifications done to the reference syntax. I quote from http://www.groveware.com/~lee/papers/sgml97b6p/ "It is worth commenting on three aspects of the above system. First, many programmers prefer using an underscore to mixed case; this works moderately well in a fixed width typeface, but looks unbearable in anything else, as the underscore is generally a full em wide. At any rate, the underscore is not available as an SGML name character in the reference concrete syntax. Only the dot and the hyphen, together with ASCII letters and digits, may be used. If you can change the syntax to allow the underscore, you can also change it to allow mixed case. " Bob From MarkH at ActiveState.com Wed Oct 4 09:07:34 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 5 Oct 2000 00:07:34 +1100 Subject: Win32: ByRef equivalent in pythoncom for function callbacks? In-Reply-To: Message-ID: > What I did was strip the particular event handler class out of the mshtml > Makepy interface file (which will not import, likely because > it's 1.9 MB), Note there is a new "for demand" option that will create a package, and only generate the specific interfaces when actually needed - for exactly this reason! Most of the gencache functions have a bForDemand param... Python talking to a DOM - that seems to be happening a bit, recently ;-) Mark. From sholden at holdenweb.com Mon Oct 16 18:58:19 2000 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 16 Oct 2000 18:58:19 -0400 Subject: Cross-referencing Python? Indexing program attached Message-ID: <39EB880A.172D0B4D@holdenweb.com> Does anyone know of a godd cross-referencing program for Python? A quick search on the web revealed little of relevance. To help me in getting to know some substantial chunks of code I have hacked together (and it *is* a hack) a program which will provide at least a listing of class, method and function definitions in many cases. I attach it to see if others might find it useful. regards Steve -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ -------------- next part -------------- # # Index python module files' function and class definitions. # import sys, string, re, glob, os.path p = re.compile(r"([\t ]*)(def|class)\s*(\w+)\s*(.*):$") def slen(s, tlen=8): """Returns effective length of string, allowing for tabs of given length.""" r = 0 for c in s: if c == " ": r = r+1 elif c == "\t": r = ((r+tlen)/tlen)*tlen return r def process(filename): """Extract class, function and method definitions from a file. Returns a sortable list of references, each created by setof().""" lengths = [0] names = ["__main__"] types = ["builtin"] clen = 0 ll = open(filename).readlines() bname = os.path.basename(filename) r = [] for i in range(len(ll)): m = p.match(ll[i]) if m: s = slen(m.group(1)) if s > clen: clen = s types.append(None) names.append(None) elif s < clen: clen = s del types[-1] del names[-1] try: types[-1] = m.group(2) names[-1] = m.group(3) except KeyError: print "Impossible keyword:", m.group(2) r.append(setof(types, names, bname, i+1)) return r def setof(types, names, fn, i): """Produce a quintuple for a class/method/function reference. Value returned is (sort_name, name, type, line_number, filename).""" # print "###", types, types[-2:] if types[-2:] == ['class','def']: type = 'Method' name = '%s [%s]' % (names[-1], names[-2]) elif types[-1] == 'class': type = 'Class' name = names[-1] elif types[-1] == 'def': type = 'Function' name = names[-1] else: type = ' ???' name = names[-1] return (string.lower(name), name, type, i, fn) r = [] for pat in sys.argv[1:]: fn = glob.glob(pat) for f in fn: r = r + process(f) r.sort() for rr in r: print "%-8s %-40s %5d: %s" % (rr[2], rr[1], rr[3], rr[4]) From ack at simplyweb.net Fri Oct 20 15:23:18 2000 From: ack at simplyweb.net (Michael Ackerman) Date: Fri, 20 Oct 2000 12:23:18 -0700 Subject: Announcing Jython, the sucessor to JPython References: Message-ID: <39F09BA5.14A16864@simplyweb.net> How about `PyJama'? Oleg Broytmann wrote: > > On Fri, 20 Oct 2000, Daniel Dittmar wrote: > > > "Jython" kinda sticks in my larynx. How about "Javathon", or "Pythonava? > > How about "Jivethon"? > > PyJava? > > Oleg. (All opinions are mine and not of my employer) > ---- > Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru > Programmers don't die, they just GOSUB without RETURN. > > -- > http://www.python.org/mailman/listinfo/python-list From jkraska1 at san.rr.com Mon Oct 30 22:54:58 2000 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 31 Oct 2000 03:54:58 GMT Subject: A Suggestion (please read and respond) References: <39FDAE7D.2259B2EC@san.rr.com> Message-ID: <39FE438C.B6B3FAD9@san.rr.com> > !Scripting languages don't require that someone declare a variable. > > Perl doesn't require a declaration, but does offer the option with > 'use strict;'. Then, for instance, a variable must be introduced with > 'my' or an error will be flagged. Yes, and I quite like that notation. Hence the use of the "strict" keyword in the rest of my message that you snipped. C// From jeffm52 at rivernet.com.au Sun Oct 22 21:04:52 2000 From: jeffm52 at rivernet.com.au (Jeff Melvaine) Date: Mon, 23 Oct 2000 11:04:52 +1000 Subject: Pmw: please help with Windows 98 install Message-ID: <39f385ac@news.rivernet.com.au> I have downloaded Python 1.5.2 to my Dell laptop under Windows 98, and the installation works; a simple hello world Tkinter application (copied from Grayson's book) executes as expected, simply by double clicking its icon in the browser. I also downloaded Pmw, but when I try to run a simple Pmw application (any of the demos, for example) the same way, the MS-DOS console window stays up for all of half a second and dies without logging a message. The documentation for Pmw says that the lib directory should be included in the sys.path variable. This suggests to me that the import for Pmw is failing when the console drops out. When I run a MS-DOS prompt window and type 'set', I don't see a sys.path variable. Is this is Unix advice, like much in the Pmw documentation? My background: I have considerable experience writing shell and perl scripts on Unix but I am not a professional Unix systems administrator. I am at beginner level with MS-DOS and its relationship to Windows. I could probably do the installation of Pmw to Linux more easily, but I have particular reasons to want to use Python windowing applications in a Windows environment, including Windows NT on my desktop. Any help with this problem (including pointers to textbook or internet resources to help me understand the issues) would be appreciated. From nospam at nospam.com Mon Oct 23 10:40:42 2000 From: nospam at nospam.com (Tom) Date: Mon, 23 Oct 2000 14:40:42 GMT Subject: Compiling kjBuckets for Win32 & Python20 Message-ID: Some Linux users asked me to compile kjBuckets for them on Win32. I've run into the following problems. Any help is appreciated. I got version 2.2 of kjBuckets. It includes a header 'rename2.h' which I found in the Python 152 source, but not in Python 2.0 - so I just used the old one. I'm getting lots of errors and warnings, let me start by commenting on these 2: For the following line (#160): enum GState { UNKNOWN, FREE, ROOT, OVERFLOW }; What are these constants? Only OVERFLOW is defined on my system. The compiler reports: "syntax error : 'constant'". And the line: (#3295): OB_HEAD_INIT(&Typetype) Causes the compiler to report: "initializer is not a constant". 'TypeType' is defined in that rename2.h header file (above) as PyType_Type which is imported from the Python DLL, so it can't be treated as a constant. I believe I've seen this before - the value will need to be set during module initialization. But before I get into that I wanted to ask 'is this legal in GCC?' Is this legal in ANSI-C? Or does this relate to the differences between Linux's .so files and windows' DLL's? Tom. From dfan at harmonixmusic.com Sat Oct 21 08:57:27 2000 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 21 Oct 2000 08:57:27 -0400 Subject: Resuming a file download with python References: <8srp7c$ak$07$1@news.t-online.com> Message-ID: "Robert Harris" writes: | I want to resume a file download with python. It would be | either the http or ftp protocol used. How could I do it or isn't | it possible ? I browsed through the docs of the http and ftp objects | but didn't find anything. ftplib started supporting this in 2.0 (two days after I hacked it into my own copy of the library :). retrbinary() now takes an optional 'rest' parameter to tell it how many bytes into the file to seek before starting to download. -- Dan Schmidt | http://www.dfan.org Honest Bob CD now available! | http://www.dfan.org/honestbob/cd.html From gerrit at NOSPAM.nl.linux.org Sun Oct 22 16:01:43 2000 From: gerrit at NOSPAM.nl.linux.org (Gerrit Holl) Date: 22 Oct 2000 20:01:43 GMT Subject: Web client References: Message-ID: On Wed, 4 Oct 2000 15:22:09 +0200, Fredrik Eriksson wrote: > > I want to build a simple web client that logs in to a free web service to > send a sms. What it need to do is get the first web page, fill in the form > and send the information, get the next web page and do the same thing and > then disconnect. > But this requires a handling of cookies and I can't find anything for that > in Python? I believe there _is_ a Cookie module, findable through the Vaults of Parsannus (http://www.vex.net/~x/parnassus): http://www.timo-tasi.org/python/Cookie.py regards, Gerrit. -- **************************************************************************** * Save Mother Earth! -- Earth First! -- visit http://www.earthfirst.org/! **************************************************************************** From tim_one at email.msn.com Mon Oct 9 22:25:59 2000 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 9 Oct 2000 22:25:59 -0400 Subject: numpy, overflow, inf, ieee, and rich comparison In-Reply-To: Message-ID: [Huaiyu Zhu] > I'm stumbling over a seemingly trivial problem. Sorry, but nothing about x-platform floating-point is trivial. Although, ya, it *should* be. > ... > We know that exp(-1000) is approximately zero to machine precision. That depends on your hardware. > However, on my machine > > >>> from math import * > >>> exp(-745) > 4.9406564584124654e-324 > >>> exp(-746) > Traceback (most recent call last): > File "", line 1, in ? > OverflowError: math range error While that's inherited from your libc. On Windows, with MS's libraries: >>> import math >>> math.exp(-746) 0.0 >>> math.exp(-1000) 0.0 >>> math.exp(-1e300) 0.0 >>> > Now, for this simple example, it is easy to add an if statement. > But for a Numeric.array, which has the same problem, an if statement > obviously does not work, in the sense that it defeats all the speed > gains. I haven't used Numeric, but I do guess you're simply hosed without resorting to C. > So the first question is: Can this be avoided? My understanding is that > this is the issue of the underlying C library and cannot be avoided unless > we are willing to rewrite it. C89 was fatally fuzzy about almost all floating-point issues, so there's unfortunately little that Python does for you beyond passing on your libc's particular delusions. From the above, it appears that an underflowing exp on your platform sets errno to ERANGE, while it does not under Windows. Python explicitly sets errno to 0 before calling libc/libm math functions, and checks errno (among other things) when the platform functions return. So in this particular case, you could use a variant of mathmodule.c where math_1 and math_2 (generic drivers) are changed simply to stop checking errno! That is, change the few blocks that look like if (errno != 0) return math_error(); else return PyFloat_FromDouble(x); to return PyFloat_FromDouble(x); There are other layers of checking, though, that may still get in your way. There's more than a bit of irony here: 754 arithmetic was designed from the ground up to make writing robust numeric algorithms much easier than they had been before. But Python's multiple layers of "catch and complain" about every little numeric endcase fight the 754 view to the death. The irony is that the "catch and complain" code was mostly contributed by number-crunchers. So, by the time you guys stop stabbing each other in the back <0.9 wink>, perhaps C99 will be widely implemented enough that Python can actually do something useful for you here. > ... no-answers-ly y'rs - tim From dts42 at my-deja.com Fri Oct 20 09:09:14 2000 From: dts42 at my-deja.com (dts42 at my-deja.com) Date: Fri, 20 Oct 2000 13:09:14 GMT Subject: Problem building Python 1.6 on NT... Message-ID: <8spg5m$1b7$1@nnrp1.deja.com> I am having a problem building a good python 1.6 on NT. Installing the binary distribution of Python 1.6 for NT does not expose all of the functions that are documented as available for NT. Specifically I want to use the os.tmpnam and os.tempname functions documented in "os - 6.1.4 Files and Directories". To get these I downloaded the source distrib and loaded up the workspace in dev studio 6.0, edited the posixmodule.c file in the python16 files project to add the necessary #defines and compiled it (along with tcl/tk) and installed the binaries/dll/support files out in D:\some\install\dir (the bin dir under that is in my NT PATH). Now the os.tmpnam and os.tempnam functions are exposed and work, BUT... If I try to import the 'fnmatch' module I get the traceback: >>> import fnmatch Traceback (most recent call last): File "", line 1, in ? File "D:\some\install\dir\lib\Python-1.6\lib\fnmatch.py", line 13, in ? import re File "D:\some\install\dir\lib\Python-1.6\lib\re.py", line 28, in ? from sre import * File "D:\some\install\dir\lib\Python-1.6\lib\sre.py", line 19, in ? import sre_compile File "D:\some\install\dir\lib\Python-1.6\lib\sre_compile.py", line 11, in ? import _sre ImportError: No module named _sre >>> I DO NOT get the traceback if I try this with the binary distrib I had installed in C:\Program Files\Python. Even stranger (to me anyway) is that everything seems to work if I run the python executable that I compiled BUT set PYTHONHOME to C:\Program Files\Python (the binary distribs support files)... What is going on here? Any ideas how I can build and configure python to run correctly? I need to remove my current dependency on the installed binary distribution so that I can remove it. Thanks in advance for any help! Dave Sent via Deja.com http://www.deja.com/ Before you buy. From skoer at adams.com Tue Oct 17 07:42:45 2000 From: skoer at adams.com (Stephan Koerner) Date: Tue, 17 Oct 2000 07:42:45 -0400 Subject: unsubscribe skoer@adams.com Message-ID: <39EC3B35.1D2F7A2C@adams.com> unsubscribe skoer at adams.com (thank you) -- From glandrum at my-deja.com Thu Oct 12 18:20:21 2000 From: glandrum at my-deja.com (Greg Landrum) Date: Thu, 12 Oct 2000 22:20:21 GMT Subject: Quickest way to build a long string? References: <8s4ica$fsm$1@nnrp1.deja.com> Message-ID: <8s5deu$968$1@nnrp1.deja.com> In article , dale at out-think.NOSPAM.co.uk wrote: > That's excellent. Thanks very much. :^) You're welcome. > > You wouldn't like to post your code would you? I'm curious to know how > closely your approach is likely to match my own. Sure, look below. > Also - what method did you use to profile? I used the python profiler. Check the bottom of the code. -greg #-------------- import string block = 'a'*100 def AddBuild(nToAdd): res = '' for i in xrange(nToAdd): res = res + block def JoinBuild(nToAdd): res = [] for i in xrange(nToAdd): res.append(block) string.join(res,'') def JoinBuild2(nToAdd): res = ['']*nToAdd for i in xrange(nToAdd): res[i] = block string.join(res,'') import profile import pstats nToDo = 5000 print 'running add' profile.run('AddBuild(nToDo)','add.dat') print 'running join' profile.run('JoinBuild(nToDo)','join.dat') print 'running join2' profile.run('JoinBuild2(nToDo)','join2.dat') for fName in ['add.dat','join.dat','join2.dat']: print 'data from: %s'%fName stats = pstats.Stats(fName) stats.sort_stats('time').print_stats(5) Sent via Deja.com http://www.deja.com/ Before you buy. From erik at pacific-shores.com Wed Oct 25 02:21:33 2000 From: erik at pacific-shores.com (Erik Myllymaki) Date: Wed, 25 Oct 2000 06:21:33 GMT Subject: Scripting SSH with Python References: Message-ID: in article qnklmvd6hr8.fsf at arbutus.physics.mcmaster.ca, David M. Cooke at cookedm at physics.mcmaster.ca wrote on 10/24/2000 2:39 PM: > At some point, "Lenny Self" wrote: > >> Hello, all. >> >> I am scripting SSH or actually rsync using ssh and I am in need of a bit of >> help. When I make the SSH connection I am prompted to enter a password... >> my problem is that I don't know how to look for this promt and have the >> script submit the password for me. Can anyone give me some help on this. >> >> I have been experimenting with os.popen and os.popen3 but I am either >> looking in the wrong spot or I am not doing it correctly. >> > > I've done this (actually for scp) and it looked like scp was looking > for a tty: if it wasn't connected to a tty, it would pop up an X > window to type the password in. To get around this I fooled it using > the pty module (which according to the documentation works only on > IRIX and Linux, but it also worked on AIX for me) to fool scp into > thinking it's talking to a tty. I had a similar question a while back and solved it with non-password authentication and some help from this page: www.freebsddiary.org/secure-file-copy.html Worked like a charm for me. Erik Myllymaki erik at pacific-shores.com From bryanbz at yahoo.com Thu Oct 12 14:11:46 2000 From: bryanbz at yahoo.com (Bryan BZ) Date: Thu, 12 Oct 2000 14:11:46 -0400 Subject: newbie question: temporarily store data Message-ID: I am looking to store data read in from a file into a cache to dump at a later time into a database. Should I use the "pickle" or "shelve" functions? If not, any suggestions? From root at rainerdeyke.com Fri Oct 27 00:59:42 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 27 Oct 2000 04:59:42 GMT Subject: [Numpy-discussion] ? References: <8t9d2m$lqo$2@news.wrc.xerox.com> <39F8DB20.C9FBE4ED@holdenweb.com> Message-ID: <2Z7K5.126092$g6.57970438@news2.rdc2.tx.home.com> "Steve Holden" wrote in message news:39F8DB20.C9FBE4ED at holdenweb.com... > I can understand and* appreciate all the arguments suggesting that > division of two integers should yield a non-integer result. Maybe > I've just been programming too long, so I have fixed ideas about > how the integers should behave in programming, which is NOT the way > they behave in mathematics. It should be noted that kids in school typically learn integer division with remainder before they learn about fractions or decimal numbers. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From aahz at panix.com Tue Oct 10 11:02:23 2000 From: aahz at panix.com (Aahz Maruch) Date: 10 Oct 2000 08:02:23 -0700 Subject: Running Python on SMP machine References: <8rsssg$lcs$1@panix3.panix.com> Message-ID: <8rvb1v$5ct$1@panix3.panix.com> In article , William Park wrote: > >My program is not particularly I/O intensive -- just slurping single >table at the beginning, and writing a smaller table at the end. But, >within my program, there are a lot of sections where calculations are >inherently independent. Eg. > c = a+b <- section 1, independent of section 2 > d = a-b <- section 2, independent of section 1 > e = c/d <- using result of the two sections. In that case, you have three options: * Write separate Python programs that communicate with each other over sockets, CORBA, or some other IPC mechanism * Use or write a Python extension and make your program threaded (NumPy may be of help if it releases the GIL) * Forget about getting a performance boost out of SMP -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 WWJCD? From aahz at panix.com Thu Oct 19 11:42:02 2000 From: aahz at panix.com (Aahz Maruch) Date: 19 Oct 2000 08:42:02 -0700 Subject: Lets Talk More Threads References: <67DH5.155361$Qx4.5103925@news1.rdc1.il.home.com> Message-ID: <8sn4oa$qe$1@panix3.panix.com> In article <67DH5.155361$Qx4.5103925 at news1.rdc1.il.home.com>, Alex McHale wrote: > >Using the Thread class, which I'm extremely happy with, I've run into >a problem. The documentation on the class suggests that you can >obj.start( ) a thread multiple times. Yet, when I do this, I get an >error to the effect of "thread already started" What I'm needing to do >is have a thread which I can resurrect over and over. If you tell me where in the docs it says this, I can either get it fixed or explain why your reading is wrong. The simplest good way to deal with this is to use a Queue object to pass work to the thread. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "real love can't be explained by simplistic platitudes." --piranha From jkraska1 at san.rr.com Tue Oct 24 23:54:41 2000 From: jkraska1 at san.rr.com (Courageous) Date: Wed, 25 Oct 2000 03:54:41 GMT Subject: Of what use is 'lambda'??? References: <39C6C4BF.430048FE@yahoo.com> <39c751ac.9682004@news.bright.net> Message-ID: <39F65A51.BA7073D4@san.rr.com> Jonadab the Unsightly One wrote: > > tdixon at linux.the-dixons.net (Tim Dixon) wrote: > > > Just a convenience: it lets you do function-like stuff without having to > > create and name a function. Lisp people (and its derivatives, from RPL to > > Logo to ....) will find it a familiar concept. > > OTOH, I seldom use lambda in elisp, either. I can only imagine that you don't make frequent use of any expression involving map? C// From oivvio at cajal.mbb.ki.se Tue Oct 17 03:57:43 2000 From: oivvio at cajal.mbb.ki.se (Oivvio Polite) Date: Tue, 17 Oct 2000 09:57:43 +0200 Subject: staus of pythondoc? Message-ID: <8sh0oq$g5n$1@news.kth.se> Hi All. What's up with pythondoc? At my place it breaks under python 2.0. It's seems kind of unmaintained. I think the current release is from 1998. Does anyone out there have a any plans for it? I could throw in a couple of hours of work if there's someone who is willing take a firm grip off the rudder of this project. Maybe the originator, Daniel Larsson? oivvio ------------------------------------- Oivvio Polite Laboratory of Molecular Neurobiology Department of Medical Biochemistry and Biophysics Berzeliusv. 3 Karolinska Institute S-171 77 Stockholm Sweden Phone: (+46) 709 304030 From olivierS.dagenaisP at canadaA.comM Mon Oct 23 16:22:23 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Mon, 23 Oct 2000 20:22:23 GMT Subject: event loop problem References: <8t21ei$e5a$1@nnrp1.deja.com> Message-ID: <361J5.369195$Gh.11216252@news20.bellglobal.com> > I am trying to write a simple Python script which which uses ADO > through Python's COM extension but never exit. For this I have writen I am sorry to report that a script or application that "never exits" is, in practice, impossible. In order to actually help you, I would recommend you *not* write a script that never exits, since I see no practical use for something like: while 1: time.sleep(0.01) ...unless you've got a timer or interrupt somewhere that will stop it. -- ---------------------------------------------------------------------- Olivier A. Dagenais - Software Architect and Developer "Someone called 'Type your name here' is impersonating me on the internet and is posting exactly the same things I am posting!" From loewis at informatik.hu-berlin.de Mon Oct 9 10:32:00 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 09 Oct 2000 16:32:00 +0200 Subject: copy_reg problem - UPDATE! PLEASE READ! References: <7ecD5.41113$g6.16721199@news2.rdc2.tx.home.com> Message-ID: "Rainer Deyke" writes: > > Can you please elaborate? What is it that you want to do, and why is > > that a good thing? > > class A: > ... > > def create_A(data): > return A(data) > > def pickle_A(a): > return create_A, (a.get_data(),) > > copy_reg.pickle(A, pickle_A, create_A) > > I can later move the implementation of A into a C extension type and still > be able to load old pickles containing A by replacing the create_A function > (which is pickled by name). This is important, because my current project > may require better performance than Python can provide. You can do that without copy_reg. If you look at the pickle code, you'll find that restoring a class does args= module= name= klass = find_class(module, name) inst = apply(klass, args) state = inst.__setstate__(state) So if you later change class A to a type, *and* you still need to be able to read old pickles, just arrange that find_class will return something meaningful, e.g. a function to create instances of your type. It is then your choice whether the type supports a __setstate__, or updating of __dict__, or item-by-item update of its state members - see the source of pickle for the exact algorithm used. > I have a variety of interconnected persistant objects which can't > all be loaded into memory at the same time. Therefore I want > pickled objects that when loaded connect to the objects that are > already in memory. I wrote a class to facilitate this (shown in > simplified form): I believe your scheme can be greatly simplified by using the persistent_id mechanism of pickle. I.e. assign functions to the persistent_id (or inst_persistent_id) attributes of your pickler object (works both for pickle and cPickle). Then use your resource names as persistent ids. Regards, Martin From fgranger at teleprosoft.com Wed Oct 11 10:41:05 2000 From: fgranger at teleprosoft.com (Fran=?ISO-8859-1?B?5w==?=ois Granger) Date: Wed, 11 Oct 2000 16:41:05 +0200 Subject: Newbie: How do I implement an 2 element integer array in Python=?ISO-8859-1?B?hQ==?=.? References: <8s1s48$89a$1@nnrp1.deja.com> Message-ID: in article 8s1s48$89a$1 at nnrp1.deja.com, jbranthoover at my-deja.com at jbranthoover at my-deja.com wrote on 11/10/00 16:06: > Hello All, > What is the syntax for creating a 2 element integer array? I > have looked at the Array Module documentation, but I am afraid that I > don?t quite understand it. In Basic I would do something like: > > Dim MyArray(100,16) > > For i = 0 to 100 > For j = 0 to 16 > MyArray( i,j ) = MyData > Next j > Next i I would say (not tested) MyArray = [] for i in range(100): MyArray.append([]) for j in range(16): MyArray[i].append([]) and then you adress it with MyArray[i][j] = 10 and MyInt = MyArray[i][j] Salutations, Francois Granger -- fgranger at teleprosoft.com - tel: +33 1 41 88 48 00 - Fax: + 33 1 41 88 04 90 From SBrunning at trisystems.co.uk Fri Oct 27 10:41:35 2000 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Fri, 27 Oct 2000 15:41:35 +0100 Subject: GUI Message-ID: <31575A892FF6D1118F5800600846864D5B1362@intrepid> > From: Hajnalka K?nt?s [SMTP:Hajnalka.Kontos at eth.ericsson.se] > Is it possible to write graphical user interfaces in python? Do I need a > spec. > library .. for that? Is there a documentation describing the graphical > functions? There are several. The 'standard' one is Tkinter, and I believe that this is the most commonly used (thought wxPython is coming up fast). If you are running Windows, you already have it, if *nix, you can download it from the same place you got Python. (Dunno about Mac). There isn't a lot of documentation with it - take a look at for better stuff. Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk Women - can't live with them... Pass the beer nuts. - Norm Peterson (Cheers) ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From robin at jessikat.fsnet.co.uk Sun Oct 1 17:55:41 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sun, 1 Oct 2000 22:55:41 +0100 Subject: ANNOUNCE: cCopy 0.1 References: Message-ID: In article , Tom writes >Robin, > >Thanks for cCopy. > >Browsing the code brings to some comments about the implementation and >documentation of cCopy and copy.py. > >Some object types are described as 'atomics', some as 'special', and the >rest aren't supported. (It appears that the atomics don't actually get >copied, but just have their reference counts increased.) > >The atomic types are: >NoneType,IntType,LongType,FloatType,StringType,CodeType,TypeType,XRangeType, >ClassType. >The special types are: ListType,TupleType,DictionaryType,InstanceType. > >My Comments: > >- XRange isn't atomic, it is a compound. I presume that the reason that it >can be copied in this manner is because it is only composed of immutables? >- Class & Code aren't atomic either. To me they appear to belong with the >other unsupported types in the un-named third category - those that don't >really have a regular value and are composed entirely of special attributes. >- Instances are not compound objects (as the other 'special' types are). I >suppose that it can be copied (unlike a similar type like a class) because >multiple identical instances are allowed? > >It doesn't seem to me that the 'atomic/compound/no-value' trichotomy (is >that a real word?) is really the issue for copying purposes, but I don't >have a better alternative. > >I realize these weren't your decisions - I am just making these comments to >see if my understanding of this module is accurate. > >Thanks, > >Tom. ... I'm afraid I'm not privy to the decision making process about the original copy module so (perhaps like you) I have only a vague understanding of the real issues involved. I guess you're right wrt xrange it's a structure type which is somehow a constant so gets copied atomically. Of course many have argued that the dichotomy of the immutables versus everthing else is a bit artificial, but I only did the extension as a speedup of the existing. It seems natural to me that 1.3 is atomic, but others would clearly demand more generality. I guess the bets that a mechanically minded moron like me can hope is that my speedup duplicates the existing python module semanticas as closely as possible. -- Robin Becker From jcea at argo.es Fri Oct 6 14:23:54 2000 From: jcea at argo.es (Jesus Cea Avion) Date: Fri, 06 Oct 2000 20:23:54 +0200 Subject: Citical bug in "Pyro 1.3" and another minor bug Message-ID: <39DE18BA.A7576D2E@argo.es> I've just downloaded, but it didn't work. After almost three hours debugging the "name server", I found the following bug. I think that it's a critical one: In "util.py", you have: >>>>> # asc2binGUID converts a string guid to a binary one (16-byte string): def asc2binGUID(guid): print "hola",guid try: return int2binstr(eval('0x'+guid[:8]+'L')) + \ int2binstr(eval('0x'+guid[9:17]+'L')) + \ int2binstr(eval('0x'+guid[18:26]+'L')) + \ int2binstr(eval('0x'+guid[27:]+'L')) except SyntaxError: raise ValueError('invalid GUID format') <<<<< BUT, the problem is: >>>>> def int2binstr(i): s='' while i>0: s=chr(i&0xFF)+s i=i>>8 return s <<<<< If i<0x01000000, that is, if i=0x00??????, the resulting string has *LESS* than four bytes. Let's see: >>> import util >>> util.int2binstr(eval('0x'+"01234567"+"L")) '\001#Eg' <- FOUR BYTES >>> util.int2binstr(eval('0x'+"00112233"+"L")) '\021"3' <- ONLY THREE BYTES So, you can have a GUID length of less than 16 bytes. Such objects can't be found using the "ns"; they are unreachable. If the "nameserver" object had this problem, all the "name service" will be unavailable (that was the problem I was seeing). The patch is fairly simple: cvs diff: Diffing . Index: util.py =================================================================== RCS file: /opt/src/cvsroot/pyro/Pyro/util.py,v retrieving revision 1.1.1.1 diff -c -r1.1.1.1 util.py *** util.py 2000/10/06 14:40:06 1.1.1.1 --- util.py 2000/10/06 18:16:00 *************** *** 119,127 **** print ! def int2binstr(i): s='' ! while i>0: s=chr(i&0xFF)+s i=i>>8 return s --- 119,127 ---- print ! def int2binstr(i,l): s='' ! for a in range(l): s=chr(i&0xFF)+s i=i>>8 return s *************** *** 166,172 **** r2=(random.randint(0,sys.maxint/2)>>4) & 0xffff r3=(random.randint(0,sys.maxint/2)>>5) & 0xff rndm = (r2<<8) | r3 ! return int2binstr(networkAddr)+int2binstr(timestamp)+int2binstr(rndm) # bin2ascGUID converts a binary guid from getBinaryGUID to a readable string: # AAAAAAAA-AAAABBBB-BBBBBBBB-BBCCCCCC --- 166,172 ---- r2=(random.randint(0,sys.maxint/2)>>4) & 0xffff r3=(random.randint(0,sys.maxint/2)>>5) & 0xff rndm = (r2<<8) | r3 ! return int2binstr(networkAddr,6)+int2binstr(timestamp,7)+int2binstr(rndm,3) # bin2ascGUID converts a binary guid from getBinaryGUID to a readable string: # AAAAAAAA-AAAABBBB-BBBBBBBB-BBCCCCCC *************** *** 180,189 **** # asc2binGUID converts a string guid to a binary one (16-byte string): def asc2binGUID(guid): try: ! return int2binstr(eval('0x'+guid[:8]+'L')) + \ ! int2binstr(eval('0x'+guid[9:17]+'L')) + \ ! int2binstr(eval('0x'+guid[18:26]+'L')) + \ ! int2binstr(eval('0x'+guid[27:]+'L')) except SyntaxError: raise ValueError('invalid GUID format') --- 180,189 ---- # asc2binGUID converts a string guid to a binary one (16-byte string): def asc2binGUID(guid): try: ! return int2binstr(eval('0x'+guid[:8]+'L'),4) + \ ! int2binstr(eval('0x'+guid[9:17]+'L'),4) + \ ! int2binstr(eval('0x'+guid[18:26]+'L'),4) + \ ! int2binstr(eval('0x'+guid[27:]+'L'),4) except SyntaxError: raise ValueError('invalid GUID format') Another aditional problem with the "ns" is that Pyro should do a "set_reuse_addr()" on the listening socket, in order to allow launching a new "ns" just after we stop it. Without "set_reuse_addr()", you must wait several minutes to launch a new "ns" if your previous one dies or it's killed. -- Jesus Cea Avion _/_/ _/_/_/ _/_/_/ jcea at argo.es http://www.argo.es/~jcea/ _/_/ _/_/ _/_/ _/_/ _/_/ _/_/ _/_/ _/_/_/_/_/ PGP Key Available at KeyServ _/_/ _/_/ _/_/ _/_/ _/_/ "Things are not so easy" _/_/ _/_/ _/_/ _/_/ _/_/ _/_/ "My name is Dump, Core Dump" _/_/_/ _/_/_/ _/_/ _/_/ "El amor es poner tu felicidad en la felicidad de otro" - Leibniz From effbot at telia.com Fri Oct 20 16:15:41 2000 From: effbot at telia.com (Fredrik Lundh) Date: Fri, 20 Oct 2000 20:15:41 GMT Subject: tk scaling in python problem, HELP! References: <8sir5h$lc9$1@nnrp1.deja.com> Message-ID: vogler at innercite.com wrote: > How do I call it within python? I tried the following command without > any success: > > self.master.tk.call( 'tk', 'scaling', '1.0' ) > > It appears that python passed it on to tcl/tk, but the scaling does not > change. I didn't get any error messages and python went on its merry > way. this works for me (using 8.2). on a 96-dpi screen, the red box comes out smaller than the blue one: from Tkinter import * root = Tk() print "original", root.tk.call("tk", "scaling") Frame(root, bg="red", width="1c", height="1c").pack() root.tk.call("tk", "scaling", "1.0") print "new", root.tk.call("tk", "scaling") Frame(root, bg="blue", width="1c", height="1c").pack() mainloop() From mikael at isy.liu.se Fri Oct 20 02:45:00 2000 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 20 Oct 2000 08:45:00 +0200 (MET DST) Subject: Undocumented regex behaviour in re module In-Reply-To: <012f01d65299$646f54a0$6401a8c0@home> Message-ID: On 05-Jul-20 Darrell Gallion wrote: > I think [...] Hmm... Darren, have you gotten hold of the time machine? I'm impressed. At least you communicate with us from 2020. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 20-Oct-00 Time: 08:41:30 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From jeffg at provenance.com.au Mon Oct 23 18:49:48 2000 From: jeffg at provenance.com.au (jeffg at provenance.com.au) Date: Mon, 23 Oct 2000 22:49:48 -0000 Subject: Do any debuggers work with Python threads? Message-ID: <8t2fac+2k37@eGroups.com> Is there any way I can use any of the Python debuggers with Python applications that are multi-threaded using the 'threading' module? I'm talking about a pure Python app at the moment. I don't need to worry about debugging external C modules. I've tried IDLE, Wing & pdb to no avail. The developers of Wing say they plan to implement it in the next major version, but that's months away. I'm mainly working under Linux, but do occasional work in Windows. Other than putting print statements everywhere, do I have any other option? From mikael at isy.liu.se Thu Oct 19 10:05:50 2000 From: mikael at isy.liu.se (Mikael Olofsson) Date: Thu, 19 Oct 2000 16:05:50 +0200 (MET DST) Subject: Reading the error stream from os.popen() In-Reply-To: <8smt02$8sb$1@kopp.stud.ntnu.no> Message-ID: On 19-Oct-00 Tov Are Jacobsen wrote: > The msgfmt command below outputs info to the stderr stream, > but the read() method retrieves data from stdin. > > s = os.popen('/usr/bin/msgfmt --statistics '+x[0]+'.po').read() > > Any ideas? (I would like to make my script to work with an > unmodified version of msgfmt) :-) You could take a look at the module popen2, and especially the functions popen2.popen2 and popen2.popen3. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 19-Oct-00 Time: 16:03:47 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From amused at webamused.com Sun Oct 29 16:12:23 2000 From: amused at webamused.com (Joshua Macy) Date: Sun, 29 Oct 2000 21:12:23 GMT Subject: PythonLabs Team Moves to Digital Creations References: <8tfa4l$3ns$1@nnrp1.deja.com> <39fcdbf9.67323218@nntp.interaccess.com> <39FC8BFE.D5E8795@webamused.com> Message-ID: <39FCBE09.E927AB4E@webamused.com> Alex wrote: > > It may depend on the complexity of what you're trying to implement, and > the number of people involved in the implementation. > > I'm sure it does, but I used to be sure that you couldn't possibly be productive without a really good debugger. Now I know that in at least some cases it's not an absolute requirement. Joshua From mikael at isy.liu.se Tue Oct 31 01:24:13 2000 From: mikael at isy.liu.se (Mikael Olofsson) Date: Tue, 31 Oct 2000 08:24:13 +0200 (MET) Subject: PythonLabs Team Moves to Digital Creations In-Reply-To: <20001030.235855.937370163.4587@locutus.noreboots.com> Message-ID: On 30-Oct-00 Bill Anderson wrote: > Yes, the PSU, which is completely different than the SPU, the Secret > Python Underground. Word has it that if they both existed, they would not > get along. Not to mention the Secret Underground of Python... /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 31-Oct-00 Time: 08:23:37 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From MarkH at ActiveState.com Sat Oct 14 10:10:11 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Sat, 14 Oct 2000 14:10:11 GMT Subject: does os.popen() search the path? References: <8s8ubv$21q$1@nnrp1.deja.com> Message-ID: <7PZF5.8592$wG1.27385@news-server.bigpond.net.au> wrote in message news:8s8ubv$21q$1 at nnrp1.deja.com... > I can get it to print the PATH environment variable and it tells me > that things like 'grep' are in my path. Yet, > > cmd = os.popen( 'grep' ) > > never launches. Never launches, or launches and quickly terminates? "grep" with no options will attempt to read from stdin, but no stdin it setup, so it will exit immediately. eg: >>> len(os.popen("grep --help").read()) 2112 > Another thing, I can also do this: > > cmd = os.popen( 'foo.cmd' ) os.popen simply uses "cmd.exe" (or whatever your COMSPEC is, etc), so whatever behaviour you are seeing is cmd.exe at work. Have you tried: cmd = os.popen( os.path.abspath('foo.cmd') ) ? Mark. From djc at object-craft.com.au Thu Oct 12 20:10:00 2000 From: djc at object-craft.com.au (Dave Cole) Date: 13 Oct 2000 11:10:00 +1100 Subject: Sybase DB-Client module searched References: <39E40B3F.A8B9A911@eed.ericsson.se> <39E46E8D.93BFC01F@ix.netcom.com> Message-ID: >>>>> "Thomas" == Thomas Gagne writes: Thomas> The Sybase module provides a Python interface to the Sybase Thomas> relational database system. The Sybase package supports almost Thomas> all of the Python Database API, version 2.0 with extensions. Thomas> The module works with Python versions 1.5.2 and later and Thomas> Sybase versions 11.0.3 and later. It is based on the Sybase Thomas> Client Library (ct_* API), and the Bulk-Library Client (blk_* Thomas> API) interfaces. Thomas> Changes: Thomas> I have made some minor changes to the module to allow it to Thomas> work with Python 1.6. Thomas> Where can you get it: Thomas> http://object-craft.com.au/projects/sybase/ We have some DNS issues at the moment (blush), so you should probably try this instead: http://www.object-craft.com.au/projects/sybase/ -- http://www.object-craft.com.au From gavrilov at iname.com Tue Oct 24 21:18:56 2000 From: gavrilov at iname.com (Alexander Gavrilov) Date: Wed, 25 Oct 2000 01:18:56 GMT Subject: python snippet request: calculate MD5 checksum on 650 MB ISO cdrom image quickly References: Message-ID: <4yqJ5.353715$i5.5498220@news1.frmt1.sfba.home.com> Ok. I played with your script a little. I discovered some drawbacks of it. First, the whole read file became garbage when you tried to warm up the cache. Second (I think) the system frees the cache when the file is closed. Therefore, I corrected the script (the new script in attachment): 1. added a new function just to read the file without calculation 2. call this function to warm up the file cache 3. play with various sizes of chunk Results are followed. The file size is 95823736 bytes. My system has 256 MB of RAM so the whole file is in the cache I presume. Indeed, CRC is a little faster then MD5, but not radically. Note also, whereas the system penalize you for a frequent reading with a small chunks, the speed of memory allocation begins to play a significant role in big chunks. Chunk size = 2**8 Time for simpleread is 6.2 Time for getcrc32 is 13.31 Time for getmd5 is 14.105 Time for getsha is 17.765 Chunk size = 2**10 Time for simpleread is 4.432 Time for getcrc32 is 9.013 Time for getmd5 is 10.809 Time for getsha is 14.124 Chunk size = 2**12 Time for simpleread is 2.369 Time for getcrc32 is 5.479 Time for getmd5 is 8.013 Time for getsha is 10.831 Chunk size = 2**16 Time for simpleread is 2.7 Time for getcrc32 is 5.487 Time for getmd5 is 8.258 Time for getsha is 10.835 Chunk size = 2**18 Time for simpleread is 2.898 Time for getcrc32 is 5.707 Time for getmd5 is 8.443 Time for getsha is 10.972 Chunk size = 2**20 Time for simpleread is 4.2 Time for getcrc32 is 7.271 Time for getmd5 is 10.049 Time for getsha is 12.678 Chunk size = 2**25 Time for simpleread is 4.7 Time for getcrc32 is 8.038 Time for getmd5 is 10.793 Time for getsha is 13.466 Chunk size = 95823737 (file size+1) Time for simpleread is 5.6 Time for getcrc32 is 8.928 Time for getmd5 is 11.694 Time for getsha is 14.371 "Tim Peters" wrote in message news:mailman.972427267.4483.python-list at python.org... > [Alexander Gavrilov] > > I run test script Tim posted and got the following results on my system: > > > > Timing C:\Program Files\Microsoft Visual > > Studio\MSDN98\98VS\1033\MSDNVS98.CHQ w/ size 95823736 > > Time for getcrc32 is 29.852 > > Time for getmd5 is 29.444 > > Time for getsha is 31.513 > > > > The system is Windows NT4 SP6, Dual Pentium II 300 Mhz > > The program as posted used a 32Mb chunk size, so your memory configuration > is more interesting than anything else. Play with this line: > > > > func(f, 2**25) > > and see how it changes. The sweet spot for you is probably substantially > lower. > > > begin 666 test.py M:6UP;W)T(&UD-2P at 8FEN87-C:6DL('-H82P@=&EM92P@;W,*"F1E9B!S:6UP M;&5R96%D*&8L($-(54Y+/3(J*C$V*3H*(" @(')E7-T96T at 9FEL92!C86-H92P@=&\@879O:60@<&5N86QI M>FEN9R!T:&4 at 9FER Message-ID: On Fri, 6 Oct 2000, Philipp von Klitzing wrote: > Hi there, > > the subject pretty much says it: I am looking for a Win32 build of > MySQLdb, preferably for Python 1.52 - is there anyone out there > that could help me with this? Unfortunately I don't have access to > a Windows C compiler. http://www.faqts.com/knowledge-base/view.phtml/aid/4188/fid/395 This is a slightly dated version, and has a small bug regarding .fetchall() with the latest mysql... It works great, given a wrapper (below).. Maybe we ought to ask Activestate to consider maintaining mysqldb with their win32 tools.. Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ """ this is a wrapper to bring mysqldb up to dbapi 2.0 compliance a better idea would be to upgrade to the 0.22 of mysqldb, but I only have 0.21 as a windows binary, and 0.22 has resisted all my attempts to compile it. (perhaps because I'm using a new version of mysql???) anyway, without further ado... """ from MySQLdb import * import MySQLdb def connect(*args, **kwargs): return Connection(apply(MySQLdb.connect, args, kwargs)) class Wrapper: def __init__(self, realDeal): self._realDeal = realDeal def __getattr__(self, attr): if attr == "_realDeal": return self.__dict__["_realDeal"] else: return getattr(self._realDeal, attr) def __setattr__(self, attr, value): if attr != "_realDeal": setattr(self._realDeal, attr) else: self.__dict__["_realDeal"] = value class Connection(Wrapper): def cursor(self): return DBAPI2Cursor( MySQLdb.Connection.cursor(self._realDeal)) class DBAPI2Cursor(Wrapper): def fetchone(self): try: return self._realDeal.fetchone() except IndexError: return None if __name__=="__main__": dbc = connect(host="jubie", user="sabren", passwd="chacha", db="zike_test") cur = dbc.cursor() cur.execute("DELETE FROM test_fish") cur.execute("SELECT * FROM test_fish") assert cur.fetchone() == None, \ "ooops!" From jflores at codeit.com Wed Oct 25 18:27:14 2000 From: jflores at codeit.com (Julio Flores Schwarzbeck) Date: Wed, 25 Oct 2000 15:27:14 -0700 Subject: dbase module In-Reply-To: <39F7588A.31FB17BE@tridog.com> Message-ID: <5.0.0.25.0.20001025152440.00a2bbb0@mail.codeit.com> I assume you usew windows to access the dbase tables.. Use the zope ODBC driver to pull the data, INSERT records, queries, etc. I'll be glad to send you more information if interested.. Julio F. Schwarzbeck At 04:02 PM 10/25/00 -0600, Ken Kinder wrote: >When looking for a module to read dbase files, I found > > http://www.stud.ifi.uio.no/~lmariusg/download/python/dbfreader.py > >I was wondering if anyone had any other suggestions for importing dbase >data. > > >-- >http://www.python.org/mailman/listinfo/python-list From sill at localhost.kitenet.net Tue Oct 24 16:10:35 2000 From: sill at localhost.kitenet.net (Oldayz) Date: Tue, 24 Oct 2000 20:10:35 -0000 Subject: need advanced curses module Message-ID: Hiya, I need the curses module (file is called cursesmodule-1.5b2.tar.gz), I found it at ftp://starship.python.net/pub/crew/andrich/mystuff/cursesmodule-1.5b2.tar.gz but the download don't work (starship's down again isn't it?). Anybody who got the file can put up a mirror? -- Andrei From dbrueck at edgix.com Tue Oct 10 11:15:38 2000 From: dbrueck at edgix.com (Dave Brueck) Date: Tue, 10 Oct 2000 09:15:38 -0600 Subject: Request for Python Source Code In-Reply-To: <8rva9b$vbs$1@desig-bs01-s04.adtranzsig.de> Message-ID: <003d01c032cc$f34f46b0$6237693f@PRODUT2KDAVE> >I suppose (this is just an assumption) that Simoney invented it >in the 70ies when writing assembler code. There, it might make sense >to prefix a name of a variable with a type prefix. >It doesn't make much sense from C upwards. Really? It's probably _most_ useful in a language like C where the programmer is allowed to abuse data types at will, sometimes without so much as a warning from the compiler. Because it's largely the programmer's responsibility to keep track of whether something is an int or a pointer, for example, having that information contained in the variable name can be pretty handy. Even when the compiler does warn you, I still find that it's handy to know (via the name) what sort of an object you're operating on. It's certainly not a must, and I've never used the full Hungarian style, but it really adds to code readability to know the data type when it affects the program's behavior. In Python I don't use that notation as much because things are more concise, but it's still occasionally helpful (boolean flags are the most common case in which I use them). Anybody else do this in Python or is it just my bad habit left over from programming in inferior languages? -Dave From aleaxit at yahoo.com Tue Oct 17 06:46:58 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 17 Oct 2000 12:46:58 +0200 Subject: I want to impress the boss. References: <8sdvc6$jqq$1@nnrp1.deja.com> <39EAFE3C.7D13B8B3@engcorp.com> <8sgn6d$s10$1@nnrp1.deja.com> Message-ID: <8shb6201v2a@news1.newsguy.com> wrote in message news:8sgn6d$s10$1 at nnrp1.deja.com... > Ok... Now that we've all had our turn at stating "I'm new to Python" > (and don't yet know much). Focus....Focus! :) > > The questions: > - The location of a complete set of Microsoft Word COM commands is > asking too much? http://msdn.microsoft.com/library/officedev/odeomg/deovrmicrosoftword2000.ht m gives a graphical diagram of the Word 2000 object model and reminds you that the complete documentation of it (in compiled HTML form) "is available in VBAWRD9.CHM" (assuming, of course, that you've installed the "Visual Basic for Application Help files" as a part of your Office 2000 installation). "commands" is not a term that I've ever heard used in conjunction with COM or Automation (Methods, Properties, Interfaces, Events, etc, are terms generally used), but I guess this is what you mean...? Actually, almost-full docs are also part of MSDN and available online. E.g., if you're looking for details of the AutoCorrect object, you'll find them starting from http://msdn.microsoft.com/library/officedev/off2000/grproautocorrect.htm However, this part of MSDN is not well-integrated with its TOC, so navigating it is not maximally easy (the above-mentioned CHM file makes it easier, IMHO). > - When interfacing to VSS it's up to me to build my own 'home grown' > set of commands...(it's possibly not mature enough a program to have a > built in COM interface)? Visual SourceSafe 6.0 supports COM Automation. Some relevant articles, easily found in 5 minutes with a fast net connection and intimate familiarity with MSDN (but no VSS experience:-)...: http://msdn.microsoft.com/library/techart/vssauto.htm http://msdn.microsoft.com/isapi/gosupport.asp?TARGET=/support/kb/articles/q2 01/4/31.asp and others listed at: http://msdn.microsoft.com/library/default.asp?URL=/ssafe/technical/articles. asp > Answers: > - What's the hurry? I understood you could do things quickly in > Python. Why must I show patience? :) Python is generally the fastest way to solve a given problem. Getting very good familiarity with the many gigabytes of information on MSDN, so you can find what you're looking for (and decipher it from MS-speak to your own terms:-), is, on the other hand, a "fine art", only learned through extensive experience. And hurry tends to interfere. Alex From tismer at appliedbiometrics.com Sun Oct 8 12:53:08 2000 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Sun, 08 Oct 2000 19:53:08 +0300 Subject: future of Python: Stackless, Standard -> fragmentation ? References: <8rk7e5$47u$1@oslo-nntp.eunet.no> <39DF1E75.5589C2D7@seebelow.org> Message-ID: <39E0A674.6444E3A9@appliedbiometrics.com> Grant Griffin wrote: [good stuff] > That was very interesting, and it makes good sense. But I guess the > thing that confuses me, in that context, is the assertion I have read > that Stackless is 100% backwards compatible with CPython. Is the > "irreconcilable difference", then, in terms of the _new_ features or > capabilities that Stackless adds? If so, JPython programmers presumably > could happily continue to do without them, in the same way that CPython > programmers currently do; only programs that rely on the new features > would be incompatible with JPython. Right! There is 100% backwards compatibility with CPython. The funny argument is in fact that with Stackless, there would be modules written that would not run at all or without larger changes on JPython. That makes me into the one who seeds incompatibility between the two. But! With the same consideration, one could argue: Why was JPython written at all? Jim Hugunin *knew* that the Java VM isn't capable to express everything that can be done with C, so it was clear that there would be lots of modules for CPython which cannot easily be ported, since yet there are no written resrictions on what you are allowed to code in C. So Jim should have foreseen that I would write continuations in the future, and either not write JPython or change the JVM. :-)) I still consider these considerations ridiculous, born from the fear these continuations could make it into Python somehow. I never saw the argument "don't do this since JPython can't do it" before I begun to break the holy stack. guilty-ly y'rs - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From aleaxit at yahoo.com Wed Oct 25 06:25:29 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 25 Oct 2000 12:25:29 +0200 Subject: C's syntax References: <8t0or303ee@news1.newsguy.com> <8t1964$v8a$1@news7.svr.pol.co.uk> <17WI5.58198$oN2.2362868@news20.bellglobal.com> <39F45B51.320AA63F@alcyone.com> <8t1nr90105v@news1.newsguy.com> <39F4FEAF.FA466927@alcyone.com> <8t3nt4027fk@news2.newsguy.com> <39F5B3AC.7A02F667@alcyone.com> <8t4q9121lpv@news1.newsguy.com> <39F65D4C.8270EE5A@alcyone.com> Message-ID: <8t6co5085b@news1.newsguy.com> "Erik Max Francis" wrote in message news:39F65D4C.8270EE5A at alcyone.com... > Alex Martelli wrote: > > > It *IS* most definitely the language's fault if its syntax is so > > horrid that it needs specific implementations to "subset" that > > syntax, while having standards that assert the whole syntax > > must be such-and-such. > > Then don't use it. People who like C will disagree with you, however. I like C, and I don't disagree with myself. So, I use it (when needed -- i.e., as little as possible, since higher-abstraction- level languages such as Python are more productive when their use is feasible), *despite* its syntax. And, of course, despite your imperative "don't use it": I don't take orders from you (what ever made you think I would?). See below for another person who considers C "quirky and flawed", about whom I'm expecting to hear you saying "he doesn't like C"... > > Either the idiom > > while(this_char = get_next_char()) > > is a good thing to have in the language, in which case it's > > silly to state that a good compiler should strive to make its > > users avoid it; or, the idiom is a BAD thing to have in the > > language, in which case it's just as silly to keep stating that > > the language's syntax is good! > > It's a good thing to have in the language, because it adds more > flexibility. The typical way of using it is something like > > while ((c = getchar()) != EOF) This is not "using the idiom" where the assignment is directly used as the while's condition; it's a different idiom. If, instead of accepting any expression in while(expr)/if(expr), C's syntax specified something slighty different (a "logical expression" -- comparison, negation, &&, ||...), then this "typical idiom" would not be affected; "if(a&b)" and "if(a=b)" would become syntactically invalid -- one could still insert a specific comparison-with-0 to get the same effect: if( (a&b) != 0) etc. There are also other, non-syntactic possibilities (e.g, Java's introduction of a specifically 'boolean' type) to make most such typos into compile-time errors. By the way, the need for extra parentheses here points to another one of C's syntax horrors, one which even Dennis Ritchie cannot fail to admit is "an infelicity of C's precedence rules". Do read his very interesting paper: http://cm.bell-labs.com/cm/cs/who/dmr/chist.html including such assertions as "historical accidents or mistakes have exacerbated their difficulty", "many of the nested declarations and expressions would become simpler if the indirection operator had been taken as a postfix operator instead of prefix, but by then it was too late to change", "an accident of syntax contributed to the perceived complexity of the language", etc. Don't worry, Ritchie isn't disowning his brainchild! He sums it up: "C is quirky, flawed, and an enormous success", explaining that success exactly the way I do -- "satisfied a need for a system implementation language efficient enough to displace assembly language, yet sufficiently abstract". Note well, syntactic aspects are prominently ABSENT from this explanation, and quite rightly, too. As Ritchie's quoted paper amply shows, the "quirks and flaws", which make C "quirky" and "flawed" in his estimation, are predominantly concentrated in the syntax of the language, and explained by historical accidents, and by mistakes that he has no compunction against owning up to. Now will you claim that _Ritchie_ "doesn't like C", and admonish HIM to give it up, too...? Or will it finally get through your skull that one can at the same time admire, respect, and like the key aspects of a programming language, while being acutely aware of the many defects (quirks, flaws, whatever) of its syntax, and therefore not ready to acquiesce in any assertion to the effect that said syntax is "good"?! > > you seem unable to follow through logically and admit > > that, as *the syntax of C has horrid aspects that should > > NOT be used* (with, even, compiler-warnings pushing users > > away from them), therefore, *the syntax of C is _NOT_ > > good*. > > _You_ don't like C's syntax. That does not mean that it is not good; > that just means that, in your opinion, it is not good. Don't use C; get > over it. In my opinion, in Koenig's, in Ritchie's, C's syntax is such as to make the language quirky and flawed. & and | have the wrong priority, comments should have stayed // as in BCPL right from the start (as they finally have become again, in C++ and C99), assignment might well have remained := as in BCPL rather than = (avoiding many issues; Ritchie has admitted to "legacy of PL/I" in those changes he made back when BCPL became B, and couldn't undo later), break is a silly way to terminate a switch's case (making it impossible to conditionally exit a loop based on a switch rather an an if!), the indirection-operator should have been postfix rather than prefix, etc, etc. All of this is just as likely to convince me (or Ritchie, or Koenig) to "not use C" or "get over it", as the buses' horrid color is likely to convince me to stop commuting by bus (and start spewing exhaust fumes at the environment twice a day every day...). But, being acutely aware of all of these flaws and quirks in the language's syntax, I don't have to keep quiet while clueless assertions about the syntax's goodness get bandied about. Neither does Ritchie have to keep quiet, and maybe his words are likelier to command respect from true _fanatics_ of C (as is typical, those who can best claim to understand the language are _not_ fanatical in its favour -- they just opine that its semantical-level strengths have been, and may still be, more important than its undeniable syntactic quirks and flaws). Alex From dsh8290 at rit.edu Mon Oct 30 09:39:18 2000 From: dsh8290 at rit.edu (D-Man) Date: Mon, 30 Oct 2000 09:39:18 -0500 Subject: CPython vs. Jython/JPython In-Reply-To: ; from tdelaney@avaya.com on Sun, Oct 29, 2000 at 23:50:56 -0500 References: Message-ID: <20001030093918.B5375@dman.rh.rit.edu> Java isn't necessarily slower than C. (I should expand that a little: Java *apps* aren't necessarily slower than C *apps*) There was an article published in the October 2000 edition of IEEE Computer magazine giving an experimental, quantitative analysis of 7 programming languages. A number of the Java implementations (of the solution) were faster than some of the C implementations. (BTW, there were 24 Java implementations and only 5 C implementations) As far as memory usage goes, the Java programs were much higher than everything else. I am unfamiliar with JNI so I'll have to take your word for it. I did read an article on Stackless (C)Python and it looked very interesting. If it can't be implemented in Java, that would be a good reason to stick with C. My other question still stands, however: Wouldn't it be more productive if both teams worked together on the same interpreter? Thanks for the response. -D On Sun, 29 Oct 2000 23:50:56 "Delaney, Timothy" wrote: > There are a number of things against this suggestion (note - I'm not > dismissing it out of hand). > > 1. Need for a Java Virtual Machine. > > The CPython interpreter is *much* smaller than the JVM, both in install size > and resource usage. The disparity is even greater when using Stackless > CPython. > > 2. Speed. > > The CPython interpreter is much faster than J(P)ython. Whilst this could be > offset somewhat by doing everything through JNI, this has a few other > problems: > > Harder to use a single source tree for all platforms. > It will still be *many* times slower than CPython due to the > overhead of JNI. > > 3. Compatibility > > In addition to the need for JNI (and the incompatibilities introduced by > that) Python would *only* be available on those platforms which had a > well-behaving implementation of the correct version of the JVM. As an > example - I doubt there would be an Amiga version of Python if Python only > ran on top of the JVM. > > 4. Stackless. > > If Python was written in Java, I highly doubt we would *ever* have seen the > wonderful Stackless implementation come about. Since it has been done people > are looking at how the Stackless extensions could be mapped onto J(P)ython, > but it appears that everything would have to be done with Java Threads - > which will slow Stackless down to a crawl. > > Personally, I can't think of any advantages of having the reference > implementation in Java which Python doesn't already have. > > I'll let others come up with other reasons for and against. > > Tim Delaney > PIP From borcis at geneva-link.ch Sat Oct 21 08:39:49 2000 From: borcis at geneva-link.ch (Boris Borcic) Date: Sat, 21 Oct 2000 14:39:49 +0200 Subject: Announcing Jython, the sucessor to JPython References: Message-ID: <39F18E95.7AACCE47@geneva-link.ch> Ivan Frohne wrote: > > "Barry A. Warsaw" wrote in message news:mailman.971962862.8385.python-list at python.org... > > > > Hello JPython users, > > > > I'm very happy to announce the formation of the Jython project on > > SourceForge. Jython is the successor to JPython, the Java > > implementation of the Python programming language > > "Jython" kinda sticks in my larynx. How about "Javathon", or > "Pythonava? Google permitted me to establish the existence of a "python timorensis", but no "python javanensis" apparently. Too bad. BB From jorgen at bos.nl Thu Oct 26 05:06:28 2000 From: jorgen at bos.nl (Jørgen Teunis) Date: Thu, 26 Oct 2000 11:06:28 +0200 Subject: ldap.update AND members in groups Message-ID: <972551162.771607@proxy.bos.nl> Hello, Could anybody tell me how the update function for the ldap module works and how i can add users to a group with the ldap module? Do i've to update the group everytime? Cause now i add a ou when adding a person, and that works, but when i look at the members of that group, there aren't any. Please help. Best regards, J?rgen From aleaxit at yahoo.com Fri Oct 27 06:34:00 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 27 Oct 2000 12:34:00 +0200 Subject: Python scoping References: <8tab8k024o3@news1.newsguy.com> Message-ID: <8tbm1i0oth@news1.newsguy.com> "Steve Horne" wrote in message news:gqeivsspqj64idsf6rr6dgbekif5t9osfo at 4ax.com... > On Fri, 27 Oct 2000 00:28:15 +0200, "Alex Martelli" > wrote: > > >I recall that in PL/I you may, if you wish, recall the label in > >the END clause (or was it Ada...? darn -- big languages, long > >ago...): > > Ada certainly allows some types of blocks to be named, and allows you > to use those names (for instance) to exit out of multiple layers of > loop in one go (sound like a hidden goto?) No, just a very useful and clear multi-level break. Java has it too, as, I think I recall, does Perl (Perl's keyword for it being 'last' rather than 'break'). In other languages, you have to fake this useful control structure with exceptions and try-blocks, or by wrapping the nested loops in a function that has no other reason to exist (return acts as the multi-level break). I find explicit constructs for named-loop exit far preferable. > You must specify the block name for 'end' with procedures and > functions, but cannot (except comments) for ifs, loops etc. Thanks for refreshing my fogged memory. I now suspect PL/I was like that, too. Dylan, apparently, is the language that lets you optionally name, in the END construct, what is it that you are ending, and I think I had this vague subconscious memory confused with the other languages that let you name blocks at the start, but not for the purpose of naming the end as well. Alex From pete at petes-place.com Sat Oct 7 19:23:04 2000 From: pete at petes-place.com (David T. Grove) Date: Sat, 07 Oct 2000 23:23:04 GMT Subject: Is this a dream or a nightmare? (Was Re: XML) References: <39d1d3b2.43465571@news.telus.net> <39D19EBB.ABF18F23@engcorp.com> <39def2ae.8929692@news.davesworld.net> Message-ID: <39dfabb5.27391600@news.davesworld.net> On Sat, 7 Oct 2000 15:09:29 -0600, "Frank Sergeant" wrote: > >"David T. Grove" wrote in message >news:39def2ae.8929692 at news.davesworld.net... > >David, I enjoyed your rant about ActiveState in this post and in the >interview with "Pete" on the www.CodeMagicCD.com web site. It had always >annoyed me that ActiveState allowed one to download only a >non-redistributable "distribution" of Perl. I feared (and I believe it has >been realized) they would take Python in the same direction. Don't just fear it. I've been fighting these bastards for more than two years now. I know what their goals are, and how they get there. If this community shows any acceptance of them, you can kiss python goodbye within five years. Pick up a copy of the camel and you'll see what I mean (third edition)... every other page is another feature that's partially implemented. The only reason that's been publicly visible for the horrendously early release of Perl 5.6 by Sarathy was for ActiveState to meet the Microsoft crossplatform toolkit deadline... and since they own Sarathy, they can control such things... and put out a perl that's about half finished just to impress their Redmond masters. But then, without Redmond, ActiveState doesn't really have the wherewithall to pay their electricity bills... I do wish people would stop saving them from bankruptcy. When I heard that ActiveState was going Python, I was furious at Guido for allowing it. He's so GPL/OSS that he flogged me until he found out that CodeMagic was free. (I just won't distribute source except to developers helping with the project, because there are theieves in them there perl woods.) I'm starting to see that Guido didn't "allow" it at all... or that's the impression I'm getting from posts like this. >I noticed on the web site that you said > >> The true beauty of perl is shown in how rapidly a program can be created: >> a good average for comparison is 1 line of perl for every 25 lines of C, >> TclTk, Python, or Visual Basic, and every 100 lines of C++. > >I was surprised to see that ratio of 1 to 25 for Perl to Python. Could you >say a little about your reasoning in that regard? Did that in a later post in this thread. First rude pythonista I've found so far. Well, second. (Is "pythonista" politically correct? I don't know the right word. In Perl it would be "japh".) > >Is your PerlMagic port of Perl freely redistributable? Of course. That's the whole point of it. The problem is, anyone who mentions it on the Win32-Perl mailing lists (controlled by guess-who) gets banned. (Pretty easy to control markets if you control the media.) It's shortly to be renamed "FreePerl" unless the trademark on Perl gets put into place, in which even I'd probably do something like FreePL. It's just a distribution without the ActiveState crap in it that disables standard embedding and extending. It's not a port, just a build with most of the most popular modules built in. I'm trying to take it even a step farther and bring it to GCC, but several of the modules aren't ready for anything but MSVC. Even the Borland compile has stagnated for over two years. Problem is, nowadays, they've bought up so many of the P5P, they're hoarding modules until months after they release them in ActivePerl, to prevent competition (me) from showing the world that one person can keep up with their whole team. It took me over three months to get a libwin32 that was usable with Perl 5.6, when AS had it the day of the 5.6 announcement. "No, we don't change any modules." Pffft, yeah, right. Anyway, let's get off that subject. I have another issue or two that I need some help with. I need to determine the future of CodeMagic itself. Just a quick question before I bring it up... how many of you actually use it? From olivierS.dagenaisP at canadaA.comM Mon Oct 16 15:44:57 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Mon, 16 Oct 2000 19:44:57 GMT Subject: Remote Procedure Call References: Message-ID: I hate to disappoint you, but RPC *is* a complicated thing! You can look in "The Vaults of Parnassus" for RPC stuff [http://www.vex.net/parnassus/apyllo.py?so=d&find=rpc] or you can write your own, simple special-case one, like I did: use CGI and pass a variable called "method" and a few variables called "parameterX". You can urlencode your results back to your client, too, to stay consistent in your data encoding/decoding and it's REALLY easy to get started. Give me a little while to finish my implementation and to release my code and you'll have a working example, too! pick-up-any-operating-systems-book-to-know-just-how-complicated-rpc-can-be-l y y'rs :) -- ---------------------------------------------------------------------- Olivier A. Dagenais - Software Architect and Developer "Someone called 'Type your name here' is impersonating me on the internet and is posting exactly the same things I am posting!" "Sandor" wrote in message news:LSFG5.3366$eI1.18191 at news1-hme0... > To anyone who can help, > I am fairly new to network programming and I am trying to find out how to > write a simple program in Python implementing RPC. Everywhere I look on RPC > seems to be very advanced. I would like to know how to write some simple > source code using RPC. Any help on the matter would be greatly appreciated > Many thanks > Sandor > > From bjorn at roguewave.com Wed Oct 4 12:55:23 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Wed, 04 Oct 2000 10:55:23 -0600 Subject: Wholly unnecessary flame. (was Re: pyXML!) References: <8r1oq1$5go$1@desig-bs01-s04.adtranzsig.de> <39D44213.59B6CA11@seebelow.org> <8ra9iu$bo0$1@desig-bs01-s04.adtranzsig.de> Message-ID: <39DB60FB.F3422BCC@roguewave.com> Dirk-Ulrich Heise wrote: > > "Grant Griffin" schrieb im Newsbeitrag > news:39D44213.59B6CA11 at seebelow.org... > > Dirk-Ulrich Heise wrote: > > > You mean something like, "it works, so i won't touch it"? > > > (Yeah okay, i'm frightened still every time i gotta launch > > > MSVC, but then, i get paid for it) > > > > Care to elaborate on your fear, uncertainty, and doubt? > > I use MSVC daily, and I really don't know what there is to be frightened > > about. I actually get a warm, comfortable feeling each time I use it. > > It always generates correct code (for me, at least), and its IDE is far > > slicker than any other IDE I've seen. > > Maybe you should see some more ;-). I like the Borland thingies > and of course Boa constructor much more. YMMV. Every compiler has it's set of bugs, however I still haven't seen the ms compiler lay down incorrect assembly (not accepting legal code is a different issue ;-). I _have_ seen the other compiler you mention lay down incorrect code (and it's not much better at accepting legal code either...) -- bjorn From loewis at informatik.hu-berlin.de Sun Oct 8 12:50:54 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 08 Oct 2000 18:50:54 +0200 Subject: busting-out XML sections References: <39DCFFC2.A26BF159@ix.netcom.com> Message-ID: Thomas Gagne writes: > Niether solution sounds appealing. It amounts to a lot of code for > what's really a simple problem. Maybe there's something in the SAX > stuff that would allow me to grab everything between (and including) > the tags. Using PyXML, I would inherit from XMLGenerator. Roughly, it would look like class DevNull: def write(*args): pass class OrderFilter(XMLGenerator): def __init__(self,outstream): self._null = DevNull() self._realout = outstream XMLGenerator.__init__(self,self._null) def startElement(self,tag,attrs): XMLGenerator.startElement(tag,attrs) if tag == "order": self._out = self._realout def endElement(self,tag): if tag == "order": self._out = self._null XMLGenerator.startElement(tag,attrs) Then, create a parser, and attache an OrderFilter created with the output stream. Hope this helps, Martin From tyler at tylereaves.com Tue Oct 17 21:44:18 2000 From: tyler at tylereaves.com (Tyler Eaves) Date: Wed, 18 Oct 2000 01:44:18 GMT Subject: String adding. References: <39ECFA3F.26B87754@uoguelph.ca> Message-ID: <39ed0048.3155582@news.geeksnet.com> On Tue, 17 Oct 2000 21:17:51 -0400, Mark Cunningham wrote: >i know doing: > > >strName = 'wow' > '<' + strName + '>' > >will give you > Yep >but what about: > >intName = 3 >print '<' + intName + '>' >this gives me some illegal argument type for built-in operation.. >how would i make it give me <3>???? > The reason is that < and > are the greater than lesstan signs. use '<'+str(intName)+'>' --- Tyler Eaves Visit Ultra Coaster Central! The internet's largest repository of Ultra Coaster Tracks! http://www.ultracoastercentral.com -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From josh at open.com Tue Oct 3 02:10:37 2000 From: josh at open.com (Joshua Muskovitz) Date: Tue, 3 Oct 2000 02:10:37 -0400 Subject: how do I listen on a socket without sucking up all the CPU time? References: <39d971f3_1@corp.newsfeeds.com> Message-ID: <39d976b9_4@corp.newsfeeds.com> > This sounds like a job for the select module. > > Alex. Can you be a little more specific? -- j -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From hwanjoyu at uiuc.edu Tue Oct 31 14:50:54 2000 From: hwanjoyu at uiuc.edu (Hwanjo Yu) Date: Tue, 31 Oct 2000 13:50:54 -0600 Subject: Q: how to extract only text from a html ? Message-ID: Could someone please tell me how to get rid of all the tags in a html ? It seems that the htmllib.HTMLParser is not helpful to do it. Thanks. From keisari_ at hotmail.com Tue Oct 17 12:25:57 2000 From: keisari_ at hotmail.com (joonas) Date: Tue, 17 Oct 2000 19:25:57 +0300 Subject: Starage for loops Message-ID: <39EC7D95.D88E056F@hotmail.com> What does this actually do ######## for cuvihrea in vihrea.curves: ptsvihrea= cuvihrea.points for pt in ptsvihrea: pt.pt[1]= pt.pt[0]*nopeusvihrea cuvihrea.points= ptsvihrea # update ######## Beginner. From MarkH at ActiveState.com Wed Oct 18 02:37:30 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 18 Oct 2000 06:37:30 GMT Subject: calldll and python20 References: <8sjeu1$4h6$1@nnrp1.deja.com> Message-ID: > __declspec(dllexport) void > initcalldll(void) Is it C++ code? Try "extern "C"" before it. Also, MSVC comes with a tool "dumpbin.exe" - try "dumpbin /exports calldll.pyd" Mark. From loewis at informatik.hu-berlin.de Sun Oct 1 14:46:24 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: Sun, 1 Oct 2000 20:46:24 +0200 (MET DST) Subject: Import libraries and Borland C (Was: Wholly unnecessary flame.) In-Reply-To: <009f01c02b9d$51be26d0$0101a8c0@jayk3> (jay.krell@cornell.edu) References: <009f01c02b9d$51be26d0$0101a8c0@jayk3> Message-ID: <200010011846.UAA00916@pandora.informatik.hu-berlin.de> > Oh, there is also the question of "ABI", how the compiler layouts out > structs and stack frames and such, but generally compilers follow > Microsoft's (or whatever the "native" vendor is) lead in order to be able to > consume windows.h (or whatever platform specific headers/shared libraries, > w/o resorting to something hacky like modifying the headers or providing > thunking libraries). It seems that you are right in the "general" case. In the specific case of Borland C++ builder, it appears that Borland always prefered to ship their own copy of windows.h and the system import libraries (or whatever technology they use to make the functions available). As a Unix person, I feel the entire concept of import libraries is flawed - you should be able to directly link to the dynamic library. I believe in Win32, this is actually possible; not sure why the tools still insist on import libraries. But then, even *if* Borland C could link with the VC++ compiled python20.dll, you still could not build extension modules with it. python20.dll uses stdio, and that comes from msvcrt40.dll. However, Borland C has a different implementation of stdio. Opening a file with the Borland function, and passing that (through python.dll) to a Microsoft function causes a crash. So to build extension modules with Borland's tools, you need a Borland-build Python. Hopefully, people won't call the resulting DLL "python20.dll"... Again, it appears that GCC is ahead of Borland C here; gcc can happily use MSVCRT as stdio (instead of its "own" cygwin library). Regards, Martin From effbot at telia.com Sun Oct 8 10:15:14 2000 From: effbot at telia.com (Fredrik Lundh) Date: Sun, 08 Oct 2000 14:15:14 GMT Subject: Tkinter.PhotoImage question References: Message-ID: Kent wrote: > I would like to display image files onto labels and canvasses. I noticed > however, that if I call PhotoImage from within a function, no image will > appear. When I run the following code, a photo appears on the label but > not the canvas, even though the lines and bitmap do appear. Is this a > Tkinter bug? Is there a workaround? You must keep a reference to the photoimage object. For example: c = Tkinter.Canvas(f) c.pack() c.photo2 = Tkinter.PhotoImage(file="lena.gif") ... c.create_image(10,10,anchor=Tkinter.NW, image=c.photo2) ... for more info, see: http://www.python.org/doc/FAQ.html#4.69 From jay.krell at cornell.edu Thu Oct 26 16:25:34 2000 From: jay.krell at cornell.edu (jay.krell at cornell.edu) Date: Thu, 26 Oct 2000 13:25:34 -0700 Subject: [Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich , comparison Message-ID: <00d301c03f8a$e63ae4f0$8001a8c0@jayk3.jaykhome> 1.5.2 source: Are those trailing Py.._From... doing heap allocations? I believe so. Yuck. That probably dominates everything, in general, in Python. Besides, "PyLong" is more expensive than "PyDouble", right? Well, it looks like one level of its heap allocation is made very fast, just pluck the head of the free list. Why does integer division return a long? I can understand integer multiplication.. static PyObject * float_div(v, w) PyFloatObject *v; PyFloatObject *w; { double result; if (w->ob_fval == 0) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); return NULL; } PyFPE_START_PROTECT("divide", return 0) result = v->ob_fval / w->ob_fval; PyFPE_END_PROTECT(result) return PyFloat_FromDouble(result); } static PyObject * int_div(x, y) PyIntObject *x; PyIntObject *y; { long d, m; if (i_divmod(x, y, &d, &m) < 0) return NULL; return PyInt_FromLong(d); } static int i_divmod(x, y, p_xdivy, p_xmody) register PyIntObject *x, *y; long *p_xdivy, *p_xmody; { long xi = x->ob_ival; long yi = y->ob_ival; long xdivy, xmody; if (yi == 0) { PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo"); return -1; } if (yi < 0) { if (xi < 0) xdivy = -xi / -yi; else xdivy = - (xi / -yi); } else { if (xi < 0) xdivy = - (-xi / yi); else xdivy = xi / yi; } xmody = xi - xdivy*yi; if ((xmody < 0 && yi > 0) || (xmody > 0 && yi < 0)) { xmody += yi; xdivy -= 1; } *p_xdivy = xdivy; *p_xmody = xmody; return 0; } -----Original Message----- From: Fredrik Lundh To: jay.krell at cornell.edu Cc: python-list at python.org Date: Thursday, October 26, 2000 12:25 PM Subject: Re: [Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich , comparison >jay wrote: >> But is integer division actually much faster than floating point division? I >> don't believe there is a fast algorithm for integer division. > >On my PII, floating point division under Python is *faster* than >integer division (hint: look at the float_div and int_div functions, >and you'll understand why...) > >(btw, my "wow" meant "wow, I've seen many strange arguments >in this thread, but not so many in one single paragraph...") > > > > >-- >http://www.python.org/mailman/listinfo/python-list From jcm at bigskytel.com Sat Oct 21 07:50:57 2000 From: jcm at bigskytel.com (David Porter) Date: Sat, 21 Oct 2000 05:50:57 -0600 Subject: Resuming a file download with python In-Reply-To: <8srp7c$ak$07$1@news.t-online.com>; from Robert.Harris@gmx.net on Sat, Oct 21, 2000 at 11:56:25AM +0200 References: <8srp7c$ak$07$1@news.t-online.com> Message-ID: <20001021055056.A22935@bigskytel.com> * Robert Harris : > I want to resume a file download with python. It would be > either the http or ftp protocol used. How could I do it or isn't > it possible ? I browsed through the docs of the http and ftp objects > but didn't find anything. Why not just use an external program, like wget? [Reinventing the wheel and all that...] From cjc26 at nospam.cornell.edu Tue Oct 31 11:19:18 2000 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Tue, 31 Oct 2000 16:19:18 GMT Subject: Method or function? References: Message-ID: * Dale Strickland-Clark menulis: | I dare say that this has been discussed before, I just can't see it | anywhere. | | Shouldn't these standard functions be methods of their various | datatype classes? | | [...] | | Some of these are particularly odd, like those that have to be | implemented by a special __method__, e.g. str(), repr() and len(). | | What's the logic behind this? Methods which can take many different types as an argument were made functions. So, for example, since you can find the length of strings, lists, and tuples, it was made a function. Also, some of the functions on your list, like abs, only apply to numbers; do you really want to write (-4).abs() instead? ;) -- cliff crawford http://www.people.cornell.edu/pages/cjc26/ But WHERE are the turtles? From josh at open.com Fri Oct 6 21:30:35 2000 From: josh at open.com (Joshua Muskovitz) Date: Fri, 6 Oct 2000 21:30:35 -0400 Subject: list sort question References: <8rlr4e$6av$1@nnrp1.deja.com> Message-ID: <39de7b1c_2@corp.newsfeeds.com> You could create a dictionary where the last name is the key and the tuple is the value. (This assumes [a] you have a good function for figuring out which part of the name is the "last name", and [b] that each entry's last name is unique.) Then, get the list of keys from the dictionary, sort it, and then walk the sorted list, extracting the original tuples out of the dictionary in the proper sort order. Note, you can solve [b] by taking "Firstname M. Lastname" and instead of extracting the lastname, converting it to "Lastname, Firstname M." or whatever else would give you the proper sort order. To solve [a], check the dictionary for a previous entry with the same key, and then append something trivial to the new string (like ".1" or something). The assumption here would be that two items with the same name sort ambiguously. If you want to sort same name entries by their email address, then you could append that, for example. Hope this helps. -- josh -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From aahz at panix.com Sun Oct 22 13:11:20 2000 From: aahz at panix.com (Aahz Maruch) Date: 22 Oct 2000 10:11:20 -0700 Subject: mmap? References: Message-ID: <8sv73o$a1o$1@panix3.panix.com> In article , seung-won hwang wrote: > >I am wondering if there is any mmap-like functionality in Python. >Or is there any other way to flush data structure on the memory >to the file and load from the file later? I would appreciate your >answers very much! Use the mmap module? -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "In the end, outside of spy agencies, people are far too trusting and willing to help." -- Ira Winkler From pearu at ioc.ee Fri Oct 6 09:10:44 2000 From: pearu at ioc.ee (Pearu Peterson) Date: Fri, 06 Oct 2000 15:10:44 +0200 Subject: Displaying progress status? Message-ID: <39DDCF54.87FB754C@ioc.ee> Hi! Say, that I have a 'for' loop that takes lots of time to complete. Do you know if there is a Python module that can display some kind of progress information for this situation. Something like this: for i in list: showprogress(100.0*i/len(list)) #do something and in terminal window I would see the following: Status: |------> | [34% completed] Thanks, Pearu From dave at zeus.hud.ac.uk Thu Oct 19 08:07:39 2000 From: dave at zeus.hud.ac.uk (Dave Dench) Date: Thu, 19 Oct 2000 13:07:39 +0100 (BST) Subject: Andy Robinson's SpamServer COM demo Message-ID: <200010191207.NAA05318@brahms.hud.ac.uk> Thanks Mark, this did make the difference and demo works fine now. Best wishes, David > > There is a good chance that the path to the spamserver example is not > on your PythonPath. > > If the COM object has a "_reg_class_spec_" attribute, remove it. > Later versions of win32com allow you to omit this, in which case they > imply both the path and the module. spameserver predates this > enhancement. > > If that is not it, look up the documentation on debugging COM objects, > and see what the "trace collector" has to say... > > Mark. > -- > markh at activestate.com - but if you think I speak for them, you dont > know Dick! > > "Dave Dench" wrote in message > news:mailman.971943147.4468.python-list at python.org... > > > > Dear All, > > didn't see a response to this so I'll try again. > > I am running the SpamServer and it's later brother SpamServerGPO. > > The original demo works fine. The GPO ( LOCAL_SERVER ) version > > registers correctly apparently and can be seen from the COM browser, > > but the /test fails saying > > **** - The Python.SpamServer test server is not available > > > > I have tried registering it as > > SpamSrv = win32com.client.dynamic.Dispatch("Python.SpamServerGPO") > > > > and as > > SpamSrv = > win32com.client.Dispatch("Python.SpamServerGPO",clsctx=pythoncom.CLSCT > X_LOCAL_SERVER) > > > > without success. > > Any pointers ? > > PS running Python1.6 on an NT server ( via winframe ) > > > > Thanks > > David > > From effbot at telia.com Fri Oct 27 02:58:46 2000 From: effbot at telia.com (Fredrik Lundh) Date: Fri, 27 Oct 2000 06:58:46 GMT Subject: MS Windows Clipboard References: <8t3m1n025h1@news2.newsguy.com> <8t6fmn0bg9@news1.newsguy.com> <8ta16b01n0d@news2.newsguy.com> <39F8DCC2.130D64@holdenweb.com> Message-ID: Steve Holden wrote: > When I use Tkinter I always shudder to think about all the data that's > being passed as strings when enumerated constants or simple integers > would be better. help is on the way: http://w1.132.telia.com/~u13208596/tkinter From robin at jessikat.fsnet.co.uk Fri Oct 20 15:40:56 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 20 Oct 2000 20:40:56 +0100 Subject: Alternate Python download locations References: <8sq3ql$jee$1@nnrp1.deja.com> Message-ID: In article <8sq3ql$jee$1 at nnrp1.deja.com>, Jeremy Hylton writes >I have made Python download files available from >http://www.python.org/2.0/ >and >http://sourceforge.net/projects/python/ > >I hope this makes it easy for people to get 2.0 despite heavy load or >other problems with an individual download site. > >-- >-- Jeremy Hylton, > > >Sent via Deja.com http://www.deja.com/ >Before you buy. So this lack of pythonlabs is a Zope effect? Or maybe the load is huge? -- Robin Becker From dale at out-think.NOSPAMco.uk Thu Oct 19 20:24:37 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Fri, 20 Oct 2000 01:24:37 +0100 Subject: ActivePython 2.0 Release References: Message-ID: <634vusk9nco8qem70ddo43t4qpgid30s1l@4ax.com> Yes, but how is this better then Python 2.0 + Win32all? activestate-announce at ActiveState.com wrote: >It is our pleasure to announce the release of ActivePython 2.0, build 202. > >This binary distribution, based on Python 2.0, is available from >ActiveState's website at: > > http://www.ActiveState.com/Products/ActivePython/ > >ActiveState is committed to making Python easy to install and use on all >major platforms. ActivePython contains the convenience of swift >installation, coupled with commonly used modules, providing you with a >total package to meets your Python needs. Additionally, for Windows users, >ActivePython provides a suite of Windows tools, developed by Mark Hammond. > >ActivePython is provided in convenient binary form for Windows, Linux and >Solaris under a variety of installation packages, available at: > > http://www.ActiveState.com/Products/ActivePython/Download.html > >For support information, mailing list subscriptions and archives, a bug >reporting system, and fee-based technical support, please go to > > http://www.ActiveState.com/Products/ActivePython/ > >Please send us feedback regarding this release, either through the mailing >list or through direct email to ActivePython-feedback at ActiveState.com. > >ActivePython is free, and redistribution of ActivePython within your >organization is allowed. The ActivePython license is available at >http://www.activestate.com/Products/ActivePython/License_Agreement.html >and in the software packages. > >We look forward to your comments and to making ActivePython suit your >Python needs in future releases. > >Thank you, > >-- The ActivePython team > ActiveState Tool Corporation > Dale Strickland-Clark Out-Think Ltd Business Technology Consultants From ak42 at altavista.com Mon Oct 2 06:35:08 2000 From: ak42 at altavista.com (Alexander K) Date: Mon, 02 Oct 2000 10:35:08 +0000 Subject: listening socket doesnt answer References: <39D8334F.76DEFCD3@altavista.com> Message-ID: <39D864DC.3309CAF@altavista.com> well i found the problem myself. but i still wonder about the address/proto families and .bind(). Alexander K wrote: > > hostname = gethostbyname(gethostname())[0] i had confused gethostbyname() with gethostbyaddr(), which i had used before, and which returns a tuple, not a string... tia / alex k . . ... ~~~:[ com dot altavista at ak42 ]:~~~ ... From gustav at morpheus.demon.co.uk Sun Oct 29 16:26:23 2000 From: gustav at morpheus.demon.co.uk (Paul Moore) Date: Sun, 29 Oct 2000 21:26:23 +0000 Subject: MS Windows Clipboard References: <8t3m1n025h1@news2.newsguy.com> <8t6fmn0bg9@news1.newsguy.com> <8ta16b01n0d@news2.newsguy.com> <33r5OSRm=gidrgnmJUqLe=tsbYNP@4ax.com> <8tfkre01rj3@news1.newsguy.com> Message-ID: On Sun, 29 Oct 2000 00:40:49 +0200, "Alex Martelli" wrote: >Depends on the generality one can reach without excessive >effort, I guess. Here, as an alternative, is a stand-alone VC++ >implementation which I hacked together by modifying a >component I had once written to turn clipboard changes into >COM events (removing the COM stuff, adding the Python >interface, and a simple event-loop with timeout...). You can >save it to clipwait.cpp, and build and install clipwait.pyd with >the following setup.py: Wow! Thank you for this... I will look at it in detail later (no time right now), but it seems like exactly the sort of thing I was trying to do. I could probably have coded the Windows bits myself, but seeing it in a proper Python format, with a setup.py as well, is very useful. Paul Moore From aleaxit at yahoo.com Sun Oct 8 13:16:01 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 8 Oct 2000 19:16:01 +0200 Subject: Is this a dream or a nightmare? (Was Re: XML) References: <39d1d3b2.43465571@news.telus.net> <39D19EBB.ABF18F23@engcorp.com> <39def2ae.8929692@news.davesworld.net> <8ro52a0q1o@news1.newsguy.com> <39dfa617.25953118@news.davesworld.net> <39dfe6db.42535595@news.davesworld.net> <8rq496$ik0l1$1@ID-11957.news.cis.dfn.de> Message-ID: <8rqa7402uo2@news1.newsguy.com> "Emile van Sebille" wrote in message news:8rq496$ik0l1$1 at ID-11957.news.cis.dfn.de... [snip] > One recent study that many of this group participated in > shows that python uses less lines of code than the other > languages. > > http://wwwipd.ira.uka.de/~prechelt/Biblio/jccpprtTR.pdf Excellent reference, but please note that the median length (in SLOC -- "non-comment, non-blank source lines of code") was (by a tiny and not statistically significant fraction) even shorter in Perl than in Python -- maybe by about as 5% (which makes one smile thinking of those claimed "25 times", but...). About 2/3 times shorter than median Java/C/C++ programs. Median time for task completion (around 2.5 hours) is also statistically indistinguishable between Perl and Python (the tiny non-significant advantage is here in Python's favour), and about 4 times better than Java/C/C++ programs. Productivity in SLOC/hours was where Python really stood out from all other languages, around 40 versus a range of 20 to 30 for the other languages. But basically the task turned out into "scripting (Python, Perl, Tcl, Rexx) versus traditional compiled languages (C, C++, Java)", and a significant victory for scripting (4 times better productivity, substantially-equal run times -- maybe 30% slower than C or C++, but faster than Java...). Pity the author did not think (or was unable to) include functional programming languages (ML dialects, Haskell, Erlang, perhaps Dylan...) -- the productivity/speed performances of such languages in the yearly ICFP competition makes it appeat they might well have shown up as significant contenders too! Still, a very interesting study indeed -- wish there were more studies like it...! Alex From dalke at acm.org Thu Oct 19 20:42:41 2000 From: dalke at acm.org (Andrew Dalke) Date: Thu, 19 Oct 2000 18:42:41 -0600 Subject: Undocumented re bug??? References: <39EF1503.B34048EA@insight.co.il> Message-ID: <8t0lmc$ti2$1@nntp9.atl.mindspring.net> Benny Shomer wrote: >I'm experiencing a werid re behaviour. Whenever the digit 7 is present >in a range specifier, the re fails, although the pattern exists in the >string. Yeah. sre.DIGITS up until the 2.0beta didn't contain 7. Took me a long time to track that one down :) I sent in a patch which has been applied to the newer distributions. If you don't want to upgrade, just fix DIGITS in sre_parse.py. Andrew dalke at acm.org P.S. Looks like you are doing Prosite searches of protein sequences. You might want to look into biopython.org which includes, among other things, a Prosite to (s)re converter. From yanivk at my-deja.com Sun Oct 29 10:19:19 2000 From: yanivk at my-deja.com (yanivk at my-deja.com) Date: Sun, 29 Oct 2000 15:19:19 GMT Subject: Getting the window manager name on unix Message-ID: <8thf5i$jv0$1@nnrp1.deja.com> Hi friends, I am looking for a way to get the name of the window manager my application runs upon. This is due to some trouble I've encountered with some WMs. All ideas are kindly welcome. Yaniv. Sent via Deja.com http://www.deja.com/ Before you buy. From parkw at better.net Wed Oct 11 23:18:30 2000 From: parkw at better.net (William Park) Date: Wed, 11 Oct 2000 23:18:30 -0400 Subject: [Python-Dev] RE: [Numpy-discussion] RE: Possible bug (was Re: numpy, overflow, inf, ieee, and rich comparison) In-Reply-To: ; from huaiyu_zhu@yahoo.com on Wed, Oct 11, 2000 at 07:22:54PM -0700 References: <200010120145.UAA02030@cj20424-a.reston1.va.home.com> Message-ID: <20001011231830.B2226@better.net> On Wed, Oct 11, 2000 at 07:22:54PM -0700, Huaiyu Zhu wrote: > >>> from math import * > >>> exp(777) > inf > >>> exp(-777) > 0.0 > >>> sqrt(-1) > Traceback (innermost last): > File "", line 1, in ? > OverflowError: math range error Dear Guido, 'exp(-777)' should return 0, not raise OverflowError exception. It is mathematically correct behaviour. I am less certain about returning 'inf', though. ---William Park, Open Geometry Consulting From claird at starbase.neosoft.com Thu Oct 19 09:17:12 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 19 Oct 2000 08:17:12 -0500 Subject: "Portability" (was: How to create a Unix Domain Socket?) References: <39ED6C4A.CBEE94DB@schlund.de> <8skj2r$3i9k$1@nntp6.u.washington.edu> <4BE3250D4FF22FD0.C3EA83F880EAEC04.44DD6B4DD07EB906@lp.airnews.net> <39EEE7D8.1059A34F@holdenweb.com> Message-ID: In article <39EEE7D8.1059A34F at holdenweb.com>, Steve Holden wrote: >Cameron Laird wrote: >> >> I'm going to grumble briefly--or perhaps ask for help. >> I'm getting tired of calling Python "wonderfully por- >> table" or whatever it is I say when I'm acting as an >> advocate. I know what I mean by it, but for most >> people, most of the time, Python's not quite up to the >> portability of C, and almost every other language is >> equally tender on the point. > >Don't know that I'd agree with that. In my (limited) >experience with C, the thing that tripped me up most moving >between platforms was differences in library semantics: i.e. >the language is the same on all platforms, but the underlying >support code differs, sometimes in subtle, non-obvious ways. Sooooo true. I suspect there's some artifact of my personal history operating here, but it surprises me nowadays how often I hear porta- bility concerns about *languages*, when, as you write, it's almost always the run-time libraries where the problems lie. I think it's worth a follow-up to emphasize tha. > >Given that the Python library offers MUCH higher-level >functionality, I find there's a remarkable degree of poertability. I do *not* find it remarkable. Ha!--it's the higher-level stuff that's easier to get right, or at least invariant. > >> So: what's a good word >> to express, "available on lots of platforms, more or >> less, and, whatever the semantics are on any particular >> one, there's an entertaining story to explain why it's >> so"? > >Might I suggest "The usual portability concerns apply to Python >just as much as any other language"? The fact is that it's always >tempting to implementors to expose underlying OS support in >scripting systems such as Python, and when there's a variety of >platforms then there'll be a variety of non-portable constructs >in library usage. Part of my growsing is uncertainty about whether that's a temptation or a responsibility. My personal emotional reaction is that Python shouldn't be like Perl, and shouldn't just expose the OS run-time; it should build in a portability layer for strftime(), socket(), and other notor- ious black sheep. I suppose I'll just leave it at the level that I'm curious to hear what Guido and the other silverbacks think about exposing the OS vs. construction of a library coders use portably. . . . -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From gdighton at geocities.com Fri Oct 6 16:16:58 2000 From: gdighton at geocities.com (Garth Dighton) Date: 6 Oct 2000 15:16:58 -0500 Subject: Organizing Python Code References: <39D7F3DE.D4104FE7@ix.netcom.com> <39D82B17.81958D15@esatclear.ie> <39DBB04C.1681E515@esatclear.ie> <39DBC391.EDF52FF8@my.signature> <39DD2319.6ECE412E@esatclear.ie> Message-ID: <39de333a$1_2@goliath2.newsfeeds.com> rwallace at esatclear.ie (Russell Wallace) wrote in <39DD2319.6ECE412E at esatclear.ie>: >Greg Ewing wrote: >> Recently I had occasion to work on a Borland Pascal >> program written by someone else, consisting of a few >> dozen source files spread over several directories. >> I found myself wishing that Borland Pascal had a more >> explicit import mechanism than just "uses modulename". > >...I don't understand where the difficulty is? > >Pascal: grep "procedure foo" or "function foo" *.pas (unless my Pascal >is rustier than I think it is :)) >C: grep foo *.h >Python: grep "def foo" *.py > >and equivalents for definitions of classes, global variables etc. I >find this easily works even for hundreds of source files of other >people's code that I'm not familiar with. > This doesn't work when the code is in several directories. I frequently have this problem at work, where the source code for our main product is spread across several hundred files in 50 or so directories (our product is a database server, so the architecture is fairly complicated). You CAN'T just do a grep to find the function definition. (although you can usually grep the include directory to find the declaration, this doesn't always tell you where to look for the definition itself.) -- Garth Dighton -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From nospam at nospam.com Tue Oct 3 10:37:47 2000 From: nospam at nospam.com (Tom) Date: Tue, 03 Oct 2000 14:37:47 GMT Subject: Newbie - Recursive calls in class objects... References: Message-ID: <%amC5.75852$dZ2.28432752@news3.rdc1.on.home.com> "Eric" wrote in message news:ST9C5.97$Q13.124792 at news.pacbell.net... > Hi all, > > To summarize: How do I test if a "__dict__" item is a class object or an > instance variable? > > I am trying to do something like pickling where I recursively call an > object's method that prints out the object's instance variables. I am > looping thru the object's instance variables, printing each one. I do this > with the line: > for t in self.__dict__.items(): (See listing below) As an aside, did you know that you can write this line as: for tkey, tvalue in self.__dict__.items() > I get into trouble if one of the instance variables ( t[0] ) is itself an > object to be printed. I can't seem to figure out how to test if the > variable is an object. Every variable is an object (or, in Python-speak, every name binds to an object). > I've tried "isinstance(t[0], CElement)" which didn't work. > I've tried "issubclass(t[0], CElement)" which didn't work, either. I think you mean "isinstance(t[1], CElement)", because t[0] is the key, whereas t[1] is the value. Tom. > Thanks for your help! > Eric. > > > Here are my classes: > > class CElement: > """Base Class for elements in a project""" > pad = " " > def __init__(self): > self.Name = "" > self.Type = "" > self.PadMult = 1 # equals the number of parent nodes > this object will have in the XML structure > self.XmlTag = self.Type # the node text used to mark the XML > node (i.e., 'User' => ) > > def toXML(self): > strXML="" > strXML = self.pad * self.PadMult + "<" + self.XmlTag + ">\n" > for t in self.__dict__.items(): > ****** NEED HELP HERE ****** > strXML = strXML + self.pad * (self.PadMult + 1) + "<" + t[0] + > ">" + t[1] + "\n" > strXML=strXML + self.pad * self.PadMult + " ">\n" > print strXML > > class CUser(CElement): > """Defines Users""" > def __init__(self): > CElement.__init__(self) > self.Name = "New User" > self.Type = "User" > self.Address = "" > self.City = "" > self.State = "CA" > self.Zip = "" > self.PadMult = 1 > > class CProject(CElement): > """Defines a project""" > def __init__(self): > CElement.__init__(self) > self.Name = "New Project" > self.Type = "Project" > self.XmlTag = self.Type > self.User = CUser() > self.PadMult = 1 > > > From josh at open.com Sat Oct 7 01:59:05 2000 From: josh at open.com (Joshua Muskovitz) Date: Sat, 7 Oct 2000 01:59:05 -0400 Subject: Code obfuscation / decompilers? References: <39de791e_4@corp.newsfeeds.com> <39DE9F04.59C95D24@pehr.net> <39dea172_4@corp.newsfeeds.com> <39deb678.30520382@news.telus.net> Message-ID: <39deba0b_2@corp.newsfeeds.com> > This is a hopeless task: at some point your application must finally come > down to a yes/no decision -- yes, it *can* toggle that bit (because the > license is valid) or no, it *can not* toggle that bit (the license doesn't > conform). > > And at that point, the hacker simply changes your code to say "yes," all > the time. Yes, the same logic applies to the lock on m front door. Anyone who comes all the way to my door intending to come in, is going to come in. The lock only has to be good enough to force them to go through a window. Any more is a waste. I'm trying to avoid tempting those people who are otherwise honest, but might "just be curious". Also, as I said previously, sometimes we are forced to live with the mistakes of others. Sometimes these include poor designs. To argue over whether it should have been done that way in the first place is basically peeing into the wind. It is what it is, and so the questions stand. Having looked at the output of dis.dis() on my code, it is obvious that there is a lot of information still in there which could be removed without affecting the behavior of the code. The names of local variables is an obvious place to start. Their original names contain big clues as to their purpose. Names like "key", "count", "validtags" are a lot more useful to someone perusing the code than "foo", "bar", "gronk", or even "_1", "_2", "_3". Randomizing the order of the list of constants would help to reduce one's ability to see patterns in the data. Shuffling the order of instructions, adding in jumps, small amounts of dead code, removing line numbers, all of these techniques could be done such that you could obfuscate the same chunk of code multiple times and get different results each time. Ah well. It would appear that the answer is "no, there aren't any handy code obfuscators out there." Maybe I'll write one, if I get a chance. -- j -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From josh at open.com Tue Oct 17 12:04:40 2000 From: josh at open.com (Joshua Muskovitz) Date: Tue, 17 Oct 2000 12:04:40 -0400 Subject: Timeout for UDP receive References: <8shm3g$u41$1@news.umbc.edu> Message-ID: <39ec76f9_1@corp.newsfeeds.com> Try this: readyToRead = select.select([server], [], [], timeout_period)[0] if readyToRead: pkt, who = server.recvfrom(BUFSIZE) It works great in my code... -- josh -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From aahz at panix.com Tue Oct 3 11:06:31 2000 From: aahz at panix.com (Aahz Maruch) Date: 3 Oct 2000 08:06:31 -0700 Subject: Global Module Index References: Message-ID: <8rcsln$3ip$1@panix3.panix.com> In article , Dale Strickland-Clark wrote: > >Is it me, or has the Global Module Index vanished in 1.6? Why do you care? Why aren't you waiting for 2.0? ;-) -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 There's a difference between a person who gets shit zie doesn't deserve and a person who gets more shit than zie deserves. --Aahz From nospam at nospam.com Thu Oct 26 14:07:10 2000 From: nospam at nospam.com (Tom) Date: Thu, 26 Oct 2000 18:07:10 GMT Subject: Do any debuggers work with Python threads? References: Message-ID: Here's a little Trace utility that I use for debugging multi-threaded python apps. I've only used it on Win32 - you'll need to compile it yourself. To use it I put the following code at the beginning of a Python application's main module: from Trace import *; TraceOn( 'x:\\logs\\ServerTrace.txt' ); // specify no parameter for stdout. Time = time.localtime( time.time() ); Trace( 'MyApp.py, ' + time.strftime( "%a at %I:%M%p.", Time ) ); It indents comments according to the current stack depth (this make sense to me). If you would like, I could change it so that each Python thread (each tstate) gets to specify its own output file. Tom. > wrote in message > news:mailman.972341522.15869.python-list at python.org... > > Is there any way I can use any of the Python debuggers with Python > > applications that are multi-threaded using the 'threading' module? > > > > I'm talking about a pure Python app at the moment. I don't need to > > worry about debugging external C modules. > > > > I've tried IDLE, Wing & pdb to no avail. The developers of Wing say > > they plan to implement it in the next major version, but that's months > > away. > > > > I'm mainly working under Linux, but do occasional work in Windows. > > > > Other than putting print statements everywhere, do I have any other > > option? > > > > > > From aleaxit at yahoo.com Sat Oct 28 06:32:39 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 28 Oct 2000 12:32:39 +0200 Subject: Window extension question References: <39fa93df$0$4491$73bec57d@news.be.uu.net> Message-ID: <8tea680f2f@news1.newsguy.com> "Olivier Paquay" wrote in message news:39fa93df$0$4491$73bec57d at news.be.uu.net... > Hi, > > I am trying to make a Windows DLL extension. The main C file was generated > with SWIG. Everything compiles fine but i have a link problem > > Linking... > ..\..\Python16\libs\python16.lib : fatal error LNK1106: invalid file or disk > full: cannot seek to 0x39b65ad1 > Error executing link.exe. > > I get this message under DevStudio. I tried compiling with a Makefile in the > way described in the Python Doc but i get the same message. Looks like your python16.lib is damaged ("invalid file", as the message says -- "disk full" seems unlikely to cause this). Try uninstalling Python 1.6, download and install 2.0, and rebuild all of your extension, then it should work. Alex From emile at fenx.com Sun Oct 8 11:26:15 2000 From: emile at fenx.com (Emile van Sebille) Date: Sun, 8 Oct 2000 08:26:15 -0700 Subject: Is this a dream or a nightmare? (Was Re: XML) References: <39d1d3b2.43465571@news.telus.net> <39D19EBB.ABF18F23@engcorp.com> <39def2ae.8929692@news.davesworld.net> <8ro52a0q1o@news1.newsguy.com> <39dfa617.25953118@news.davesworld.net> <39dfe6db.42535595@news.davesworld.net> Message-ID: <8rq496$ik0l1$1@ID-11957.news.cis.dfn.de> "David T. Grove" wrote in message news:39dfe6db.42535595 at news.davesworld.net... > Said that wrong too. Sorry... lack of sleep. I mean, I lumped several > languages together. VB and C with Python (which wasn't any kind of jab > at the Python language), and separated out C++ as an extreme. There > are actually studies done on this if you are really interested in line > counts. Look them up. > > --- > > So, it appears then that my concern in moving to Python is less one of > off-by-one slices, and more of slowing down my train of thought to > come closer to the computer's way of thinking than my own. Of course, > it's only one step away from Perl, and doesn't slow me down to a crawl > as VB or C would, and doesn't use nearly as much fluff as C++. It will > just take a bit of getting used to, sort of like moving from upper > long island to the virginia coast (as opposed to moving to the > Tennessee hills). One recent study that many of this group participated in shows that python uses less lines of code than the other languages. http://wwwipd.ira.uka.de/~prechelt/Biblio/jccpprtTR.pdf Perhaps there are counter example studies you could point us to? After-you-learn-to-walk-you-learn-to-run-ly y'rs, -- Emile van Sebille emile at fenx.com ------------------- From aahz at panix.com Thu Oct 12 15:45:28 2000 From: aahz at panix.com (Aahz Maruch) Date: 12 Oct 2000 12:45:28 -0700 Subject: Programmer-Wanna-Be (Is Python for me?) References: <8s2354$ep2$1@nnrp1.deja.com> Message-ID: <8s54co$ar4$1@panix6.panix.com> In article , Niklas Frykholm wrote: > >BUT, if what you want to do is create Windows shareware or something >similar, Python has, in my view, two clear disadvantages > >* NO CANONIZED GUI > >If you want to make a GUI with Python you have to use an add-on product >such as Tk or wxPyhton, which means you have to install and learn >one of these packages as well as Python. And while I wouldn't go so >far as to call them un-pythonic, they are not completely pythonic >either... so you need to learn to think a little differently. Huh? Tk comes standard with the Python Windoze distribution and has at least since 1.5.2. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Isn't it interesting that the same people who laugh at science fiction listen to weather forecasts and economists?" -- Kelvin Throop III From costas at malamas.com Tue Oct 10 13:17:32 2000 From: costas at malamas.com (Costas Malamas) Date: Tue, 10 Oct 2000 13:17:32 -0400 Subject: Overwriting 'self' in constructor? References: Message-ID: <000c01c032dd$fb644e70$5a01020a@retek.com> Thanks for the input, but I was aiming for something else: > On Tue, 10 Oct 2000, Costas Malamas wrote: > > I am trying to extend a class that produces an object in two steps: the > > constructor produces a factory object and then there is a method that > > returns the object I really want, i.e.: A.make(). Now, I want to extend > > A, but I'd like to get the second type of object from the constructor. > > Python (1.52, 1.6, Win32) won't let me do this: > > > > class B(A): > > def __init__(self): > > A.__init__(self) > > self = A.make(self) > > i think python will let you do that, it just just doesn't do what you > want it to. :) > > > The product of this is _always_ 'self' as defined by A.__init__() Why? > > Can I/Should I work around it? > > Why it happens: > > Because even though self starts out as a reference to the object > you're working with, when you say self=ANYTHING it stops referencing > the first object and starts referencing something else. Python doesn't > look inside your method for anything that happens to be named "self", > it just looks at the original object. You can do anything you want TO > the object, but you can't replace it with another object altogether. So, could I copy the structure of another object onto it somehow? > How to deal with it: > > Usually, when talking about a factory you should have at least 3 > classes... "A", "B", and "Factory"... Factory returns one or the > other.. Perhaps something like this: > > class Factory: > defaultClass = A > def make(someClass=None): > what = someClass or defaultClass > return what() > > >>> f = Factory() > >>> f.make(A) > > > Is that what you want? Unfortunately, no; for my own reasons, I want to change the behavior of class A, so as to make the two step process an one-step deal. I don't mind even if I didn't extend A but I basically want to do this: z = B(), not z = F.make(B) I guess I am being pedantic here... Thanks again, Costas From josh at open.com Thu Oct 12 11:17:57 2000 From: josh at open.com (Joshua Muskovitz) Date: Thu, 12 Oct 2000 11:17:57 -0400 Subject: Python Guru Available For Contract Work References: Message-ID: <39e5d48a_3@corp.newsfeeds.com> Sounds like it's time to create comp.lang.python.binaries..., but I think some people will be surprised what shows up there. -- josh, whose penis can assume the shape of any of the platonic solids, and also does a fair impression of the Utah Teapot. -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From stephenk at cc.gatech.edu Tue Oct 17 22:23:27 2000 From: stephenk at cc.gatech.edu (Stephen Kloder) Date: Tue, 17 Oct 2000 22:23:27 -0400 Subject: String adding. References: <39ECFA3F.26B87754@uoguelph.ca> Message-ID: <39ED099F.1B3DB0F8@cc.gatech.edu> Mark Cunningham wrote: > i know doing: > > strName = 'wow' > '<' + strName + '>' > > will give you > > but what about: > > intName = 3 > print '<' + intName + '>' > this gives me some illegal argument type for built-in operation.. > how would i make it give me <3>???? >>> intName=3 >>> print '<' + `intName` + '>' # (Those are back-ticks, not quotes) <3> BTW `x` is the same as repr(x) -- Stephen Kloder | "I say what it occurs to me to say. stephenk at cc.gatech.edu | More I cannot say." Phone 404-874-6584 | -- The Man in the Shack ICQ #65153895 | be :- think. From pearu at ioc.ee Wed Oct 11 05:53:35 2000 From: pearu at ioc.ee (Pearu Peterson) Date: Wed, 11 Oct 2000 11:53:35 +0200 Subject: ANNOUNCE: PySymbolic - Doing Symbolics in Python References: <8s18gk$mqb$1@news.tpi.pl> Message-ID: <39E4389F.1E7F243F@ioc.ee> "Tomek Lisowski (TPK)" wrote: > > Current features include basic simplifications: > > *** cancellations: 0*a -> 0, a+0 -> 0, > > It should be: a+0 -> a, right? You are absolutely right. > > *** expanding integer powers: (a+b)**n -> a**n+a**(n-1)*b+... > > It should be: (a+b)**n -> a**n + n*a**(n-1)*b + ... You are right again;) > > You seem to have forgotten about the Newton symbols in the power expansion > The package process my mistakes correctly, however. Thanks, Pearu From mpaindav at arinc.com Tue Oct 31 17:31:47 2000 From: mpaindav at arinc.com (mpaindav at arinc.com) Date: Tue, 31 Oct 2000 22:31:47 -0000 Subject: newbie puzzled with thread Message-ID: <8tnh8j+86iu@eGroups.com> I am compiling a source that has "import thread" in it.... and it compile on one box but not on the other. However, on both machine, there is no thread.py, just a thread.h. (I have python 1.5.2 on both) Where is the catch? Does it has to do with setting the sys.path? Thanks for any suggestion. Matthieu From fredrik at effbot.org Mon Oct 30 02:29:34 2000 From: fredrik at effbot.org (Fredrik Lundh) Date: Mon, 30 Oct 2000 07:29:34 GMT Subject: Shall we declare Tkinter dead? No-one seems interested in it ;o) References: Message-ID: Mike Fletcher wrote: > Third time for this question, still no (as in nada, zip, zero, zilch) > responses. it's the first time I see your question. where did you send it? > I'm beginning to suspect that, like me, everyone has already > moved to wxPython :o) . really? > Can anyone tell me what event to bind in a Tkinter system that says "the > root window has been closed", or, more precisely, "it's safe to shut down > the mainloop now"? install a DELETE_WINDOW handler: root.protocol("WM_DELETE_WINDOW", callback) for more info, see: http://www.pythonware.com/library/tkinter/introduction/events-and-bindings.htm From trentm at ActiveState.com Thu Oct 26 11:43:14 2000 From: trentm at ActiveState.com (Trent Mick) Date: Thu, 26 Oct 2000 08:43:14 -0700 Subject: dynamically loaded modules (.so files) does not work under openbsd In-Reply-To: <39f791a1.1bcb7@nancy.pacific.net.au>; from kiyolee*remove*@ctimail.com on Thu, Oct 26, 2000 at 01:05:55PM +1100 References: <39f791a1.1bcb7@nancy.pacific.net.au> Message-ID: <20001026084314.B16027@ActiveState.com> On Thu, Oct 26, 2000 at 01:05:55PM +1100, Kiyo Kelvin Lee wrote: > Under OpenBSD, I can't make dynamically loaded modules work. > Python responsed with "ImportError: dynamic modules does not define init > function (initXYZ)" upon import XYZ. > Any ideas? > Kiyo I haven't looked at it and I can't really because I don't have access to a BSD box but $10 that the problem with the flags that Python configure script chooses to use for compiling and linking the .so's. They are probably setup to work for a typical Linux setup with the presumption that the same choices would work on BSD. Or actually, looking at the configure script I see: case $ac_sys_system/$ac_sys_release in AIX*) LDSHARED="\$(srcdir)/ld_so_aix \$(CC)";; BeOS*) LDSHARED="\$(srcdir)/../BeOS/linkmodule -L.. -lpython\$(VERSION)";; IRIX/5*) LDSHARED="ld -shared";; IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";; SunOS/4*) LDSHARED="ld";; SunOS/5*) if test "$GCC" = "yes" then LDSHARED='$(CC) -G' else LDSHARED="ld -G"; fi ;; hp*|HP*) LDSHARED="ld -b";; OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";; DYNIX/ptx*) LDSHARED="ld -G";; Darwin/*|next/*) if test "$ns_dyld" then if test "$ac_sys_system" = Darwin then LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined suppress' else LDSHARED='$(CC) $(LDFLAGS) -bundle -prebind' fi else LDSHARED='$(CC) $(CFLAGS) -nostdlib -r'; fi if test "$with_next_framework" ; then LDSHARED="$LDSHARED \$(LDLIBRARY)" fi ;; Linux*) LDSHARED="gcc -shared";; dgux*) LDSHARED="ld -G";; BSD/OS*/4*) LDSHARED="gcc -shared";; OpenBSD*) LDSHARED="ld -Bshareable";; NetBSD*) if [ "`$CC -dM -E - Message-ID: <8rrks8$a1a$1@panix3.panix.com> In article , Erno Kuusela wrote: >>>>>> "William" == William Park writes: > > | How do I take advantage of a SMP (2 CPU) machine? > >use separate processes. Why? Why not use threads? -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "[I have a] windmill fetish." --Darkhawk From robin at alldunn.com Wed Oct 25 14:14:03 2000 From: robin at alldunn.com (Robin Dunn) Date: Wed, 25 Oct 2000 18:14:03 GMT Subject: Where is wxPython? References: <39E33757.E9F81F9C@cicei.ulpgc.es> <8t216i$dvu$1@nnrp1.deja.com> <8t54hu$hl$1@nnrp1.deja.com> Message-ID: <8t77t1$ndf$1@nnrp1.deja.com> In article , Paul Moore wrote: > > Fiddling in the registry is even worse... > I agree. > Actually, I believe that you should be able to put the DLL in the same > directory as the DLL which uses it (ie, the wxPython PYD file). I've > done this with other modules and it seems to work. > > Basically, Python itself loads DLLs (PYDs) from explicit directories > in sys.path. If these DLLs load other DLLs, I believe that the search > path includes the directory in which the loading DLL is located, > rather than the directory in which the original EXE is located. The > Windows documentation seems to imply otherwise - all I can say is that > it seems to work. I'm sure I tried that before and it didn't work... But it *is* working for me now with both 1.5.2 and 2.0. Perhaps it is a win2k thing, which version of windows are you running? -- Robin Dunn Software Craftsman robin at AllDunn.com http://wxPython.org Java give you jitters? http://wxPROs.com Relax with wxPython! Sent via Deja.com http://www.deja.com/ Before you buy. From claird at starbase.neosoft.com Fri Oct 13 11:30:41 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 13 Oct 2000 10:30:41 -0500 Subject: Problem installing the python-ldap mod References: <971428378.905163@proxy.bos.nl> Message-ID: <1AD6C8455D51E042.DE5D85F05D6AE814.25AF4B95C93C92BB@lp.airnews.net> In article <971428378.905163 at proxy.bos.nl>, Xander van Es wrote: ># make >cd Modules && make srcdir=/home/xander/python-ldap-1.10alpha3/Modules . . . >ld -G LDAPObject.o common.o constants.o errors.o functions.o ldapmodule.o >message.o version.o linkedlist.o template.o >CIDict.o -L/tmp/ldap-pfx/lib -lldap -llber -lsocket -lnsl -lm -lkrb -o >_ldapmodule.so >ld: fatal: library -lldap: not found >ld: fatal: library -llber: not found . . . Python-LDAP assumes the prior installation of a standard LDAP software development kit (SDK) (as the README mentions). Do you need one, or do you need help in con- figuration so Python-LDAP finds one you already have? -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From Michael.Burns at sas.com Wed Oct 25 14:43:08 2000 From: Michael.Burns at sas.com (Michael Burns) Date: Wed, 25 Oct 2000 13:43:08 -0500 Subject: problems with Linking and loading extensions to Python Message-ID: <20001025184308.E95191CE94@dinsdale.python.org> Thanks a whole bunch! The '-bundle -undefined warning' did the trick. Now it no longer complains about the filetype, just one problem remaining (so far) and that is an unresolved reference to either dyld_stub_binding_helper or __mh_dylib_header If I remove dylib1.o from my ld command the undefined for __mh_dylib_header goes away and I get the undefined for dyld_stub_binding_helper. The dyld_stub_binding_helper references is coming from a .o file compiled this way: % cc -O2 -DXML_ERRORS -DFOR_LT -I/usr/local/include/python2.0 -I. -I/usr/local/include/ltxml12 -c NSLintermodule.c -o NSLintermodule8.o % nm NSLintermodule8.o | grep dyld_stub_binding_helper U dyld_stub_binding_helper There is no mention of this symbol in the .c source or even in the .i file. I cannot figure out where this reference is coming from or how it is supposed to be satisfied. I cannot find mention of it in the man pages for ld, cc, libtool, dyld. otool says there are 75 references to this symbol: Relocation information (__DATA,__la_symbol_ptr) 75 entries address pcrel length extern type scattered symbolnum/value 00000128 False long True VANILLA False dyld_stub_binding_helper 00000124 False long True VANILLA False dyld_stub_binding_helper ... My experience with dynamic loading is on AIX, and it does not help much here. Any help you can add would be much appreciated. Here is my command: /usr/bin/ld \ -bundle -undefined warning \ -arch ppc -o XMLintermodule8.so -L/usr/local/lib \ NSLintermodule8.o alloc.o block_alloc.o hash.o \ -lltapi12 -lltstd12 \ -framework System On Tuesday, October 24, 2000, at 11:49 PM, Steven D. Majewski wrote: > > On Tue, 24 Oct 2000, Michael Burns wrote: > > > What is the right combinations of ld options to use? > > Anybody have > any examples that work for them? > > > Background: > > I am trying to get > an extension to Python to link and load on Mac OS X public beta. > > > I > have tried many combinations of ld options like -dyld, -bundle, -dylinker, > -fvmlib, > > -preload > > > Some of them give me unresolved references or > other ld complaints. > > Are you using Python 2.0 ? > > Take a look at the switches the python2.0/Modules/Makefile uses for > building shared libraries: "-bundle -undefined suppress" > > I used the following command to link the python gtk module: > > cc -bundle -undefined warning gtkmodule.o -L/usr/local/lib > -L/usr/X11R6/lib -lgtk -lgdk -lgmodule -lgthread -lglib -lXext -lX11 > .libs/lib_gtkmodule.a -o _gtkmodule.so > > > ---| Steven D. Majewski (804-982-0831) |--- > ---| Department of Molecular Physiology and Biological Physics |--- > ---| University of Virginia Health Sciences Center |--- > ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- > "All operating systems want to be unix, > All programming languages want to be lisp." > > > -- > http://www.python.org/mailman/listinfo/python-list > > ------------------------------------------------------------------------ Michael Burns email: Michael.Burns at sas.com Principal Systems Developer home: mburns at bga.com Metadata Integration Technology voice: (512)258-5171x3264 SAS Institute, Inc. fax: (512)258-3906 11920 Wilson Parke Ave. www: http://www.realtime.net/~mburns Austin, TX 78726-4052 sww: http://sww.sas.com/~sasmkb "choose for yourselves today whom you will serve;... but as for me and my house, we will serve the Lord." Joshua 24:15 From sholden at holdenweb.com Mon Oct 23 14:22:28 2000 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 23 Oct 2000 14:22:28 -0400 Subject: ANY NEWS ON THE STARSHIP? References: <8su1su$euq$1@nnrp1.deja.com> <39F47496.22449099@holdenweb.com> <8t1ur1$8jt$1@panix3.panix.com> Message-ID: <39F481E4.989093B6@holdenweb.com> Aahz Maruch wrote: > ... > > I think that the Starship is being hosted by PythonLabs these days; it's > understandable, I think, if their first priority is getting the main > site up. Seems sensible. Moving away from CNRI's DNS server might seem to be a good first step, given its recalcitrance. Or are there trade mark issues there too? Longer term, mirroring is going to be essential if Python is to dominate the world effectively. It certainly would have helped in the current situation. regards Steve -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ From jwbnews at scandaroon.com Sun Oct 15 15:19:29 2000 From: jwbnews at scandaroon.com (John W. Baxter) Date: Sun, 15 Oct 2000 12:19:29 -0700 Subject: 2.0c1 Tutorial 3.1.3 unicode example problem Message-ID: The example near the start of the 2.0c1 Tutorial (as downloaded to here) appears flawed: The small "u" in front of the quote indicates that an Unicode string is supposed to be created. If you want to include special characters in the string, you can do so by using the Python Unicode-Escape encoding. The following example shows how: >>> u'Hello\\u0020World !' u'Hello World !' In fact, the result of doing that (both on Linux (RH 6.2) and on Mac (Jack's Python 2.0c1 distribution) is: >>> u'Hello\\u0020World !' u'Hello\\u0020World !' While a single \ works as described for the \\: >>> u'Hello\u0020World !' u'Hello World !' My guess is the problem is in the tutorial, not in Python. --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From smoriano at sicon.net Thu Oct 19 09:45:40 2000 From: smoriano at sicon.net (Sergio Boix Moriano) Date: Thu, 19 Oct 2000 15:45:40 +0200 Subject: WRITING FILES Message-ID: <39EEFB04.AF25E654@sicon.net> Hi all, I want to make a procedure to append lines to a file, in the position i want. I've tried to do this opening the file in mode "r+", but if i do this, it writes in the document from a position x, but overwritting the text that is in the document. If i open de document with (a+) it writes always at the end of the document. What i'm doing bad? From debl.spamnonon.nospam at world.std.com Tue Oct 3 00:40:01 2000 From: debl.spamnonon.nospam at world.std.com (David Lees) Date: Tue, 03 Oct 2000 04:40:01 GMT Subject: Debugging Python -Newbie? Message-ID: <39D9631B.A209BA56@world.std.com> I am looking for an elementary introduction (cookbook) to debugging Python code with either PythonWin or IDLE. I am playing with the classic recursive factorial example in PythonWin and somehow am not able to single step through, even though I see the step functions (F11 and F10). A pointer to step by step instructions on debugging/debuggers would be great. Thanks in advance. David Lees From ryzam at tm.net.my Mon Oct 16 13:37:56 2000 From: ryzam at tm.net.my (irwan) Date: Tue, 17 Oct 2000 01:37:56 +0800 Subject: Error to compile example_nt in the Python source code Message-ID: <003401c03797$d19a17a0$9d10bcca@telekom.com.my> Hi All, I'm a newbie .I have download source code for python Be-Open Python-2.0.tar.gz and try to compile example_nt which is in Pc directory. I follow the instructions where need me to move it up to one level. i get an error when build example.dll I'm using python 98 with python2.0 final --------------------Configuration: example - Win32 Release-------------------- Compiling... example.c ..\Include\pyport.h(252) : warning C4273: 'hypot' : inconsistent dll linkage. dllexport assumed. ..\Include\pyport.h(372) : fatal error C1189: #error : "could not set LONG_MAX in pyport.h" Error executing cl.exe. example.dll - 1 error(s), 1 warning(s) -------------- next part -------------- An HTML attachment was scrubbed... URL: From hakan at netg.se Wed Oct 4 15:56:45 2000 From: hakan at netg.se (Hakan Nilsson) Date: Wed, 4 Oct 2000 21:56:45 +0200 Subject: Substring Detection? Pythonically? In-Reply-To: <20001004.123529.97857@Jeremy.cerebralmaelstrom.com> References: <20001004.123529.97857@Jeremy.cerebralmaelstrom.com> Message-ID: I would use filter to do this, together with string.find With your example filter(lambda s: not string.find(s, 'th'), list) Seems to be fast, although I'm not sure what is fast enough for you. ;o) /Hakan On Wed, 4 Oct 2000, Stephen Hansen wrote: > Okay, say I have three different strings: > #1: they > #2: that > #3: tommy > > And a user gives me a string -- 'the', I want it to match to 'they'. Then > say they give me a string, 'to', I want it to match to 'tommy'. A string > of 'th' or 't' is ambiguious, and i want a list returned, ['they','that'] > and ['they','that','tommy'] respectively. > > What's the best way to do that? The onyl way I can think if is a massive > nested switch(if-elif), basically, since the 'words' i'm testing for will > be somewhat predefined. Another idea that just popped into my head was to > use mxTextTools instead of the nested-case, it'd do the same thing but it > seems like it'd be faster since Python isn't having to run through and > parse itself. Not sure tho :) > > Note that my 'words' will end up being a rather big list, mebbe a hundred > at least, and i'll be checking against it very frequently, so want this to > be as efficient as possible. > > --S > -- > http://www.python.org/mailman/listinfo/python-list > - Hi! I'm a .signature virus! Copy me into your .signature file to help me spread! From martinw at lenti.med.umn.edu Mon Oct 16 13:49:04 2000 From: martinw at lenti.med.umn.edu (Martin Wessendorf) Date: Mon, 16 Oct 2000 12:49:04 -0500 Subject: Newbie Mac question re: Tkinter References: <39EB30B5.52BF@lenti.med.umn.edu> Message-ID: <39EB3F90.6231@lenti.med.umn.edu> Martin Wessendorf wrote: > > Hello all-- > > I've just started trying to learn Python and have installed 1.5.2 on my > Mac 6100 under system 7.5 (...I always try to be at the cutting > edge...). The "Vise" installer claimed that it was installing Tk along > with Python, and at the completion of the installation its window stated > that the installation had been successful. However, when I tried > running some of the Tk demo's I got an error message in the Python > interpreter window stating that the Tkinter module couldn't be found. --I think I just answered my own question by finding the page: http://schockwellenreiter.editthispage.com/python/tkinterenglish.html --Martin From thomas at xs4all.net Sun Oct 29 16:57:21 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 29 Oct 2000 22:57:21 +0100 Subject: Cross Platform Locking: THe Easy Way In-Reply-To: ; from moshez@math.huji.ac.il on Sun, Oct 29, 2000 at 11:34:19PM +0200 References: Message-ID: <20001029225720.A12812@xs4all.nl> [ Long thread about cross-platform locking, most of which I missed ] Not sure if this has been mentioned yet, because I missed most of this thread, but Mailman (2.0 / CVS) does a good job at attempting cross-platform locking that works over NFS. I know, I reworked it, after which Barry took it and reworked it even better ;) It's also quite usable outside of Mailman, Barry went through some trouble to put Mailman specific imports in a try/except. You might want to adjust the logging, if you want to enable that, but that's about it. (The locking mechanism used by Mailman is that which was proposed in a few revisions of the 'open(2)' manpage on Linux, some revisions of the QMail documentation (I believe), probably a ton of other places, and is in heavy use at, for instance, XS4ALL, to do locking over NFS.) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From kirschh at lionbioscience.com Tue Oct 10 05:03:29 2000 From: kirschh at lionbioscience.com (Harald Kirsch) Date: 10 Oct 2000 11:03:29 +0200 Subject: path of execfile'd script Message-ID: I use execfile() to run a piece of python code. Is it is possible within this code to get hold of the file in which it is? (I use execfile() instead of import because the file to be executed is given as a command line argument to a python script.) Harald Kirsch -- ----------------+------------------------------------------------------ Harald Kirsch | kirschh at lionbioscience.com | "How old is the epsilon?" LION Bioscience | +49 6221 4038 172 | -- Paul Erd?s From dale at out-think.NOSPAMco.uk Wed Oct 25 10:08:36 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Wed, 25 Oct 2000 15:08:36 +0100 Subject: Pretty report printing Message-ID: I need to produce a bunch of standard reports from a database and am considering Python. The reports need to be pretty but probably text only (although borders and boxes would be nice). They should be previewable online and printable to any Windows printer. I like the idea of using HTML but it doesn't understand the printed page so headings, headers and footers are trickey. Other options include PDF (which I'd have to research cos I know nothing about it) and driving Word or Excel through COM to build pages - which isn't an attractive thought. How have others tackled this problem? Thanks Dale Strickland-Clark Out-Think Ltd Business Technology Consultants From paul.moore at uk.origin-it.com Tue Oct 24 05:05:25 2000 From: paul.moore at uk.origin-it.com (Paul Moore) Date: Tue, 24 Oct 2000 11:05:25 +0200 Subject: Where is wxPython? References: <39E33757.E9F81F9C@cicei.ulpgc.es> <8t216i$dvu$1@nnrp1.deja.com> Message-ID: On Mon, 23 Oct 2000 20:48:53 +0200, Robin Dunn wrote: >> Is there a Python 2.0 (release) compatible version? Will the 2.0b1 >> version work? I'll download and try it, but I don't know what form a >> failure would take... > >Yes, it works, (at least as far as the bit of testing I did.) I'm >working on getting a 2.2.2 release done now, with binaries for both >1.5.2 and 2.0. It's almost ready to go but I'm fighting some dynamic >linking problems on Linux with the Python 2.0 version... I hope to have >it worked out in the next day or two. That's good news. I tried the 2.0b1 version, and it seemed OK, but one of the demos (sorry, can't remember which one, and it's on the other PC...) crashed. Whether that's a version incompatibility problem, I couldn't say... I'll wait for the new release, and try again. Paul. PS The 2.0b1 version installed some DLLs in my WINNT\SYSTEM32 directory. The uninstall removed them OK, but on general principle, I prefer applications which don't do this. Is there no way these DLLs can be installed with the wxPython module? From quinn at bolivar.ugcs.caltech.edu Sat Oct 28 17:13:04 2000 From: quinn at bolivar.ugcs.caltech.edu (Quinn Dunkan) Date: 28 Oct 2000 21:13:04 GMT Subject: Python scoping References: <8tab8k024o3@news1.newsguy.com> <8tbkfk0kn8@news1.newsguy.com> Message-ID: On Fri, 27 Oct 2000 12:07:25 +0200, Alex Martelli wrote: >"Quinn Dunkan" wrote in message >news:slrn8vi15h.j5e.quinn at pfennig.ugcs.caltech.edu... > [snip] >> > Foo: BEGIN >> > /* whatever */ >> > END Foo; >> >> Same for dylan, although it's optional there too: >> >> define me a new generic method called foo(x is an type please) >> .. >> end define me a new generic method called foo(x is an type >please); > >Terminology question: isn't it "generic function" (with "method" being >a concrete implementation of a g.f. for certain argument types)? My >knowledge of Dylan is limited (the "Dylan Programming" book and little >more) and I'd like to ensure I have understood its terms & architecture... >thanks! Yeah, it's part of the new experimental dylan spec. There was a lot of debate about whether the new "define me a new ..." form was really preferable to plain "define", especially given grammatical concerns, but some guy at FunOb really liked it, so it stayed. As far as what a generic method is, you'll have to wait until the spec is finalized. It's used in the new (rather complicated) 'fuzzy specialization' concept and involves the 'please', 'maybe', and 'sorta' keywords. Don't worry about it, it'll be a long time before a working compiler for the new spec comes out. From uwe at chromasphere.com Thu Oct 5 11:48:01 2000 From: uwe at chromasphere.com (Uwe Ilgenstein) Date: Thu, 05 Oct 2000 17:48:01 +0200 Subject: How to extend the interpreter? Message-ID: <39DCA2B1.59B1BECA@chromasphere.com> Hi, Can somebody out there give me a hint how to modify the Python language itself? I tried extending the grammar and running the parser generator. Now the parser understands the extension but the compiler complains: "SystemError: com_node: unexpected node type" I know that there has to be done something more than just extending/modifying the grammar but I don't know how to do this. Maybe someone can help... Thanks, Uwe. From tyler at tylereaves.com Sun Oct 29 20:48:43 2000 From: tyler at tylereaves.com (Tyler Eaves) Date: Sun, 29 Oct 2000 20:48:43 -0500 Subject: import x as y References: Message-ID: <6qkpvsgtetij5s9cu4hb40v0jnln63pmvv@4ax.com> Just wondering, as a python 'advanced' novice, is there any advantage of: import x as y ratheer than import x y=x ? Or is it just the elimination of the extra line? --- Tyler Eaves Visit Ultra Coaster Central! The internet's largest repository of Ultra Coaster Tracks! http://www.ultracoastercentral.com -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From frneh at yahoo.com Thu Oct 5 08:07:15 2000 From: frneh at yahoo.com (Fredrik Nehr) Date: Thu, 5 Oct 2000 14:07:15 +0200 Subject: Possible bug in sgmllib? Message-ID: <8rhqds$90b$1@newstoo.ericsson.se> The start_ and do_ methods does't get called with the correct name when tag contains a underscore, however the end_ method works as expected. This interactive session shows the possible problem: ActivePython 1.6, build 100 (ActiveState Tool Corp.) based on Python 1.6b1 (#0, Aug 23 2000, 13:42:10) [MSC 32 bit (Intel)] on win32 Copyright (c) Corporation for National Research Initiatives. Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam. >>> import sgmllib >>> class Parser(sgmllib.SGMLParser): ... def __getattr__(self, name): ... print name ... raise AttributeError ... >>> Parser().feed("data") start_foo do_foo end_foo >>> Parser().feed("data") start_foo do_foo end_foo_bar >>> Regards, Fredrik Nehr From loewis at informatik.hu-berlin.de Sun Oct 1 03:57:02 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 01 Oct 2000 09:57:02 +0200 Subject: Wholly unnecessary flame. (was Re: pyXML!) References: <7BD10B680501D411B9DF009027E06F32011BD9@exchange> <39d2d532.43850056@news.telus.net> Message-ID: root at 127.0.0.1 (David) writes: > Why is Visual C/C++ being used? Why not Cygwin or Borland C/C++? The > latter two are both freely available; one of them is, IIRC, even open > source. Many people have attempted to build Python both with Borland C, and cygwin. I believe they all had some kind of problems, and did give up instead of solving them, and producing a Python distribution based on these compilers. Regards, Martin From ats1 at ukc.ac.uk Mon Oct 9 06:52:03 2000 From: ats1 at ukc.ac.uk (Adam Sampson) Date: 09 Oct 2000 11:52:03 +0100 Subject: Why is "while" ticking me off??? References: <39DD15A1.442E5A33@ix.netcom.com> <39DDEC25.CEE0E16A@gssec.bt.co.uk> <39E1254A.B0F55D01@my.signature> Message-ID: <87zokes2wc.fsf@cartman.azz.net> Greg Ewing writes: > Huaiyu Zhu wrote: > > > > if a = dict1[k1]; a: > > a.do_something_interesting() > > I don't like that as it stands; it's too hard to read. > > It could perhaps be improved: > > if a where a = dict1[k1]: > a.do_something_interesting() > > except that then the evaluation order is different > from the reading order. How about adding a "set to" operator? if a := dict[k1]: a.something() Hmmm. -- Adam Sampson azz at gnu.org From jurgen.defurne at philips.com Wed Oct 11 09:27:19 2000 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Wed, 11 Oct 2000 15:27:19 +0200 Subject: Request for Python Source Code Message-ID: <0056900012809227000002L072*@MHS> gcc indeed issues warnings when interchanging pointers and ints. However, I have at home Zortech C/C++ (long time not used), and I recall that I only got messages concerning pointers vs. ints when I was compiling programs which used other size pointers than the size of an int (medium, compact or large programs). It didn't warn about the types, but about the sizes. So, in older compilers I suppose that there is no warning issued for pointers vs. ints. Jurgen hei at adtranzsig.de@SMTP at python.org on 11/10/2000 12:05:48 Sent by: python-list-admin at python.org To: python-list at python.org@SMTP cc: Subject: Re: Request for Python Source Code Classification: "Dave Brueck" schrieb im Newsbeitrag news:mailman.971190983.20602.python-list at python.org... > >I suppose (this is just an assumption) that Simoney invented it > >in the 70ies when writing assembler code. There, it might make sense > >to prefix a name of a variable with a type prefix. > >It doesn't make much sense from C upwards. > > Really? It's probably _most_ useful in a language like C where the > programmer is allowed to abuse data types at will, sometimes without so much > as a warning from the compiler. Because it's largely the programmer's > responsibility to keep track of whether something is an int or a pointer, > for example, having that information contained in the variable name can be > pretty handy. Funny. The compilers i use can distinguish between an int and a pointer. You're sure we talk about the same language? -- Dipl.Inform. Dirk-Ulrich Heise hei at adtranzsig.de dheise at debitel.net -- http://www.python.org/mailman/listinfo/python-list From jtm63 at shell-1.enteract.com Fri Oct 6 19:07:35 2000 From: jtm63 at shell-1.enteract.com (James_McNaughton) Date: 06 Oct 2000 18:07:35 -0500 Subject: win32net without NetAddUse method References: <1ANC5.5044$Uc.516357@juliett.dax.net> <39de16c7.5905331@nntp.gov.bc.ca> Message-ID: kelly.kranabetter at gems6.gov.bc.ca (KellyK) writes: > > I noticed in your previous message you said you were using an old > version of Pythonwin. You should probably upgrade to the latest > version (132 for Python 1.5.2) at: > > http://www.activestate.com/Products/ActivePython/win32all.html > > I use this version and successsfully use the functions you are trying > to use. Thanks. I thought there was something funny when I downloaded win32all from www.python.org and it was the same version as before. What's up with that site, anyway. There was no indication of how or where to get the latest Win32 python that I could find. I just assumed that was the definitive source of python info -- my have things changed since I last installed python. Now I have to wait until Monday to try it out since everyone who knows the admin password has gone home already. I think I'll go home too. Jim From jay.krell at cornell.edu Wed Oct 11 08:39:57 2000 From: jay.krell at cornell.edu (jay.krell at cornell.edu) Date: Wed, 11 Oct 2000 05:39:57 -0700 Subject: super - is (should) it (be) a reserved word? Message-ID: <009c01c03380$5f4ee3d0$6700a8c0@jayk3> Sorry, no, that doesn't work. Python is too dynamic. class Food: def Print(self): print("Food") class Dessert(Food): super = Food def Print(self): self.super.Print(self) print("Dessert") class Pie(Dessert): super = Dessert def Print(self): self.super.Print(self) print("Pie") Pie().Print(); recurses infinitely. You were just lucky to try with only two levels of inheritance. If you replace all occurences of super with __super, it works, because Python has private, kind of, I guess. - Jay -----Original Message----- From: Alan Gauld Newsgroups: comp.lang.python To: python-list at python.org Date: Wednesday, October 11, 2000 3:26 AM Subject: Re: super - is (should) it (be) a reserved word? >Grant Edwards wrote: >> >Wouldn't it be nice if "super" were a reserved word > >OK, Having read the thread so far it looks like no-one >has suggested the C++ trick mentioned by Bjarne Stroustrup >in his 'Design and Evolution' book, so here goes: > >class Foo: > def __init__(self): > self.a = 1 > def doit(self): > print "a = ", self.a > >class Bar(Foo): > super = Foo > def __init__(self,n): > self.super.__init__(self) > self.b = n > def doit(self): > self.super.doit(self) > print "b = ", self.b > >f = Foo() >f.doit() > >b = Bar(5) >b.doit() > > >This is somewhat like using super and has the real maintenance >advantage that if the superclass of Bar is changed you don't >need to edit all the methods. > >Alan G >-- >http://www.python.org/mailman/listinfo/python-list From MarkH at ActiveState.com Fri Oct 13 21:25:32 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Sat, 14 Oct 2000 01:25:32 GMT Subject: Compiling Python on Win32 References: <39E79EDC.3EDE7950@OMIT_THIS.us.ibm.com> Message-ID: "Kevin F. Smith" wrote in message news:39E79EDC.3EDE7950 at OMIT_THIS.us.ibm.com... > Then to add the module that I am trying to add, I used the same > workspace (i.e., pcbuild.dsw), and went to the "python15 files" section > and added the module name (e.g., xmodule.c). Then doing a build of both This is probably the wrong direction. This will result in a new builtin module, which you really dont need. If you _do_ want to go this way, you will need to edit PC\config.c However, you should check out pc\example_nt - this is a sample for a simple extension module. This will create a .pyd (a .dll with a funny extension!), and will not require changes to either the Python source code, or the the project/workspace files. This is almost certainly the direction you should take... > On AIX, using ./configure and make, everything seems to work. But there > must be something simple that I am missing on MS VC++ 5.0. Using ./configure on Unix is equivilent to hand editing the project file and config.c file on Windows. People rarely do this on Windows, as the process I described is much simpler. The process I described is equivilent to creating the module as an external .so on Unix. Mark. From the_brain at mit.edu Sun Oct 29 16:37:11 2000 From: the_brain at mit.edu (Alex) Date: 29 Oct 2000 16:37:11 -0500 Subject: PythonLabs Team Moves to Digital Creations References: <8tfa4l$3ns$1@nnrp1.deja.com> <39fcdbf9.67323218@nntp.interaccess.com> <39FC8BFE.D5E8795@webamused.com> <39FCBE09.E927AB4E@webamused.com> Message-ID: >> It may depend on the complexity of what you're trying to implement, and >> the number of people involved in the implementation. >> >> > > I'm sure it does, but I used to be sure that you couldn't possibly be >productive without a really good debugger. Now I know that in at least >some cases it's not an absolute requirement. I was talking more about regression testing. Alex. -- Speak softly but carry a big carrot. From dalke at acm.org Sun Oct 29 15:55:28 2000 From: dalke at acm.org (Andrew Dalke) Date: Sun, 29 Oct 2000 13:55:28 -0700 Subject: PythonLabs Team Moves to Digital Creations References: <8tdstp$cvp$1@slb6.atl.mindspring.net> <39fbdb7d.67199359@nntp.interaccess.com> Message-ID: <8ti2o1$lid$1@slb6.atl.mindspring.net> Thaddeus L. Olczyk wrote: >>"Andrew Dalke" writes: >> >>> Does this mean Python 3.0 will be coming out soon? :) [...] >I think he meant Python 3000. Nope. I meant 3.0, and purely as a joke refering to the version number bump after the last job change. Andrew dalke at acm.org From moshez at math.huji.ac.il Tue Oct 31 00:47:11 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Tue, 31 Oct 2000 07:47:11 +0200 (IST) Subject: CPython vs. Jython/JPython In-Reply-To: Message-ID: On Tue, 31 Oct 2000, Delaney, Timothy wrote: > The BDFL has spoken :) > > The real question which was posed I guess is "why can't they be maintained > by the same people?" To which the answer would have to be that the CPython > people have a limited amount of time, the two projects require different > areas of expertise, and that the source trees really cannot share > *anything*. Ummmm.....as my last sarcastic answer should have hinted, they are. Barry and Guido have worked in the same company for quite a few years, and IIRC Jim H, when he wrote JPython, worked at CNRI, which was then the Python development center. Barry is a respected CPython developer (for example, he's responsible for a lot of the i18n in Python 2.0). The two "teams", as far as they can be called that, work so close together it hurts . -- Moshe Zadka -- 95855124 http://advogato.org/person/moshez From g2 at seebelow.org Thu Oct 5 16:46:48 2000 From: g2 at seebelow.org (Grant Griffin) Date: Thu, 05 Oct 2000 21:46:48 +0100 Subject: Why is "while" ticking me off??? References: <39DD15A1.442E5A33@ix.netcom.com> Message-ID: <39DCE8B8.3100BE89@seebelow.org> Huaiyu Zhu wrote: ... > if a = dict1[k1]; a: > do something with a > elif a = dict2[k2]; a<0: > do something else with a > elif a = dict3[k3]; a=="asdsdaf": > do something different with a Personally, if I wanted to tinker with Python's syntax, my first choice would be to turn "elif" into "else if". Perhaps there's some parser-related reason this won't work, but I'm always bugged by "elif" because I can never remember whether it's "elif", "elsif", or "elseif". (BTW, if one _had_ to make "else if" into a single keyword wouldn't the last make one make the most sense? But I suppose that Guido thought it was best to follow the poor precedent of C...) python-already-has-more-syntax-than-it-needs--ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From grante at visi.com Tue Oct 31 15:00:25 2000 From: grante at visi.com (Grant Edwards) Date: Tue, 31 Oct 2000 20:00:25 GMT Subject: import x as y References: <8tk7qf$as1$1@panix6.panix.com> Message-ID: In article , Rainer Deyke wrote: >On a related note, I want the following to work: > >l = [0] >def l[0](): > pass Well, it doesn't. Perhaps you can explain a little further _why_ you want that to work and perhaps we can suggest an alternative means to that end. -- Grant Edwards grante Yow! .. Now KEN and BARBIE at are PERMANENTLY ADDICTED to visi.com MIND-ALTERING DRUGS... From loewis at informatik.hu-berlin.de Tue Oct 3 11:52:48 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 03 Oct 2000 17:52:48 +0200 Subject: Number of Python Users References: <8rb8an$jfl$1@nnrp1.deja.com> Message-ID: echuck at mindspring.com writes: > Is there any kind of estimate on the number of Python users? Or even > related numbers, like # of downloads of 1.5.2? I think there has been no attempt to estimate these numbers in a scientific way, yet. The German iX magazing asks its readers once a year what they use in their job and at home (hardware, operating systems, software, ...); this year, they first explicitly asked whether readers use Python. They have not yet published the results. One good estimate is the number of articles posted to comp.lang.python; I believe there is a number of places to get statistics about that. See also http://www.python.org/doc/FAQ.html#2.1 Regards, Martin From rjroy at takingcontrol.com Sat Oct 7 09:24:01 2000 From: rjroy at takingcontrol.com (Robert Roy) Date: Sat, 07 Oct 2000 13:24:01 GMT Subject: restricting import to current package References: <39dcd16c.72134234@news1.on.sympatico.ca> Message-ID: <39df1ae7.146801390@news1.on.sympatico.ca> On Fri, 6 Oct 2000 09:40:08 -0500, "Jeff Kunce" wrote: >> >Is there a way to do something like: >> > from . import mymodule >> >In other words: >> > try to import mymodule from the same package (or directory) as this >module >> > If mymodule is not there, raise ImportError >> > >> import mymodule >> see the tutorial on intrapackage references > >Not really. That will look *first* in the current package, but then will >go merrily down sys.path looking for any other mymodule it can find. > >When you say: > from mypackage import mymodule >python will look for mymodule *exclusively* in mypackage. >I want to do the same thing for the (unspecified) current package. > > --Jeff > Sorry, I misunderstood what you were trying to do. There does not seem to be a simple way to do what you want. You could write your own import handler using the imp module but that may be more effort than it is worth. It might be possible to do something like this though, import os import mymodule if os.path.split(mymodule.__file__)[0] != os.path.split(__file__)[0]: raise ImportError This should work as long as the module is not the __main__ module or the module you are importing is not a builtin (eg cPickle). In those cases there is no __file__ variable defined and you would get an AttributeError. You could always wrap the above in a try statement... And it gets complicated in a hurry lol... Would be nice if there was a __package__ magic variable... Bob From aleaxit at yahoo.com Wed Oct 25 18:08:26 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 26 Oct 2000 00:08:26 +0200 Subject: detecting param type References: Message-ID: <8t7lsj01usg@news2.newsguy.com> "Jason Cunliffe" wrote in message news:sve9sa9p0rot59 at corp.supernews.com... [snip] > def append(self, date=now(), entry='entry', display=0): > s = self.eventdict > # detect if date param is already a string or a datetime object > if type(date) == 'DateTime': ### <<< this is the one I need help > with > date = str(date) > s.append(date, entry) > if display: > self.display() I would simply change the routine to: def append(self, date=now(), entry='entry', display=0): self.eventdict.append(str(date), entry) if display: self.display() It does no harm to call str(date) 'again' even if date is _already_ a string -- in that case it will just be a very fast no-operation, probably faster than checking for specific types! One warning: the default value for the date parameter is computed ONCE -- i.e., the now() function is called just once, when the routine is defined. If that is not what you desire, you must take a slightly different tack: def append(self, date=None, entry='entry', display=0): if not date: date = now() self.eventdict.append(str(date), entry) if display: self.display() this way, now() is called afresh each time if needed. Just thought this could help... Alex From aleaxit at yahoo.com Thu Oct 12 05:10:53 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 12 Oct 2000 11:10:53 +0200 Subject: Newbie: How do I implement an 2 element integer array in Python….? References: <8s1s48$89a$1@nnrp1.deja.com> <7U%E5.61379$g6.27618408@news2.rdc2.tx.home.com> <8s2608$2da$1@panix3.panix.com> Message-ID: <8s3vg4019ep@news1.newsguy.com> "Rainer Deyke" wrote in message news:u97F5.64035$g6.28185416 at news2.rdc2.tx.home.com... [snip] > > >MyArray = [[0 for i in range(16)] for j in range(100)] > > >MyArray[5][4] = 7 > > > > Why zero rather than None? > > I think BASIC initializes to 0 (although I could be wrong here). Therefore In Visual Basic 6, Private Sub Form_Load() Dim x(10, 7) MsgBox TypeName(x(2, 4)) End Sub displays "Empty" when run. In the docs (MSDN) it explains: """ Empty Indicates that no beginning value has been assigned to a Variant variable. An Empty variable is represented as 0 in a numeric context or a zero-length string ("") in a string context. """ Your impression that 0 is stored for uninitialized cells of an array may thus come from the 'implicit coercion' of Empty to 0 -- just like somebody else might have received the equally misleading impression that said uninitialized cells are set to the empty-string, because of the _other_ implicit coercion. It all depends on what context you're using it in (the "TypeName" call does no implicit coercion -- it returns information on the ACTUAL type...). If your array's declaration was Dim x(10, 7) as Integer or Dim x(10, 7) as String then the point would also be moot. But Python has no type-declarations, so there is no direct equivalent. > 0 is most consistent with the original poster's experience. There are cases > where None is the better choice, but there are also cases where 0 is > superior (example: the array is used to store accumulators). Yes, it does depend on "context of intended usage". None is best if the intention is that no array-cell be used without being explicitly set first; '', or 0, or 0L, or 0.0, may each be best for different intended-uses. In other words, encapsulating this into a function, we might have: def dim2(dimx, dimy, defaultValue=None): return [[defaultValue for i in range(dimy)] for j in range(dimx)] and a numeric array might be built with: myArrayInt = dim2(16, 100, 0) or myArrayLong = dim2(16, 100, 0L) or myArrayFloat = dim2(16, 100, 0.0) while non-numeric arrays remain just as easily buildable (just give a different default...). I think the "default of the default" might well remain at None, but opinions may certainly differ on this!-) Alex From emile at fenx.com Tue Oct 3 09:34:22 2000 From: emile at fenx.com (Emile van Sebille) Date: Tue, 3 Oct 2000 06:34:22 -0700 Subject: Global Module Index References: Message-ID: <8rcnps$hbq93$1@ID-11957.news.cis.dfn.de> It's there. So-it-must-be-you-ly y'rs, -- Emile van Sebille emile at fenx.com ------------------- "Dale Strickland-Clark" wrote in message news:k3njtsku6bmilhomunfnu24i6sagnjodvn at 4ax.com... > Is it me, or has the Global Module Index vanished in 1.6? > > > Dale Strickland-Clark > Out-Think Ltd > Business Technology Consultants > > From darrell at dorb.com Mon Oct 2 17:53:51 2000 From: darrell at dorb.com (Darrell Gallion) Date: Mon, 2 Oct 2000 17:53:51 -0400 Subject: Python equivalent of Java Vector References: <8rau5e$afv$1@nnrp1.deja.com> Message-ID: <092201c02cbb$409161f0$6401a8c0@home> From: > > "Does Python have something equivalent to Java's Vector? For instance, > most of the time if you want to use an array you have to declare the > size up front. Java has a Vector class which is an array of objects > which grows as you add things to it. > See lists: tmp=[] tmp.append("value1") tmp.append(55) print len(tmp) print tmp[1] Check out the docs, lists and dictionaries are very powerful. And who needs to declare what's in the list! --Darrell From kragen at dnaco.net Mon Oct 2 20:23:41 2000 From: kragen at dnaco.net (Kragen Sitaker) Date: Tue, 03 Oct 2000 00:23:41 GMT Subject: Python Metalanguage confusticates and bebothers me... References: <39b5942f.11001184@news.bright.net> <39c74a9f.7876057@news.bright.net> <39C791F7.9A397B5@alcyone.com> <39cb6ecd.10865567@news.bright.net> Message-ID: In article <39cb6ecd.10865567 at news.bright.net>, Jonadab the Unsightly One wrote: >. . . Obviously I wouldn't call >an associative list a "hash" in lisp, because they're not >implemented that way. (Which is why you can do such things >as rassq, which I've occasionally wished were possible in >Perl without making an inverted copy of the whole hash.) You can do the same thing as rassq in Perl; I don't think it will perform much worse than rassq in Lisp, except due to extraneous factors like interned atoms and the lack of a compiler. #!/usr/bin/perl -w use strict; sub rassq { my ($hash, $wanted_value) = @_; while (my ($key, $value) = each %$hash) { if ($value eq $wanted_value) { return $key; } } return undef; } print rassq({a => 'b', c => 'd'}, 'b'), "\n"; -- Kragen Sitaker Perilous to all of us are the devices of an art deeper than we ourselves possess. -- Gandalf the Grey [J.R.R. Tolkien, "Lord of the Rings"] From horst at proceryon.at Thu Oct 5 02:05:25 2000 From: horst at proceryon.at (Horst Gassner) Date: Thu, 05 Oct 2000 08:05:25 +0200 Subject: CIF parser Message-ID: <39DC1A25.9E7504D8@proceryon.at> Hi all! Does anyone know if there is a parser for the CIF (Crystallographic Information File) format? I only found parsers written in C language but none written in Python. The following URL is the one where I have looked for a parser: http://www.iucr.org/iucr-top/cif/home.html Thanx in advance Horst From claird at starbase.neosoft.com Fri Oct 13 09:23:08 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 13 Oct 2000 08:23:08 -0500 Subject: Historical details (was: Programmer-Wanna-Be (Is Python for me?)) References: <8s2354$ep2$1@nnrp1.deja.com> <1mxF5.36034$Cl1.869085@stones> Message-ID: <7976529C9EC788DE.0D6775FC31932620.9ECB197CA90B34A7@lp.airnews.net> In article <1mxF5.36034$Cl1.869085 at stones>, Lokie wrote: . . . >Tcl is an old scripting language which by some accounts is beginning to show >its age and limitation against the new breed of languages such as Python >that are beginning to emerge. TK is a GUI development system written in Tcl . . . John Ousterhout had the idea for Tcl in 1987. He began writing it in 1988, and others were using it early that same year. Guido thought up Python's essentials at the end of '89. He made a first working version at the beginning of '90. Colleagues used it in '90. He posted a release to NetNews in '91. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From breiter at usf.Uni-Osnabrueck.DE Tue Oct 10 17:11:31 2000 From: breiter at usf.Uni-Osnabrueck.DE (Bernhard Reiter) Date: 10 Oct 2000 21:11:31 GMT Subject: Python IDE: Boa (was: Is this a dream or a nightmare?) References: Message-ID: <8s00m3$7c5$1@newsserver.rrzn.uni-hannover.de> In article , Bill Hunter writes: > A real IDE for Python would be wonderful. No criticism implied of > IDLE or PythonWin - I'd just like to wake up some morning and find > something that didn't make my VB-centric colleagues roll their eyes. I recently gave the CVS version of Boa-Constructor a spin. (writing an article about wxPython for a new German Developer magazin). It actually aims to be an IDE, inspired by Delphi. A lot of stuff is in place, though it still needs some work it is worth checking out. http://boa-constructor.sourceforge.net/ > And sure, I'd pay some money for it. Well hire a support programmer. :) Bernhard ps: Personally I think that most IDEs are too bloated and self inclided. The only one I really liked were the development tools of NeXTStep... Unfortunatly Boa also suffers from this bloat. -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) From dnew at san.rr.com Tue Oct 10 12:09:23 2000 From: dnew at san.rr.com (Darren New) Date: Tue, 10 Oct 2000 16:09:23 GMT Subject: Super reps a class, not an instance References: <39DD4E57.53C27A3F@ix.netcom.com> <39DD865E.D97E4D09@cable.a2000.nl> <8rkpsr$bpa$1@nnrp1.deja.com> <39DE2905.1E62C763@ix.netcom.com> <8rliak0crt@news1.newsguy.com> <39DEAD1A.1201A557@ix.netcom.com> <8rmu1e12bc1@news1.newsguy.com> <39E1E331.BA9B9252@ix.netcom.com> Message-ID: <39E33F35.E099A14A@san.rr.com> Thomas Gagne wrote: > 2) references from within an instance to its superclass (however that is > accomplished) are intended to access the superclass's methods/data as an > instance not a class, aren't they? In Smalltalk, super message is identical to self message except that the method search starts at the superclass of the class containing the call to "super" instead of starting at the class of "self". That is, "super message" does exactly the same as "self message" if the "message" routine is not defined in the class containing "super message" or any of its descendants. -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. The tragedy of the commons applies to monitizing eyeballs, too. From aleaxit at yahoo.com Wed Oct 4 06:23:03 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 4 Oct 2000 12:23:03 +0200 Subject: Python as an embedded scripting language References: <8ren1o$cq3$1@nnrp1.deja.com> Message-ID: <8rf0ng02u9a@news2.newsguy.com> wrote in message news:8ren1o$cq3$1 at nnrp1.deja.com... > Is it possible to embed Python as a scripting language in a C++ > application and exposing the internals of the application to Python > through use of dynamic extension modules (PYDs)? Or is it necessary to > link the extension modules statically with the executable in order to > give them access to its internal data, and thus also to link the Python > interpreter in as well, since the extension modules must then be > realized as builtin modules? This breaks PYDs altogether, though, since > they are dependent upon a DLL Python core. Your application can embed Python residing in a DLL, and add its own modules to it with PyImport_AppendInittab (or the more general PyImport_ExtendInittab) before it calls Py_Initialize. > I would be thankful on any pointers on how to retain both Python's > access to the application data structures and the ability to import > PYDs. Section 5.3 in "Python/C API Reference Manual". For cross-platform work, also note section 4.2 in "Extending and Embedding". Alex From aleaxit at yahoo.com Thu Oct 26 05:18:36 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 26 Oct 2000 11:18:36 +0200 Subject: C's syntax (was Re: Python Formatted C Converter (PfCC)) References: <0056900013224812000002L022*@MHS> Message-ID: <01f201c03f2d$c048f960$102b2bc1@cadlab.it> > I agree on not allowing '=' in a condition, but it is nice for > testing bits if one can say > > if (var & 0x01) { It's nice, but sometimes that & in such constructs is a typo for &&. If, in a hypothetical no-compatibility-constraints variant of C, the latter operator is renamed to 'and', then the problem vanishes. If && must stay, i.e. in a minimal- changes setup, it seems to me that having to write (e.g.): if((var & 1)) rather than: if(var & 1) is no greater hardship than having to write (e.g.): while((nextone=getnext())) rather than: while(nextone=getnext()) as you already have to do to avoid warnings in gcc (when used with suitably high warning-level). And if you think the worst problem with Java is the need to express such an idiom with the variant: if((var&1)!=0) then I have a very interesting bridge to sell you!-) Alex From hinsen at cnrs-orleans.fr Mon Oct 16 11:52:43 2000 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: Mon, 16 Oct 2000 17:52:43 +0200 Subject: [Python-Dev] RE: [Numpy-discussion] RE: Possible bug (was Re: numpy, overflow, inf, ieee, and rich comparison) In-Reply-To: References: Message-ID: <200010161552.RAA02685@chinon.cnrs-orleans.fr> > > I'd like to have at least the option of raising an exception in that > > case. Note that this is not what NumPy does today. > > Does NumPy use the fpectl module? I suppose not. LLNL contribued that No. Perhaps it should, but it doesn't make sense unless fpectl works on a large number of platforms. I confess I have never looked at it. I want my code to be portable, so I don't even consider using packages that aren't. > > For the same reason that makes 2/3 return zero instead of a float > > division result. Like C or Fortran, Python treats integers, floats, > > and complex numbers as different data types. > > You know I'm in general agreement with you on this one, but I have to draw a > distinction here: Guido thinks that 2/3 returning 0 was a design mistake, > but not that math.sqrt(-1) raising an exception is a mistake. Most Python > users won't know what to do with a complex number, so it's "an error" to > them. Well, that would be a good occasion to learn about complex numbers! I remember having learned about generalized inverses by using APL in high school (in a very similar way: I was amazed that it could invert non-square matrices), and that turned out to be very useful knowledge later on. Perhaps that's a topic for the EDU-SIG... Anyway, I don't care what math.sqrt(-1) does, but I would definitely prefer Numeric.sqrt(-1) to return a complex result. And I think that someone who uses NumPy has probably heard about complex numbers. > I would like to view this in P3K (if not earlier) as being akin to > 754 exceptions: some people are delighted to have 1e300**2 return +Inf, > while others want to see OverflowError instead, and still others want to see > +Inf *and* have a sticky flag set saying "an overflow occurred". We could > treat f(x) (for f == sqrt and everything else) the same way wrt to a new > ComplexResultFromNonComplexInputsError: define "non-stop" complex results, > let the user choose whether to do nonstop or raise an exception, and a > supply a sticky flag saying whether or not any complex results were > generated from non-complex inputs. There is, however, one difference: in properly debugged production code, there should be no overflow situations, so it doesn't matter much how they are treated. Complex number can (do!) occur in production code, but there could also be production code relying on exceptions for sqrt(-1) (e.g. for input error checking). Therefore a program using several libraries might be impossible to run with either setting. Since this concerns only the math module, I'd prefer to keep separate module versions for the two cases, which can be used in parallel. > > The "right" solution, in my opinion, would be to have a single > > "number" type of which integers, float, and complex numbers are simply > > different internal representations. But such a change cannot be > > introduced without breaking a lot of code. > > The current distinction between ints and longs (unbounded ints) should also > get swallowed by this. A way to get from here to there is especially > irksome at the C API level, since, e.g., many C API functions pass Python > ints as C longs directly. A smaller number pass Python floats as C doubles > directly. I don't see the problem in that direction, it's rather C API functions that *return* numbers in C data types that would be difficult to adapt. But then, why should be C API not be allowed in P3K? it's-wonderful-that-anything-may-be-changed-in-p3k'ly Konrad. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From tgagne at ix.netcom.com Sat Oct 7 00:51:14 2000 From: tgagne at ix.netcom.com (Thomas Gagne) Date: Sat, 07 Oct 2000 00:51:14 -0400 Subject: busting-out XML sections References: <39DCFFC2.A26BF159@ix.netcom.com> <39DDB4F8.60ECF23C@milagrosoft.com> <39DE24AE.71AD86C1@ix.netcom.com> <8rliub0daq@news1.newsguy.com> Message-ID: <39DEABC2.B0980E15@ix.netcom.com> Alex Martelli wrote: > > I think it's wrong to assume that the implementation of crucial > infrastructure > such as XML DOM analysis is defective, just because it *might* be and thus > cause problems if you ever have to process a gigabyte-size input file. Why > not "do the simplest thing you can possibly get away with", as XP teaches? I'm curious, in this example, what the simplest thing would be? I've been reading the XP debates in comp.object at arm's-length and decided on something that is fairly straight-forward, but avoids consuming memory (attached). Briefly, the first argument is the tag inclosing the text I want to 'burst' from the rest of the file (hence the name, burster.py). And it even avoids being a poor computer citizen. Line-for-line I'd imagine it's pretty low-maintenance. Out of curiosity, is part of what XP is about? Doing the simplest thing first? Heck, I'm always looking for the simplest way to get something done (I think I even lead-off the first message in that thread complaining that I didn't want to do anything too complicated--or maybe I'm just lazy? > > Using an XML DOM approach is often simplest. Use it, and see if you can't > get away with it. If and when the XML DOM implementation you have proves > defective, upgrade to a better one, and, *poof*, problem disappears again... > > Alex -- .tom From jm at recumbent.co.uk Wed Oct 11 04:14:34 2000 From: jm at recumbent.co.uk (JTC Murphy) Date: Wed, 11 Oct 2000 09:14:34 +0100 Subject: Is this a dream or a nightmare? (Was Re: XML) Message-ID: > A real IDE for Python would be wonderful. http://www.pythonware.com - or am I missing something? Murph >>> Bill Hunter 10/10/00 19:31:45 >>> A real IDE for Python would be wonderful. No criticism implied of IDLE or PythonWin - I'd just like to wake up some morning and find something that didn't make my VB-centric colleagues roll their eyes. And sure, I'd pay some money for it. Bill From the_brain at mit.edu Tue Oct 24 16:26:59 2000 From: the_brain at mit.edu (Alex) Date: 24 Oct 2000 16:26:59 -0400 Subject: Scripting SSH with Python References: Message-ID: > I am scripting SSH or actually rsync using ssh and I am in need of a > bit of help. When I make the SSH connection I am prompted to enter a > password... my problem is that I don't know how to look for this > promt and have the script submit the password for me. Can anyone give > me some help on this. Here's some code that I ripped off another news post ages ago, and mutated. Hope it helps. It requires the pty module. Alex. -- Speak softly but carry a big carrot. #!/usr/bin/env python import os execfile (os.path.join (os.environ['PYTHONSTARTUP'])) import os, string, pty, time, signal def remote_ex(hostname, password): pid, fd = pty.fork() if pid == 0: os.execv("/usr/local/bin/ssh",[hostname]) else: time.sleep(2) print "Child says %s" % string.strip(os.read(fd,1024)) # print "Child took %d password bytes." % os.write(fd, password) time.sleep(2) #being over cautious print "Child took %d command bytes" % \ os.write(fd, "echo $HOST > ~/ptyhost.txt\n") print "Child says %s" % string.strip(os.read(fd,1024)) print "Child took %d exit bytes." % os.write(fd, "exit\n") print "Child says %s" % string.strip(os.read(fd,1024)) # st () os.kill(pid, signal.SIGKILL) return #=-=-=-=-=-Main=-=-=-=-=-=-=# def main(): # myhost = string.strip(raw_input("Enter a host:")) # mypass = raw_input("Enter your Password:") remote_ex(myhost, mypass) ########################## if __name__ == "__main__": main() From aleaxit at yahoo.com Fri Oct 20 05:11:08 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 20 Oct 2000 11:11:08 +0200 Subject: ActivePython 2.0 Release References: <634vusk9nco8qem70ddo43t4qpgid30s1l@4ax.com> Message-ID: <8sp2he01b00@news1.newsguy.com> "Dale Strickland-Clark" wrote in message news:634vusk9nco8qem70ddo43t4qpgid30s1l at 4ax.com... > Yes, but how is this better then Python 2.0 + Win32all? That will depend on what's in win32all build 135, I guess. Right now, I can't find it anywhere on ActiveState's site -- it only seems to have builds up to 134, so far. If anybody has an URL for a build-135 to install on top of BeOpen Python 2.0 final, I would welcome that, of course... Apart from that, "one-stop-shopping" seems to be what the ActiveState build has going for it, as they claim themselves: > >ActiveState is committed to making Python easy to install and use on all > >major platforms. ActivePython contains the convenience of swift > >installation, coupled with commonly used modules, providing you with a > >total package to meets your Python needs. Additionally, for Windows users, > >ActivePython provides a suite of Windows tools, developed by Mark Hammond. I.e., one download, one install. They have now added Tkinter too, I gather from their announcement-page (and, I guess/hope, IDLE as well). One little plus (from my POV) I noticed in their previous build is that the docs in the Windows build are in CHM, which I find quite preferable to bare HTML (built-in index and search, etc), although there were lots of defects in the .CHM themselves (missing/wrong indices, etc). Alex From tnixon at avalanchesoftware.com Wed Oct 18 16:02:56 2000 From: tnixon at avalanchesoftware.com (Travis Nixon) Date: Wed, 18 Oct 2000 14:02:56 -0600 Subject: How to statically bind modules written in Python Message-ID: <01fb01c0393e$685e73f0$0700000a@travis2> Ok, after quite a lot of trouble, I've got a Windows version compiling that doesn't require the python dll in any way shape or form. I've also figured out how to statically add C based modules, so they can be imported on a system that doesn't contain anything other than the statically linked python.exe. Obviously, I won't be able to import outside modules from dlls or .py files, but I'm ok with that. Now, where I'm running into a problem is that there are going to be some .py files that I need to be able to import, but I can't for the life of me figure out how to bind them statically, so they're available for scripts run by my statically linked python.exe. Eventually, this is going to be the base for using python embedded into a project that doesn't have (as far as I know) support for any type of dynamic linking. Any suggestions on how to approach this? Basically what I want is to have something along the lines of a module named staticmodule.py, and have that available through the normal import statement, without it actually going out to disk to look for it. A couple solutions I've considered: Solution 1: Rewriting the necessary modules in C, and adding them to the library. Obviously, for any new modules I could probably do this, although it would very possibly end up being more work than I really wanted to do (which is one of the reasons I'm trying to do this in the first place, to make LESS work). But there are some .py files in the standard distribution that I'd like to include as well, and I'm going by the (possibly faulty) assumption that if they were easy to move to C, it would already have been done. :) Solution 2: I read a post from somebody suggesting throwing the python modules through freeze, and then copying the generated C code. First of all, I'm having trouble getting freeze to work at all on windows, and even when/if I do get it working, this also is more work than I really want to do. And it's work that has to be done by hand, as opposed to work that can be done by a makefile. Solution 3: I just thought of this, but it probably would be possible to include the .py files (or rather the .pyc files) in the resources, and rewrite the python's import to grab them from there instead of going to disk. The major problem here is that our final platform is not going to be windows. I suppose I could do something similar though, with a file that's loaded into memory at startup, and then do the same sort of modifications to import to search there instead. This is actually a fairly workable option, but it's still just not as clean and elegant as simply being able to somehow statically bind the .py module to the executable itself. (which as I'm writing this I'm realizing is probably impossible anyway) By the way, the reason I don't want to just have them loaded from disk on demand is that the eventual target is a game console, and I don't want to have to hit the disk during the game for a python script that's just being imported. I'd prefer to load them all up front (since they should be fairly small), and provide import access to them that way. Anyway, I seem to have mosty answered my own question, but if anybody has any input on something I'm maybe missing, sharing would be greatly appreciated. :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From LONNIET at PRODIGY.NET Thu Oct 19 04:59:14 2000 From: LONNIET at PRODIGY.NET (LONNIE) Date: Thu, 19 Oct 2000 01:59:14 -0700 Subject: newbie Message-ID: <8soeic$57gs$2@newssvr05-en0.news.prodigy.com> I have been teaching myself python for about a month now for the simple reason that I have read alot of literature that says that its easy to jump from python to c++. I was just wondering if this was true also I have been teaching myself from online tutorials but I have been looking for a good book to go along with the literature that I have downloaded so far any suggestions would be nice. thanks Lonnie lonniet at prodigy.net From piet at cs.uu.nl Tue Oct 17 04:16:24 2000 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 17 Oct 2000 10:16:24 +0200 Subject: ANN: gdchart-py-0.5 References: Message-ID: >>>>> Mike Steed (MS) writes: MS> Gdchart-py-0.5 is available. MS> Gdchart-py is a Python interface to Bruce Verderaime's GDChart library, MS> which produces charts and graphs in PNG, JPEG, and GIF format. MS> Documentation, source code, and Win32 binaries are available: The Windows binaries, for which version of Python are they? -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From nadavh at envision.co.il Sun Oct 8 05:59:59 2000 From: nadavh at envision.co.il (Nadav Horesh) Date: Sun, 08 Oct 2000 11:59:59 +0200 Subject: Integer multiplication overflow Message-ID: <39E0459F.910D8A58@envision.co.il> try: def fact(num): if num < 2: return 1L return num * fact(num - 1) Nadav. -------------- next part -------------- A non-text attachment was scrubbed... Name: nadavh.vcf Type: text/x-vcard Size: 360 bytes Desc: Card for Nadav Horesh URL: From kc5tja at garnet.armored.net Thu Oct 12 18:26:57 2000 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 12 Oct 2000 15:26:57 -0700 Subject: how to save HOURS of time with python... References: Message-ID: On Sun, 8 Oct 2000 00:19:51 -0400 (EDT), Michal Wallace wrote: >#!/usr/home/sabren/bin/python >""" >I waste way too much time checking email. >This is a little script to prevent me >from checking email too often. >""" >import os, stat, time > Hey, Billy! This is just what you need for your Usenet news addiction! >:) -- KC5TJA/6, DM13, QRP-L #1447 | Official Channel Saint, *Team Amiga* Samuel A. Falvo II | Oceanside, CA | From aleaxit at yahoo.com Wed Oct 25 05:09:18 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 25 Oct 2000 11:09:18 +0200 Subject: C's syntax (was Re: Python Formatted C Converter (PfCC)) References: <8t0or303ee@news1.newsguy.com> <39F4FFB7.452EDDEC@alcyone.com> <8t3mdv025uo@news2.newsguy.com> <39F5B404.B5626FB7@alcyone.com> <8t4q8v11lpv@news1.newsguy.com> <39F65EB2.EE2E3B1C@alcyone.com> Message-ID: <8t6894040e@news1.newsguy.com> "Erik Max Francis" wrote in message news:39F65EB2.EE2E3B1C at alcyone.com... > Alex Martelli wrote: > > > But that doesn't mean I have to keep silent when somebody > > baldly asserts that C's syntax is "pretty good". Yecch. It's > > most definitely *NOT*! > > In _your_ very obviously biased opinion. And many others'. Re-read this thread, and you'll see many concurring -- including the one who originally posted the assertion about "pretty good" (turns out that his only criterion of judgment here was that C is "compatible with itself" -- a rather peculiar one). > > And trying to classify me as "does > > not like C" because I *detest* its syntax is just silly. > > How can you "_detest_" (your emphasis) a language's syntax but like the > language? They're inseparable, bub. A language's syntax is _part_ of that language. A rather small part: a typical language processor has less than 1/10th of its code devoted to syntax issues. Many people just can't see that smallness, and consider a lanuage to "be" its syntax. This is (though not quite as extreme) like considering a book to "be" its cover. Sure, the cover is the first thing you see. But it's so far from "being" the book, that the idiom "judging a book by its cover" is proverbially used to indicate shallowness of judgment and perception. "Judging a language by its syntax" is a similar (though not quite as extreme) misperception. The excessive interest devoted to applications' GUI's compared to their internals is another example of this kind of mistake. Nevertheless, if a silly publisher put out, say, "Master and Margarita" in an edition whose cover is tacky and horrible, I would not stand silently by if somebody proclaimed that cover "pretty good". The goodness, or even greatness, of the novel itself, would not one whit enhance the cover! "Judging a cover by its book" is not a widespread misperception, but it's no less peculiarly silly and erroneous for being rare. > Considering that you're the one who's ranting for paragraphs and > paragraphs about C, it's pretty clear that you have a bee in your bonnet > about _something_. I don't wear bonnets (black cowboy hats, if any, being my chosen headgear). > Don't like C's syntax? Don't use it. Hate its syntax but use it > anyway? Live in your own private hell. Hate its syntax but like it? > By all means, continue making no sense. It's impractical to "not use" C syntax, when programming in C. This was basically the proposal at the root of this thread, and I'm surprised to hear you voicing approval for it, since it seemed to be universally disliked. As for "private hells", this must surely deserve a good place in the empyreon of Usenet overstatements, considering how clear I've always made that syntax is rather a lesser issue for me -- Python's clean and effective syntax is a minor issue in my love for it, C's horror of a sorry excuse for a syntax a minor annoyance. I take a bus to work every day. It's cheap, fast, generally punctual and clean. Most buses on that line are also painted a horrid shade of orange, a color I wouldn't wish on my worst enemies (with a possible exception for those who proclaim C's syntax "pretty good":-). Do you truly believe this makes my commuting 'hellish'...? How *superficial* can you get...? [But I'm not going to stay silent if some benighted soul starts lavishing praise on _that_ orange hue -- *yecch*!-)] Alex From marcc at yieldworks.com Mon Oct 16 22:51:11 2000 From: marcc at yieldworks.com (marc cheatham) Date: Tue, 17 Oct 2000 02:51:11 GMT Subject: Python and Lotus Notes Message-ID: <39EBBD7E.34ADD5BD@yieldworks.com> Has anyone used Python 1.5 and COM for Lotus Notes 5.02 and up? I am able to Initialize a new notes session, but cannot access the my mail database on the Domino server. I believe the COM call to GetDatabase returns an object, and this is where the problem lies. I have gotten this to work under VB6, but would prefer to use Python. Thanks in advance, Marc From gregj at pobox.com Sun Oct 22 14:33:09 2000 From: gregj at pobox.com (Greg Jorgensen) Date: Sun, 22 Oct 2000 18:33:09 GMT Subject: How can I send mail to 'Cc'address in smtplib? References: <8spfg4$s7$1@news2.kornet.net> <8stjbg$58g$1@reader1.imaginet.fr> Message-ID: The bug in quopri.py described below is fixed in 2.0. "Gilles Lenfant" wrote in message news:8stjbg$58g$1 at reader1.imaginet.fr... > WARNING > "quopri.py" module is buggy (python 1.5.2, don't know for others) and does > not encode text as the mail client expect it ! > Edit the "quopri.py" module and comment out or remove the first 3 lines of > the "quote" function. It should look like this: > ----- quopri.py ----- > ... > def quote(c): > ## if c == ESCAPE: > ## return ESCAPE * 2 > ## else: > i = ord(c) > return ESCAPE + HEX[i/16] + HEX[i%16] > ... > --- end quopri.py --- -- Greg Jorgensen Deschooling Society Portland, Oregon, USA gregj at pobox.com From aleaxit at yahoo.com Mon Oct 9 03:13:00 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 9 Oct 2000 09:13:00 +0200 Subject: Running Python on SMP machine References: <8rrks8$a1a$1@panix3.panix.com> Message-ID: <8rrrg00nle@news2.newsguy.com> "Aahz Maruch" wrote in message news:8rrks8$a1a$1 at panix3.panix.com... > In article , > Erno Kuusela wrote: > >>>>>> "William" == William Park writes: > > > > | How do I take advantage of a SMP (2 CPU) machine? > > > >use separate processes. > > Why? Why not use threads? Perhaps because of Python's single interpreter lock...? If all your threads are running Python bytecode, I do not think you will ever be using the second CPU (haven't tried it, but this seems to be the effect of the current architecture as I understand it). Alex From see at my.signature Thu Oct 5 20:41:05 2000 From: see at my.signature (Greg Ewing) Date: Fri, 06 Oct 2000 13:41:05 +1300 Subject: How can you copy (clone) a string? References: <39DBBF7D.6F28E487@my.signature> Message-ID: <39DD1FA1.A75774@my.signature> piet at cs.uu.nl wrote: > > That will not help, as the strings will be garbage collected. Well, keep them in a list or something. If the strings are fairly big, the extra memory taken up by the list won't make much difference. Or chain them into a linked list using tuples. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From aleaxit at yahoo.com Fri Oct 13 08:48:49 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 13 Oct 2000 14:48:49 +0200 Subject: Most Effective Way to Build Up a Histogram of Words? References: <8s4hc3$a5a$1@news.nuri.net> Message-ID: <8s718k02kum@news1.newsguy.com> "Quinn Dunkan" wrote in message news:slrn8uc5v3.k2j.quinn at mark.ugcs.caltech.edu... [snip] > >> for word in words: > >> histogram[word] = histogram.get(word, 0) + 1 [snip] > Also, if you're using python 2.0, you could use a slightly more efficient > > historgram.setdefault(word, 1) > > instead of: > > histogram[word] = histogram.get(word, 0) + 1 Not really: if you used setdefault instead of the above-quoted line in the for loop's body, you would not be counting words, just marking with a '1' those which are present. You do need the '+ 1', in some form, to do the actual *counting*. The new .setdefault is useful mostly when what you want to put in correspondence with an entry is some *mutable* object. When the object is an integer (or otherwise immutable), you need a dictionary[key] = newvalue anyway, so the .setdefault has no real advantage over a good old .get -- in fact, it can be very-fractionally-slower. When the object is mutable, and your fondest desire is to call: dictionary[key].somemutation() but you need to ensure that, if key was not already present, its entry IS initialized to a fresh new object before you start mutating it, _then_ the new method is useful...: dictionary.setdefault(key,NewObject()).somemutation() Actually, even in this case, you have to take a little care if you do care about performance... note that a NewObject() is called *anyway* in this idiom -- even when .setdefault is going to ignore the result -- since Python is 'strict', aka 'eager', in its evaluations (first the arguments are fully evaluated, then the function is called; almost every other language behaves this way, too, except for a few [not very widely used] languages such as Haskell, which have by default 'lazy', aka 'normal order', evaluation). So, you have to look carefully at the cost of evaluation of that new-object constructors... if it's high enough, then the new idiom may not be affordable, particularly if the case in which the key is already present is very frequent (i.e., 'new' keys, not-already-present, are rare). This suggests the exception-idiom over the checking-idiom: try: dictionary[key].somemutation() except KeyError: dictionary[key] = NewObject() dictionary[key].somemutation() rather than the more compact: if not dictionary.has_key(key): dictionary[key] = NewObject() dictionary[key].somemutation() but either might be better, performance-wise, than the use of .setdefault in this case. The advantage of .setdefault is big when the possibly unused new-constructor is very cheap...: dic.setdefault(key,[]).append(something) and this specific usage is probably going to be the dominant case of setdefault, since dictionaries of lists are such a natural and widespread datastructure, and the 'very cheap constructor' applies forcefully!-) Alex From skodela at my-deja.com Thu Oct 19 16:04:49 2000 From: skodela at my-deja.com (Sindh) Date: Thu, 19 Oct 2000 20:04:49 GMT Subject: Somebody must know this! [was plugin problems] References: <8sfp1f$35p$1@nnrp1.deja.com> Message-ID: <8snk4s$ici$1@nnrp1.deja.com> I am sure someone surely knows the answer. Waiting patiently....... Thanks sreekant In article <8sfp1f$35p$1 at nnrp1.deja.com>, Sindh wrote: > Hi folks > > I am writing an application in python / Tkinter and Pmw. I am planning > to include plugin facility. > I am trying this way currently. It fails saying btnname attribute is not > available and also importing n says no module byname n, where I > planned to use n as a place holder to iterate over the .py plugin files > in ./plugins/ directory. > > Code follows. > ################################ > Plugin loader in the application > ################################# > self.pluginb=Pmw.ButtonBox(self.nb.pg_sys,orient='vertical') > for n in os.listdir('plugins'): > import n > self.pluginb.add(getattr(n,btnname),command=getattr(n,'mainrun')) > > ########## > example plugin > ##################### > def mainrun(): > print "hello world" > > btnname="HelloWorld" > ############################### > Any ideas and helpwould be greatly appreciated. > > Thanks > sreekant > > -- > A man needs to sleep for 36 hours a day atleast. > > Sent via Deja.com http://www.deja.com/ > Before you buy. > -- A man needs to sleep for 36 hours a day atleast. Sent via Deja.com http://www.deja.com/ Before you buy. From jschmitt at vmlabs.com Wed Oct 11 13:48:38 2000 From: jschmitt at vmlabs.com (jschmitt at vmlabs.com) Date: Wed, 11 Oct 2000 17:48:38 GMT Subject: how do I know when popen() finishes? References: <8s0gts$767$1@nnrp1.deja.com> <8s1nn2$4co$1@nnrp1.deja.com> Message-ID: <8s295i$kea$1@nnrp1.deja.com> Thanks for the tip. I thought that with the advent of Python 2.0, this stuff should work under Windows as well. In Python 1.5.2 I saw this disclaimer and the recommendation of using Python 2.0. What would you use under Windows instead? John PS email to bragib at my-deja.com bounces. In article <8s1nn2$4co$1 at nnrp1.deja.com>, bragib at my-deja.com wrote: > John: > > Typically I read from popen like this: > proc = os.popen( 'busyprogram' ) > while 1: > line = proc.readline() > if line: > print line > else: > break > > Bragi > > Note that popen is only for UNIX platforms. > > In article <8s0gts$767$1 at nnrp1.deja.com>, > jschmitt at vmlabs.com wrote: > > I'm using Python 2.0b2 on Wind2000. > > > > If I do something like > > > > import os > > f = os.popen( 'busyprogram' ) > > > > how do I retrieve all the output that busyprogram produces when > > busyprogram finishes? Do I busy wait on f.read(), ie, wait for end of > > file? Does f.close() do the same thing as pclose(f)? > > > > Thanks. > > > > John > > > > Sent via Deja.com http://www.deja.com/ > > Before you buy. > > > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From trentm at ActiveState.com Thu Oct 26 13:11:58 2000 From: trentm at ActiveState.com (Trent Mick) Date: Thu, 26 Oct 2000 10:11:58 -0700 Subject: TypeError In-Reply-To: <39F86026.D65F0CB7@hotmail.com>; from keisari_@hotmail.com on Thu, Oct 26, 2000 at 07:47:34PM +0300 References: <39F83ED4.57ADB649@hotmail.com> <39F86026.D65F0CB7@hotmail.com> Message-ID: <20001026101158.B21420@ActiveState.com> On Thu, Oct 26, 2000 at 07:47:34PM +0300, joonas wrote: > I used the "print type(first)" method and it printed > > "" > > but when i wrote used "print first" it gave me > > "100" > "100" is the result of running your BUtton's __str__() method. > So. How can i make first substractable. Well, are you sure you want to subtract Buttons? I don't know what it means to do that. Trent -- Trent Mick TrentM at ActiveState.com From bob at wildthink.com Sun Oct 8 17:12:28 2000 From: bob at wildthink.com (Robert Hicks) Date: Sun, 08 Oct 2000 21:12:28 GMT Subject: Text size in Idle under X11? References: <8ronir$78d$1@nnrp1.deja.com> <8roq66$985$1@nnrp1.deja.com> Message-ID: Keep looking. I just moved to the Mac so I cannot find it for you. But it is there I did it on Linux so I know it was not just a Windows thing. > From: Nate Bargmann > Organization: Deja.com - Before you buy. > Newsgroups: comp.lang.python > Date: Sun, 08 Oct 2000 03:37:41 GMT > Subject: Re: Text size in Idle under X11? > > In article , > Robert Hicks wrote: >> You can edit the editor.py (?) and change the font in idle. > > That particular filename comes up empty on my system. Per the help in > Idle I looked at /usr/lib/idle/EditorWindow.py and found this relevant > frgament: > > if sys.platform[:3] == 'win': > text['font'] = ("lucida console", 8) > > The if statement leads me to believe this only works in MS Windows as I > tried changing it and still had the small text size upon the next > restart of Idle. > > Thanks. > > Next? > > - Nate >> > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From MarkH at ActiveState.com Wed Oct 18 18:43:26 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 18 Oct 2000 22:43:26 GMT Subject: Parsing tuples in C extension References: <8sl63k$jku$1@nnrp1.deja.com> Message-ID: PyArg_ParseTuple will work on any tuple. Eg, if you have nested tuples, you could use PyArg_ParseTuple(args, "000", t1, t2, t3), then PyArg_ParseTuple(t1, "iii", &i1) (assuming relevant error checking, of course :-) Mark. -- markh at activestate.com - but if you think I speak for them, you dont know Dick! wrote in message news:8sl63k$jku$1 at nnrp1.deja.com... > Is there a function similar to PyArg_ParseTuple(...) that you can use to > parse a tuple that is not the args tuple? > From mbel44 at dial.pipex.net Tue Oct 24 11:42:01 2000 From: mbel44 at dial.pipex.net (Toby Dickenson) Date: Tue, 24 Oct 2000 16:42:01 +0100 Subject: event loop problem References: <8t21ei$e5a$1@nnrp1.deja.com> <8t3q4402a3u@news2.newsguy.com> Message-ID: Geoff Talvola wrote: >For a single-threaded Python program using ADO, there's no shared data to worry >about. And what if your program structure contains long-running calculations >based on data from your ADO database? You have to contort your calculations to >insert PumpWaitingMessages() calls everywhere. A single-threaded, non-GUI >application shouldn't have to have a message loop, IMO. Threads that use apartment-model COM must have a message loop - thats a rule imposed by that threading model. If you dont want a message loop, there are plenty of other COM threading models to choose from. Toby Dickenson tdickenson at geminidataloggers.com From MarkH at ActiveState.com Tue Oct 17 02:11:59 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Tue, 17 Oct 2000 06:11:59 GMT Subject: I want to impress the boss. References: <8sdvc6$jqq$1@nnrp1.deja.com> <39EAFE3C.7D13B8B3@engcorp.com> <8sgn6d$s10$1@nnrp1.deja.com> Message-ID: > The questions: > - The location of a complete set of Microsoft Word COM commands is > asking too much? Actually there _was_ a pointer to the complete commandset (ie, the makepy generated source file). No pointer to documentation yet tho. But it is too much to ask on this newsgroup. Check the Office 2000 install options - it may be there, but disabled (that was true for Office 97). Or try the Office 2000 developers kit. > - When interfacing to VSS it's up to me to build my own 'home grown' > set of commands...(it's possibly not mature enough a program to have a > built in COM interface)? No - it has a complete COM interface. There was a pointer to some sample code in Pythonwin that uses this interface. Again, you will need to look for VSS resources to locate the object model documentation... Mark. From aahz at panix.com Tue Oct 3 11:12:27 2000 From: aahz at panix.com (Aahz Maruch) Date: 3 Oct 2000 08:12:27 -0700 Subject: How can you copy (clone) a string? References: Message-ID: <8rct0r$4hc$1@panix3.panix.com> In article , wrote: > >Earlier I asked a question about cloning python strings, but neglected >to say why I needed it. >What I'm trying to do is determine how large a user process can be >before it runs out of memory. This is useful in debugging kernel >parameter issues in our performance lab where our tests are running out >of memory and I have to provide empirical proof that the kernel parms >are set correctly and that an example program can prove it. > >Originally, I created a one-meg string, then concatenated it to itself >until I ran out of memory (on the heap). The number of iterations >would give me a close approximation of the maximum date-segment size >for a single process. The problem is, that once the string approaches >half or so of the kernel limit, you get a memory error....Python will >have to malloc a string that is 1-meg larger than the original >string....you get the idea. Okay, here's a simple (and very rough!) approach: OneMBstring = 'a' * ( 1024 * 1024 ) stringList = [] i = 1 while 1: print "%sMB consumed" % i stringList.append(OneMBstring + str(i)) i = i + 1 -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 There's a difference between a person who gets shit zie doesn't deserve and a person who gets more shit than zie deserves. --Aahz From francois.granger at free.fr Tue Oct 10 16:31:48 2000 From: francois.granger at free.fr (=?ISO-8859-1?Q?Fran=E7ois_Granger?=) Date: Tue, 10 Oct 2000 20:31:48 GMT Subject: What is Python? References: <8pqhm9$6a9$1@panix3.panix.com> <3BBC75F01B2A2291.3CC54B93C0C69DED.4E021EA85330C94C@lp.airnews.net> <8pt65c$cbs$2@newshost.accu.uu.nl> <39C29336.71ED41AC@seebelow.org> <39C3E664.BCEAF741@seebelow.org> <8q5rgv$7to$1@nnrp1.deja.com> <39C6DF06.FF7F8A74@engcorp.com> <39C70642.D6CBF93A@alcyone.com> <39C710F7.4E72D963@seebelow.org> <39C86059.2F644D70@engcorp.com> <39C867B5.DFF9FFD3@seebelow.org> <8qat1u02g2j@drn.newsguy.com> <1eha5k2.kxgxg85fmpvrN@paris11-nas8-55-47.dial.proxad.net> <8rkk93028po@news2.newsguy.com> <1ei797z.80h2j11axifjmN@paris11-nas2-42-25.dial.proxad.net> <3dvgv2m0k4.fsf@kronos.cnri.reston.va.us> <1ei99nj.xzk3gmmvlbnlN@paris11-nas8-55-45.dial.proxad.net> <8rtf6d02v5g@news1.newsguy.com> Message-ID: <1eib4h6.13juqm7x0omh5N@paris11-nas6-50-136.dial.proxad.net> Alex Martelli wrote: > At least, that's how I've seen it in the French programming texts I have > recently been reading (O'Reilly-published book on OCaml, etc). Why do you read programming books in French ;-) Ho! OCaml! I see ;-) (I would not understand one word on it even in french :-D))) -- "De quelque mani?re que l'on divise le monde, il y a toujours la m?me proportion d'imb?ciles et de c.." - Propos de O.L.Barenton, Confiseur A. Detoeuf From jim at digicool.com Fri Oct 27 22:45:02 2000 From: jim at digicool.com (Jim Fulton) Date: Fri, 27 Oct 2000 22:45:02 -0400 Subject: PythonLabs Team Moves to Digital Creations References: Message-ID: <39FA3DAE.ADB2C8B1@digicool.com> Guido van Rossum wrote: > (snip) > I am proud to have found a new home for my entire team: starting > today, Tim Peters, Barry Warsaw, Jeremy Hylton, Fred Drake and myself > are working for Digital Creations. We will be spending part of our > time on core Python development (including Jython and Mailman) and > part of our time on Python infrastructure improvements that also > benefit Zope. Needless to say (but I'll say it anyway), Digital Creations is proud and thrilled that the this team has joined us. These are indeed exciting times! Jim -- Jim Fulton mailto:jim at digicool.com Technical Director (888) 344-4332 Python Powered! Digital Creations http://www.digicool.com http://www.python.org From MarkH at ActiveState.com Thu Oct 26 19:05:01 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 26 Oct 2000 23:05:01 GMT Subject: How do I force a single instance of a python app? References: Message-ID: wrote in message news:mailman.972547429.774.python-list at python.org... > >Or attempt to create a directory - that is an atomic operation that > >indicates what you need to know. Obviously will need some sort of > ... > > Creating a directory does not have automatic cleanup upon process death. That is exactly what I said (in a round-about way) in the sentence that starts with "Obviously..." quoted above. You must have missed the original? > A real Win32 synchronization mechanism like a possibly named mutex is best, I thought a Win32 specific solution was ruled out? > but for the people that insist on files, use the Win32 api that lets you > specify no sharing. If people are happy with using a Win32 specific solution, but insist on using files when other Win32 facilities better suited exist, they are fools ;-) The idea of creating a directory was one I saw in a very old source control system. They documented that they used a directory as a lock, as it was the only reasonable, cross platform, atomic operation with failure they could rely on. If a Windows only solution is acceptable, then this thread has already covered the best answer... Mark. From pearu at ioc.ee Thu Oct 12 13:25:40 2000 From: pearu at ioc.ee (Pearu Peterson) Date: Thu, 12 Oct 2000 19:25:40 +0200 Subject: ANNOUNCE: PySymbolic - Doing Symbolics in Python References: Message-ID: <39E5F414.5A2457E3@ioc.ee> Pearu Peterson wrote: > In addition, I am thinking of the following syntax examples in Python: > Diff(x*x,x) > Integrate(a*x,x=[c,d]) > Limit(1/x,x=0) > Factor(x**2-4*a**2,x) > Sum(i**2,i=[2,N]) > Substitute(x*a+2,a=5) # or Subs(..) > Expand() > Collect() > Simplify() > ... > > It is not possible to get this kind of a look for Python and it > looks pretty good to me. I really meant, "It is possible to get .." Pearu From carroll at cis.ohio-state.edu Thu Oct 5 09:37:51 2000 From: carroll at cis.ohio-state.edu (Mark Carroll) Date: 5 Oct 2000 13:37:51 GMT Subject: Class Browsers vs Static Types (Re: Inefficiency of __getattr__) References: <8rfslr$335$1@news.cis.ohio-state.edu> Message-ID: <8ri07f$cmf$1@news.cis.ohio-state.edu> In article , Kragen Sitaker wrote: (snip) >Those features are buggy and poorly designed, unless --- and probably They fit snugly in with the rest of everything. What makes you think they're any more poorly designed than a later first attempt would have been? >even if --- you've implemented something very similar before. And when >you do get around to using them, you will end up fixing bugs that you >wrote months before instead of minutes before. This makes the problem >much harder. IME it is easier to fix bugs in old code than to add substantial new features to old code - after all, it was written at a time when you understood the rest of that part better so even if you got an interaction with it wrong then at least you have some piece of code that _tries_ to do the interaction and reminds you it needs to be done at all. No doubt one's mileage varies: (snip) >and fixing them; it vitiates process feedback. (Do you write most of >your bugs when working past 17:00? When you've eaten a low-protein >lunch? How effective are your code reviews? How will you have any >idea if your bugs remain hidden for a month?) When you're working in a >system full of untested code and something breaks, you can't tell if >it's something you just added --- or a bug that's been there for weeks, >months, or years. That makes debugging slower. (snip) When you add code that actually uses a feature, and a bug appears, you can be pretty sure the bug's in the feature or the bit of code that calls it. No different to if you'd added it later. -- Mark From keisari_ at hotmail.com Thu Oct 26 10:25:24 2000 From: keisari_ at hotmail.com (joonas) Date: Thu, 26 Oct 2000 17:25:24 +0300 Subject: TypeError Message-ID: <39F83ED4.57ADB649@hotmail.com> I get error, "TypeError: bad operand type(s) for -" What could be wrong. Joonas. From hernanf at my-deja.com Tue Oct 24 07:13:55 2000 From: hernanf at my-deja.com (Hernan M. Foffani) Date: Tue, 24 Oct 2000 11:13:55 GMT Subject: ActivePython 2.0 Release References: <634vusk9nco8qem70ddo43t4qpgid30s1l@4ax.com> <8sp2he01b00@news1.newsguy.com> <8spsoh$csm$1@nnrp1.deja.com> <6p18vs8kf64ubh72rm08b3d0u6dj8qn793@4ax.com> <8t21jl$eg3$1@nnrp1.deja.com> Message-ID: <8t3qth$rov$1@nnrp1.deja.com> In article <8t21jl$eg3$1 at nnrp1.deja.com>, Robin Dunn wrote: > I just started working on it the evening that 2.0 was released, mainly > because it wasn't until then that I could find the conversion script > hiding on my wife's computer (which was mine when Python 1.5.2 was > released and when I did the same for those docs.) The script was > originally done by someone else. I forget who but I think his ID is in > the file somewhere... It's me. In the following page http://www.orgmf.com.ar/condor/pytstuff.html you can find the .chm files of 1.5.2 and patches 1 and 2. I used to update the page as soon as the docs were available but I am moving these days: job, home, country, continent (from Buenos Aires to Madrid) If I get the free time in the following days I might include the 2.0 docs, just for the sake of consistency. BTW, thanks Robin. I must confess I was a bit err... angry at first. But this is an Open Source Community so thanks again. Regards, -Hernan -- Hern?n Mart?nez Foffani hernanf at my-deja.com Sent via Deja.com http://www.deja.com/ Before you buy. From hzhu at yahoo.com Tue Oct 10 16:31:21 2000 From: hzhu at yahoo.com (Huaiyu Zhu) Date: Tue, 10 Oct 2000 20:31:21 GMT Subject: Possible solution for IEEE754? (was Re: numpy, overflow, inf, ieee, and rich comparison) References: Message-ID: There is a miniproposal to use IEEE754 arithmetic near the end of this long article. On Tue, 10 Oct 2000 07:01:40 -0400, Tim Peters wrote: >> [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2 >I'm not enough of a collector of gcc trivia to see at once that egcs-2.91.66 >is exactly the same as egcs-1.1.2, but if you say so ... The gcc version is egcs-2.91.66, provided in the rpm package egcs-1.1.2 # /usr/bin/gcc --version egcs-2.91.66 # rpm -qf /usr/bin/gcc egcs-1.1.2-24 [About why python1.5.2 and python2.0 behaves differently in math.exp] >Can't answer your question. It's a platform-dependent crap shoot, and in >any case is usually entirely due to the libraries you're linking with and >nothing to do with the compiler. Do you have any way to tell which >libraries you're using in the two cases? Can you still get at them? If so, >write a little C program to do the same thing, and see whether exp sets >errno there. Here's the result for the gcc I used to compile Python 2.0 x exp(x) errno errmessage -744.0 9.88131e-324 0 Success -745.0 4.94066e-324 0 Success -746.0 0 34 Numerical result out of range -747.0 0 34 Numerical result out of range So does this mean that Python 1.5.2 that shipped with RedHat was built to link to a different library than the one gcc links to? This sounds extremely unlikely, as the Python rpm does not seem to depend on libc compatibility packages. Any RedHat users out there to test this behavior of gcc? (C code below) > >The CVS history of mathmodule.c is available online, ... >From that, you can see that math_1 has been raising an error on non-zero >errno since Sun Oct 14 12:07:23 1990 (i.e., since the beginning of RPT >(Recorded Python Time)). The 1.5.2 version is revision 2.42. Nothing >interesting about Python's math.exp has changed since then on any platform. Is this the only place that errno is checked for numerical stuff? What about the following change that ignores math range error when math behaves as IEEE 754. #ifdef IEEE754 if (errno != 0 && errno != ERANGE) #else if (errno != 0) #endif These are the only places that uses math_error(): ./Modules/cmathmodule.c:317:math_error(void) ./Modules/cmathmodule.c:341:return math_error(); ./Modules/mathmodule.c:30:math_error(void) ./Modules/mathmodule.c:54:return math_error(); ./Modules/mathmodule.c:71:return math_error(); ./Modules/mathmodule.c:147:return math_error(); ./Modules/mathmodule.c:172:return math_error(); ./Modules/mathmodule.c:201:return math_error(); The remaining problem is only to tell when to define IEEE754, which presumably is a simpler problem. In any case, users who want to do this could just #define IEEE754 somewhere. Is this a good solution? I understand that there are more details to IEEE 754 than this, but wouldn't this be far better than raising an exception when something is approximately zero? Here' the C code to check errno of exp: #include #include #include main () { double x, y; printf(" x exp(x) errno errmessage\n"); for (x=-744; x>-748; x--) { y = exp(x); printf("%.1f %13.6g %3d %s\n", x, y, errno, strerror(errno)); } return 0; } Huaiyu From syam at c544784-a.stcla1.sfba.home.com Sat Oct 7 01:08:10 2000 From: syam at c544784-a.stcla1.sfba.home.com (Syam Pannala) Date: Sat, 07 Oct 2000 05:08:10 GMT Subject: Iterating over a stream with only readline() method [newbie question] Message-ID: [Newbie Alert!!] hi, i have a stream which provides only a readline() method (it can come from a variety of sources including network and i dont want to buffer it so that i can implement readlines()). What is the python idiom for iterating over this stream until it throws EOFError ? thanks, syam To elobarate, if it had readlines(), i would have said for i in stream.readlines(): ..use i .. i want the ..use i.. code not to change very much. Also, i think while 1: try: i = stream.readline() expcept EOFError: break ... use i .. looks very inelegant, even though that is what i have used as the current implementation. thanks again. From andrew.markebo at telelogic.com Thu Oct 19 06:35:59 2000 From: andrew.markebo at telelogic.com (Andrew Markebo) Date: 19 Oct 2000 12:35:59 +0200 Subject: copy protection References: Message-ID: Create an own python interpreter that needs licensing to get started, move some functionality into it that needs extra licenses.. /a From bsdunix at bellatlantic.net Wed Oct 4 00:01:09 2000 From: bsdunix at bellatlantic.net (BSD UNIX) Date: Wed, 04 Oct 2000 04:01:09 GMT Subject: ConfigParser & dots Message-ID: <9YxC5.6365$uO1.355962@typhoon1.ba-dsg.net> Hello all. I'm still getting acquainted to Python, and a little thing I'm working on was going to use fully qualified domain names as sections in a config file, something like: [somehost.example.dom] setting = value The problem I run into is that dots are not allowed in section headers (from ConfigParser.py, line 240): # Regular expressions for parsing section headers and options. Note a # slight semantic change from the previous version, because of the use # of \w, _ is allowed in section header names. __SECTCRE = re.compile( r'\[' # [ r'(?P
[-\w]+)' # `-', `_' or any alphanum r'\]' # ] ) Yet the options can contain dots. This is using v1.5.2, however. Is this going to be changed (or is it already)? What is the reasoning behind disallowing dots in the section headers? Thanks in advance, Bill bsdunix at bellatlantic.net From the_brain at mit.edu Sun Oct 1 17:37:28 2000 From: the_brain at mit.edu (Alex) Date: 01 Oct 2000 17:37:28 -0400 Subject: New Python development process (SourceForge considered Harmful?) References: <8qss6t$7i$1@saltmine.radix.net> <8erA5.37729$dZ2.13446193@news3.rdc1.on.home.com> Message-ID: I looked for an instance of this on the SourceForge pages, but didn't find one. Can you post a URL for a page that exhibits this behaviour? Alex -- Speak softly but carry a big carrot. From keisari_ at hotmail.com Thu Oct 26 12:52:20 2000 From: keisari_ at hotmail.com (joonas) Date: Thu, 26 Oct 2000 19:52:20 +0300 Subject: TypeError References: <39F83ED4.57ADB649@hotmail.com> Message-ID: <39F86144.4CB2C735@hotmail.com> I also tried to convert first into "float" and "int" but i gave me "TypeError: object cant be converted to float" So I still dont know how to convert it into number. Joonas. joonas wrote: > > I get error, "TypeError: bad operand type(s) for -" > > What could be wrong. > > Joonas. From djberg96 at my-deja.com Fri Oct 27 16:12:49 2000 From: djberg96 at my-deja.com (Daniel Berger) Date: Fri, 27 Oct 2000 20:12:49 GMT Subject: Newbie question - where is wxpython.wx module? Message-ID: <8tcnjp$7to$1@nnrp1.deja.com> Hi all, NT 4.0, sp 5, using ActiveState Python (latest release). Downloaded and installed wxpython. But, I get an error message that says it cannot locate module wxPython.wx. I don't find that file anywhere on the system. Please help. Thanks. Dan -- In the immortal words of Socrates, "I drank what?" Sent via Deja.com http://www.deja.com/ Before you buy. From aahz at panix.com Mon Oct 9 12:48:16 2000 From: aahz at panix.com (Aahz Maruch) Date: 9 Oct 2000 09:48:16 -0700 Subject: Running Python on SMP machine References: <8rrks8$a1a$1@panix3.panix.com> <8rrrg00nle@news2.newsguy.com> Message-ID: <8rsssg$lcs$1@panix3.panix.com> In article <8rrrg00nle at news2.newsguy.com>, Alex Martelli wrote: >"Aahz Maruch" wrote in message >news:8rrks8$a1a$1 at panix3.panix.com... >> In article , >> Erno Kuusela wrote: >>>>>>>> "William" == William Park writes: >>> >>> | How do I take advantage of a SMP (2 CPU) machine? >>> >>>use separate processes. >> >> Why? Why not use threads? > >Perhaps because of Python's single interpreter lock...? If all >your threads are running Python bytecode, I do not think you will >ever be using the second CPU (haven't tried it, but this seems >to be the effect of the current architecture as I understand it). That's the Global Interpreter Lock. But my experience is that frequently the overhead of synchronizing between two separate processes overwhelms the payback you get from actual use of SMP -- that trick works best if the two processes do no synchronization. Furthermore, it's not that hard to beat the GIL. If any significant amount of blocking I/O takes place, you'll benefit from threads. In addition, it's certainly possible to create C extensions for computation that release the GIL. Overall, it's almost always worth trying threading first. [What I sometimes wonder is, how/why did *I* get to be the threading champion on c.l.py? It's not like I use threads very much, nor am I an expert on them... ;-)] -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "[I have a] windmill fetish." --Darkhawk From gsar at ActiveState.com Sun Oct 15 03:57:22 2000 From: gsar at ActiveState.com (Gurusamy Sarathy) Date: Sun, 15 Oct 2000 00:57:22 -0700 Subject: [OFF-TOPIC] What's wrong with David T. Grove? Message-ID: <200010150757.AAA09084@smtp3.ActiveState.com> It has been brought to my attention that David T. Grove has yet again been venting his peculiar brand of venom and FUD about ActiveState and about my personal integrity. I normally don't respond to his lies and insinuations because they are all blatantly and obviously false. But since the Python crew probably aren't aware of his deceitful ways, I feel compelled to point out a few things. Here are some facts: 1. David T. Grove was employed by ActiveState as a telecommuting contractor about two-and-a-half years ago. He was laid-off (for reasons I'm not aware of, but can probably find out easily) before I started working for ActiveState in December 1998. 2. David T. Grove has never contributed anything to the Perl community in terms of written code. Not a single patch to the Perl sources, not a single line of Perl on CPAN, not even anything on Usenet (apparently) that I can find from a quick search of www.deja.com. For all his chatter about his "insanely great" IDE, the code is not freely available. 3. David T. Grove has a history of abusing the charter of the Perl mailing lists, newsgroups, and other media such as The Perl Journal. [*] He has posted various unsubstantiated and false claims to the perl5-porters list in the past. He tried to sneak in clearly off-topic advertisements into the comp.lang.perl.announce group. He tried to deceitfully (and unsuccessfully) introduce an advertisement that pretended to be a regular article in the Perl Journal. He enjoys the dubious distinction of having been banned from the Perl advocacy mailing list for being arrogant and off-topic. That's only a small sample of his notoriety. 4. ActiveState has spent countless man-hours in improving Perl and Python since I joined the company in December 1998. All of these changes to the Perl and Python core have been contributed back into the respective communities. For more info on this, see: http://ActiveState.com/Corporate/About_ActiveState/Open_Source_Community.html 5. ActiveState is still the only company I know where one can hack the Perl source code and get paid for it. If you know otherwise, I'd be happy to know. 6. Nobody but me decided when Perl 5.6 would ship, and I decided to ship it when I considered it ready enough and timely enough. As "pumpking", this was my prerogative, and I exercised it fairly and squarely. If anyone says otherwise, they're either wrong or lying. Here are some personal opinions: 1. David T. Grove is a loon. Ignore him. 2. David T. Grove is also an incompetent programmer. I know this because I had to fix the lousy code he wrote for ActiveState. 3. If I knew or even suspected that ActiveState has less than honorable intentions about Perl or Python, I would have bailed a long time ago. 4. I'm sure there are easier ways to make money than subverting open source projects. If ActiveState didn't really care for the success of Perl and Python, the company would be in a different business altogether. 5. If Perl or Python lose, ActiveState loses too. In summary, be very wary of David T. Grove. He usually states his lies and deceptions as if they were facts, and insists on wasting everyones time in this way. A quick search on Google or Deja should tell you all you need to know about him. Please accept my apologies for the lack of python-related content in this message--I find it impossible to watch quietly while this individual tries to destroy another community of peers. Good luck with Python, Sarathy gsar at ActiveState.com [*] Some quick links: P5P abuse: http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2000-04/msg00259.html http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/1999-05/msg00463.html http://www.xray.mpe.mpg.de/cgi-bin/w3glimpse/perl5-porters?query=David+Grove&errors=0&case=on&maxfiles=100&maxlines=30 CLPA abuse: http://x76.deja.com/=dnc/getdoc.xp?AN=607620761&CONTEXT=971588747.899350574&hitnum=22 TPJ abuse: http://www.mail-archive.com/advocacy%40perl.org/msg00617.html From steinar at cc.uit.no Fri Oct 27 05:28:31 2000 From: steinar at cc.uit.no (Steinar Traedal--Henden) Date: Fri, 27 Oct 2000 11:28:31 +0200 Subject: HP-UX Install References: Message-ID: <39F94ABF.E28B0569@cc.uit.no> Chris wrote: > I'm trying to get Python 2.0 installed on HP-UX. Anyone have some reliable > instructions on doing so? > > It seems to work well except for some thread errors towards the end of "make > test" (and may have been in the make too). > > PYTHONPATH= ./python -tt ./Lib/test/regrtest.py -l > pthread_mutex_init: Invalid argument > /bin/sh: 11021 Memory fault(coredump) > gmake: [test] Error 139 (ignored) > PYTHONPATH= ./python -tt ./Lib/test/regrtest.py -l > pthread_mutex_init: Invalid argument > /bin/sh: 11023 Memory fault(coredump) > gmake: [test] Error 139 (ignored) > > How can I correct the pthread issue? > > Any help appreciated, > Chris After reading the bug report at sourceforge (see: http://sourceforge.net/bugs/?func=detailbug&bug_id=110665&group_id=5470 ) and following the work around there. It seems to work fine. What I did. -- Replacing all pthread_create in the configure file with __pthread_create_system and then adding -lcl to the Modules/Makefile: LIBS= -lpthread -lnsl -ldld -lcl Then at leaste the "make test" doesn't core dumop anymore. Oh, I used the --without-gcc option to the configure since I don't have an updated version of gcc. (Another work aound would be waitng for the python 2.0 binaries to appear at http://hpux.connect.org.uk/ ) Cheers Steinar From arildh at arildh.stud.cs.uit.no Thu Oct 12 05:39:51 2000 From: arildh at arildh.stud.cs.uit.no (Arild Hansen) Date: Thu, 12 Oct 2000 11:39:51 +0200 Subject: Redhat 7.0, python 2.0b2 and tcl-8.3.1-46 problem ... In-Reply-To: <8s2glp$rej$1@nnrp1.deja.com> References: <8rt2la$1rq$1@news.uit.no> <8s2glp$rej$1@nnrp1.deja.com> Message-ID: Actually I tried to make a sym link, but without luck. So I guess I'll have to wait for a RedHat 7.0 rpm release before continuing my work. In the mean time I'll just sit here waiting :) Arild Hansen On Wed, 11 Oct 2000, David Hughes wrote: > I had a similar problem installing scotty, it was looking for > libtcl8.0.so but all I had was /usr/lib/libtcl8.3.so, all I did was > symlink the 8.3 to 8.0 and it worked fine i.e. > ln -s /usr/lib/libtcl8.3.so /usr/lib/libtcl8.0.so > > HTH > > In article <8rt2la$1rq$1 at news.uit.no>, > "Arild Hansen" wrote: > > Hello, > > > > I try to install python 2.0b2 on a Redhat 7.0 distribution. When I > installed > > Redhat 7.0 I selected everything related to the Development sections > > (packages). When trying to install Python 2.0b2 everything works > fine. When > > trying to install expat-1.1-1.i386.rpm everything works fine, BUT > when I try > > to install Tkinter-2.0-8.0.1.i386.rpm I get the following errors: > > > > error: failes dependenies: > > > > libtcl8.0.so is needed by Tkinter-2.0-8.0.1 > > > > libtk8.0.so is needed by Tkinter-2.0-8.0.1 > > > > So I install Tcl/Tk version 8.0.5 (tcl-8.0.5-35.i385.rpm) but then I > get > > several conflicts with the already installed (i.e. installed under the > > installation of Redhat 7.0) tcl package being version tcl-8.3.1-46. > In other > > words, my system contains a new version of tcl that is not compatible > / > > recognized by python 2.0 beta 2 and when I try to install an older > version > > of tcl I am not allowd (yes, I know I can try rpm -U --force but this > > conflicts with other packages depending on the new version of tcl). > So, how > > do I get python 2.0 beta 2 to work with tcl-8.3.1-46 ? Thx for all > help, > > > > Arild Hansen > > > > > > -- > David Hughes, > System Administrator, > Highwired.com. > > > Sent via Deja.com http://www.deja.com/ > Before you buy. > From junaftnoon at nospamplzyahoo.com Tue Oct 31 14:14:23 2000 From: junaftnoon at nospamplzyahoo.com (June Kim) Date: Wed, 1 Nov 2000 04:14:23 +0900 Subject: Some strange behaviours of default arguments Message-ID: <8tn5n7$2s5$1@news.nuri.net> def add(a, list=[]): list.append(a) print list (I think "list" is a local variable, and every time the function is called without the optional argument, the variable is initiated with a new object, blank list -- but Python 2.0 doesn't work that way) >>> add(3) [3] >>> add(5) [3,5] Why is the local variable "list" NOT initialized with the default value every time I call it? Can anyone gimme some, if any, reasonable explanation? Thanks in advance, June From jaspervp at hotmail.com Wed Oct 11 18:40:35 2000 From: jaspervp at hotmail.com (jasper van putten) Date: Wed, 11 Oct 2000 22:40:35 +0000 Subject: PyQt References: <39E46C25.67DD50A7@montana.com> Message-ID: <39e4d028$0$28370@reader3> bowman wrote: > I'm trying to build PyQt with 2.0/1 on a Mandrake 7.1 installation. sip > builds and installs, and PyQt itself builds for an hour or so, > ultimately failing with: > > make[3]: Entering directory `/usr3/python/PyQt-2.0/qt' > (cd /tmp; > PYTHONPATH=/usr/local/lib/python2.0/site-packages:/usr/local/lib/python2.0/site-packages > python -c "import qt") > Traceback (innermost last): > File "", line 1, in ? > File "/usr/local/lib/python2.0/site-packages/qt.py", line 16, in ? > import libqtc > ImportError: /usr/local/lib/libsip.so.3: undefined symbol: > PyObject_Init > > Anyone know what this is about? > > tia. I had a simulair problem. it has something to do with libsip.so.3 which cannot be found. I solved it by copying libsip.so.3 from /usr/local/lib/ to /usr/lib/ Jasper van Putten From cobrien at Radix.Net Wed Oct 25 20:13:10 2000 From: cobrien at Radix.Net (Cary O'Brien) Date: 25 Oct 2000 20:13:10 -0400 Subject: SysV IPC Interface? Message-ID: <8t7sum$p84$1@saltmine.radix.net> Does anyone know of an interface to the (perhaps slightly retro) SysV IPC system calls? I.E. shared memory , message queues, and semaphores? I know there are more um- modern ways to do IPC, but, ok, I'll admit it, I'm doing more python and I miss SysV IPC. Sniff. Thanks in Advance, -- cary From teep at inet.co.th Sun Oct 1 22:18:40 2000 From: teep at inet.co.th (Prateep Siamwalla) Date: Mon, 2 Oct 2000 09:18:40 +0700 Subject: PyGimp Resources? References: <39D7DF4F.6AFABDC3@att.net> Message-ID: <8r8ra5$qaa$1@news.inet.co.th> I haven't tried this out myself, but would gdchart do what you need? http://www.fred.net/brv/chart/ there are python bindings at http://athani.pair.com/msteed/software/gdchart/index.html HTH teep Joseph C. Kopec wrote in message news:39D7DF4F.6AFABDC3 at att.net... > Can anyone point me at online resources regarding PyGimp (in addition to > James Henstridge's site with the PyGimp download). I am not aiming to > do anything fancy -- just generate some graphs dynamically for use on a > web site. Thanks in advance. From kentsin at poboxes.com Tue Oct 31 23:57:11 2000 From: kentsin at poboxes.com (kentsin at poboxes.com) Date: Wed, 01 Nov 2000 04:57:11 -0000 Subject: URLLIB and PROXY Message-ID: <8to7r7+654b@eGroups.com> The urllib of python 2.0 does not like the MS proxy. In my environment, the proxy is 192.168.83.3:80. I have the following in my win98 box : autoexec.bat set http_proxy=http://192.168.83.3:80 I try to load a page with import urllib a = urllib.urlopen('http://www.python.org/') print a.read() This only works once but return null on all other cases. a.headers is : >>> print a.headers Server: Microsoft-IIS/4.0 Date: Wed, 18 Oct 2000 06:40:54 GMT Proxy-Authenticate: NTLM How could I debug this? Rgs, Kent Sin From moshez at math.huji.ac.il Tue Oct 31 09:33:35 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Tue, 31 Oct 2000 16:33:35 +0200 (IST) Subject: PythonLabs Team Moves to Digital Creations In-Reply-To: <14846.53905.194421.965357@anthem.concentric.net> Message-ID: On Tue, 31 Oct 2000, Guidoferatu van Rossumati wrote: > > >>>>> "MO" == Mikael Olofsson writes: > > >> Yes, the PSU, which is completely different than the SPU, the > >> Secret Python Underground. Word has it that if they both > >> existed, they would not get along. > > MO> Not to mention the Secret Underground of Python... > > Or the Python Underground Society. Wasn't the People's Front of Python the one that we're not in? -- Moshe Zadka -- 95855124 http://advogato.org/person/moshez From akuchlin at mems-exchange.org Tue Oct 17 15:25:55 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 17 Oct 2000 15:25:55 -0400 Subject: copy protection References: Message-ID: <3dwvf7p8vw.fsf@kronos.cnri.reston.va.us> "Max M. Stalnaker" writes: > If I were doing this, I would produce a binary python with these features, > which I believe is allowed by the license. Aside from the unique > application number, it would optionally encrypt the pyc with a special > language key that is kept secret. In the present product, there is a Zope did something similar, back in the days before the code was released. Products could be shipped as encrypted .pyc files; see lib/python/App/Extensions.py in the Zope code, where it does: elif p[-4:]=='.pyp': prod_id=split(module, '.')[0] data=zlib.decompress( rotor.newrotor(prod_id +' shshsh').decrypt(open(p,'rb').read()) ) execsrc=compile(data, module, 'exec') m={} exec execsrc in m That code probably isn't directly applicable to your situation. Instead, you would probably write an import hook using imphooks.py that automatically decrypts .pyp files with some key, the key being derived down in C code so it's a bit more difficult to reverse engineer it, and uses something a bit stronger than the rotor module. --amk From ge at nowhere.none Tue Oct 3 08:19:58 2000 From: ge at nowhere.none (Grant Edwards) Date: Tue, 03 Oct 2000 12:19:58 GMT Subject: how do I listen on a socket without sucking up all the CPU time? References: <39d971f3_1@corp.newsfeeds.com> Message-ID: In article <39d971f3_1 at corp.newsfeeds.com>, Joshua Muskovitz wrote: >I've got a worker thread which listens on an ICMP (ping) socket for replies >to pings that I send out (on the same socket from a different thread). All >of this code runs fine, but the socket is set to be non-blocking, so >recvfrom() returns immediately most of the time, and this thread runs like >mad, consuming all the available CPU time. Why is the socket set to non-blocking? Why not set it to blocking so that the thread blocks until there's data to read? -- Grant Edwards grante Yow! Th' MIND is the Pizza at Palace of th' SOUL visi.com From hove at phys.ntnu.no Fri Oct 13 14:39:12 2000 From: hove at phys.ntnu.no (Joakim Hove) Date: 13 Oct 2000 20:39:12 +0200 Subject: File tests in Python References: <8s7jvh$s9n$1@panix6.panix.com> Message-ID: aahz at panix.com (Aahz Maruch) writes: > import types > if type(foo) == types.ListType: Wow - it's all in there - Thanks again. Joakim -- === Joakim Hove www.phys.ntnu.no/~hove/ ====================== # Institutt for fysikk (735) 93637 / E3-166 | Sk?yensgate 10D # # N - 7491 Trondheim hove at phys.ntnu.no | N - 7030 Trondheim # ================================================ 73 93 31 68 ======== From donn at u.washington.edu Tue Oct 24 12:43:15 2000 From: donn at u.washington.edu (Donn Cave) Date: 24 Oct 2000 16:43:15 GMT Subject: fileinput module doesn't work to spec? References: <0s8bvs0n0e4d0t462mqlknha2ekj7grm22@4ax.com> Message-ID: <8t4e73$huj4$1@nntp6.u.washington.edu> Quoth Dale Strickland-Clark : | According to the spec, the fileinput module should support overwriting | of the input file after renaming it to preserve a backup. (Extract | below.) | | It doesn't seem to work. | | 1. The input file is overwritten with an empty file. | 2. No backup is taken | 3. stdout is written to the console in stead of the input (now output) | file ... | # Tab delimited file to basic HTML Table converter | | import sys, fileinput | | def genCell(cell): | if cell: | if cell[0] == '"': | cell = cell[1:-1] | cell = cell.strip() | if not cell: | cell = ' ' | return ['', cell, ''] | | def genRow(line): | row = [''] | for cell in line.split('\t'): | row = row + genCell(cell) | row.append('\n') | return row | | table = [] | for line in fileinput.input(sys.argv[1:], inplace = 1): | table = table + genRow(line) | | | print ''.join(table) You're mainly missing the iterative aspect of this system. It supports multiple input files, and it sets up and tears down this redirection all by itself. After the last file, output goes back to stdout - it's a feature. If you want to write to the current input/output file, you have to catch it while it's still current, not after all the input has been read. In your case, try # table = [] for line in fileinput.input(sys.argv[1:], inplace = 1): hline = genRow(line) print string.join(hline, '') There is a backup file, during the execution of that loop. If you want the backup file afterward, supply a third argument ("backup") with the suffix string. Donn Cave, donn at u.washington.edu From wware at world.std.com Sun Oct 29 08:08:07 2000 From: wware at world.std.com (Will Ware) Date: Sun, 29 Oct 2000 13:08:07 GMT Subject: DLL-building griefs Message-ID: I'm trying to build a DLL (previously using Cygwin, now using Mingw) for a Python module. My batch file looks like this: gcc -Ic:\Python20\Include -c foo.c echo EXPORTS > foo.def nm foo.o | grep " T _" | sed "s/.* T _//" >> foo.def dllwrap --def foo.def --base-file foo.base --output-exp foo.exp \ --dllname foo.dll foo.o During the execution of dllwrap.exe, I get complaints that various functions are undefined: PyArg_ParseTuple, Py_BuildValue, and Py_InitModule4. As a result, the DLL never gets built. My experience with Unix while building .so files has been that the linker is willing to assume that these references would be resolved when the .so file was invoked by, say, being imported by Python. Is it possible for references to remain unresolved during the build process in Windows, or is this a fatal flaw in everything Windows-ish? -- # - - - - - - - - - - - - - - - - - - - - - - - - # Resistance is futile. Capacitance is efficacious. # Will Ware email: wware @ world.std.com From bill at libc.org Sat Oct 28 01:42:15 2000 From: bill at libc.org (Bill Anderson) Date: Sat, 28 Oct 2000 11:42:15 +0600 Subject: Python in RedHat 7 References: <8t6bku$13s$1@lola.ctv.es> Message-ID: <20001028.114215.1253207672.18601@locutus.noreboots.com> In article , "Ken Kinder" wrote: > Unfortunately, that doesn't really fix the problem. If you use the > stable compiler on Red Hat 7, then what it compiles is binary > incompatible with the rest of the system. You'd have to recompile > *everything* If I were you, I'd just declare Red Hat 7 to be pre-alpha > software and not use it. Red Hat releases are generally unstable until > about .2 series. 7.2, should therefor be stable. Are you talking about kgcc as the 'stable version' of the compiler? That would be egcs-2.91.66. IME (as in , I have _done_ it), that version has been generating compatible binaries just fine, fo rboth the RH7 systems I have, and the RH6.x systems. You are certainly welcome to your opinion regarding teh quality of RH .0 rleeases, one I don't entirely agree/disagree with. But you should refrain from making statements about various aspects of it if you don't know from use. You can use kgcc or the gcc that redhat uses, and you system works just fine. I know, as I have _done_ this. Hell, I'm writing this on a system that has binaries compiled from either compiler. Reading the RELEASE-NOTES reveals how to use the compiler of your choice. No need for downloading new rpms, or building the compiler yourself unless you _want_ to. kgcc is installed by default. From bwinton at tor.dhs.org Fri Oct 13 23:47:59 2000 From: bwinton at tor.dhs.org (Blake Winton) Date: Sat, 14 Oct 2000 03:47:59 GMT Subject: What is Python? References: <8q5rgv$7to$1@nnrp1.deja.com> <39C6DF06.FF7F8A74@engcorp.com> <39C70642.D6CBF93A@alcyone.com> <39C710F7.4E72D963@seebelow.org> <39C86059.2F644D70@engcorp.com> <39C867B5.DFF9FFD3@seebelow.org> <39D02F19.2A13F38C@my.signature> <39D1259E.2D6668B6@san.rr.com> <39D1611A.FB67931D@san.rr.com> <8qt8fb$2og$1@newshost.accu.uu.nl> Message-ID: On 27 Sep 2000 16:49:47 GMT, Martijn Faassen wrote: >Let's take a completely regular verb, to program: > >I program >you program >he programs >we program >you program >they program I thought it was: I architect you program he hacks ;) Later, Blake. -- 9:40pm up 52 days, 21:07, 2 users, load average: 0.02, 0.09, 0.07 From sands2 at home.com Sun Oct 1 22:19:34 2000 From: sands2 at home.com (O. Scott Sands) Date: Mon, 02 Oct 2000 02:19:34 GMT Subject: ATLAS for NUMPY and/or MatPy Message-ID: <39D7F0B7.62754640@home.com> Is there any move afoot to use ATLAS (c.f. http://www.netlib.org/atlas/index.html) in the NUMPY or MatPy? I've achieved a factor of 6 speedup in matrix multiplication using ATLAS over non-optimized libraries under Octave using PCs running Linux. -- O. Scott Sands o.s.sands at ieee.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From dirkl at home.com Mon Oct 23 00:25:57 2000 From: dirkl at home.com (Dirk Leas) Date: Mon, 23 Oct 2000 04:25:57 GMT Subject: MySQLdb binaries for Windows References: <8r2tpb$fhu$1@nnrp1.deja.com> Message-ID: Now that Python 2.0 is official, any ETA on a Win32 binary for 0.2.[1|2]? That's the only thing that's keeping me from moving to 2.0... You'd be 'da Man as usual!!! TIA, D "Gerhard Haering" wrote in message news:slrn8u99rn.27j.haering at sunhalle4.informatik.tu-muenchen.de... > I have moved my build of MySQLdb for Windows to the following location: > > http://home.t-online.de/home/err666/ > > It's still version 0.2.1. Perhaps a 0.2.2 build will be there, rsn. It's > all for Python 1.5.2. Sorry, I do not bother with Python 2.0 until the > final is released, which should also be rsn :-) > > Gerhard Haering From jurgen.defurne at philips.com Wed Oct 4 05:05:57 2000 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Wed, 4 Oct 2000 11:05:57 +0200 Subject: Inefficiency of __getattr__ Message-ID: <0056900012482207000002L072*@MHS> I think that with a good statically typed language, you can eliminate a whole lot of run-time checks. This means less and faster code. I think that is the most principal reason behind this, because you can debug and test a dynamically typed language as good as a statically typed one. Jurgen kragen at dnaco.net@SMTP at python.org on 04/10/2000 07:49:04 Sent by: python-list-admin at python.org To: python-list at python.org@SMTP cc: Subject: Re: Inefficiency of __getattr__ Classification: OK, so you agree that silent coercions cause problems in some cases in C++, some of which cases are built into the language. So what's the advantage of static typing over dynamic typing? Does it help you catch bugs, and if so, which ones? -- Kragen Sitaker Perilous to all of us are the devices of an art deeper than we ourselves possess. -- Gandalf the Grey [J.R.R. Tolkien, "Lord of the Rings"] -- http://www.python.org/mailman/listinfo/python-list From jasonic at nomadicsltd.com Sat Oct 21 14:52:09 2000 From: jasonic at nomadicsltd.com (Jason Cunliffe) Date: Sat, 21 Oct 2000 14:52:09 -0400 Subject: VisAd Python anyone? Message-ID: Hello Wondering if anyone here has experience with VisAd and Python /JPython? I refer to http://www.ssec.wisc.edu/~billh/visad.html and in particular http://www.ssec.wisc.edu/~billh/README.python VisAD is a Java component library for interactive and collaborative visualization and analysis of numerical data. The name VisAD is an acronym for "Visualization for Algorithm Development". The system combines: The use of pure Java for platform independence and to support data sharing and real-time collaboration among geographically distributed users. Support for distributed computing is integrated at the lowest levels of the system using Java RMI distributed objects. A general mathematical data model that can be adapted to virtually any numerical data, that supports data sharing among different users, different data sources and different scientific disciplines, and that provides transparent access to data independent of storage format and location (i.e., memory, disk or remote). The data model has been adapted to netCDF, HDF-5, FITS, HDF-EOS, McIDAS, Vis5D, GIF and JPEG file formats. A general display model that supports interactive 3-D, data fusion, multiple data views, direct manipulation, collaboration, and virtual reality. The display model has been adapted to Java3D and Java2D and used in an ImmersaDesk virtual reality display. Data analysis and computation integrated with visualization to support computational steering and other complex interaction modes. Support for two distinct communities: developers who create domain- specific systems based on VisAD, and users of those domain-specific systems. VisAD is designed to support a wide variety of user interfaces, ranging from simple data browser applets to complex applications that allow groups of scientists to collaboratively develop data analysis algorithms. Developer extensibility in as many ways as possible. The visad.python package defines a Python-based language for using VisAD. The classes in this package are: JPythonEditor - an editor for VisAD Python scripts that can be incorporated in application programs JPythonFrame - a program and GUI for editing and running VisAD Python scripts JPythonMethods - a set of functions for accessing VisAD that can be called from VisAD Python scripts Jason ________________________________________________________________ Jason CUNLIFFE = NOMADICS['Interactive Art and Technology'].DesignDirector From sabren at manifestation.com Sat Oct 7 01:37:03 2000 From: sabren at manifestation.com (Michal Wallace) Date: Sat, 7 Oct 2000 01:37:03 -0400 (EDT) Subject: Code obfuscation / decompilers? (fwd) In-Reply-To: <39deb1ab_1@corp.newsfeeds.com> Message-ID: On Sat, 7 Oct 2000, Joshua Muskovitz wrote: > As I said in my original post, "the algorithm originates in older code > written in C." I had meant that phrase to imply the issue of my installed > base, but clearly it was too subtle. Next time, I'll be more verbose. Josh, decompyle lives at http://goebel-consult.de/decompyle/ I know you've already ported the code for your thing to python.. But if you're worried about the bytecode, maybe you ought to consider just wrapping your old C module as extension module. It's not hard. Just download the python sources so you have all the .h files, and read the docs for extending and embedding.. I was able to write an extenion module in C without really knowing anything about C, so if you already are used to C, it should be a snap. Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From -$Paul$- at verence.demon.co.uk Fri Oct 27 14:40:14 2000 From: -$Paul$- at verence.demon.co.uk (Paul Wright) Date: 27 Oct 2000 18:40:14 -0000 Subject: Pretty report printing References: <39F93665.BA3945E4@ses.curtin.edu.au> Message-ID: <8tci6e$63e$1@verence.demon.co.uk> In article <39F93665.BA3945E4 at ses.curtin.edu.au>, Nick Bower wrote: [someone else said:] >> AFAIK, a tool called latex2pdf comes with the standard LaTeX >> installation (at least the RPM I downloaded had it). It should be >> pretty easy to generate the LaTeX and then run latex2pdf on it. >> > >i found this bitmapped fonts on my distros (mandrake and redhat), which >is unacceptable. I had more luck with dvi2pdfm which didn't rasterize >the text. do a search on freshmeat for it. ps2pdf bitmaps the fonts (which I believe means you can't copy the text: I tried this on Linux Acrobat reader and that's what happens). pdfLaTeX doesn't: it generates PDFs directly from LaTeX source, and is generally a Good Thing. It's possible to stay compatible with ordinary LaTeX, too, in those places where you need to do something different for each, can test whether you're running ordinary LaTex or pdfLaTeX. Here are some useful URLs: http://www.dgp.toronto.edu/~mac/dgp/tex_to_pdf.html http://www-h.eng.cam.ac.uk/help/tpl/textprocessing/makingWWWdocs.html -- ----- Paul Wright ------| 418 I'm a teapot -paul.wright at pobox.com--| http://pobox.com/~pw201 | From phrxy at csv.warwick.ac.uk Mon Oct 9 14:19:40 2000 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Mon, 9 Oct 2000 19:19:40 +0100 Subject: doubling slashes in a string In-Reply-To: <8rs9dc0143f@news2.newsguy.com> References: <39de8a48_3@corp.newsfeeds.com> <8rmvbo02dfo@news1.newsguy.com> <8rs9dc0143f@news2.newsguy.com> Message-ID: On Mon, 9 Oct 2000, Alex Martelli wrote: > wrote in message news:uy9zytl1w.fsf at cs.uu.nl... > [snip] > > >> newname = string.join(string.split(oldname,"\\"), "\\\\") > [snip] > > AM> newname = oldname.split(r'\').join(r'\\') > > AM> newname = oldname.replace(r'\', r'\\') > > > > AM> would strike some of us as being even better yet!-) > > > > It would strike most of us as being particularly bad, especially those who > > would try it. (A string cannot end in an odd number of \, not even a raw > > Whoops! You're right. I had never noticed this lexical peculiarity, > and now I wonder about the rationale for it -- since backslashes play > no special role within a rawstring, why the peculiarly specific prohibition > about having an odd number of them _at the end_...? Because you need to be able to quote quotes! I got caught out by the exact same thing in Perl. I guess there are some ugly things you can't avoid in any language. (yes Alex, Hofstadteresque again) > Oh well, then I guess my above-quoted suggestions will have to be reworded: > > newname = oldname.split('\\').join(r'\\') > newname = oldname.replace('\\', r'\\') [...] John From aleaxit at yahoo.com Mon Oct 9 04:39:04 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 9 Oct 2000 10:39:04 +0200 Subject: super - is (should) it (be) a reserved word? References: Message-ID: <8rs0hc0rkj@news2.newsguy.com> "Michal Wallace" wrote in message news:mailman.971064623.25775.python-list at python.org... > On Mon, 9 Oct 2000, Greg Ewing wrote: > > > Alex Martelli wrote: > > > > > > self.__class__.__bases__[0] satisfies this request, I think. > > > > Not when there is more than one level of inheritance > > involved. The class you want to find the base class > > of isn't the class of self, it's the class where the > > currently executing method was defined, and there's > > currently nothing in Python that keeps track of that. > > Why do you need that? Calling a method of a class > climbs the hierarchy for you, all the way up to where > the method was first defined or last overridden. The purpose of the request for "super" is, presumably, to help those typical overrides that may also need to call the method version they are overriding as a part of their operation. Assuming single inheritance (maybe because of a Smalltalk background by the requester[s]), it is then considered handier to call super.method(foo) than to have to know the name of the class whose method is being overridden in order to call Baseclass.method(self,foo). If "super" needs to indicate a different class each time it's named, depending on the method in which it is named, then the problem looks difficult indeed. Is this the exact Smalltalk semantic? I was not aware of that -- I thought that "super", like in Java, would rather indicate the immediate superclass. If there's such a subtle and treacherous semantic nuance between 'super' in Smalltalk and in Java, then this may be a reason to avoid mimicking it in Python -- can't make both camps happy, after all. As for "the class that defined the method (which may be a base class of the class of which im_self is an instance)", this is exactly the definition (3.2 in the Reference Manual) of the im_class of the method object. Therefore, within method foo, foo.im_class.__bases__[0] should be able to play the same role as I envisaged, above, for self.__class__.__bases__[0]. It should still be possible to write a super() function that will return such a class -- by finding out what method it's been called from, raising an exception if not called from a method, etc. And a mixin approach, such as I suggested, might still artificially synthesize (and presumably cache) an object of that class to be returned - if, that is, super() can be written. Trying to put this in practice, the first difficulty is that one can easily get to the code-object (via the traceback and frame objects), but not from that back to the method-object (and thus via im_class to the class whose 'super' is actually of interest). Am I having a spot of localized blindness, or is it in fact a problem...? Alex From aleaxit at yahoo.com Thu Oct 12 16:38:27 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 12 Oct 2000 22:38:27 +0200 Subject: newbie question: temporarily store data References: Message-ID: <8s59nn1c39@news2.newsguy.com> "Bryan BZ" wrote in message news:T9nF5.148$B_2.11385 at iad-read.news.verio.net... > I am looking to store data read in from a file into a cache to dump at a > later time into a database. Should I use the "pickle" or "shelve" > functions? If not, any suggestions? The so-called "cache" must be another file? What is the advantage of reading it from somewhere to temporarily write somewhere else...? Anyway, if there is structure in the data that you want to preserve, cPickle with the binary option may be fastest; else, a simple .write to the so-called "cache" (and then a .read back from it again later), e.g. if it's just a huge string that you want to stash away somewhere. Alex From DavidA at ActiveState.com Sat Oct 21 00:53:51 2000 From: DavidA at ActiveState.com (David Ascher) Date: Fri, 20 Oct 2000 21:53:51 -0700 (Pacific Daylight Time) Subject: large file support In-Reply-To: <8sqn2l$ec$1@ncar.ucar.edu> Message-ID: On 21 Oct 2000, Fred Clare wrote: > How does one read large files into Python? I have a 4 gigabyte > file on an SGI (that has over 30 GB main memory), but when I use > > f = open("file","rb") > s = f.read() > > on this file, I get "MemoryError". Trying the I/O from the os module > produces the same result. In fact I get the MemoryError even when > trying to read 2GB files. When I run configure before building python, it > indicates that large file support *is* enabled. I'm not sure what the status of large file support is on SGI's. One thought, however, is that you may be better off using mmap to deal with the file, as the OS can be much more efficient about what parts of the data to load from disk. Some docs on mmap are available: http://www.activestate.com/Products/ActivePython/Docs/lib/module-mmap.html (I would point to the pythonlabs page, but it appears to be temporarily down). --david ascher From tratt at dcs.kcl.ac.uk Sat Oct 28 14:55:07 2000 From: tratt at dcs.kcl.ac.uk (Laurence Tratt) Date: Sat, 28 Oct 2000 19:55:07 +0100 Subject: Public Domain Python References: <39F65DE7.1DF35813@san.rr.com> <8tevmn$3re$1@srv38.cas.org> Message-ID: <39FB210B.A3904737@dcs.kcl.ac.uk> lvirden at cas.org wrote: [Courageous] > :I disagree; once you have granted someone the right to create a derived > :work, and that derived work exists, you have no legal ability to withdraw > :their ability to continue to own/sell their derived work. > > If that were the case, then a product could never have a license change - > but they change all the time. Most license that I've read in fact address > the issue of future changes to the license; if GPL/OpenSource/BSD/etc. do > not, then they probably should. > > What seems to make sense logically is that one can chance the license on > anything that has not yet been distributed, which would include a new > release of a product (even if said new release had, as the only change, > the new license). I think the generally accepted take on this is that essentially a license - unless it has a "this can be revoked at any time" type clause - applies in perpetuity to a specific version of a program. Later versions may have different licences but the old versions licenses still apply to those old versions. This has allowed eg the OpenSSH project to get hold of an old version of SSH which had an open license and make their own version forked from that whilst newer versions of SSH are commercial. Laurie From sabren at manifestation.com Sun Oct 8 00:19:51 2000 From: sabren at manifestation.com (Michal Wallace) Date: Sun, 8 Oct 2000 00:19:51 -0400 (EDT) Subject: how to save HOURS of time with python... Message-ID: #!/usr/home/sabren/bin/python """ I waste way too much time checking email. This is a little script to prevent me from checking email too often. """ import os, stat, time ## how long to wait between allowing email checks? DELAY = 120 ## calculate the time in seconds since I last checked ## mail (which is the last time this program ran, and ## also the last time this file was modified, because ## I call touch, below..) modtime = os.stat('/usr/home/sabren/bin/pine')[stat.ST_MTIME] elapsed = time.time()-modtime ## now, see if it was less than DELAY mins ago: if elapsed < DELAY * 60: print "not for another %i minutes..." \ % (DELAY - int(elapsed/60)) else: ## i can check mail! :) os.system('/usr/local/bin/pine') ## all done. no more mail for a while: os.system('touch /usr/home/sabren/bin/pine') """ 'Nuff said. :) Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ """ From g2 at seebelow.org Sat Oct 7 09:30:28 2000 From: g2 at seebelow.org (Grant Griffin) Date: Sat, 07 Oct 2000 14:30:28 +0100 Subject: JPython Status References: <8rfqga$9sd$1@nnrp1.deja.com> <8rhsrj$i8j$4@newsserver.rrzn.uni-hannover.de> Message-ID: <39DF2574.6CBE80EB@seebelow.org> Ivan Frohne wrote: > > "Bernhard Reiter" wrote in message > > > (Ivan Frohne): But CPython is not really open source, either. > > > > This is not true. > > Python qualifies as open source and free software. > > Java implementations from Sun do not. And Sun has a firm grip > > legal on the java specs. > > I'll be the first to admit that my understanding of the term "open source" > is fuzzy and imprecise, but I do know what I like. I dunno...I think its pretty clear. Despite all the hype, "open source" simply means software whose source (that is, its most easily modified manifestation) is open (that is, publicly available). There's a very good reason the OSI's application to claim the term "open source" as a trademark was rejected. (In fact, in retrospect, the whole nutty trademark thing comes across as a bit Mephistophelean. ) One can only suppose they have FSF folks have better legal representation than the OSI. The FSF has never tried to trademark the general term "free software", even though they use it as a trade name. (Heck, they don't even capitalize it: just imagine how far "coca-cola" would have gotten without capital letters. ) In case anybody asks, "free software" is just like "open source" in the sense that it actually means exactly what you'd think it means. It just means "software you don't have to pay for". (And if anybody ever tries to tell you "free software" is any different than "free beer", just show them how to set their beer "free" by breaking its bottle.) but-please:-*not*-over-richard-stallman's-head--ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From sholden at holdenweb.com Thu Oct 12 09:49:33 2000 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 12 Oct 2000 09:49:33 -0400 Subject: 2.0c1 zipfile problem Message-ID: <39E5C16D.584F96D2@holdenweb.com> The zipfile library in 2.0 came along at just the right time to solve a client's problem. However, my dumbass attempts to use it are meeting with no success. Can someone who knows this library tell me why the program below creates an archive about which WinZip 7.0 says: Cannot open this file: it does not appear to be a valid archive" The zipfile library also gives me a BadZipFile exception if I try to read the file back. If it makes a difference (byte ordering?) I am running this on a SPARCstation under Red Hat Linux 5.2. IF I can get verification that the code seems correct I will report a bug, but at present I suspect programmer error. Does this program work on other architectures, or what have I done wrong? regards Steve ----------------------------------------------------------------- import zipfile import os.path import sys # # NOTE: requires binascii module from python 2 # def createzip(name, ext): target = name+".zip" if os.path.exists(target): print target, "exists" return z = zipfile.ZipFile(target, mode="w") z.write(name+"."+ext) z.close print target, "created" createzip(sys.argv[1], sys.argv[2]) -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ From jasonic at nomadicsltd.com Sun Oct 1 20:54:20 2000 From: jasonic at nomadicsltd.com (Jason Cunliffe) Date: Sun, 1 Oct 2000 20:54:20 -0400 Subject: newbie help needed factoring methods and params in class defs Message-ID: I am writing a module 'caldict.py' with classes to manage 'timeline' dictionaries. Timestamps (as strings) are lookup keys and the event data they fetch is any string. I am using Marc-Andr? Lemburg's mxDateTime package http://starship.python.net/~lemburg/mxDateTime.html plus 'seqdict' and 'mseqdict' modules by Wolfgang Grafen http://home.germany.net/100-366919/Python/Modules/Modules.html A great combination - thanks to both authors. So far so good. I have a class CalDict() which has various methods: init(), append(), sort(), findnth(), etc.. I want to use key arguments for various options for all my functions in a consistent manner. import caldict cd = caldict.CalDict() cd.append(year=1955, month=4, day=5, hour=14, minute=30, 'birthday') cd.append(year= -2500, 'Bronze age') cd.append(year = 1789, 'French Revolution') cd.append(str(now()), 'here and now') #now put everything in order beautifully thanks to seqdict and mxDateTime cd.sort() #Timeline events can be returned by date... cd.getevent('1955-04-05 14:30:00.00') #or by index... cd.findnth(index='last') cd.findnth(index=1) cd.findnth(index= -2) #returns penultimate event ie: 'French Revolution' #cool! #now I need the option to have other arguments also for example: cd.findnth(index='last', display=1) #or cd.findnth(index='last', showdate=1) These will overide defaults and display the result, or show the date as well as the event string for whatever the last item in the timeline is. At present I do this very simply as follows inside class Caldict: def reverse(self, display = 0): s = self.eventdict if display: self.display() But as I look down my list of growing class methods, I see the same code repeated again and again. There must be a much more elegant pythonic way to factor the "if display" condition out. But not sure how.. I have a method display () in the top of my Class.but when I try to detect there to see if the passed parameter display =1 it does not work. I seem to be not undersrtanding something basic about passing parameters and reusing methods within a class definition. Another perhaps related problem also concernt best way to factor: 1 class Caldict: 2 def __init__(self, size=12, months=1, days=0, hours=0): 3 #default creates 12 months from the present day and time 4 self.eventdict = seqdict.seqdict() 5 self.indexdict = {} 6 s = self.eventdict 7 for x in range (size): 8 #initialize our delta values 9 dmonths = months * x 10 ddays = days * x 11 dhours = hours * x 12 ddate = now()+RelativeDateTime( months=+dmonths, days=+ddays, hours=+dhours) 13 s.append(str(ddate), "entry" + str(x)) 14 s.sort() 15 #showme 16 def display(self): 17 s = self.eventdict 18 if display: 19 for x in range(len(s)): 20 print x, s.keys()[x] Why can do I have to redefine in line 17 's = self.eventdict' when I alrady did so in line 6. Same for all teh followng methods? This must be Python101.. I someone can help me get to grips with Python classes better.. Thanks - Jason ________________________________________________________________ Jason CUNLIFFE = NOMADICS.(Interactive Art and Technology).Design Director From todd_gruben at my-deja.com Fri Oct 6 08:59:03 2000 From: todd_gruben at my-deja.com (todd_gruben at my-deja.com) Date: Fri, 06 Oct 2000 12:59:03 GMT Subject: Internal Server Error Message-ID: <8rkiaj$4q4$1@nnrp1.deja.com> I am using Apache/1.3.12 and developing a simple cgi python app. The script simply prints Content- type: text/plain followed by a couple of line feeds then I call a method that is actaully a "swigged" share c library method. For some reason the browser returns a Internal server error and the log file prints the following message. [Thu Oct 5 19:49:23 2000][error][client 192.168.0.7] Premature end of script headers: /home/httpd/cgi-bin/CreateUser.py The script is this .. #!/usr/bin/python import uuid print "Content-type: text/plain\n\n" print "Hello\n" a = uuid.newid() print a Note: this script runs fine from the command line. I suspenct it is not finding the uuid module, which is a c program. Anybody have any ideas? -Todd Sent via Deja.com http://www.deja.com/ Before you buy. From thomas at xs4all.net Mon Oct 30 17:35:23 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 30 Oct 2000 23:35:23 +0100 Subject: com_addbyte In-Reply-To: <8tkfq7$vgp$1@nnrp1.deja.com>; from etsang@my-deja.com on Mon, Oct 30, 2000 at 06:48:42PM +0000 References: <8tkfq7$vgp$1@nnrp1.deja.com> Message-ID: <20001030233523.H12812@xs4all.nl> On Mon, Oct 30, 2000 at 06:48:42PM +0000, etsang at my-deja.com wrote: > I currently have the following problem: > Description: > Python has the limit for either the number of arguments or size of the > parameters. > Try SILIB_IAM_MAO.py in ~isup/ctftest/si/problem directory. > Try si_tc_S20/si_tc_S2005.py as the test case. > Traceback (innermost last): > File "ctf_gui_tstmgr.py", line 1311, in executeCmd > exec("import %s"%importFile); > File "", line 1, in ? > File "si_tc/si_tc_S20/si_tc_S2005.py", line 90, in ? > from SILIB_IAM_MAO import * > SystemError: com_addbyte: byte out of range (line 12265) > I am currently ysing python 1.5.2 for Solaris. > If I can get around without breaking SILIB_IAM_MAO, it will save a lot > of trouble!! You can switch to Python 2.0, which does probably fix this problem. (Or rather, it moves the problem to the 2 milion rather than 65 thousand range.) Without seeing the source files, I'm not entirely sure what it barfs on, so it might not even be fixed. No harm in trying, though. Other than that, no, there isn't a way to avoid breaking up your generated file. If the generator is written in Python, it shouldn't be *that* hard -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From g2 at seebelow.org Fri Oct 13 13:45:11 2000 From: g2 at seebelow.org (Grant Griffin) Date: Fri, 13 Oct 2000 18:45:11 +0100 Subject: C macros in Python. References: Message-ID: <39E74A27.87695A51@seebelow.org> Steve Juranich wrote: > > I was just wondering if there was anything available in Python like the > __FILE__ and __LINE__ macros in C. I know about the __name__ attribute, but > I'm not sure that does exactly what I'm looking to do. > > What I'd like to do is write some code that will tell me _exactly_ on which > file and while line things went wrong. On a different, but related, topic...I sometimes miss C's #define macro. There doesn't seem to be any similar thing in Python capable of creating identifiers which are 1) constant, that is, "read only", and 2) truly global in scope. "Or-am-I-about-to-learn-a-new-wortish-Python-idiom?-asked-the -beamish-boy-in-uffish-thought-with-vorpal-blade-in-hand-ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From dgoodger at bigfoot.com Mon Oct 30 23:30:55 2000 From: dgoodger at bigfoot.com (David Goodger) Date: Mon, 30 Oct 2000 23:30:55 -0500 Subject: =?ISO-2022-JP?B?GyRCPEFMZBsoSg==?= In-Reply-To: References: Message-ID: on 2000-10-30 00:52, Kenichi (k_yosida at minnie.ai.kyutech.ac.jp) wrote: > ?????????????????????????????????????? > ???? > ?????????????????????????????????????? > ??????????????????????????????? > ???????????????????????? Python?????????????????????????????????? ??????????????????????????????????????? ?????pickle???Zope?ZODB?????????????????????? ?????????? ??Python????????????????????????????????? ??????????????????????????? -- David Goodger dgoodger at bigfoot.com Open-source projects: - The Go Tools Project: http://gotools.sourceforge.net (more to come!) From parkw at better.net Tue Oct 31 15:13:01 2000 From: parkw at better.net (William Park) Date: Tue, 31 Oct 2000 15:13:01 -0500 Subject: function with a lot of parameters --maintainability issue In-Reply-To: <8tn5q1$7mn$1@nnrp1.deja.com>; from etsang@my-deja.com on Tue, Oct 31, 2000 at 07:16:26PM +0000 References: <8tn5q1$7mn$1@nnrp1.deja.com> Message-ID: <20001031151301.A20329@better.net> On Tue, Oct 31, 2000 at 07:16:26PM +0000, etsang at my-deja.com wrote: > Hi all, > > I have several functions that takes in more than 255 parameters and > cause Python to complain about com_addbyte error out of range. > We are using Python 1.5.2 and have to take that versiona t the moment. > > I think one way to get around that is as follows: > > Since a lot of your functions are like: > def func(sid,a,b,c,d,e,f, ..... more than 255 parameters): > > setVariable(sid,.....,a); > setVariable(sid,.....,b); > ..... > setVariable(sid,.....,z); > ...... > sendPrim(sid,"somePrim .."); > we can break the function into several functions: > > def func1(sid,a,b,c,d,e): > setVariable(sid,.....,a); > setVariable(sid,.....,b); > .... > setVariable(sid,.....,d); > setVariable(sid,.....,e); > def func2(sid,f,g,h,i,....): > setVariable(sid,.....,f); > setVariable(sid,.....,g); > .... > > def func3(sid,......): > setVariable(sid, ....); > sendPrim(sid,........); > Note that setVariable and sendPrim are just other user defined > functions. > > Then just call these three functions in order of func1,func2,func3. > > That is in places that call func, that following is replaced > func1, func2, func3. There are quite a lot of places that call func. > So this may generate maintainability issue, as we need to keep track of > three functions instead of one. > > So can anyone suggest a better solution at the moment? Yes, pass dictionary to the function, ie. def func(sid, args): for i in args.keys(): setVariable(sid, ..., args[i]) # argv['a'], ... argv = {'a':..., 'b':..., 'c':..., ...} func(sid, argv) ---William Park, Open Geometry Consulting From aleaxit at yahoo.com Sun Oct 29 04:13:44 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 29 Oct 2000 10:13:44 +0100 Subject: C's syntax (was Re: Python Formatted C Converter (PfCC)) References: <8t0or303ee@news1.newsguy.com> <39F4FFB7.452EDDEC@alcyone.com> <8t3mdv025uo@news2.newsguy.com> <39F5B404.B5626FB7@alcyone.com> <8t4q8v11lpv@news1.newsguy.com> <39F5E620.C780A71C@seebelow.org> <8t6vj70spd@news1.newsguy.com> <39F73E41.C8EE143F@seebelow.org> <8t8sgn0ahc@news1.newsguy.com> <39F8985B.6909B5CF@seebelow.org> <8tbv0r01082@news1.newsguy.com> <39FB2080.D38CAD35@seebelow.org> Message-ID: <8tgpr201ipj@news1.newsguy.com> "Grant Griffin" wrote in message news:39FB2080.D38CAD35 at seebelow.org... [snip] > If you speak true words of wisdom on some subject, the words stand on > their own. Oh, do they? Even to a reader whose knowledge of the subject is infinitesimal? How interesting! So (supposing for the sake of argument you knew no Italian), you are somehow able (is it divine inspiration, ESP, or...?) to tell whether the following assertion, for example...: "hyphenation in Italian is best performed algorithmically, given the strong regularity of the language's syllabification rules; trying to adapt to Italian hyphenation algorithms designed for other languages, adjusting only a data table to account for the language, is vastly sub-optimal" is made up of "true words of wisdom"? How, pray tell, do these words "stand on their own", when you have no basis on which to apply judgment? Are you _seriously_ claiming that a reader's ability to judge the worth of my words about Italian usage is not helped by knowing that I am a native speaker of Italian, have lived in Italy for most of my life, have co-authored with Tullio De Mauro (a prominent Italian linguist, currently the Minister for Education) a book on the results of computational linguistic studies applied to Italian, etc? Assuming (for the sake of argument) you truly mean what you write, this seems a serious case of "word fetishism" on your part. Most sensible readers would agree that their ability to judge whether to apply this advice is strongly affected by information regarding the advisor's competence regarding the Italian language, its linguistic study, and the application of computers to handling it. And similarly, when we're not talking of simple work/does not work advice that can easily be tested, but of more general issues (is a given language's syntax good or terrible), information on the advisor's competence, fluency, and experience with the language being discussed is crucial to the reader's ability to judge the worth of the advice being proffered. Words never "stand on their own": they refer (partly implicitly, partly explicitly) to a *context*, a "state of the world" which fully includes the relevant experiences of the speaker and listener. If it were true, as some dolt maintained, that "only people who don't like C" criticize its syntax, this might be relevant, weakening a bit the weight of these criticisms. It is, therefore, important to show how deeply wrong this assertion is -- that some of the people who most harshly dislike C's syntax have vast experience with the language and like it overall (for its suitable uses) *despite* the terrible syntax, while the very inventor of the language, in an article that defends it against some criticisms, freely admits to its "quirky and flawed" nature, particularly on a syntax plane, and explains the historical accidents and mistakes that led to some of its worst idiosyncrasies. Alex From ttkurppa at cs.Helsinki.FI Thu Oct 19 15:26:23 2000 From: ttkurppa at cs.Helsinki.FI (T Teemu E Kurppa) Date: 19 Oct 2000 19:26:23 GMT Subject: Easiest way to do simple animation (no GUI) Message-ID: <8snhsv$ivb$1@oravannahka.helsinki.fi> What is the best way to do simple animation with Python. I'm planning to do a simple robot simulator with Python, and I need some simple way to do graphical view of simulator state. Simulator gets commands from other processes through sockets, and updates its state. It has to show graphical view of its state quickly. However, I don't need any GUI components, and would prefer simple viewer, because program is not "GUI-event driven", if you understand what I mean. Is there other solutions than wxPython or Tkinter ? If not, which one would you prefer ? Simulator will be run on Linux-machines only. Thanks in advance, -- Teemu Kurppa University of Helsinki Teemu.Kurppa at Helsinki.fi From aleaxit at yahoo.com Wed Oct 4 07:10:06 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 4 Oct 2000 13:10:06 +0200 Subject: Inefficiency of __getattr__ References: Message-ID: <8rf3fm030n4@news2.newsguy.com> "Kragen Sitaker" wrote in message news:NpzC5.1605$l52.81889 at news-west.usenetserver.com... [snip] > So what's the advantage of static typing over dynamic typing? Does it > help you catch bugs, and if so, which ones? It helps catch some type-related bugs -- particularly in areas of the code that it's hard to ensure are wholly tested because they deal with rare/exceptional/abstruse conditions. Even for bugs one would catch anyway in testing, it does help by letting you do the "catching" earlier -- costs are lower the earlier you catch the bugs. It also helps your compiler generate better code. And, your source can be more expressive, as it states certain things that you know about your code, in a precise and unambiguous way. Whether these undeniable gains are worth the various components of bother that static typing just-as-undeniably adds, is of course The Question. I come from a background of mostly static typing, but over the years I've never entirely lost track of the dynamic-typing world, and from a LOT of relevant experience in both camps I have come to be pretty convinced of two things: -- the whole song-and-dance of mandatory strict static typing where the programmer has to specify everything statically is far too much to pay for the benefits; this means Eiffel, C, C++, Java, Pascal, &c; -- having NO way to specify static typing in the language, even where one would DEARLY LOVE to do so for any of the possible benefits, is going too far in the other direction; this covers Python, Scheme, &c. I think the optimal solution will have to include: -- type INFERENCE: the compiler is able to INFER types when feasible -- OPTIONAL static type annotation: the programmer MAY, IF AND WHEN HE OR SHE WISHES, specifically denote the type (or rather 'typeclass', in the Haskell sense...) that a give object reference must have at some point (just as he or she may, if and when desired, specifically denote other semantic constraints); this extra, optional info will be usable in various ways depending on development mode/stage: -- when the explicit denotation is contradicted by the inference, a compile-time error result -- in debugmode, runtime checks are added to verify the explicit denotations (possibly giving exceptions) -- in optimizemode, the compiler can rely on the explicit denotations (as well as its inferences) and deduce any possible optimization from them -- warnings and advice can optionally be given by the compiler to prompt the programmer to add denotations where this would be of greatest help if possible Haskell is already pretty good at this -- it does have fully static typing, but this is only a moderate hassle thanks to its wide use of inference, polymorphism, and typeclasses. Dylan points the way to get there from the fully dynamic side of things, with explicit denotations being really optional (and fully-dynamic typing available when wanted) and mostly used for optimization or clarity. I know of no language where "belonging to a type" (or class/typeclass/etc), "satisfying a certain contract" (in the Meyer sense), and other kinds of "assertions" (explicit denotations), are handled as seamlessly and smoothly as I would love them to be; e.g. where, when writing or editing a function, I can just as easily and productively assert of an argument "...and this meets the OrderedNumeric typeclass constraints" as I can assert "...and this is positive, odd, and not exactly 1 more than a power of two" (should I happen to know this specific and peculiar bag of facts about the characteristics of the argument I expect:-). Eiffel and Sather perhaps come closest on this, but these "contract clauses" only really apply "at the interface" of modules (objects) in those languages, while their (static) typing applies more pervasively, so they're not equivalent and "seamless"... Alex From raja at cs.indiana.edu Thu Oct 19 10:01:03 2000 From: raja at cs.indiana.edu (Raja S.) Date: 19 Oct 2000 14:01:03 GMT Subject: A suggestion for python 2.1. References: <39f09400.33100312@nntp.interaccess.com> Message-ID: <8smuqv$1o9$1@flotsam.uits.indiana.edu> since you seem to be running your scripts under Unix, why don't you just use the conventional shell trick ? #!/usr/local/bin/python or #!/usr/bin/env python as the first line in your scripts. Put them in your $HOME/bin (assuming that is in your $PATH) and turn on execution permissions (e.g., chmod a+x cleanup). You'll also need to do a 'rehash'. From then on: % cleanup will work Raja olczyk at interaccess.com (Thaddeus L. Olczyk) writes: >A new enviromental variable I call it PYTHONSCRIPTPATH, >but maybe someone can come up with a better name. >The idea of this variable is this. >I write a bunch of scripts for doing system stuff, >and I want to store them in one or two directories ( some may even be >stored in common areas ). Call one cleanup.py which deletes >extraneous files ( *.o, #*# ( emacs aborted exit ),*~(emacs backup)) >in the present directory. >The way I would like to run it is: >python cleanup(.py) >the way I have to write it is >python directoryWhereCleanupIsStored/cleanup.py >I've tried various tricks for this ( modifying PATH and PYTHONPATH ), >and have no real way to make it work. From aahz at panix.com Sun Oct 1 12:29:34 2000 From: aahz at panix.com (Aahz Maruch) Date: 1 Oct 2000 09:29:34 -0700 Subject: [1.5.2] Buglet in Mailbox-module? References: <8FBFE5F1rcamesz@127.0.0.1> <8r3a8v$5c$1@panix2.panix.com> <8FC037529rcamesz@127.0.0.1> Message-ID: <8r7ope$ca6$1@panix2.panix.com> In article <8FC037529rcamesz at 127.0.0.1>, Robert Amesz wrote: > >"Munged?" I've never heard that word, but I presume you're referring to >the spamblocker in the From-header. The one in the Reply-To header is >perfectly valid though. Any half-decent newsreader will use that one >when replying by e-mail, so I'm not really sure what the problem is >here. You don't have a Reply-To: header; you probably have Xnews configured incorrectly. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Shadows 2000: when you're tired of "Cthulhu for President" --Aahz From jkraska1 at san.rr.com Mon Oct 30 12:42:37 2000 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 30 Oct 2000 09:42:37 -0800 Subject: Python Labs Move In-Reply-To: <14845.17091.157414.58824@lrz.uni-muenchen.de> References: <39FCE915.C1DC844C@san.rr.com> <39FCE915.C1DC844C@san.rr.com> Message-ID: <5.0.0.25.0.20001030093957.00bf0870@pop-server> > > Guido's a good fellow, I'm sure, but Python is bigger than > > him now. Look at it on the bright side: so far Python has > >It is always better to keep the future of a major project in hands of >a single person who's immune to a sellout. In case it forks, one can >still stick to the one true branch (Guido's Python). More to the point, and as I hinted in the snipped out section, design by committee is the kiss of death. But even still, Python has become its own phenomenon and will continue to have a life of its own. Perhaps now that this has happened, we should rename it "Hydra": cut off a head, and two will grow in its place. Apologies to Guido, of course. :)- C// From holger at phoenix-edv.netzservice.de Thu Oct 12 10:21:34 2000 From: holger at phoenix-edv.netzservice.de (Holger Jannsen) Date: Thu, 12 Oct 2000 16:21:34 +0200 Subject: Distributing Python References: <39E1B493.A0EC8F3@hotmail.com> <39E5BAA2.CA694E5C@phoenix-edv.netzservice.de> Message-ID: <39E5C8EE.5E905556@phoenix-edv.netzservice.de> Sorry, seems to be that my script doesn't work with version 2.0 of python. I did a downgrade to 5.2 and win1.25 and it works so far I could see yet (not much time today anymore). It's just I got that idea today and wanted to stare to the newest version of python. Bad idea, isn't it? Something has changed heavily?!? have a nice day Holger From kuncej at mail.conservation.state.mo.us Tue Oct 3 10:59:00 2000 From: kuncej at mail.conservation.state.mo.us (Jeff Kunce) Date: Tue, 3 Oct 2000 09:59:00 -0500 Subject: Freeze References: <8rauae$12sl$2@earth.superlink.net> Message-ID: > Python 1.5.2 on Windows 95: I've looked in my tools folder and cannot > find the freeze.py file. Does anyone know where I can get it? You will have to download the source distribution of python to get freeze. Since "freezing" an application involves compiling both the application and python itself, there is no point in distributing freeze.py without the python source code. --Jeff From tbryan at python.com Sat Oct 28 20:19:16 2000 From: tbryan at python.com (Thomas A. Bryan) Date: Sat, 28 Oct 2000 20:19:16 -0400 Subject: Q: how to scan every element of a dictionary ? References: <%fJK5.79$6b7.1499@vixen.cso.uiuc.edu> Message-ID: <39FB6D04.3F656E12@python.com> Hwanjo Yu wrote: > Doesn't the dictionary data structure support an enumeration operator to > scan every element of it ? ... > How to do it ? Enumeration only works for sequences. Dictionaries are mappings, not sequences. Generally, I iterate over the keys, values, or items in a dictionary, as appropriate. $ 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 >>> dict = {'one': 1, 'two': 2, 'three': 3} >>> for el in dict.keys(): ... print dict[el] ... 1 3 2 >>> for el in dict.items(): ... print el[0], "->", el[1] ... one -> 1 three -> 3 two -> 2 >>> for el in dict.values(): ... print el ... 1 3 2 ---Tom From jhauser at ifm.uni-kiel.de Fri Oct 20 07:55:13 2000 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 20 Oct 2000 13:55:13 +0200 Subject: Assertion vs. try-except References: <39f029e8.165482310@news.eunet.no> Message-ID: <87em1benha.fsf@ifm.uni-kiel.de> Assertions are not executed if Python runs with -O flag, so you can run or distribute production code without assertions. HTH, __Janko -- Institut fuer Meereskunde phone: 49-431-597 3989 Dept. Theoretical Oceanography fax : 49-431-565876 Duesternbrooker Weg 20 email: jhauser at ifm.uni-kiel.de 24105 Kiel, Germany From jurgen.defurne at philips.com Wed Oct 18 02:28:58 2000 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Wed, 18 Oct 2000 08:28:58 +0200 Subject: copy protection Message-ID: <0056900013007590000002L002*@MHS> Or on multi-user machines. I have seen such a bookkeeping program. We swapped CPU's a few times (I'm talking about mini's here, with proprietary CPU's), and we had to call to software company. A small program encoded the configuration in a key, and upon delivery of that key, we got a new code to make the program run again. Jurgen josh at open.com@SMTP at python.org on 18/10/2000 06:32:19 Sent by: python-list-admin at python.org To: python-list at python.org@SMTP cc: Subject: Re: copy protection Classification: Well, given that he's talking about *porting* their app, I would say that their entire client base would be that stupid. Licensing code to a particular machine is actually quite common, especially for expensive software. Using the network adapter ID or other unique identifiers is no big deal. I'm sure that if they need to move to another machine, it is probably just a phone call or an email to get a new key. -- josh -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- -- http://www.python.org/mailman/listinfo/python-list From MarkH at ActiveState.com Tue Oct 24 23:27:15 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 25 Oct 2000 03:27:15 GMT Subject: MS Windows Clipboard References: <8t3m1n025h1@news2.newsguy.com> Message-ID: [Alex] > [I'd really like to use .GetDesktopWindow() rather than > .GetActiveWindow() to create the dummy window's parent, > but for some reason win32gui is not exposing GetDesktopWindow > in win32all build 135, so I fudged it...] It will be in 137 ;-) > I'm not sure where the standard formats (CF_TEXT, etc) > are defined as symbolic constants in win32all -- they're I've added these to win32clipboard. > Calling win32clipboard.GetClipboardData(1) is clearly the > way to get at the data we want. It's documented as > returning "the handle of a clipboard object in the specified > format", so we might worry about using a PyHANDLE to Fixed the docs ;-) > handy! Careful, though: the undocumented conversion to > string seems to take place somewhat indiscriminately; if > asking for format 49159, the FileNameW (clearly meant to Note that if you ask for CF_UNICODETEXT, you should get back a Unicode object. That was a very useful post! Thanks... Mark. From olivierS.dagenaisP at canadaA.comM Fri Oct 20 20:25:40 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Sat, 21 Oct 2000 00:25:40 GMT Subject: large file support References: <8sqn2l$ec$1@ncar.ucar.edu> Message-ID: <8o5I5.354510$Gh.10807008@news20.bellglobal.com> > How does one read large files into Python? I have a 4 gigabyte > file on an SGI (that has over 30 GB main memory), but when I use 30 gigs of RAM? THIRTY GIGS of RAM? I used to think a 30 GB hard drive would be a nice addition to my computer! I am very jealous!!! I don't suppose you also have a terrahertz processor??? :p No, sorry, I can't help you... and-to-think-I-started-with-an-XT-with-a-30-meg-HD-ly y'rs -- ---------------------------------------------------------------------- Olivier A. Dagenais - Software Architect and Developer "Someone called 'Type your name here' is impersonating me on the internet and is posting exactly the same things I am posting!" From wtanksle at dolphin.openprojects.net Mon Oct 23 19:00:41 2000 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Mon, 23 Oct 2000 23:00:41 GMT Subject: C's syntax (was Re: Python Formatted C Converter (PfCC)) References: <8t0or303ee@news1.newsguy.com> Message-ID: On 23 Oct 2000 15:30:37 -0700, Samuel A. Falvo II wrote: >On Mon, 23 Oct 2000 20:40:19 GMT, Rainer Deyke wrote: >>It gets worse. >>int (*a)[5], *(b[5]); >>It looks like 'a' is an array of pointers and 'b' is a pointer to an array, >>but the opposite is the case. >I don't know -- that makes perfect sense to me. Order of operations and all >that. :) I know. I saw that message, was confused that it would seem the reverse to anyone, then realised that I've worked FAR too much with C. What a depressing language :-). >Samuel A. Falvo II | -- -William "Billy" Tanksley From ejr at lotus.CS.Berkeley.EDU Tue Oct 17 15:08:42 2000 From: ejr at lotus.CS.Berkeley.EDU (Edward Jason Riedy) Date: 17 Oct 2000 19:08:42 GMT Subject: Some Q&A with Kahan on IEEE 754 References: Message-ID: <8si83q$jfk$1@agate.berkeley.edu> And Tim Peters writes: - - > 5) Thread specific handling of traps with creation-time inheritance of - > settings. - - Yes, all 754 state (rounding, precision, sticky flags, trap masks) must be - part of thread state. The fun part is in the implementation, which is what I was pondering before (in case you meant me). I've never checked to see if threads behave sensibly in this respect on various platforms. Considering how different vendors implement compiler parallelization, I wouldn't be at all surprised if there are significant differences between platforms. - Less clear is whether sticky flags should be inherited too or - cleared in a new thread; I favor the latter [...] Even given a single method call that clears the flags and makes the intent equally clear? I suspect that some OSes keep the sticky flags (fork-join type semantics), some clear them (for your reasons), and others give you random crap (poor implementation of threads from a thread pool). - Signaling NaNs are a minor feature; I'm not sure I've *ever* seen - them used (on purpose ). Remember that every NaN read from I/O is supposed to be a signalling NaN. It's one of those really disgusting parts of 754 that can be dropped without complaint (I hope). - > 2) Speaking of signal handlers, Tim Peters stated that returns are not - > allowed from sIGFPE handlers. I have yet to see this restriction in - > any platform documentation. What is the deal? - - C standard. Also the Single Unix Specification's definition of sigaction: > * The behaviour of a process is undefined after it returns normally > from a signal-catching function for a SIGBUS, SIGFPE, SIGILL or > SIGSEGV signal that was not generated by kill(), sigqueue() or > raise(). - For example, if you try to return from a SIGFPE handler on a WinTel box, - you *usually* get into an infinite loop, [...] Same on Intel/Linux. Sparc/Solaris seems to return normally, and is backed up by the example in their documentation for ieee_handler. - Note that I/O is a problem: different platforms spell Inf and NaN in - different ways, [...]. I expect everyone will eventually move to the - C99 spellings for these things, [...] Does that coincide with the XML Schema spellings (INF and NaN)? Or Java's (Infinity and NaN)? Those are two non-trivial groups that might want it their way. As long as it's well defined for Python, though, it's no big deal. [On the insane number of comparators...] - But there's no way Python will grow new language syntax for these. The current ones plus the ability to test the invalid flag is all that's really necessary. Further comparators are nice for compilers that are told not to optimize anything. - Also doubtful that - x == x - will be changed to special-case NaNs; this currently returns 1 no matter - what x is bound to because the same ("x is x") objects are being compared, - and object identity is fundamental in Python. That is why there's is. The statement "x is NaN" or "x is x" where x holds a NaN should be true, but I would request that NaNs be special-cased in == by the principal of least surprise when migrating from other languages. And saying == has something to do with object identity gives it two different meanings in different situations. My mental model for working with these things is that there's only one number 1.0, one +Inf, one NaN, and that variables just reference those things. Then something like "is" checks to which objects things are bound, and something like "==" actually interrogates the objects, possibly with object-specific semantics. Also, consider a case where you're comparing terms in two sequences to see where they diverge: while x == y: x = A.next_term() y = B.next_term() Particular choices may give one sequence suddenly diverging to Inf - Inf and another diverging to sqrt(-1). Personally, I think it would be sensible (minimally surprising?) to stop the iteration there... But then this is a pretty lousy example. BTW, there's another issue with trapping: When a complex operation traps, should we expose the individual floating-point operation that trapped underneath it? (Assuming Python keeps its own implementation rather than relying on (broken) compilers' complex types.) Personally, I think not. [Also, Dr. Kahan's down on trapping simply because they're such a bear to implement. I've gotten the feeling that he'd find an easy to use trap system interesting.] Jason From edcjones at erols.com Thu Oct 12 10:07:11 2000 From: edcjones at erols.com (Edward C. Jones) Date: Thu, 12 Oct 2000 10:07:11 -0400 Subject: Python 2.0c1: Minor problem Message-ID: <39E5C58F.D949D166@erols.com> I have a PC running RedHat 6.2 Linux with kernel-2.2.17. Python 2.0c1 installed with no difficulty except for modifying Modules/Setup. In several cases I just copied lines from the config file for the python-1.5.2-13 RedHat rpm. When I run a Python program of mine I get the message: WARNING: Python C API version mismatch for module getdate: This Python has API version 1009, module getdate has version 1007. WARNING: Python C API version mismatch for module _mysql: This Python has API version 1009, module _mysql has version 1007. The program ran properly. What do these messages mean? What should I do about them? Thanks, Ed Jones From kalle at gnupung.net Fri Oct 13 09:23:52 2000 From: kalle at gnupung.net (Kalle Svensson) Date: Fri, 13 Oct 2000 15:23:52 +0200 Subject: Subroutines In-Reply-To: <39E708C2.611C97BC@hotmail.com> References: <39E708C2.611C97BC@hotmail.com> Message-ID: On Fri, 13 Oct 2000, j wrote: > For example how would a perl subroutine below be in python. > sub myfunc { > print $_[0]; > } I'm not very good at perl, but I believe you want to print the first argument to the function. In this case def myfunc(arg): print arg would be what you want. I suggest you Read The Fine Manual, starting with the tutorial, where functions are discussed in sections 4.6 and 4.7. Python docs - http://www.pythonlabs.com/doc/manuals/python2.0/ Tutorial - http://www.pythonlabs.com/doc/manuals/python2.0/tut/tut.html Regards, Kalle -- Email: kalle at gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) Not signed due to logistical difficulties (I'm not at home). If you doubt the authenticity of this message, please tell me. From thomas.svensson at era.ericsson.se Thu Oct 5 12:16:25 2000 From: thomas.svensson at era.ericsson.se (Thomas Svensson) Date: Thu, 05 Oct 2000 18:16:25 +0200 Subject: re.match question References: <39DC9F7C.67B71D52@era.ericsson.se> <8ri81j$eog$1@bob.news.rcn.net> Message-ID: <39DCA959.D2B1E683@era.ericsson.se> Tony Sideris wrote: > > "Thomas Svensson" wrote in message > news:39DC9F7C.67B71D52 at era.ericsson.se... > > Hello, > > > > I'm matching a list of strings. I want "xxxBar" to be a match but not > > "xxxFooBar", xxx can be anything. I've tried the following: > > > > re.match('^.*?(?!Foo)Bar$', word) > > > > re.match('^.*?(Foo){0}Bar$', word) > > > > But they all returns a match. What am I doing wrong?? I think this > > should be an easy thing to do. > > > > > > Thanks for any help, > > Thomas > > re.match(r'^[^(?:Foo)]*Bar', 'xxxFooBar'); > > seems to be working for me. the above line fails, 'xxxBar' passes. may need > further tweeking... > -Tony Thanks, But this seems not to be quite correct. If I try "xxxoBar" it also fails, that should only happen for the complete substring ("Foo"). / Thomas From root at gyptis.frmug.org Sun Oct 8 11:54:24 2000 From: root at gyptis.frmug.org (gyptis) Date: 8 Oct 2000 15:54:24 GMT Subject: test4 Message-ID: <8rq5bg$oil$1@gyptis.frmug.org> From bk at xk7.com Wed Oct 18 06:42:33 2000 From: bk at xk7.com (Burkhard Kloss) Date: Wed, 18 Oct 2000 11:42:33 +0100 Subject: convert python into C References: <8sjrjf$ei5$1@nnrp1.deja.com> <39ed77a4.95075431@news.eunet.no> Message-ID: <971866036.493939@master.nyc.kbcfp.com> > > I wrote a small program in python and I wish I could use it on > >my Next computer. I have no python interpreter on the Next, but > >I do have, of course, a C compiler. > > Is there any method to convert a python program into C or C++ code ? The alternative, and probably both easier and more useful in the long run, would be to compile the python interpreter on the Next. Since there's a fairly standard Unix hiding underneath, it shouldn't be too difficult to port Python itself. From nmw at ion.le.ac.uk Fri Oct 6 10:07:25 2000 From: nmw at ion.le.ac.uk (Nigel Wade) Date: Fri, 06 Oct 2000 15:07:25 +0100 Subject: Embedded Python/NumPy and reference counts Message-ID: <39DDDC9D.6BB055C8@ion.le.ac.uk> Hi, I'm in the process of embedding Python in an application of mine, and want to be able to transfer Numerical Python arrays from the application to the interpreter. In essence what I need to do is initialize the interpreter, create a local dictionary, then loop repeatedly passing an array from C to the interpreter in the same item in the local dictionary. It looks something like this: int dims[1]; PyObject *locals, *numpy_array; float *ptr; Py_Initialize(); PyImport_ImportModule("Numeric"); locals = Py_DictNew() loop { ptr = pointer to a C data array dims[0] = length of C data array; numpy_array = PyArray_FromDimsAndData(1, dims, PyArray_CFLOAT, (char *)ptr) PyDict_SetItemString(locals, "d_data", numpy_array) PyRun_String("print d_data", Py_single_input, NULL, locals) } Now, what I am not sure about is what to do about numpy_array and the d_data item in the locals dictionary each time around the loop. After I have called PyDict_SetItemString has the reference count on the object numpy_array been incremented, so I can call Py_DECREF(numpy_array) without losing d_data in the locals dictionary? After I have called PyRun_String if I call PyDict_DelItemString(locals,"d_data") will this remove all remaining references to d_data? Also, what happens to the data to which the numpy_array points? Is it free'd, or is it up to me to free it? For my purposes it would be much more efficient if I created numpy_array and d_data once and then manipulated the internal values of dimensions and the data pointer for numpy_array. But I don't really like doing this because messing around in the internal structure seems like a good way to cause future maintenance headaches. Is there any defined interface for doing something like this? I can't find anything in the Numerical Python manual. -- ----------------------------------------------------------- Nigel Wade, System Administrator, Space Plasma Physics Group, University of Leicester, Leicester, LE1 7RH, UK E-mail : nmw at ion.le.ac.uk Phone : +44 (0)116 2523568, Fax : +44 (0)116 2523555 From debl.nospam.nono at world.std.com Tue Oct 17 00:06:22 2000 From: debl.nospam.nono at world.std.com (David Lees) Date: Tue, 17 Oct 2000 04:06:22 GMT Subject: Use of Win32all with Python 2.0 final? Message-ID: <39EBD042.171141BA@world.std.com> Mark Hammond's Build 134 of Win32all says it is for Python 2.0b1. Will it work properly with the newly released Python 2.0 final or should I wait for a new build? David Lees From tim at degree.ath.cx Thu Oct 19 21:38:53 2000 From: tim at degree.ath.cx (Tim Hammerquist) Date: Fri, 20 Oct 2000 01:38:53 GMT Subject: Perl rules - Python drools References: <8s6ksl$mea$1@ctb-nnrp2.saix.net> <39e77de7.28583100@news.davesworld.net> <39EEE96B.7C8C8891@holdenweb.com> Message-ID: "David T. Grove" wrote: > wrote: > > begin 666 cameleatingpython.jpg [ snipped long troll-evoked response ] > You might consider thinking twice before trolling, there's likely to > be someone in the group who can slam you harder than you wanna be, you > wannabe. YHBT. YHL. HAND. -- -Tim Hammerquist Millions long for immortality who do not know what to do with themselves on a rainy Sunday afternoon. -- Susan Ertz From quinn at zloty.ugcs.caltech.edu Tue Oct 17 16:10:39 2000 From: quinn at zloty.ugcs.caltech.edu (Quinn Dunkan) Date: 17 Oct 2000 20:10:39 GMT Subject: Checking whether an object has been created. References: <39EC83BC.797424B0@vibes.net> Message-ID: On Tue, 17 Oct 2000 18:52:12 +0200, Olivier CARRERE wrote: >Hello, > >has anyone a clean method to check if an object has been instanciated? > >What I wish to do is to create an object if it hasn't been made before, >ie something like this : > >if not exists(objectReference): > objectReference=Object() ># perform stuff on objectReference > >Thanks in advance, > >- Olivier try: obj except NameError: obj = Obj() If you have an object which may or may not exist, it would probably be cleaner to keep it in a dictionary. Then you could write: obj = objstore.get('myobj', Obj()) or obj = objstore.setdefault('myobj', Obj()) # in 2.0 obj = objstore['myobj'] = objstore.get('myobj', Obj()) # in 1.5.2 BTW, calling things xReference or yReference in python is going to get tiring because *everything* is a reference :) From jkraska1 at san.rr.com Wed Oct 25 00:00:53 2000 From: jkraska1 at san.rr.com (Courageous) Date: Wed, 25 Oct 2000 04:00:53 GMT Subject: Of what use is 'lambda'??? References: <39cbdb38.38624667@news.bright.net> Message-ID: <39F65BC5.E05A5FDA@san.rr.com> > (defun foo-blah-quux-prepare-for-baz (arg) > Maybe I should shut up now before I make lisp look a > lot worse than it really is. That *was* pretty horrific, but isn't required with ANSI Common Lisp. C// From root at rainerdeyke.com Wed Oct 11 23:08:33 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Thu, 12 Oct 2000 03:08:33 GMT Subject: Programmer-Wanna-Be (Is Python for me?) References: <8s2354$ep2$1@nnrp1.deja.com> <8s2q2a013la@news1.newsguy.com> Message-ID: "Tim Hammerquist" wrote in message news:slrn8ua6rr.mg.tim at degree.ath.cx... > What, vi-users are a minority over here? Heck, I might as well just go > back to clpm! *j/k* "soundly hated by most editor-users?" How many of > this alleged majority even know what vi/vim is? I do have to agree > though: we are quite vocal. =) The other editor users are just jealous of the power and beauty of vi. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From aleaxit at yahoo.com Wed Oct 11 18:45:25 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 12 Oct 2000 00:45:25 +0200 Subject: How does "for" work? References: <8s17bl02cuq@news1.newsguy.com> Message-ID: <8s2qm80145a@news1.newsguy.com> "Steve Juranich" wrote in message news:Pine.SOL.3.96.1001011131237.10163C-100000 at condor.ee.washington.edu... [snip] > > rather than a list? Using it correctly with a for-loop requires > > that the keys be a compact set of integers from 0 upwards -- and > > in this case, what do you gain by making it a dictionary rather [snip] > self.data is a time-indexed bunch of data structures. I would have used a > list, but I wanted to allow for start times != 0. I know that in the other > "P" language, it allows re-defining the start index of a list. Has Python > implemented a similar bad idea? No, list-index always starts from 0 in Python. But then, you DO need the first index to be 0 if the object is to be iterated on with a for statement -- that one calls the __getelement__ method starting from 0, too. So, a list, plus a separate 'actual start index', seems a better solution than an array. Alex From ats1 at ukc.ac.uk Mon Oct 9 18:34:36 2000 From: ats1 at ukc.ac.uk (Adam Sampson) Date: 09 Oct 2000 23:34:36 +0100 Subject: Why is "while" ticking me off??? References: <39DD15A1.442E5A33@ix.netcom.com> <39E1254A.B0F55D01@my.signature> <87zokes2wc.fsf@cartman.azz.net> <8rstcj$t1n$1@panix3.panix.com> Message-ID: <87aecdmyo3.fsf@cartman.azz.net> aahz at panix.com (Aahz Maruch) writes: > In article <87zokes2wc.fsf at cartman.azz.net>, > Adam Sampson wrote: > > > >How about adding a "set to" operator? > > > >if a := dict[k1]: > > a.something() > > See dict.setdefault() in the Python 2.0 documentation. I wasn't being serious, but dict.setdefault() is backwards from what I was intending there. If = were an operator in Python with the same meaning it has in C, then you could have written that as: if a = dict[k1]: a.something() -- Adam Sampson azz at gnu.org From alfred6465 at my-deja.com Tue Oct 17 16:26:17 2000 From: alfred6465 at my-deja.com (alfred6465 at my-deja.com) Date: Tue, 17 Oct 2000 20:26:17 GMT Subject: Reading a binary file in as hex Message-ID: <8sicku$91r$1@nnrp1.deja.com> Hello, I am new to python and am kinda stuck on something. I have a binary file which I would like to read as hexidecimal. The file can vary in length. After I get it in a hex format I want to scan through it to look for certain numbers. Any thoughts on how to do this? Thanks for the help in advance. Sent via Deja.com http://www.deja.com/ Before you buy. From jackxh at my-deja.com Mon Oct 30 23:51:46 2000 From: jackxh at my-deja.com (jackxh at my-deja.com) Date: Tue, 31 Oct 2000 04:51:46 GMT Subject: Would anyone show me how to use htmllib? References: <8te2ch$8ou$1@nnrp1.deja.com> Message-ID: <8tlj50$u47$1@nnrp1.deja.com> Thanks for all of the help. Your examples are very helpful. One question is how did you guys figure those things out? python reference library are not clear about a lot of the variables and functions calls. Thanks again. Jack Xie Sent via Deja.com http://www.deja.com/ Before you buy. From sholden at holdenweb.com Thu Oct 26 14:11:21 2000 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 26 Oct 2000 14:11:21 -0400 Subject: TypeError References: <39F83ED4.57ADB649@hotmail.com> <39F86026.D65F0CB7@hotmail.com> Message-ID: <39F873C9.B7C96FC1@holdenweb.com> joonas wrote: > > I used the "print type(first)" method and it printed > > "" > > but when i wrote used "print first" it gave me > > "100" > > So. How can i make first substractable. > > Joonas. If you can tell me how to subtract three from a banana, I'll tell you how to subtract one hundred from a button! The confusion seens to be that you want to get some numeric property of the button (probably its caption) and subtract that from it. A button is a complex graphical object, with many properties. When you see "100" as the value of the button in printing it, the print statement is actually asking the Python system to produce a printable representation of itself. Look in the Tkinter documentation at the properties of buttons, and you'll probably find what you need is something like sppedgear.text = str(int(first.text) - int(second.text)) Hope this helps. regards Steve -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ From arneh++ at ifi.uio.no Sat Oct 28 12:00:21 2000 From: arneh++ at ifi.uio.no (Arne Martin =?iso-8859-1?Q?G=FCettler?=) Date: Sat, 28 Oct 2000 18:00:21 +0200 Subject: Chosing between sys.argv and sys.stdin References: <39FA00DC.B234907E@holdenweb.com> Message-ID: <39FAF815.B3B76DFA@ifi.uio.no> Steve Holden wrote: > > Probably what you need is something like the following, which > will work for a single file name. You can easily extend it to > multiple filenames (left as an exercise to the reader...) something like: myfiles = map(open, sys.argv[1:]) or [sys.stdin] for file in myfiles: input = file.read() (put inside try-except for error handling) -- Arne Martin From moshez at math.huji.ac.il Sun Oct 29 15:41:32 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sun, 29 Oct 2000 22:41:32 +0200 (IST) Subject: PythonWin IDE sucks! In-Reply-To: <39f9f7d2.49345203@nntp.interaccess.com> Message-ID: [Dale Strickland-Clark] >I've just received this by email: > >"As a friend of the person who wrote PythonWin, I didn't see anything >lighthearted about your message at all and although I have some ideas >to help you improve your situation, there is no way I am going to >bother unless you apologize. I suspect a lot of very knowledgeable >people reading the list feel the same way. >Paul Prescod" [Thaddeus L. Olczyk] > While not advocating your posts, I will say that this is a stupid > email. The guy probably doesn't have any clue how to help you and is > just bluffing to try to make you feel bad. Invariably some call for > help which turns into a flame war draws this exact response "I could > help but I won't because I think you are an asshole." The only thing I > think it accomplishes is to make the sender look stupid and the > community he represents look a little less intelligent overall. > I wish people would stop it. As someone who knows both Mark H and Paul P, I'm going to take all my friends from Python-Dev, some friends from lynx-dev, a few good men from Debian-Devel and RMS, and we're going to....well, we're probably going to argue what software to use on the tanks we'll have. We'll quickly whip up something in Python, but then Mark H will suggest we write the UI in MFC/Python, the lynx-dev guys will argue that this is neither blind- nor color-blind-friendly and will ask to write the interface via a web-server. Paul will be very happy to write an offline script to take a ui definition in XML and translate it to HTML, while the Debian-Devel guys wonder which mailer to install on the system, and whether the upgrade path is safe. RMS will walk around and remind everyone that if they're using GPL'ed code they have to relase the derived work as GPL also. We'll probably have so much fun writing the software, we'll forget to actually use it to control the tanks, so you have nothing to fear from us. -- Moshe Zadka -- 95855124 http://advogato.org/person/moshez From sandj.williams at gte.net Tue Oct 10 23:10:49 2000 From: sandj.williams at gte.net (Steve Williams) Date: Wed, 11 Oct 2000 03:10:49 GMT Subject: Worked on DCOM Today Message-ID: <39E3DAD0.2A419CF3@gte.net> Started with Python 'Server execution error', VBA "ActiveX can't create object..." Nothing showing in the debug trace. Server works with local client, remote client gives 'Server execution error'. Suddenly, things started to work. Why? What did I change? The remote client started to show up in the trace. Everything's working. Debugged a Unicode problem. Changed the Python server code, reregistered and ran. Same unicode error--the trace showed the old server program was still invoked, not the new version. Unregistered server and client, reregistered. Old program still running. Deleted pyc files, unregistered, reregistered, old program still running. Where was the old program coming from? Unregistered and deleted everything, rebooted client and server. Now Pythonpath no longer has win32com on client and server. How did that happen? I didn't modify Pythonpath to begin with. Added win32com back to PythonPath with regedit. Back to 'Server execution error', no progress since then. From steffen.ries at sympatico.ca Thu Oct 12 08:13:36 2000 From: steffen.ries at sympatico.ca (Steffen Ries) Date: Thu, 12 Oct 2000 12:13:36 GMT Subject: pyGTK -- how to wait for modal dialog? References: Message-ID: ge at nowhere.none (Grant Edwards) writes: > In article , Grant Edwards wrote: > > >I've created a modal dialog box, but can't figure out how to > >wait until the dialog is dismissed so I can find out which > >button was pressed. > > Here's what I've figured out so far (it seems to work), is it > the recommended idiom? > > class FooBar(GtkDialog): > __super = GtkDialog > def __init__(self,msg,buttonTextList): > self.__super.__init__(self) > self.__returnString = None > self.set_modal(TRUE) > [...] > > def clicked(self,buttonWidget,buttonText): > self.__returnString = buttonText > self.destroy() > > def wait(self): > while self.__returnString is None: > mainitereation() > return self.__returnString > > The important thing is that mainiteration blocks until it > receives an event -- this is the default behavior. I came up with a similar solution, but I can't say whether *that* one is recommended: class Dialog(GtkDialog): def __init__(self, parent, ...): ... self.retVal = None self.set_modal(TRUE) self.set_transient_for(parent) def run(self): self.show_all() self.dest_id = self.connect("destroy", self.close) mainloop() # blocks until mainquit() is called return self.retVal def close(self, _o, val=None): self.retVal = val self.disconnect(self.dest_id) self.destroy() mainquit() The actual dialogs would inherit from Dialog and connect self.close() to some button, which passes the appropriate return value. (Just closing the window acts like canceling the dialog). hth, /steffen -- steffen.ries at sympatico.ca <> Gravity is a myth -- the Earth sucks! From grante at visi.com Fri Oct 20 11:28:03 2000 From: grante at visi.com (Grant Edwards) Date: Fri, 20 Oct 2000 15:28:03 GMT Subject: newbie References: <8soeic$57gs$2@newssvr05-en0.news.prodigy.com> Message-ID: <7wZH5.2296$FU3.559467@ptah.visi.com> In article <8soeic$57gs$2 at newssvr05-en0.news.prodigy.com>, LONNIE wrote: >I have been teaching myself python for about a month now for >the simple reason that I have read alot of literature that says >that its easy to jump from python to c++. Python is an excellent language with with to learn generally programming and object-oriented programming. It is an excellent first language (I'd recommend two or three others as second/third languages rather than C++, but there are pragmatic reasons why one might want to learn C++). C++, just plain sucks (IMO). It's complicated, hard to write, harder to read, and unsafe. It will be far easier to learn, however, if you already know the basics of programming and object-oriented thinking -- and Python is excellent for learning that. -- Grant Edwards grante Yow! .. he dominates the at DECADENT SUBWAY SCENE. visi.com From xander at bos.nl Fri Oct 13 05:14:11 2000 From: xander at bos.nl (Xander van Es) Date: Fri, 13 Oct 2000 11:14:11 +0200 Subject: Problem installing the python-ldap mod Message-ID: <971428378.905163@proxy.bos.nl> # make cd Modules && make srcdir=/home/xander/python-ldap-1.10alpha3/Modules VPATH=/home/xander/python-ldap-1.10alpha3/Modules make[1]: Entering directory `/home/xander/python-ldap-1.10alpha3/Modules' ld -G LDAPObject.o common.o constants.o errors.o functions.o ldapmodule.o message.o version.o linkedlist.o template.o CIDict.o -L/tmp/ldap-pfx/lib -lldap -llber -lsocket -lnsl -lm -lkrb -o _ldapmodule.so ld: fatal: library -lldap: not found ld: fatal: library -llber: not found ld: fatal: File processing errors. No output written to _ldapmodule.so make[1]: *** [_ldapmodule.so] Error 1 make[1]: Leaving directory `/home/xander/python-ldap-1.10alpha3/Modules' make: *** [_ldapmodule-build] Error 2 Anyone an idea? Please help. Xander From aleaxit at yahoo.com Wed Oct 11 10:42:21 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 11 Oct 2000 16:42:21 +0200 Subject: how do I register a local-server-only COM object in Python? References: <8s1dav02iog@news1.newsguy.com> <39E470C3.AD1D2123@holdenweb.com> <39E471DC.138CA8F4@holdenweb.com> Message-ID: <8s1ui405tc@news1.newsguy.com> "Steve Holden" wrote in message news:39E471DC.138CA8F4 at holdenweb.com... > In my previous posting I inadvertently wrote > > CLSCTX_LOCALSERVER > > when I should have written > > CLSCTX_LOCAL_SERVER > > Steve Holden wrote: > > > ... > > As you suspect, the default used is > > > > CLSCTX_LOCALSERVER | CLSCTX_INPROC_SERVER Also, the property name was mis-spelled. But, no matter: _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER adding this line to the shareddictionary.py I was playing with works a charm, and does indeed register just the local-server version, as desired. Thanks!!! Alex From hwanjoyu at uiuc.edu Tue Oct 24 16:01:48 2000 From: hwanjoyu at uiuc.edu (Hwanjo Yu) Date: Tue, 24 Oct 2000 15:01:48 -0500 Subject: Q: re Message-ID: Hi, It seems that '|' is not working for the OR in regular expression. For instance, >>> matchstr = re.compile(r".*homepage", re.IGNORECASE) >>> re.match(matchstr, "http://www.my.com/me/homepage") In this case, it returns the match object because the "homepage" is matched. But, >>> matchstr = re.compile(r".*homepage | .*~.*", re.IGNORECASE) >>> re.match(matchstr, "http://www.my.com/me/homepage") In this case, this should return matchobject since it matches the "homepage", but it doesn't. What is wrong here ? Thanks. From fgeiger at datec.at Sat Oct 21 05:20:32 2000 From: fgeiger at datec.at (Franz GEIGER) Date: Sat, 21 Oct 2000 11:20:32 +0200 Subject: Eval the caller within a method? Message-ID: <8srn4j$lr8$1@newsreaderm1.core.theplanet.net> I wonder if in Python there is a possibility to evaluate the method which called a method within that method like it is in Perl. This would prevent me from having to write code like logIt = TLog("Callers name") logIt("Some diagnostics"); (printing: "'Callers name': Entered. " "Callers name': Some diagnostics" ) because TLog() could figure out which method called it. Any ideas? Best regards Franz GEIGER From syver at cyberwatcher.com Wed Oct 25 08:34:43 2000 From: syver at cyberwatcher.com (Syver Enstad) Date: Wed, 25 Oct 2000 14:34:43 +0200 Subject: Using COM constants on under IIS ASP. Message-ID: Does anybody know how to access the constants of COM objects created with Server.CreateObject. I tried using the global.asa file to accomplish this, but it doesn't seem to work. Any help / directions much appreciated. From tim_one at email.msn.com Sat Oct 14 02:21:23 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 14 Oct 2000 02:21:23 -0400 Subject: fill a sequence In-Reply-To: Message-ID: [Johannes Zellner] > is there somthing like the C++ std::fill() No. > e.g. I want to create a sequence of 5 0's [0] * 5 > a = [0, 0, 0, 0] a = [0] * 4 "sequence * int" is defined for all Python sequence types (incl. lists, arrays, tuples and strings). Advanced trick of the trade: s * 0 can be used to create an empty sequence of the same type as s, without needing to know s's type. Slice notation can also be used for that purpose: s[:0] # i.e., one way to ask for an empty slice See section "Sequence Types" in the Library Reference Manual. From aleaxit at yahoo.com Fri Oct 6 04:48:33 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 6 Oct 2000 10:48:33 +0200 Subject: Fibonacci Sequence and Long numbers. References: Message-ID: <8rk3v401brs@news1.newsguy.com> "Will Ware" wrote in message news:G1zo3M.Fzw at world.std.com... > Neil Macneale (macneale at cats.ucsc.edu) wrote: > > I am using MacPython 1.5.2 on a G3 powerbook, and I am getting a > > strange result from a fibonachi function. > > You might have better luck with a dictionary than a list, something > like this: > > cache = { } > cache[0] = 0L > cache[1] = 1L > > def fib(i): > try: return cache[i] > except KeyError: pass > cache[i] = fib(i-1) + fib(i-2) > return cache[i] > > print fib(1000) > > Oddly, when I try fib(10000) on a Linux box (Red Hat 6.2), I get a > segmentation fault and core dump. That's a pretty rare thing to get > from Python, it might suggest a fault in the long-integer arithmetic > module. Never having looked at it, and having no idea whose toes I'm > stepping on by suggesting this possibility, I'll now duck back into > the woodwork. Hmmm, maybe a stack overflow? Using 0.0 and 1.0 for the original cache entries (so that floating-point arithmetic is involved rather than long-integers) gives me exactly the same huge-traceback (no segfault in either case) on Python 2.0b2 (IDLE, Win/NT 4 SP6). I suspect that in this case recursion does need to be truly eliminated, if you need computations as deep as fib(10000). And in this case, you might as well go for the lower overhead of a list of cached (memoized) results rather than a dictionary. Performance gets REALLY better...! Consider this little module prova.py: cache = { } cache[0] = 0L cache[1] = 1L def fibd(i): try: return cache[i] except KeyError: pass cache[i] = fibd(i-1) + fibd(i-2) return cache[i] lcac = [0L, 1L] def fibl(i): try: return lcac[i] except IndexError: pass now_have = len(lcac) but_need = i+1 lcac.extend([0]*(but_need-now_have)) for j in range(now_have, but_need): lcac[j]=lcac[j-1]+lcac[j-2] return lcac[i] import profile profile.run('prova.fibd(500)') profile.run('prova.fibl(500)') Results of a "reload(prova)" are: 1001 function calls (3 primitive calls) in 0.160 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 0.159 0.159 :1(?) 0 0.000 0.000 profile:0(profiler) 1 0.001 0.001 0.160 0.160 profile:0(prova.fibd(500)) 999/1 0.159 0.000 0.159 0.159 prova.py:5(fibd) 3 function calls in 0.005 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 0.004 0.004 :1(?) 0 0.000 0.000 profile:0(profiler) 1 0.001 0.001 0.005 0.005 profile:0(prova.fibl(500)) 1 0.004 0.004 0.004 0.004 prova.py:13(fibl) And, of course...: >>> prova.fibl(10000) 3364476487643178326662161200510754331030214846068006390656476997468008144216 6662368155595513633734025582065332680836159373734790483865268263040892463056 4318873545443695598274916066020998841839338646527313000888302692356736131351 1757929743785441375213052050434770160226475831890652789085515436615958298727 9682987510631200575428783453215515103870818298969791613127856265033195487140 2142875326981879620469360978799003509623022910263681314931952756302278376284 4154036058440257211433496118002309120828704608892396232883546150577658327125 2546093591128203925285393434620904245248929403901706233888991085841065183173 3604374707379085526317643257339937128719375877468974799263058370657428301616 3740896917842637862421283525811282051637029808933209990570792006436742620238 9783111470054074998459250360633560933883831923386783056136435351892133279732 9081337326426526339897639227234078829281779535805709936910491754708089318410 5614632233821746563732124822638309210329770164805472624384237486241145309381 2206564914032751086643394517512161526545361333111314042436854805106765843493 5238369596534280717687753283482343455573667197313927462736291082106792807847 1803532913117677892465908993863545932789452377767440619224033763867400402133 0343297496902028328145933418826817683893072003634795623117103101291953169794 6076327375892535307725523759437884345040677155557790564504430166401194625809 7221672975861502696844314695203461493229110597067624326851599283470989128470 6740862008587135016260312071903172086094081298321581077282076353186624611278 2455372085323653057759564300725177443150515396009051686032203491632226408852 4885243315805153484962243484829938090507048348244932745373262456775587908918 7190803662058009594743150052402532709746995318770724376825907419939632265984 1474981936092852239450397071654431564213281576889080587831834049174345562705 2022356484649519611246026831397097506938264870661326450766507461151267752274 8621598642530711298441182622661057163515069260029861704945425047491378115154 1399415506712562711971332527636319396069028956502882686083622410820505624307 01794976171121233066073310059947366875L >>> Alex From hove at phys.ntnu.no Fri Oct 13 14:12:54 2000 From: hove at phys.ntnu.no (Joakim Hove) Date: 13 Oct 2000 20:12:54 +0200 Subject: File tests in Python References: Message-ID: Following up on my own post: > [...] Writing > > List = [1,2,["List","in","List"]] > > in Python is just the way it _should_ be, really nice! In this case List[0] and List[1] are simple scalars - whearas List[2] is a new list (or is this a "unPythonlike" way of thinking ??). Is there a way of testing this, i.e. for x in range(len(List)): if is_scalar L[x]: print "List[",x,"] is scalar" else print "List[",x,"] is not scalar - maybe a list?" Joakim Hove -- === Joakim Hove www.phys.ntnu.no/~hove/ ====================== # Institutt for fysikk (735) 93637 / E3-166 | Sk?yensgate 10D # # N - 7491 Trondheim hove at phys.ntnu.no | N - 7030 Trondheim # ================================================ 73 93 31 68 ======== From urner at alumni.princeton.edu Fri Oct 13 20:34:12 2000 From: urner at alumni.princeton.edu (Kirby Urner) Date: Fri, 13 Oct 2000 17:34:12 -0700 Subject: Coming soon: Python in Math Class Message-ID: Review of my curriculum writing at the O'Reilly website: http://www.oreillynet.com/pub/a/python/2000/10/04/pythonnews.html (with pointers to "the beef" at my website). Kirby From tim_one at email.msn.com Sat Oct 7 16:43:05 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 7 Oct 2000 16:43:05 -0400 Subject: Is this a dream or a nightmare? (Was Re: XML) In-Reply-To: <39def2ae.8929692@news.davesworld.net> Message-ID: [David T. Grove] > ... > There have been three things keeping me out of Python: > ... > 2) I can't mentally deal with [:5] when logically it's [:4] > ... > Actually, 2 I can probably deal with using a compatibility library > and a function or two to make slices make sense until I'm used > to them being off by one. Actually, this part of Python is a dream. When I was learning C, I was baffled by why it declared arrays with a number one larger than the largest valid index, e.g. int a[10]; With a Fortran background at the time, "it was obvious" that arrays *should* be declared with their minimum and maximum indices instead: INTEGER A(0:9) Therefore, since C only allows 0 as its lower bound, the proper declaration would be int a[9]; But of course C had nothing of the sort in mind, and 10 is simply the number of elements in the array. Perfectly clear to everyone but me . You're similarly suffering a bad illusion wrt Python slices: from the Python POV, it would be insane to write [:4] when you want the first *five* elements -- *that* would cause a boundless number of off-by-one errors. The trick is that indices in Python point *between* array elements: |a[0]|a[1]|a[2]|a[3]|a[4]|a[5]| ... |a[len(a)-1]| ^ ^ ^ ^ ^ ^ ^ ^ ^ 0 1 2 3 4 5 6 ... len(a)-1 len(a) <--------- a[:5] --------> When you've got N adjacent boxes, there are N+1 "walls", and trying to map those into the ints from 0 thru N-1 inclusive is necessarily ambiguous. Slice notation names the walls, not the boxes. Picture the slice bounds as *intended*-- as identifying the gaps between elements --and there's a unique obvious int in the range 0 thru N inclusive to identify each wall, and you'll find that off-by-one errors are much less common in Python than in C or Perl. In general, a[i:j] contains j-i elements, and a[i:j] == a[i:k] + a[k:j], and those two cover a universe of practical problems. Give it a chance, and the notion that, e.g., a[i:i+2] could contain *three* elements will become abhorrent. The same "indices point between" idea is implicit in Java and the C++ STL, and explicit in the Icon language, for the same reasons: in practice, it works better. when-things-aren't-clear-turn-on-a-light-ly y'rs - tim From ams70 at cam.ac.uk Thu Oct 19 23:44:27 2000 From: ams70 at cam.ac.uk (Andy Smith) Date: 20 Oct 2000 04:44:27 +0100 Subject: Idea for improved tuple unpacking References: Message-ID: Michael Haggerty writes: > Hi, > > In my code the following idiom is pretty common: > > (first,second) = t[:2] > rest = t[2:] > > (t is a tuple). Other scripting languages (Perl, REXX, ...) have a > way to do this sort of thing in one statement. Then it occurred to me > that by analogy with function declaration syntax, it would be cool to > be able to do > > (first,second,*rest) = t While it isn't as short as your suggestion it is possible to do it in one line with current Python syntax: ((first, second), rest) = (t[:2], t[2:]) Andy -- Andy Smith ams70 at cam.ac.uk St John's College, Cambridge, CB2 1TP, UK (07989) 453208 From dalke at acm.org Fri Oct 13 12:17:49 2000 From: dalke at acm.org (Andrew Dalke) Date: Fri, 13 Oct 2000 10:17:49 -0600 Subject: hack to auto-define variables? References: Message-ID: <8s7cju$vte$1@nntp9.atl.mindspring.net> Samuel A. Falvo II wrote: [wants functionality like] > >>> x > *** Variable `x' implicitly declared in __main__, line ?? > None [although for class instances.] I don't understand the need for such a thing, except perhaps to reduce a bit of typing. For all such cases inside of an instance, can't you use getattr(self, "x", None) instead? It effectively does what you want, and is even a bit better since you can replace None with "" or 0.0 and specify the initial value. >This way, during the course of running the application being developed, I >can examine the log files to see if I need to do any source code cleanup. I've worked on several projects where compiler warnings were simply ignored. In one such, over 1,000 were generated, and about a dozen of them were real errors (most were about type casts and variables declared but not used). I'll wager that if this functionality is added, people will ignore its output, or even complain about how it obscures running code since they *know* it's correct. With my workaround, you don't get see the output, making it somewhat more difficult to see where you've added the interim code. On the other hand, "getattr(" is pretty rare code and easy to search for. In addition, the search can be done lexically, while for you case you would have to run all the execution paths to ensure you aren't missing something. Finally, you can have run-time output by writting your own variaion of getattr: def my_getattr(obj, name, default = None): if hasattr(obj, name): return getattr(obj, name) # ... do the work to get the caller's filename line number # (try: "" except: "" ; back up a stack frame and get the filename/lineno) # ... print the status information return default You may also want a "setattr(obj, name, default) before the return. In which case, this function should be renamed to, perhaps, "setdefaultattr". Andrew dalke at acm.org From glandrum at my-deja.com Sat Oct 28 09:57:22 2000 From: glandrum at my-deja.com (Greg Landrum) Date: Sat, 28 Oct 2000 13:57:22 GMT Subject: how to build DLLs with Cygwin References: Message-ID: <8telvv$kvo$1@nnrp1.deja.com> I assume that you were looking for instructions on how to do this. :-) The best source that I've found is: http://starship.python.net/crew/kernr/mingw32/Notes.html Another informative link for general win32 programming with cygwin is: http://www.geocities.com/Tokyo/Towers/6162/win32/index.html good luck, -greg Sent via Deja.com http://www.deja.com/ Before you buy. From aleaxit at yahoo.com Wed Oct 25 18:03:21 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 26 Oct 2000 00:03:21 +0200 Subject: C's syntax (was Re: Python Formatted C Converter (PfCC)) References: <8t0or303ee@news1.newsguy.com> <39F4FFB7.452EDDEC@alcyone.com> <8t3mdv025uo@news2.newsguy.com> <39F5B404.B5626FB7@alcyone.com> <8t4q8v11lpv@news1.newsguy.com> <39F5E620.C780A71C@seebelow.org> Message-ID: <8t7lio01u29@news2.newsguy.com> "William Tanksley" wrote in message news:slrn8veadt.roh.wtanksle at dolphin.openprojects.net... [snip] > I don't mind the syntax, myself; the hard part for me is how incredibly > poorly designed the standard library is. A good library is able to catch > mistakes; C's library usually 'detects' errors by corrupting memory and > dying later. Well, "catching mistakes" within a language of very low semantic level and its library is not easy -- and I think C's level was just right for its time & target (and still comes in handy often). Still, there are other design defects. For example, the idea of having strcpy and strcat return (rather uselessly) the same value that was passed as the first argument, rather than something useful, such as the pointer to the _end_ of the resulting string (so putting a long string together from small pieces ends up being O(N squared) if you want to use the C standard library -- you have to use another, custom library [or manipulate the pointers directly] to get the 'natural' O(N) performance). Or the useless inconsistencies in stdio routines about where the FILE* parameter goes. However, patching _these_ up with your own routines (or macros) is very easy, fortunately. Pity that everyone has to do it anew (or suffer the standard library's strange design limitations). > immediately). C's library, when thus tested, detected almost none of the > misuse. It's a design flaw, not something a compiler can easily fix. It's a design _decision_ -- being low-level and straining for performance, at the cost of error-checking or ease of use. I would not call this decision a _flaw_, per se. Alex From aquarius at kryogenix.org Tue Oct 24 20:01:19 2000 From: aquarius at kryogenix.org (Aquarius) Date: 25 Oct 2000 01:01:19 +0100 Subject: How do I force a single instance of a python app? References: <39f5e46f_3@corp.newsfeeds.com> <8t54f9$9r4$1@drmanhattan.kryogenix.org> Message-ID: <8t57sf$apn$1@drmanhattan.kryogenix.org> Aquarius spoo'd forth: > Joshua Muskovitz spoo'd forth: >> I need to prevent multiple copies of a python app from running >> simultaneously on a single machine. In Windows and C++, this is done with >> sending custom window messages to all top level windows, or using some other >> kind of scheme. >> >> I'm looking for a platform neutral way to do this for my python apps -- the >> second instance should somehow detect the first instance and should quietly >> kill itself. It does not need to notify the first instance of anything. >> Initial target platforms are Solaris and NT, but others will follow, so a >> generic solution would be the best. File existence is a bad solution >> because the first instance might (possibly) terminate before it could delete >> the file. I need a semaphore which will absolutely go away when the first >> instance dies, or else a way to reliably probe to see if the first instance >> exists on the fly. Another way to do this would be to have instance1 write its PID to the lockfile. Sadly, I can't find a way of knowing whether a process with a specific PID is running; you might have to shell out in a platform-specific way to do this. :-( You could have the processes signal each other with os.kill() and signal handlers, but, er, Don't Do That :) Aq. -- We learn that the material NSA is withholding from release ... describes an NSA database coincidentally called Aquarius. -- http://www.cufon.org/cufon/Aquarius/aquarius.htm From dbrueck at edgix.com Thu Oct 5 13:30:30 2000 From: dbrueck at edgix.com (Dave Brueck) Date: Thu, 5 Oct 2000 11:30:30 -0600 Subject: for in if Message-ID: <000201c02ef2$55aabcb0$6f37693f@PRODUT2KDAVE> Dave> for line in lines if line.strip.startswith('y'): Dave> doStuff(line) >What's wrong with > > for line in lines: > if line.strip().startswith('y'): > doStuff(line) Nothing at all. But then again, there's nothing wrong with 'x = x + 1' instead of 'x += 1', either. :) -Dave From grante at visi.com Fri Oct 27 12:43:31 2000 From: grante at visi.com (Grant Edwards) Date: Fri, 27 Oct 2000 16:43:31 GMT Subject: Python scoping References: <8FD6F80F0suppamanxcollectoror@209.155.56.95> Message-ID: In article <8FD6F80F0suppamanxcollectoror at 209.155.56.95>, SuppamanX wrote: > I have been using Python off and on for 6 months now and have grown to >love it from the beginning. However, there is a facett of Python that >annoys me somewhat. It is the 'scoping by indentation'. Coming from a >background of 'formal' languages (e.g. Pascal, C, Java,...), I am >accustomed to explicitly start and end my scopes with a braces. Perhaps you already know this, and I'm about to sound overly pedantic, but... You're mixing together two different things: scoping and statement grouping. They're two different (though in many languages not orthogonal) things. In C, Pascal, Java, the _same_ method is used for both scoping and grouping statements: the begin/end tokens and curly-braces do two distinct things: delimit a scope _and_ group multiple statements into a single "statement". In Python, indentation is used to group statements but it is not used for scoping, as you seem to indicate. >Can someone clarify why there is no explicit end for scopes? >(i.e. IFs, FORs, WHILEs, METHODs, etc...) In python, IF, FOR, WHILE do not start a new scope. The only thing that starts a new scope is a function definition. -- Grant Edwards grante Yow! BRILL CREAM is at CREAM O' WHEAT in another visi.com DIMENSION... From loewis at informatik.hu-berlin.de Tue Oct 3 11:08:23 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 03 Oct 2000 17:08:23 +0200 Subject: Import libraries and Borland C (Was: Wholly unnecessary flame.) References: <009f01c02b9d$51be26d0$0101a8c0@jayk3> Message-ID: "Bruce Dodson" writes: > This is not true. I'm not sure what 'this' you mean; I assume you refer to my statement > > But then, even *if* Borland C could link with the VC++ compiled > > python20.dll, you still could not build extension modules with > > it. You then wrote > You can mix and match, as long as you don't export borland-format > resources to MSVC-based consumers. That is, if memory is allocated > by Borland runtime library, it should freed by the Borland runtime. > If files are opened by Borland stdio, they should be encapsulated > and not exposed directly to Python. In Python, you are sometimes required to pass files opened in an extension to python.dll for consumption, e.g. in PyRun_AnyFile; you cannot encapsulate them if you want to use that API. Regards, Martin From paul.moore at uk.origin-it.com Mon Oct 30 09:08:21 2000 From: paul.moore at uk.origin-it.com (Paul Moore) Date: Mon, 30 Oct 2000 15:08:21 +0100 Subject: Using more than 7 bit ASCII on windows. References: <8tdlgd$r0t$1@news.nuri.net> <39FA90D9.7070403@ActiveState.com> <8tfpf7$jnn$2@troll.powertech.no> <39FCB40B.6090509@ActiveState.com> <8tjfrs02jte@news1.newsguy.com> <39FD75B0.1010103@ActiveState.com> Message-ID: On Mon, 30 Oct 2000 14:24:28 +0100, Mark Hammond wrote: >Alex Martelli wrote: > > >> Not sure what's going on here...? Perhaps an 'OEM codepage' >> in the dos-box versus another in PythonWin...? > >That is quite possible. However, I was already out of my depth ages ago >with this stuff! Although some will accuse Australian's of having their >own language, we do get by on ASCII characters ;-) That sounds very likely - ? in latin-1 is different from ? in the DOS-codepage - a fact I had forgotten, which has probably caused all of this confusion. Mark, thanks for your patience and explanations. I think I now have enough understanding to work out what is going. When I have a reasonably coherent explanation of things, I'll post it here, if there is interest. Paul. From joonas at olen.to Sun Oct 29 12:45:17 2000 From: joonas at olen.to (Joonas) Date: Sun, 29 Oct 2000 19:45:17 +0200 Subject: QUERY_STRING error References: <39FC1FF6.76FDABE3@NOUSPAMMhotmail.com> Message-ID: <39FC622D.BC469906@olen.to> But the script works and know that QUERY_STRING is in my environment. Joonas. Fredrik Lundh wrote: > > Joonas wrote: > > I got error seen below. > > > > > > > > Traceback (innermost last): > > File "./viestit.cgi", line 5, in ? > > komento = environ["QUERY_STRING"] > > File "/opt/python/lib/python1.5/UserDict.py", line 12, in __getitem__ > > def __getitem__(self, key): return self.data[key] > > KeyError: QUERY_STRING > > > > > > why not read the fine manual? > > library reference -> index -> k -> keyerror: > > KeyError > raised when a mapping (dictionary) key is not > found in the set of existing keys > > in other words, Python's telling you that there are no > QUERY_STRING in your environment. > > From max at alcyone.com Sat Oct 28 18:33:48 2000 From: max at alcyone.com (Erik Max Francis) Date: Sat, 28 Oct 2000 15:33:48 -0700 Subject: Howto find same files? References: <8tffmp$847$1@nnrp1.deja.com> Message-ID: <39FB544C.C2A03E4A@alcyone.com> gregoire.favre at ima.unil.ch wrote: > Would it be a good idea to create a files which contains the > path,filename,size,md5sum and then working on it? My utility which eliminates duplicate files (written in Python) simply keeps 1. the filename it first saw the file as (for reference), 2. a tag which can be used to indicate in what group it was seen (say, a date), 3. the file size, and 4. a 32-bit CRC. Since you're evidently already using a UNIX-like system, you can get the CRC for free: `cksum'. (This also gives you the file size without any extra work, which is helpful not so much for uniquely identifying the file, but also for being able to determine the size of your processed collection from the databaes alone.) It's really quite straightforward to write one; what's giving you trouble? -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ That which is resisted persists. \__/ Camden Benares Esperanto reference / http://mirror/alcyone/max/lang/esperanto/ An Esperanto reference for English speakers. From johannes at zellner.org Fri Oct 13 16:42:02 2000 From: johannes at zellner.org (Johannes Zellner) Date: 13 Oct 2000 20:42:02 GMT Subject: reference to objects Message-ID: Hello, what happens in python if I assing an object to different variables ? e.g.: class Lola: def __init__(x): x.y = 0 l = Lola() g = l # <-- !! now, does g.y = 1 modify l.y ? (do both variables refer to the same object ? -- Johannes From sh at ttsoftware.co.uk Thu Oct 26 11:41:16 2000 From: sh at ttsoftware.co.uk (Steve Horne) Date: Thu, 26 Oct 2000 16:41:16 +0100 Subject: Python scoping References: <8FD6F80F0suppamanxcollectoror@209.155.56.95> <39F5478B.41DF73BA@geneva-link.ch> <39f5e57b_1@corp.newsfeeds.com> Message-ID: On Tue, 24 Oct 2000 15:46:30 -0400, "Joshua Muskovitz" wrote: >> this tends to diminish the number of lines in a "scope", and thus >> optimizes for the chance that both ends are simultaneously visible >> on a single page, does it not ? > >Driving without my headlights at night tends to diminish my overall speed >and distance I prefer to travel, but it doesn't make my life easier or >safer, does it? The end of an indented section is at least as visible as an 'end;' or a '}'. Especially programmers using C, C++, pascal and other languages seem to have a wide range of stupid places that they habitually put these symbols, rather like having headlights on the roof and pointing upwards! If you read style guidelines for C, C++, pascal, modula 2, and ada you'll see consistent indenting is one of the most basic and important aspects of good readable code. But none of these languages enforce this - and it's easy for a program to evolve through maintenance to have very confusing half-done-but-inconsistent indenting. Believe me - I've worked with large programs in all these languages and more, and Python scores very high in readability. -- Steve Horne sh at ttsoftware.co.uk From News at Titanic.co.uk Sun Oct 22 13:42:07 2000 From: News at Titanic.co.uk (Simon Faulkner) Date: Sun, 22 Oct 2000 17:42:07 GMT Subject: Environment VAriables Message-ID: <0l96vs0fg2kvp630f8cukv1av2rp72v225@4ax.com> Answered my own question... import os print os.environ["REMOTE_ADDR]" Easy!!! Simon Faulkner From thomas.wright1 at ntlworld.REMOVETHIS.com Thu Oct 19 07:50:57 2000 From: thomas.wright1 at ntlworld.REMOVETHIS.com (Tom wright) Date: Thu, 19 Oct 2000 12:50:57 +0100 Subject: Help with threading Message-ID: Hi All, sorry if this is a newbie problem, but i have RTFM etc I have a problem with the following class from threading import * class KernelThread(Thread): "A Kernel Thread implementation" def __init__(self): # init the base class constructor Thread.__init__() # set the thread to a daemon thread self.setDaemon( TRUE ) # create the event we sleep on self.sleepingEvent = Event() # start the thread self.start(); def run(self): # the main thread event loop while(1): wait( self.sleepingEvent ) self.targetObject.handleMessage( self.internalMessage ) self.sleepingEvent.clear() del self.targetObject del self.internalMessage def handleMessage(self,message,destObject): # set up the data for the thread to handle self.internalMessage = message self.targetObject = destObject self.sleepingEvent.set() when i try and create an instance of the class i get >>> t = KernelThread() Traceback (innermost last): File "", line 1, in ? t = KernelThread() TypeError: call of non-function (type module) As i am a newbie to Python ( but not programming ), i seem to be missing something to do with threading/python syntax here. Any help REALLY appreciated, i am sure its an obvious omission on my part so dont flame me to hard :-) Regards Tom Wright From the_brain at mit.edu Sat Oct 14 16:01:42 2000 From: the_brain at mit.edu (Alex) Date: 14 Oct 2000 16:01:42 -0400 Subject: SMTP receive as well as send References: <39e8bfe4.2248931@news.demon.nl> Message-ID: > I'm in need of an SMTP setup that will allow me to receive as well as > send messages. The Python SMTPlib looked like a good bet but it seems > to be send-only (kind of like the POP3 lib stuff seems to be read > only). A python-based mailserver would be really cool, but I don't know of one. Most mailservers let you pass mail to an external program, though. As I understand mailman (all I've done is configure it for use; I haven't looked at the source much,) that's how it works. You might want to take a look at it. > Benny (who apologises if this has been discussed recently or if this > is obviously posted somewhere but days of searching hasn't helped) Heh, if we restricted ourselves to new stuff, the volume in the newsgroup would be decimated or worse, and then how would we procrastinate? But this is a new question, to me, at any rate. Alex. -- Speak softly but carry a big carrot. From sabren at manifestation.com Mon Oct 9 10:05:25 2000 From: sabren at manifestation.com (Michal Wallace) Date: Mon, 9 Oct 2000 10:05:25 -0400 (EDT) Subject: join() In-Reply-To: <39E1A345.6B6E@hvision.nl> Message-ID: On Mon, 9 Oct 2000, Hans Nowak wrote: > Greg Ewing wrote: > > > > echuck at mindspring.com wrote: > > > > > > In Python 2.0, I was surprised to see join() had become a method of > > > string. I "naturally" expected it to be a method of list. > > > > Quite a lot of people screamed blue murder about > > this at the time, and were ignored. Getting it > > changed now seems to be impossible. > > > > My advice is to boycott those methods and continue > > using the string module, which fortunately is > > still there. > > I second that. I never really saw the need for string methods anyway... > then again, maybe I'm just daft. :) However, it's not unlikely that the > string module will be deprecated, like other nice stuff. So I don't know > if it's a good idea to boycott it. ",".join.(sequence) makes perfect sense. There's no reason someone can't add sequence.join(',') later.. :) String methods are important to minimize complexity with unicode: http://starship.python.net/crew/amk/python/writing/new-python/ section 7 Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From rvprasad at cis.ksu.edu Mon Oct 30 00:35:16 2000 From: rvprasad at cis.ksu.edu (Venkatesh Prasad Ranganath) Date: 29 Oct 2000 23:35:16 -0600 Subject: Python in RedHat 7 References: <8t6bku$13s$1@lola.ctv.es> <20001028.114323.982936784.18601@locutus.noreboots.com> Message-ID: Hi, This problem has got to do with LONG_INT defined as 64 in /usr/include/bits/xopen_lim.h. Once you redefince it as 32 it compiles. -- Venkatesh Prasad Ranganath From kohler at medien.tecmath.de Fri Oct 27 04:13:31 2000 From: kohler at medien.tecmath.de (Markus Kohler) Date: Fri, 27 Oct 2000 10:13:31 +0200 Subject: os.system limitations on Windows NT References: <39F6A9CE.80407@cms.tecmath.de> <8t6d5408j3@news1.newsguy.com> Message-ID: <8tbd79$npq$1@sun.rhrk.uni-kl.de> Hi Alex, Alex Martelli schrieb in Nachricht <8t6d5408j3 at news1.newsguy.com>... >"Markus Kohler" wrote in message >news:39F6A9CE.80407 at cms.tecmath.de... >> Hi, >> I trying to execute a command with a large list of arguments. >> When I do os.system("link " + args) the program crashes. >> When I write the arguments to a file (fileName) and use >> >> os.system ("link @" + fileName) >> >> the arguments are truncated at an arbitrary point. > >That depends on your system (and on the link program you >use; it appears from the @-convention for automatic >response files, that you may be using some link.exe under >some Microsoft operating system). The link.exe that >comes with VC++6 is apparently able to take huge amounts >of arguments in an automatic-response-file (@filename). Yes that is exactly what I'm trying already. But what puzzles me is that it doesn't work when I call "link @filename" from Python. It truncates what is in the file. > >I'm not sure, but I think you may be able to download >that recent version of link.exe as a part of the freely >downloadable "Microsoft Platform SDK" at Microsoft's >website. Otherwise, the only solution I can think of >(taking advantage of a linker's specific semantics) >is to proceed in steps, grouping numbers of .obj files >into temporary .lib ones (using LIB.EXE, in a MS >setting), so the command arguments you eventually must >pass to LINK.EXE are substantially shorter. OK, but I really want to avoid this, because it is just more complicated. Markus From carroll at cis.ohio-state.edu Wed Oct 4 14:24:59 2000 From: carroll at cis.ohio-state.edu (Mark Carroll) Date: 4 Oct 2000 18:24:59 GMT Subject: Class Browsers vs Static Types (Re: Inefficiency of __getattr__) References: <39DB62F6.EF943473@geneva-link.ch> Message-ID: <8rfslr$335$1@news.cis.ohio-state.edu> In article , graham wrote: (snip) >Err, that's the point of a type system. If you have a piece of code >that does > > true + 1 > >it will cause a run-time problem of some sort, unless the code isn't >run. But the latter case is not very common, since no-one writes code >that they don't intend to run. (snip) Unless you have a very well designed test suite, for any significant project it's likely that not every line of code will actually be executed during development and testing. Indeed, some of the code I'm writing now has modules with features that aren't used by the functions that use the modules, but I'm expecting that some later version will use those features and it's easier to include them now rather than trying to add them on later. In particular, with languages like Lisp, without lots of (declare ...)'s I'd sometimes find type errors cropping up some time after the code had been put into use. -- Mark From mertz at gnosis.cx Fri Oct 13 12:20:09 2000 From: mertz at gnosis.cx (Lulu of the Lotus-Eaters) Date: Fri, 13 Oct 2000 12:20:09 -0400 Subject: Perl rules - Python drools (fwd) Message-ID: <5Yz55kKkXoKK092yn@bellatlantic.net> >>your art is well done, if the sentiment fails. Even more important, please do not post binaries to this group. If one wants to draw cartoons about the (dis)advantages of Python, fine. Put them at the end of a URL, and just give us the pointer to it. Makes things easier for everyone. From stephenk at cc.gatech.edu Thu Oct 12 14:40:46 2000 From: stephenk at cc.gatech.edu (Stephen Kloder) Date: Thu, 12 Oct 2000 14:40:46 -0400 Subject: Most Effective Way to Build Up a Histogram of Words? References: <8s4hc3$a5a$1@news.nuri.net> Message-ID: <39E605AE.495A8406@cc.gatech.edu> June Kim wrote: > > and then how could I sort the dictionary according to the > frequency order? > Rather than creating a list-of-tuples data structure, you might want to use Python's built-in sorting features: words=histogram.keys() words.sort(lambda x,y:cmp(histogram[y],histogram[x])) for w in words: print "%s : %d"%(w,histogram[w]) The above code sorts in decreasing order. Use cmp(histogram[x],histogram[y]) to sort increasing. -- Stephen Kloder | "I say what it occurs to me to say. stephenk at cc.gatech.edu | More I cannot say." Phone 404-874-6584 | -- The Man in the Shack ICQ #65153895 | be :- think. From ak42 at altavista.com Mon Oct 2 03:53:37 2000 From: ak42 at altavista.com (Alexander K) Date: Mon, 02 Oct 2000 07:53:37 +0000 Subject: do telnet-clients not connect() ? References: <39D70111.BCA114BD@the.sig> <39D7B063.F0F8071@engcorp.com> Message-ID: <39D83F01.B3E788E6@altavista.com> Peter Hansen wrote: > What hostname and port? my hostname:) no, not 127.0.0.1/localhost. and it was a port above 1024. as i said it seemed to open and listen just fine. however it seems my python is breaking down. i am not sure. i cant open up functioning sockets with python anymore, i think:( dunno where the prob is. > root, AFAIK. Also, have you tried '127.0.0.1' or 'localhost' for the > hostname, which should always work when on the same machine you try to > telnet to that address. tried now. didnt work. > It doesn't take host:port on my machine (FreeBSD 2.2.8), > but "telnet host port". same here, and yepp i did. > Doing the above (after "from socket import *") works on > my machine provided I use appropriate hostname and port settings... ok, so i figure it should work. hmm -- . . ... ~~~:[ com dot altavista at ak42 ]:~~~ ... From hnowak at cuci.nl Mon Oct 2 17:24:49 2000 From: hnowak at cuci.nl (Hans Nowak) Date: Mon, 2 Oct 2000 23:24:49 +0200 Subject: questions In-Reply-To: <39D8CF3C.C851E7B8@aer.com> Message-ID: <200010022127.e92LRNb18592@hera.cuci.nl> On 2 Oct 00, at 14:09, Xiaoxia Dong wrote: > i am working on one of the project which needs using python, i am trying > to read a directory and list all > the files there according to the directory tree. I am thinking to make > the directory name bold and trying to > have some format like a2ps in unix. I am just writing the output to a > text file. I don't use any graphical interface. Can anybody help me with > this? I'm not sure what you mean here... if you want all files in a certain directory, you can use glob: >>> import glob >>> glob.glob("c:/PythonWin/*.*") ['c:/PythonWin\\UNWISE.EXE', 'c:/PythonWin\\python.exe', ... etc ... 'c:/PythonWin\\test1.py', 'c:/PythonWin\\logfile.txt', 'c:/PythonWin\\xref-results.html'] If you want a files in all subdirectories in a tree, you should use os.path.walk: >>> import os >>> def visit(arg, dirname, names): # just an example print dirname, ":" print names >>> os.path.walk("c:/foo/bar/", visit, 0) # should print list of subdirectories and their files Hope this will get you started, --Hans Nowak (zephyrfalcon at hvision.nl) You call me a masterless man. You are wrong. I am my own master. May a red dragon make a horoscope about your arms! From the_brain at mit.edu Sun Oct 29 15:05:14 2000 From: the_brain at mit.edu (Alex) Date: 29 Oct 2000 15:05:14 -0500 Subject: Backwards searching for regexps? References: Message-ID: > How about something like '.*regexp'? Since the * is greedy, I guess > that will give the last match, too. Is that efficient? OK, looks like this is fast enough for my purposes. Alex. -- Speak softly but carry a big carrot. From cfelling at iae.nl Tue Oct 24 10:08:31 2000 From: cfelling at iae.nl (Carel Fellinger) Date: 24 Oct 2000 16:08:31 +0200 Subject: Newbie question: Replace line in file? References: <8t259u$hud$1@nnrp1.deja.com> <8t2cgo0l50@news2.newsguy.com> Message-ID: <8t454v$p9p$1@animus.fel.iae.nl> Alex Martelli wrote: ... > for line in fileinput.input(onefilename, inplace=1): > print line.replace(old,new) there should be a trailing ',' at the end of that print statement, like: print line.replace(old,new), ... > for line in fileinput.input(allfiles, inplace=1): > print line.replace(old,new) and of course here too, like: print line.replace(old,new), -- groetjes, carel From MarkH at ActiveState.com Wed Oct 25 05:36:31 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 25 Oct 2000 09:36:31 GMT Subject: win32all build 135: missing functions from win32gui...? References: <8t3iqh021lg@news2.newsguy.com> <8t65071en@news1.newsguy.com> Message-ID: "Alex Martelli" wrote in message news:8t65071en at news1.newsguy.com... > "Mark Hammond" wrote in message > news:qVtJ5.14237$Ab3.72584 at news-server.bigpond.net.au... > > "Alex Martelli" wrote in message > > news:8t3iqh021lg at news2.newsguy.com... > > > > > Apparently, win32gui in build 135 is exporting the > > > following functions whose names start with Get...: > > > > I have no idea what happened here? They appear to have > > been disabled for ages. I have reenabled them... > > So we'll wait for build 136, right...? It would be 137 - 136 is a 1.5.2 build, and suffers the same problem. If starship was up, I could put it there. I'm not sure it is urgent enough to bother with for the next few days until its fate is known. I could always mail it to you ;-) Mark. From thomas at xs4all.net Wed Oct 11 04:26:14 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Wed, 11 Oct 2000 10:26:14 +0200 Subject: [Python-Dev] RE: Possible bug (was Re: numpy, overflow, inf, ieee, and rich comparison) In-Reply-To: ; from tim_one@email.msn.com on Wed, Oct 11, 2000 at 12:40:41AM -0400 References: Message-ID: <20001011102614.R12812@xs4all.nl> On Wed, Oct 11, 2000 at 12:40:41AM -0400, Tim Peters wrote: > We need a glibc expert! Anyone qualify? No, at least not me ;) > So the remaining question is why the same exp from the same library has > different errno behavior depending on which version of Python it's called > from. *That* one we couldn't answer, after a fruitless time digging thru > the Byzantine glibc source code trying to reverse engineer it. Their exp > *can* display different error behavior at runtime depending on several > obscure things, but they're too obscure to relate back clearly to anything > Python is doing. Well, I've seen & heard about compilers doing slightly different things depending on ANSI or K&R style C, so perhaps the presence of ANSI C definitions triggered this. I sincerely doubt it, though, but you never know, and it's fairly easy to test. > I don't know what to do next. I can't pursue it myself, and you've seen > from the lack of replies to your posts that I'm the only who'll even listen > to you . Guido suggests that one big change in 2.0 is that we're > including a lot more std headers than we used to. It could well be that one > of those #defines some God-forsaken preprocessor symbol one of whose five > meanings (documented or not) is "use POSIX-conformant libm error reporting", > but which someone #include'd in 2.0 to make (who knows?) sockets work right > on some other flavor of Unix. Don't know. Unix config is a mess, and so is > glibc. Best hope now is for someone intimately familiar with glibc > internals to jump in and own this. Actually, there was some activity to define the right combination of _GNU_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE, _BSD_SOURCE, et al, but I'm not sure what the end result was. If any #define changes the behaviour of glibc, these would definately be it ! A simple test might be to compile 1.5.2 with the config.h from 2.0, and manually add whatever _*_SOURCE defines aren't in 1.5.2. (They reside in Python.h and config.h, currently.) I'll see if I can reproduce it on the glibc almost-2.2 (that is, glibc-2.1.94) systems here, and do some of the above tests. Computers-suck-ly y'rs, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From bruce at hoult.org Mon Oct 9 17:55:39 2000 From: bruce at hoult.org (Bruce Hoult) Date: Tue, 10 Oct 2000 10:55:39 +1300 Subject: Class Browsers vs Static Types (Re: Inefficiency of __getattr__) References: <39DB62F6.EF943473@geneva-link.ch> <8rst48$iqoq6$1@ID-9852.news.cis.dfn.de> Message-ID: In article <8rst48$iqoq6$1 at ID-9852.news.cis.dfn.de>, "Joachim Durchholz" wrote: > C++ compilers started as C preprocessors. Yet enough people liked C++ so > that it would be accepted. This is wrong. C++ has *always* been a true compiler that just happened to produce C output instead of assembler (as indeed many functional languages do). Objective C was originally a preprocessor (and it shows in the syntax). The litmus test: you should *never* get any error messages from the underlying C compiler, even when you present faulty code to the front end (C++, Scheme, Dylan, Mercury, ...) compiler. If you do then it's a bug in either the front end compiler or the C compiler. -- Bruce From phd at phd.russ.ru Thu Oct 12 11:30:46 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Thu, 12 Oct 2000 15:30:46 +0000 (GMT) Subject: Timeout for urllib.urlopen(...) In-Reply-To: <8s4kp1$r4r$1@reader1.imaginet.fr> Message-ID: On Thu, 12 Oct 2000, Gilles Lenfant wrote: > Has any of you any hint for making like urllib.urlopen(...) but with a > TimeOut ? > I'm making a script to check if the Web application server is running. > If it's down... the urllib.urlopen(...) waits for a reply till... there's no > more power supply. First thing to try is http://www.timo-tasi.org/python/timeoutsocket.py Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From fredrik at effbot.org Tue Oct 31 17:26:35 2000 From: fredrik at effbot.org (Fredrik Lundh) Date: Tue, 31 Oct 2000 22:26:35 GMT Subject: destructors order not guaranteed? References: <39FDBC9E.5030204@netscape.com> <8tkj6o05dm@news1.newsguy.com> <87snpduoxg.fsf@lisa.zopyra.com> <8tmlsb022v4@news1.newsguy.com> <878zr5ez0i.fsf@lisa.zopyra.com> Message-ID: William wrote: > Which is what I would like, but I guess this will take some getting > used to ... I really do prefer LIFO order. it doesn't matter what you prefer, or what the current version of CPython happens to do: it's perfectly legal for a Python implementation to *never* call any destructors at all... you have been warned ;-) From sholden at holdenweb.com Fri Oct 20 16:57:18 2000 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 20 Oct 2000 16:57:18 -0400 Subject: newbie References: <8soeic$57gs$2@newssvr05-en0.news.prodigy.com> Message-ID: <39F0B1AE.88B92A2C@holdenweb.com> LONNIE wrote: > > I have been teaching myself python for about a month now for the simple > reason that I have read alot of literature that says that its easy to jump > from python to c++. I was just wondering if this was true also I have been > teaching myself from online tutorials but I have been looking for a good > book to go along with the literature that I have downloaded so far any > suggestions would be nice. > > thanks > Lonnie > lonniet at prodigy.net I think you will learn a lot about object-oriented programming in Python which will stand you in good stead when you make the transition to C++. But the principal advantage of learning Python before C++ is that you may end up convinced (unless your applications call for high efficiency or need to be integrated with other C++ code) that you don't really need to learn C++ at all! It's a much more restrictive language that Python: where Python tends to be permissive (you can do these things, but you might end up in trouble if you don't do them right), C++ is proscriptive (you can't do this, and you can't do that, and you have to declare this, that and the other). regards Steve -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ From kare at speech.kth.se Mon Oct 30 07:28:27 2000 From: kare at speech.kth.se (Kare Sjolander) Date: Mon, 30 Oct 2000 13:28:27 +0100 Subject: Audiorecording of wave-files References: <39FD625C.57D02783@STOPUCE.gmx.de> Message-ID: <39FD696A.5E85399@speech.kth.se> Try Snack at http://www.speech.kth.se/snack/ works for Windows 95/98/NT/2000, Linux, Macintosh, Sun Solaris, HP-UX, NetBSD, and SGI IRIX Kare From jasonic at nomadicsltd.com Sat Oct 21 12:29:56 2000 From: jasonic at nomadicsltd.com (Jason Cunliffe) Date: Sat, 21 Oct 2000 12:29:56 -0400 Subject: ActivePython 2.0 Release References: Message-ID: <003901c03b7c$26571a80$c3090740@megapathdsl.net> Hello I appreciated your clarification of many issues about ActivePython2.0. I hope you go much further in this direction Python is going through a lot of growing pains now and there seems to be quite a bit of paranoia and suspicions around ActiveState. I cannot speak to ActiveState's 'reputation' as I never heard of it until recently...And I do not pretend to fathom the licensing issues at stake. But I wish to god each of the Python distributions could find a way to simplify the main licensing issues and present them in comparative manner. This would help everyone make an informed choice As I understand it there is a real advantage to having a solid distribution provided it does not end up in Python spinning off into too many flavors of incompatibleness. What I recommend to both ActiveState and PythonLabs to do is to put much clearer information on the websites preferable in table format so one can see what is being offered, what is included etc. Python has a significant community of very experienced users, many of whom may now be uncomfortable with a new era adn Python's growing 'success'. On the other hand because of this success, Python is attracting many new programmers, including people searching for a starter language. These latter know nothing of the politics and recent upheavals. What they do face immediately is quite a bit of confusing presentations. ActiveState can rally help here by improving the information and reasons why ActivePython exists and where you are going etc. In other words formalize and illustrate your post to comp.lang.python in an open comparative manner and people will accept you more readily. For my own part I see 3 good reasons to consider ActivePython: 1. Some very talented well respected Python gurus have fulltime paid jobs to make this work. Mark Hammond and Andy Robinson's book 'Python programming on Win32' is one of the few really good Python books out there. 2. ActivePython is listed regularly in magazines and elsewhere as being on board for M$ .NET evolution. Much as everyone in the Linux oss world loves to bash M$, I believe .NET is a very important change of direction ... an intelligent and appropriate one by M$ which will benefit everyone. IT is important in terms of perception and practicality. But it will take 2 years to see if it works adn for all the necessary parts to be in place.. That is a long time in Internet time.. Having Python introduced at the start in this new scheme is very good news for its long term adoption as a default language. This is perhaps the best chance Python will get to show itself off against VisualBasic etc. It is also among its best chances to be accepted in Schools as serious introductory programming language. It means as Python continues to gather momentum in the opensource Linux world, that it will not get left behind in the win32 .Net world. This is important because it maintains its portability... one of its major features.. BUT only if ActiveState remain keenly tuned to this issue.. ELSE we descend into a familiar chaos. I suspect this is what is behind so much suspicion of ActivePython. 3. Easy download is a real advantage for newbies. In practice ease of download can largely be addressed by having really excellent website design. PythonLabs looks pretty messy to me at the moment. There are lists and links aplenty, but it lacks a good map, and the design imho is cute but very amateur [green type gets tiring fast]. I know PythonLabs team have been very busy adn making hard changes getting the basics sorted out [new versions wow]. But the PythonLabs site MUST address the needs of all python users or suffer the consequences. If PythonLabs considers itself the spiritual epicenter of Python then it needs to present as such ... : Give a clear view also of who why what is www.python.org is, : Give a clear view also of who why what is http://www.activestate.com/Products/ActivePython/ If one searches for 'python' on Google for example , it is invariable the classic python sites which come up. This is the confusing reality and PythonLabs ActiveState and others cannot ignore this. A real advantage which ActivePython can , and should offer imho is ready compiled Win32 binaries of valuable libraries which python can use. For example: I am using the Berkeley DB python wrapper developed by Robin Dunn. Now that he is rightly focusing on the wonderful wxPython, I ma happy to see the bsddb torch has been passed to Gregory P. Smith http://electricrain.com/greg/python/bsddb3/ The new version uses Berkeley 3.1 available at http://www.sleepycat.com/download.html I would like very much to upgrade but do not own a copy of Microsoft C++ compiler on Win32 needed to build Berkeley Storage What to do? A decent ActivePython distribution should offer MORE not less and especially make it easier and better to work with these out of the box. Other modules I would love to see bundled include:, NumericPy, mxDateTime, mxODBC, SEQDICT.. all the tools which really show off Python's strengths. Beyond this are the fabulous cross platform Gui tools like wxPython, and BOA. Perhaps these go against the grain of ActivePython, but perhaps not == it might be an excellent way to spread the strength and usefulness of the distribution as a crossplatform solution. Finally, what ActivePython could really do to help Python community is to publish affordable Python booklets. I suggest short focused titles under $5 to $15 price range in a disposable magazine format. A focused series of publications addressing realworld issues. Much if this could be semi.tutorial topic based. Python still needs a much better bookstore/newstand presence. There is a huge publishing niche left unfilled by low cost magazine + CD style progamming. In Korea this is brilliantly filled by color ilustrated stepbystep series published by SamGakHyungPress www.samgak.com. A list is at http://www.ok-easy.com/ok_easy/re_book_list.asp?category1=6 These are under 100 pages, color highly illustrated wiht many screen shots. This is partly becuase the focus is graphics and mutlimedia software, but also becuase of teh language differntial between Korean and English. There is another reason why ...many software instructions are very verbose when truyign to descirble thinsg liek menues adn toolboxes adn sequences of actions. But very concise and simple when a series of small screen shots or highlighted annotated zooms are repsented.They sell for 3,800 WON = $3.50 In France also there is a tradition of all kinds of samll chaep howto booklets. The US market is sauturated by dumb overheavy overpriced tomes. Some are excellent but many are garbage as we know. The leadtime to market for a good book is a long and painful road. Magazine articles and webzines have been filling this beter and better. In Python's case consider all the great online work by Jon Udell, Cameron Laird, Stephen Figgins and others. What is a shame is that these cannot be made available or edited into a more general printed public format. This could increase the awareness of Python at large and open up a new publishing format lackign in the USA. If well done it could easily be extended in translation to cover a much wider international market. If anyone is interested to pursue this idea of PythonPress then please contact me. Jason ________________________________________________________________ Jason CUNLIFFE = NOMADICS['Interactive Art and Technology'].DesignDirector ----- Original Message ----- From: Paul Prescod Newsgroups: comp.lang.python To: Sent: Friday, October 20, 2000 6:07 PM Subject: Re: ActivePython 2.0 Release > Before I start to describe the benefits of the ActivePython 2.0 > installation for windows, I'd like to make the point that as far as I > know, ActiveState is the first source for Python 2.0 binaries for > Solaris, > and Debian Linux (in addition to the more mainstream Windows and RPM > installations). Quality assured cross-platform distributions are a big > part of our mission. So looking only at the Windows installer does not > give the whole picture. > > Q. How does ActivePython benefit the Windows user? > > We strove to make ActivePython the easiest way to > get started with Python 2.0. It is certainly possible to download most > parts of the ActivePython product from various sites: > > * Python 2.0 core > * PythonWin environment > * Win32 APIs > * TKinter > * Indexed HTMLHelp versions of Python documentation > > If you are a Python expert and you know what you want and where to get > it, then ActivePython may not be of interest to you. On the other hand, > when you wish to distribute a program with dependencies on these various > packages you may want to point your customers at ActiveState's > distribution rather than at various download sites. > > In addition to the major advantages of multi-platform support and ease > of > installation, ActivePython is expected to be the first of many > ActiveState > Python-world products. We look forward to being able to point our > customers at a family of quality assured, cross-platform distributions > rather than multiple parts for multiple operating systems. Also, we are > not bound by anyone else's release schedule so we can release newer > versions on an accelerated schedule when we feel that will benefit our > customers. > > Q. Why use the Microsoft Installer (MSI)? > > My opinion is that an operating system should come with a standard > installation engine rather than having it bundled in each executable > distribution. This allows much safer and cleaner uninstallation and > dependency tracking because the operating system knows everything that > is going on. In my personal opinion, Microsoft, Red Hat, Debian etc. > have finally gotten this right. It is unfortunate that older versions of > Windows do not come with MSI. Even if we had Guido's time machine I > don't think we could correct that situation. I've railed against the > Windows installer situation for about a decade and it didn't have any > effect the first time! > > Q. How does ActivePython differ from PythonLabs in terms of > "standard-ness"? > > We have one minor bug fix and miscellaneous changes to the build system > and documentation to reflect our alternate documentation delivery > format. > The primary reason that there are so few differences is because > ActiveState contributes our improvements to the Python core to the > Python > development team. That ensures that we remain standard and everybody > benefits from our work. > > Q. What's in the package? > > ActivePython ships with TKinter and IDLE but not TK. This keeps our file > size down. IDLE is not in the start menu because it depends on TKinter > and > anyway it would be somewhat confusing for us to suggest two development > environments for the same product. > > We are certainly interested in feedback on our choice of extensions to > include and exclude. This is especially true of the GUI world where > there are many different libraries competing for support. > > ActivePython-Feedback at activestate.com is the best place to voice these > opinions because it is connected to our bug and feature request tracking > systems. > > Q. Why doesn't the license allow redistribution? > > ActiveState's license does not allow redistribution without contacting > us. Anyone who has created, tested and supported multiple platform > installations knows that this is a large effort and ActiveState depends > upon the publicity that accrues from having people download from our > site. This also helps us to quickly take obsolete versions (especially > betas) out of circulation and to ensure that our customers have the code > we expect them to have. > > Q. What does ActivePython contribute to the Python world? > > Guido has stated on various occasions that he hoped that multiple Python > distributions would arise and thrive. Out of the box, ActivePython is an > excellent platform for developing Windows, Linux or Solaris > applications. Those who are new to Python world and want to get up and > running, with lets say COM or MFC programming quickly and easily now > have a choice that gets them there. Choice is good. > > Also, not every ActiveState product will be groundbreaking and > revolutionary. Some are incremental improvements. Nevertheless, we have > announced many products that will take Python places it has never been > before and ActivePython is a part of that strategy. > > Paul Prescod > ActiveState Tool Corp. > From jerry_spicklemire at my-deja.com Tue Oct 17 12:10:50 2000 From: jerry_spicklemire at my-deja.com (jerry_spicklemire at my-deja.com) Date: Tue, 17 Oct 2000 16:10:50 GMT Subject: Mass Text Indexing Tools References: Message-ID: <8shtm2$qg0$1@nnrp1.deja.com> In article , "Ender" wrote: > Does anyone know of some good mass text indexing/searching tools > (preferrable open source) that are accessible from python. i've tried > using popen2 calls to grep but it starts to flag around 50Mbs. text > material consists of around a hundredb thousand small files (emails). > Check out: http://ransacker.sourceforge.net/ "Ransacker is a scriptable, incrementally-double-indexed search engine written in python. It's scriptable in that you can index any text with any key. This makes it easy to index content ("pages") stored in databases, file systems, the web, etc. It can index incrementally. This means you can add content or update the entry for a particular page without touching the rest of the index. It's double-indexed, meaning that not only does every word have a list of pages, every page has a list of words. This is used for the incremental indexer, but also allows you to determine which pages have the most in common. This will allow ransacker to produce "what's related" pages." Sent via Deja.com http://www.deja.com/ Before you buy. From grante at visi.com Tue Oct 17 07:13:23 2000 From: grante at visi.com (Grant Edwards) Date: 17 Oct 2000 06:13:23 -0500 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Oct 17) Message-ID: Jeremy Hylton announces Python 2.0c1 -- release candidate 1. http://deja.com/=dnc/getdoc.xp?AN=679664784 Oleg Broytmann's bookmark database and internet robot modules, version 3.0 http://deja.com/=dnc/getdoc.xp?AN=679664820 Robin Becker announces ReportLab 1.01 -- a Python package for generating PDF documents using Python as a scripting language. http://deja.com/=dnc/getdoc.xp?AN=679675365 Pearu Peterson starts PySymbolic project - "Doing Symbolics in Python" http://deja.com/=dnc/getdoc.xp?AN=679810372 Robin Becker adds Unicode support to cCopy 0.2 http://deja.com/=dnc/getdoc.xp?AN=680053128 Edward Muller provides binaries for Python on Compaq iPAQ. http://deja.com/=dnc/getdoc.xp?AN=681552161 ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org although PythonLabs.com bills itself as "The Python Source", which is becoming increasingly true in 2000 http://www.pythonlabs.com/ PythonWare complements the digest you're reading with the daily python url http://www.pythonware.com/daily comp.lang.python.announce announces new Python software. Be sure to scan this newly-revitalized newsgroup at least weekly. http://deja.com/group/comp.lang.python.announce The Vaults of Parnassus ambitiously collects Python resources http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Consortium emerges as an independent nexus of activity http://www.python.org/consortium Cetus does much of the same http://www.cetus-links.de/oo_python.html Python FAQTS http://python.faqts.com/ Python To-Do List anticipates some of Python's future direction http://www.python.org/cgi-bin/todo.py Python Journal is at work on its second issue http://www.pythonjournal.com Links2Go is a new semi-automated link collection; it's impressive what AI can generate http://www.links2go.com/search?search=python Archive probing trick of the trade: http://www.dejanews.com/dnquery.xp?QRY=&DBS=2&ST=PS&defaultOp=AND&LNG=ALL&format=threaded&showsort=date&maxhits=100&groups=comp.lang.python Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://www.dejanews.com/dnquery.xp?QRY=~g%20comp.lang.python%20Python-URL%21 Suggestions/corrections for next week's posting are always welcome. [http://www.egroups.com/list/python-url-leads/ is hibernating. Just e-mail us ideas directly.] To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. Mention "Python-URL!". -- The Python-URL! Team-- Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and sponsor the "Python-URL!" project. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From effbot at telia.com Tue Oct 3 11:29:23 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 03 Oct 2000 15:29:23 GMT Subject: How can you copy (clone) a string? References: Message-ID: Peter Schneider-Kamp wrote: > If you know it is not empty: > > >>> a = "abcd" > >>> b = a[:1] + a[1:] > >>> id(a) > 21765696 > >>> id(b) > 21763648 > >>> a is b > 0 > >>> a == b > 1 >>> a = "a" # not empty >>> b = a[:1] + a[1:] >>> id(a) 7834944 >>> id(b) 7834944 >>> a is b 1 >>> a == b 1 From the_brain at mit.edu Wed Oct 11 12:30:05 2000 From: the_brain at mit.edu (Alex) Date: 11 Oct 2000 12:30:05 -0400 Subject: Programmer-Wanna-Be (Is Python for me?) References: <8s2354$ep2$1@nnrp1.deja.com> Message-ID: > NowI've got many questions for all of you who use Python. (And please > dumb things down to my current "non-programmer" level of comprehension!) > > 1. First of all, is Python what I'm looking for: a way to create > Windows (or other OS's) applications? Yes. > 2. Is Python RELATIVELY one of the easiest ways to do this? Yes. > 3. What about Visual Basic? (the most commonly used) Why should I not > choose VB instead? Never used it, so I don't really know. It seems to me based on what I've read here that people who write complex applications in VB often end up regretting it. > 4. Is there a WYSIWYG editor (like Frontpage is for HTML)? Is this what > Tkinter is? Is there a 'better' WYSIWYG editor for Python that I should > use instead? Don't know. I recall seeing some stuff like that here occaisionally, but I don't know how finished it is. > 6. Where should I start? (I've already downloaded and installed > Python2.0b2 but haven't attempted to write anything) Do I need to > download anything else? http://www.python.org/doc/tut Alex. -- Speak softly but carry a big carrot. From jon at bezek.dstc.monash.edu.au Tue Oct 24 20:17:25 2000 From: jon at bezek.dstc.monash.edu.au (Jonathan Giddy) Date: 25 Oct 2000 10:17:25 +1000 Subject: Suggestions on sockets and Tkinter References: <8spg3u$c61$1@oravannahka.helsinki.fi> Message-ID: T Teemu E Kurppa writes: ] Main purpose of simulator is to simulate the game, NOT to view it. So it ] should read sockets frequently and update it state, and now and then ] (approx. 10 times in second ...) also update the graphical view. ] However, in Tkinter programming, I must enter to Tkinter's mainloop, and ] can not run my own. Now, I can use after command or createfilehandler to ] get events for handling the sockets, but for my needs this solution will ] turn the situation wrong-side-up. I can think of 3 ways to handle this: 1. Use threads, one thread handles sockets, the other calls mainloop(). Works OK on Unix, I believe not so well on Windows, although there are ways around it. 2. Use the Tcl interpreter that is builtin to Python when Tk is enabled. This would require using the _tkinter functions, particularly the call function for any Tcl commands that are not supported directly. Yuk! 3. The _tkinter module provides access to the Tcl_DoOneEvent interface. At appropriate times, you can call this to let Tkinter run. TCL_DONT_WAIT = (1<<1) # From tcl.h while _tkinter.dooneevent(TCL_DONT_WAIT): pass # empty the Tk event queue From aleksei.guzev at bigfoot.com Fri Oct 6 04:54:48 2000 From: aleksei.guzev at bigfoot.com (Aleksei Guzev) Date: Fri, 6 Oct 2000 14:54:48 +0600 Subject: Are there Python code for a FIFO-like structure? In-Reply-To: <39DD82E1.8DC66A4B@appliedbiometrics.com> Message-ID: Standard list class has method "pop()" which extracts list[len(list)-1]. You should only define a method push(o) def push(L, o): L.insert(0,o) Aleksei Guzev -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Christian Tismer Sent: Friday, October 06, 2000 1:45 PM To: Will Ware Cc: python-list at python.org Subject: Re: Are there Python code for a FIFO-like structure? Will Ware wrote: > > Huaiyu Zhu (hzhu at users.sourceforge.net) wrote: > > I need something like a fifo, inplemented in a fixed length list... > > an IndexError is raised if the tail gets > > too close to the head. > > I'm not aware of any standard thing like that. Generally one would > implement a stack using list.append() and list.pop(), and I have > implemented FIFOs using list.append() and list.pop(0), but I hadn't > faced the constraint of keeping the list length constant. > > Since you can't do a put and a get literally simultaneously, you'll > have to tolerate a list length that oscillates between two adjacent > values. It might be useful to whip up a state diagram telling when > it's OK to do a put or a get based on the current list length. You'll > need to alternate puts and gets to prevent greater length variations. > See if this does what you want: > > class FixedLengthFifo: > def __init__(self, length): > self.length = length > self.lst = length * [None] > def put(self, x): > if len(self.lst) != self.length: > raise IndexError > self.lst.append(x) > def get(self): > if len(self.lst) != self.length + 1: > raise IndexError > return self.lst.pop(0) Hmm, why don't you really use a fixed length list, maintain two rotating pointers, and check that they behave well? I didn't implement it, but it is obvious (left as an exercise for the reader :-) But if the fixed length implementation is not the main goal, but to achieve O(1) behavior, then the attached linked list implementation might be helpful. It also allows for rotations (only efficient for smal deviations). ciao - chris -------- linkedlist.py --------- class LinkedList: def __init__(self, items=[]): self.data = None self.size = 0 for item in items: self.append(item) def __del__(self): self.data[:] = [] def append(self, item): if not self.data: thing = self.data = [] thing[:] = [item, thing, thing] else: a = self.data z = self.data[-1] new = [item, a, z] a[-1] = new z[1] = new self.size = self.size+1 def __len__(self): return self.size def _spot(self, key): if key < 0: if self.size + key < 0: [][key] # error if 2*abs(key) > self.size: key = self.size + key dir = 1 else: key = abs(key) dir = -1 else: if key >= self.size: [][key] # error if 2*key > self.size: key = self.size - key dir = -1 else: dir = 1 this = self.data while key: this = this[dir] key = key-1 return this def __getitem__(self, key): return self._spot(key)[0] def __repr__(self): lis = [] for i in range(self.size): lis.append(self[i]) return "LinkedList(%s)" % repr(lis) def insert(self, pos, item): if not self.size: if pos: [][pos] # error self.append(item) else: a = self._spot(pos) z = a[-1] new = [item, a, z] a[-1] = new z[1] = new self.size = self.size+1 def __delitem__(self, key): this = self._spot(key) nil, a, z = this a[-1] = z z[1] = a self.size = self.size-1 if key == 0: self.data = a def rotate(self, pos=1): """return the current value and rotate into new location""" ret = self.data[0] self.data = self._spot(pos) return ret def move(self, pos=0): """return the current value and move current into new location. With pos==0, the behavior is identical to rotate(1) """ if not pos or pos==self.size-1: return self.rotate() q = self._spot(pos+1) p = q[-1] this = self.data self.data = self.data[1] a = this[1] z = this[-1] a[-1] = z z[1] = a p[1] = this this[-1] = p this[1] = q q[-1] = this return this[0] -------- yp.tsildeknil --------- -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com -- http://www.python.org/mailman/listinfo/python-list From donn at u.washington.edu Thu Oct 19 13:21:18 2000 From: donn at u.washington.edu (Donn Cave) Date: 19 Oct 2000 17:21:18 GMT Subject: Reading the error stream from os.popen() References: <8smt02$8sb$1@kopp.stud.ntnu.no> <39EEF9F8.B5D65B06@schlund.de> Message-ID: <8snaie$8bcg$1@nntp6.u.washington.edu> Quoth jmcbray at carcosa.net (Jason F. McBrayer): | >>>>> "CG" == Carsten Gaebler writes: | >>>>> "TAJ" == Tov Are Jacobsen wrote: | | TAJ> The msgfmt command below outputs info to the stderr stream, | TAJ> but the read() method retrieves data from stdin. | | TAJ> s = os.popen('/usr/bin/msgfmt --statistics '+x[0]+'.po').read() | | CG> Redirect stderr to stdout: | CG> s = os.popen('/usr/bin/msgfmt --statistics '+x[0]+'.po' 2>&1).read() | | Or better, use the popen2 module. | | import popen2 | | out, in, err = popen2.popen3('/usr/bin/msgfmt --statistics ' + x[0] + '.po') | s = err.read() | del out; del in; del err; Maybe, assuming this particular command reliably does NOT produce a lot of output. Try this: out, in, err = popen2.popen3('cat large_file') s = err.read() ... hang forever. What's going on here? cat wants to write all its output before it closes its error unit, you want to wait for something on that error stream before you attend to the output; cat fills up its output pipe and blocks, and we have a deadlock. It's often not an issue, but the more different streams you're trying to deal with for a single source, the more vulnerable to deadlocks. When the application really just wants all the output and doesn't need to separate diagnostic output from normal output, "2>&1" is perfect. Donn Cave, donn at u.washington.edu From tonys111 at erols.com Thu Oct 5 11:51:14 2000 From: tonys111 at erols.com (Tony Sideris) Date: Thu, 5 Oct 2000 11:51:14 -0400 Subject: re.match question References: <39DC9F7C.67B71D52@era.ericsson.se> Message-ID: <8ri81j$eog$1@bob.news.rcn.net> "Thomas Svensson" wrote in message news:39DC9F7C.67B71D52 at era.ericsson.se... > Hello, > > I'm matching a list of strings. I want "xxxBar" to be a match but not > "xxxFooBar", xxx can be anything. I've tried the following: > > re.match('^.*?(?!Foo)Bar$', word) > > re.match('^.*?(Foo){0}Bar$', word) > > But they all returns a match. What am I doing wrong?? I think this > should be an easy thing to do. > > > Thanks for any help, > Thomas re.match(r'^[^(?:Foo)]*Bar', 'xxxFooBar'); seems to be working for me. the above line fails, 'xxxBar' passes. may need further tweeking... -Tony From nospam at nospam.com Tue Oct 24 17:55:35 2000 From: nospam at nospam.com (Tom) Date: Tue, 24 Oct 2000 21:55:35 GMT Subject: kjBuckets binary for Win32 & Python2.0 Message-ID: I've compiled Aaron Watters' kjBuckets module for Win32 and Python20. kjbuckets is a Python extension module that provides fast set, graph and mapping operations. It can be downloaded from www.malcolmson.com/python. Tom. From erno-news at erno.iki.fi Mon Oct 30 18:38:51 2000 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 31 Oct 2000 01:38:51 +0200 Subject: How can I get a list of all public symbols in Python librararies References: <39FDC14E.50FAABBE@nrc.ca> Message-ID: | In order to build support for dictation of Python code, I need a list of | all the symbols (functions, methods, classes, variables) defined in the | standard Python libraries. [...] | Any suggestions on what would be the easiest way to get such a list? one definition of what's public is what's documented - so you could extract the symbols from the docs. the doc sources (tex) would be quite easy to scan for these. the other obvious way would be to use the python introspection features to look for them. maybe you could use the pyclbr module, which provides class browser support. also worth looking at may be inspect and htmldoc by ka-ping yee, you can find those at (bottom of page). -- erno From daniel.dittmar at sap.com Fri Oct 20 04:08:45 2000 From: daniel.dittmar at sap.com (Daniel Dittmar) Date: Fri, 20 Oct 2000 10:08:45 +0200 Subject: Announcing Jython, the sucessor to JPython References: Message-ID: <8souia$db8$1@news1.wdf.sap-ag.de> > "Jython" kinda sticks in my larynx. How about "Javathon", or "Pythonava? How about "Jivethon"? -- Daniel Dittmar daniel.dittmar at sap.com SAP DB, SAP Labs Berlin From max at alcyone.com Fri Oct 6 22:59:00 2000 From: max at alcyone.com (Erik Max Francis) Date: Fri, 06 Oct 2000 19:59:00 -0700 Subject: list sort question References: <8rlr4e$6av$1@nnrp1.deja.com> Message-ID: <39DE9174.9A4F4F93@alcyone.com> Bill Tolbert wrote: > I was asked today to sort a list of names and email addresses by last > name. I ended up with a list of tuples: > > [('Bill Tolbert', 'bill_tolbert at bigfoot.com'), ...] > > I couldn't figure out the list.sort(somefunction) syntax and resorted > to > all sorts of slicing before I gave up and solved it in a query > (outside > of Python). The function passed to sort takes two arguments, and must return -1, 0, or 1 if the first is less than, equal to, or greater than the second (respectively). To get the last name of one of your tuples, you'd want something like import string tuple = ('Bill Tolbert', 'bill_tolbert at bigfoot.com') string.split(tuple[0])[-1] # take the first element, # split it into words, # take the last word So to sort the list you could do something like: list.sort(lambda x, y: cmp(string.split(x[0])[-1], string.split(y[0])[-1])) Now this would be pretty unwieldy on anything but tiny lists. If you are expecting to have even relatively sizeable lists, you'd probably want to choose another data structure (another poster suggested a dictionary whose keys are the last name and whose values are the tuples). -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Morality is a weakness of the mind. \__/ Arthur Rimbaud Esperanto reference / http://mirror/alcyone/max/lang/esperanto/ An Esperanto reference for English speakers. From parkw at better.net Sun Oct 8 01:07:08 2000 From: parkw at better.net (William Park) Date: Sun, 8 Oct 2000 01:07:08 -0400 Subject: Data distribution by frequency In-Reply-To: ; from gfortune_ewu@ispchannel.com on Sat, Oct 07, 2000 at 11:45:58PM +0000 References: Message-ID: <20001008010708.A11914@better.net> On Sat, Oct 07, 2000 at 11:45:58PM +0000, Greg Fortune wrote: > Obj1 > Frequency: 2 > Obj2 > Frequency:2 > > should yeild > [Obj1, Obj2, Obj1, Obj2] > Obj1 > Frequency: 3 > Obj2 > Frequency: 2 > Obj3 > Frequency: 1 > Obj4 > Frequency: 2 > > Should yield > [Obj1, Obj2, Obj4, Obj1, Obj3, Obj2, Obj1, Obj4] Getting correct number of entries is no-brainer, [Obj1] * Frequecy1 + [Obj2] * Frequency2 + ... But, how are the items distributed in the list? ---William Park, Open Geometry Consulting From gtalvola at nameconnector.com Mon Oct 23 16:41:26 2000 From: gtalvola at nameconnector.com (Geoff Talvola) Date: Mon, 23 Oct 2000 16:41:26 -0400 Subject: event loop problem References: <8t21ei$e5a$1@nnrp1.deja.com> <39F49F8E.54AA9BD6@NameConnector.com> Message-ID: <39F4A276.78E54795@NameConnector.com> Geoff Talvola wrote: > There are 2 solutions I can think of. First of all, win32all already > contains a function that can process all waiting messages: > win32gui.PumpWaitingMessages() inserted into your while loop should do the > trick. Oops, I meant to say pythoncom.PumpWaitingMessages(). The win32gui version might be the same thing, but I'm not sure. Use the pythoncom one. -- - Geoff Talvola Parlance Corporation gtalvola at NameConnector.com From aleaxit at yahoo.com Wed Oct 11 09:09:27 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 11 Oct 2000 15:09:27 +0200 Subject: ANNOUNCE: PySymbolic - Doing Symbolics in Python References: <8s167e02bdd@news1.newsguy.com> <87og0r39n5.fsf@ifm.uni-kiel.de> Message-ID: <8s1p3v031gl@news1.newsguy.com> "Janko Hauser" wrote in message news:87og0r39n5.fsf at ifm.uni-kiel.de... > Perhaps I'm wrong, but I understood that GiNaC does not directly > expose an API, but helps a C++ programmer to write expressions > directly in C++, which would mean that the interface itself needs to > be written and beforehand defined in C++. So SWIG would not be an > option, perhaps CXX or something like that. Another system to look at > is YACAS, which has an API. My impression is that YACAS, like a typical CAS system, implements and exposes its own little scripting language, while GiNaC's novelty is that it *doesn't* -- it _just_ implements and exposes the functionality at the low (i.e., C++) level. So, if one's purpose is basically to use it as an engine from _another_ scripting language (namely, Python:-), one should be able to avoid having to "work around" the intrinsic scripting language, &c. As I said, it's an _impression_ -- I haven't made any in-depth study... SWIG, in theory, should be usable to interface Python (and other scripting languages it supports) to C++ code just as well as to C code. CXX and py_cpp are, clearly, also feasible alternatives. Alex From nhiller at san.rr.com Thu Oct 12 14:55:14 2000 From: nhiller at san.rr.com (Nathan) Date: Thu, 12 Oct 2000 18:55:14 GMT Subject: Expired Page / I.E. HELP ! Message-ID: Every time I use the BACK button on a I.E. browser to navigate my web site I get a warning page that says: Warning: Page has Expired The page you requested was created using information you submitted in a form. This page is no longer available. As a security precaution, Internet Explorer does not automatically resubmit your information for you. To resubmit your information and view this Web page, click the Refresh button. This does not occur when I use a Netscape browser. Does anyone know how to fix this? My web site works like a search engine. The user types in a word, my database is searched, and then results are displayed. If I go to a new page and then try to go back to the previous page I get the error :( Please send me an email incase I miss your post. Thanks, Nathan nhiller at san.rr.com From gregj at pobox.com Tue Oct 17 01:53:46 2000 From: gregj at pobox.com (Greg Jorgensen) Date: Tue, 17 Oct 2000 05:53:46 GMT Subject: scanf in python...? References: <39ebd839.159714@news> Message-ID: "Tony Waterman" wrote in message news:39ebd839.159714 at news... > Does python have any way to mimic scanf ? I just bought Python on > Win32 and I can't find anything in there about it, or on the > python.org html tutorial. Also; how many ways to mimic scanf are > there? scanf is necessary in C because C is a statically-typed language. Python is dynamically typed--names can represent any type and change type at runtime. You can use Pythons string functions and conversions to accomplish what you would do with scanf in C: # assume input lines: lastname firstname salary total = 0.0 while 1: s = sys.stdin.readline() if not s: break t = s.split() # break s on whitespace into list of three elements total += float(t[2]) # convert salary to float, add to total ... This technique will work with simple delimited input lines. You can handle almost anything with regular expressions. -- Greg Jorgensen Deschooling Society Portland, Oregon, USA gregj at pobox.com From quinn at chunder.ugcs.caltech.edu Mon Oct 30 18:15:41 2000 From: quinn at chunder.ugcs.caltech.edu (Quinn Dunkan) Date: 30 Oct 2000 23:15:41 GMT Subject: Newbie biting off more than he can chew, can you lend some molars? References: <8tkcps$sdd$1@nnrp1.deja.com> Message-ID: On Mon, 30 Oct 2000 17:57:22 GMT, dwelden at my-deja.com wrote: >I have a vendor supplied Perl module that I would like to convert into >a Python module. I am very new to Python and don't have much of a clue >on creating extension modules, but from what I have learned so far it >looks like what I want to do is feasible. Uh, do you mean converting a C perl module to a C python module, or perl perl module to python python module? >Any takers? If you mean "if I send the source to you will you do half the work and I'll do the other half", you're unlikely to get many takers unless you can be more specific :) If you say what it is you're doing, you may get (in order of probability): a pointer to an existing python module or project that's similar, suggestions about how to go about implementation, or maybe even someone willing to write it for you (doubtful, that last one :) ) From bill at libc.org Mon Oct 30 11:58:55 2000 From: bill at libc.org (Bill Anderson) Date: Mon, 30 Oct 2000 23:58:55 +0700 Subject: PythonLabs Team Moves to Digital Creations References: <8tfa4l$3ns$1@nnrp1.deja.com> Message-ID: <20001030.235855.937370163.4587@locutus.noreboots.com> In article , cjc26 at nospam.cornell.edu wrote: > * William Tanksley menulis: > | > | Out of curiosity, will there be any reorganization in the secret and > | completely nonexistant Python Underground? > > Ahem. That's the Python SECRET Underground, thankyouverymuch. Yes, the PSU, which is completely different than the SPU, the Secret Python Underground. Word has it that if they both existed, they would not get along. Mere conjecture, I am sure. Bill Anderson From bwarsaw at beopen.com Sat Oct 14 23:21:40 2000 From: bwarsaw at beopen.com (Barry A. Warsaw) Date: Sat, 14 Oct 2000 23:21:40 -0400 (EDT) Subject: SMTP receive as well as send References: <39e8bfe4.2248931@news.demon.nl> Message-ID: <14825.8901.187391.168426@anthem.concentric.net> >>>>> "benny" == writes: benny> I'm in need of an SMTP setup that will allow me to receive benny> as well as send messages. The Python SMTPlib looked like a benny> good bet but it seems to be send-only (kind of like the benny> POP3 lib stuff seems to be read only). benny> Can a kind soul help out a Python newbie and give me a few benny> hints about how/where/etc. I could get an SMTP setup that benny> works both ways please? (The PC is a Linux box.) I have a minimal RFC 821 smtp server built on top of asyncore/asynchat, which I've used to experiment with and debug GNU Mailman. It will probably make it into Python 2.1's standard library. In the meantime, you can download it from http://www.wooz.org/barry/software/pyware.html It supports configurable backends via subclassing, but currently doesn't do mailbox delivery. Enjoy, -Barry From phd at phd.russ.ru Fri Oct 20 04:01:55 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Fri, 20 Oct 2000 08:01:55 +0000 (GMT) Subject: Stopping a python thread In-Reply-To: Message-ID: On 20 Oct 2000, Andrew Markebo wrote: > | But what if a thread just waited for some event and cannot return? For > | example, a thread that uses urllib to retrieve a file and urllib just > | hangs; you know, urllib is pretty bad regarding timeouts :( > > You use an alternative to urllib, that uses a select-loop for reading With select(), I do not need threads at all :) > :-) Get in touch with me and I can see if I can dig up the latest of > my httpp.py and socketp.py modules for you :-) Waiting... 12% complete... :))) Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From see at my.signature Thu Oct 5 21:43:53 2000 From: see at my.signature (Greg Ewing) Date: Fri, 06 Oct 2000 14:43:53 +1300 Subject: New Python development process (SourceForge considered Harmful?) References: <39e0d75b.78955419@news.telus.net> <_g7D5.4318$WJ3.742225@ptah.visi.com> Message-ID: <39DD2E59.B4847FCF@my.signature> Grant Edwards wrote: > > it can get > annoying when you get the "ERROR 4xx yadda-yadda-yadda not > found" messages splattered all over the page where the ads used > to be. How about redirecting them to a locally-running fake server that returns an empty piece of HTML for any request? -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From hackee at penguinpowered.com Fri Oct 27 09:55:55 2000 From: hackee at penguinpowered.com (Eugene A.Tyurkin) Date: Fri, 27 Oct 2000 21:55:55 +0800 (KRAST) Subject: Keywords searching via regexp Message-ID: <20001027135555.A5F4E96A78@form.in.krs.ru> Hi! Here's a task I have a list of keywords: keywords = ['qwerty','is','a','good','keyboard'] and want to find any of them in some text The question is: how to write correct regexp to find them? Notice, that I don't want to find words like 'goody', I want exectly my keywords But I also want to find strings like 'qwerty', #good# etc Here what I've tryed: regexp = r"[^w]*\s+(" + string.join(keywords.'|') + r")"[^\w]*\s+" aaa = re.compile(regexp) ... It works fine, but it never find the word at the beginnig or the end of line. Is it possible to make it all in one? Thanx From bill at libc.org Mon Oct 30 12:01:34 2000 From: bill at libc.org (Bill Anderson) Date: Tue, 31 Oct 2000 00:01:34 +0700 Subject: Python in RedHat 7 References: <8t6bku$13s$1@lola.ctv.es> <20001028.114323.982936784.18601@locutus.noreboots.com> Message-ID: <20001031.000134.1237379107.4587@locutus.noreboots.com> In article , "Venkatesh Prasad Ranganath" wrote: > /usr/include/bits/xopen_lim.h Fine, but that is not due to the compiler. That is due, on my RH7 system to: ucntcme at locutus in /home/ucntcme $ rpm -qf /usr/include/bits/xopen_lim.h glibc-devel-2.1.92-14 Not the compiler. From aleksei.guzev at bigfoot.com Sun Oct 8 23:37:15 2000 From: aleksei.guzev at bigfoot.com (Aleksei Guzev) Date: Mon, 9 Oct 2000 09:37:15 +0600 Subject: super - is (should) it (be) a reserved word? In-Reply-To: <8rliak0crt@news1.newsguy.com> Message-ID: I'm afraid "super" should evaluate to a sequence of class object, because of multiple inheritance. -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Alex Martelli Sent: Saturday, October 07, 2000 3:59 AM To: python-list at python.org Subject: Re: super - is (should) it (be) a reserved word? "Grant Edwards" wrote in message news:wAqD5.4401$WJ3.791257 at ptah.visi.com... [snip] > Personally, I would like some way to refer to _a_ superclass. > If there's more than one, it's an error or undefined or > arbitrarily picks one. Almost all of the code I see/write uses self.__class__.__bases__[0] satisfies this request, I think. Would the saving of about three characters to call it, say, self.__class__.__super__ be worth introducing a 'shortcut'...? Alex -- http://www.python.org/mailman/listinfo/python-list From glyph at no.spam Wed Oct 11 18:35:13 2000 From: glyph at no.spam (Glyph Lefkowitz) Date: 11 Oct 2000 17:35:13 -0500 Subject: super - is (should) it (be) a reserved word? References: <39DD4E57.53C27A3F@ix.netcom.com> <39DD865E.D97E4D09@cable.a2000.nl> <8rkpsr$bpa$1@nnrp1.deja.com> <39DE2905.1E62C763@ix.netcom.com> <39E43B65.AFBBCA0C@gssec.bt.co.uk> <39E4637A.E4695E98@gssec.bt.co.uk> Message-ID: Alan Gauld writes: > > Pie().Print(); > > > > recurses infinitely. You were just lucky to try with only two > > Which is of course true because self always points to the > leaf node....oops! > > Back to the drawing board I guess :-) > Not really, just use self.__super as a previous poster suggested. (Python mangles the name to self._Dessert__super or self._Pie__super internally, depending on which method or class it's referred to from) If the prettier syntax (I.E. fewer underscores) is really what you want, you can write an accessor method by overriding __getattr__ somewhere to special-case super. -- Glyph Lefkowitz Professional -- Software Engineer, Origin Systems Amateur -- Computer Scientist, Twisted Matrix Enterprises (My opinions are my own and do not reflect in any way on the policies or practices of my employer, etcetera etcetera.) From quickdry at users.sourceforge.net Thu Oct 5 12:05:19 2000 From: quickdry at users.sourceforge.net (Steven Adams) Date: Thu, 05 Oct 2000 16:05:19 GMT Subject: WindowsCE RAPI with Python Message-ID: <3F1D5.1307$45.4031@news1.belrs1.nsw.optushome.com.au> does anyone have a working version of wincerapi the version I have "does not define init function (initwincerapi)" I'm using Python 1.5.2 and latest version of PythonWin for it, any help would be VERY much appreciated. thanks, Steven -- Cogito cogito ergo cogito sum -- "I think that I think, therefore I think that I am." -- Ambrose Bierce, "The Devil's Dictionary" From gtalvola at nameconnector.com Tue Oct 24 10:59:50 2000 From: gtalvola at nameconnector.com (Geoff Talvola) Date: Tue, 24 Oct 2000 10:59:50 -0400 Subject: event loop problem References: <8t21ei$e5a$1@nnrp1.deja.com> <8t3q4402a3u@news2.newsguy.com> Message-ID: <39F5A3E6.26CC582A@NameConnector.com> Alex Martelli wrote: > "Geoff Talvola" wrote in message > news:mailman.972333065.14276.python-list at python.org... > > I know exactly the problem you're talking about -- and I consider it a huge > > design flaw in NT that any one application can cause other applications to > > hang if it's not processing its message loop. > > Only if those "other applications" *WANT* to hang; otherwise, > they would be using SendMessageTimeout (to guarantee termination > by time-out if needed) rather than SendMessage (whose semantics > are blocking, without a timeout, like those of many other system > calls). The problem I have is that any one application that is *completely* *unrelated* to another application can nevertheless cause that other application to hang by not processing its message loop. From what you're saying, it's a bug in those applications, not in Windows -- I can accept that. However, it's not exactly obvious when you have accidentally created a hidden window and therefore need to be processing messages. I use Spy++ from Visual Studio to diagnose these things, but usually I don't realize I've created a hidden window until I start noticing things like PythonWin not starting up :-) > [snip] > > Starting up PythonWin is > > another example of something you can't do if any program isn't processing > > its messages. > > Really? I hadn't noticed. This is a bug in PythonWin, from > my POW -- it should NOT be doing a broadcast SendMessage without > a timeout (be it via DDEML or otherwise). Have you submitted > this bug to ActiveState? I didn't know it *was* a bug, since I've seen so many other programs behave the same way :-) > > But a better solution is to tell win32com to run in free-threading mode, in > > which case it doesn't create a hidden window and everything works fine > > No, but it DOES freely create threads! Remember to protect > all access to shared-data if you choose this route. Personally, > I think serving the message-loop is simpler. For a single-threaded Python program using ADO, there's no shared data to worry about. And what if your program structure contains long-running calculations based on data from your ADO database? You have to contort your calculations to insert PumpWaitingMessages() calls everywhere. A single-threaded, non-GUI application shouldn't have to have a message loop, IMO. In my experience, whether or not you're using free-threading mode, ADO will create lots of threads and a hidden window for its own use anyway. The difference is that in free-threading mode, the hidden window is in a different thread and appears to have its messages processed automatically, whereas if you use the default single-threaded apartment, the hidden window is created in the main thread and you have to explicitly use PumpWaitingMessages everywhere. -- - Geoff Talvola Parlance Corporation gtalvola at NameConnector.com From robin at jessikat.fsnet.co.uk Fri Oct 27 03:43:16 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 27 Oct 2000 08:43:16 +0100 Subject: Hyphenation algorithm in Python? References: <39f983fd.3380109@news.btx.dtag.de> <8tabce024v5@news1.newsguy.com> Message-ID: In article <8tabce024v5 at news1.newsguy.com>, Alex Martelli writes >"Stefan Franke" wrote in message >news:39f983fd.3380109 at news.btx.dtag.de... >> I'm looking for a hyphenation algorithm in Python. On parnassus I found >> an interface to libhnj, but since I'm on a Win32 machine, I'm not able >> to compile it. >> >> Does anyone know about a Python-only algo or an Win32 compiled >> version of libhnj?. > >I have one such algorithm, but it's for Italian (exploiting the huge >regularity of Italian hyphenation rules) and I'm sure it will not >generalize to any other natural language. What natural language >did you have in mind...? > > >Alex ... I have the hnj from libart algorithm working; I have only got the us dict set up though. That's what came from libhnj. I got this from Daniel Yoo who was working on the python interface. -- Robin Becker From neilh at scintilla.org Wed Oct 11 19:24:32 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Wed, 11 Oct 2000 23:24:32 GMT Subject: was: Is this a dream or a nightmare? (Was Re: XML) References: <39d1d3b2.43465571@news.telus.net> <39D19EBB.ABF18F23@engcorp.com> <39def2ae.8929692@news.davesworld.net> <39dfabb5.27391600@news.davesworld.net> <8s0tai$mc1$1@news1.xs4all.nl> <%h1F5.113896$dZ2.50563651@news3.rdc1.on.home.com> Message-ID: Tom: > What is the status of a Win32 version of this product? You may get a better response from the Archaeopteryx guys but while they have expressed interest in doing a Win32 version, I haven't seen any code yet. A constraint is that Wing is dependent on GTK+ and GTK+ on Win32 is not really ready or stable yet. When GTK+ 2.0 is released, GTK+ should be much more usable on Win32. Neil From rerwig at my-deja.com Mon Oct 30 06:35:24 2000 From: rerwig at my-deja.com (rerwig at my-deja.com) Date: Mon, 30 Oct 2000 11:35:24 GMT Subject: wxPython 2.2.2 demo crashes Message-ID: <8tjmds$96v$1@nnrp1.deja.com> I have just downloaded wxPython 2.2.2. I'm using Python 2.0 (final) Running the demo gives: PYTHONW caused an exception c06d007eH in module WX22_2.DLL at 016f:00b140fa. Registers: EAX=006dec18 CS=016f EIP=00b140fa EFLGS=00000246 EBX=00000000 SS=0177 ESP=006debdc EBP=006dec0c ECX=c12d64c0 DS=0177 ESI=00b4e09c FS=0f47 EDX=818732b0 ES=0177 EDI=00000000 GS=0000 Bytes at CS:EIP: 8b 45 f8 e9 ff 00 00 00 57 ff 76 08 ff 15 f8 d3 Stack dump: 00b1d0a4 00000000 004367d0 00000024 00b4e09c 00bec0d4 00b32910 00000000 00000073 00000000 00000000 00000485 006dedf0 00adb256 0000005c 006debe8 Trying Python directly gives same result. Pointers Please? Sent via Deja.com http://www.deja.com/ Before you buy. From sh at ttsoftware.co.uk Mon Oct 30 06:03:13 2000 From: sh at ttsoftware.co.uk (Steve Horne) Date: Mon, 30 Oct 2000 11:03:13 +0000 Subject: Python scoping References: Message-ID: <9ikqvso5e0rd5naoh3cgqsnop3ejsbe78r@4ax.com> On Thu, 26 Oct 2000 15:29:22 -0700, Michael Ackerman wrote: >"Steven D. Majewski" wrote: >> A situation where the human eye uses indentation and the compiler >> uses braces is unsafe. > >Why is it unsafe? Doesn't it work well in Haskell? Never used Haskell, but the principle is the same in any block structured language. The program gets edited under a deadline for changed requirements/bugfixing and the indentation no longer matches the braces. The compiler believes the braces but the programmer believes the indentation, so confusion ensues. Yes there are ways of dealing with this, but it takes a while to realise that this is the problem. -- Steve Horne sh at ttsoftware.co.uk From tbryan at python.com Thu Oct 19 11:44:30 2000 From: tbryan at python.com (Thomas A. Bryan) Date: Thu, 19 Oct 2000 11:44:30 -0400 Subject: New - Need Help References: <39EEF2DE.E7B3EA39@python.com> <8sn329$s33$1@panix3.panix.com> Message-ID: <39EF16DE.298E93DE@python.com> > >Does anyone know whether the Sam's (Python in 24 Hours?) book is any better > >for a first-time programmer? If not, I'll can post a bunch of notes and > >exercises that I wrote to supplement _Learning_Python_ for my wife. > > Well, it's aimed at the first-time programmer. It's hard for me to > judge whether it actually succeeds, but I think I've seen a couple of > favorable comments posted. _Learning_Python_ attempts to aim at both the first time programmer and someone who has already finished a Programming 101 class in Pascal or C and someone who has some practical programming experience in a language other than Python but who isn't necessary a seasoned professional. I think that by attempting to aim at so many different audiences, they really end up missing the beginner in a lot of places. For example, a beginner might not really even know what a program is. Some people might learn by being dragged through the first few chapters, but most "beginning" books I have seen give some sort of background to orient the students. Sections on loops generally have some sort of introduction to the whole concept of looping. All sections try to teach both a topic and why it is useful in practice. I think that _Learning_Python_ really leaves a lot to be desired in these respects. I should have guessed as much, but I saw the favorable reviews here too. For example, the terms "call a function," "function call," and "caller" are never really defined. The terms are used with some context, but it can leave a beginner feeling like he must have missed a page somewhere. A beginner's book should also NEVER have examples with variable names like X and y. Remember, students learn by example, and if the *book* uses variable names like that, I guess that's what all professional programmers use. Yuck. Since _Learning_Python_ aims for many audiences, they also sometimes introduce vaguely obscure elements of loops or functions or whatever with all of the other material. That's great for someone who wants a comprehensive Python text, but I'd be happier with more coverage of basics and less complete coverage. Or at least complete coverage with a "digging deeper" section at the end of each chapter that beginners can safely skip on their first time through the book. Don't get me wrong. I actually like _Learning_Python_ quite a bit. I think that it could make a good book for a first course or for a programmer teaching his friend. The teacher can fill in the gaps, and the student is left with a nice, trim book that doesn't have any fluff once they've internalized a bunch of programmer folklore. I would simply never recommend _Learning_Python_ to a beginner programmer to read by himself. It's also a good book with some sort of programming background. If they already know about functions and loops and typing code into text files and such, then _Learning_Python_ is a great no-nonsense, intro to the core of the language. Pedagogically yours, ---Tom From thomas at cintra.no Mon Oct 16 08:14:41 2000 From: thomas at cintra.no (Thomas Weholt) Date: Mon, 16 Oct 2000 12:14:41 GMT Subject: Import-error using own modules in Python in ASP Message-ID: <39eaf017.4386547@news.eunet.no> Hi, I'm trying to ditch VBScript in favour of Python in ASP, but I keep getting an import error when I try to import my own modules. It works fine in Pythonwin, but fails terribly in ASP. In my Python-folder I've created a folder called hs, with an empty __init__.py file in it. In the asp-page I'm trying to import it doing stuff like : from hs.db import * And it fails, saying there's no module named db. The file db.py exists in the hs-folder. Any tips or hints? Thomas From josh at open.com Tue Oct 3 03:06:48 2000 From: josh at open.com (Joshua Muskovitz) Date: Tue, 3 Oct 2000 03:06:48 -0400 Subject: how do I listen on a socket without sucking up all the CPU time? References: <39d971f3_1@corp.newsfeeds.com> <39d976b9_4@corp.newsfeeds.com> <39d97e56_4@corp.newsfeeds.com> Message-ID: <39d983e4_4@corp.newsfeeds.com> Ok, I got select.select to work -- this cuts the CPU usage back down to normal, but now I'm losing KeyboardInterrupt exceptions. Before, I could ctrl-c my app and it would die. Now they seem to hang the process, and get queued up in the input buffer somehow. My change thus far: pkt, who = PingScheme.icmpSocket.recvfrom(512) ... Becomes: readyToRead = select.select([PingScheme.icmpSocket], [], [], MAX_LOOP_PERIOD)[0] if readyToRead: pkt, who = PingScheme.icmpSocket.recvfrom(512) ... Any guesses what is happening to the ctrl-c's? -- josh -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From chris at araidesign.com Fri Oct 13 14:12:08 2000 From: chris at araidesign.com (Chris Arai) Date: Fri, 13 Oct 2000 11:12:08 -0700 Subject: StringIO readline() bug?? >>> THANKS! References: <39E6CC82.F7A1711A@araidesign.com> Message-ID: <39E75078.B47E9D81@araidesign.com> Thanks for the help!! Chris From tim_one at email.msn.com Sat Oct 21 17:09:59 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 21 Oct 2000 17:09:59 -0400 Subject: Getting Python 2.0 without pythonlabs.com Message-ID: As many have noticed (including us ), pythonlabs.com is down. We don't know why, so don't know when it will revive again either. Since it's been down for a couple days already we're making the 2.0 release available from python.org too: http://www.python.org/2.0/ Note that ActiveState also released a new version of ActivePython based on 2.0: http://www.activestate.com/Products/ActivePython/index.html If both of those sites go down too, we'll look into attaching free Python CDs to boxes of major breakfast cereals. easier-than-prying-a-cd-out-of-a-domino's-pizza-ly y'rs - tim From cbbrowne at news.hex.net Mon Oct 2 20:38:50 2000 From: cbbrowne at news.hex.net (Christopher Browne) Date: Tue, 03 Oct 2000 00:38:50 GMT Subject: Python equivalent of Java Vector References: <8rau5e$afv$1@nnrp1.deja.com> Message-ID: In our last episode (Mon, 02 Oct 2000 21:19:50 GMT), the artist formerly known as hoopy_frood at my-deja.com said: >I've been asked another Python question that's over my head, so I >asked the querant to re-phrase it a bit so I could ask y'all. Here >is his question: >"Does Python have something equivalent to Java's Vector? For >instance, most of the time if you want to use an array you have to >declare the size up front. Java has a Vector class which is an array >of objects which grows as you add things to it. >"Just curiousity on my part really, but if you are serious about >using Python productively, you probably need to answer that. In >Java, for instance, if I want an array of String I say "String >tmp[]=new String[5]" and I have an array of Strings with 5 slots. If >I didn't know how many Strings I was going to have though, I could >say "Vector tmp=new Vector()" then every time I wanted to add a >String, say "String tmpvalue" I could say "tmp.addElement(tmpvalue)". >Then, I could say "tmp.size()" to see how many elements were in the >Vector, and I can even to a "tmp.elementAt(int x)" to retrieve a >value. So, I think the terminology would be that Java supports >dynamic arrays of objects. I was wondering if Python had the >equivalent." A Python "dictionary" can certainly be used to handle this; this provides arbitrary access that does not mandate actually _filling_ any of the slots in. You might do: a[0] = "this" a[1] = "that" a[7] = "other" note that a[2] thru a[6] wind up not having any values; if you try to access them, Python would raise a KeyError exception. Which means that safely accessing entries requires something like: if a.has_key(k): do something with a[k] else: do whatever is needed if there is no a[k] -- (concatenate 'string "cbbrowne" "@" "acm.org") "Intel engineering seem to have misheard Intel marketing strategy. The phrase was ``Divide and conquer'' not ``Divide and cock up''" -- Alan Cox From olivier at vibes.net Tue Oct 17 12:52:12 2000 From: olivier at vibes.net (Olivier CARRERE) Date: Tue, 17 Oct 2000 18:52:12 +0200 Subject: Checking whether an object has been created. Message-ID: <39EC83BC.797424B0@vibes.net> Hello, has anyone a clean method to check if an object has been instanciated? What I wish to do is to create an object if it hasn't been made before, ie something like this : if not exists(objectReference): objectReference=Object() # perform stuff on objectReference Thanks in advance, - Olivier From ats1 at ukc.ac.uk Sun Oct 15 09:08:28 2000 From: ats1 at ukc.ac.uk (Adam Sampson) Date: 15 Oct 2000 14:08:28 +0100 Subject: Testing existance of variable References: Message-ID: <87itquxneb.fsf@cartman.azz.net> Steve George writes: > if os.environ.has_key('REMOTE_HOST') or os.environ.has_key('REMOTE_ADDR'): > remote_id = os.environ['REMOTE_HOST'] or os.environ['REMOTE_ADDR'] Why not: if os.environ.has_key('REMOTE_HOST'): remote_id = os.environ['REMOTE_HOST'] elif os.environ.has_key('REMOTE_ADDR'): remote_id = os.environ['REMOTE_ADDR'] ? -- Adam Sampson azz at gnu.org From tismer at tismer.com Wed Oct 25 12:55:28 2000 From: tismer at tismer.com (Christian Tismer) Date: Wed, 25 Oct 2000 19:55:28 +0300 Subject: DESPERATE FOR NEWS ON STARSHIP OUTAGE References: <8t1rb9$8hn$1@nnrp1.deja.com> Message-ID: <39F71080.AB9C2BBB@tismer.com> Manus Hand wrote: > > I fit the category described in the subject of this message. > > Anyone know anything about when whatever network problem that > is preventing us from getting to starship.python.net and > to beopen.com will be resolved? > > Anyone know if it's being worked? Can I badger someone more > specific than the whole newsgroup? I am very sorry. I cannot tell you more than this today: The Starship will be unavailable for a couple more days. Please, be a little patient (I know it is hard if one depends on the machine), but I can't accelerate it any more. We are in serious trouble, but we got enough help, so please don't send money - praying and keeping fingers crossed will help. Next update scheduled for tomorrow. ahoi - chris -- Christian Tismer :^) Mission Impossible 5oftware : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From sabren at manifestation.com Sat Oct 7 11:28:07 2000 From: sabren at manifestation.com (Michal Wallace) Date: Sat, 7 Oct 2000 11:28:07 -0400 (EDT) Subject: Xmodem module In-Reply-To: <8rneou$idibt$1@ID-11957.news.cis.dfn.de> Message-ID: On Sat, 7 Oct 2000, Emile van Sebille wrote: > Has anyone got anything resembling xmodem? I have a > customer that's been using a procomm script to communicate > through to their bank, and they've lost the source. They're > now switching back-end systems, and the function needs to be > ported. If there's a good starting point, I'd just as soon > use python, but if not, I'll recreate the script. dunno about a python module, but linux/freebsd/unix/whatever usually has "sz" and "rz" commands... they support X, Y, and Z modem protocols over stdin, and probably over a pipe... Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From jasonic at nomadicsltd.com Wed Oct 4 19:17:40 2000 From: jasonic at nomadicsltd.com (Jason Cunliffe) Date: Wed, 4 Oct 2000 19:17:40 -0400 Subject: Timezone conversions using Python, References: <39DB99C2.AEC538DC@k12s.phast.umass.edu> Message-ID: Joe check out the wonderful http://starship.python.net/~lemburg/mxDateTime.html It really __should__ be the DEFAULT for Python and all OSen. Get away from the crappy January 1970 ticks madness arghh.. let me know how it works out - Jason ________________________________________________________________ Jason CUNLIFFE = NOMADICS.(Interactive Art and Technology).Design Director From jurgen.defurne at philips.com Mon Oct 9 04:18:19 2000 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Mon, 9 Oct 2000 10:18:19 +0200 Subject: future of Python: Stackless, Standard -> fragmentation ? Message-ID: <0056900012699194000002L042*@MHS> YARWMS (Yet another reason why m$ still sucks) Jurgen nas at arctrix.com@SMTP at python.org on 06/10/2000 16:33:52 Sent by: python-list-admin at python.org To: python-list at python.org@SMTP cc: Subject: Re: future of Python: Stackless, Standard -> fragmentation ? Classification: On Fri, Oct 06, 2000 at 04:05:27PM +0200, Dirk-Ulrich Heise wrote: > I suppose that [the C#] VM shares the same disadvantages the > Java VM has? I understand it the .NET VM is more general and powerful then the Java VM. It was designed as a platform for multiple languages while the Java VM was not. Also, the .NET VM does not make the security guarantees that the Java VM does. Neil -- http://www.python.org/mailman/listinfo/python-list From kuchler at ajubasolutions.com Fri Oct 27 17:28:04 2000 From: kuchler at ajubasolutions.com (Dan Kuchler) Date: Fri, 27 Oct 2000 14:28:04 -0700 Subject: PythonLabs Team Moves to Digital Creations References: Message-ID: <39F9F364.BE36B139@ajubasolutions.com> Guido van Rossum wrote: > > Unfortunately, BeOpen.com's original plans for PythonLabs didn't work > out as hoped, and we weren't able to reach mutual agreement on > workable alternative plans -- despite trying for months. Can you elaborate on what the 'original plans' wer for PythonLabs at BeOpen, or what some of the alternatives were? > I am proud to have found a new home for my entire team: starting > today, Tim Peters, Barry Warsaw, Jeremy Hylton, Fred Drake and myself > are working for Digital Creations. We will be spending part of our > time on core Python development (including Jython and Mailman) and > part of our time on Python infrastructure improvements that also > benefit Zope. Congratulations guys, best of luck at your new company/jobs. --Dan From tovj at stud.ntnu.no Thu Oct 19 09:37:02 2000 From: tovj at stud.ntnu.no (Tov Are Jacobsen) Date: Thu, 19 Oct 2000 15:37:02 +0200 Subject: Reading the error stream from os.popen() Message-ID: <8smt02$8sb$1@kopp.stud.ntnu.no> I just made my first python script, and hit a problem. The msgfmt command below outputs info to the stderr stream, but the read() method retrieves data from stdin. s = os.popen('/usr/bin/msgfmt --statistics '+x[0]+'.po').read() Any ideas? (I would like to make my script to work with an unmodified version of msgfmt) :-) # # stat.py -- prints translation status # # Manual administration required, add/remove language code in the # lang variable. # # Requires modified version of msgfmt which sends output to stdout. # import os import re import string lang = [ ['ca', 0.0, 'Catalan'], ['da', 0.0, 'Danish'], ['de', 0.0, 'German'], ['en_GB', 0.0, 'British'], ['es', 0.0, 'Spanish'], ['fi', 0.0, 'Finnish'], ['fr', 0.0, 'French'], ['ga', 0.0, 'Irish'], ['gl', 0.0, 'Galician'], ['it', 0.0, 'Italian'], ['ja', 0.0, 'Japanese'], ['ko', 0.0, 'Korean'], ['lt', 0.0, 'Lithuanian'], ['nl', 0.0, 'Dutch'], ['no', 0.0, 'Norwegian'], ['pl', 0.0, 'Polish'], ['ru', 0.0, 'Russian'], ['sl', 0.0, 'Slovenian'], ['sp', 0.0, 'Serbian (cyrrilic)'], ['sr', 0.0, 'Serbian (latin)'], ['sv', 0.0, 'Swedish'], ['tr', 0.0, 'Turkish'], ['uk', 0.0, 'Ukranian']] reg = re.compile("(\d+)") for x in lang: # update the .po files. os.popen('sh update.sh '+x[0]) # retrieve statistics s = os.popen('/usr/bin/msgfmt --statistics '+x[0]+'.po').read() all = reg.findall(s); n = len(all) p1 = 0.0 p2 = 0.0 p3 = 0.0 if n >= 1: p1 = float(int(all[0])) if n >= 2: p2 = float(int(all[1])) if n >= 3: p3 = float(int(all[2])) tot = p1+p2+p3 un = tot-(p2+p3) x[1] = (un/tot)*100 # Descending sort on percentage lang.sort(lambda x, y: int((y[1]*10-x[1]*10))) print """ PAN TRANSLATION STATUS Debug messages are not translated in some languages. en_GB is a minor variation on the english translation. """ i=1 for x in lang: print '%3d' % i, '%22s' % (x[2]+"("+x[0]+")"), '%6.1f' % x[1] i=i+1 #-------------------- -- Tov Are Jacobsen From bjorn at roguewave.com Fri Oct 20 18:03:30 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Fri, 20 Oct 2000 16:03:30 -0600 Subject: ActivePython 2.0 Release References: <634vusk9nco8qem70ddo43t4qpgid30s1l@4ax.com> <8sp2he01b00@news1.newsguy.com> <8spsoh$csm$1@nnrp1.deja.com> Message-ID: <39F0C132.39246C6D@roguewave.com> Robin Dunn wrote: > > > > > One little plus (from my POV) I noticed in their previous build is > > that the docs in the Windows build are in CHM, which I find quite > > preferable to bare HTML (built-in index and search, etc), although > > there were lots of defects in the .CHM themselves (missing/wrong > > indices, etc). > > > > I've built a .CHM from the BeOpen python docs. You can get it at > http://alldunn.com/python/py2docs.zip. I just did a quick hack on a > python script (included) I had laying around from 1.5.2 to make it find > the extra docs added since then. The script produces the stuff needed > for the MS HTML Help compiler. I havn't found anything missing yet, but > no guarantees... Oh, this rocks!!! -- bjorn From jay.krell at cornell.edu Sun Oct 15 07:27:12 2000 From: jay.krell at cornell.edu (jay.krell at cornell.edu) Date: Sun, 15 Oct 2000 04:27:12 -0700 Subject: LONG_BIT == 64, can't compile Message-ID: <002201c0369a$ea3529b0$8001a8c0@jayk3> Shouldn't 2147483647 == 2147483647L? For most purposes #define LONG_BIT (CHAR_BIT * sizeof(long)) works (for that matter #define bitsof(x) (CHAR_BIT * sizeof(x)) ) but not if you later do like #if LONG_BIT==64 ... #endif Another possible definition is #if LONG_MAX > 2147483647 #define LONG_BIT 64 #else #define LONG_BIT 32 #endif I tried this with Visual C+++ 5.0 and Cygwin and FreeBSD 4.1 gcc 2.95.2 19991024 (release-2) and it printed 1 with all three. #include int main() { int i = (2147483647 == 2147483647L); printf("%d\n", i); return 0; } The type of "2147483647" can vary between machines. It is int on most, if int is 32 bits, otherwise long, but its value I think should always be 2147483647, even when compared to 2147483647L which is always of type long. That is, there should be unsigned or negative problem. The only way I can imagine it getting messed up is if you do like (long)(short)2147483647 or (int)(short)2147483647 (on 32bit machines), in which case you are likely to end up with -1. Yes, I tried that with the compilers too and got -1. I guess I need to get GCC 2.95.2 20000220.. - Jay > # define LONG_BIT 32 > #else > /* Safe assumption. */ > # define LONG_BIT 64 > #endif > >This fails, becauls LONG_MAX is defined to 2147483647L -----Original Message----- From: Johannes Zellner Newsgroups: comp.lang.python To: python-list at python.org Date: Sunday, October 15, 2000 2:51 AM Subject: Re: LONG_BIT == 64, can't compile >In article , Johannes Zellner wrote: >>Hello, >> >>the following lines of the latest python from cvs >>make it uncompilable here: >> >>Include/pyport.h:384 >> >>#if LONG_BIT != 8 * SIZEOF_LONG >>/* 04-Oct-2000 LONG_BIT is apparently (mis)defined as 64 on some recent >> * 32-bit platforms using gcc. We try to catch that here at compile-time >> * rather than waiting for integer multiplication to trigger bogus >> * overflows. >> */ >>#error "LONG_BIT definition appears wrong for platform (bad gcc config?)." >>#endif >> >> >>LONG_BIT is apparently 64 here. >> >>I use: >> >> GCC 2.95.2 20000220 (Debian GNU/Linux) >> >>hmm. I just commented out the above lines which makes python >>compile but I can't do integer multiplictaions. >> >>So: how can I compile the stuff then ? > >I located the problem to be in /usr/include/bits/xopen_lim.h: > > /* Number of bits in a word of type `long int'. */ > #if LONG_MAX == 2147483647 > # define LONG_BIT 32 > #else > /* Safe assumption. */ > # define LONG_BIT 64 > #endif > >This fails, becauls LONG_MAX is defined to 2147483647L > ^ > >Where does this have to be reported ? > > >So again: how can I compile the stuff to get proper integer operations ? >can I simply override the definition of LONG_BIT to 32 ? > >-- > Johannes >-- >http://www.python.org/mailman/listinfo/python-list From nospam at nospam.com Tue Oct 31 01:44:08 2000 From: nospam at nospam.com (Tom) Date: Tue, 31 Oct 2000 06:44:08 GMT Subject: CPython vs. Jython/JPython References: <9BfL5.14315$w6.6473179@news3.rdc1.on.home.com> Message-ID: "D-Man" wrote in message news:mailman.972917908.25577.python-list at python.org... > > Java's implementation (from Sun) is proprietary. However, you can get a compiled version for free. > > There are also other implementations (gcj allows compiling to native machine code, kaffe provides a bytecode compiler and VM -- > for Linux at least Yes, but if you write a program in Java, and then compile it for Linux with DCJ, then it is still written in (and must be maintained in) a proprietary language controlled in every way by one company - no better than VB. Tom. > > BTW [OT]: I can't remember how to create bytecode with gcj. Would anyone like to refresh my memory? > > On Mon, 30 Oct 2000 09:29:25 Tom wrote: > > And isn't Java a proprietary language/platform (ie. how would you like a VB > > implementation)? > > > > > From the_brain at mit.edu Sun Oct 29 13:41:23 2000 From: the_brain at mit.edu (Alex) Date: 29 Oct 2000 13:41:23 -0500 Subject: Backwards searching for regexps? References: Message-ID: Would something like 'regexp(?!.*regexp.*)' efficiently find the last match to a regexp in a string? Alex. -- Speak softly but carry a big carrot. From thomas.heller at ion-tof.com Wed Oct 25 03:21:00 2000 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Wed, 25 Oct 2000 09:21:00 +0200 Subject: Patch for ExtensionClass Message-ID: <013601c03e54$208a8da0$e000a8c0@thomasnotebook> The current ExtensionClass RCSid 1.39 is not compatible with python 2.0 with Py_TRACE_REFS defined (in debug mode). Reason: You zero out newly created instances and fiddle the refcount explicitely. This patch fixes this problem. Regards, Thomas Heller -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: diff.txt URL: From loewis at informatik.hu-berlin.de Sun Oct 1 04:27:42 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 01 Oct 2000 10:27:42 +0200 Subject: omniORBpy / IDL mapping question... References: Message-ID: cbbrowne at news.hex.net (Christopher Browne) writes: > As an arguably odd-ball choice, you could use a DBM file, so that the > values actually reside in a database outside the Python world. It > doesn't have to be a plain old variable... Indeed, this is one rationale for mapping attributes that way (Paul Prescod calls it "computed attributes", and complains every now and then that Python does not really support them). The other rationale for mapping attributes to operation pairs is that the CORBA Core specification says that attributes really *are* operation pairs, so the IDL notation is just a short-hand notation. Regards, Martin From ats1 at ukc.ac.uk Sun Oct 8 12:22:14 2000 From: ats1 at ukc.ac.uk (Adam Sampson) Date: 08 Oct 2000 17:22:14 +0100 Subject: Code obfuscation / decompilers? References: <39de791e_4@corp.newsfeeds.com> <39DE9F04.59C95D24@pehr.net> <39dea172_4@corp.newsfeeds.com> Message-ID: <87pulbe215.fsf@cartman.azz.net> "Joshua Muskovitz" writes: > But... I don't want prying eyes to easily reverse engineer our key > validation process, or it will become useless. If your key authentication system relies on people not being able to find out your algorithm, then you need a better authentication system, not a code obfuscator. -- Adam Sampson azz at gnu.org From echuck3 at my-deja.com Fri Oct 6 20:40:28 2000 From: echuck3 at my-deja.com (echuck3 at my-deja.com) Date: Sat, 07 Oct 2000 00:40:28 GMT Subject: join() References: <8rjj82$dnb$1@nnrp1.deja.com> <39DD9A9A.7130@hvision.nl> Message-ID: <8rlrdr$6ed$1@nnrp1.deja.com> In article <39DD9A9A.7130 at hvision.nl>, ivnowa at hvision.nl wrote: > echuck at mindspring.com wrote: > > > > > In Python 2.0, I was surprised to see join() had become a method of > > string. I "naturally" expected it to be a method of list. > [...] > > list.join(string) > > The problem is that string.join does not work on a list... it works on a > *sequence*. These are all valid: Ah, I see your point. That brings me to my next suggestion: That types can inherit from each other and that we make an abstract Sequence type from which List, Tuple and possibly String all inherit from. > I agree that something like list.join would have been more intuitive, > though. This is not the only step away from being intuitive that Python > has taken lately. What other things in Python have become non-intuitive in your opinion? -Chuck -- http://webware.sourceforge.net Sent via Deja.com http://www.deja.com/ Before you buy. From tim_one at email.msn.com Sun Oct 8 03:25:17 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 8 Oct 2000 03:25:17 -0400 Subject: Is this a dream or a nightmare? (Was Re: XML) In-Reply-To: <39dffde6.48435086@news.davesworld.net> Message-ID: [David T. Grove] > die unless @d = map {"$basedir/$_"} grep {!-d && -w} readdir(dir); [Grant Griffin] > What in the heck does all _that_ mean? [back to David] > Actually, fully extended, it means "give me a platform independent > list of writable (non-directory) files in that directory in a form > that will allow me to name the files so that I can see them from > elsewhere in my code regardless of where they are on disk, or halt > immediately because if this doesn't work you might screw something > up". It generally takes no code in Python to "halt immediately ... if this doesn't work" <0.5 wink>. I note some odd stuff about that Perl: 1. You skipped over the code to open the directory handle (dir). Presumably you need a few more lines, like $basedir = "/code"; die $! unless opendir(dir, $basedir); 2. The "!-d && -w" test doesn't make sense since the names returned from readdir are just file names (not paths), and you didn't chdir() to $basedir first. Unless that's another missing line: die $! unless chdir $basedir; 3. Inserting a forward slash is not platform-independent (think e.g. Macs, or even Windows if the paths are to be passed on to a DOS command). Python (2.0) code for doing all that correctly is no more lines (it could be squashed into fewer but not profitably), but they are longer; OTOH, they do more, and don't change the current directory: import os, stat basedir = os.path.normpath("/code") paths = [os.path.join(basedir, f) for f in os.listdir(basedir)] d = [p for p in paths if os.path.isfile(p) if os.stat(p)[stat.ST_MODE] & 0222] Curiously, there is no obvious x-platform way in Python to test whether a file is writable. Doing a stat and mucking with the permission bits directly is about as good as it gets. OTOH, people are sometimes surprised by what "-w" means in Perl! That you're not mucking with the mode bits directly there means Perl gets to surprise you by picking a meaning you may not have intended -- at least in Python you can see exactly what "writable" is testing. Although, if your background isn't Unix, it's utterly mysterious . Python's os.access() instead is closest to the Perl meaning, but doesn't exist on Mac Python. God only knows what works on Palm Pilot Python . x-platform-is-hard-ly y'rs - tim From xdong at aer.com Mon Oct 2 17:55:33 2000 From: xdong at aer.com (Xiaoxia Dong) Date: Mon, 02 Oct 2000 17:55:33 -0400 Subject: questions References: <200010022127.e92LRNb18592@hera.cuci.nl> Message-ID: <39D90454.B7B0A2F5@aer.com> Hans Nowak wrote: > On 2 Oct 00, at 14:09, Xiaoxia Dong wrote: > > > i am working on one of the project which needs using python, i am trying > > to read a directory and list all > > the files there according to the directory tree. I am thinking to make > > the directory name bold and trying to > > have some format like a2ps in unix. I am just writing the output to a > > text file. I don't use any graphical interface. Can anybody help me with > > this? > > I'm not sure what you mean here... if you want all files in a certain > directory, you can use glob: > > >>> import glob > >>> glob.glob("c:/PythonWin/*.*") > ['c:/PythonWin\\UNWISE.EXE', 'c:/PythonWin\\python.exe', > ... etc ... 'c:/PythonWin\\test1.py', 'c:/PythonWin\\logfile.txt', > 'c:/PythonWin\\xref-results.html'] > > If you want a files in all subdirectories in a tree, you should use > os.path.walk: > > >>> import os > >>> def visit(arg, dirname, names): > # just an example > print dirname, ":" > print names > > >>> os.path.walk("c:/foo/bar/", visit, 0) > # should print list of subdirectories and their files > > Hope this will get you started, > > --Hans Nowak (zephyrfalcon at hvision.nl) > You call me a masterless man. You are wrong. I am my own master. > May a red dragon make a horoscope about your arms! thank you very much for your help. I guess i did not make myself clear, I am tyring to change the font of some of the string i am going to write to a file and in overall i want my file look pretty and elegant. Is there anyway i can do it in python? thanks, xiaoxia From m.faassen at vet.uu.nl Mon Oct 2 16:19:39 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 2 Oct 2000 20:19:39 GMT Subject: What is Python? References: <39C6DF06.FF7F8A74@engcorp.com> <39C70642.D6CBF93A@alcyone.com> <39C710F7.4E72D963@seebelow.org> <39C86059.2F644D70@engcorp.com> <39C867B5.DFF9FFD3@seebelow.org> <39D02F19.2A13F38C@my.signature> <39D1259E.2D6668B6@san.rr.com> <39D1611A.FB67931D@san.rr.com> <8qt8fb$2og$1@newshost.accu.uu.nl> <39D22A2E.5D870956@san.rr.com> Message-ID: <8raqkr$2sm$2@newshost.accu.uu.nl> Darren New wrote: [snip discussion of 'thou'] Well, thou may change the picture, but currently English does look like I described, so that still stands. :) > But speaking to other non-native speakers (whose first languages were > romance languages, mind), I was suprised to hear that the simplicity of verb > conjugations was one of the appealing aspects of English. I would have > thought it was the gender thing, myself. Oh, the absence of gendered nouns is very important to me. I'd probably not be very fluent if English had gendered nouns. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From feldmh01 at popmail.med.nyu.edu Sun Oct 8 14:38:45 2000 From: feldmh01 at popmail.med.nyu.edu (Henry Feldman) Date: Sun, 08 Oct 2000 18:38:45 GMT Subject: Python2.0 beta 2 on MacOSX/Darwin References: Message-ID: Not yet. Once somebody posts a binary, it will be much easier. However, we are still attempting to debug the build process. -- Henry Feldman, '2001 NYU School of Medicine From g_will at cyberus.ca Tue Oct 24 10:12:03 2000 From: g_will at cyberus.ca (Gordon Williams) Date: Tue, 24 Oct 2000 10:12:03 -0400 Subject: urllib problem with "version" now using Python 2.0 Message-ID: <8t45ej$2o4l$1@news2.ottawa.cyberus.ca> I have been using a script to extract some information from web pages using Python 1.5.2 for some time without problem. Since I have changed to Python 2.0 (final) I have an .html error page sent back to me rather than the page that I wanted. The error message is: Error Information Machine: TFLAPP03 Date/Time: 10/23/00 13:26:01 Template: D:\Servers\The Fund Library 2K\tfl\FundCompany\CompanyDetail\p_CompanyDetail.cfm Remote IP Address: 209.195.65.35 Referring URL: Browser: Python-urllib/1.13 Query: Tab=price&SR=1&Sort=Fund_Name_TFL&Order=ASC&Company=40 Details: Parameter 2 of function Left which is now "0" must be a positive integer The error occurred while evaluating the expression: Version = Left(Version,Find(" ",Version)) The error occurred while processing an element with a general identifier of (CFSET), occupying document position (29:1) to (29:49). ** end of error message *********** I'm not sure what "Version" is referring to in the error message (maybe some header information???). Some changed have been made to the urllib module since python 1.5.2 and I am wondering if a bug was introduced. Any ideas?? Regards, Gordon Williams From MarkH at ActiveState.com Wed Oct 25 20:15:07 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 26 Oct 2000 00:15:07 GMT Subject: How do I force a single instance of a python app? References: <39f5e46f_3@corp.newsfeeds.com> Message-ID: "Dale Strickland-Clark" wrote in message news:urodvssp7e7cmbv1ljlqnqgej9rjhfqbli at 4ax.com... > Open a flag file exclusively for writing. If successful you are alone, > if not, another instance already has the file. > > The OS should close the file and free the exclusive lock if the app > crashes. Or attempt to create a directory - that is an atomic operation that indicates what you need to know. Obviously will need some sort of recovery options or process tho... Mark. From sdm7g at virginia.edu Thu Oct 26 15:39:13 2000 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Thu, 26 Oct 2000 15:39:13 -0400 (EDT) Subject: Python scoping In-Reply-To: <20001026152429.A7714@better.net> Message-ID: On Thu, 26 Oct 2000, William Park wrote: > > Good programmers always use indentation, with or without braces. But, I > personally wouldn't mind "end" statements (ie. endif, endfor, endwhile, > etc.) for situations where blocks are longer than one screen. > I try to keep my blocks and functions short enough to be easily readable, but yes: there are times when they have to be longer than a page. But in those cases, even with a block delimiter, I find I need to use additional comments: 'endif' isn't enough because I probably have multiple if statements, so I need "endif (test-condition)" to match up with "if (test-condition)". I don't know of any programming languages that are quite that verbose, and I'm not sure I would like it since the shorter one-page cases vastly prevail, so I might as well use comments for those exceptional cases. ( And it's not any harder to use comments with "offside rule" block structure than it is with explicit end tokens. ) ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- "All operating systems want to be unix, All programming languages want to be lisp." From mail at jbrisbin.net Tue Oct 10 17:47:51 2000 From: mail at jbrisbin.net (Jon Brisbin) Date: Tue, 10 Oct 2000 16:47:51 -0500 Subject: [ANNOUNCE] Python ServerPages 0.7.0a on sourceforge Message-ID: The Python ServerPages distribution on sourceforge has been updated with the latest release. This software is still considered alpha, or pre-beta :-) You can get it at http://sourceforge.net/projects/pythonpages It is also mirrored at (with more documentation) at: http://www.jbrisbin.net/PythonServerPages What is this PSP implementation? Python ServerPages is an OpenSource project that seeks to give developers wishing to embed Python into their HTML pages a consistent and stable parse engine, which would increase their productivity, while including small, simple services to reduce repetitive tasks that every developer faces. The changes to version 0.7.0a include: * Major bug fixes :-) * Added html_quote(stuff) function * Added include(file="file.html") function * Added a proc_total_time to gauge the speed of parsing and executing the page * Added a view_source() function to aid in debugging * Altered the parsing routine to allow nested parsing This version of PSP is easier to use (sample code:) [- include(file="header.psp") first_name = Form.name -] [+Form.name+] [$ def do_something(self, param): $]
[+param+]
[$ enddef $] [$ if Form.name == "harry": $] [- do_something("Harry") -] is logged in. [$ endif $] [- include(file="page2.psp") -] [- include(file="footer.html") -] Some documentation is also available at http://www.jbrisbin.net/PythonServerPages Enjoy! Jon Brisbin www.jbrisbin.net +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Email: mail at jbrisbin.net PSP Home: www.jbrisbin.net/PythonServerPages Public PGP key: www.jbrisbin.net/pgpkey.shtml +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From sabren at manifestation.com Sat Oct 7 02:18:29 2000 From: sabren at manifestation.com (Michal Wallace) Date: Sat, 7 Oct 2000 02:18:29 -0400 (EDT) Subject: super - is (should) it (be) a reserved word? In-Reply-To: <39DEAD1A.1201A557@ix.netcom.com> Message-ID: On Sat, 7 Oct 2000, Thomas Gagne wrote: > I like the idea of 'super' being useful when there's single > inheritence, and its behavior being undefined, or even an error, > when thee are multiples. how about a utility function? def super(object): try: return object.__class__.__bases__[0] else: return None Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From wware at world.std.com Thu Oct 5 23:13:44 2000 From: wware at world.std.com (Will Ware) Date: Fri, 6 Oct 2000 03:13:44 GMT Subject: Are there Python code for a FIFO-like structure? References: Message-ID: Huaiyu Zhu (hzhu at users.sourceforge.net) wrote: > I need something like a fifo, inplemented in a fixed length list... > an IndexError is raised if the tail gets > too close to the head. I'm not aware of any standard thing like that. Generally one would implement a stack using list.append() and list.pop(), and I have implemented FIFOs using list.append() and list.pop(0), but I hadn't faced the constraint of keeping the list length constant. Since you can't do a put and a get literally simultaneously, you'll have to tolerate a list length that oscillates between two adjacent values. It might be useful to whip up a state diagram telling when it's OK to do a put or a get based on the current list length. You'll need to alternate puts and gets to prevent greater length variations. See if this does what you want: class FixedLengthFifo: def __init__(self, length): self.length = length self.lst = length * [None] def put(self, x): if len(self.lst) != self.length: raise IndexError self.lst.append(x) def get(self): if len(self.lst) != self.length + 1: raise IndexError return self.lst.pop(0) -- # - - - - - - - - - - - - - - - - - - - - - - - - # Resistance is futile. Capacitance is efficacious. # Will Ware email: wware @ world.std.com From jeroen.valcke at savaco.com Mon Oct 30 09:33:24 2000 From: jeroen.valcke at savaco.com (Jeroen Valcke) Date: Mon, 30 Oct 2000 14:33:24 GMT Subject: __getitem__ AttributeError Message-ID: <39FD86B3.E13ABF1E@savaco.com> In python I call a method of a selfdeclared class and I keep getting the error: H:\progs\python>python listslides.py Traceback (innermost last): File "listslides.py", line 18, in ? for slide in slidelist: AttributeError: __getitem__ What am I doing wrong? The code looks like this ------listslides.py------- import string import slidelist import slide f = open('h:/progs/python/testfile.txt', "r") lines = f.readlines() f.close() slidelist = slidelist.Slidelist() slidelist.make_list(lines) for slide in slidelist: slide.display -----slidelist.py------ import slide, string class Slidelist: def __init__ (self): self.slidelist = [] def make_list(self, line_list): for line in line_list: tokens = string.split(line, ":") if len(tokens) >= 3: current_slide = slide.Slide( string.strip(tokens[0]), string.strip(tokens[1]), string.strip(tokens[2]), string.strip(tokens[3])) self.slidelist.append(current_slide) -----slide.py------ class Slide: def __init__ (self, t="", s="", c="", p=""): self.traynr = t self.slidenr = s self.slidecomment = c self.setpcdinfo = p def display (self): print self.traynr, self.slidenr, self.slidecomment, self.pcdinfo From dag at orion.no Wed Oct 4 17:47:41 2000 From: dag at orion.no (Dag Sunde) Date: Wed, 04 Oct 2000 21:47:41 GMT Subject: win32net without NetAddUse method References: Message-ID: <1ANC5.5044$Uc.516357@juliett.dax.net> There is a WNetAddConnection2()... could that be of any help? See: X:\Python\win32\demos\win32wnet\netresource.htm of your installation... Dag. "James_McNaughton" wrote in message news:d1m7l7ov3so.fsf at shell-3.enteract.com... > I want to write a script to mount NT network shares as local > drives in the same manner as "net use". I found a posting > via Deja.com* which advised using win32net.NetUseAdd(). For > some reason when I import win32net there's no NetUseAdd. > > I have reinstalled the win32all collection thinking that > there would be an update that I was missing and apparently > there isn't. What I have is Pythonwin build 125. > > Any suggestions? > > Jim > > * For some reason I couldn't post a follow up to the > previosly mentioned thread through Deja.com. I must > therefore ask myself why use Deja.com for anything? From fwang2 at mcnc.org Wed Oct 4 17:45:50 2000 From: fwang2 at mcnc.org (Feiyi Wang) Date: Wed, 4 Oct 2000 17:45:50 -0400 Subject: asyncore: select on UDP socket question Message-ID: Hi, I have some trouble of using "asyncore" for UDP based server (the examples I have seen are all TCP based): I will first describe the problem I ran into, then the sample code. (1) once the server call "asyncore.loop()", I saw a flood of messages saying that "write unhandled", obviously "handld_write()" is called, but why? no one is writing to that private port. (2) there is always "log: adding channel " printed out and I can't get rid of it. In general, i don't think I am using the package in the right way, please help, here is the sample code on server: class asynServer(asyncore.dispatcher): def __init__(self, port): asyncore.dispatcher.__init__(self) self.create_socket(AF_INET, SOCK_DGRAM) self.bind(("", port)) # received an incoming connection def handle_read(self): K=1024 try: data, address = self.recvfrom(64*K) print address[0], "said : \n", data ... asynServer(6000) asyncore.loop() Thanks Feiyi From quinn at bolivar.ugcs.caltech.edu Sat Oct 28 17:00:52 2000 From: quinn at bolivar.ugcs.caltech.edu (Quinn Dunkan) Date: 28 Oct 2000 21:00:52 GMT Subject: PythonLabs Team Moves to Digital Creations References: <8tfa4l$3ns$1@nnrp1.deja.com> Message-ID: On Sat, 28 Oct 2000 19:41:10 GMT, tim_one at email.msn.com wrote: >at the other end of that scale. Things like library feature set and >internal implementation tradeoffs are on target, and, yes, we will make >changes in those areas that benefit Digital Creations products (but we >did before too! the lines here are grey). When such changes become So does that mean there's going to be some sort of standard way to attach data to functions so they can stop overloading docstrings? :) I seem to recall you previously expressed some distaste about that "it's an abuse" From akuchlin at mems-exchange.org Thu Oct 19 10:21:52 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 19 Oct 2000 10:21:52 -0400 Subject: "Portability" (was: How to create a Unix Domain Socket?) References: <39ED6C4A.CBEE94DB@schlund.de> <8skj2r$3i9k$1@nntp6.u.washington.edu> <4BE3250D4FF22FD0.C3EA83F880EAEC04.44DD6B4DD07EB906@lp.airnews.net> <39EEE7D8.1059A34F@holdenweb.com> Message-ID: <3dog0g6hdr.fsf@kronos.cnri.reston.va.us> claird at starbase.neosoft.com (Cameron Laird) writes: > My personal emotional reaction is that Python > shouldn't be like Perl, and shouldn't just expose > the OS run-time; it should build in a portability > layer for strftime(), socket(), and other notor- > ious black sheep. I suppose I'll just leave it One risk of this approach is that you wind up following Java's least-common-denominator approach. Not every platform supports select()? Then you can't use select() on any platform at all... --amk From kern at caltech.edu Thu Oct 5 23:43:50 2000 From: kern at caltech.edu (Robert Kern) Date: Thu, 05 Oct 2000 20:43:50 -0700 Subject: adding matrices of strings References: <39DBA479.1179C63E@northwestern.edu> Message-ID: <8rjhlu$hqh@gap.cco.caltech.edu> In article <39DBA479.1179C63E at northwestern.edu>, Louis Luangkesorn wrote: [snip] > It does not seem like the NumPy array accepts strings, and I was > thinking about adding lists of lists together, but all I get is the set > of lists in A with the lists in B. You can use NumPy. Just use the "O" typecode when creating the matrix with the "array" function. The caveat is that when you pull an element out of the array by indexing it, the value returned is not a Python string, but another NumPy array. Use str(A[i,j]) to convert. >>> from Numeric import array >>> a = array([['a', 'b'],['c','d']], 'O') >>> a array([[a , b ], [c , d ]],'O') >>> a + a array([[aa , bb ], [cc , dd ]],'O') >>> type(a[0, 0]) >>> str(a[0, 0]) 'a' > the other thing I need to do is to take that matrix A, and pull a > particular element from it (without removing that element like a > a.pop(x) would do) A[i,j] with NumPy arrays. With matrices built from lists, A[i][j] should work. -- Robert Kern kern at caltech.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." From alex116321 at my-deja.com Tue Oct 24 11:38:59 2000 From: alex116321 at my-deja.com (alex116321 at my-deja.com) Date: Tue, 24 Oct 2000 15:38:59 GMT Subject: event loop problem References: <8t21ei$e5a$1@nnrp1.deja.com> Message-ID: <8t4aei$93r$1@nnrp1.deja.com> In article , "Mark Hammond" wrote: > wrote in message > news:8t21ei$e5a$1 at nnrp1.deja.com... > > I am trying to write a simple Python script which which uses ADO > > through Python's COM extension but never exit. For this I have > writen > > a simple while loop however this causes a problem on Windows NT. > > Sometimes other windows on NT broadcast messages which need to be > > confirmed by all running windows. If at least one window does not > > dispatch the confirmation, the broadcaster will hang. In C++ the > > solution is to make the main event loop listen for windows messages, > > for example: > > > > while(PeekMessage(&msg,NULL,NULL,NULL,PM_REMOVE)) { > > TranslateMessage(&msg); > > DispatchMessage(&msg); > > } > > What you want is pythoncom.PumpWaitingMessages() > > Mark. > > Thanks Mark, that did the trick. Alex Sent via Deja.com http://www.deja.com/ Before you buy. From gtalvola at nameconnector.com Tue Oct 24 14:13:59 2000 From: gtalvola at nameconnector.com (Geoff Talvola) Date: Tue, 24 Oct 2000 14:13:59 -0400 Subject: event loop problem References: <8t21ei$e5a$1@nnrp1.deja.com> <8t3q4402a3u@news2.newsguy.com> <8t4caq031fl@news2.newsguy.com> Message-ID: <39F5D167.73991827@NameConnector.com> Alex Martelli wrote: > > > > But a better solution is to tell win32com to run in free-threading > mode, in > > > > which case it doesn't create a hidden window and everything works fine > > > > > > No, but it DOES freely create threads! Remember to protect > > > all access to shared-data if you choose this route. Personally, > > > I think serving the message-loop is simpler. > > > > For a single-threaded Python program using ADO, there's no shared data to > worry > > If that Python program exposes COM stuff, and it tells COM it's free > threaded, it's a risky gamble to call it "single-threaded". _IT_ does > not explicitly start up more threads, BUT its code may be executed on > other threads (e.g. in response to COM events, if it hooks any). And > I don't think the Python-interpreter's single global lock will save > your skin in that case -- the interaction level made "atomic" by that > lock is the single-Python-bytecode-instruction, which I think is too > semantically low (which is why Python multithreaded programs use their > own locking strategies). Interesting... I hadn't considered that COM events could be executed on a different thread in free threading mode. I don't happen to be hooking any COM events at the moment though. > > about. And what if your program structure contains long-running > calculations > > based on data from your ADO database? You have to contort your > calculations to > > insert PumpWaitingMessages() calls everywhere. A single-threaded, non-GUI > > application shouldn't have to have a message loop, IMO. > > I disagree. _Particularly_ if that application "contains long-running > calculations", it *should* be checkpointing regularly, *and* responding > sensibly when the system tells it "we're about to go down, is that > all right?" -- which it does by sending it appropriate messages. It's > even more important when the system has advanced power management: if > the application doesn't handle that, it has no way to tell the system > "no, DON'T switch to low-power-mode, I need all the CPU I can get for > my long-running calculations!", etc, etc. You're right, these are certainly valid concerns for many (but not all) apps. > I'll freely admit I have not looked at the issue of ADO "creating lots of > threads", and I do wonder where that extra 'hidden window' comes from (are > there apartment-threaded objects in the ADO/OleDb internals, not just > free-threaded ones...?). But I wonder how you _ensure_ that none of your > code is ever executed on one of those other "lots of threads" -- maybe > by exposing no COM functionality whatsoever, including not hooking any > events. Seems a rather high price to pay, in general, though it may be > OK for a lite/throw-away little thingy that doesn't need to receive > events or be externally-automatable anyway. Here's my reasoning for choosing free threading in my app (which is certainly not a lite or throwaway thingy): My app is a web application built around a multithreaded web application server (WebKit, part of WebWare for Python) which has a main thread and a number of worker threads, each of which uses ADO for database access. My ADO objects are never shared between threads, I'm not using any COM events, and my app is not a COM server. By using free threading, I don't need to process messages in each of my worker threads. I believe that if I were using apartment threading, every one of my threads would need its own message loop. -- - Geoff Talvola Parlance Corporation gtalvola at NameConnector.com From the_brain at mit.edu Thu Oct 5 13:30:20 2000 From: the_brain at mit.edu (Alex) Date: 05 Oct 2000 13:30:20 -0400 Subject: exceptions References: Message-ID: You just have the try block in the wrong place. Try something like this: def f(divident): L=[2,4,5,0,5,0,8] for divisor in L: try: print divident/divisor except: print '' f(100) Alex. -- Speak softly but carry a big carrot. From gunars at spss.com Fri Oct 20 10:54:29 2000 From: gunars at spss.com (Gunars Lucans) Date: Fri, 20 Oct 2000 09:54:29 -0500 Subject: ActivePython 2.0 Release References: <634vusk9nco8qem70ddo43t4qpgid30s1l@4ax.com> Message-ID: <39F05CA5.FE8C4AD8@spss.com> Dale Strickland-Clark wrote: > > Yes, but how is this better then Python 2.0 + Win32all? And _is_ it better? -- i.e. is ActivePython 2.0 a strict superset of Pythonlabs Python 2.0 final + Win32all? That fact that tkinter and Idle were just added makes me wonder what else is missing. From johann at physics.berkeley.edu Sun Oct 8 21:12:42 2000 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 08 Oct 2000 18:12:42 -0700 Subject: Pyton on MacOS X is a link away ... References: <8rq7i8$ru7$1@news.panix.com> Message-ID: Thelonious Georgia writes: > Hey all- > Okay, my attempts to get Python 1.6 running on MacOS X have stymied at > ranlib libpython1.6.a > true > cd Modules; make OPT="-g -O2 " VERSION="1.6" \ > prefix="/usr/local" exec_prefix="/usr/local" \ > LIBRARY=../libpython1.6.a link > cc python.o \ > ../libpython1.6.a -o python > /usr/bin/ld: Undefined symbols: > __PyImport_DynLoadFiletab > __PyImport_GetDynLoadFunc > make[1]: *** [link] Error 1 > make: *** [python] Error 2 > [toad_hall:~/Python-1.6] root# > This is a tricky one ... I can't figure my way out of this. Any ideas as to > why this is happening? Well, that looks like it's based on the dynamnic loading somehow. Are you trying to build a static version, or are you including dynamic modules? I've only worked with dynamic loading under Python 2.0b2 on OS X. There, the link command needed -framework System added to it to work. If that were your problem, I'd expect more errors, though. More info? -- Johann Hibschman johann at physics.berkeley.edu From aahz at panix.com Sun Oct 8 01:42:09 2000 From: aahz at panix.com (Aahz Maruch) Date: 7 Oct 2000 22:42:09 -0700 Subject: Is this a dream or a nightmare? (Was Re: XML) References: <39d1d3b2.43465571@news.telus.net> <39dfa617.25953118@news.davesworld.net> <39DF88E1.A4181BC5@seebelow.org> <39dffde6.48435086@news.davesworld.net> Message-ID: <8rp1fh$fmi$1@panix2.panix.com> In article <39dffde6.48435086 at news.davesworld.net>, David T. Grove wrote: > >If-it-weren't-for-monotype-text,-you'd-never-catch-your-end-of-block > -errors,-though-ly y'rs. > >Did I do that right? That's about right. Now, please make sure to attribute quotes in the future. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "[I have a] windmill fetish." --Darkhawk From OneDay at A.Time Mon Oct 2 17:20:13 2000 From: OneDay at A.Time (OneDay at A.Time) Date: Mon, 2 Oct 2000 17:20:13 EDT Subject: Deselecting Radio Buttons Message-ID: <8rau6d$12sl$1@earth.superlink.net> Heelo All, It must be possible to deselect a radio button after selecting it. Would someone please tell me how? Thanks for your help, Al PMVar = IntVar() PMBut = Radiobutton(root, text="Select for P.M.", value=2,/ variable=PMVar, padx=50) PMBut.grid(row=1, column=2,sticky=E) PM = PMVar.get() From thanos at 0x01.com Fri Oct 6 19:54:44 2000 From: thanos at 0x01.com (thanos vassilakis) Date: Fri, 06 Oct 2000 19:54:44 -0400 Subject: web hosting with python cgi References: <8rdk5o$97j$1@news5.svr.pol.co.uk> <39DD4F18.49A39005@nospam.twovoyagers.com.invalid> Message-ID: <39DE6644.27381D2A@0x01.com> http://0x01.com is another we hosting service that's doing it with Python thanos Andrew Malcolmson wrote: > In the Toronto there's a very Python-friendly ISP called vex.net > (www.vex.net). They have Python 1.5.2 and Zope and even run their whole > site on Python scripts (HTMLgen ?). They offer a Web hosting account for > $60 Cdn / year and which permits running CGI. > > I think I'll check them out myself. > > Andrew > > "Steve" wrote in message > news:39DD4F18.49A39005 at nospam.twovoyagers.com.invalid... > Bill de h?ra wrote: > > > > Hi, > > > > Can anyone recommend a domain web hosting service that will allow Python > cgi > > scripting? Preferably in the UK and with some kind of pricing structure > for > > non-ecommerce use. > > Not in the UK, but my web host is addr.net: > > % which python > /usr/local/bin/python > % python > Python 1.5.2 (#2, May 11 1999, 17:14:37) [GCC 2.7.2.1] on freebsd3 > > -- > Steve Ackman From hartmut at oberon.noris.de Tue Oct 10 15:23:56 2000 From: hartmut at oberon.noris.de (hartmut Goebel) Date: Tue, 10 Oct 2000 20:23:56 +0100 Subject: Disassambling code in Python: What is in the .co_code-part References: <8rkp43$j2j$1@oslo-nntp.eunet.no> <8rkr45$fmd$1@netserv.univ-lille1.fr> Message-ID: <16600790@oberon.noris.de> Calvelo Daniel (dcalvelo at pharion.univ-lille2.fr) schrieb: >Have a look at: > >* module 'dis' (disassembler module, in Lib/dis.py from the source distro) > >* bytecodehacks : http://bytecodehacks.sourceforge.net You may also want to have a look at decompyle http://www.goebel-consult.de/decompyle/ +++hartmut | hartmut Goebel | hartmut at oberon.noris.de // | | Compiler Manufactur | Essich at irc \X/ | From sabren at manifestation.com Mon Oct 9 12:04:38 2000 From: sabren at manifestation.com (Michal Wallace) Date: Mon, 9 Oct 2000 12:04:38 -0400 (EDT) Subject: PEP 4: Deprecation of standard modules In-Reply-To: Message-ID: On 9 Oct 2000, Martin von Loewis wrote: > Well, that is the whole point of the PEP. Without asking, I wouldn't > know which modules are still in use and which are not. I will > undeprecate the gopher module in the next revision of the PEP, > documenting who is using the module still. Then, ten years from now, > we can ask this person whether he is still using gopherlib, then in 50 > years, and so on. Once he doesn't use it anymore, we can again > deprecate it and wait for somebody else to claim using it :-) Why deprecate modules at all? Why not just move them out of the standard distribution and make a home (page) for outcast modules.. As long as you can get to this stuff from parnassus, everyone should be happy. Or am I missing something? Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From breiter at usf.Uni-Osnabrueck.DE Thu Oct 5 09:41:34 2000 From: breiter at usf.Uni-Osnabrueck.DE (Bernhard Reiter) Date: 5 Oct 2000 13:41:34 GMT Subject: Gnuplot and Python on Windows References: <39DA44F4.B4AFCDAE@wag.caltech.edu> Message-ID: <8ri0ee$o18$1@newsserver.rrzn.uni-hannover.de> In article <39DA44F4.B4AFCDAE at wag.caltech.edu>, Richard Muller writes: > I'm having a hard time getting the Gnuplot-1.4 module to work in the > Windows version of Python 1.5.2. I've installed the win32all module, as > well as pgnuplot.exe. I'm still seeing the following error message: > > Please press return to continue... > Please press return to continue... > gnuplot> set title "A simple example" > gnuplot> set data style linespoints > gnuplot> plot 'c:\windows\TEMP\~-1563933-1' notitle > gnuplot> reset > gnuplot> set title "Data can be computed by python or gnuplot" > gnuplot> set xlabel "x" > gnuplot> set ylabel "x squared" > gnuplot> plot x**2 title "calculated by gnuplot", > 'c:\windows\TEMP\~-1563933-2' title "calculated by python" with points 3 > 3 > Traceback (innermost last): > File "demo.py", line 129, in ? > demo() > File "demo.py", line 80, in demo > g.ylabel('x^2') # take advantage of enhanced postscript mode > File "__init__.py", line 1273, in ylabel > self.set_string('ylabel', s) > File "__init__.py", line 1263, in set_string > self('set %s "%s"' % (option, s)) > File "__init__.py", line 1095, in __call__ > self.gnuplot(s) > File "gp_win32.py", line 100, in __call__ > self.write(s + '\n') > IOError: [Errno 32] Broken pipe > > I never see a plot. > > Can anyone offer any helpful suggestions on how I should proceed to get > this to work? Thanks in advance. No idea, but you might ask on the gnuplot newsgroup. comp.graphics.apps.gnuplot Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) From jdries at mail.com Sat Oct 28 21:18:59 2000 From: jdries at mail.com (Jan Dries) Date: Sun, 29 Oct 2000 02:18:59 +0100 Subject: Q: how to scan every element of a dictionary ? References: <%fJK5.79$6b7.1499@vixen.cso.uiuc.edu> Message-ID: <39FB7B03.EA62D1DF@mail.com> Hwanjo Yu wrote: > Doesn't the dictionary data structure support an enumeration operator to > scan every element of it ? A dictionary has 3 functions that convert the dictionary to a list that can be enumerated: Given : my_dict = { ..... } you can write: my_dict.items() # returns a list of tuples (key,value) my_dict.keys() # returns a list of all the keys my_dict.values() # returns a list of all the values These are all lists, and you can enumerate over them using for, for example: for i in my_dict.items(): print "key = %s, value = %s" % i Regards, Jan From glenfant at nospam-e-pack.net Mon Oct 2 14:29:28 2000 From: glenfant at nospam-e-pack.net (Gilles Lenfant) Date: Mon, 2 Oct 2000 20:29:28 +0200 Subject: quopri module bug? (python 1.5.2) Message-ID: <8rak0r$iih$1@reader1.imaginet.fr> quopri encodes "=" to "==" when mail clients encode/decode it to/from "=3D". Mail clients I tested are Outlook express (Win), StarOffice and Netscape messenger (Linux) Who has got the bug ? Python or the mail clients ? From mvanaken at keywareid.com Mon Oct 30 10:52:37 2000 From: mvanaken at keywareid.com (Michel Vanaken) Date: Mon, 30 Oct 2000 16:52:37 +0100 Subject: Borland makefile/project for Python 2.0 ? Message-ID: <8tk8ul$9m4@news.idtech.be> Hello, Does anybody have (or could point me to a site with) a makefile or a project file to compile Python 2.0 using a Borland compiler ? TIA, Michel From kohler at medien.tecmath.de Fri Oct 27 05:58:08 2000 From: kohler at medien.tecmath.de (Markus Kohler) Date: Fri, 27 Oct 2000 11:58:08 +0200 Subject: os.system limitations on Windows NT References: <39F6A9CE.80407@cms.tecmath.de> <8t6d5408j3@news1.newsguy.com> Message-ID: <8tbjbc$802$1@sun.rhrk.uni-kl.de> Thanks for your hints Actually there were two problems. First I used "cl" instead of "link", because I passed the wrong variable to a function. It seems that cl automatically invoked link, but that It truncated the arguments (silly Windows behaviour probably). The other problem was that I had a "f.close" instead of "f.close()". That's the disadvantage of having a convenient syntax for function objects. Markus From effbot at telia.com Tue Oct 24 10:54:05 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 24 Oct 2000 14:54:05 GMT Subject: Python Socket problem References: <8t3a7j$ffb$1@nnrp1.deja.com> Message-ID: Sam Schulenburg wrote: > I am trying to use sockets ( I really do not know what I am doing) and > have obtained the following results: > > from socket import * > Sock = socket(AF_INET,SOCK_STREAM) > MySocket = Sock.connect(('192.168.100.101',80)) > MySocket.send('DoTheTest \n\r\0') > MySocket.close() > > The above will send the DOTheTest mesage to 192.168.100.101 and the the > DoTheTest will execute on the server. What I need to do next is obtain > the responce from the test. you're close. but connect doesn't return a new socket; it connects the existing socket to a remote server: from socket import * Sock = socket(AF_INET,SOCK_STREAM) Sock.connect(('localhost',80)) Sock.send('DoTheTest \n\r\0') Sock.close() (and yes, "execute DoTheTest" sounds a bit dangerous, but I assume you know what you're doing...) client sockets can only be used once. to make another request from the same program, create a new socket. > I tried the following code: > > Sock = socket(AF_INET,SOCK_STREAM) > MySocket = Sock.connect(('192.168.100.101',80)) > Data = MySocket.recv() > MySocket.close() > print Data clients connect, servers bind, listen and accept: from socket import * # create a listening socket Sock = socket(AF_INET,SOCK_STREAM) # bind it to a port Sock.bind(("", 80)) # create a small listening queue Sock.listen(1) while 1: # wait for a client to connect NewSock, Info = Sock.accept() print "incoming connection from", Info # read a package from the client print NewSock.recv(1024) NewSock.close() break # shutdown (note that the listening socket can be reused; just remove the "break" to have the loop process another command) for more examples (and better ways to do this), see the "network" chapter in the eff-bot guide. From josh at open.com Sat Oct 7 00:14:09 2000 From: josh at open.com (Joshua Muskovitz) Date: Sat, 7 Oct 2000 00:14:09 -0400 Subject: Code obfuscation / decompilers? References: <39de791e_4@corp.newsfeeds.com> <39DE9F04.59C95D24@pehr.net> Message-ID: <39dea172_4@corp.newsfeeds.com> Thanks for the reply. I too, spent my youth doing just this sort of thing. I understand that the effort necessary to make code unreadable yet efficient is approximately the same amount of time it takes to reverse the process. Luckily, the advancement of compilation techniques makes obfuscation possible, by automating the process. So, for the concrete example, suppose that I have a mechanism written in Python which handles, say, license key validation. I need a method (or set of methods) which manipulate keys to verify their authenticity, and decompose them to turn various program bits on and off. This is a standard problem for many software developers. The actual algorithm for generating the keys and taking them apart originates in older code written in C. It was fairly easy, given the original C source, to produce a python equivalent. But... I don't want prying eyes to easily reverse engineer our key validation process, or it will become useless. There is a "good enough" point, though, where the amount of time needed to crack the algorithm exceeds the value of the software. My goal is to obfuscate my code enough to get to this point. (Identifying this point is another matter, of course!) I realized that simply shipping .pyc files is far from enough. Importing them into the interpreter gives one access to the names of the methods, docs, etc. (Duh.) So, the first obvious step was to replace the names of the more sensitive methods with arbitrary names (__abc, __def, etc) and only keeping the names of the intentionally public methods, which take in a key and simply return a boolean, for example. Removing the docs is the next step. Removing error handling (!) goes another step towards maing experimentation less useful. But a "real" obfuscator, which took bytecode and munged it into something really bizarre would help a lot more. The value of the decompiler is to verify how well the obfuscator works. -- josh -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From twlichty at execulink.com Tue Oct 24 19:15:06 2000 From: twlichty at execulink.com (root) Date: Tue, 24 Oct 2000 19:15:06 -0400 Subject: MySQL Message-ID: <39F617FA.A1DAB270@execulink.com> Hi, I;m fairly new to Python but so far I really enjoy it. I was wondering if someone could tell me how to go about connecting to a MySQL database or, more precisely, where I can download the MySQL modules for python. Thanks From akuchlin at mems-exchange.org Fri Oct 27 11:09:19 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 27 Oct 2000 11:09:19 -0400 Subject: bsddb buffer overflow References: <39f97888@news.edunet.ru> <3dn1fqo0xg.fsf@kronos.cnri.reston.va.us> <39f9924d@news.edunet.ru> Message-ID: <3dhf5ynwww.fsf@kronos.cnri.reston.va.us> lg at rgz.ru writes: > #0 0x2828a61e in memcpy () from /usr/lib/libc_r.so.4 > (gdb) where > #0 0x2828a61e in memcpy () from /usr/lib/libc_r.so.4 > #1 0x81cfbec in ?? () > #2 0x805b809 in call_builtin (func=0x81d8ba0, arg=0x81a60ac, kw=0x0) > at ceval.c:2650 Hmmm... the function of interest would be the one given as ??. Otherwise, it's not clear that the segfault is happening inside the bsddbmodule. Assuming it is, and there are two calls to memcpy() inside the keys() function, so it's plausible, I can see one possible problem. The code used is: if (status == 0) { if (krec.size > sizeof(buf)) data = malloc(krec.size); else data = buf; memcpy(data,krec.data,krec.size); } The return value of malloc() isn't checked, so if it's NULL, the module will blithely attempts to memcpy() to NULL. Perhaps you're really running out of memory, or perhaps krec.size is some bogusly large value. Your best course is probably to use your debugger some more, and step through the bsddb_keys() function to see what's happening. --amk From kc5tja at garnet.armored.net Fri Oct 13 14:14:53 2000 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 13 Oct 2000 11:14:53 -0700 Subject: New Python development process (SourceForge considered Harmful?) References: <39DCF021.16E862A1@estinc.com> <8s7apb$9vd$1@dahlia.singnet.com.sg> Message-ID: On 13 Oct 2000 15:46:51 GMT, Ng Pheng Siong wrote: >Roughly, large numbers of routing updates (oh, this route's up; ooh, it goes down; >hey it comes back again) propagating thru the Internet causing degradation >in network service. OK, thanks. I've never heard this phenomina called that before, but it makes perfect sense. :) -- KC5TJA/6, DM13, QRP-L #1447 | Official Channel Saint, *Team Amiga* Samuel A. Falvo II | Oceanside, CA | From jepler.lnk at lnk.ispi.net Fri Oct 13 18:23:47 2000 From: jepler.lnk at lnk.ispi.net (jepler epler) Date: Fri, 13 Oct 2000 22:23:47 GMT Subject: quopri module bug? (python 1.5.2) References: <8rak0r$iih$1@reader1.imaginet.fr> Message-ID: Python violates the RFC on this issue. I hope it gets fixed. Jeff From kentsin at poboxes.com Wed Oct 18 03:15:19 2000 From: kentsin at poboxes.com (kentsin at poboxes.com) Date: Wed, 18 Oct 2000 07:15:19 -0000 Subject: unicode : big5 encoding? Message-ID: <8sjim7+qv4h@eGroups.com> What codec I should use if the file is in big-5 encoding? Rgs, Kent Sin From hwanjoyu at uiuc.edu Sat Oct 28 19:21:44 2000 From: hwanjoyu at uiuc.edu (Hwanjo Yu) Date: Sat, 28 Oct 2000 18:21:44 -0500 Subject: Q: how to scan every element of a dictionary ? Message-ID: <%fJK5.79$6b7.1499@vixen.cso.uiuc.edu> Hi, Doesn't the dictionary data structure support an enumeration operator to scan every element of it ? When I use the "for" statement to do it as I do with a list structure, it doesn't work. How to do it ? Thanks. From dnew at san.rr.com Fri Oct 27 18:21:18 2000 From: dnew at san.rr.com (Darren New) Date: Fri, 27 Oct 2000 22:21:18 GMT Subject: [Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich , comparison References: <8t65060en@news1.newsguy.com> <39F7D93F.B5B201B4@home.com> <8tc1en0129j@news1.newsguy.com> <39F9C00B.B51361D9@san.rr.com> Message-ID: <39F9FFEE.5C55007A@san.rr.com> Johann Hibschman wrote: > What's 'remainder', if not the same as 'modulo'? The problem is with negatives. X mod 7 is between 0 and 6 (inclusive) for all X. -3 mod 7 != 3 and -3 mod 7 != -3. -3 mod 7 = 4. -1 mod 7 = 6. That's the definition of mod, and that's the semantics I find useful. Note: I don't think there *is* a definition for mod that handles a negative number as the second argument. Now, if you're not going to define it that way, then you shouldn't call it "mod". Call it "remainder". Call it "divrem" and not "divmod". :-) > "r = a % m" should preferrably be in the range from 0 < r < |m|, > right? Well, 0 <= r < |m| I would guess. -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. The tragedy of the commons applies to monitizing eyeballs, too. From trentm at ActiveState.com Fri Oct 20 16:54:59 2000 From: trentm at ActiveState.com (Trent Mick) Date: Fri, 20 Oct 2000 13:54:59 -0700 Subject: [Python-Dev] Re: Compiling python 2.0 In-Reply-To: <20001020222118.M12812@xs4all.nl>; from thomas@xs4all.net on Fri, Oct 20, 2000 at 10:21:18PM +0200 References: <20001020222118.M12812@xs4all.nl> Message-ID: <20001020135459.C1562@ActiveState.com> On Fri, Oct 20, 2000 at 10:21:18PM +0200, Thomas Wouters wrote: > As for the other error, that's really an error :( > > ../libpython2.0.a(fileobject.o): In function portable_fseek': > /usr/home/thomas/Python-2.0/Objects/fileobject.c:274: undefined > reference to `TELL64' > > The problem is that BSDI has an 'off_t' type that is larger than the 'long' > type, and Python's configure makes the flawed assumption that this means > BSDI supports large files (larger than 2Gb.) However, BSDI doesn't. This bug > is even present with BSDI 4.1, and probably more platforms. You can fix this > by editing './config.h' after running './configure', and commenting out the > HAVE_LARGEFILE_SUPPORT line; changing this: > > #define HAVE_LARGEFILE_SUPPORT 1 > > into something like this: > > /* #define HAVE_LARGEFILE_SUPPORT 1 */ > > (You can just remove the line as well.) The downside of both these 'hacks' > (excuse me, 'hotfixes'), is that you'll have to reedit the files again after > running configure again (or something that runs configure, like > 'config.status'.) This one isthe saem problem that showed up for NetBSD1.4.2 and OpenBSD (I see a pattern) http://sourceforge.net/bugs/?func=detailbug&bug_id=112289&group_id=5470 It was fixed by adding a hack in fileobject.c to *define* TELL64. http://sourceforge.net/patch/index.php?func=detailpatch&patch_id=101558&group_id=5470 For the quickfix, the same hack could be used for BSDI. As you suggest Thomas, the proper fix is to patch configure.in such that it does not report that these system support largefiles. I don't have the time to do this right away, nor do I have one of these boxes on which to test it. I can try to make a patch though. We don't you file a bug and assign it to me. Trent -- Trent Mick TrentM at ActiveState.com From pete at petes-place.com Mon Oct 9 15:27:45 2000 From: pete at petes-place.com (David T. Grove) Date: Mon, 09 Oct 2000 19:27:45 GMT Subject: What's wrong with ActiveState? (was: Is this a dream or a nightmare? (Was Re: XML)) References: <39d1d3b2.43465571@news.telus.net> <39D19EBB.ABF18F23@engcorp.com> <39def2ae.8929692@news.davesworld.net> <39e1f314.11798695@news.davesworld.net> Message-ID: <39e21b61.22117262@news.davesworld.net> To private posters: thanks for letting me know about that search engine. That's one kick in the butt I won't soon forget. I'll see to it that it re-organizes its site indices. On Mon, 09 Oct 2000 18:29:19 GMT, pete at petes-place.com (David T. Grove) wrote: >I should have noticed this in the earlier thread. How was this >document seen? To my knowledge, there has never been any link to it >from anywhere on the site. It was not finished, never cleaned up, and >was considered a marketing direction that we didn't want to follow. From moshez at math.huji.ac.il Thu Oct 12 01:09:31 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Thu, 12 Oct 2000 08:09:31 +0300 (IDT) Subject: Python Guru Available For Contract Work In-Reply-To: Message-ID: On Wed, 11 Oct 2000, Tim Peters wrote: [revtracyj at my-deja.com, quoting a Mr. Jarvis] > My last IQ test came in at 161, although I have tested as low as 145. [David] > My penis is 10.5" long. Beat that! [Tim Peters] > Easily. My penis has an IQ of 183, although it has tested as high as 220 in > the Spring. It is particularly fond of long walks by the seashore, and > rubbing up against the works of Schopenhauer. Well, as long as Tim doesn't mention his balls, I think we're doing relatively OK. making-c.l.py-xxx-rated-ly y'rs, Z. -- Moshe Zadka There is no IGLU cabal. http://advogato.org/person/moshez From vr at acm.org Fri Oct 6 07:43:06 2000 From: vr at acm.org (Vetle Roeim) Date: 06 Oct 2000 13:43:06 +0200 Subject: Calling the parent class' __init__ References: <39DD4E57.53C27A3F@ix.netcom.com> <39DD865E.D97E4D09@cable.a2000.nl> Message-ID: * Roeland Rengelink > > A parent class defines some instance variables I want to access in > > the subclass. I thought I was supposed to call the super class' > > __init__ but whenever I tried I got errors so I didn't--but the > > first time I tried accessing the super's instance variable (oddly > > enough, in one of the super's methods) I got a name error. Wierd. > > > > Does anyone have some pointers? > > You'll need something like: > > class A: > def __init__(self, value): > self.a = value > > class B(A): > def __init__(self, val1, val2): > A.__init__(self, val1) > self.b = val2 > > def do(self) > print self.a, self.b or: class C(A): def __init__(self, val1, **keywordvals): apply(A.__init__, (self, val1), keywordvals) the-possibilities-are-endless-ly y'rs, vr From matt at virtualspectator.com Sat Oct 7 18:24:58 2000 From: matt at virtualspectator.com (matt) Date: Sun, 8 Oct 2000 11:24:58 +1300 Subject: realmeadia bindings In-Reply-To: References: <8rdk5o$97j$1@news5.svr.pol.co.uk> <39DD4F18.49A39005@nospam.twovoyagers.com.invalid> Message-ID: <00100811300004.00912@localhost.localdomain> Hi, I need to test some realmedia transaction between client and a realmedia server. Unfortunately I am limited to this or NetMedia(ugh!!) so I chose the Realmedia option. I need to look at the overhead of forming stream connections, both using TCP and UDP streams. I alsready know the overheads of both these protocols, but need to teat the RealMedia protocol specific overheads. Of course, I want to do this with python. Has anyone had any experience, or know of any information about bindings to the Realmedia protocols? regards Matt From mballen at erols.com Tue Oct 17 02:04:25 2000 From: mballen at erols.com (Michael B. Allen) Date: 17 Oct 2000 06:04:25 GMT Subject: Global Configuration Variables Message-ID: Hi! I would like to have some global configuration parameters in a class that can be accessed like this: server = smtplib.SMTP(Config.mailserver) ... My class might have default values, be stored in a module called config.py, and look like this: class Config: spoolfile = 'mail.spool' mailserver = os.environ['HOSTNAME'] mailaddr = os.environ['USER'] + '@' + mailserver ... and then I want to be able to override these defaults with something like: def configinit(filename): execfile(filename, Config.__dict__) Where the passed file might contain: mailserver = 'mail.myserver.org' ... This seem like it should work but I am generally confused with using globals and how I'm supposed to import my config module. If I import like this: from kpdbconfig import Config from kpdbconfig import configinit I get an exception :~( Traceback (innermost last): File "./t0.py", line 174, in ? conifginit('c0.conf') NameError: conifginit What's the best way to do this? Thanks, Mike From erno-news at erno.iki.fi Mon Oct 30 18:46:13 2000 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 31 Oct 2000 01:46:13 +0200 Subject: Python processing of an input byte stream References: <8tkoso$84l$1@nnrp1.deja.com> Message-ID: | import sys, time | ops = { | 0x1 : lambda: 'Function (main) initialized', | 0x2 : lambda a: "Key '%s' was pressed" % a, | # etc. | } | while 1: | c = sys.stdin.read(1) | if not c: probably works better if you replace the below 2 lines... | time.sleep(1) | continue ... with break :) | op = ops[c] | nargs = op.func_code.co_argcount | args = tuple(sys.stdin.read(nargs)) | print apply(op, args) -- erno From peter.stoehr at weihenstephan.org Sat Oct 21 15:00:08 2000 From: peter.stoehr at weihenstephan.org (Prof. Peter Stoehr) Date: Sat, 21 Oct 2000 21:00:08 +0200 Subject: class mutex Message-ID: <39F1E7B8.D2E0F2AB@weihenstephan.org> Hi out there, there is a class mutex shipped with python. I've tried to use it to syncronise two processes created with os.fork() and failed :-( Looking at the source code of mutex.py I found out, that it is implemented in pure python. Thus, it does not implement a real mutex-object as a python code can be interrupted after each step of the byte-code. Based on that, I have two questions: 1) Does python provide a real mutex object. 2) What is the use of the class mutex Greeting Peter -- --------------------------------------------------------------------------- Prof. Peter Stoehr --- Teisenbergweg 6 --- 85435 Erding --- 08122/47232 http://www.weihenstephan.org/home/ak/support/team/jpg/peter.jpg --------------------------------------------------------------------------- I'm the terror that flaps through the night From bob at wildthink.com Sat Oct 21 13:05:35 2000 From: bob at wildthink.com (Robert L Hicks) Date: Sat, 21 Oct 2000 17:05:35 GMT Subject: ActivePython 2.0 Release References: <634vusk9nco8qem70ddo43t4qpgid30s1l@4ax.com> <8sp2he01b00@news1.newsguy.com> <39EFFA36.D953BA53@seebelow.org> Message-ID: I am for it. I have a printed 1.5.2 set. The only *problem* I foresee is that Python is changing pretty rapidly now. What would be cool...is a binder type format. You could print the documents one time and then when changes are made only those changes would have to be swapped out. but-that-is-probably-unworkable-ly-yours Bob > From: jmcbray at carcosa.net (Jason F. McBrayer) > Organization: The Peace Authority > Newsgroups: comp.lang.python > Date: 21 Oct 2000 12:11:15 -0400 > Subject: Re: ActivePython 2.0 Release > >>>>>> "GG" == Grant Griffin writes: >>>>>> "DS" == Dale Strickland-Clark wrote: > > DS> Indeed. Index help would be very handy. > > GG> The Pythonlabs site provides Python 2.0 docs in several formats, > GG> as separate downloads. IIRC, that includes HTMLHelp. But given a > GG> choice, I prefer PDF. > > I prefer dead trees, sewn into signatures and bound into covers. I > _think_ that the licensing on the documentation implies that anyone > can print, bind, and sell copies of the documentation as books. > Looking at some micro-press sites on the web, it looks like I could > sell hardbacks (printed from the LaTeX source) for somewhere between > $20 and $30 and be able to cover my costs (based on printing a run of > 50 to 100 books). > > If people are interested in this, please email me so that I can gauge > whether I can afford to go ahead with this. > > -- > +----------------------------------------------------------------+ > | Jason F. McBrayer jmcbray at carcosa.net | > | The scalloped tatters of the King in Yellow must hide Yhtill | > | forever. R.W. Chambers _The King in Yellow_ | From see at my.signature Sun Oct 29 23:08:30 2000 From: see at my.signature (Greg Ewing) Date: Mon, 30 Oct 2000 17:08:30 +1300 Subject: import x as y References: <6qkpvsgtetij5s9cu4hb40v0jnln63pmvv@4ax.com> Message-ID: <39FCF43E.46D2BAF3@my.signature> Tyler Eaves wrote: > > Just wondering, as a python 'advanced' novice, is there any advantage > of: > import x as y > ratheer than > import x > y=x It avoids spuriously leaving the name x in the namespace. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From tim_one at email.msn.com Mon Oct 30 05:16:21 2000 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 30 Oct 2000 05:16:21 -0500 Subject: C's syntax (was Re: Python Formatted C Converter (PfCC)) In-Reply-To: <8tbv0r01082@news1.newsguy.com> Message-ID: [Grant Griffin] > Just for the record, Backus also played "Mr. McGoo"-- ... [Alex Martelli] > I'll trust you on this. Like many people with even mild physical > disabilities, and like anybody with decent empathy, I have a hard > time understanding what's supposed to be fun in sight-impairment. It's the comedy of misunderstandings. Mr. Magoo enjoyed grand adventures due to acting upon his flawed perceptions of the world (to which everyone with a smidgen of introspection can relate, sight-impaired or not). A better question is why Mr. Magoo prospered as long as it did: his predicaments were so shallow that the cartoons rarely raised so much as a chuckle. a-blow-to-someone-else's-groin-is-a-laff-riot-by-comparison-ly y'rs - tim From skip at mojam.com Tue Oct 31 15:54:16 2000 From: skip at mojam.com (Skip Montanaro) Date: Tue, 31 Oct 2000 14:54:16 -0600 (CST) Subject: Python 2.0 and SOAP In-Reply-To: References: Message-ID: <14847.12664.501029.237391@beluga.mojam.com> Warren> Is anyone working on updating the www.secretlabs.com SOAP Warren> component for Python 1.5 to Python 2.0? Is there a SOAP/XML-RPC Warren> SIG? There's no SOAP/XML-RPC SIG that I'm aware of. Since both protocols are language-independent, it seems to me that it's better to not hide significant discussion in a language-specific mailing list. Here are the discussion forums/mailing lists related to SOAP and/or XML-RPC that I'm aware of: xml-rpc at egroups.com http://www.egroups.com/group/xml-rpc Userland's XML-RPC group http://www.xmlrpc.com/discuss/topics Userland's SOAP group http://soap.weblogs.com/ I'm sure there are more. -- Skip Montanaro (skip at mojam.com) http://www.mojam.com/ http://www.musi-cal.com/ From g_will at cyberus.ca Tue Oct 24 17:16:02 2000 From: g_will at cyberus.ca (Gordon Williams) Date: Tue, 24 Oct 2000 17:16:02 -0400 Subject: [ANN] Creating Py Extensions Using Borland's Free Compiler v3.0 Message-ID: *** Creating Python Extensions Using Borland's Free Compiler V2.0*** I am pleased to announce a set of step-by-step instructions and examples to create extensions using the free Borland Command Line Compiler with the standard Python Windows Binary Distribution. This information can be found at http://www.cyberus.ca/~g_will/pyExtenDL.shtml . Version 3.0 updates the linking library to Python 2.0 and removes an obsolete patch for the Python 1.5.2 config.h file. I have also added a section about using VIDE (http://www.objectcentral.com/), a free and useful IDE for Borland and other compilers. ********************************************************************** ABSTRACT This paper describes the method used to create Python Extensions using the Borland 5.5 C++ Compiler (BCC). This command line compiler is available free from http://www.borland.com/bcppbuilder/freecompiler/. I describe the steps that are necessary to produce the extension from the C source code and how to set up the associated files for the compiler and linker. These extensions work with the standard Windows Distribution of Python. The process used to produce the extension is very easy and consists of running a simple batch file that I provide as part of this package. A section is provided on how to create extensions using VIDE to make it even easier. I also have some examples and a short reference section at the end of this paper that may be helpful. Gordon Williams g_will at cyberus.ca From akuchlin at mems-exchange.org Thu Oct 19 16:01:40 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 19 Oct 2000 16:01:40 -0400 Subject: jpython and DCOracle ? References: <8snfr7$8uo@slip.net> Message-ID: <3ditqo61nf.fsf@kronos.cnri.reston.va.us> Bill Scherer writes: > DCOracle is C extension to Python, which means it works only with > CPython. > To access Oracle from JPython, you'll probably have to use JDBC. If portability between CPython and JPython (argh... make that Jython) is important to you, zxJDBC emulates the Python DB-API on top of JDBC. If it isn't, then you can just code using the JDBC interfaces. --amk From aleaxit at yahoo.com Tue Oct 24 14:42:19 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 24 Oct 2000 20:42:19 +0200 Subject: C's syntax References: <8t0or303ee@news1.newsguy.com> <8t1964$v8a$1@news7.svr.pol.co.uk> <17WI5.58198$oN2.2362868@news20.bellglobal.com> <39F45B51.320AA63F@alcyone.com> <8t1nr90105v@news1.newsguy.com> <39F4FEAF.FA466927@alcyone.com> <8t3nt4027fk@news2.newsguy.com> <8t4gv3$81f$1@newsg3.svr.pol.co.uk> Message-ID: <8t4q8s01lpv@news1.newsguy.com> "Makhno" wrote in message news:8t4gv3$81f$1 at newsg3.svr.pol.co.uk... > >But, as I said, you just can't turn the warning level up all > >the way (to /W4) with Visual C++, if you have any system > >headers -- you'll get swamped with warnings about constructs > >being non-portable (of course system headers DO include many > >non-portable constructs...!-). The default /W3 is pretty > >strict... but it does NOT warn of "if(a=0)". > > And this implementation is C's fault? No. But the desperate need for warnings to ameliorate some of the ill-effects of its tortured syntax, oh yes, it most definitely _is_ one of C's weaknesses. > It's not even C, it's *Microsoft* C. A bastard hybrid child. C89 compliant, as far as I've been able to determine. Of course, the ISO standard says nothing about what is in the "system headers", since those are totally outside its purview (you cannot write any application with a GUI that is based solely on the ISO standard, etc, etc). Alex From hans.kristian.ruud at inenco.no Fri Oct 6 14:15:17 2000 From: hans.kristian.ruud at inenco.no (Hans Kristian Ruud) Date: Fri, 06 Oct 2000 18:15:17 GMT Subject: Fibonacci Sequence and Long numbers. References: Message-ID: <39DE153D.420D7BBE@inenco.no> Huaiyu Zhu wrote: > On Thu, 05 Oct 2000 15:35:43 -0700, Neil Macneale > wrote: > > > >>>> cache = [] > >>>> cache.insert(0, 0L) > >>>> cache.insert(1, 1L) > >>>> def fib(i): > >... if len(cache) > i: > >... return cache[i] > >... cache.insert(i, fib(i-1) + fib(i-2)) > >... return cache[i] > >... > > > >All seems good and well to this point. But when I try: > > > >>>> fib(1000) > > > >I get a whole bunch of recursive erros which tell me there is an Integer > >addition error. > > Are you seeing RuntimeError: Maximum recursion depth exceeded? > > If so, this is because fib is calling fib recursively. When you call fib(n) > there are n-len(cache) open function calls before they are fulfilled one by > one. On my Linux, fib(len(cache)+997) works, but fib(len(cache)+998) fails. > An alternative solution would be to use the following properties of Fibonacchi numbers: with F(1) = 1, F(2) = 1, F(3) = 2, ... we have: F(2n+1) = F(n)*F(n) + F(n+1)*F(n+1) F(2n) = F(n-1)*F(n) + F(n)*F(n+1) This will reduce the recursion depth from N to O( log_2(N) ) >>> cache = {} >>> cache[0] = 0L >>> cache[1] = 1L >>> cache[2] = 1L >>> def fib(i): if cache.has_key(i): return cache[i] else: if i%2: f1 = fib( (i-1)/2 ) f2 = fib( (i+1)/2 ) return f1*f1+f2*f2 else: f0 = fib(i/2-1) f1 = fib(i/2) f2 = fib(i/2+1) return f0*f1+f1*f2 >>> fib(5) 5L >>> fib(12) 144L >>> fib(24) 46368L >>> fib(10000) 33644764876431783266621612005107543310302148460680063906564769974680081442166662 36815559551363373402558206533268083615937373479048386526826304089246305643188735 45443695598274916066020998841839338646527313000888302692356736131351175792974378 54413752130520504347701602264758318906527890855154366159582987279682987510631200 57542878345321551510387081829896979161312785626503319548714021428753269818796204 69360978799003509623022910263681314931952756302278376284415403605844025721143349 61180023091208287046088923962328835461505776583271252546093591128203925285393434 62090424524892940390170623388899108584106518317336043747073790855263176432573399 37128719375877468974799263058370657428301616374089691784263786242128352581128205 16370298089332099905707920064367426202389783111470054074998459250360633560933883 83192338678305613643535189213327973290813373264265263398976392272340788292817795 35805709936910491754708089318410561463223382174656373212482263830921032977016480 54726243842374862411453093812206564914032751086643394517512161526545361333111314 04243685480510676584349352383695965342807176877532834823434555736671973139274627 36291082106792807847180353291311767789246590899386354593278945237776744061922403 37638674004021330343297496902028328145933418826817683893072003634795623117103101 29195316979460763273758925353077255237594378843450406771555577905645044301664011 94625809722167297586150269684431469520346149322911059706762432685159928347098912 84706740862008587135016260312071903172086094081298321581077282076353186624611278 24553720853236530577595643007251774431505153960090516860322034916322264088524885 24331580515348496224348482993809050704834824493274537326245677558790891871908036 62058009594743150052402532709746995318770724376825907419939632265984147498193609 28522394503970716544315642132815768890805878318340491743455627052022356484649519 61124602683139709750693826487066132645076650746115126775227486215986425307112984 41182622661057163515069260029861704945425047491378115154139941550671256271197133 252763631939606902895650288268608362241082050562430701794976171121233066073310059947366875L >>> ;-) > Huaiyu -- Hans Kristian From aleaxit at yahoo.com Sun Oct 8 06:17:57 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 8 Oct 2000 12:17:57 +0200 Subject: Is this a dream or a nightmare? (Was Re: XML) References: <39d1d3b2.43465571@news.telus.net> <39D19EBB.ABF18F23@engcorp.com> <39def2ae.8929692@news.davesworld.net> <8ro52a0q1o@news1.newsguy.com> <39dfa617.25953118@news.davesworld.net> Message-ID: <8rphoj229t3@news1.newsguy.com> "David T. Grove" wrote in message news:39dfa617.25953118 at news.davesworld.net... [snip] > >> > a good average for comparison is 1 line of perl for every 25 lines of C, > >> > TclTk, Python, or Visual Basic, and every 100 lines of C++. > > > >Such an assertion can only come from a mind that's totally out of > >synch with reality. 400% *more* lines of code for C++ than for > > OOP over a procedural language has more lines, no matter how you look C++ isn't "OOP over a procedural language". It's a multi-paradigm language, with procedural, object, and generic programming, all supported quite reasonably, and melding rather synergically. C is _just_ procedural -- period. Anything else, you have to build up from scratch, or do without -- and you don't get fundamental language tools to help you build, or help you use what you build. Just std::string and std::vector, by themselves, are A LOT of excellent infrastructure code, enough to slash development time (and resulting SLOC) by *a lot*; and std::map is not far behind. > >C?! That's even crazier than the 2500%-more assertion for Python [snip] > Granted, python is very close to Perl in these respects, but it's > still more verbose. Yes, but *NOT* by _anywhere_ like TWENTYFIVE TIMES, which is what your "lumping" brought you to ludicrously claim. > die unless @d = map {"$basedir/$_"} grep {!-d && -w} readdir(dir); > > ...which is perfectly logical and readable to me as a single > "thought"... "get me all the filenames in that directory or halt > immediately because you'll screw something up". Single thoughts don't Even for such an extreme case, idiomatic Python, while less concise, is of course nothing like TWENTYFIVE TIMES more. E.g.: entries = [ os.path.join(basedir,file) for file in os.listdir(basedir) ] allfiles = [ f for f in entries if os.access(f,os.W_OK) and os.path.isfile(f) ] if not allfiles: raise ValueError, "no writable plainfiles in directory" A ratio of about 2 to 4 (for "worst-case"/"extreme" examples) is indeed quite a defensible hypothesis. That's a *far sight* from TWENTYFIVE, in case you had not noticed. > Without the newbies, you can't match it with any python that I'm aware Assignment not being acceptable within an expression, I do believe you need two statements, not one, to set something AND raise an exception if the value you've just set is empty. Computing the "allfiles" value in one Python statement is of course trivial (you do not HAVE to name the intermediate 'entries' value -- you can just use the list comprehension expression for it, embedded inside the one for allfiles); but in Python's normal approach, such super-concision takes a second seat to clarity. If the idiom "set this, but raise exception if empty" is common in your code, say it happens 10 times in one script, then you will of course have towards the start of it a single function definition such as: def nonempty(value, exception=ValueError, msg="empty list!"): if not value: raise exception, msg return value and you will amortize these three lines over several uses such as: resultlist=nonempty([x for x in f if foo(x)], msg="no good x!") thus taking the "irreducible ratio" (amortized) from about 2 to, say, about 1.3 (and the "typical idiomatic ratio", similarly amortized, from about 3 to about 2.3). Again: nothing like 25! > of. But then, I was also comparing VB and C in there, and I challenge > anyone to do that in less than 25 lines of C or VB (1 line = 1 > semicolon per line, no cheating) I don't particularly care about either C or VB. In standard C++, you have no built-in way to take a directory listing, nor to test if a given file is a directory or a plain-file (functionalities not in the standard library). Assuming you've #include'd suitable headers supplying such functionality, I predict about 12 lines for a good, typical, idiomatic implementation -- std::copy_if to build up a std::vector of those files that satisfy the condition, a few lines to objectify that condition, the test-if-empty-then-raise-exception, plus declarations, braces &c. > >vs Perl. If this quote is correct, then the site must clearly be one > >devoted to silly humour. > > Bah. Be nice and pay attention. You just totally zapped the entire > meaning of this thread. I'm not python-bashing... quite the opposite > if you'd take time to read up a little in the thread. I don't particularly care, in this context, whether your purpose is to bash Python or to praise it. I do care that the absurd numbers you spewed, about SLOC ratios between languages, don't go unchallenged -- wouldn't want some poor innocent readers to believe there's anything defensible about them! Alex From mballen at NOSPAM_erols.com Sat Oct 7 15:43:03 2000 From: mballen at NOSPAM_erols.com (Michael B. Allen) Date: Sat, 7 Oct 2000 15:43:03 -0400 Subject: best way to store dbm records? Message-ID: <8rnu4o$emc$1@bob.news.rcn.net> Hi! I was wondering what the best/simplest way to store dbm records is? This is how I am currently adding records: # create dbm record p = '102' s = getfield(msg, 'from') a = getfield(msg, 'authors') v = getfield(msg, 'version') d = getfield(msg, 'description') x = getfield(msg, 'fixes') o = getfield(msg, 'obsoletes') r = getfield(msg, 'requires') f = getfield(msg, 'flags') dbmrecord = (a,v,d,x,o,r,f) db[p] = `dbmrecord` This is what the dbm record looks like as a string(with the key '102' before it): 102 ('', 'ds-0.1', 'Would you like to send a Broadcast Email Advertisement to\012 1,000,000 PEOPLE DAILY (30,000,000 People a Month) for FREE?', '', '', '', '') [don't worry, I'm not sending bulk e-mail. I'm just processing e-mail and happen to have plenty of junk to test it with] Then, to get a record out I eval it like this: dbmrecord = eval(db[key]) (a,v,d,x,o,r,f) = dbmrecord Will this work reliably or is there a better way? Thanks, Mike From cherokee30114 at my-deja.com Thu Oct 19 10:19:26 2000 From: cherokee30114 at my-deja.com (cherokee30114 at my-deja.com) Date: Thu, 19 Oct 2000 14:19:26 GMT Subject: SWIG compatability with Python 2.0 final? Message-ID: <8smvt5$nh$1@nnrp1.deja.com> Does anyone have a comment on the compatability of SWIG with the Python 2.0 final release? The documentation on SWIG's web site seems a little dated and I am about to undertake a massive project integrating Python into my companies C++ engine. (I can't wait to see management's faces) Best Regards! Mike Sent via Deja.com http://www.deja.com/ Before you buy. From quinn at seniti.ugcs.caltech.edu Sun Oct 1 20:32:58 2000 From: quinn at seniti.ugcs.caltech.edu (Quinn Dunkan) Date: 2 Oct 2000 00:32:58 GMT Subject: New Python development process (SourceForge considered Harmful?) References: <8qss6t$7i$1@saltmine.radix.net> <8erA5.37729$dZ2.13446193@news3.rdc1.on.home.com> Message-ID: On 01 Oct 2000 10:32:18 -0400, Alex wrote: > >> No, I can't. I believe there is a delay based on the way that pages >> appear: the ad appears quickly, then there is a considerable delay >> before the rest of the content is sent. This is common technique on >> the internet. >> >> On the other hand, if you've looked at the source, and the delay isn't >> there, then I'm wrong and I retract my comments. > >Banner ads are usually served from a completely unrelated machine >administered by the company brokering the ad space, aren't they? I >would have expected those machines to work faster than the ones serving >up the sourceforge content proper. I often see banner ads first because I use netscape, which doesn't incrementally display tables. Some people like to put their whole page in one giant table, with the banner ad included at the top outside of the table. So the result is that the ad (or rather the "unloaded image" box :) pops up immediately while the rest of the page is only displayed after it is completely done loading. From spahievi at vega.bg Sun Oct 29 12:42:48 2000 From: spahievi at vega.bg (Niki Spahiev) Date: Sun, 29 Oct 2000 19:42:48 +0200 Subject: DLL-building griefs In-Reply-To: References: Message-ID: <7112704194.20001029194248@vega.bg> 29.10.2000, 15:08:07, Will Ware wrote: WW> I'm trying to build a DLL (previously using Cygwin, now using Mingw) WW> for a Python module. My batch file looks like this: WW> gcc -Ic:\Python20\Include -c foo.c echo EXPORTS >> foo.def WW> nm foo.o | grep " T _" | sed "s/.* T _//" >> foo.def WW> dllwrap --def foo.def --base-file foo.base --output-exp foo.exp \ WW> --dllname foo.dll foo.o WW> During the execution of dllwrap.exe, I get complaints that various WW> functions are undefined: PyArg_ParseTuple, Py_BuildValue, and WW> Py_InitModule4. As a result, the DLL never gets built. WW> My experience with Unix while building .so files has been that the WW> linker is willing to assume that these references would be resolved WW> when the .so file was invoked by, say, being imported by Python. WW> Is it possible for references to remain unresolved during the build WW> process in Windows, or is this a fatal flaw in everything Windows-ish? These are in pythonXX.dll so you should include puthonXX.lib for linker to be happy. -- Best regards, Niki Spahiev From maalokam at my-deja.com Wed Oct 11 19:49:14 2000 From: maalokam at my-deja.com (maalokam at my-deja.com) Date: Wed, 11 Oct 2000 23:49:14 GMT Subject: Newbie - EOF question Message-ID: <8s2u9p$767$1@nnrp1.deja.com> Hi, I just started programming in python and the following piece of code gives me an EOFError. Was wondering if someone could help ? Thanks in advance, Maalokam --- CODE --- f = open("tmpfile") x = cPickle.load(f) while x: print x x = cPickle.load(f) --- ERROR LOG --- Traceback (innermost last): File "./test.py", line 16, in ? Main() File "./test.py", line 14, in Main x = cPickle.load(f1) EOFError Sent via Deja.com http://www.deja.com/ Before you buy. From nospam at nospam.com Wed Oct 18 22:36:58 2000 From: nospam at nospam.com (Tom) Date: Thu, 19 Oct 2000 02:36:58 GMT Subject: kjbuckets Win32 binaries for Python 2.0 References: <39EDB29E.F7309137@ibm.net> Message-ID: What's kjbucket? Point me to the source & I'll compile it for you. Tom. "Laurent Szyster" wrote in message news:39EDB29E.F7309137 at ibm.net... > Dear All, > > Has anyone built kjbucket Win32 binaries for Python 2.0? > > I'm mainly working with Debian GNU/Linux and I don't have Visual C++. > > Thanks, > > > Laurent Szyster From frohne at gci.net Thu Oct 5 21:47:22 2000 From: frohne at gci.net (Ivan Frohne) Date: Thu, 5 Oct 2000 17:47:22 -0800 Subject: JPython Status References: <8rfqga$9sd$1@nnrp1.deja.com> <8rhsrj$i8j$4@newsserver.rrzn.uni-hannover.de> Message-ID: "Bernhard Reiter" wrote in message > > (Ivan Frohne): But CPython is not really open source, either. > > This is not true. > Python qualifies as open source and free software. > Java implementations from Sun do not. And Sun has a firm grip > legal on the java specs. I'll be the first to admit that my understanding of the term "open source" is fuzzy and imprecise, but I do know what I like. Software that is free, easy, universal and stable. Visual C, gcc, Cygwin et al don't score as well as Java on those criteria with Windows users IMO. > > (Ivan Frohne): Guido is free to screw every one up. > > He has less handles. He cannot withdraw the current Cpython > implementation for being free software. I don't need legal assurances that Guido won't ever take Python back. Likewise, I just don't think Java is ever going to cost me anything, or become system-specific, unstable or hard-to-use. --Ivan Frohne From tim_one at email.msn.com Wed Oct 11 23:22:39 2000 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 11 Oct 2000 23:22:39 -0400 Subject: Python Guru Available For Contract Work In-Reply-To: <39e516c3.13120104@news.telus.net> Message-ID: [revtracyj at my-deja.com, quoting a Mr. Jarvis] > My last IQ test came in at 161, although I have tested as low as 145. [David] > My penis is 10.5" long. Beat that! Easily. My penis has an IQ of 183, although it has tested as high as 220 in the Spring. It is particularly fond of long walks by the seashore, and rubbing up against the works of Schopenhauer. comp.lang.python-is-one-class-act-ly y'rs - tim From claird at starbase.neosoft.com Mon Oct 9 05:32:41 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 9 Oct 2000 04:32:41 -0500 Subject: Python and GUI in soft real-time systems? References: <8rqmnp$ild$1@nnrp1.deja.com> <1n5E5.786$YU1.80422@newsc.telia.net> Message-ID: <10EAEA0B25ACACAE.ADFAEA8568266537.DC96A93978EBFED6@lp.airnews.net> In article <1n5E5.786$YU1.80422 at newsc.telia.net>, Fredrik Lundh wrote: >mdeaver wrote: >> So, is Python - it's interpreter and one of the >> available GUIs - worth considering for this type >> of application? > >Definitely. What you're describing isn't too far from stuff >we've been doing (industrial image processing/production >systems based on Tkinter), and performance shouldn't be >much of a problem. > >Contact me directly if you want more details. > > > Fredrik's right. Well, he essentially always is, but perhaps you don't know that yet. In any case, concern about an interpreted GUI binding is largely misplaced, although many people share it with you. Tkinter is the slowest of the Python GUI bindings for most common uses, and yet, as Fredrik writes, it absolutely is able to handle the kinds of requirements you describe (five windows open simultan- eously, events every few seconds, modest animation, sub-second response, ...). You're going to like your Python-based GUI career. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From aa8vb at yahoo.com Thu Oct 26 09:22:26 2000 From: aa8vb at yahoo.com (Randall Hopper) Date: Thu, 26 Oct 2000 09:22:26 -0400 Subject: python-mode in xemacs -- font-locking and auto-indentation b0rken In-Reply-To: ; from jmcbray@carcosa.net on Wed, Oct 25, 2000 at 05:13:11PM -0400 References: <14839.30557.697461.468137@anthem.concentric.net> Message-ID: <20001026092226.A248303@vislab.epa.gov> Jason F. McBrayer: |I'm in the process of moving from GNU Emacs to XEmacs. Python-mode |worked perfectly in GNU Emacs for font-locking and automatic |indentation. It doesn't in XEmacs -- it seems to have a really hard |time telling where strings end. I think it is confused by multiline |("triple quoted") strings. Does anyone have any suggestions or |contrary experience? Python mode works well for me in GNU Emacs (with fontification and auto-indent). Thanks Barry. However, I have noticed (in GNU Emacs) what you describe with Python-mode getting syntax-confused sometimes -- in particular with nested quoting characters. See attached. Perhaps this is your problem? If not, send a fragment that hoses fontification. -- Randall Hopper aa8vb at yahoo.com -------------- next part -------------- #!/usr/bin/env python """ This is a comment I want to use "double" quotes in. Note that `double' is not highlighted as a comment. """ def NoBigProblem__FontificationIsStillFine(): pass """ Now we use a quote somewhere in the "comment which isnt matched by a closing quote... """ def Oops_FontificationIsHosed(): pass """ This space for rent """ def Yep__StillHosed(): pass From jim.vickroy at noaa.gov Wed Oct 4 11:14:07 2000 From: jim.vickroy at noaa.gov (j vickroy) Date: Wed, 04 Oct 2000 09:14:07 -0600 Subject: 4-byte string to integer Message-ID: <39DB493F.A7AA3E40@noaa.gov> How can a 4-byte string be converted to an unsigned integer using Python? The byte order may be either big or little endian. Thnaks From gerrit at NOSPAM.nl.linux.org Sun Oct 22 16:05:04 2000 From: gerrit at NOSPAM.nl.linux.org (Gerrit Holl) Date: 22 Oct 2000 20:05:04 GMT Subject: very newbie questions References: <20000930161649.06131.00000281@ng-fy1.aol.com> Message-ID: On 30 Sep 2000 20:16:49 GMT, AquaRock7 wrote: > How do you write an exponent sign in python (ie how do u write 16 x 16 in > exponential form?) 16 ** 16 > WHat does the '%' operation do? >>> divmod(7,3) (2, 1) >>> 7/3 2 >>> 7%3 1 It calculates the rest. > One more thing... How do you turn a string into numerical data to do math on >>> int('2') + int('3') 5 > (I have to use the raw_input() command, b/c they enter a # in hexadecimal) then > turn the numerical data back into a string? > > Please reply to > dustin at getzfamily.inbox.as > > Thanks! > Dustin -- **************************************************************************** * Save Mother Earth! -- Earth First! -- visit http://www.earthfirst.org/! **************************************************************************** From db3l at fitlinxx.com Mon Oct 2 21:53:37 2000 From: db3l at fitlinxx.com (David Bolen) Date: 02 Oct 2000 21:53:37 -0400 Subject: Runtime error importing extension modules References: <8r9mda$9gs$1@nnrp1.deja.com> Message-ID: lss at excosoft.se writes: > I have a problem with PYDs in an application using Python as an > embedded scripting language. In this case, the application and Python > are statically linked together into a single executable. To get this to > work, I had to remove definitions of USE_DL_EXPORT and USE_DL_IMPORT > and other DLL-related preprocessor macros. Now, however, each attempt > to import a PYD results in a runtime error. Does anyone have any > pointers on how I may link Python together statically with a C++ > application and yet retain the the ability to import dynamic extension > modules? Is USE_DL_IMPORT or USE_DL_EXPORT necessary for this, and if > so, how can I have them without compromising the ability to link Python > statically? I'm not sure you'll be able to mix the two. The dynamic extensions are specifically linked against the dynamic Python core, so if you try to import them the extension is going to find it is talking to an uninitialized core, since its your static version that is actually performing the import. This is actually the same problem state that is being seen if you import a Python 1.5.2 extension under a Python 1.6/2.0 script under Windows, for example. So you either need to make your program use the DLL version of Python (is there a specific reason you can't do this?), or you need to rebuild the extensions and link them into your application statically as well (this is similar to the freeze process). I suppose you could experiment with having your application not only link Python statically for its own purpose, but also initialize a dynamically linked interpreter for use with the imports, but I don't know if that could prove workable. You'd still be unable to execute scripts that tried to cross the boundary. Not sure what sorts of naming collisions you might run into in that case as well. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From jari.seppala at iki.fi Mon Oct 23 15:58:59 2000 From: jari.seppala at iki.fi (jari.seppala at iki.fi) Date: Mon, 23 Oct 2000 19:58:59 GMT Subject: Newbie question: Replace line in file? Message-ID: <8t259u$hud$1@nnrp1.deja.com> How to replace line: Content-Type: text/plain; format=flowed with Content-Type: text/plain; charset=iso-8859-1 in one message file and also in all files in one directory? Any help appreciated. Jari Sent via Deja.com http://www.deja.com/ Before you buy. From mtebeka at iil.intel.com Thu Oct 12 05:22:16 2000 From: mtebeka at iil.intel.com (Miki Tebeka) Date: Thu, 12 Oct 2000 12:22:16 +0300 Subject: conditional print Message-ID: Hello All, Is there something like the following in the regular python libraries/languge? class DBPrompt: """Prompt message according to debug level""" def __init__(self, trashhold = 0): self._trashhold = trashhold def trashhold(self): return self._trashhold def set_trashhold(self, trashhold): self._trashhold = trashhold def prompt(self, msg, level = 0): if (level >= self._trashhold): print msg Bye. ------------------------------------------------------------------------------ Smile, damn it, smile. lambda msg: { 'name' : 'Miki Tebeka', 'email' : 'tebeka at lycosmail.com', 'homepage' : 'www.tebeka.freeservers.com', 'quote' : "I don't suffer from insanity, I enjoy every minute of it." }[msg] From borcis at geneva-link.ch Sat Oct 28 18:45:09 2000 From: borcis at geneva-link.ch (Boris Borcic) Date: Sun, 29 Oct 2000 00:45:09 +0200 Subject: PythonWin IDE ! References: <7tuivs46osods22uumpvsvsap2jocrd4si@4ax.com> <39FB5D09.B2D6F987@mjs400.co.uk> Message-ID: <39FB56F5.1764D1BB@geneva-link.ch> Peter Moore wrote: > > "Fix it > yourself or be more polite" comments made to drivers probably didn't > help Ferrari win the constructors championship this year. Were your email adress not in uk I would have put the above on the count of US election year, and exclaimed on its soon being over . BB From aleaxit at yahoo.com Thu Oct 19 05:49:29 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 19 Oct 2000 11:49:29 +0200 Subject: about floating number References: <8sm7qa$1711$1@reader.ccu.edu.tw> Message-ID: <8smgdg01grm@news1.newsguy.com> "Graduate" wrote in message news:8sm7qa$1711$1 at reader.ccu.edu.tw... > when I in python 2.0, I try to use floating number, > but I have a proplem like this... > >>> a = 2.8 > >>> a > 2.7999999999999998 > > why? or I forget some step?? Notice the following: >>> a=2.8 >>> a 2.7999999999999998 >>> print a 2.8 >>> str(a) '2.8' >>> repr(a) '2.7999999999999998' >>> See the difference? repr(a) strives to give all digits it possibly can -- and that is what gets used when you just enter a at the interactive interpreter prompt. str(a) is not so eager, and is more oriented towards a 'readable' output than a complete one -- and that is what gets used when you use the print statement. Python, like almost all modern computer environments, uses *binary* representation for numbers. There is no exact, finite representation in base two for the fraction 28/10 (14/5) because 5 is not a power of 2 (just like, say, there is no exact, finite representation in base 10 for the fraction 1/3, because 3 is not a power of 10). Not all fractional numbers with exact, finite representation in base 10 have exact, finite representation in base 2 (since 10 has a prime factor, 5, which 2 lacks). This often confuses beginners, because most computer tools may accept base-10 input but really store their data in base-2 (or, equivalently, a base that's a power of 2). For most uses, this is OK -- just remember to use print (or str(), or the %-operator) and not repr. If you really need decimal (base-10) numbers, I think there are some modules you can get them from (but for financial arithmetic it's normally better to do the arithmetic in integer terms, in the smaller unit -- e.g., integer arithmetic in cents rather than fractional arithmetic in dollars; Python's "long" integers offer "unlimited" precision, though no fractional part). Alex From aleaxit at yahoo.com Fri Oct 13 17:51:26 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 13 Oct 2000 23:51:26 +0200 Subject: reference to objects References: Message-ID: <8s80cs014na@news1.newsguy.com> "Johannes Zellner" wrote in message news:slrn8uessj.4r4.johannes at kristine.zellner.org... > Hello, > > what happens in python if I assing an object to different > variables ? Each variable (and/or other 'slot' -- "cell" in a list, key or entry in a dict, etc) will then refer to the same object. > class Lola: > def __init__(x): > x.y = 0 > > l = Lola() > g = l # <-- !! > > now, does g.y = 1 modify l.y ? > (do both variables refer to the same object ? Yes, and yes. If you want a COPY of the object, rather than a reference to the same object, you can ask for it explicitly: import copy g = copy.copy(l) NOW, g.y=1 does not modify l.y -- the variables are in fact now referring to different, separate objects (that start out as copies of each other). (You can also use copy.deepcopy if you want to make absolutely sure that the _sub-parts_ of the object are also copied, but this is rarely needed). You can also check...: if g is l: print "same!" else: print "distinct", if g == l: print "but equal" else: print "and different" Another way you can check...: if id(g)==id(l): print "same identity!" else: print "distinct identities" Alex From remove.me.wwicker at spectratechnologies.com Wed Oct 4 13:39:36 2000 From: remove.me.wwicker at spectratechnologies.com (William Wicker) Date: Wed, 04 Oct 2000 12:39:36 -0500 Subject: Problem with using PythonWin and ActiveX COM Object References: <8rfdjo0apr@news2.newsguy.com> Message-ID: On Wed, 4 Oct 2000 16:02:27 +0200, "Alex Martelli" wrote: >"Jeremy Howard" wrote in message >news:stkikpeusp7057 at corp.supernews.com... >> I've asked this before but never really got an answer. I'm working for a >> company that is using Siebel CRM software. This software comes with COM >> objects for accessing their system from external applications. Below is >the > >I don't know the details of their interfaces, but I'll give it a >try based on what you post... > > >It looks, specifically, as if iErr is passed by-reference; i.e., a >_reference_ to iErr is given to the LoadObjects method, which places >an error-code there (a strange thing to do in COM, although allowed; >normally, COM returns errors quite differently -- this looks like a >partial translation of some older C API...?). > I am working with a different package, but just enough of the COM interface includes functions with an interface like this (return values stuck in parameters passed by reference) to be really (REALLY) frustrating. > >Python's COM interface is no doubt passing iError by value (it always >does: no pass-by-reference in Python!) and I think this is what the >Siebel object is diagnosing as a type-error. > I though *everything* in Python was by-reference? >Try calling LoadObjects with just one argument, the path to the file; >it should then *RETURN* the iError value as its *RESULT*. I.e., >change the offending line to > > iError = objSiebel.LoadObject(r'c:\siebel\bin\psblprd.cfg') > I've tried this in my application, and get complaints about missing arguments. >(I'm using the r'' syntax to avoid having to double up the backslashes, >but that's another, purely-syntactic-sugar issue!). > >This is how Python's COM support handles by-reference, output values: it >transforms them into results. You may have to run makepy on the type >library of interest, and maybe use EnsureDispatch or equivalent to make >sure the genpy-supplied wrappers are used rather than purely dynamic >dispatching (it's a rather advisable thing anyway, in general), but I >think you might be able to get away without that. > I haven't tried then genpy interface. That might work. William. From effbot at telia.com Sat Oct 21 09:42:23 2000 From: effbot at telia.com (Fredrik Lundh) Date: Sat, 21 Oct 2000 13:42:23 GMT Subject: Crypt XOR or any other cipher ! References: <8ss58s$3oh$1@nnrp1.deja.com> Message-ID: <33hI5.2004$QH2.170568@newsb.telia.net> Sindh wrote: > Whereis XOR in python anyway! look under "X" in the fine manual: http://www.python.org/doc/current/ref/genindex.html#letter-x From tim at scheer.com Mon Oct 2 15:06:55 2000 From: tim at scheer.com (tim at scheer.com) Date: Mon, 02 Oct 2000 19:06:55 GMT Subject: PythonCOM and Unicode Message-ID: <8ramc8$37o$1@nnrp1.deja.com> I am having a problem with passing a unicode string to the Python COM extension. I am testing with Python 2.0b2 and Pythonwin ver 134. I pass in a unicode string that contains chinese characters from a file. When I call a sample COM object (which I created to simply accept strings) the COM layer returns with an error. Below is attached a interactive session demonstrating the error. The problem seems to me that the COM layer is attempting to convert the unicode string even though it is already being passed as a unicode string. Python Session: Python 2.0b2 (#6, Sep 26 2000, 14:59:21) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. IDLE 0.6 -- press F1 for help >>> import unicodedata >>> import codecs >>> import os >>> os.chdir('c:\\testunicode') >>> ufile = codecs.open('123.u8', 'rb', 'utf-8') >>> ufile >>> ustring = ufile.read() >>> ustring u'123 = \u4E00\u4E8C\u4E09\015\012' >>> type(ustring) >>> # test sending output in utf-8 >>> y = ustring.encode('utf-8') >>> y '123 = \344\270\200\344\272\214\344\270\211\015\012' >>> type(y) >>> # Test sending to COM object >>> from win32com.client import Dispatch >>> ctest = Dispatch('BeXcom.TestUnicode') >>> ctest.read(ustring) Traceback (innermost last): File "", line 1, in ? ctest.read(ustring) File "", line 2, in read com_error: (-2147352567, 'Exception occurred.', (0, 'Python COM Server Internal Error', 'Unexpected Python Error: exceptions.UnicodeError: ASCII encoding error: ordinal not in range(128)', None, 0, - 2147467259), None) >>> # It cannot read a direct unicode string (using extended characters) >>> # test 2: unicode string with no extended characters >>> ustring2 = u"This is a test" >>> type(ustring2) >>> ctest.read(ustring2) >>> # worked ok! >>> # test 3: send string in utf-8 format >>> utf8 = ustring.encode('utf-8') >>> utf8 '123 = \344\270\200\344\272\214\344\270\211\015\012' >>> ctest.read(utf8) Traceback (innermost last): File "", line 1, in ? ctest.read(utf8) File "", line 2, in read com_error: (-2147352567, 'Exception occurred.', (0, 'Python COM Server Internal Error', 'Unexpected Python Error: exceptions.UnicodeError: ASCII encoding error: ordinal not in range(128)', None, 0, - 2147467259), None) >>> Tim Sent via Deja.com http://www.deja.com/ Before you buy. From wynand at mindspring.co.za Sun Oct 22 13:07:56 2000 From: wynand at mindspring.co.za (Wynand van Dyk) Date: Sun, 22 Oct 2000 19:07:56 +0200 Subject: Slice Notation? References: <39F2CF69.372971ED@mindspring.co.za> <8sudfc0abg@news1.newsguy.com> Message-ID: <39F31EEC.9DA35970@mindspring.co.za> Thanks to both Alex Martelli and Fredrik Lundh, now that I know _why_ I would want to use them and _what_ they do, the tutorial is a lot clearer. Thanks guys Wynand van Dyk From jay.krell at cornell.edu Tue Oct 10 17:37:09 2000 From: jay.krell at cornell.edu (jay.krell at cornell.edu) Date: Tue, 10 Oct 2000 14:37:09 -0700 Subject: List of running processes Message-ID: <021101c03302$3f741fe0$0101a8c0@jayk3> You could write it.. a) for Unix wrap ps -u 0 in something b) for Windows see http://home.netcom.com/~jaykrell/jps.c for a good start c) For Mac, VMS, ...? - Jay -----Original Message----- From: Gilles Lenfant Newsgroups: comp.lang.python To: python-list at python.org Date: Tuesday, October 10, 2000 3:21 AM Subject: List of running processes >Hi, > >Does any of U know how to get a list of the running processes (something >like "ps -u 0") that has an identical interface under Unix and Windows. >I did not find anything for this in the "os" package! >Any hint welcome. > >Gilles Lenfant > > >-- >http://www.python.org/mailman/listinfo/python-list From skodela at hotmail.com Mon Oct 9 08:05:39 2000 From: skodela at hotmail.com (Sreekant Kodela) Date: Mon, 09 Oct 2000 13:05:39 +0100 Subject: Distributing Python Message-ID: <39E1B493.A0EC8F3@hotmail.com> Hi folks I was wondering if there is a url which will explain various ways of packaging a python / PMW / Tkinter application as a single executable for windows. Any relevant info would do. Thanks a lot Sreekant From rcameszREMOVETHIS at dds.removethistoo.nl Thu Oct 26 21:18:42 2000 From: rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) Date: Fri, 27 Oct 2000 01:18:42 GMT Subject: DESPERATE FOR NEWS ON STARSHIP OUTAGE References: <8t1rb9$8hn$1@nnrp1.deja.com> <4tKJ5.68526$oN2.2731135@news20.bellglobal.com> Message-ID: <8FDA20DE2rcamesz@127.0.0.1> Olivier Dagenais wrote: >> We are in serious trouble, but we got enough help, >> so please don't send money - praying and keeping fingers >> crossed will help. > >DON'T send money???? Good lord - it's ANTIspam! If that message ever _touches_ any spam the explosion probably will take out all comp.lang.* groups. Please be more careful in future. Robert Amesz -- Sorry, couldn't resist. From breiter at usf.Uni-Osnabrueck.DE Tue Oct 10 13:34:29 2000 From: breiter at usf.Uni-Osnabrueck.DE (Bernhard Reiter) Date: 10 Oct 2000 17:34:29 GMT Subject: New Python development process (SourceForge considered Harmful?) References: <8qss6t$7i$1@saltmine.radix.net> <8rhsgu$i8j$3@newsserver.rrzn.uni-hannover.de> Message-ID: <8rvjv5$q15$1@newsserver.rrzn.uni-hannover.de> In article , "J?rgen A. Erhard" writes: > The problem with SourceForge is that there's no alternative. > Or can anyone point to an equally *open* service? It depends. You can get development accounts on different locations. Including cvs and webpages and mailinglists. And I think we should work towards making this a general attitue to host free software projects at companies, university, agencies and so on. > And it's open to all comers... there were/are various sites that give > out CVS and web space... but even if they're known, it's rarely very > well known that you can get access, and even if, it still feels like > begging ("Hi Tom/Dick/Harry, I have this cool project and I'd really > like to have some CVS and it would be great to... uhm, uhhh,...") I am not sure if I acually regard a bigger formal step as better. Convince somebody that your project is good and worth the effort. I know completly useless projects on sourceforge. Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) From lg at rgz.ru Fri Oct 27 08:53:52 2000 From: lg at rgz.ru (lg at rgz.ru) Date: 27 Oct 2000 16:43:52 +0350 Subject: bsddb buffer overflow Message-ID: <39f97888@news.edunet.ru> It seems to be bsddb.keys() function of bsddb module is buffer overflowable. on FreeBSD 4.0-RELEASE i've got [16:38][lg at ns][/]# python [p6] Python 2.0 (#8, Oct 18 2000, 16:49:14) [GCC 2.95.2 19991024 (release)] on freebsd4 Type "copyright", "credits" or "license" for more information. >>> import bsddb >>> a = bsddb.hashopen('some.db', 'c', 0664) >>> a.keys() zsh: bus error (core dumped) python [16:39][lg at ns][/]# [p6] -- zev From loewis at informatik.hu-berlin.de Tue Oct 3 10:47:42 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 03 Oct 2000 16:47:42 +0200 Subject: omniORBpy / IDL mapping question... References: Message-ID: kragen at dnaco.net (Kragen Sitaker) writes: > Someone posted a nice computed-attribute system in Python here a couple > of weeks ago, using __getattr__ and __setattr__. Someone should point > Paul at it next time he complains. The problem with __setattr__ and __getattr__ is that it does not mix well with inheritance. I.e. there is no simple way to inherit from a class that implements __setattr__, and implement __setattr__ yourself as well. Regards, Martin From sandj.williams at gte.net Sat Oct 28 00:01:34 2000 From: sandj.williams at gte.net (Steve Williams) Date: Sat, 28 Oct 2000 04:01:34 GMT Subject: Python/C++ Engineers Wanted References: <8tchu7$2gd$1@nnrp1.deja.com> Message-ID: <39FA5040.625CB8E2@gte.net> steveamyers at my-deja.com wrote: > Keep reading if any of the following interest > you: Linux, Beowulf, Apache, Zope, Python, C++, > Macy's, the Gap, JC Penney, Solaris, Boston. > > Our Company: > TSI develops custom mathematical optimization > models to help major retailers determine > merchandise markdown strategies that maximize > gross profit. [snip] Sounds like a perfect application for fuzzy logic. From donn at u.washington.edu Fri Oct 6 18:39:40 2000 From: donn at u.washington.edu (Donn Cave) Date: 6 Oct 2000 22:39:40 GMT Subject: Help a newbie use Python's OS module: References: <39DE4685.4C3EB1E9@pacbell.net> Message-ID: <8rlkbc$a7b0$1@nntp6.u.washington.edu> Quoth Kevin O'Gorman : | I can use os.fork() to create a child process, but I cannot | get messages from the child to the parent through the pipe | I've created. | | If anyone's got a little sample program that shows how this | is done, I'd sure appreciate it. | | At the moment, my (non-working) version complains that the | parent's attemts to read the pipe are failing. It looks | like this: | | | #! /usr/bin/python | # $Id: fork.py,v 1.2 2000/10/06 04:17:32 kevin Exp kevin $ | | import string | import sys | import re | import os | | print "Running $Id: fork.py,v 1.2 2000/10/06 04:17:32 kevin Exp kevin $" | | osi=sys.stdin | oso=sys.stdout | ose=sys.stderr | | rw=os.pipe() | r=rw[0] | w=rw[1] | print "Reading on",r,", and writing on",w | child=os.fork() | if child==0: | sys.stderr.write("In child\n") | os.close(1) | os.dup(w) | sys.stdout=os.fdopen(1,"w") | os.close(r) | os.close(w) | | sys.stderr.write("Writing\n") | print "foo" | print "bar" | print "foobuar" | sys.stdout.close() | sys.exit(0) | | os.close(0) | os.dup(r) | sys.stdin=os.fdopen(r) ## <----- | os.close(r) | os.close(w) | | print "Stdin is ",sys.stdin | print "about to read" | lin=sys.stdin.readline() | if not lin: | print "Read failed",lin | sys.exit(1) | while lin: | print lin | | lin=sys.stdin.readline() I think you will recognize the nature of the problem right away. Try sys.stdin = os.fdopen(0), in the parent. I find dup2() easier to use than dup(). I rarely use file objects in this kind of thing, because of their buffering. In this example I don't see any problems with either of those, though. Donn Cave, donn at u.washington.edu From quinn at hork.ugcs.caltech.edu Sat Oct 7 14:23:15 2000 From: quinn at hork.ugcs.caltech.edu (Quinn Dunkan) Date: 7 Oct 2000 18:23:15 GMT Subject: join() References: <8rjj82$dnb$1@nnrp1.deja.com> <39DD9A9A.7130@hvision.nl> <8rlrdr$6ed$1@nnrp1.deja.com> Message-ID: On Sat, 07 Oct 2000 01:36:19 GMT, Huaiyu Zhu wrote: >What is really needed is an abstraction mechanism, so that we can define the >abstract form AFTER the special forms. This way, somebody someday may say: >Hey, I need a writable file here, and I can use any of open(name,"w") kind >of objects, or sys.stdout, or MyOutStream, or any other object with a write >method - and he promptly defines WritableFile, and specifies these cases. A bit OT, but: Sounds like supertyping, which you can do in sather. I.e., you can not only say which classes your class subtypes from, but also specify its supertypes in the same place. It's really intended as a hack to support the situation when subtyping would be the proper solution, but you're using a library you don't want to modify. But sather also tries to be type-safe, and any type-checking extension to python will have to recognize that if people really wanted complete type-safety they'd be better off with another language :) BTW, sather also makes a distinction between subtyping and code inclusion. You can only subtype from an abstract class (with just a signature, no actual code). You can include code from anywhere, but it's mostly just a textual inclusion (not quite like from blah import *). This is different again from haskell, in which classes and types are seperated (a class is a collection of types). A function can say it wants a type in a certain class, and at any time you can make any type you want into an instance of that class by defining the class's signature for your type. The python approach to interfaces is: def f(fp): # declare that f() expects an object with a 'write' method if not hasattr(fp, 'write'): raise Attribute, 'write' ... except that the interpreter will do this for you :) Ok, ok, so it doesn't express more abstract things about the object, but python programmers seem to be basically down-to-earth guys :) From matt at mondoinfo.com Thu Oct 26 17:16:56 2000 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Thu, 26 Oct 2000 21:16:56 GMT Subject: Loading a module by expanding a string variable? References: Message-ID: On 26 Oct 2000 23:07:24 +0200, Joakim Hove wrote: >I have written two modules Mod1 and Mod2, and then I want load either >Mod1 or Mod2 - depending on the value of a string variable. Joakim, One way to do what you want is to read the appropriate module into a string and then use Fredrik Lund's technique for importing a module from a string. It's at: http://www.deja.com/getdoc.xp?AN=621152936 Regards, Matt From g2 at seebelow.org Wed Oct 4 16:56:29 2000 From: g2 at seebelow.org (Grant Griffin) Date: Wed, 04 Oct 2000 21:56:29 +0100 Subject: setting pythonpath on Windows NT Message-ID: <39DB997D.959281FD@seebelow.org> Hi Gang, I've been trying to set my PYTHONPATH on Windows NT for my installation of 2.0. Basically, I just want to add a certain directory to my PYTHONPATH. After a fair amount of head-banging, I'm ready to ask you folks for a little help: 1. I added the directory on to the PYTHONPATH variable using NT's Registry Editor. However, it then didn't show up in the sys.path list. I restarted the computer, just in case that was an issue, but it _still_ didn't show up. The sys.path list matched the Registry's original PYTHONPATH, so the Registry entry seems to be the source of it. But that leaves me stumped as to what basis Python discriminates against my addition. 2. Next, I tried adding a ".pth" file inside the Python 2.0 installation. That worked in terms of the sys.path list, and I also could import a module from the new directory. However, I wasn't able to _execute_ a file in that directory on the command line, from another directory. That is, I couldn't do "python Module" or "python Module.py". Should I be able to, or is the PYTHONPATH just not intended for command-line pathing? 3. Does anybody know the format of the ".pth" file for listing multiple directories? The 2.0 doc left an explanation of that as something to be added later. also, 4. Is there any way to _permanently_ set the PYTHONPATH programatically from within Python? (Maybe I could append sys.path, but is that only temporary?) if-_all_-of-python-were-this-hard-to-deal-with,-i'd-still-be-using -perl--ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From stadt at cs.utwente.nl Sun Oct 22 21:26:13 2000 From: stadt at cs.utwente.nl (Richard van de Stadt) Date: Mon, 23 Oct 2000 02:26:13 +0100 Subject: All permutations of a list References: <39F1FB22.6E9246E7@cs.utwente.nl> Message-ID: <39F393B5.A978CC9D@cs.utwente.nl> Rainer Deyke wrote: > > "Richard van de Stadt" wrote in message > news:39F1FB22.6E9246E7 at cs.utwente.nl... > > Then a collegue of mine impressed me with a recursive program > > in the functional language Miranda/Amanda: > > > > ins a [] = [[a]] > > ins a (x:xs) = (a:x:xs) : map (x:) (ins a xs) > > > > perms [] = [[]] > > perms (x:xs) = concat (map (ins x) (perms xs)) [...] > def ins(a, list): > return [list[:i] + [a] + list[i:] for i in range(len(list) + 1)] After having seen this, my colleague came up with this two-line solution, a version that doesn't need an ins-part: perms [] = [[]] perms xs = concat [ map (x:) (perms (xs--[x])) | x <- xs ] How would that be in Python? I guess it's about time I start downloading v2.0. Anyway, this guy's now also interested in Python :-) Richard. From shwang5 at students.uiuc.edu Sun Oct 22 13:01:05 2000 From: shwang5 at students.uiuc.edu (seung-won hwang) Date: Sun, 22 Oct 2000 12:01:05 -0500 Subject: mmap? Message-ID: Hello, I am wondering if there is any mmap-like functionality in Python. Or is there any other way to flush data structure on the memory to the file and load from the file later? I would appreciate your answers very much! From pinard at iro.umontreal.ca Mon Oct 9 20:01:47 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 09 Oct 2000 20:01:47 -0400 Subject: join() In-Reply-To: Thomas Wouters's message of "Mon, 9 Oct 2000 23:32:23 +0200" References: <8rjj82$dnb$1@nnrp1.deja.com> <39E1286F.D27A1034@my.signature> <20001009233223.P12812@xs4all.nl> Message-ID: [Thomas Wouters] > On Mon, Oct 09, 2000 at 03:07:43PM +1300, Greg Ewing wrote: > > echuck at mindspring.com wrote: > > > In Python 2.0, I was surprised to see join() had become a method of > > > string. I "naturally" expected it to be a method of list. > > Quite a lot of people screamed blue murder about this at the time, > > and were ignored. Getting it changed now seems to be impossible. > Now now, that's not very nice. I'm certain I saw a lot of responses to > the threads about "".join() that tried to explain the choice. Behind each choice, good or bad, there is an explanation. :-( > I can imagine that some postings were 'ignored', given the sheer volume, > but it's not like *all* complaints were ignored. Explaining a choice does not make it good, and responding with an explanation, without otherwise listening, is still a way to "ignore" those who cannot bear that choice. I like Python a great deal so, short of a better reason, I only guess that some thought that adding a bit of intrinsic ugliness would make it more widespread and wi[l]dely popular! :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From etsang at my-deja.com Tue Oct 31 14:16:26 2000 From: etsang at my-deja.com (etsang at my-deja.com) Date: Tue, 31 Oct 2000 19:16:26 GMT Subject: function with a lot of parameters --maintainability issue Message-ID: <8tn5q1$7mn$1@nnrp1.deja.com> Hi all, I have several functions that takes in more than 255 parameters and cause Python to complain about com_addbyte error out of range. We are using Python 1.5.2 and have to take that versiona t the moment. I think one way to get around that is as follows: Since a lot of your functions are like: def func(sid,a,b,c,d,e,f, ..... more than 255 parameters): setVariable(sid,.....,a); setVariable(sid,.....,b); ..... setVariable(sid,.....,z); ...... sendPrim(sid,"somePrim .."); we can break the function into several functions: def func1(sid,a,b,c,d,e): setVariable(sid,.....,a); setVariable(sid,.....,b); .... setVariable(sid,.....,d); setVariable(sid,.....,e); def func2(sid,f,g,h,i,....): setVariable(sid,.....,f); setVariable(sid,.....,g); .... def func3(sid,......): setVariable(sid, ....); sendPrim(sid,........); Note that setVariable and sendPrim are just other user defined functions. Then just call these three functions in order of func1,func2,func3. That is in places that call func, that following is replaced func1, func2, func3. There are quite a lot of places that call func. So this may generate maintainability issue, as we need to keep track of three functions instead of one. So can anyone suggest a better solution at the moment? Sent via Deja.com http://www.deja.com/ Before you buy. From ge at nowhere.none Mon Oct 9 10:39:32 2000 From: ge at nowhere.none (Grant Edwards) Date: Mon, 09 Oct 2000 14:39:32 GMT Subject: doubling slashes in a string References: <39de8a48_3@corp.newsfeeds.com> Message-ID: In article <39de8a48_3 at corp.newsfeeds.com>, Joshua Muskovitz wrote: >Man, I just have to say, I *love* python. I was struggling with the problem >of how to take a pathname and double all of the backslashes in it, so that >(for example): > >c:\foo\bar\zingo.walla.walla --> c:\\foo\\bar\\zingo.walla.walla I find it much easier to use forward slashes. -- Grant Edwards grante Yow! ... I have read the at INSTRUCTIONS... visi.com From paralizer at my-deja.com Wed Oct 18 05:09:03 2000 From: paralizer at my-deja.com (paralizer at my-deja.com) Date: Wed, 18 Oct 2000 09:09:03 GMT Subject: Overloaded Constructor References: <8sjj0v$7mb$1@nnrp1.deja.com> <39ed5438.86008483@news.eunet.no> Message-ID: <8sjpbe$cro$1@nnrp1.deja.com> Thank you... In article <39ed5438.86008483 at news.eunet.no>, thomas at cintra.no (Thomas Weholt) wrote: > As far as I can see, Python doesn't support this. You'll have to just > have to something like this: > > class myClass: > def __init__(self,any_var1 = None,any_var2 = None): > if any_var1 != None and any_var2 != None: > dosomething_with_any_varx() > else: > dosomething() > > Or something ... the feature would be nice to have though. Used it in > Java alot, but I think we would have seen it in Python allready if the > model Python is built on allowed it ( but I have nothing to back this > up !! ) > > Thomas > > On Wed, 18 Oct 2000 07:21:06 GMT, paralizer at my-deja.com wrote: > > >How can I use overloaded constructor in Python? > >Such as > > > >class myClass: > > def __init__(self): > > dosomething() > > def __init__(self,any_var1,any_var2): > > dosomething_with_any_varx() > > > >and when i use > > > > d = myClass # means i use the first constructor > > e = myClass(yyy,zzz) # means i use the second one > > > >any suggestion? > > > > > >Sent via Deja.com http://www.deja.com/ > >Before you buy. > > Sent via Deja.com http://www.deja.com/ Before you buy. From keisari_ at hotmail.com Wed Oct 18 12:36:21 2000 From: keisari_ at hotmail.com (joonas) Date: Wed, 18 Oct 2000 19:36:21 +0300 Subject: Integer -> String Message-ID: <39EDD184.B97C3A39@hotmail.com> How can i convert integer into srtring and string into integer. Joonas. From neilh at scintilla.org Wed Oct 11 19:18:31 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Wed, 11 Oct 2000 23:18:31 GMT Subject: [ANNOUNCE] cCopy 0.2 References: <7xK$7KA$p145Ewoi@jessikat.fsnet.co.uk> Message-ID: Robin Becker: > In article , Alex > writes > ... > >You should judge more by your web server logs than the response here. > >My own experience suggests there are a lot of shy people lurking > >here. (Well, I would count as one of them, in your case. :) > > > >Alex. > > > If my crappy, about to go broke ISP, allowed such things I would check. > I am monetarily constrained so use the cheapest available option. SourceForge is about as cheap as possible and provides information on the number of times packages have been downloaded. The biggest problem with moving to SourceForge is that the upload process is a bit complex requiring ftp to copy the file to SourceForge and then interacting with some web pages to park it correctly. Neil From djhughex at my-deja.com Wed Oct 11 15:56:46 2000 From: djhughex at my-deja.com (David Hughes) Date: Wed, 11 Oct 2000 19:56:46 GMT Subject: Redhat 7.0, python 2.0b2 and tcl-8.3.1-46 problem ... References: <8rt2la$1rq$1@news.uit.no> Message-ID: <8s2glp$rej$1@nnrp1.deja.com> I had a similar problem installing scotty, it was looking for libtcl8.0.so but all I had was /usr/lib/libtcl8.3.so, all I did was symlink the 8.3 to 8.0 and it worked fine i.e. ln -s /usr/lib/libtcl8.3.so /usr/lib/libtcl8.0.so HTH In article <8rt2la$1rq$1 at news.uit.no>, "Arild Hansen" wrote: > Hello, > > I try to install python 2.0b2 on a Redhat 7.0 distribution. When I installed > Redhat 7.0 I selected everything related to the Development sections > (packages). When trying to install Python 2.0b2 everything works fine. When > trying to install expat-1.1-1.i386.rpm everything works fine, BUT when I try > to install Tkinter-2.0-8.0.1.i386.rpm I get the following errors: > > error: failes dependenies: > > libtcl8.0.so is needed by Tkinter-2.0-8.0.1 > > libtk8.0.so is needed by Tkinter-2.0-8.0.1 > > So I install Tcl/Tk version 8.0.5 (tcl-8.0.5-35.i385.rpm) but then I get > several conflicts with the already installed (i.e. installed under the > installation of Redhat 7.0) tcl package being version tcl-8.3.1-46. In other > words, my system contains a new version of tcl that is not compatible / > recognized by python 2.0 beta 2 and when I try to install an older version > of tcl I am not allowd (yes, I know I can try rpm -U --force but this > conflicts with other packages depending on the new version of tcl). So, how > do I get python 2.0 beta 2 to work with tcl-8.3.1-46 ? Thx for all help, > > Arild Hansen > > -- David Hughes, System Administrator, Highwired.com. Sent via Deja.com http://www.deja.com/ Before you buy. From robin at jessikat.fsnet.co.uk Fri Oct 20 03:48:42 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 20 Oct 2000 08:48:42 +0100 Subject: SF corpsed? References: <39EF22E7.4C058D08@ajubasolutions.com> <39EFC5E2.86A0E0C9@ajubasolutions.com> Message-ID: In article <39EFC5E2.86A0E0C9 at ajubasolutions.com>, Jeffrey Hobbs writes ... >login as in ssh? That works for me, as does cvs: > >pop [~/cvs/tkcon] 5 % tkconcvs up >hobbs at cvs.sourceforge.net's password: >cvs server: Updating . >cvs server: Updating docs >cvs server: Updating extra > >(tkconcvs is just an alias to get the right cvs tree). It looks >like you may have a cvsroot problem. Checking their support manager >entries for recent entries: >http://sourceforge.net/support/?func=browse&group_id=1&set=open&offset=50 > >I see that there are numerous similar problems already noted. Perhaps >anyone doing cvs activity during some burp in the system got hosed. >I'd submit a support request for your project as well. > I always used ssh for sf, but that won't help with cvs locks as far as I can tell as the only people who can remove the #locks are sf people. It's all come back now so it was some kind of global problem. Makes you wonder if the one strategy is non-robust argument may not be true after all. -- Robin Becker From erno-news at erno.iki.fi Thu Oct 26 21:24:12 2000 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 27 Oct 2000 04:24:12 +0300 Subject: Is global really global. References: Message-ID: global is really only module-global, not global-global. -- erno From mmueller at dgfz.de Wed Oct 25 10:51:35 2000 From: mmueller at dgfz.de (Mike Müller) Date: Wed, 25 Oct 2000 16:51:35 +0200 Subject: DLL in Python References: <8t1e4p$gok@micky.ibh-dd.de> <8t290k0hjb@news2.newsguy.com> <8t35kk$1j8@micky.ibh-dd.de> <8t3ep701srg@news2.newsguy.com> <8t45h8$6h0@micky.ibh-dd.de> <8t49r402u24@news2.newsguy.com> Message-ID: <8t6rl6$m8v@micky.ibh-dd.de> Alex Martelli wrote: >Ooops, you also need a line of > >#include > Actually I looked for the missing *.h but could not find the right file in long list under \include. Now my dll works. I had to add extern "C" because I used the .cpp extention (trying to switch to .c it seems to have problems compiling the content of Python.h and gave a bunch of errors). I tested the dll with the help of windll and also wrote a short C++ programm that called the dll. Everything is ok. Now I just have resolve the FORTRAN-C problem of exchanging int. Defining integer(4) or integer(2) in FORTRAN does not seem be the same as in C, at least the addition of 22 and 33 does not return 55 (as it does with windll and the C++ program) but -28,996 for interger(2) or 8,949,436 for integer(4). Have to ask the guy who is charge with the FORTRAN program to solve this one when he is back. Thanks for your help. BTW, what would be the best reference for VC++. There are lot out there but which one would you recommend? Thanks a lot. Mike From echuck at mindspring.com Mon Oct 2 20:13:15 2000 From: echuck at mindspring.com (echuck at mindspring.com) Date: Tue, 03 Oct 2000 00:13:15 GMT Subject: Number of Python Users Message-ID: <8rb8an$jfl$1@nnrp1.deja.com> Is there any kind of estimate on the number of Python users? Or even related numbers, like # of downloads of 1.5.2? -Chuck Sent via Deja.com http://www.deja.com/ Before you buy. From olivierS.dagenaisP at canadaA.comM Fri Oct 27 11:55:15 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Fri, 27 Oct 2000 15:55:15 GMT Subject: PythonWin IDE sucks! References: <7tuivs46osods22uumpvsvsap2jocrd4si@4ax.com> <8tc42n$lm3$1@nnrp1.deja.com> Message-ID: > > What can I do about it? > Learn the language, and if you do not like the PythonWin tool, use > another. It's not too hard to tweak PythonWin. I've made a few modifications to get it to be more to my liking and yes, it sort of sucks to not be able to use the debugger, but I find other ways to hunt down problems in my code. -- ---------------------------------------------------------------------- Olivier A. Dagenais - Software Architect and Developer "Someone called 'Type your name here' is impersonating me on the internet and is posting exactly the same things I am posting!" From duncan at rcp.co.uk Mon Oct 9 04:39:40 2000 From: duncan at rcp.co.uk (Duncan Booth) Date: 9 Oct 2000 08:39:40 GMT Subject: Zope tag nesting madness! References: <8rrt4i$f05$1@nnrp1.deja.com> Message-ID: <8FC86DD8Bduncanrcpcouk@194.238.50.13> noahspurrier at my-deja.com wrote in <8rrt4i$f05$1 at nnrp1.deja.com>: >Hello, > >How do I nest tags inside of tags? You will probably get more comprehensive answers if you ask on the Zope mailing list. > >In general I want to pass an to a ZSQL Method, >but must be an INTEGER. This syntax will not work: > )"> >The manager editor will compain about this and will not even let me >submit this change. The expression in double quote marks is simply a Python expression with slightly funny name lookup rules. Python knows nothing about dtml. Simply refer to the variable by its name and all will be well: >The problem here is that I have to pass id as an INTEGER. Since id probably has a string value, try this: > >Here is one way, but this only works if I'm calling my >DTML Method from a form then this syntax works: > > >But I would rather figure out how to do this in the general case. >Do I always have the REQUEST dictionary? Can I add a value to it >just to hack my way out of this syntax problem? As I said above the name lookup is a bit funny. When you refer to a variable Zope searches a lot of possible namespaces in order. Variables created by dtml-let come first, then objects and their properties (which is where 'id' will be matched). The last place to be searched is the REQUEST object, and that in turn searches sub objects such as REQUEST.form. So if you refer to a variable called id, it will pick up the value from the id property of the current object, but REQUEST['id'] will pick up the id variable from the REQUEST.form object. If you want to set a variable temporarily then use to add another variable to REQUEST.form. From aleksei.guzev at bigfoot.com Thu Oct 5 13:01:22 2000 From: aleksei.guzev at bigfoot.com (Aleksei Guzev) Date: Thu, 5 Oct 2000 23:01:22 +0600 Subject: exceptions Message-ID: Why Python has exceptions of the only type? Take CLU. It supports exceptions and signals. The difference is what happens upon completing an exception or a signal handling code. In the latter case the execution returns to the next statement after one wich throwed the signal. For instance one can encounter zeros while dividing by elements of a list: def f(divident): L=[2,3,4,5,0,5,6,0,6,7] for divisor in L: print divident/divisor f(100) Assume I wish to print in that cases, i.e. smth like this: def f(divident): L=[2,4,5,0,5,0,8] for divisor in L: print divident/divisor try: f(100) except ZeroDivision: print should yield: 50 25 20 Division by zero 20 Division by zero 13 Maybe this should be done by another Python operator? P.S. In FoxPro the execution may continue to the next statement after handling block, or it may continue to the next statement to one which throwed the exception, or it may repeat the statement after the handling block. From cfelling at iae.nl Tue Oct 24 14:41:19 2000 From: cfelling at iae.nl (Carel Fellinger) Date: 24 Oct 2000 20:41:19 +0200 Subject: fileinput module doesn't work to spec? References: <0s8bvs0n0e4d0t462mqlknha2ekj7grm22@4ax.com> Message-ID: <8t4l4f$3qm$1@animus.fel.iae.nl> Dale Strickland-Clark wrote: > According to the spec, the fileinput module should support overwriting the specs are *always* right:), but keep a lot implicit:) > table = [] > for line in fileinput.input(sys.argv[1:], inplace = 1): > table = table + genRow(line) printing in this loop will go to the file currently read > print ''.join(table) printing after the loop will again go to standard output. -- groetjes, carel From dawks at tesco.net Thu Oct 26 19:19:36 2000 From: dawks at tesco.net (phil) Date: Thu, 26 Oct 2000 23:19:36 GMT Subject: Python IDEs and eXtreme Programming References: <8t6umj$qma$1@clematis.singnet.com.sg> Message-ID: <39f8b9b5.14873436@news.tesco.net> On 25 Oct 2000 15:36:51 GMT, ngps at madcap.dyndns.org (Ng Pheng Siong) wrote: >Hi, > >For my next programming job I intend to do extreme programming >with about 6-10 programmers; might bring in an XP coach to head >the team. (Commercial thing, obviously.) > >I expect to use Python. > >Personally, I program with vim on both Un*x and Win32. I'm just >thinking about the so-called IDEs for Python: IDLE, PythonWorks, >um, them's all I know about. ;-) > >I wonder if these facilitate or inhibit XP, such as pair programming >and ContinuousIntegration. > >I am expecting to find Java code monke^H^H^H^H^Hpeople who have >worked with the usual Windows-type IDEs. I believe I am unlikely >to find up to 10 Python programmers who can do vim and CVS. ;-) > >Any experience, thoughts, etc.? Yes. I hope the monke^H^H^H^H^Hpeople read this post. And no, i'm not a Java code monkey, but i'm sure that you'll find a steaming heap of script kiddies that can manage to hack your product together. What an asshole (unless you're making a joke in which case i apologise). phil. > >Side note: the Smalltalk Refactoring Browser sounds very cool. Is >such a beastie for Python feasible? > >TIA. Cheers. > > >-- >Ng Pheng Siong * http://www.post1.com/home/ngps > From loewis at informatik.hu-berlin.de Sun Oct 1 05:22:22 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 01 Oct 2000 11:22:22 +0200 Subject: Python2.0 beta 2 on MacOSX/Darwin References: Message-ID: Johann Hibschman writes: > Yes, I've been getting this same error. If anyone has any idea how to > get around this, I'd appreciate any information. Python's not doing > me much good if I have to statically link all my extensions I've been studying quite a few mailing lists recently. I don't have MacOS X myself, so I can't really try any of my theories. A. You can suppress undefined symbols. So instead of linking with '-bundle -prebind', try '-bundle -undefined suppress'. This is what Apache 1.3 does to build its extension modules (there is also conflicting information on -prebind - the linker of MacOS X does not seem to like it for bundles). B. An alternative is to link extension modules with the Python bundle. It seems configure.in already has an option --with-next-framework, which generates some files through libtool(1) (whatever that is), and links these files into extension modules. I don't know whether these approaches works, or, if they work both, which is the right one. I'd appreciate if anybody with MacOS X could try, though. Regards, Martin From parkw at better.net Thu Oct 5 16:53:14 2000 From: parkw at better.net (William Park) Date: Thu, 5 Oct 2000 16:53:14 -0400 Subject: Running Python on SMP machine Message-ID: <20001005165314.A12041@better.net> How do I take advantage of a SMP (2 CPU) machine? The speed improvement that I get is what I would expect from 1 CPU machine. Is anyone using Python on SMP machines? ---William Park, Open Geometry Consulting From MarkH at ActiveState.com Mon Oct 30 08:45:03 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Tue, 31 Oct 2000 00:45:03 +1100 Subject: Initial value of sys.path In-Reply-To: <31575A892FF6D1118F5800600846864D5B1371@intrepid> Message-ID: > > I'm sorry, but which part are you still unclear on? Why our foresight > > isn't as good as our hindsight? > Woops - obviously that came across as some kind of criticism. It > *certainly* > wasn't intended as one. Sorry. I'm glad I changed it then - my original was worse ;-) However, I did give you the benefit of the doubt, so no apology required! > I really just wanted to know whether a decision was made at some point not > to have a site directory in Windows installations, or whether it was just > that *no* decision had been made *to* have a site directory. If > the former, > what the reasons were. The latter. I should have phrased my original better. Something like "a conscious decision was made to make no decision regarding Windows at that time" (or something like that ;-) Mark. From ajs at ix.netcom.com Sat Oct 28 09:53:02 2000 From: ajs at ix.netcom.com (Arthur Siegel) Date: Sat, 28 Oct 2000 09:53:02 -0400 Subject: PythonLabs Team Moves to Digital Creations References: <8tdb7b$nm6$1@nnrp1.deja.com> Message-ID: <8tenfd$f1l$1@slb7.atl.mindspring.net> >But DC is a great company and I > think both DC and Python will benefit greatly from this arraingment. I'm in for some shares of this set-up. Just gut, but 'dis one should work nice. ART From skodela at my-deja.com Sat Oct 21 06:13:01 2000 From: skodela at my-deja.com (Sindh) Date: Sat, 21 Oct 2000 10:13:01 GMT Subject: ANNOUNCE: print manager for python win32 applications. Message-ID: <8srq7c$shq$1@nnrp1.deja.com> Hi folks I have just wrote a simple application with Delphi for people like me to use in python win32 applications. It is a text printer. You can get it from http://www.skodela.net and it is called printmgr.zip, printmgr.txt. You can use it with GPL license. Use it in python win32 programs and pass the data as a text file as first and only argument to printmgr.exe which can be freely distributed. Just mention where you got it. Regards sreekant -- A man needs to sleep for 36 hours a day atleast. Sent via Deja.com http://www.deja.com/ Before you buy. From fredrik at effbot.org Sun Oct 29 08:22:37 2000 From: fredrik at effbot.org (Fredrik Lundh) Date: Sun, 29 Oct 2000 13:22:37 GMT Subject: boy, does this thread suck or what? References: <7tuivs46osods22uumpvsvsap2jocrd4si@4ax.com> <39FB5D09.B2D6F987@mjs400.co.uk> <4TTK5.3013$QH2.281633@newsb.telia.net> <39FC2539.FD88DD96@mjs400.co.uk> Message-ID: Peter wrote: > Is Mark receiving a huge amount sponsorship income? do any of your posts have anything to do with anything? I don't understand what you're talking about, or what point you're trying to make here. even if I accept that "a single open source developer" is equivalent to "a massively funded formula one racing team", a "random usenet poster" to "the worlds best driver", and "a free beer at the python conference" to "hundreds of millions of dollars", I still don't get it. does anyone? do you? From jepler.lnk at lnk.ispi.net Mon Oct 30 07:38:48 2000 From: jepler.lnk at lnk.ispi.net (jepler epler) Date: Mon, 30 Oct 2000 12:38:48 GMT Subject: Shall we declare Tkinter dead? No-one seems interested in it ;o) References: Message-ID: All the code below is untested, but I'm familiar with the techniques from pure tcl/tk programming. You can have a piece of code be called when the window-manager "close" function is invoked: blah = Toplevel(...) blah.wm_protocol("delete", func) func might set a global variable, raise an exception, or manipulate a semaphore. You could also use the wait_window method: blah = Toplevel(...) blah.wait_window() wait_window essentially executes the tk mainloop (potentially recursively) until the window is destroyed. Finally, you could use the wait_variable method: blah = Toplevel(...) var = Variable() blah.wait_variable(var) arrange to set var to a new value when the window is closed. Whether these work properly in the presence of "microthreads", I admit I'm unsure. On Sun, 29 Oct 2000 21:42:59 -0500, Mike Fletcher wrote: >Side note: are all the mouse interactions under Tkinter atomic C functions? >For instance, dragging or resizing the window stops all other micro-threads >until the drag/resize stops. This may depend on the platform where you use tk, and when under X11 on the details of your window manager. I use X11 and a window manager called "icewm". When I enable "solid" moves/resizes, a tkinter app is able to respond during the operation. Jeff PS if we had to jettison tkinter in favor of some other gui, I wish that someone would set up gtk+pygtk+glade for me to run on win32. I looked at wxpython once, but it was all greek to me, and I couldn't get it to run under X11 at all, just win32. The point being, I think it's probably largely a religious argument. Tkinter works, and it gets installed by default everywhere, and I'd be the first to admit the pragmatism of "doing in Rome as the Romans do." From x at y.z Thu Oct 19 01:55:59 2000 From: x at y.z (Alexander K) Date: Thu, 19 Oct 2000 07:55:59 +0200 Subject: Threads, again References: Message-ID: <8sm28c$ald$1@merkurius.lu.se> Alex McHale wrote in message news:dzsH5.153671$Qx4.5060109 at news1.rdc1.il.home.com... > This may be a bit of a dumb question - but I, for the life of me, can't > understand why, when using the thread module, start_new_thread will only > pass a tuple of arguments to the function. Can anyone explain this to me? > Does this mean any function I want to thread, has to take 3 arguments? > no. the start_new_thread function can take 3 args, but the func you want to thread can take arbitraryly many. it looks like this, right? start_new_thread (function, args[, kwargs]) function is the name of the to-be-threaded function. args is a tuple (containing the args for your function), and kwargs is optional (havent used it myself:)). so if you want to thread this: >>> my_funk('blabla', 42) you would write this: >>> start_new_thread(my_funk, ('blabla', 42)) the tuple you pass as second argument can be whatever suits your function... (i think:)) / alex k ps. i am a beginner programmer myself, so no guarantees... From daimun at home.com Tue Oct 17 22:54:07 2000 From: daimun at home.com (Alex McHale) Date: Wed, 18 Oct 2000 02:54:07 GMT Subject: importing dynamic files, unimporting Message-ID: Hi there, I was just wondering if there is a way to import a module where the module name is dynamic (basically contained in a string). The idea is that the module will contain specific functions (ie def foobar( arg1, arg2 ) in all such modules). The second part is removing these imports. Is there a way to 'unimport' a module? The python website seems to be very lacking on such topics. Daimun daimun at home.com From root at rainerdeyke.com Wed Oct 25 14:56:35 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 25 Oct 2000 18:56:35 GMT Subject: [Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich , comparison References: <39F6639E.B74867EE@home.com> Message-ID: "Paul Prescod" wrote in message news:mailman.972450070.10196.python-list at python.org... > In either case you are in control. If Guido changes the default to be > float division you can get integer division by wrapping the result in a > floor(). When you are using long integers, the result of floor could be missing significant digits. Floating points should not be part of the core language. The correct way to implement floating points is in terms of integers, preferable within the language (as opposed to a C extension). I can live with rationals, but for performance reasons I want a way to do pure integer division in the language, just like I want to keep non-long integers. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From dalke at acm.org Thu Oct 12 04:01:43 2000 From: dalke at acm.org (Andrew Dalke) Date: Thu, 12 Oct 2000 02:01:43 -0600 Subject: profiling python References: Message-ID: <8s3r36$9bq$1@slb7.atl.mindspring.net> Johannes Zellner wrote in message ... >is there a way to profile python scripts ? http://www.python.org/doc/current/lib/profile.html "The Python Profiler" Andrew dalke at acm.org From aleaxit at yahoo.com Mon Oct 9 18:10:19 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 10 Oct 2000 00:10:19 +0200 Subject: getting full filename under NT Message-ID: <8rtfs90300n@news1.newsguy.com> This seems to work in my setup (2.0b2, Win98): import sys try: raise RuntimeError except: x=sys.exc_info()[2] print x.tb_frame.f_code.co_filename Placing this in alongfilename.py and running python alongfilename.py results in the expected output: alongfilename.py Alex From not_such_a_brain_after_all at mit.edu Tue Oct 31 09:04:48 2000 From: not_such_a_brain_after_all at mit.edu (Alex) Date: 31 Oct 2000 09:04:48 -0500 Subject: Would anyone show me how to use htmllib? References: <8te2ch$8ou$1@nnrp1.deja.com> <8tlj50$u47$1@nnrp1.deja.com> Message-ID: > One question is how did you guys figure those things out? python > reference library are not clear about a lot of the variables and > functions calls. I agree. I figured out how to use it by reading the source of htmllib. It could really use some better documentation. Alex. -- Speak softly but carry a big carrot. From rwklee at home.com Fri Oct 6 11:54:11 2000 From: rwklee at home.com (Rick Lee) Date: Fri, 06 Oct 2000 15:54:11 GMT Subject: Any parser generator available? Message-ID: <39DDF5A2.130F2656@home.com> The Python Library contains a fair number of parsers for specific syntaxes like XML, HTML, URL, etc. However, I am looking for a parser generator that can generate a parser from a grammar description. The Python Parser in the Python Language Services in the Library may have been built from a parser generator, because the documentation refers to a GRAMMAR file in the standard distribution. However, the documentation did not mention a parser generator. The grammar that I like to parse is quite simple, compared to a programming language like Python. My interest for a parser generator is so that I don't have to implement a parser (not that I know how to do it well), and also because the grammar, though simple, will change a lot in its life time (new statements get added). For those who might know, the grammar that I like to have a parser for is a set of TL1 commands. TL1 is a meta-grammar, so to speak, that is fairly commonly used in the telecom industry. Thanks in advance. - Rick Lee rwklee at home.com From kiyolee*remove* at ctimail.com Thu Oct 26 19:57:04 2000 From: kiyolee*remove* at ctimail.com (Kiyo Kelvin Lee) Date: Fri, 27 Oct 2000 10:57:04 +1100 Subject: dynamically loaded modules (.so files) does not work under openbsd References: <39f791a1.1bcb7@nancy.pacific.net.au> <39F835FD.AC39663C@dcs.kcl.ac.uk> Message-ID: <39f8c4f9.17478@nancy.pacific.net.au> You are exactly right. Thanks. Kiyo "Laurence Tratt" wrote in message news:39F835FD.AC39663C at dcs.kcl.ac.uk... > Kiyo Kelvin Lee wrote: > > > Under OpenBSD, I can't make dynamically loaded modules work. > > Python responsed with "ImportError: dynamic modules does not define init > > function (initXYZ)" upon import XYZ. > > You need to change Python/dynload_shlib.c: > > from: sprintf(funcname, "init%.200s", shortname); > to: sprintf(funcname, "_init%.200s", shortname); > > This line is very near the start of the file. > > I've been thinking of submitting this as a patch to the main source, but I > don't know what other platforms need the same change as the comment in > dynload_shlib implies. > > > Laurie From tjreedy at udel.edu Wed Oct 18 00:20:50 2000 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 18 Oct 2000 00:20:50 -0400 Subject: scanf in python...? References: <39ebd839.159714@news> Message-ID: <8sj835$jea$1@news.udel.edu> "Tony Waterman" wrote in message > Does python have any way to mimic scanf ? I just bought Python on > Win32 and I can't find anything in there about it, or on the > python.org html tutorial. Also; how many ways to mimic scanf are > there? xscanf(x, format, pointer1, pointer2, .... pointern) is not directly possible in Python because Python does not have pointers. However, it would be possible to write a scan(string,format) function that would return a tuple of values. Since Python uses C formats for the % operator, it would add a nice symmetry. [IE, scan(format%tuple,format) == tuple]. It might be possible to do this by replacing the %format specifiers by the corresponding re specifiers and using re behind the scenes. Or by using openly available scanf code. Terry J. Reedy From dcalvelo at pharion.univ-lille2.fr Thu Oct 12 13:57:58 2000 From: dcalvelo at pharion.univ-lille2.fr (Calvelo Daniel) Date: 12 Oct 2000 17:57:58 GMT Subject: what is the python equivelant of this? References: <8s4sh9$pgs$1@nnrp1.deja.com> Message-ID: <8s4u36$nh$1@netserv.univ-lille1.fr> jschmitt at vmlabs.com wrote: : typedef struct : { : int field1; : char* field2; : } RECORD; : : RECORD records[] = : { : { 10, "gumby" }, : { 20, "barny" } : /* etc */ : }; Using a Python "list": records = [ (10,"gumby"), (20,"barny") # etc ] : or how about : RECORD* recordarray = malloc( sizeof(RECORD) * 10 ); : memset( recordarray0, sizeof(RECORD) * 10 ); No need for allocation. It is done as the list grows. For instance: records.append( (30,"hwdy") ) If you need to cut back the list, you don't have to care about deallocation: records = records[:2] # take the first two records out If your records are to be retrieved by one of the fields, you might also use this field as keys for a "dictionary": records = { 10:"gumby" , 20:"barny" } >From there, if you wish to have all the field2's: records.values() all the records' field1's: records.keys() and to retrieve a particular field2 knowing its field1: records[20] # returns "gumby" Try to browse the tutorial. Python is fresh air+water+fire coming from C. HTH, DCA -- Daniel Calvelo Aros calvelo at lifl.fr From jurgen.defurne at philips.com Fri Oct 13 09:00:05 2000 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Fri, 13 Oct 2000 15:00:05 +0200 Subject: Perl rules - Python drools Message-ID: <0056900012881514000002L042*@MHS> Perl in vinegar can be drunk (cf. Cleopatra). Jurgen bk at xk7.com@SMTP at python.org on 13/10/2000 12:15:40 Sent by: python-list-admin at python.org To: python-list at python.org@SMTP cc: Subject: Re: Perl rules - Python drools Classification: "Python can be eaten, but Perl can't" Well, surely that means Python is more useful, at least when you're hungry :) trying-very-hard-not-to-rise-to-the-bait-and-failingly- burkhard -- http://www.python.org/mailman/listinfo/python-list From chakie at infa.abo.fi Mon Oct 16 09:17:20 2000 From: chakie at infa.abo.fi (Jan Ekholm) Date: 16 Oct 2000 15:17:20 +0200 Subject: Python in WWW-development? References: <39eab13e_1@newsflash.abo.fi> <39EACDF7.A89FE1FA@infercor.no> Message-ID: <39eaf1d0_1@newsflash.abo.fi> Paul Boddie wrote: : In a persistent fashion of self-promotion (and the promotion of many other good : people ) here's my Web modules page which might help to inform you of the : choices in this area: : http://www.paul.boddie.net/Python/web_modules.html This was exactly what I was looking for. I'll start evaluating the various packaged. Thanks a lot for th help! Chakie -- --------------------+-------------------------------------------------------- Jan 'Chakie' Ekholm | Balrog New Media http://www.balrog.fi/ Linux Inside | I'm the blue screen of death, nobody hears your screams From ghubbar at sandia.gov Tue Oct 17 16:43:27 2000 From: ghubbar at sandia.gov (ghubbar) Date: Tue, 17 Oct 2000 13:43:27 -0700 Subject: Connecting to running win32com Message-ID: <39ECB9EF.D4EDEE5A@sandia.gov> Hi again, I lost track of the thread, so I am starting a new one. Thanks Alex and Mark for your attempts but I am afraid I mistated the problem, confusing Visual C++ problems with COM problems. There is the code that is not working. The server uses wxPython, but I have the same problem with WIN32 GUI code. ==== The server side is: from wxPython.wx import * counter = 0 class MyFrame(wxFrame): def __init__(self, parent, id, title): wxFrame.__init__(self, parent, id, title) self.timer = wxPyTimer(self.OnTimer) self.timer.Start(250) EVT_PAINT(self,self.OnPaint) def OnPaint(self,event): dc = wxPaintDC(self) dc.DrawText("%3d Counts" % counter, 0,0) def OnTimer(self): global counter counter = counter + 1 self.Refresh(1) class MyApp(wxApp): def OnInit(self): self.frame = MyFrame(NULL, -1, "COM Test") self.frame.Show(true) self.frame.SetFocus() self.SetTopWindow(self.frame) return true class MyPythonComServer: _public_methods_ = ["ReturnMessage"] _reg_progid_ = "StatusData.Access" _reg_clsid_ = "{38C739C1-4EC0-11D4-BDFB-005004D78D9D}" print "Creating ComServer" def ReturnMessage(self,arg): global counter # counter = counter+1 s = str(counter) return str(arg) + ":" + str(counter) if __name__ == '__main__': print "Registering COM server..." import win32com.server.register apply(win32com.server.register.RegisterClasses([MyPythonComServer], {"debug":1})) app = MyApp(0) app.MainLoop() === This is the client import pythoncom import win32com.client s = win32com.client.Dispatch("StatusData.Access", clsctx=pythoncom.CLSCTX_LOCAL_SERVER) print s.ReturnMessage("Hello") s=None === The GUI program shows counter increasing all the time, while the WIN32 client always shows counter as 0. As you stated, once the win32com server is started by win32com.client.Dispatch, other starting another one definitely serves up a the same counter. I can see that by uncommenting the counter increment in ReturnMessage. My whole goal here is for a remote program, eventually on a second computer, to be able to access data collected by a long running data acquisition program. Unfortunately, the instance started by running c:\progra~1\python\python serverCode.py is not the instance run by win32com. I can see a choice of creating a second, non-GUI program which the GUI program also communicates with using COM, placing any data there it might want to export. The client on the second machine then communicates with this second, slave, program. This would be acceptable, but seems a little kludgy. Is there any way to do it within a single program? TIA Gary From aleaxit at yahoo.com Tue Oct 24 06:55:21 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 24 Oct 2000 12:55:21 +0200 Subject: event loop problem References: <8t21ei$e5a$1@nnrp1.deja.com> Message-ID: <8t3q4402a3u@news2.newsguy.com> "Geoff Talvola" wrote in message news:mailman.972333065.14276.python-list at python.org... > I know exactly the problem you're talking about -- and I consider it a huge > design flaw in NT that any one application can cause other applications to > hang if it's not processing its message loop. Only if those "other applications" *WANT* to hang; otherwise, they would be using SendMessageTimeout (to guarantee termination by time-out if needed) rather than SendMessage (whose semantics are blocking, without a timeout, like those of many other system calls). Do you consider it "a huge design flaw in Unix that any one application can cause other applications to hang" if it's not serving its end of a socket -- IF, that is, those other applications use blocking syscalls on that socket rather than select-with-timeout, &c...?-) Blame it on the laziness of people using SendMessage with broadcast-destination... I can see no justification for it, ever, except the historical accident that SendMessageTimeout was not available on 16-bit Windows lo those many years ago. Generally, the big culprit is the library DDEML, which WAS written at the time of 16-bit Windows and MS has been yearning to kill -- with all DDE variants -- even since they introduced COM as a vastly superior alternative for inter-application communications; *that* one, internally, uses just such a silly SendMessage -- the bug has been known and documented for many years, and it's never going to get fixed. Solution: eschew DDE. Alternate solution: if you MUST do DDE at all cost, eschew DDEML, doing low-level DDE programming instead, so you can have a timeout on all the messages you send!-). A good FAQ on DDE is at: http://www.angelfire.com/biz/rhaminisys/ddeinfo.html and its author doesn't necessarily agree with me (he likes DDE for many tasks, I detest it heartily:-), but he has good points & good info in there, anyway. > Starting up PythonWin is > another example of something you can't do if any program isn't processing > its messages. Really? I hadn't noticed. This is a bug in PythonWin, from my POW -- it should NOT be doing a broadcast SendMessage without a timeout (be it via DDEML or otherwise). Have you submitted this bug to ActiveState? > But a better solution is to tell win32com to run in free-threading mode, in > which case it doesn't create a hidden window and everything works fine No, but it DOES freely create threads! Remember to protect all access to shared-data if you choose this route. Personally, I think serving the message-loop is simpler. Alex From emile at fenx.com Mon Oct 23 00:13:30 2000 From: emile at fenx.com (Emile van Sebille) Date: Sun, 22 Oct 2000 21:13:30 -0700 Subject: All permutations of a list References: <39F1FB22.6E9246E7@cs.utwente.nl> <39F393B5.A978CC9D@cs.utwente.nl> <9nNI5.110763$g6.50159527@news2.rdc2.tx.home.com> <8t08bb$lnvu5$1@ID-11957.news.cis.dfn.de> Message-ID: <8t0eh5$lm0pu$1@ID-11957.news.cis.dfn.de> never mind ... doesn't-help-that-it-calls-perms-ly y'rs -- Emile van Sebille emile at fenx.com ------------------- "Emile van Sebille" wrote in message news:8t08bb$lnvu5$1 at ID-11957.news.cis.dfn.de... > "Rainer Deyke" wrote in message > news:9nNI5.110763$g6.50159527 at news2.rdc2.tx.home.com... > > > > > > Here's my short Pythonic permutation function: > > > > def perms(list): > > if list == []: > > return [[]] > > return [[list[i]] + p for i in range(len(list))\ > > for p in perms(list[:i] + list[i+1:])] > > > > ... which permutes into... > > def perms3(list): > return not [list] or [[list[i]] + p for i in > range(len(list))\ > for p in perms(list[:i] + list[i+1:])] > > > > -- > > Emile van Sebille > emile at fenx.com > ------------------- > > > From ge at nowhere.none Tue Oct 3 10:23:18 2000 From: ge at nowhere.none (Grant Edwards) Date: Tue, 03 Oct 2000 14:23:18 GMT Subject: how do I listen on a socket without sucking up all the CPU time? References: <39d971f3_1@corp.newsfeeds.com> <39d9df0c_1@corp.newsfeeds.com> Message-ID: In article <39d9df0c_1 at corp.newsfeeds.com>, Joshua Muskovitz wrote: >> Why is the socket set to non-blocking? Why not set it to >> blocking so that the thread blocks until there's data to read? > >This is one of those "um" questions. The answer is "um, well, >the prototype code I was given to start with set it to >non-blocking." > >The only reason I can thing of is that a separate thread needs >to be able to use the same socket to send requests (send and >recv operate on the same socket in different threads), but this >may not be a valid reason either. I _think_ that you can set the thread to blocking, and then the receive thread will sleep when it has nothing to do. The send threads should still be fine, unless they are currently returning EAGAIN or EWOULDBLOCK errors -- in which case the blocking socket will cause the sending threads will block until the send operation can complete. >select.select worked great, but now I've got other problems, >namely figureing out why I'm no longer catching the >KeyboardInterrupt exception I used to be able to catch. Don't know for sure about that one. -- Grant Edwards grante Yow! Let's climb to the at TOP of that MOUNTAIN and visi.com think about STRIP MINING!! From linuxqna at chollian.net Mon Oct 16 23:22:11 2000 From: linuxqna at chollian.net (junwon,Seo) Date: Tue, 17 Oct 2000 12:22:11 +0900 Subject: How can I convert string to utf-7 encoding. Message-ID: <8sgfvu$497$1@news1.kornet.net> Hi... In IMAP protocol, Mailbox names are encoded by utf-7. How can I get the utf-7 encoding string... From michael at stroeder.com Thu Oct 12 06:26:20 2000 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Thu, 12 Oct 2000 12:26:20 +0200 Subject: Python+LDAP+Netscape4 how? References: <971341627.231694@proxy.bos.nl> Message-ID: <39E591CC.5CB4AF8E@stroeder.com> "J?rgen Teunis" wrote: > > I want to configure python to work with a ldap server (netscape 4). python-ldap is a wrapper module around a LDAP C-SDK. Get the latest CVS snapshot of python-ldap (many memory leaks fixed): http://sourceforge.net/cvs/?group_id=2072 Get a copy of OpenLDAP 1.2.11 (not 2.0.x!) from http://www.openldap.org needed for building python-ldap. Note: If you rely on some LDAPv3 features (Netscape Directory Server 4 is a LDAPv3 server) you might get lost since OpenLDAP 1.2.11 libs are LDAPv2. Some things work, others not. Feel free to ask here if you have any detailed questions. And you might wanna check out http://www.web2ldap.de for a more complex programming example... Ciao, Michael. From sdm7g at virginia.edu Thu Oct 12 14:25:44 2000 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Thu, 12 Oct 2000 14:25:44 -0400 (EDT) Subject: [Python-Dev] RE: [Numpy-discussion] RE: Possible bug (was Re: numpy, overflow, inf, ieee, and rich comparison) In-Reply-To: <200010121724.TAA15487@chinon.cnrs-orleans.fr> Message-ID: On Thu, 12 Oct 2000 hinsen at dirac.cnrs-orleans.fr wrote: > > The idea that your calculation should blow up and you should > > check it and resubmit your job sounds just so ancient-20th-century- > > Fortran-JCL-and-punched-cards-technology! > > Long-running jobs are still with us, even there's neither Fortran nor > JCL in them. And for these applications, stopping is better than going > on with nonsense values. On the other hand, as you point out, exceptions > for math errors are a bit of a pain for interactive work. > > So how about making this a run-time option? I'd choose exceptions by > default and Infs and Nans by specifying a command-line option, but > there are certainly others who would prefer it the other way round. > What matters most to me is that the choice is possible somehow. > I agree entirely! Maybe I was being a bit too glib, but I didn't mean to imply that wanting it to halt or throw an exception on errors is wrongheaded. I just wanted to make sure the counter-case to what Paul was saying also got heard: Yes-- underflows or infinities where they aren't expected are usually a sign that something is very wrong somewhere. But in the case where the vector holds independent observations or data points, then usually what it means is that there's something wrong with *that* data point -- miscallibrated or mislabeled -- but no reason not to complete the calculations for all of the other points. Scaling or doing projections for interactive graphics is another case where bad points are often better than throwing an exception. ( And it's a pain to have to remember to lambda wrap all the function calls with some sort of guard when you'ld be happy to get NaNs. ) I also mostly agree with Tim, except that I'm not sure that bad or incomplete ieee support is always better than none at all. ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- "All operating systems want to be unix, All programming languages want to be lisp." From alwagner at tcac.net Wed Oct 4 21:53:12 2000 From: alwagner at tcac.net (Albert Wagner) Date: Wed, 04 Oct 2000 19:53:12 -0600 Subject: Inefficiency of __getattr__ References: Message-ID: <39DBDF08.137B5269@tcac.net> Wasn't this whole static/dynamic thing beat to death here several months ago? If another language does things more to your liking, then use that other language. If NO language does things to your liking, then write one that does. Most on this newgroup are here because for various reasons they like Python. Also most have a diverse background of many languages. This NG has grown by leaps and bounds the last year. We don't need to waste bandwidth rehashing an old, old argument. From sholden at holdenweb.com Fri Oct 27 18:25:32 2000 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 27 Oct 2000 18:25:32 -0400 Subject: Chosing between sys.argv and sys.stdin References: Message-ID: <39FA00DC.B234907E@holdenweb.com> "Syn.Terra" wrote: > > I've got a Python script that I want to be used either with commandline > arguments or using stdin (most likely by piping). My question is, what's > the simplest way to code that sort of conditional? My current script > fragment looks like this: > > import sys > try: > text = sys.argv[1] > except IndexError: > print "usage: ..." > sys.exit() > Obviously, you will get the IndexError if len(sys.argv) < 2 so this is the key condition to code around. > How would I add something that says "use sys.stdin if they don't include > commandline arguments, but if neither is present, print the error > message"? Right now, if it calls sys.stdin.read() and it wasn't piped > into (like calling "spam.py" rather than "cat file | spam.py") it just > sits there until I hit ctrl-d. > Probably what you need is something like the following, which will work for a single file name. You can easily extend it to multiple filenames (left as an exercise to the reader...) if len(sys.argv) < 1: myfile = sys.stdin else: try: myfile = open(sys.argv[1], 'r') except: print "Could not open file", sys.argv[1] sys.exit(-1) > Note: I don't frequent the newsgroup, so if you could send replies to > dream at aevum.net, I'd be greatly appreciative. > > ---- > Syn.Terra > Aevum Industries > http://www.aevum.net Posted and mailed. regards Steve -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ From echuck at mindspring.com Tue Oct 17 07:54:08 2000 From: echuck at mindspring.com (echuck at mindspring.com) Date: Tue, 17 Oct 2000 11:54:08 GMT Subject: Web Development References: <8qloh6$djs$1@nnrp1.deja.com> Message-ID: <8shekv$d9p$1@nnrp1.deja.com> In article <8qloh6$djs$1 at nnrp1.deja.com>, Charles Medcoff wrote: > Hello, > > I'm fairly new to both but I trying to get started with web development > using Python. A web server with CGI capabilities is what I'm shooting > for as a first step. Unfortunately I'm working on Windows NT so > CGIHTTPServer doesn't help me any. I'd appreciate any advice, > references to papers, books, URL?s, etc. that might help me get > started. (I already have an order in for "Internet Programming with > Python" on Amazon. I know that it is out of print, but hopefully they > can find me a copy). I believe I read in the Python 2.0 release notes that CGIHTTPServer now works on Windows. What version of Python are you using? You can get the 2.0 final release here: http://www.pythonlabs.com/products/python2.0/ Also, you can run Apache on Windows (I do). http://httpd.apache.org/ Also, you should check out Webware for Python. It's broken into components so you can bite off as much or as little as you would like. It includes an app server, CGI wrapper, servlets, Python Server Pages, etc. http://webware.sourceforge.net -Chuck Sent via Deja.com http://www.deja.com/ Before you buy. From aleaxit at yahoo.com Wed Oct 18 03:38:08 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 18 Oct 2000 09:38:08 +0200 Subject: String adding. References: <39ECFA3F.26B87754@uoguelph.ca> <39ED099F.1B3DB0F8@cc.gatech.edu> Message-ID: <8sjkbi01cct@news1.newsguy.com> "Stephen Kloder" wrote in message news:39ED099F.1B3DB0F8 at cc.gatech.edu... [snip] > > strName = 'wow' > > '<' + strName + '>' > > > > will give you > > > > but what about: > > > > intName = 3 > > print '<' + intName + '>' > > this gives me some illegal argument type for built-in operation.. > > how would i make it give me <3>???? > > >>> intName=3 > >>> print '<' + `intName` + '>' # (Those are back-ticks, not quotes) > <3> > > BTW `x` is the same as repr(x) Exactly because of this, I would suggest "<%s>" % whatever as a preferable solution to '<' + `whatever` + '>' The %-solution calls str(whatever), rather than repr(whatever), and (at least as I understand things) str() is the one that is supposed to give you a readable-string as opposed to a more detailed 'string representation'. Not important (no difference...) when whatever is an integer, but...: >>> foo=23L >>> '<' + `foo` + '>' '<23L>' >>> '<%s>' % foo '<23>' >>> I think one is more likely to want the 'cleaner' output of the second example, here, rather than the explicit L that repr uses to demark foo as long-integer. Alex From jeff at statusbar.com Sun Oct 22 04:44:28 2000 From: jeff at statusbar.com (Jeff Koftinoff) Date: Sun, 22 Oct 2000 08:44:28 GMT Subject: Python for Mac OS X? References: Message-ID: <39F2ACD1.BEACBCA0@statusbar.com> "Steven D. Majewski" wrote: > > The latest 2.0c1 release of Python will build "out-of-the-box" on > Darwin or OSX with either the Darwin or Apple development tools. > Use: > ./configure --with-dyld --with-suffix=.x > make > > then: > su > ... > make install > > You can get the source from www.pythonlabs.com > > As far as I know, no one has yet built a version with support for > Tkinter, pyGtk, WxWindows or any other GUI code. ( We're working > on that next. ) > > The MacPython build for OS<9 will work in the OS9 environment on > OSX, and will give you both Tkinter and native Mac toolbox support. > ( I haven't done any exhaustive testing -- I just installed it and > ran a couple of scripts to see that it [mostly] worked. ) > Very cool, Python 2.0 works for me on Mac OSX PB... Now, what would be involved in using SWIG or something to make the Cocoa objective-c api available via python? I think it would be much nicer to use python for cocoa apps than java or objective c... jeff koftinoff jeffk @ jdkoftinoff.com From ssthapa at harper.uchicago.edu Tue Oct 17 02:10:29 2000 From: ssthapa at harper.uchicago.edu (Suchandra Thapa) Date: Tue, 17 Oct 2000 06:10:29 GMT Subject: Exception Handling in Python Message-ID: I'm trying to figure out how to catch an exception, do some error handling and then reraising the same exception in python. Right now, I'm doing it using the following code: try: ... except Foo: ... except Bar: ... except Exception, x: ... raise x else: ... which seems to work but I wanted to know if there are any problems with this method or if there is a better way to do it. The only potential problem I know of right now is that user defined exception not derived from Exception will slip through but is that much of a problem? -- ------------------------------------------------------------------ | Suchandra Thapa | "There are only two kinds of math books. s-thapaNO at SPAMuchicago.edu | Those you cannot read beyond the first | sentence, and those you cannot read | beyond the first page." | -C.N. Yang ------------------------------------------------------------------ From glenfant at equod.com.nospam Thu Oct 19 14:28:04 2000 From: glenfant at equod.com.nospam (Gilles Lenfant) Date: Thu, 19 Oct 2000 20:28:04 +0200 Subject: How to: py --> pyc References: <8snc7l$hsl$1@newsreaderm1.core.theplanet.net> Message-ID: <8sneac$6tn$1@reader1.imaginet.fr> RTFM !! :) When importing a module like "import amodule", the amodule.py file is compiled into amodule.pyc if needed (based on the date of both files). This speeds up python. Try a complex python app (let's say IDLE) start delay. Delete all .pyc files from the IDLE directory and run it again. You'll see the startup speed difference. ALL scripts compile the imported modules into .pyc. "Franz GEIGER" a ?crit dans le message news: 8snc7l$hsl$1 at newsreaderm1.core.theplanet.net... > I have some scripts which "convert" into pyc files and some which don't. Why > do some scripts compile and some do not? > > I use Python 1.5.2 on an NT box (4.0SP4). > > Thans in advance and > best regards > > Franz Geiger > > > From tdelaney at avaya.com Sun Oct 29 23:50:56 2000 From: tdelaney at avaya.com (Delaney, Timothy) Date: Mon, 30 Oct 2000 15:50:56 +1100 Subject: CPython vs. Jython/JPython Message-ID: There are a number of things against this suggestion (note - I'm not dismissing it out of hand). 1. Need for a Java Virtual Machine. The CPython interpreter is *much* smaller than the JVM, both in install size and resource usage. The disparity is even greater when using Stackless CPython. 2. Speed. The CPython interpreter is much faster than J(P)ython. Whilst this could be offset somewhat by doing everything through JNI, this has a few other problems: Harder to use a single source tree for all platforms. It will still be *many* times slower than CPython due to the overhead of JNI. 3. Compatibility In addition to the need for JNI (and the incompatibilities introduced by that) Python would *only* be available on those platforms which had a well-behaving implementation of the correct version of the JVM. As an example - I doubt there would be an Amiga version of Python if Python only ran on top of the JVM. 4. Stackless. If Python was written in Java, I highly doubt we would *ever* have seen the wonderful Stackless implementation come about. Since it has been done people are looking at how the Stackless extensions could be mapped onto J(P)ython, but it appears that everything would have to be done with Java Threads - which will slow Stackless down to a crawl. Personally, I can't think of any advantages of having the reference implementation in Java which Python doesn't already have. I'll let others come up with other reasons for and against. Tim Delaney PIP > -----Original Message----- > From: D-Man [mailto:dsh8290 at rit.edu] > Sent: Monday, 30 October 2000 3:28 PM > To: python-list at python.org > Subject: CPython vs. Jython/JPython > > > > Hi. > > This isn't to start a flame war, but to clarify some confusion I have. > > I am wondering why there are two separate python interpreters > being developed (the one in C, the other in Java). Wouldn't > it be more productive if both teams worked together on one > interpreter? Another thought I had was that it would be > easier to make python cross-platform if it was written in > Java and let the Java developers worry about the C-level > platform dependencies. Isn't it also possible to write Java > extensions in C? (read: ... python extensions in C (using > the Java interpreter)) > > I thank all in advance for your insight into this matter. > > -D > > > -- > http://www.python.org/mailman/listinfo/python-list > From piet at cs.uu.nl Thu Oct 5 04:56:30 2000 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 05 Oct 2000 10:56:30 +0200 Subject: How can you copy (clone) a string? References: <39DBBF7D.6F28E487@my.signature> Message-ID: >>>>> Greg Ewing (GE) writes: GE> Peter.Rupp at ual.com wrote: >> >> What I'm trying to do is determine how large a user process can be >> before it runs out of memory. >>>> a = 1000 * 'a' >>>> b = 1000 * 'a' >>>> id(a) GE> 1052344 >>>> id(b) GE> 1091800 >>>> GE> Loop until done. That will not help, as the strings will be garbage collected. i = 0 s = 1000 * 'x' mem = None while 1: i = i+1 mem = (mem, s+`i`) might work (untested) -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From eff at my-deja.com Fri Oct 20 08:59:41 2000 From: eff at my-deja.com (eff at my-deja.com) Date: Fri, 20 Oct 2000 12:59:41 GMT Subject: ActivePython 2.0 Release References: <634vusk9nco8qem70ddo43t4qpgid30s1l@4ax.com> Message-ID: <8spfjq$qt$1@nnrp1.deja.com> Dale wrote: > Yes, but how is this better then Python 2.0 + Win32all? hint: have you checked the license? Sent via Deja.com http://www.deja.com/ Before you buy. From nospam at nospam.com Tue Oct 10 12:11:56 2000 From: nospam at nospam.com (Tom) Date: Tue, 10 Oct 2000 16:11:56 GMT Subject: What's wrong with ActiveState? (was: Is this a dream or a nightmare? (Was Re: XML)) References: <39d1d3b2.43465571@news.telus.net> <39e1f314.11798695@news.davesworld.net> Message-ID: "Cameron Laird" wrote in message news:ABE8719E58552782.10F0DE3A10643726.D1376FE7AD8F70C3 at lp.airnews.net... > In article <39e1f314.11798695 at news.davesworld.net>, > David T. Grove wrote: > . > I'll summarize what I understand from this thread: you > are angry with ActiveState. Thousands of other people > are opposed to ActiveState. The reasons are sufficiently > evident that I could comprehend them without further > explanation if only I would "pay attention". > > Thank you for your help in this matter. Good luck with > CodeMagic and CodeMagicCD; I'm told these are quite useful > and praiseworthy. The other thing that strikes me as noteworthy here is that David Grove works for a competitor to ActiveState, and that they were considering using his position regarding ActiveState as a marketing initiative. I'm not saying that he is wrong. Just that he can't be considered an objective source on this matter. I think the Python community will have to judge ActiveState based on its actions relative to Python. My personal opinion (and I'm not affiliated with anyone) is that Mark Hammond appears to have contributed quite a bit to the Python community, so I'm quite interested to see what he (and AS) come up with. Tom. > > Cameron Laird > Business: http://www.Phaseit.net > Personal: http://starbase.neosoft.com/~claird/home.html From borcis at geneva-link.ch Tue Oct 24 04:25:47 2000 From: borcis at geneva-link.ch (Boris Borcic) Date: Tue, 24 Oct 2000 10:25:47 +0200 Subject: Python scoping References: <8FD6F80F0suppamanxcollectoror@209.155.56.95> Message-ID: <39F5478B.41DF73BA@geneva-link.ch> SuppamanX wrote: > > I am > accustomed to explicitly start and end my scopes with a braces. From a > readability standpoint, it gets quite problematic for especially for some > of the example code that I am trying to learn from. > > Can someone clarify why there is no explicit end for scopes? > (i.e. IFs, FORs, WHILEs, METHODs, etc...) this tends to diminish the number of lines in a "scope", and thus optimizes for the chance that both ends are simultaneously visible on a single page, does it not ? BB From meng.engineering at bluewin.ch Thu Oct 5 01:57:30 2000 From: meng.engineering at bluewin.ch (Markus Meng) Date: Thu, 5 Oct 2000 07:57:30 +0200 Subject: Windows Binaries for PIDDLE and Graphite ... Message-ID: <8rh5ki$t1k$1@bw107zhb.bluewin.ch> Hi all, are binaries available? If not is it enough to download the sources for PIDDLE and Graphite and then to build those modules, if you only have the binary distribution for windows from python version 1.6, or do I need the sources for python 1.6 as well? markus -- ******************************************************************** ** Meng Engineering Telefon 056 222 44 10 ** ** Markus Meng Natel 079 230 93 86 ** ** Bruggerstr. 21 Telefax 056 222 44 10 ** ** CH-5400 Baden Email meng.engineering at bluewin.ch ** ******************************************************************** ** Theory may inform, but Practice convinces. -- George Bain ** From jbedal at hotmail.com Sun Oct 29 15:24:38 2000 From: jbedal at hotmail.com (John R Bedal) Date: Sun, 29 Oct 2000 20:24:38 GMT Subject: getting keyboard input 1 char at a time Message-ID: Is there a platform independant method for getting keyboard input one character at a time? -John From hwanjoyu at uiuc.edu Wed Oct 25 00:28:39 2000 From: hwanjoyu at uiuc.edu (Hwanjo Yu) Date: Tue, 24 Oct 2000 23:28:39 -0500 Subject: Q: python and distributed object like CORBA Message-ID: Hi, Is there a distributed object supported for python like CORBA or RMI ? If not, isn't there any way of implementing it in python ? Thanks in advance. From aleaxit at yahoo.com Thu Oct 19 15:01:49 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 19 Oct 2000 21:01:49 +0200 Subject: SWIG compatability with Python 2.0 final? References: <8smvt5$nh$1@nnrp1.deja.com> Message-ID: <8snjpp01o4r@news2.newsguy.com> "Johann Hibschman" wrote in message news:mtn1g0zq4m.fsf at astron.berkeley.edu... > cherokee30114 writes: > > > Does anyone have a comment on the compatability of SWIG with the Python > > 2.0 final release? The documentation on SWIG's web site seems a little > > dated and I am about to undertake a massive project integrating Python > > into my companies C++ engine. (I can't wait to see management's faces) > > So far, it's worked for me. I'm using python 2.0b2 and SWIG 1.3a1 as > we speak, for numerics. I don't pretend to have exhaustively tested it, > but I'm a data point. I haven't tried SWIG with the Python 2 final release either, but I also had no problem using it for simple things with Python 2 betas. For 'massive' integration of C++ stuff, though, I would recommend either CXX (mature, massive) or py_cpp (newish, lean-and-mean). These take specific advantage of C++ features and know the typical C++'ish things one would like to do (e.g., expose a C++ class to Python as a Python class, so that Python code can inherit from it, override some virtual methods, etc... I'm not sure if CXX can do it all, including implicit "callbacks" from C++ to Python when C++ code calls a virtual method that has been Python-overridden, but that's a py_cpp strength). I know there are other specific tools for C++/Python integration (the py_cpp page mentions a few), but CXX and py_cpp (and SWIG) are the ones I've "used in anger" and can recommend. Alex From jwbnews at scandaroon.com Sat Oct 14 20:12:59 2000 From: jwbnews at scandaroon.com (John W. Baxter) Date: Sat, 14 Oct 2000 17:12:59 -0700 Subject: SMTP receive as well as send References: <39e8bfe4.2248931@news.demon.nl> <39e8ce9c@news.server.worldonline.co.uk> Message-ID: In article <39e8ce9c at news.server.worldonline.co.uk>, "Phil Harris" wrote: > I may be talking out of the hole where the sun don't shine here, so > someone > correct me if I'm wrong, but: > > SMTP is only for sending, isn't it? > POP3 is only for receiving, isn't it? > > Yes, but... Some POP3 servers can be induced to act as if they handled the sending side (recent qpopper versions from Qualcomm, for example). I say "as if they handled" because they seem to accept the message, and pass it along to the SMTP server for action (and the version we have installed leaves a stray file behind per message). At least, the log entries are made by the SMTP server. On the Mac version of Eudora, I don't see a way to configure this, even with the esoteric settings plugin installed. It's probably available in one of the things. On the Windows version, one edits a configuration file to turn this on. I've messed with it in the Windows version (to be sure we could support it...it works but is a bit of a pain). I don't see a setting for it in Mac Outlook Express. --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From echuck at mindspring.com Fri Oct 27 14:04:04 2000 From: echuck at mindspring.com (echuck at mindspring.com) Date: Fri, 27 Oct 2000 18:04:04 GMT Subject: __builtins__ changes types Message-ID: <8tcg2e$nc$1@nnrp1.deja.com> It appears that __builtins__ changes types. It can be either a dictionary or a module. Anyone know why? # one.py def main(): print 'type of __builtins__:', type(__builtins__) if __name__=='__main__': main() # two.py import one one.main() > python one.py type of __builtins__: > python two.py type of __builtins__: I didn't see anything in the FAQ on this. This is Py2 on Win32: Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 -Chuck -- http://webware.sourceforge.net Sent via Deja.com http://www.deja.com/ Before you buy. From loewis at informatik.hu-berlin.de Mon Oct 2 05:05:28 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: Mon, 2 Oct 2000 11:05:28 +0200 (MET DST) Subject: Import libraries and Borland C (Was: Wholly unnecessary flame.) In-Reply-To: <021201c02c32$caa63110$0101a8c0@jayk3> (jay.krell@cornell.edu) References: <021201c02c32$caa63110$0101a8c0@jayk3> Message-ID: <200010020905.LAA06930@pandora.informatik.hu-berlin.de> > It shouldn't be hard to point Borland C at the VC stdio headers and > msvcrt.dll, but I don't actually know. This isn't a problem of differing > compilers/linkers but of there being no one stdio on the platform with a > frozen binary interface. Even Microsoft gives you three -- libc, libcmt, > msvcrt.lib.. Well, they made an attempt with crtdll.dll in NT, but that seems to be so broken that nobody uses it. > Like Bruce Dodson later said, just don't pass FILE* across .dll boundaries. > Likewise there's no guarantee of being able to delete/free new or malloced > memory across .dll boundaries. At least not w/o specifying and making > available functions to work with them. Or drop down to something more > guaranteed, like CoTaskMemAlloc and CreateFile. On the malloc/free front, I think python.dll is doing quite good: all deallocations are done by the same extension module that did the original allocation [somebody correct me if that is not the case]. On passing FILE*, there is a proposal to wrap the stdio routines with Py functions, so extensions would always get the stdio library that Python was built with. Regards, Martin From qrczak at knm.org.pl Fri Oct 27 13:50:31 2000 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 27 Oct 2000 17:50:31 GMT Subject: [Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich comparison References: <39EB3D03.A00C78B6@jps.net> <39F4A4DE.9202540A@udel.edu> <8t3ota028jv@news2.newsguy.com> <39F5AA7A.2C5E35CE@udel.edu> <8t4dl301a4@news2.newsguy.com> <39F6E187.52EB03BB@udel.edu> <39F9076E.5C7253E7@my.signature> Message-ID: Fri, 27 Oct 2000 17:41:18 +1300, Greg Ewing pisze: > Whenever I write a division in my code, I know which one I want. > But the only way I can tell Python which one to use is indirectly, > by manipulating the types of operands I feed to the / operator. > > To me, this is so obviously wrong that I can't understand > how any serious programmer could think it was right. I agree. A coincidence of Python's features makes this especially bad: Integers are promoted to floats implicitly. There are almost no places when such explicit conversion changes the result, so people learn that it is not necessary. This applies both to conversion of expressions and to using integer literals as floating point constants. Division is one of these places where it is necessary. Variables don't have types. That's why the above feature is not as bad in languages like C, where the conversion is often done by passing the value through a variable of a floating point type. gnuplot is a program which does this like Python and it is IMHO bad and confusing. It draws plots of real number functions. Usually the user may ignore the fact that integers are treated in a different way. But 11/4*x + 2*x*log(2/(5*x)) is wrong and he has to write 11.0/4.0*x. Other constants here do work. It's easy to forget that constant divisions must be explicitly floatified, because integers work well as floating point values in other places. It's bad to have a rule that something works almost always. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From dale at out-think.NOSPAMco.uk Thu Oct 12 09:09:50 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Thu, 12 Oct 2000 14:09:50 +0100 Subject: Quickest way to build a long string? References: Message-ID: Max M?ller Rasmussen wrote: >From: Dale Strickland-Clark [mailto:dale at out-think.NOSPAMco.uk] > >>String operations of this type tend to be memory thrashers so I was >>wondering if anyone had conducted any tests to see which of the >>approaches available might be the most efficient. > >>1. multiple string concetenation. (html = html + cell) >>2. build list of components then use join at the end to make a string >>3. something even cleverer > >In my expeerience the join of list(2) is by far the fastest, but why don't >you just make a simple test? > >Regards > > Max M Time! mainly. But I will if I don't get an authoritive response. Dale Strickland-Clark Out-Think Ltd Business Technology Consultants From the_brain at mit.edu Sun Oct 8 10:58:42 2000 From: the_brain at mit.edu (Alex) Date: 08 Oct 2000 10:58:42 -0400 Subject: Text size in Idle under X11? References: <8ronir$78d$1@nnrp1.deja.com> <8roq66$985$1@nnrp1.deja.com> <8rpo08$t33$1@nnrp1.deja.com> Message-ID: > I downloaded and tried version .05 and still have the same small font. > Since I use Debian, I'm afraid that installing Python later than 1.5.2 > will likely break several scripts if I jump to 1.6 or a CVS version. > So I guess I'll wait until version 2.0 is formally released and > incorporated into Debian a year to 18 months from now. ;-) You could do what I do, which is build a CVS version of python, and stick it somewhere other than /usr. I do this because the folks responsible for maintaining my machines don't want to have to track who's doing what to the machines' core binaries, but it would also be appropriate in your case, I suppose. When you build it, you just need to run configure with an argument like '--prefix=~' Then make install will put the binary in ~/bin Alex. -- Speak softly but carry a big carrot. From root at rainerdeyke.com Thu Oct 26 15:02:38 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Thu, 26 Oct 2000 19:02:38 GMT Subject: C's syntax (was Re: Python Formatted C Converter (PfCC)) References: <8t0or303ee@news1.newsguy.com> <39F4FFB7.452EDDEC@alcyone.com> <8t3mdv025uo@news2.newsguy.com> <39F5B404.B5626FB7@alcyone.com> <8t4q8v11lpv@news1.newsguy.com> <39F5E620.C780A71C@seebelow.org> <8t7lio01u29@news2.newsguy.com> Message-ID: "William Tanksley" wrote in message news:slrn8vgskg.uqr.wtanksle at dolphin.openprojects.net... > For example, it's generally conceded that realloc has too many functions: > it does downsizing, allocation, and upsizing. At least one of those > functions (preferably allocation) should be removed. Then people would have to write a wrapper function which re-includes that capability. There are, believe it or not, cases where all of realloc's capabilities are needed (or at least useful). For example, what if you want a resizable array that can be reduced to (or starts at) size zero? -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From loewis at informatik.hu-berlin.de Sun Oct 1 04:41:30 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 01 Oct 2000 10:41:30 +0200 Subject: XML References: <39d1d3b2.43465571@news.telus.net> Message-ID: root at 127.0.0.1 (David) writes: > I dug deeper into the PEP and discovered that the full XML-SIG package will > make it into v2, which is very reassuring. I'll try to be patient! Now I'm confused. Which PEP exactly, and which statement in it makes you believe that? XML in Python 2 will be SAX2 with the expat driver, and minidom. It will not include xmlproc, sgmlop, SAX1, and 4DOM, which are also parto of PyXML. Regards, Martin From eviltofu at rocketmail.com Wed Oct 25 19:12:13 2000 From: eviltofu at rocketmail.com (Jerome Chan) Date: Wed, 25 Oct 2000 23:12:13 GMT Subject: Python IDEs and eXtreme Programming References: <8t6umj$qma$1@clematis.singnet.com.sg> Message-ID: In article <8t6umj$qma$1 at clematis.singnet.com.sg>, ngps at post1.com (Ng Pheng Siong) wrote: > I am expecting to find Java code monke^H^H^H^H^Hpeople who have > worked with the usual Windows-type IDEs. I believe I am unlikely > to find up to 10 Python programmers who can do vim and CVS. ;-) > > Any experience, thoughts, etc.? get wincvs. it reduces cvs pain. From aahz at panix.com Tue Oct 24 02:02:41 2000 From: aahz at panix.com (Aahz Maruch) Date: 23 Oct 2000 23:02:41 -0700 Subject: SQL server data types???? References: <8t23lq$gak$1@nnrp1.deja.com> <39F49C97.75E7140B@holdenweb.com> <8t2bnk$ns5$1@nnrp1.deja.com> Message-ID: <8t38m1$sm7$1@panix2.panix.com> In article <8t2bnk$ns5$1 at nnrp1.deja.com>, wrote: > >and if I have in a table (SQL server) a datatype nvarchar, Python shell >send the follow error: > >InterfaceError: SQL type (code -9) not implemented > >To solve this erro, i need make a cast, but it's so hard, because I >have a lot a fields nvarhcar.... Ugh. Yeah, I remember that. Unfortunately, I'm not working at that job any more, so I can't play with SQL Server to test things. I do recall that we used a hacked version of mxODBC for a while when we were using Python 1.5.1, so that's one possibility. Another option would be to create views, but that creates messy update issues. I forget what nvarchar is -- is that the Unicode type? If so, Lemburg will probably fix that in the 2.0 version of mxODBC, because 2.0 is the first standard version of Python to support Unicode. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Boy, I got vision, and the rest of the world wears bifocals." --Butch Cassidy From sandj.williams at gte.net Wed Oct 18 23:36:12 2000 From: sandj.williams at gte.net (Steve Williams) Date: Thu, 19 Oct 2000 03:36:12 GMT Subject: urllib and MS proxy. How can I debug? References: Message-ID: <39EE6CC9.2A5EB09F@gte.net> kentsin at poboxes.com wrote: > The urllib of python 2.0 does not like the MS proxy. In my > environment, the proxy is 192.168.83.3:80. I have the following in my > win98 box : > 'snip' Ah yes, Microsoft Proxy. Not just a browser setting, but a control panel setting. Something that sits between you and the net for every application--not just the browsers--sniffing and controlling. Can you say 'per transaction billing?' Sure, I knew you could. Wait 'til you get the invoice from Redmond for that whitepaper you downloaded. "Welcome to Oceania, Winston." From boud at rempt.xs4all.nl Mon Oct 23 15:57:39 2000 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 23 Oct 2000 19:57:39 GMT Subject: [ANNOUNCE] dbObj 1.0 released Message-ID: <8t257j$eco$1@news1.xs4all.nl> I've just wrapped up the 1.0 version of dbObj, an ultra-light object-oriented middleware toolkit for MySQL and Python (although it should be easy to plug in another database - the db-dependent bits are well-marked). People have thought that it did look a bit like Apple's (formerly Next's) enterprise objects - but much, much simpler... dbObj offers relation tables and records as Python objects that can be subclassed and everything. Repositories can be stored in xml files (and retrieved), and ddl sql can be generated from a repository. I do not know of any remaining bugs, but I suspect there are still some. But there's something like a manual now, and a test application, too. Get it at: http://www.valdyas.org/python/dbobj.html or (if that one is down) http://www.xs4all.nl/~bsarempt/python/dbobj.html dbObj forms the basis of my Kura linguistics database application: http://www.valdyas.org:8000 -- Boudewijn Rempt | http://www.valdyas.org From aleaxit at yahoo.com Fri Oct 13 06:13:53 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 13 Oct 2000 12:13:53 +0200 Subject: very good reasons? References: <8r2k0n01u30@drn.newsguy.com> <8r34dg0kek@drn.newsguy.com> Message-ID: <8s6nja02b6j@news1.newsguy.com> "Samuel A. Falvo II" wrote in message news:slrn8ucb9e.eam.kc5tja at garnet.armored.net... [snip] > Python does. In my ideal system, I'd use: > > sorted = array.inAscendingOrder(); foo( sorted ) > > or: > > sorted = array.inSortedOrderBy( compare_function ); foo( sorted ) > > This, to me, makes much more sense and is more explicit. This disadvantage > is that this consumes more memory in the process. It's easy to build your "ideal system"'s functionality in terms of what Python offers today, except for the syntactic-sugar detail of having it appear as a function-call rather than as a method-call: def inAscendingOrder(sequence): result = list(sequence) result.sort() return result sorted = inAscendingOrder(array); foo(sorted) and so on. Alex From MarkH at ActiveState.com Fri Oct 6 01:28:53 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Fri, 06 Oct 2000 05:28:53 GMT Subject: freeze bugs References: <8rip7c$oo9$1@nnrp1.deja.com> Message-ID: > I've been able to use freeze.py to generate source, the makefile and > have successfully frozen a script. When I run the script I get some > unexpected screen output: > > Initialising 'pywintypes' > Initialising 'pythoncom' > Initialising 'win32ui' > "my program output here" > Terminating 'win32ui' > Terminating 'pythoncom' > Terminating 'pywintypes' I have just checked in a fix to the core Python sources for this... Mark. From dcalvelo at pharion.univ-lille2.fr Fri Oct 6 11:29:09 2000 From: dcalvelo at pharion.univ-lille2.fr (Calvelo Daniel) Date: 6 Oct 2000 15:29:09 GMT Subject: Disassambling code in Python: What is in the .co_code-part References: <8rkp43$j2j$1@oslo-nntp.eunet.no> Message-ID: <8rkr45$fmd$1@netserv.univ-lille1.fr> Thomas Weholt wrote: : what is the content of the string-attr found in : : someclass.__class__.__dict__['some'].func_code.co_code ? : : Where can I find documentation of how Python is structured at this level? : : I want to make a semi-disassembler/optimizer/debugging kinda thing. Have a look at: * module 'dis' (disassembler module, in Lib/dis.py from the source distro) * bytecodehacks : http://bytecodehacks.sourceforge.net Those should give you lots of brain food. HTH, DCA -- Daniel Calvelo Aros calvelo at lifl.fr From qrczak at knm.org.pl Wed Oct 4 16:01:15 2000 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 4 Oct 2000 20:01:15 GMT Subject: Class Browsers vs Static Types (Re: Inefficiency of __getattr__) References: <39DB62F6.EF943473@geneva-link.ch> Message-ID: Followup-To: comp.lang.functional Wed, 04 Oct 2000 19:03:50 +0200, Boris * (1+(is->cic)) pisze: > > More errors are fixed at compile time, before testing. > > Mmmhhh...:) one might be tempted to argue that this way of > putting it is politically loaded in the direction of disallowing > undecidable compilability... It is not. There are Haskell extensions which make the type system undecidable, and we sometimes use them. Of course it is better when they are eliminated by designing an appropriately constrained subset of the extension which is decidable. > and before a language with such a feature, it becomes a bit of an > abuse to distinguish compilation from testing, does it not ? Why? An undecidable type system may fail to give any answer, but when it does give one, it is accurate - if it says a program is type correct, it is such for sure. It is not the case for testing. > ...tempting to suggest that dynamic OO languages have natural and > efficient class browsers and method editors where static typing > languages have natural and efficient checks and error messages. Is > that anywhere close to what you wanted to say with "more expressive > tools" ? Sorry, I should have said "language features" rather than "tools". That a static type system at the same time rejects some correct programs and gives more power to some old constructs. But it indeed happens that I don't feel comfortable with complex GUIs for editing programs, and prefer the style of batch compilation :-) An interactive interpreter is good only for trying out new ideas and small experiments, not for writing programs. > This looks as if it could be universally assumed that typing bugs > would translate to bugs during program execution if they weren't > caught during compilation... IMHO it is almost always true. It is especially true for trivial bugs in boring programs. It is less often true when trying to develop a library which reaches the borders of expressiveness of the type system. I have met two cases when the type system disallowed a particular design. One is a statically typed HTML tree, where for the possibility of "included" elements I could not find a better solution than to group all elements ever "included" in the grammar in a single type and use that type all over the tree. The other is the design of the collection framework for Haskell, which uses a few complex language extensions (two of which are not yet implemented in GHC, only in Hugs) and still does not allow some sensible usages available in another framework because it would add too much complexity. Thousands of other complaints from type checkers were real bugs. Some of them were obvious from the first sight, sometimes it took several minutes to locate and fix it, but the fault was always on my side. > > One thing applying especially to Haskell: > > Why Haskell and not OCaml ? OCaml is not lazy, so the debugging output includes the whole history of computing a value instead of only parts actually used, the evaluation order is not interleaved with computing and using a value, there are debuggers for it (although I haven't used one), and the act of outputting a value does not change the behavior of the program. OCaml is not pure, so it is easier to add debugging actions at any place. Fortunately Haskell implementations do provide ways to attach debugging output to pure values. Since Haskell is lazy, it is common to put expressions of the form (error "message") where the value should not be evaluated and trying to evaluate it will be a bug in the program. It avoids the need to invent an artificial values. Unfortunately in case of an error it does not show why, how and where it was attempted to be evaluated. It also prevents useful printing of structures containing such values. An OCaml program would be forced to find a representation for these values and place checks where values are used instead of where they are produced. > So what we want is an analogue to debugging hooks... again, could > the "programming language organ" that is an "inferred static typing > system" not evolve to "a facility to throw tracing (e.g. recoverable) > exceptions from a lexical distance" ? I don't know what exactly do you mean, how could it look like. > What if we assumed the real benefit (or reason for popularity) of > dynamic OO languages to stem from a particular "implicit adequation" > of "class & method-ic" division of code with IDE integration (and > related advantages) ? I believe that a reason of their popularity is that it's hard to design a static type system for the usual OO style (Eiffel is trying and has problems), so if people want OO, they tend to use dynamic typing. OCaml has a good statically typed OO system, but AFAIK it is not used much. Perhaps OCaml people prefer other ways to express their ideas, and OO people find OCaml too exotic. For designing a user interface the type system or lack of it is probably not important, especially if the programmer does not write physical code. But it is important for writing the engine. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From darrell at dorb.com Mon Oct 23 00:11:55 2000 From: darrell at dorb.com (Darrell Gallion) Date: Mon, 23 Oct 2000 00:11:55 -0400 Subject: Fw: class mutex Message-ID: <012901c03ca7$613fccb0$6401a8c0@home> I thought Semaphores might be a generally good way to handle this kind of thing. But on closer look there's a lot of talk about semaphores in all the thread_xxx.h files. And the history file: - the Python thread module doesn't use semaphores (which aren't provided on all platforms where Python threads are supported). Looks like a messy problem. --Darrell ----- Original Message ----- From: "Olivier Dagenais" > MSDN says this about an article relating to CreateMutex: "You can use a > mutex object to protect a shared resource from simultaneous access by > multiple threads or processes." Does Unix/Linux also have something like > this (at the process level)? What about Mac and (maybe) other platforms? > It would be nice if they were wrapped in one convenient Python > module/object. > > It sounds like Windows uses a tempfile to accomplish this and I would guess > Unix/Linux - a file-oriented OS - would do the same thing. However, these > are just guesses, we'd need to confirm this... > From DOUGS at oceanic.com Wed Oct 18 17:07:31 2000 From: DOUGS at oceanic.com (Doug Stanfield) Date: Wed, 18 Oct 2000 11:07:31 -1000 Subject: Need help on a program. Message-ID: <8457258D741DD411BD3D0050DA62365907A3AD@huina.oceanic.com> With this: > IOError: [Errno 2] No such file or directory: 'p7.dat' Python is telling you it can't find a file with that name. This means the file is either not there or its looking in the wrong place. Assuming you've put that file in the same place as your program, try to change the open statement on line 37 to be (untested): infile = open(r"C:\Jim's Stuff\College Stuff\CS120\Python Programs\p7.dat", "r") That (or something like it) tells Python exactly where the file is. At some point you should start to look at what you have in your PATH environmental variable and figure out where it thinks it should be looking. -Doug- > -----Original Message----- > From: Captain Obvious [mailto:captainTRASHobvious at rocketTRASHmail.com] > Sent: Wednesday, October 18, 2000 5:33 AM > To: python-list at python.org > Subject: Need help on a program. > > > I am taking a Python class in college, and am stuck on a > program I am writing. > > Here is the error I get: > Traceback (innermost last): > File "", line 1, in ? > File "C:\Jim's Stuff\College Stuff\CS120\Python > Programs\JRC_07.py", line 37, in ? > main() > File "C:\Jim's Stuff\College Stuff\CS120\Python > Programs\JRC_07.py", line 17, in main > infile = open("p7.dat", "r") > IOError: [Errno 2] No such file or directory: 'p7.dat' > > Here is the program I wrote: > > # JRC_07.py > # Program written by James Cory for October 18, 2000 > # This program, using p7.dat, will keep a running total of > heating degree days > # and cooling degree days. One heating degree day is added > for every degree the > # temperature is over 80 degrees Fahrenheit, and one cooling > degree day is added > # for every degree the temperature is below 60 degrees Fahrenheit. > > def main(): > #Greeting Section > print "This program, using p7.dat, will keep a running > total of heating degree days" > print "and cooling degree days. One heating degree day > is added for every degree the" > print "temperature is over 80 degrees Fahrenheit, and one > cooling degree day is added" > print "for every degree the temperature is below 60 > degrees Fahrenheit." > hdd = 0 > cdd = 0 > day = 0 > infile = open("p7.dat", "r") > temp = eval(infile.readline()) > while temp != "": > if temp > 80: > amount = temp-80 > hdd=hdd+amount > day=day+1 > print "Day: ", day, "Cooling Degree Days: ", cdd, > "Heating Degree Days: ", hdd > elif temp < 60: > amount = 60-temp > cdd=cdd+amount > day=day+1 > print "Day: ", day, "Cooling Degree Days: ", cdd, > "Heating Degree Days: ", hdd > else: > day=day+1 > print "Day: ", day, "Cooling Degree Days: ", cdd, > "Heating Degree Days: ", hdd > infile.close > print > print > "+------------------------------------------------------------ > ---------------+" > print "The final results are:" cdd, "Cooling Degree Days: > ", hdd, "Heating Degree Days." > main() > raw_input ("Press to quit") > > Thanks in advance. I can't get ahold of my professor, and am > really stuck. > > > -- > === > > Thanks for taking the time to read my posting. > > Take out the TRASH to respond via email. > > Any views expressed in this USENET posting and/or > attachments are not necessarily those of > Wartburg College. > > Go Knights! > > > > -- > http://www.python.org/mailman/listinfo/python-list > From mfletch at tpresence.com Tue Oct 10 07:26:59 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Tue, 10 Oct 2000 07:26:59 -0400 Subject: Totally Worst Algorithm for Fibonacci Sequence (on one line) Message-ID: http://members.home.com/mcfletch/programming/fibonacci_1000000.txt Ah, the joys of factorials :o) , Mike -----Original Message----- From: Chris Akre [mailto:dont at spam.me] Sent: Monday, October 09, 2000 11:05 PM To: python-list at python.org Subject: Totally Worst Algorithm for Fibonacci Sequence (on one line) ... Oh... and BTW... let's do 100,000 ... From aleaxit at yahoo.com Tue Oct 24 12:10:23 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 24 Oct 2000 18:10:23 +0200 Subject: event loop problem References: <8t21ei$e5a$1@nnrp1.deja.com> <8t3q4402a3u@news2.newsguy.com> Message-ID: <8t4cj207v@news2.newsguy.com> "Toby Dickenson" wrote in message news:jbbbvsspe19tec72dj8stctfa6v4l90224 at 4ax.com... > Geoff Talvola wrote: > > >For a single-threaded Python program using ADO, there's no shared data to worry > >about. And what if your program structure contains long-running calculations > >based on data from your ADO database? You have to contort your calculations to > >insert PumpWaitingMessages() calls everywhere. A single-threaded, non-GUI > >application shouldn't have to have a message loop, IMO. > > Threads that use apartment-model COM must have a message loop - thats > a rule imposed by that threading model. > > If you dont want a message loop, there are plenty of other COM > threading models to choose from. "plenty"? single-threaded is just a small variant of apartment-threaded and still needs a message-loop; then there's multi-threaded aka free-threaded. That's it for COM (though I hear COM+ has added one). And you do have to worry about your code being executed from multiple threads if you declare yourself to COM as free-threaded... thus, protect your data with locking, etc, etc. At least, in the general case. Alex From epg at progenylinux.com Sun Oct 1 17:02:18 2000 From: epg at progenylinux.com (Eric Gillespie, Jr.) Date: Sun, 1 Oct 2000 16:02:18 -0500 Subject: Secure Passwords in Memory In-Reply-To: <14807.22284.741144.900567@beluga.mojam.com>; from skip@mojam.com on Sun, Oct 01, 2000 at 10:23:56AM -0500 References: <20000930160505.A2453@liddy.indy.progenylinux.com> <14807.22284.741144.900567@beluga.mojam.com> Message-ID: <20001001160218.A29586@indy.progenylinux.com> On Sun, Oct 01, 2000 at 10:23:56AM -0500, Skip Montanaro wrote: > Why not just exec su or sudo and let them worry about password problems? Because i need to grab the password with a GTK+ dialog which shouldn't be suid root. So i need to open a pipe to an su-type program (which i've already written) and write the password to it. If i understand what everyone else is saying, there isn't really a problem because only root can look into the memory of another process. -- Eric Gillespie, Jr. <*> epg at progenylinux.com Software Developer Progeny Linux Systems - http://progenylinux.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 240 bytes Desc: not available URL: From sabren at manifestation.com Sat Oct 7 09:55:15 2000 From: sabren at manifestation.com (Michal Wallace) Date: Sat, 7 Oct 2000 09:55:15 -0400 (EDT) Subject: restricting import to current package In-Reply-To: <39df1ae7.146801390@news1.on.sympatico.ca> Message-ID: On Sat, 7 Oct 2000, Robert Roy wrote: > On Fri, 6 Oct 2000 09:40:08 -0500, "Jeff Kunce" > wrote: > > > from mypackage import mymodule > >python will look for mymodule *exclusively* in mypackage. > >I want to do the same thing for the (unspecified) current package. > > > > --Jeff > > > > Sorry, I misunderstood what you were trying to do. There does not seem > to be a simple way to do what you want. You could write your own > import handler using the imp module but that may be more effort than > it is worth. :) I love trouble... How's this: def localimport(modulename): import sys oldpath = sys.path sys.path = ["."] # raise an error to get calling namespace: try: 1 + None except: callingNS = sys.exc_info()[2].tb_frame.f_back # now import the module try: callingNS.f_locals[modulename]= \ __import__(modulename, callingNS.f_locals, callingNS.f_globals) gotError = 0 except: gotError = 1 sys.path = oldpath if gotError: raise ImportError, "no %s in local directory" % modulename Of course, changing sys.path means that the module you're importing can't import any modules that aren't in the current path, or you'll get an error... But... ask a silly question.. :) Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From aleaxit at yahoo.com Thu Oct 12 17:12:58 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 12 Oct 2000 23:12:58 +0200 Subject: Zope & Python References: <39c208eb$0$231@hades.is.co.za> <39E4B7DA.2C18D688@motorola.com> <8s3vik$b5u$1@taliesin2.netcom.net.uk> Message-ID: <8s59ob4c39@news2.newsguy.com> "Tom" wrote in message news:K9lF5.118563$dZ2.53141294 at news3.rdc1.on.home.com... > Regardless of who is technically right about the value of these language > issues (static type checking, access control), it must be accepted that a > lot of people want them. > > I don't see why these features couldn't be added to Python in a way that > would be completely optional and wouldn't affect backward compatiblity. > > I'm not suggesting that the implementation of these features would be easy. > I'm saying that, in theory, we could have the best of both worlds. Adding ANY feature to a language has costs; let alone a feature that goes as deep as "static type checking". Re "access control": Python already has the part of it that's really useful -- the ability to make fields and methods private against accidental access, by naming them with a leading "__". C++'s protected was a design error -- it's identified as such in Stroustrup's excellent "Design and Evolution" book. And protection against *accidental* undesired access (not against deliberate hacking...) is all that C++'s "private" does (again, see Stroustrup's book; this holds for most languages -- only Java has somewhat larger ambitions for _its_ "access control"). Slapping together a half-assed "type checking" kludge, "because a lot of people want" some kind of buzzword compliance about it, would be the worst kind of disaster for Python. There IS a role for (*completely* optional...) type-checking in Python -- and I'm not the only one to think so. However, I believe the "type-checking SIG" has been basically dormant for a VERY long time. I opine that, perhaps, there was no basic consensus reached about what the "type-checking" should accomplish. The detailed "means" are of less interest, if the "end" is not agreed upon, I guess. >From my POV, a 'dream' typesystem for Python would let me: -- express and name interfaces -- collections of methods and semantic assertions about those methods -- ideally with the same feature as Haskell's typeclasses, namely the ability to give a 'typical/reference' implementation of some methods in terms of others (and a minimal set of sets of methods that _must_ be overridden to implement the interface); -- _retroactively_ state "and this type/class X satisfies this interface Y, via these overridings" (minimal or not), as well as doing it contestually to the type or class's definition; -- for any given 'semantic assertion' or groups thereof, let me choose (at runtime) between checking it OR accepting it as given (potentially allowing some optimizations by deduction from those "givens"...); -- let me state that a certain argument (or field, or...) must satisfy a certain interface (treating it as either something to check, or on which to base optimizations, just as for any other semantic assertion, see previous point). I do wonder if we'll ever see all of this in the development line of the present Python, or if it all must wait for the utopia of the future/hypothetical "Python 3K"... Alex From fxital at aol.comnospam Wed Oct 4 11:13:22 2000 From: fxital at aol.comnospam (FxItAL) Date: 04 Oct 2000 15:13:22 GMT Subject: Python 1.6 BUG Message-ID: <20001004111322.03819.00000221@ng-fu1.aol.com> Hello All, I've had Python 1.6 installed on my new system for about a week. While running a script from the RUN box using -i. The DOS box will inconsistantly not close. I must use the Ctrl-Alt-Del, which responds slowly. After this happens Windows will not shut down. A reset and reboot is required. This script runs fine on my old system with Windows 95 with Python 1.5.2. I uninstalled 1.6 and installed 1.5.2 and all is well. FYI, Al From kent at tiamat.goathill.org Tue Oct 24 15:23:37 2000 From: kent at tiamat.goathill.org (Kent Polk) Date: 24 Oct 2000 19:23:37 GMT Subject: Another re question References: <972336131.124972@fezzik.endicor.com> <39F4DB27.A8F09D53@cc.gatech.edu> <972411030.904033@fezzik.endicor.com> <3dy9zeulwa.fsf@kronos.cnri.reston.va.us> Message-ID: <972415709.975464@fezzik.endicor.com> On 24 Oct 2000 14:36:21 -0400, Andrew Kuchling wrote: >kent at tiamat.goathill.org (Kent Polk) writes: >> >>> findpid_pat = r'\012+\d |0*\w*[\t, ]+([\w ]+)' >> I don't understand how a empty string matches in this last >>case. Separately they are: >> >> >>> findpid_pat = r'\012+\d *\w*[\t, ]+([\w ]+)' >> >>> findpid_pat = r'\012+0*\w*[\t, ]+([\w ]+)' > >Oh no they're not; they're '\d ' and '0*\w*[\t, ]+([\w ]+)'. >'|' has lower precedence than concatenation, so everything after the | >is in the second branch. >Try: >findpid_pat = r'\012+(?:\d |0*)\w*[\t, ]+([\w ]+)' So *that's* what 'A non-grouping version of regular parentheses' means. :^) That's exactly what I was trying to do but got confused with the syntax and figured it was a wild goose chase. Thanks So Much! >(How I caught this: by uncommenting the p.dump() commend in >Lib/sre_parse.py. It would be nice to have a way to request a dump of >the bytecode for an SRE pattern.) and for this hint. From tdelaney at avaya.com Thu Oct 26 21:34:02 2000 From: tdelaney at avaya.com (Delaney, Timothy) Date: Fri, 27 Oct 2000 12:34:02 +1100 Subject: Is global really global. Message-ID: > global options > options = read_options(parfile) What you're doing here is declaring that options is placed into the global namespace of the current module. The global options call here shouldn't be necessary (it is only necessary when inside another local namespace such as a function). > a module called "Peaks.py". > > Later on, I try and test some values in "options" via: > > if options.no_coda: > # Eventually, here's where I'd remove the coda, but for > # now, just... > raise NotImplementedError, \ > "I can't deal with the no_coda option yet." > > condor (peaks)$ Peaks.py parfile.peaks first_list First > Traceback (most recent call last): > File "./Peaks.py", line 75, in ? > main_loop() > File "./Peaks.py", line 66, in main_loop > peaks = Locator.f0_peak_locator(frames) > File "./Locator.py", line 23, in f0_peak_locator > if options.no_coda: > NameError: options Okay - what is happening here is that you need to import the Peaks module to get access to the options reference. (in Locator.py) import Peaks if Peaks.options.no_coda: ... or (in Locator.py) from Peaks import options if options.no_coda: ... One final option is to stick the options into the __builtins__ module, which makes it *truly* global, but this is a Bad Thing (TM) in most cases. (in Peaks.py) __builtins__['options'] = read_options(parfile) (in Locator.py) if options.no_coda: ... Tim Delaney Avaya Australia From lars at stea.nu Thu Oct 26 06:12:23 2000 From: lars at stea.nu (lars at stea.nu) Date: Thu, 26 Oct 2000 10:12:23 GMT Subject: variables within variables Message-ID: I'm writing a script for burning CD's I vant to set some variables like: cddev = /dev/cdrom cdrdev = 0,1,0 speed = input("Enter speed: ") and then create a new variable like: cdcopy = "cdrecord - v speed=",speed , "dev=",cdrdev, "-isoimage", cddev I've done this with def cdrecord(speed,cdrdev,cddev) and so forth. I can then print : print cdcopy but the word "Null" is appended to the end of the line. Then it doesn't work to execute: posix.system(cdrecord). Can anyone please explain a way to do this? Lars at stea.nu www.stea.nu From olivierS.dagenaisP at canadaA.comM Wed Oct 18 19:16:55 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Wed, 18 Oct 2000 23:16:55 GMT Subject: Bad documentation (no biscuit!) References: Message-ID: There's a reason I couldn't find the constants in MSDN: they're prefixed with '_' and the search kept missing them! http://msdn.microsoft.com/library/devprods/vs6/visualc/vccore/_crt_file_cons tants.htm I find these descriptions better than what I just posted, although more are missing this time, probably because Windows doesn't natively support them? -- ---------------------------------------------------------------------- Olivier A. Dagenais - Software Architect and Developer "Someone called 'Type your name here' is impersonating me on the internet and is posting exactly the same things I am posting!" > I have found the documentation provided with version 1.5.2 _and_ 2.0 to have > a big hole in it! Specifically, the file is /lib/os-fd-ops.html and the > problem is the constants/flags used with the os.open function: it isn't > obvious what the flags stand for... > > After some searching on the net, I found the following descriptions for the > flags: (from a Unix Java package or something) > > O_APPEND Open in append-only mode. > O_CREAT Open with creation flag. > O_EXCL Open with exclusive access flag. > O_NDELAY Open with no-delay flag. > O_NOCTTY Open but don't make it the control tty. > O_NONBLOCK Open in non-blocking mode flag. > O_RDONLY Open for read-only flag. > O_RDWR Open for update flag. > O_SYNC Open and keep-disk-synchronized flag. > O_TRUNC Open and truncate flag. > O_WRONLY Open for write-only flag. > > > Can these be added to the documentation, in that sorted order? (plus an > elaboration on what a control tty is and what non-blocking or no-delay do > would be very nice..) Definitions for O_DSYNC, O_RSYNC and O_BINARY are > still missing, anybody can fill them in? (although I have a good hunch as > to what O_BINARY does...) > > am-I-the-only-one-who-isn't-familiar-with-those-flags-ly y'rs > > -- > ---------------------------------------------------------------------- > Olivier A. Dagenais - Software Architect and Developer > "Someone called 'Type your name here' is impersonating me on the > internet and is posting exactly the same things I am posting!" > > > > From paul.moore at uk.origin-it.com Mon Oct 30 08:17:34 2000 From: paul.moore at uk.origin-it.com (Paul Moore) Date: Mon, 30 Oct 2000 14:17:34 +0100 Subject: Initial value of sys.path References: Message-ID: On Mon, 30 Oct 2000 12:59:43 +0100, Simon Brunning wrote: >> From: Mark Hammond [SMTP:MarkH at ActiveState.com] >> Paul Moore wrote: >> > The initial value for sys.path on WIndows is signiicantly different >> > from that on Unix. Specifically, there is no site-packages directory >> > on Windows. >> >> I believe the deliberate decision was simply to "leave windows alone". >> It wasn't clear at the time how useful the site packages would truly >> turn out to be, and Windows already had special registry support. > >I'd be very interested to know why this is. I have set up a site directory >under my Python directory, added to my Python path, and put all my >additional modules and packages there. It works fine, and makes the whole >set-up *much* neater. Depends how you do it. I put a "site" directory in my PYTHONPATH by adding it to the registry. But if I put a .pth file in there, site.py doesn't seem to pick it up. Probably something to do with order of initialisation, or some such. And of course, distutils ignores a site entry you have put in for yourself (unless you add a parameter telling it otherwise). Paul. From ge at nowhere.none Fri Oct 13 12:09:12 2000 From: ge at nowhere.none (Grant Edwards) Date: Fri, 13 Oct 2000 16:09:12 GMT Subject: how do I listen on a socket without sucking up all the CPU time? References: <39d971f3_1@corp.newsfeeds.com> <39D9AA8D.EABDF6BA@businesscollaborator.com> Message-ID: In article , Samuel A. Falvo II wrote: >>Using select with a timeout of NULL(None) is the nicer way to >>do things, i.e. make select blocking. It means this thread >>doesn't have to be limited to just that socket. It obviously >>becomes a lot more useful. > >I've read the select() source in Linux's source code. From >what I can see, it apparently busy-waits on the selectors you >give it -- I don't see any calls to functions that put the >process to sleep. >If I'm wrong on this, and I sure hope I am, could someone >please point out where Linux does put the calling process to >sleep? You're wrong on this. ;) If you look at the top of the for (;;) loop in do_select() [fs/select.c] the task state gets set to TASK_INTERRUPTIBLE. That means we're not in a runnable state. At the bottom of the loop there's a call to schedule_timeout(). Inside schedule_timeout() the scheduler gets called which gives up the processor, and that task won't get scheduled again until the timer times out or some event/signal happens. At that point the do_select()'s call to schedule_timout() returns. When the stuff in the middle of for (;;) loop decides something has_ happened that we care about (by incrementing retval), the code at the bottom of the loop breaks out of the loop and sets the task state back to TASK_RUNNING, and the task starts running again. -- Grant Edwards grante Yow! I like your SNOOPY at POSTER!! visi.com From aleaxit at yahoo.com Mon Oct 23 03:14:55 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 23 Oct 2000 09:14:55 +0200 Subject: C's syntax (was Re: Python Formatted C Converter (PfCC)) References: Message-ID: <8t0or303ee@news1.newsguy.com> "Glyph Lefkowitz" wrote in message news:m3y9zg9kn4.fsf at DHCP-98-129.origin.ea.com... [snip] > (Also, there's the fact that C's syntax is actually pretty good for > doing what C does) I strongly disagree. C's syntax has glaring flaws, such as being unparsable "locally" -- i.e., without knowing what typedef's have been previously met. For example: foo * bar; if foo has been typedef'd (and thus is now a typename), this declares variable bar as a pointer-to-foo. If foo has not been typedef'd, this has a completely different meaning, "evaluate this multiplication and throw the result away". This absurd state of affairs comes from back in the dark-ages of C, before typedef had been introduced -- at that time, this would have been a multiplication unambiguously (forgetting preprocessor issues, which can of course introduce unbounded ambiguity -- hardly a "pretty good" situation, either:-). Even from a human-factors point of view, such syntactic tripwires (over which people DO keep stumbling...) as if(a=0) ... /* oops, an assignment...! */ or foo* bar, baz; /* NOT two pointers... */ or struct foo { int bar; } /* forgot a semicolon... */ /* int can be omitted and is implied -- how CRAZY! */ myfun() ... hardly combine to make C's syntax "pretty good". TERRIBLE is more like it. ALL that C's syntax has going for it is familiarity: it's a good field-test of the hypothesis that human beings can get used to ANYTHING. I consider the current prevalence of C's syntax, and the resulting use of C-like syntax in newer languages such as Java or C#, a clear case of "Stockholm Syndrome"...:-) Alex From olivierS.dagenaisP at canadaA.comM Tue Oct 31 19:41:02 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Wed, 01 Nov 2000 00:41:02 GMT Subject: commenting multiple lines References: Message-ID: """ Add triple-quotes before and after your block, just like this "block"... That is assuming, of course, that you don't have any triple quotes inside that block... """ -- ---------------------------------------------------------------------- Olivier A. Dagenais - Software Architect and Developer "Someone called 'Type your name here' is impersonating me on the internet and is posting exactly the same things I am posting!" "Hwanjo Yu" wrote in message news:CvJL5.885$6b7.17872 at vixen.cso.uiuc.edu... > Hi, > > Isn't there any way to comment out multiple lines without using '#' on every > line ? > Thanks. > > > From tim.lavoie at mts.net Thu Oct 26 10:48:04 2000 From: tim.lavoie at mts.net (Tim Lavoie) Date: Thu, 26 Oct 2000 14:48:04 GMT Subject: POST HTML Form to 2 seperate apps References: Message-ID: Ryan N. wrote: >Hello All, >Python Weenie here needs some insight on taking a form post and then >re-posting the form contents to two other applications-one in ASP and the >other a CGI. > >Any ideas / examples? My only example is pretty messy, so I'm not sure I should post it. :-) Anyway, I used urllib to submit a form repeatedly for benchmarking, with the form parameters in the form of a dictionary I loaded from a pickle file. In any case, once you have the form parameters, then you can post them to whatever URL you like. Use one URL for your ASP, and another for the CGI. If you need to take the original input as a POST as well, then you'll need to write your own Python CGI to get the data to repost. -- ignorance, n.: When you don't know anything, and someone else finds out. From peter.stoehr at weihenstephan.org Fri Oct 20 06:50:57 2000 From: peter.stoehr at weihenstephan.org (Prof. Peter Stoehr) Date: Fri, 20 Oct 2000 12:50:57 +0200 Subject: Scheduling of Threads Message-ID: <39F02391.D88003C7@weihenstephan.org> Hi out there, is it possible to implement an own scheduler for the threads of the threading objects. And has to be done for this. I looked at the manuals but I didn't find any information. Thanks in advance Peter -- --------------------------------------------------------------------------- Prof. Peter Stoehr --- Teisenbergweg 6 --- 85435 Erding --- 08122/47232 http://www.weihenstephan.org/home/ak/support/team/jpg/peter.jpg --------------------------------------------------------------------------- I'm the terror that flaps through the night From aleaxit at yahoo.com Tue Oct 10 04:47:49 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 10 Oct 2000 10:47:49 +0200 Subject: Why is "while" ticking me off??? References: <39DD15A1.442E5A33@ix.netcom.com> <87zokes2wc.fsf@cartman.azz.net> <8rstcj$t1n$1@panix3.panix.com> <87aecdmyo3.fsf@cartman.azz.net> <8rtlqf$72m$1@panix3.panix.com> Message-ID: <8ruldi018n@news2.newsguy.com> "Aahz Maruch" wrote in message news:8rtlqf$72m$1 at panix3.panix.com... [snip] > >was intending there. If = were an operator in Python with the same > >meaning it has in C, then you could have written that as: > > > >if a = dict[k1]: > > a.something() > > OIC. Well, in Python, I'd write this as > > if dict[k1]: > dict[k1].something() > > assuming I were certain that k1 existed in dict, which you'd have to do > in C (null pointer bugs are so much fun). Here, it may be OK to evaluate the expression twice, as it's simple enough. More generally, however, the idiom: if somecomplicatedthing(a,b,c): somecomplicatedthing(a,b,c).something() is untenable -- you can't even be sure that somecomplicatedthing will return the same result both times, let alone do so efficiently. I think a more Pythonic approach is (surprise, surprise!-) an auxiliary object (and I nominate this as the First Python-Only Design Pattern, as I have not met it elsewhere...:-)... # in holdit.py...: class HoldIt: def __init__(self): self.values = [] def set(self, value): self.values.append(value) return value def get(self): return self.values.pop() holdIt = HoldIt() # in your using module from holdit import holdIt if holdit.set(somecomplicatedthing(a,b,c)): holdit.get().something() I think this solution is quite acceptable in some cases, e.g. if you have to translate to Python a lot of code making large use of the idiom of assignment-within-expression that other languages afford. If several assignments must co-exist, rather than a LIFO discipline as here suggested, then the set and get methods will have to take a 'variable name' argument and the class will have to use a dict rather than a list (further syntax sugar via __getattr__ etc may then also be warranted), but I suspect one level only will often suffice, and I propose it in the usual spirit of "doing the simplest thing that can possibly work". Note that the 'holdit' object ends up holding one value when the 'if' fails -- this needs to be explicitly 'cleared' (I think that adding an 'implicit clear', i.e. not actually recording in .set a value that yields false, is a bit of an overspecialization -- although it's of course very easy to add it if you don't mind breaking "explicit is better than implicit"). E.g., in the idiom that's probably most-asked-about in this newsgroup, "how do I read & process a file just one line at a time", one solution would become: while holdit.set(fp.readline()): do_process(holdit.get()) # an extra call to clear the left-over null: holdit.get() Maybe adding a more-explicit "holdit.unset()" synonym for ".get", for the specific purpose of removing the last-set value, might be even better (just because it's more explicit). With the named-values variants, one would have: while namer.set('line', fp.readline()): do_process(namer.line) namer.del('line') or thereabouts. Implementation is left as an easy exercise to the reader... Alex From effbot at telia.com Sun Oct 8 07:29:55 2000 From: effbot at telia.com (Fredrik Lundh) Date: Sun, 08 Oct 2000 11:29:55 GMT Subject: Integer multiplication overflow. References: <8ronb6$75e$1@nnrp1.deja.com> <8rphoh129t3@news1.newsguy.com> Message-ID: Alex Martelli wrote: > It doesn't have unlimited-precision rationals in the language or > standard library (I don't know why -- it IS a strange omission) there's an implementation in the standard distribution: Demo/classes/Rat.py if it's good enough (I cannot tell), and someone contributes some documentation, I'm sure it could be added to the standard library in 2.1. (it's too late for 2.0; the 2.0 final code base is frozen, and a release candidate is being prepared. stay tuned). From sandj.williams at gte.net Sat Oct 14 00:10:09 2000 From: sandj.williams at gte.net (Steve Williams) Date: Sat, 14 Oct 2000 04:10:09 GMT Subject: This is really cheesing me off... References: Message-ID: <39E7DD3E.5AA4621F@gte.net> Not only that, but if you aren't careful, you can change stuff in imported modules after an exception. From aleaxit at yahoo.com Wed Oct 11 04:06:09 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 11 Oct 2000 10:06:09 +0200 Subject: How does "for" work? References: Message-ID: <8s17bl02cuq@news1.newsguy.com> "Steve Juranich" wrote in message news:Pine.SOL.3.96.1001010105911.8470C-100000 at condor.ee.washington.edu... > I have an object that is actually just a list of other, smaller items. > > In the list object, I have overridden __getitem__ to be the following: > > def __getitem__(self, key): > return self.data[key] [snip] > Where data is a dictionary of the smaller items, with a time index (by ints) > being used as the key. I see that other posts have already remarked that you need to change the KeyError exception (returned by addressing the self.data dictionary with a missing key) into an IndexError (which is what a sequence returns, and for expects), but I'd like to understand better what you're doing. _Why_ is self.data a dictionary at all, rather than a list? Using it correctly with a for-loop requires that the keys be a compact set of integers from 0 upwards -- and in this case, what do you gain by making it a dictionary rather than a list in the first place? Alex From stadt at cs.utwente.nl Wed Oct 25 21:08:53 2000 From: stadt at cs.utwente.nl (Richard van de Stadt) Date: Thu, 26 Oct 2000 02:08:53 +0100 Subject: How do I force a single instance of a python app? References: <39f5e46f_3@corp.newsfeeds.com> Message-ID: <39F78425.E38E5EB5@cs.utwente.nl> Joshua Muskovitz wrote: > > I need to prevent multiple copies of a python app from running > simultaneously on a single machine. In Windows and C++, this is done with > sending custom window messages to all top level windows, or using some other > kind of scheme. > > I'm looking for a platform neutral way to do this for my python apps -- the > second instance should somehow detect the first instance and should quietly > kill itself. This looks analogous to what is usually done when including header files in C programs: A header file is included, and at the top of the header file, there is some #ifdef to check if the file was included before. Why not test this in the including file, so that the file to be included may not need to be opened in the first place? The analogy to your problem is that you should not let the application test whether another instance is running, but test that before starting it. If you use some wrapper-prog that does the test (e.g. with ps on Unix), then it can decide whether an instance of the real application should be started. Richard. From jon+python-list at unequivocal.co.uk Tue Oct 24 15:32:46 2000 From: jon+python-list at unequivocal.co.uk (Jon Ribbens) Date: Tue, 24 Oct 2000 20:32:46 +0100 Subject: [Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich comparison In-Reply-To: <8t4dl301a4@news2.newsguy.com>; from aleaxit@yahoo.com on Tue, Oct 24, 2000 at 06:28:42PM +0200 References: <39EB3D03.A00C78B6@jps.net> <39F4A4DE.9202540A@udel.edu> <8t3ota028jv@news2.newsguy.com> <39F5AA7A.2C5E35CE@udel.edu> <8t4dl301a4@news2.newsguy.com> Message-ID: <20001024203246.B24383@snowy.squish.net> Alex Martelli wrote: > Usability studies show that people without previous > experiences to bias them find 2/3=0.6666667 more > natural (that's the tidbit, emerged during the studies > for CP4E, which swayed our BDFL, I think). Experienced > programmers are surely more able to adapt than less > experienced ones. My opinion is that floating point is Dangerous and To Be Avoided unless you know what you're doing. The language should not create floating point values for the programmer unless they have specifically asked for them. Cheers Jon From aleaxit at yahoo.com Sat Oct 28 12:29:59 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 28 Oct 2000 18:29:59 +0200 Subject: Python scoping References: <8tab8k024o3@news1.newsguy.com> <8tda45$626$1@paradise.nirvananet> Message-ID: <8tev230147o@news1.newsguy.com> "Hartmann Schaffer" wrote in message news:8tda45$626$1 at paradise.nirvananet... > In article , > Steve Horne wrote: > >On Fri, 27 Oct 2000 00:28:15 +0200, "Alex Martelli" > > wrote: > > > >>I recall that in PL/I you may, if you wish, recall the label in > >>the END clause (or was it Ada...? darn -- big languages, long > >>ago...): > > couldn't that be used for 'multiple closure' (i.e. it also close all > blocks that started within foo that weren't terminated yet)> Could be, if you wanted to design a language that way, but that seems error-prone, while the optional redundancy of specifying what it is that you think are closing helps to have fewer error (perhaps) and better diagnostics of block closing errors (certainly). Alex From thomas.wright1 at ntlworld.REMOVETHIS.com Sat Oct 28 12:38:59 2000 From: thomas.wright1 at ntlworld.REMOVETHIS.com (Tom wright) Date: Sat, 28 Oct 2000 17:38:59 +0100 Subject: How do you create constants? References: <39FAE133.9070001@yieldworks.com> Message-ID: Thanks Marc, that does the job nicely :-) shame they cant be made immutable once they have been set, feature for 2.1 ??? ;-) Regards Tom "marc cheatham" wrote in message news:39FAE133.9070001 at yieldworks.com... > Tom wright wrote: > > > Hi All, > > > > I am a newbie to python, and I have the following question, > > > > in c++ I can create a constant through something like an enum, or a const > > variable or a static. How do I go about doing something similar to this in > > python, e.g. > > > > I want to create a python file/class which contains all my constants for > > ease of use/maintenance. I then wish to use these from various other > > files/classes. Now I understand that due to the scoping of python > > variables, I can not simply reference variables in a separate module, but > > how can I achieve something similar to my global defines file as in c++, by > > the way, the defines would be constant strings and integers. > > > > I am sure there is an easy way to do this, but I havnt found it yet !! > > > > TIA for pointers > > > > Regards > > > > Tom > > > > PS I have RTFM, but if its there I have missed it > > I am not sure if Python has user defined constants, but a possible > solution to the scoping problem could be creating a module called > consts.py. Inside consts.py initialize varibles in with their "constant" > value. Import that module into your other modules and use > consts. to reference the pre-initialized variable. > > The drawback, of course, is anyone can change the value. > > Hope this helps. > Marc > From glyph at no.spam Tue Oct 24 15:45:39 2000 From: glyph at no.spam (Glyph Lefkowitz) Date: 24 Oct 2000 14:45:39 -0500 Subject: C's syntax (was Re: Python Formatted C Converter (PfCC)) References: <8t0or303ee@news1.newsguy.com> Message-ID: "Alex Martelli" writes: > "Glyph Lefkowitz" wrote in message > > (Also, there's the fact that C's syntax is actually pretty good for > > doing what C does) > > I strongly disagree. C's syntax has glaring flaws, such as being > unparsable "locally" -- i.e., without knowing what typedef's have > been previously met. For example: > > foo * bar; I do not disagree that C is awful :) but "what C does" in this context, is mostly being compatible with C. Keep in mind that C is not just a language, but a suite of associated tools and techniques and assumptions that it carries. In order to make a worthwhile competitor, you have to have a significant advantage. I think that on some level syntax is important, but it's not important enough to outweigh other benefits. Compare the following hypothetical statements in my language: foo pointer: bar, baz allocate bar allocate baz to the C equivalent: foo *bar, *baz; bar = calloc(sizeof(foo)); baz = calloc(sizeof(foo)); We can easily tell that they do the same thing, although one might be a little shorter than the other. Is it worth giving up a robust, strenuously-tested compiler and debugger for the nicer-looking one? I don't think that this alone (how it looks) is a compelling advantage... but when you stop to consider that 'allocate' is an operation that is really an operation which can be overloaded at compile-time to dispatch to an appropriate function for the type 'foo pointer', you get something quite like the object-oriented "constructor" mechanism, but implemented in a more straightforward manner. (This can also be extended to give you more or fewer features from that set.) It's essential that things building on top of C add significant value, or their advantages will be dismissed as "nice, but not as important as X" which is some feature (symbolic debugger, native interface) that merely not being C loses you. -- Glyph Lefkowitz Professional -- Software Engineer, Origin Systems Amateur -- Computer Scientist, Twisted Matrix Enterprises (My opinions are my own and do not reflect in any way on the policies or practices of my employer, etcetera etcetera.) From wolfson at midway.uchicago.edu Sun Oct 15 22:08:50 2000 From: wolfson at midway.uchicago.edu (Ben Wolfson) Date: Mon, 16 Oct 2000 02:08:50 GMT Subject: How can I get rid of lambda References: <39EA484C.C57D995A@gte.net> Message-ID: In article <39EA484C.C57D995A at gte.net>, Steve Williams wrote: >I'm working with IBM packed decimal data. The following code works OK, >but there are millions of rows and 10 to 50 columns per row. I want as >much speed as I can get. > >How can I avoid the lambda in the following unpack function? Or better, >is there a faster way? > >By the way, if you want a testimonial to Python's capabilities, do a >Google search on 'packed decimal' and have a look at some of the Java >solutions to this problem. > >def unpack(strPacked): > return fnJoin(map(lambda chrLeft, chrRight: chrLeft + chrRight,\ > fnTranslate(strPacked,_trtLeftNybble),\ > fnTranslate(strPacked,_trtRightNybble)),"") Try importing the operator module, and using operator.add instead of the lambda. -- BTR | It is a symptome of Melancholy to be afraid of death, and yet sometimes to desire it; this latter I have often discovered in my selfe, and thinke noe man ever desired life as I have sometimes Death. -- Thomas Browne, _Religio Medici_ From mjackson at wc.eso.mc.xerox.com Tue Oct 3 10:52:30 2000 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 3 Oct 2000 14:52:30 GMT Subject: How can you copy (clone) a string? References: Message-ID: <8rcrre$4mn$1@news.wrc.xerox.com> =?ISO-8859-1?Q?Max_M=F8ller_Rasmussen?= writes: > Just use slice: > > a = 'a' > b = a[:] Doesn't work, at least in 1.5.2: >>> a = 'a' >>> b = a[:] >>> a is b 1 The following perversity seems to do the trick unless a = '': >>> c = repr(a)[1:-1] >>> a is c 0 But I am inclined to agree with the eff-bot: If you think you need to do this, it's time to redesign your program. -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson I respect faith, but doubt is what gets you an education. - Wilson Mizner From ned3000 at my-deja.com Fri Oct 13 17:55:06 2000 From: ned3000 at my-deja.com (ned3000 at my-deja.com) Date: Fri, 13 Oct 2000 21:55:06 GMT Subject: web client urllib/httplib question Message-ID: <8s80bn$ccn$1@nnrp1.deja.com> Hi all Just wondering if anyone has run into the same problem as me with the web client module urllib. I can't figure out how to send headers. There is a method in the httplib module to send headers with a request, but this module dosen't have the functionality of the urllib module. Thanks Sent via Deja.com http://www.deja.com/ Before you buy. From junaftnoon at nospamplzyahoo.com Mon Oct 2 12:28:41 2000 From: junaftnoon at nospamplzyahoo.com (June Kim) Date: Tue, 3 Oct 2000 01:28:41 +0900 Subject: good python tutorials for C mother-tongues? Message-ID: <0L2C5.39$T34.2386@news.hananet.net> Just as the subject goes. Are there any good python tutorials for professional programmers who's been brought up in C language? Thanks in Advance. From sholden at holdenweb.com Tue Oct 3 23:04:18 2000 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 03 Oct 2000 23:04:18 -0400 Subject: Printing under Tkinter References: <39D832AA.DB10EF4D@hotmail.com> <39DA0DB6.F863E8DD@hotmail.com> Message-ID: <39DA9E32.9304B9D@holdenweb.com> Sreekant Kodela wrote: > > Is there a way to print atleast plaintext from python under win32? so > that I can print formatted text in the least. > > Thanks > sreekant Take a look at PIDDLE, which can produce PDF output and allows one to do very nice formatted text, with graphics if you want. The only drawback is that consumers of your output will require Acrobat Reader or some such to be able to view and print your output. regards Steve -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ From loewis at informatik.hu-berlin.de Tue Oct 3 11:04:06 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 03 Oct 2000 17:04:06 +0200 Subject: Coerce and multimethods (was Re: Inefficiency of __getattr__) References: Message-ID: hzhu at users.sourceforge.net (Huaiyu Zhu) writes: > That would make it quite useless in my case. Yet the simple do-nothing > __coerce__ still consumes as much time as the actual computation, although > __getattr__ uses 6 times more. In your case, the most efficient implementation would be def __coerce__(self, other): return (0,0) Then, it won't invoke another __add__ on any object - which is ok, since your __add__ would return None, anyway :-) > Sometime ago there was a brief discussion of multimethods here. The idea is > that a+b will be dependent on the classes/types of both a and b. I did not > quite understand it at the time. But now it looks to me like that > __coerce__ is simply an awkward way of doing it half-heartedly. Well, coercion is intended to do just that: coerce the arguments to a common type. In arithmethic operations, it is an elegant way to deal with the subset/superset problem. Since Natural \subset Rational \subset Real \subset Complex it is straight-forward to assume that number-like objects support coercion. > In another thread yesterday someone suggested a three way coerce, using the > operation as a third argument to fine tune the coersion. That would still > leave out the info about the original operands, though. A multimethod would > solve all these in a much cleaner way. I don't understand. If you want to operate on the original operands, you don't need any coercion... > Short of that, maybe we should propose to use __coerce__ only for builin > (numeric) types and explicit coerce calls? No, that would be a significant change, breaking compatibility. > What are the most significant applications that use coerce, anyway? Numerical types, i.e. objects implementing __add__, __mul__, and so on. If your type is not numerical, perhaps it should not provide an __add__? In any case, contributions to http://python.sourceforge.net/peps/pep-0208.html are welcome. Regards, Martin From fiona at sitegnome.com Mon Oct 9 05:59:51 2000 From: fiona at sitegnome.com (Fiona Czuczman) Date: 9 Oct 2000 09:59:51 -0000 Subject: [FAQTS] Python Knowledge Base Update -- October 9th, 2000 Message-ID: <20001009095951.6560.qmail@synop.com> Hi All, It's been a while. Sorry, I've taken a full time job which doesn't give me much time to play with the knowledge base .. This post is simply what's happened since my last post. regards, Fiona Czuczman Unanswered Questions : - How do I change the name of a process (as viewed by 'ps') from Python? - How can I get my _full_ program name (eg. "mylongpythonscript.py") under eg. NT? sys.argv[0] gives me the truncated MS-DOS style, "MYLONG~1.PY" etc. - What are the criteria I should consider when deciding between Numeric Python, Matlab or Octave? - getting full program name via sys.argv[0] on (eg.) NT? - is there code that sends the contents of a directory as a multi-part mime message to e-mail recipients? Answered Questions : - Alternative to os.path.walk - How do I find reference count errors? - Python's big, is there a crisp overview? a quick reference card? a bare bones documentation? - Of what use is 'lambda'? - How do I handle command line args with gnome? ## Unanswered Questions ######################################## ------------------------------------------------------------- How do I change the name of a process (as viewed by 'ps') from Python? http://www.faqts.com/knowledge-base/view.phtml/aid/6149 ------------------------------------------------------------- Adam Feuer ------------------------------------------------------------- How can I get my _full_ program name (eg. "mylongpythonscript.py") under eg. NT? sys.argv[0] gives me the truncated MS-DOS style, "MYLONG~1.PY" etc. http://www.faqts.com/knowledge-base/view.phtml/aid/6159 ------------------------------------------------------------- Jon Nicoll ------------------------------------------------------------- What are the criteria I should consider when deciding between Numeric Python, Matlab or Octave? http://www.faqts.com/knowledge-base/view.phtml/aid/5990 ------------------------------------------------------------- Louis Luang ------------------------------------------------------------- getting full program name via sys.argv[0] on (eg.) NT? http://www.faqts.com/knowledge-base/view.phtml/aid/6158 ------------------------------------------------------------- Jon Nicoll ------------------------------------------------------------- is there code that sends the contents of a directory as a multi-part mime message to e-mail recipients? http://www.faqts.com/knowledge-base/view.phtml/aid/5977 ------------------------------------------------------------- Wolfgang Lipp ## New Entries ################################################# ------------------------------------------------------------- Alternative to os.path.walk http://www.faqts.com/knowledge-base/view.phtml/aid/6000 ------------------------------------------------------------- Daniel Dittmar If you have trouble specifying the correct callback to os.path.walk and would prefer to use an iterator as in for fname in RecursiveFileIterator ('dir1', 'dir2'): process (fname) class RecursiveFileIterator: def __init__ (self, *rootDirs): self.dirQueue = list (rootDirs) self.includeDirs = None self.fileQueue = [] def __getitem__ (self, index): while len (self.fileQueue) == 0: self.nextDir () result = self.fileQueue [0] del self.fileQueue [0] return result def nextDir (self): dir = self.dirQueue [0] # fails with IndexError, which is fine # for iterator interface del self.dirQueue [0] list = os.listdir (dir) join = os.path.join isdir = os.path.isdir for basename in list: fullPath = join (dir, basename) if isdir (fullPath): self.dirQueue.append (fullPath) if self.includeDirs: self.fileQueue.append (fullPath) else: self.fileQueue.append (fullPath) ------------------------------------------------------------- How do I find reference count errors? http://www.faqts.com/knowledge-base/view.phtml/aid/6006 ------------------------------------------------------------- Joseph VanAndel Will Ware (Will Ware posted this on comp.lang.python) Numerous postings to c.l.python, including some of my own, have mentioned the difficulty of debugging memory leaks in C extensions. To old hands this stuff may all be obvious, but we less experienced folk need all the help we can get. This is a helpful trick I've developed using the 1.5.2 codebase. I imagine it would work with the 1.6 and 2.0 codebases as well. The typical problem with memory leaks is mismanagement of reference counts, particularly abuses of Py_INCREF and Py_DECREF, as well as ignorance of the refcount effects of functions like Py_BuildValue, PyArg_ParseTuple, PyTuple/List_SetItem/GetItem, and so forth. The existing codebase offers some help with this (search for Py_TRACE_REFS) but I found it useful to add this function in Objects/object.c, just before _Py_PrintReferences. void _Py_CountReferences(fp) FILE *fp; { int n; PyObject *op; for (n = 0, op = refchain._ob_next; op != &refchain; op = op->_ob_next, /*n++*/ n += op->ob_refcnt); fprintf(fp, "%d refs\n", n); } The difference between this and _Py_PrintReferences is that the latter prints out all objects and their refcounts, in a list that runs many pages. It's obviously impractical to do that at several points in a program that runs in a long loop. But this function will only print the total of all the refcounts in the system, which will allow you to keep track of when you have inadvertently put in something that increases the total refcount every time going thru a loop. In my C extension, I put in the following macros. #if defined(Py_DEBUG) || defined(DEBUG) extern void _Py_CountReferences(FILE*); #define CURIOUS(x) { fprintf(stderr, __FILE__ ":%d ", __LINE__); x; } #else #define CURIOUS(x) #endif #define MARKER() CURIOUS(fprintf(stderr, "\n")) #define DESCRIBE(x) CURIOUS(fprintf(stderr, " " #x "=%d\n", x)) #define DESCRIBE_HEX(x) CURIOUS(fprintf(stderr, " " #x "=%08x\n", x)) #define COUNTREFS() CURIOUS(_Py_CountReferences(stderr)) To debug, I rebuild Python using 'make OPT="-DPy_DEBUG"', which causes the stuff under Py_TRACE_REFS to be built. My own makefile uses the same trick, by including these lines: debug: make clean; make OPT="-g -DPy_DEBUG" all CFLAGS = $(OPT) -fpic -O2 -I/usr/local/include -I/usr/include/python1.5 When I suspect that one of my functions is responsible for a memory leak, I liberally sprinkle it with calls to the COUNTREFS() macro. This allows me to keep track of exactly how many references are being created or destroyed as I go through my function. This is particularly useful in loops where simple mistakes can cause reference counts to grow ridiculously fast. Also, reference counts that shrink too fast (overzealous use of Py_DECREF) can cause core dumps because the memory for objects that should still exist has been reallocated for new objects. ------------------------------------------------------------- Python's big, is there a crisp overview? a quick reference card? a bare bones documentation? http://www.faqts.com/knowledge-base/view.phtml/aid/5976 ------------------------------------------------------------- Wolfgang Lipp, Fiona Czuczman Richard Gruet, rgruet at ina.fr; Chris Hoffmann, choffman at vicorp.com; Ken Manheimer, ken.manheimer at nist.gov; Guido van Rossum, guido at CNRI.Reston.Va.US, guido at python.org; Tim Peters, tim_one at email.msn.com; and the readers of comp.lang.python yes, there is. all of it in one html page, have a look @ http://starship.python.net/quick-ref1_52.html ------------------------------------------------------------- Of what use is 'lambda'? http://www.faqts.com/knowledge-base/view.phtml/aid/6081 ------------------------------------------------------------- Joseph VanAndel Kragen Sitaker - it is useful to bind arguments, e.g. lambda x, y=zz: do_something(x,y) --- which can be passed as a function in place of do_something. - why would you want to make an indirect function call in the first place? The answer to the second is deep. Of course, you don't ever *need* to make an indirect function call; in procedural programming, you can write code like this: if fcode == 1: do_thing_one(x, y) elif fcode == 2: do_thing_two(x, y) else: complain(fcode) And when you add a new fcode value, you just have to go to every if-elif-elif-else switch and add a new branch. This is kind of bad, in that it scatters information about what fcode==2 means all over the place, and it's likely that it would be handier to have it all in one place. (There's a balance, of course. Sometimes what fcode==2 means has more to do with the code the if-elif thing is in the middle of than with the other branches that also happen when fcode==2.) With object-oriented programming, you can do something like this instead: fcodething.do_something(x, y) and rely on dynamic method dispatch to do the right thing. This has the advantage that you can put all the do_something and do_something_else methods together. With functional programming, instead, you say: fcode(x, y) and just use indirect function invocation to do the right thing. Closures (like lambda x, y, z=foo: do_something(x, y, z)) make it possible to store state in an invocable function, which means that functions (closures, lambdas) become equivalent to objects. There are times when functional code --- passing around lambdas --- is clearer, and there are arguably times when object-oriented code is clearer. Functional code seems to me more likely to be more flexible, but that's kind of a fuzzy statement and could be nonsense. Closures are sort of equivalent to objects with a single method. If you want to do multiple methods, you have to use some parameter to decide which one to invoke. This makes it hard to go from a "single-method" function to a "multiple-method" function --- you have to change every call to it. You can do prototype-based "inheritance" by delegation --- call some "prototype" function if you don't understand the requested method. Here's an example, albeit a specious one, since Python has stacks built in: def stack(op, arg, data, prototype): if op == 'push': data.append(arg) elif op == 'tos': return data[len(data) - 1] elif op == 'pop': data.pop() else: return prototype(op, arg) def make_stack(prototype=lambda op, arg: None): return (lambda op, arg=None, data=[], prototype=prototype: stack(op, arg, data, prototype)) >>> x = make_stack() >>> x('push', 3) >>> x('tos') 3 >>> x('push', 4) >>> x('tos') 4 >>> x('pop') >>> x('tos') 3 >>> x('pop') >>> x('tos') Traceback (innermost last): File "", line 1, in ? File "", line 2, in File "", line 5, in stack IndexError: list index out of range >>> x('unknown') >>> def hello(): ... print "hello, world" ... >>> x = make_stack(lambda op, arg: hello()) >>> x('push', 37) >>> x('tos') 37 >>> x('unknown arg') hello, world Just as you can create a lambda that acts like an object, you can create an object that emulates a lambda, simply by creating an object with only one method. Both are kind of awkward. (It gets a lot worse when you start trying to do multiple inheritance with lambdas, closures with objects, etc.) (Also, even without closures, function pointers allow you to simulate objects in languages that really have only structs: C, JavaScript, and Lua come to mind, and of these, JavaScript and Lua have syntactic sugar to make it easier. In C, you have to say things like obj->method(obj, arg).) So both approaches are equally powerful; but both of them are more convenient for expressing certain kinds of algorithms. Lambdas seem to be especially convenient for expressing non-mutative stateless algorithms: map, filter, zip. Objects seem to be especially convenient for writing things with lots of state that can be peacefully extended later on. Lambdas make it possible to have really private attributes, even in libertine[0] languages like Perl, JavaScript, and Python. Well, maybe not in Python --- I don't know it well enough yet, but I wouldn't be surprised if there were a way to get at default argument values ;) In Perl (and, I think, JavaScript), you can use closures to have really private methods, too. This has the unfortunate disadvantage that if the methods are potentially recursive, the closures will have circular references and screw up the reference-counting garbage collection, so you have to deallocate things by hand or leak memory. Sometimes it's clearer to write a function in-line in a lambda, even when you're not binding any data into a closure. "sort" is the usual example; you could define an interface (or protocol) "comparator" consisting of a method "compare" which compared two objects in some user-defined way, and then specify your sort routine to require an object implementing "comparator" which compares objects. This has the disadvantage that the order you want the data in is specified in a different class from the one that wants it sorted, which often means that it's actually in a different file --- by convention or by language requirement. Defining a comparator function is often much easier --- you can usually put it in the same file. But, in many languages, you still have to put it outside of the routine that wants the sorting done --- which means that it's ten, twenty, forty lines away from the sort call. Being able to write the function in-line in a lambda keeps related things together and unrelated things apart, which makes your code easier to read, easier to write, easier to find bugs in, and easier to improve. ------------------------------------------------------------- How do I handle command line args with gnome? http://www.faqts.com/knowledge-base/view.phtml/aid/6117 ------------------------------------------------------------- Joseph VanAndel frederic.gedin at free.fr You need to remove from sys.argv the options you processed before invoking the command line option parser from gnome. E.g: import sys,getopt usageStr =\ """-i input_dir [-o output_dir] -r [-- gnome_args] -r specifies real_time mode (default is batch processing) """ # we have to parse arguments before importing gnome.ui, which also wants # to parse arguments. if __name__ == "__main__": global optlist try: optlist, args = getopt.getopt(sys.argv[1:], 'i:o:r') except: detail = sys.exc_info() print detail[0], detail[1] print __doc__ print 'usage : %s %s' % (sys.argv[0], usageStr) sys.exit(-1) # pass remaining arguments to gnome.ui sys.argv = list((sys.argv[0],)) for a in args: sys.argv.append(a) from gnome.ui import * from gtk import * from gnome.config import * # Applications arguments can now be processed from 'optlist'. From skodela at my-deja.com Fri Oct 20 09:16:01 2000 From: skodela at my-deja.com (Sindh) Date: Fri, 20 Oct 2000 13:16:01 GMT Subject: Import problem Message-ID: <8spgic$1p6$1@nnrp1.deja.com> Hi folks How can I import a module by giving a name of list elements. Eg: for n in os.listdir('.'): import n but it fails. Can anyone find where I am going wrong. It says 'no module called n'. Thanks sreekant -- A man needs to sleep for 36 hours a day atleast. Sent via Deja.com http://www.deja.com/ Before you buy. From chris_barker at my-deja.com Thu Oct 19 13:51:16 2000 From: chris_barker at my-deja.com (chris_barker at my-deja.com) Date: Thu, 19 Oct 2000 17:51:16 GMT Subject: scanf in python...? References: Message-ID: <8sncag$b3l$1@nnrp1.deja.com> In article , > Soapbox mode: FWIW, I think there is a significant disparity between > Python's data input and output facilities. It has good output formatting, > but nothing comparably concise for input. I often have to write one-off > programs to process large amounts of tabular output from other programs, > usually a mixture of floats and ints, with the occasional string for good > measure. Having to write a pile of tedious code to parse this sort of guff > is irritating, considering the relative ease with which you can accomplish > other things in Python. Still, few people seem to complain about this, so I > guess it's not a common issue. Well, it's a common problem for me! (and I'm sure a lot of other people). Common enough that I'm very close to writing a C extension to deal with the problem. There have been discussions about this in the past, and I think there may be a FAQ on it. I believe Guido's response was that the string and re modules are much for flexible than *scanf, so you should just use those. Frankly, I think that's not a vey "Pythonesque" approach. In Python, there should be an easy and obvious way to do things that are very common (fast would be nice as well). If I wrote something now, I would probably do something simple, modeled after MATLAB's "fscanf". MATLAB's fscanf (it has an sscanf as well, BTW) is really just a simple extension of C's fscanf. The extension is that it is "vectorised". what it does is keep repeating the format specifier until either: 1) the end of file is reached, or 2) you have filled the size matrix that you specified. Some examples: V = fscanf(file,'%g') # to create a vector with all the numbers in file (whitespace delimited). M = fscanf(file,'%g',[m,n]) # to create a m by n matrix with the next m*n numbers in file. M = fscan(file,'%g',[m,inf]) # to create a m by ? matrix with all the numbers in the file. Note that it starts at the current position in the file, and leaves the position in place when it is done, so different calls can be combined easily to read a large variety of text file formats. MATLAB only stores matrixes of C doubles, so it's a little easier than it would be for Python. For my purposes, I would probably just have it create Numpy arrays, since that's usually what I need if I am reading a lot of numbers from a file. If anyone is interested in helping me with this project, I would love to get input, and hopefully coding, testing and debugging help. Send me a note if you are interested -Chris cbarker at jps.net Sent via Deja.com http://www.deja.com/ Before you buy. From junaftnoon at nospamplzyahoo.com Mon Oct 23 02:15:34 2000 From: junaftnoon at nospamplzyahoo.com (June Kim) Date: Mon, 23 Oct 2000 15:15:34 +0900 Subject: All combinations of a list References: <39F1FB22.6E9246E7@cs.utwente.nl> <39F393B5.A978CC9D@cs.utwente.nl> <9nNI5.110763$g6.50159527@news2.rdc2.tx.home.com> <8t08bb$lnvu5$1@ID-11957.news.cis.dfn.de> <8t0g73$lse00$1@ID-11957.news.cis.dfn.de> Message-ID: <8t0l2n$j6h$1@news.nuri.net> Just for a brain-exercise, I changed the problem into "of combinations." def comb(list): if len(list) ==0: return [[]] return [ [[list[0]],[]][i]+c for i in (0,1) \ for c in comb(list[1:]) ] Can anyone do this in different ways, still using recursion? (I guess mapping would work here) I'm waiting for your comments. Best Regards, June "Emile van Sebille" wrote in message news:8t0g73$lse00$1 at ID-11957.news.cis.dfn.de... > def perms3(list): > return [[[list[i]] + p for i in range(len(list))\ > for p in perms3(list[:i] + list[i+1:])],[[]]] [not list] > > This one works, ugly as it is. Now, if the items are Might look ugly, but very clever! Thanks for your tip. > reversed so that the empty list is element 0, is there a way > to return either a 0 or 1 other that 'not not list'? > > > > -- > > Emile van Sebille > emile at fenx.com > ------------------- > > > From dale at out-think.NOSPAMco.uk Fri Oct 27 13:09:40 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Fri, 27 Oct 2000 18:09:40 +0100 Subject: PythonWin IDE sucks! References: <7tuivs46osods22uumpvsvsap2jocrd4si@4ax.com> <39F9AEEB.BF985F00@gssec.bt.co.uk> Message-ID: Alan Gauld wrote: >Dale Strickland-Clark wrote: >> This is such a huge irritation and time waster for me that if it isn't >> sorted out I can't really consider Python for future large projects. > >What has the Pythonwin IDE got to do with using Python? > >> To test a module, I import it into PythonWin using the Import/Reload >> button and then instantiate a class in the Interactive Window. > >How are you importing? Using the Import/Reload button on the toolbar, which is the same as File -> Import or CTRL-I > You did notice that reload only >works if you use: > >import foo > >Whereas > >from foo import * > >will make reload ineffective. >That's a python limitation not a pythonwin fault. > >> After a failure, I fix the offending code and Import/Reload again. >> However, the same failure occurs showing the original line with it's >> original contents. The changed module hasn't been loaded. > >Did you delete the class instance and create a new one after >the reload? The original is still running the original >code... (I think!) In this particular case, no class was instantiated owing to a bug in the code. > >> The only way to fix it is to quite and reload PythonWin >> but then you have to arrange windows, reestablish >> breakpoints and watches, etc. and it all takes far too long. > >Too long compared to what? We have a 4 hour compile cycle >on one of our current C++ projects.... by comparison >working with python is a joy! :-) Compared to not. This is the ONLY IDE I've used that can't handle buggy code. (I've used, VB, Visual Studio, Delphi to name a few.) > >What other environment do you use that allows you to >load new module files into a running process? See list above. > > >BTW Have you tried IDLE? Only briefly. Is it likely to improve matters? I'll see if I can work with it. >What happens if you use the command line interpreter? I do for most trial runs owing to problems described but sometimes I want to have an interactive nose around. It's also useful to have a preserved program state after an error. >And what version of Pythonwin? There was a buggy version >about a year back. (was it winall version 125?) 133 > >Alan G. -- Dale Strickland-Clark Out-Think Ltd Business Technology Consultants From ajs at ix.netcom.com Sun Oct 1 03:03:43 2000 From: ajs at ix.netcom.com (Arthur Siegel) Date: Sun, 1 Oct 2000 03:03:43 -0400 Subject: JPython Status References: <39D6B498.F6003C1D@computer.org> Message-ID: <8r6pck$etk$1@nntp9.atl.mindspring.net> > Sometimes I have noticed that people spend a fair amount of > effort building something in or for Python, when they could have gotten > it for free via JPython and a Java package or two. Amen. I use the example of Python and graphics, particularly 3D, only because that happens to be a playpen for me. The Java resources one can tap from JPython are vast, but never seem to get mentioned much when the general subject comes up in Python circles. Type in Java on the Sourceforge search - and understand you can be writing Python against almost anything on the pages and pages of projects that pop-up. JPython needs some work. But why ain't it the killer Python in the end? From see at my.signature Thu Oct 5 21:36:18 2000 From: see at my.signature (Greg Ewing) Date: Fri, 06 Oct 2000 14:36:18 +1300 Subject: How can you copy (clone) a string? References: <39DC7491.3F7137C0@student.gu.edu.au> Message-ID: <39DD2C92.9630F192@my.signature> Joal Heagney wrote: > > However, I don't understand it > all, because when you just create the strings as follows: > >>> a = 'aa' > >>> b = 'aa' > >>> c = 'aa' > >>> d = 'aa' > >>> id(a), id(b), id(c), id(d) > (134879088, 134879088, 134879088, 134879088) In the interests of speed, the strings used internally to hold the names of variables, attributes, etc. are "interned" (i.e. stored uniquely in a table). The compiler also does this to string constants that you write into your code, such as 'aa' above, in some cases, both to save space, and just in case you want to use one in a getattr call or something like that. However, this is not done for strings that you compute at runtime in some way. That would take a lot of time for hardly any benefit, since it's extremely rare to use a computed string as a variable name. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From aleaxit at yahoo.com Fri Oct 27 09:07:19 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 27 Oct 2000 15:07:19 +0200 Subject: C's syntax (was Re: Python Formatted C Converter (PfCC)) References: <8t0or303ee@news1.newsguy.com> <39F4FFB7.452EDDEC@alcyone.com> <8t3mdv025uo@news2.newsguy.com> <39F5B404.B5626FB7@alcyone.com> <8t4q8v11lpv@news1.newsguy.com> <39F5E620.C780A71C@seebelow.org> <8t6vj70spd@news1.newsguy.com> <39F73E41.C8EE143F@seebelow.org> <8t8sgn0ahc@news1.newsguy.com> <39F8985B.6909B5CF@seebelow.org> Message-ID: <8tbv0r01082@news1.newsguy.com> "Grant Griffin" wrote in message news:39F8985B.6909B5CF at seebelow.org... [snip] > Like the people who responded to that thread, I guess I'm kindda > suspicious of people who brag about their amazing abilities and > accomplishments. First, my experience has been that those who actually > accomplish the most tend to brag the least. (Anybody remember hearing I think it's a cultural issue. Many cultures follow, to some extent, the pattern you describe: those cultures' members are encouraged or even strongly pressured to verbally downplay their status, accomplishments, etc. I'm sure you can easily think of (e.g., Oriental) cultures where this holds to an even stronger degree than in yours. Cultures that do not share this trait much may even see this as hypocrisy. The contrast is striking in the Arthurian cycles, where heroes depicted as close to the roots of Celtic and German pagan cultures "brag", and are often placed in a clash with knights displaying the "proper" Christian attitude of "humility" (indeed, "downplay your status so that others by contrast will praise you" is the literal lesson of one Gospel parable -- see what I mean about this being "seen as hypocrisy"?-). Or, to take a well-documented historical period, look at the very-late Roman Republic: neither Cicero nor Caesar had compunctions about bragging about their accomplishments, but the latter slyly managed to do it *in the third person* (in the De Bello Gallico; elsewhere, he _was_ prone to using first-person, as in, "I came, I saw, I conquered":-). Octavian, even slyer, got _others_ to praise him instead. We see the hints here of a transition-period, between it being socially all right to brag, and a later preference for "humility". Then, there is an issue of context. Suppose you happen to be very expert about, say, skiing. Some clueless guy makes a remark, on an unrelated forum, about skiing -- one so deeply and utterly wrong, as you feel thanks to your specific expertise, as to need being intensely rebutted. You do so. CG reacts by strongly implying that the only people who disagree with that remark are "those who don't like skiing". So: are you going to reinforce your rebuttal, by letting it be known to all readers that, far from "not liking skiing", you ARE an expert in it -- or are you going to let hypoc^H^H^H^Humility stand in the way of delivering a clear, sincere, and explicit message? > Guido brag? No!!!) Second, my experience has been that those who brag > the most tend to have accomplished the least. This seemed strange to me > at first, but it actually makes perfect sense: true accomplishments brag > for themselves, so no bragging needs to be done; however, for those who Not necessarily: it depends on context -- see above. How is anybody outside my firm going to know that I was the one who introduced C here, and taught several courses about it, for example, unless I tell them? *HOW*, exactly, is THAT "accomplishment" going to "speak by itself" to rebut the idiocy of the CG trying to lump me in with "those who don't like C"? The same book, above-mentioned, that suggests "seating at the foot of the table", also has harsh words against those who, having a lit lamp, hide it under a bushel...:-). If you're trying to psychoanalyze yourself to explain why you react badly to anything that looks to you like "bragging", then the above paragraph is probably quite perceptive. I just hope you don't take this self-analysis as a *rational* or *defensible* argument in the case at hand. > of this about 5 years ago.) The bragging usually impresses people at > first, but then one invariably discovers "the man behind the curtain". > (FYI: That was from "The Wizard of Oz".) I'm reasonably familiar with Baum's novels, and Fleming-and-others' movie, thanks (and I don't think the implied parallels in your quoting in this context make much sense, but that's another issue). > But that being said, seriously: the considerable accomplishments you > listed are probably entirely accurate; the fact that you share them with > all of comp.lang.python probably defies my generalization above. "All generalizations are suspect" (self-referential quote alert). > > Sorry, I'm a specialist in everything _except_ TV, > > TV is one of the good things in life. Live a little. :-) I'm visually challenged enough that the contents of what I view on-screen had better be worth the ocular effort (computer screens are different, as I can enlarge the font at need). Six+ hours of TV viewing per day, which I'm told is the US population average, is well beyond what my eyes can stand, even if my mind could. > Just for the record, Backus also played "Mr. McGoo"--athough one can't I'll trust you on this. Like many people with even mild physical disabilities, and like anybody with decent empathy, I have a hard time understanding what's supposed to be fun in sight-impairment. Alex From jacobs at darwin.epbi.cwru.edu Mon Oct 16 17:10:49 2000 From: jacobs at darwin.epbi.cwru.edu (Kevin Jacobs) Date: 16 Oct 2000 21:10:49 GMT Subject: Some Q&A with Kahan on IEEE 754 References: Message-ID: <8sfqsp$14e$1@slate.INS.CWRU.Edu> Huaiyu Zhu wrote: > In the past few days I asked Prof Kahan several questions about IEEE 754. I'm glad to see that Dr. Kahan's opinions are in line with what _everyone_ here wants. I am drafting a PEP and reference implementation that embodies these ideas and goals: 1) Support for setting and testing special IEEE 754 floating-point values (i.e. NaNS, NaNQ, Inf, denormals). 2) Flexible delivery and recovery from floating point traps: These will be deliverable as Python exceptions, handled by a user-specified Python function or queried by sticky status bits. All options will be setable, maskable, and mergeable at runtime. 3) A reasonable default set of IEEE 754 traps enabled. Current plan: Invalid OP, Divide-by-zero, and overflow. 4) Rounding mode and precision control if supported by the platform. 5) Thread specific handling of traps with creation-time inheritance of settings. 6) Integration with Numeric Python, MatPy, and other common numerical extensions via sensible additions to the Python and C APIs. 6) A practical software-only emulation of some of these features for non-IEEE754 systems that doesn't kill performance. 7) Available in the Python 2.1 time-frame, assuming consensus can be reached, problems solved, and damsels saved. Of the many issues to be resolved, here are a few things to consider: 1) Handling of signaling NaNs. This can get expensive since it involves a test every time a floatobject is used or requires mucking about with signal handlers. 2) Speaking of signal handlers, Tim Peters stated that returns are not allowed from sIGFPE handlers. I have yet to see this restriction in any platform documentation. What is the deal? 3) Thread support -- Python threading will have to know about per-thread floating point data-structures. There are also implications for uthreads. 4) I am going to need help implementing support for many of the commonly used Python platforms. I have access to Windows 95/98/NT/2000, Compaq/Digital Unix, AIX (Power3), IRIX, Linux (i386+glibc2.1+), and Solaris. Edward Jason Riedy has offered to help with AIX, Linux, Solaris and Unicos/mk. We still need volunteers for the following: Windows OS/2 BeOS VxWorks OpenVMS QNX Others? Speak now! Just a few comments: > [Huaiyu Zhu] >> 2. Enable IEEE whenever possible. Each f.p. exception produces a Python >> exception, which would halt the program unless trapped and handled. [Dr. Kahan] > This is an option worth integrating with a debugger, but it must not > be the default. Do you really wish to see Python programmers trying > to program their own trap handlers? Actually, I do want to see Python programmers programming their own trap handlers... in Python! It'll be slow, but very much in line with the dynamic nature of Python. ;) > [Huaiyu Zhu] >> 4. Enable IEEE whenever possible. Let a special module contain all the >> flags, without changing program flow. Programers could choose to >> examine these flags or choose to ignore them. [Dr. Kahan] > Yes; and provide quick and convenient ways to save-and-restore and > merge exception flags. Other facilities should be provided too, but > I cannot spare the time just now to discuss them in detail. I think the problem here is in the definition of "Enable IEEE". Your meaning seems to be "Enable IEEE" == "Enable all/some IEEE 754 traps". My meaning, and I believe the standard one is "use features available in conforming IEEE 754 implementations." This is, by necessity, a superset of the generic C floating point support (with a few notable, but minor exceptions). > [Huaiyu Zhu] >> The current problem with IEEE 754 support in Python is that, at least as >> it is perceived, there is no general way to turn it on on every >> 754-enabled platform and expect to obtain the same kind of signalling, >> etc. Yes and no. No, there is no general way to support IEEE 754 in Python. Its still a bloody mess in terms of APIs. However, I think there is much we can do to provide as much as possible, for as many platforms as possible, in the near future. > [Huaiyu Zhu] >> Another problem is that the leading authorities of the language plan to >> unify the behavior in such a way as to raise exceptions for Overflow, >> Divide-by-Zero, Invalid Operation, while letting through Underflow and >> Inexact Operations. They consider this as an interim step toward full >> IEEE 754 support. Since Python exceptions have to be caught, this would >> make life extremely difficult for vectorized computations during this >> period. In the short term, i.e. Python 2.0, yes. Its simply not feasible to do all that is necessary (not the least of which write a PEP, implement it and test for n platforms) before Python 2.0 goes out. While important, this isn't important enough to even consider delaying 2.0. I look forward to working with you to address these issues (then I can get back to working on statistical extensions to Python -- my real goal for all this silliness!) Regards, -Kevin Jacobs -- -----------> Kevin Jacobs <-----------|-------> (216) 778-8211 <-------- Informatics Consultant | Department of Epidemiology Primary mail: jacobs at theopalgroup.com | & Biostatistics Alternate mail: jacobs at darwin.cwru.edu | Case Western Reserve University ---------------------------------------------------------------------------- From glandrum at my-deja.com Wed Oct 25 09:51:13 2000 From: glandrum at my-deja.com (Greg Landrum) Date: Wed, 25 Oct 2000 13:51:13 GMT Subject: Newbie question: WinNT Python 1.5.2 - import seems not to work the way I expect References: Message-ID: <8t6oge$951$1@nnrp1.deja.com> In article , "Parzival" wrote: > I am running Python 1.5.2 on Win NT 4.0. > > I am trying to explore the "dopy" distributed object module, and the modules > fail with import errors. I tried to reduce this problem to its simplest > manifestation, and found that I got one result in IDLE, and another running > my test module from the command prompt. The contents of "dopy" directory > are: > > F:\Program Files\Python\dopy>ls > Manual.html __init__.py dopy.pyc naming.pyc tb.pyc > Manual.nml __init__.pyc dopyclient.py pos.py tcp.py > README.html backup dopyserver.py pos.pyc tcp.pyc > README.txt dopy.py naming.py tb.py testimp.py > > The test script "testimp.py" reads: > > import sys > print sys.path > from dopy import tcp > > The output of the script (the news client may split the lines): > > F:\Program Files\Python\dopy>testimp.py [snip] > Traceback (innermost last): > File "F:\PROGRA~1\Python\dopy\testimp.py", line 3, in ? > from dopy import tcp > ImportError: cannot import name tcp > Because you are running this from the dopy directory, Python is finding the file dopy.py before it finds the package dopy. So it imports dopy.py, which has no name tcp defined. If you copy your test script to another directory and run it there, it should work. > When running the Python command prompt, the same commands produce the > following output: [snip] > > I.e. the commands found in the script succeed. I'm guessing that you did not start Python in the dopy directory. If you had, you would have encountered the same error. > When I load testimp.py in the IDLE editor, and run it I get: > [snip] > > I.e. the script also succeeds. So, my question is why do I get this > import failure when running testimp.py from the command prompt? > Same reason, Idle is not running from the dopy directory. An aside: Thanks for providing so much information in your question, it really made it easier to come up with an answer! I hope this helps, -greg Sent via Deja.com http://www.deja.com/ Before you buy. From Roberto at lupex.net Wed Oct 18 06:40:40 2000 From: Roberto at lupex.net (Roberto Lupi) Date: Wed, 18 Oct 2000 12:40:40 +0200 Subject: Using functions to reduce code. References: <39EC7F1C.3805E714@hotmail.com> <8si4ka$a5f$1@netserv.univ-lille1.fr> Message-ID: In article <8si4ka$a5f$1 at netserv.univ-lille1.fr>, dcalvelo at pharion.univ-lille2.fr says... > Not knowing the exact structures you have, I removed the temp variables, > which may be useless. The code of the original poster, suspiciously looked as processing objects in a ZODB database. If this is the case, removing the temp variables, would prevent the updated objects to be written back in the database. -- Roberto Lupi From bob at wildthink.com Sun Oct 8 17:14:20 2000 From: bob at wildthink.com (Robert Hicks) Date: Sun, 08 Oct 2000 21:14:20 GMT Subject: Python2.0 beta 2 on MacOSX/Darwin References: Message-ID: Very cool! : ) > From: Henry Feldman > Newsgroups: comp.lang.python > Date: Sun, 08 Oct 2000 18:38:45 GMT > Subject: Re: Python2.0 beta 2 on MacOSX/Darwin > > Not yet. Once somebody posts a binary, it will be much easier. However, we > are still attempting to debug the build process. > > -- > Henry Feldman, '2001 > NYU School of Medicine > > From ge at nowhere.none Mon Oct 2 12:01:53 2000 From: ge at nowhere.none (Grant Edwards) Date: Mon, 02 Oct 2000 16:01:53 GMT Subject: A Tkinter status/information bar References: <39D47332.FF0B1907@stud.cs.uit.no> Message-ID: In article , Andrew Markebo wrote: >I just use standard Entries set to readonly.. Why use an Entry instead of Label? -- Grant Edwards grante Yow! Okay... I'm going at home to write the "I HATE visi.com RUBIK's CUBE HANDBOOK FOR DEAD CAT LOVERS"... From aleaxit at yahoo.com Thu Oct 19 06:07:37 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 19 Oct 2000 12:07:37 +0200 Subject: Lambda Forms Question References: <39EE3CC1.E2B07AB7@drew.edu> Message-ID: <8smhfq01i02@news1.newsguy.com> "Scott Weisel" wrote in message news:39EE3CC1.E2B07AB7 at drew.edu... > I'm working with Python on a school project and while I was reading the > documentation I was quite surprised to find out that Python has some > features of Lisp. Why surprised? "Every language wants to be Lisp"...:-). > Since we're using Scheme, a variant of Lisp in class, I > was hoping to use the Lisp feature in Python, but I'm having trouble > implementing it. > > The example that the online documentation gives is > def make_incrementor(n): > return lambda x, incr=n: x+incr > which returns a function. Is there any way to write the program so a value > is returned, rather than a function. A function IS a value. That's the whole point of higher-order functions such as this one -- returning a constructed function as their result. Perhaps you can clarify how you would want to call the result-function...? > Also, how do I write the functions by themselves. I wrote > lambda x: x*x > but I have no way to call it. You can call it contextually: >>> (lambda x: x*x)(4) 16 or you can give it a name, and "call the name": >>> square = lambda x: x*x >>> square(5) 25 which is (of course) quite nearly equivalent to: >>> def square1(x): return x*x >>> square1(6) 36 but not quite...: >>> square.func_name '' >>> square1.func_name 'square1' the function-object built via lambda does not know its name, while the one built via def does. You can also put the reference to the function object (built in either way) in any other 'slot' you please: >>> mylist=[] >>> mylist.append(lambda x: x*x) >>> mylist[0](7) 49 >>> mydict={} >>> mydict['foo']=lambda x: x*x >>> mydict.get('foo')(8) 64 etc, etc. Really, a function-object is a first class citizen, you can build one (with limitations) with the lambda syntax (or with def, or with new.function...), you can refer to it in any way you please, and you can call it (directly, via apply, via map, etc) by fetching back that reference in whatever appropriate way. Alex From no at spam.com Fri Oct 13 16:57:51 2000 From: no at spam.com (Phlip) Date: Fri, 13 Oct 2000 13:57:51 -0700 Subject: Status (was Re: ANNOUNCE: PySymbolic - ...) References: <8s6c8g022ph@news1.newsguy.com> Message-ID: > *** I started to create a list for TODO. See the `Help needed' section on > the homepage. Contributions and comments are most welcome. > > Regards, > Pearu Any chance this could emit MATHML output? -- Phlip ======= http://users.deltanet.com/~tegan/home.html ======= From pete at visionart.com Tue Oct 31 18:46:29 2000 From: pete at visionart.com (Pete Shinners) Date: Tue, 31 Oct 2000 15:46:29 -0800 Subject: garbage collection could force destructors? Message-ID: <8tnlim$34n$1@la-mail4.digilink.net> the talk about destructors got me thinking. now that garbage collection is a base part of python2, does that make it possible to define some behavior for object destructors? i know before there were many cases where an object might never be deleted, so is was impossible to guarantee the destructors. now with garbage collection, it seems all objects could be caught and destructed in a logically-defined order. is this possible? i haven't dug to deep to understand the gc, but if it is now possible to do something about this, i think everyone would be better off. From tyler at tylereaves.com Tue Oct 24 12:52:31 2000 From: tyler at tylereaves.com (Tyler Eaves) Date: Tue, 24 Oct 2000 16:52:31 GMT Subject: python snippet request: calculate MD5 checksum on 650 MB ISO cdrom image quickly References: Message-ID: <39f5be27.12343093@news.geeksnet.com> Do you really need to checksum the whole file? Maybe try checksuming the first k of every MB, or something along those lines? On Tue, 24 Oct 2000 12:39:51 -0400, "Warren Postma" wrote: >I am writing some python scripts to manage downloading (and re-downloading) >ISO images from FTP mirrors, and doing MD5 checksums on the received files >to make sure they are intact. > >I noticed that there is an MD5 message digest module in Python. But it only >accepts STRINGS. Is there some way to pass a WHOLE FILE to it, less >awkwardly than having a WHILE loop that reads 1k chunks and passes it along >to the MD5 module. > >A new function in the md5 module, md5.md5file(filename) would be nice, if >anyone is listening, for a future python 2.x release. > >I'll contribute a patch if anyone thinks it's a good idea. > >If there's already a one-to-ten line method that doesn't involve iterating >(SLOWLY) over chunks of the file that got loaded into Strings that would be >great. > >My current method is to use os.popen("md5 "+filename"), which then spawns a >command line md5 utility, which seems to me to be kind of wasteful and slow. > >Warren Postma >ZTR Control System > > --- Tyler Eaves Visit Ultra Coaster Central! The internet's largest repository of Ultra Coaster Tracks! http://www.ultracoastercentral.com -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From alain at onesite.org Mon Oct 16 02:37:13 2000 From: alain at onesite.org (Alain TESIO) Date: Mon, 16 Oct 2000 08:37:13 +0200 Subject: Charsets Message-ID: Hello, I'd like python to support some other charsets, how can I do it ? I'm using the mimify module, and it looks like the charset "ISO-8859-15" isn't supported, unmimify doesn't change the message. I'm using s=string.replace(s,"ISO-8859-15","ISO-8859-1") and then it works as they are similar but there must be a better solution. Alain From lss at excosoft.se Mon Oct 2 06:01:14 2000 From: lss at excosoft.se (lss at excosoft.se) Date: Mon, 02 Oct 2000 10:01:14 GMT Subject: Runtime error importing extension modules Message-ID: <8r9mda$9gs$1@nnrp1.deja.com> I have a problem with PYDs in an application using Python as an embedded scripting language. In this case, the application and Python are statically linked together into a single executable. To get this to work, I had to remove definitions of USE_DL_EXPORT and USE_DL_IMPORT and other DLL-related preprocessor macros. Now, however, each attempt to import a PYD results in a runtime error. Does anyone have any pointers on how I may link Python together statically with a C++ application and yet retain the the ability to import dynamic extension modules? Is USE_DL_IMPORT or USE_DL_EXPORT necessary for this, and if so, how can I have them without compromising the ability to link Python statically? Thankful for assistance, Ludvig Svenonius Excosoft AB +46(8)6332958 ludvig at excosoft.se / dominio at hem.passagen.se Sent via Deja.com http://www.deja.com/ Before you buy. From stianh at ifi.uio.no Wed Oct 25 04:04:46 2000 From: stianh at ifi.uio.no (Stian Husemoen) Date: 25 Oct 2000 08:04:46 GMT Subject: Scripting SSH with Python References: Message-ID: Lenny Self wrote: >help. When I make the SSH connection I am prompted to enter a password... >my problem is that I don't know how to look for this promt and have the >script submit the password for me. Can anyone give me some help on this. > >I have been experimenting with os.popen and os.popen3 but I am either >looking in the wrong spot or I am not doing it correctly. > >Any help would be greatly appriciated. SSH needs to speak to a pty if I remember correctly. It dies on you if it don't. You have to use the pty package. I did something like this a while back, but I can't seem to find my old code, so I can't give you an example, sorry. -- Stian Husemoen From johnvert at my-deja.com Sat Oct 7 22:49:11 2000 From: johnvert at my-deja.com (johnvert at my-deja.com) Date: Sun, 08 Oct 2000 02:49:11 GMT Subject: Integer multiplication overflow. Message-ID: <8ronb6$75e$1@nnrp1.deja.com> Hello, I wrote the following simple recursive factorial function in python: def fact(num): if num < 2: 1 return num * fact(num - 1) When I run it, I get the following: >>> fact(3) 6 which is correct, but if I use something slightly larger: >>> fact(15) Traceback (innermost last): File "", line 1, in ? File "", line 3, in fact File "", line 3, in fact File "", line 3, in fact OverflowError: integer multiplication Why is that? If I compare this with the Scheme equivalent: (define (fact num) (if (< num 2) 1 (num * (fact (- num 1))))) and run it with MzScheme, I can do: > (fact 15) 1307674368000 > (fact 20) 2432902008176640000 and even, > (fact 154) 30897696138473508879585646703632404659201907040888820477871589289865505687886666220300447285640952619071680544337494109264649994680187591361311072737951454695525676891035640863743200899694758450943586711068571022031011228320107310612480000000000000000000000000000000000000 So why does python choke (pun intended) on a slightly large multiplication? I know it's not meant to be very numeric (although I hear it's capable of a lot with the Numeric package,) but the factorial of 15 is trivial. Thanks a lot, -- john Les python newbie Sent via Deja.com http://www.deja.com/ Before you buy. From peter at engcorp.com Thu Oct 26 22:56:04 2000 From: peter at engcorp.com (Peter Hansen) Date: Thu, 26 Oct 2000 22:56:04 -0400 Subject: Zope question: collaborative environments? References: <39F8C8EC.EB2DC75D@UTS.Itron.com> Message-ID: <39F8EEC4.76941E04@engcorp.com> Tom Bryan wrote: > I'm a developer, and I'd like to create a combination discussion board, > bug tracking system, and general collaborative environment. I was > thinking of using Zope, but I have never even looked at Zope. Am I crazy > even to consider using Zope when we won't have any dedicated staff to > develop stuff for/in Zope and maintain it? Is Zope easy enough to use, > simple enough to maintain, and complete enough as a product that I could > get something set up with just a couple of weeks of work and then simply > use it? Short answer: NO! Note the !. Don't go there. Tell your boss to get a clue about the length of time it would take to even *specify requirements* for such a system, let alone design, build, test, and launch it in a couple of weeks. Longer answer: No! Been there, considered that. So has Digital Creations, I think. There's lots of us working at using Zope for exactly the above sorts of applications (NOT all tightly integrated... that goal went out with Win 3.1) and we have no plans to turn to anything else. It is very suitable in many ways for those things and more. On the other hand, it has a *steep* learning curve, and becoming as productive as Zope promises to be will take more than a couple of weeks. We've been learning for several months and only now have gotten past using a very simplistic Portal and a Wiki (220 pages and growing) for a group of ten. And we now have one dedicated staff member on this project, though I'm sure a small group could use it effectively with only 20-40% of one person's time dedicated. > Any advice before I waste a lot of time digging into this topic would be > much appreciated. (The time frame is very tight. My boss is planning to > lend me one of his personal machines to play put on my network at home as > a zope or sourceforge or ??? server so that I can evaluate it next week. > He definitely wants something in place in the next few weeks.) I agree with the other poster: your boss is (IMHO) an inexperienced, optimistic dolt if he thinks anything can solve his problems in a couple of weeks. Tell him to re-read Brooks on the topic of Silver Bullets. On the other hand, if he is willing to face reality and take a gamble, I would recommend he look closely at Zope *anyway*, and consider using it for a simpler, less grandiose support environment while he takes the time to *really* evaluate it and his own needs (which sound ill-thought out), and over time dedicate at least a fraction of somebody's time to improving and developing it. We have a lot of faith in Zope's future, and I recommend it on that basis. But it won't take a few weeks to get what you want! -- Peter Hansen From paulp at ActiveState.com Fri Oct 27 16:03:14 2000 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 27 Oct 2000 13:03:14 -0700 Subject: PythonWin IDE sucks! References: <7tuivs46osods22uumpvsvsap2jocrd4si@4ax.com> Message-ID: <39F9DF82.1E51FA26@activestate.com> Dale Strickland-Clark wrote: > I've just received this by email: [message from me] > If you want to have a go at me, please have the balls to do it on the > original forum. Longtime readers of python-list will know that I have no problem with balls. I do have a problem with long drawn-out flamewars about non-technical subjects. Actually, I tend to prefer that people flame me in private rather than bother the list. Dale Strickland-Clark wrote: > This newsgroup has to get the prize for some of the fragile, sensitive > egos on the net. If the polite tone of comp.lang.python offends you then you know where you can go. Am I doing better now? Paul Prescod From sdm7g at virginia.edu Wed Oct 25 01:17:35 2000 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Wed, 25 Oct 2000 01:17:35 -0400 (EDT) Subject: [Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich , comparison In-Reply-To: <39F6639E.B74867EE@home.com> Message-ID: On Wed, 25 Oct 2000, Donald O'Donnell wrote: > Correct, that's called operator overloading, a form of polymorphism. > I've seen postings in the past where someone has complained about > the fact that 5/2 results in 2. I can't, for the life of me > understand why anyone would want it to be otherwise. Every > main-stream language I've ever used (Fortran, COBOL, Basic, > C, C++, Java,...) have all truncated the result of integer > division to an integer, and that can be very useful. Well -- again those are all statically typed languages where variables have a fixed type. ( Not sure if modern Basics still fit that catagory -- they did in the old days when I last used Basic. ) Among dynamically typed languages, Lisp and Scheme return either floats or rationals. Don't know offhand about Smalltalk. I can't recall S+ and I don't know Matlab, but I would be surprised if they didn't follow Lisp. > Try writing > a binary search (where you are constantly dividing your > range by 2) -- not much fun if the interpreter/compiler keeps > secretly changing your integer indexes to floats every time you > have an odd sized range. If you really want a floating point > result in the above example, all you need to do is use a/2.0 > -- see, you are in control this way, not the compiler It's not much fun it the interpreter/compiler keeps secretly truncating correct answers to incorrect ones every time your args aren't evenly divisible. If you really wanted it truncated, all you need to do is use floor/ceil/int. ( Works fine for binary searches too! ) ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- "All operating systems want to be unix, All programming languages want to be lisp." From aahz at panix.com Mon Oct 2 12:12:33 2000 From: aahz at panix.com (Aahz Maruch) Date: 2 Oct 2000 09:12:33 -0700 Subject: Why bother with 1.6? References: <39d8510d@news.xtml.co.uk> Message-ID: <8rac5h$sk5$1@panix2.panix.com> In article <39d8510d at news.xtml.co.uk>, Nick Trout wrote: > >Since Python 2.0 b2 is out, why bother with Python 1.6? Why not just wait >for Python 2.0 final? That is exactly what you should do. 1.6 has bugs that are fixed in 2.0. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 There may or may not be a smiley above. --Aahz From donn at u.washington.edu Fri Oct 27 15:08:32 2000 From: donn at u.washington.edu (Donn Cave) Date: 27 Oct 2000 19:08:32 GMT Subject: Compiling Python on multiple platforms... References: Message-ID: <8tcjrg$3qs6$1@nntp6.u.washington.edu> Quoth Bjorn Pettersen : | I'm about to start compiling Python on a number of *nix systems | (Solaris,HPUX,AIX,True64,IRIX,Linux). To make matters more interesting | I'm only making these to the point where our sysadmin can say "make | install" (they're so sensitive about the root password ;-) | | Question 1: We'll be doing some xml work. Do I need to download and | compile expat seperatly, or does it come with the Python 2.0 tarball? | | Question 2: Are there any of the above platforms where readline doesn't | work? | | Question 3: Are there any of the above platforms where Tkinter doesn't | work? (is this a separate install?) | | Question 4: Are there any of the above platforms where PIL doesn't work? | | Question 5: I'm hoping to have _one_ source installation, and compile | the binaries so they're not conflicting with each other... Is this | possible? Unless I missed something, expat is separate; don't know for 2-4. I generally do build with a single source and multiple, separate build trees for different platforms. It's pretty easy to set up at configure time, just make an empty directory and run $src/configure --srcdir $src. The only flaw here with the Python 2.0 distribution is that the grammar source is generated during the build, and then copied to the source tree. I don't expect this will cause you any real trouble. Historically, it could also make a Lib/plat-xxx directory in the source tree, if the distribution doesn't include the right one for the platform, haven't seen this with 2.0 but it still does for all I know. You will get a wretched "make" implementation on AIX, and it may not handle VPATH well enough to cope with this. If you can use GNU make there, do. True64 and GNU Linux make will do OK, and HP/UX's I think. Donn Cave, donn at u.washington.edu From artymiak at safenet.pl Thu Oct 5 15:16:55 2000 From: artymiak at safenet.pl (Jacek Artymiak) Date: Thu, 05 Oct 2000 21:16:55 +0200 Subject: pyxhtml release 00.01.01 & pythoncgi.com issue 00/2000 Message-ID: <4.3.0.20001005211251.00d1cf00@mail.safenet.pl> Dear Pythoneers! This is just a short note to let you know that pyxhtml 00.01.01 is available on-line at http://www.pythoncgi.com/software/pyxhtml.html and that issue 00/2000 of pythoncgi.com has been sent to all subscribers (you can view it on-line at http://www.pythoncgi.com, search for the link to the Archive Issues). Subscription is free, all you have to do is join using the form at http://www.pythoncgi.com/ Best, Jacek Artymiak From python-group at rascal.remove_this_bit.org Sun Oct 15 11:52:39 2000 From: python-group at rascal.remove_this_bit.org (Steve George) Date: Sun, 15 Oct 2000 15:52:39 +0000 Subject: Testing existance of variable References: Message-ID: In article , Alex wrote: > >> if os.environ.has_key('REMOTE_HOST') or >> os.environ.has_key('REMOTE_ADDR'): >> remote_id = os.environ['REMOTE_HOST'] or os.environ['REMOTE_ADDR'] >> >> However, this fails with an exception for KeyError if one of them >> doesn't exist. > > Try this: > > new_remote_id = os.environ.get('REMOTE_HOST') or \ > os.environ.get('REMOTE_ADDR') > if new_remote_id: > remote_id = new_remote_id > > Alex. > Thanks Alex - that's just the operation I wanted. According to the Quick Python Book I can also use it to provide a default in case the environment doesn't have that variable: remote_id = os.environ.get('REMOTE_HOST') or \ os.environ.get('REMOTE_ADDR', 'empty') Steve From jepler.lnk at lnk.ispi.net Mon Oct 2 08:41:57 2000 From: jepler.lnk at lnk.ispi.net (jepler epler) Date: Mon, 02 Oct 2000 12:41:57 GMT Subject: msvcrt.getch() from IDLE returns '\377' References: <39D1DFE9.426A3972@bnmsp.de> Message-ID: On Sun, 01 Oct 2000 23:32:25 GMT, Mark Hammond wrote: > >"Georg Simon" wrote in message >news:39D1DFE9.426A3972 at bnmsp.de... >> Windows 98 >> sys.version '1.6 (#0, Sep 5 2000, 08:16:13) [MSC 32 bit (Intel)]' >> >> It seems to me that msvcrt.getch() does not work when called from >IDLE. > >I would not expect it to. getch() is designed for reading from a >"console". IDLE has no such console, so characters have to be >obtained from the message queue - ie, you will need to use Tkinter >facilities to get at key-presses. Shouldn't it raise an exception in this case? Jeff From kc5tja at garnet.armored.net Thu Oct 12 17:59:25 2000 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 12 Oct 2000 14:59:25 -0700 Subject: how do I listen on a socket without sucking up all the CPU time? References: <39d971f3_1@corp.newsfeeds.com> <39D9AA8D.EABDF6BA@businesscollaborator.com> Message-ID: On Tue, 3 Oct 2000 23:16:37 +1300, matt wrote: >Using select with a timeout of NULL(None) is the nicer way to do things, i.e. >make select blocking. It means this thread doesn't have to be limited to just >that socket. It obviously becomes a lot more useful. I've read the select() source in Linux's source code. From what I can see, it apparently busy-waits on the selectors you give it -- I don't see any calls to functions that put the process to sleep. If I'm wrong on this, and I sure hope I am, could someone please point out where Linux does put the calling process to sleep? Maybe I just skipped over it (I was reading for curiosity anyway). Quite likely, considering the complete lack of documentation in it. -- KC5TJA/6, DM13, QRP-L #1447 | Official Channel Saint, *Team Amiga* Samuel A. Falvo II | Oceanside, CA | From max at alcyone.com Tue Oct 24 12:07:08 2000 From: max at alcyone.com (Erik Max Francis) Date: Tue, 24 Oct 2000 09:07:08 -0700 Subject: C's syntax References: <8t0or303ee@news1.newsguy.com> <8t1964$v8a$1@news7.svr.pol.co.uk> <17WI5.58198$oN2.2362868@news20.bellglobal.com> <39F45B51.320AA63F@alcyone.com> <8t1nr90105v@news1.newsguy.com> <39F4FEAF.FA466927@alcyone.com> <8t3nt4027fk@news2.newsguy.com> Message-ID: <39F5B3AC.7A02F667@alcyone.com> Alex Martelli wrote: > Koenig wrote his landmark book with about a decade's worth of C > experience (one could hardly have more back then, since that was > about the language's age inside Bell Labs:-), and he disagreed > with you, recommending the "if(0==a)" idiom. And why not? It is a stylistic issue, and so is always a point of contention. Even f you find yourself making the = vs. == errors, a good compiler will warn you. If you're not using a good compiler, that's not the language's fault. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Nobody's waited longer than me / To come clean \__/ Jaki Graham Maths reference / http://www.alcyone.com/max/reference/maths/ A mathematics reference. From hzhu at yahoo.com Mon Oct 2 04:36:41 2000 From: hzhu at yahoo.com (Huaiyu Zhu) Date: Mon, 02 Oct 2000 08:36:41 GMT Subject: Coerce that can pay attention to type of operation References: Message-ID: On Mon, 02 Oct 2000 00:21:03 GMT, jepler epler wrote: >(*) I have also often wished that __str__ could take the width specifiers >given in the formatting operator, so that "%5.3s"%a would call a.__str__(5,3) >if a.__str__ is able to take arguments. Thus, objects would have the >opportunity to smartly format themselves in the available space. Or more generally, "%80.2.3.5s" % a == str(a, 80, 2, 3, 5) which could be used to format more complicated objects in a very clean and efficient way. Huaiyu From aahz at panix.com Sat Oct 7 15:25:28 2000 From: aahz at panix.com (Aahz Maruch) Date: 7 Oct 2000 12:25:28 -0700 Subject: join() References: <8rjj82$dnb$1@nnrp1.deja.com> <39DD9A9A.7130@hvision.nl> <8rlrdr$6ed$1@nnrp1.deja.com> Message-ID: <8rntb8$fhb$1@panix6.panix.com> In article <8rlrdr$6ed$1 at nnrp1.deja.com>, wrote: > >What other things in Python have become non-intuitive in your opinion? print >> file, "foo" -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "[I have a] windmill fetish." --Darkhawk From ungrzr2 at ubatxbat.pbz Wed Oct 11 12:37:30 2000 From: ungrzr2 at ubatxbat.pbz ({-- Rot13 - Hateme) Date: 11 Oct 2000 16:37:30 GMT Subject: concurrent access to dbms (was best way to store dbm records?) References: <8rnu4o$emc$1@bob.news.rcn.net> <9f2vtss06scg26psv7gvfv8agt68jc91h3@4ax.com> <8rpeko$4jd$1@bob.news.rcn.net> <8rvpfh$933$1@panix3.panix.com> Message-ID: <8FCB14DEYouAreNotMeYouKnow@205.252.144.34> aahz at panix.com (Aahz Maruch) wrote in <8rvpfh$933$1 at panix3.panix.com>: >In article <8rpeko$4jd$1 at bob.news.rcn.net>, >Michael B. Allen wrote: >> >>Shelve works great Tim, thanks. I have implemented this and it works >>very well for my purposes. >> >>I may have a different issue however. The docs on shelve(and I would >>imagine dbm's in general) report that you cannot concurrently read from >>it if it is open by a writer. If I have interpreted the docs correctly >>this is true even if it is only open by a single writer. > >Without going into the details of your specific needs, have you >considered using a full-blown DBMS? Both MySQL and PostGreSQL would >probably suit you (I have used neither, but they're both claimed to be >multi-user (read "concurrent")). http://www.sleepycat.com 's Berkeley DB will let you do all this things. From sabren at manifestation.com Tue Oct 10 14:52:47 2000 From: sabren at manifestation.com (Michal Wallace) Date: Tue, 10 Oct 2000 14:52:47 -0400 (EDT) Subject: How does "for" work? In-Reply-To: Message-ID: On Tue, 10 Oct 2000, Steve Juranich wrote: > I have an object that is actually just a list of other, smaller items. > > In the list object, I have overridden __getitem__ to be the following: > > def __getitem__(self, key): > return self.data[key] look at the UserList module... I believe you need to raise an IndexError when you get to the end of the list.. Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From sandj.williams at gte.net Mon Oct 16 07:04:26 2000 From: sandj.williams at gte.net (Steve Williams) Date: Mon, 16 Oct 2000 11:04:26 GMT Subject: How can I get rid of lambda References: <39EA484C.C57D995A@gte.net> <39ea8dee.463036046@news1.on.sympatico.ca> Message-ID: <39EAE158.33C46DFB@gte.net> Robert Roy wrote: > I went a step further with your code and created a lookup dict for all > 256 char values. 100,000 reps went from 9.2 seconds to 3.9 seconds. > > Append the following to the code you posted > #-------------- > # create a dict of characters and expansions > l = {} > for x in range(256): > l[chr(x)] = unpack(chr(x)) > #print l > #print map(None, packedNumber) > [snip] Very nice. I'm surprised the dictionary lookup is so fast. Thanks for your response. From glenfant at nospam-e-pack.net Thu Oct 12 12:07:51 2000 From: glenfant at nospam-e-pack.net (Gilles Lenfant) Date: Thu, 12 Oct 2000 18:07:51 +0200 Subject: Timeout for urllib.urlopen(...) References: Message-ID: <8s4nf7$228$1@reader1.imaginet.fr> Many thanks Oleg, This newsgroup is really fantastic ! Most times I ask for a hint, I get a full solution ! Lots of girls will thank you to enable me playing more python with them than with my computer ;-) Cheers, Gilles "Oleg Broytmann" a ?crit dans le message news: mailman.971364691.27540.python-list at python.org... > On Thu, 12 Oct 2000, Gilles Lenfant wrote: > > Has any of you any hint for making like urllib.urlopen(...) but with a > > TimeOut ? > > I'm making a script to check if the Web application server is running. > > If it's down... the urllib.urlopen(...) waits for a reply till... there's no > > more power supply. > > First thing to try is http://www.timo-tasi.org/python/timeoutsocket.py > > Oleg. > ---- > Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru > Programmers don't die, they just GOSUB without RETURN. > > From root at rainerdeyke.com Tue Oct 31 14:47:04 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Tue, 31 Oct 2000 19:47:04 GMT Subject: Method or function? References: Message-ID: "Rainer Deyke" wrote in message news:lVEL5.145180$g6.66741516 at news2.rdc2.tx.home.com... > id applies to all objects, including methods. Do you really want > 1.id().id().id() to be legal Python? I meant 1.id.id.id(), i.e. the id of the id method of the id method of 1. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From rahman at cpsc.ucalgary.ca Fri Oct 20 22:41:46 2000 From: rahman at cpsc.ucalgary.ca (Zishan Rahman) Date: Fri, 20 Oct 2000 20:41:46 -0600 (MDT) Subject: help Message-ID: hi there i was wondering how do export and import in python and can i program non-interactively like we do in c or c++ thanks From MarkH at ActiveState.com Tue Oct 17 19:04:50 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Tue, 17 Oct 2000 23:04:50 GMT Subject: Connecting to running win32com References: <39ECB9EF.D4EDEE5A@sandia.gov> Message-ID: "ghubbar" wrote in message news:39ECB9EF.D4EDEE5A at sandia.gov... > Hi again, > > I lost track of the thread, so I am starting a new one. I'm sorry, but you _will_ need to go back to that thread - there is very important information there relating to your situation, and I'm not going to attempt to repeat it. A minor issue: > class MyPythonComServer: > _public_methods_ = ["ReturnMessage"] > _reg_progid_ = "StatusData.Access" > _reg_clsid_ = "{38C739C1-4EC0-11D4-BDFB-005004D78D9D}" > print "Creating ComServer" You are misleading yourself with that "print". The ComServer is _not_ being created at that time. All that is being created is the _class_. The COM object is an _instance_ of a class. Add an __init__ function, and add the print there. A much bigger problem is: > if __name__ == '__main__': > print "Registering COM server..." > import win32com.server.register > apply(win32com.server.register.RegisterClasses([MyPythonComServer], > {"debug":1})) > > app = MyApp(0) > app.MainLoop() You can _not_ try and start your app at this point. All you should be doing here is registering your object. You must setup your code such that COM itself automatically boots up your application - ie, your object constructor must take care of this. However, you will need to re-read the other thread to understand that a new COM object will be created _every_ time a client creates one. If you want the illision of a single COM object for all clients, you _must_ re-read that thread. Mark. From speed at ?.com Fri Oct 20 09:32:19 2000 From: speed at ?.com (Jake Speed) Date: Fri, 20 Oct 2000 13:32:19 -0000 Subject: Socket recv() problem References: <39F0321A.24D58DD4@schlund.de> Message-ID: cgaebler at gmx.de (Carsten Gaebler) wrote in <39F0321A.24D58DD4 at schlund.de>: >Hi! > >It seems to me that a socket's recv() function doesn't read any data in >subsequent calls when called repeatedly. I have the following sending >and receiving programs: > ># receiver >import socket, sys >sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) >sock.bind("/tmp/to_hell.sock") >while 1: > sys.stdout.write(sock.recv(10)) > ># sender >import socket >sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) >sock.connect("/tmp/to_hell.sock") >s = "0" * 100 >sock.send(s) > > >The receiver prints out only the first 10 "0"s, the rest seems to be >ignored. What's happening here? You're using datagram sockets. When you send() on a datagram socket, the string is sent as a discrete packet -- a datagram. When you recv() on the destination socket, you read one, and only one datagram. If your buffer is not large enough to hold the entire datagram, the rest is lost. I think datagrams are limited to 64K in size, so if you just do sock.recv(0x10000) you'll be ok; the string is automatically truncated to the actual size of the datagram. If you were using stream sockets (SOCK_STREAM), then there would not necessarily be a one-to-one correspondence between calling send() and sending a single packet. The recv() call would read as much data as was available, up to the buffer size, and none would be lost. If your data is not logically broken up into packets, this would be a better idea. Even if it is divided into packets, you can still use SOCK_STREAM if you have some way of delimiting packets. If you are sending strings that do not contain newlines, you can send a newline after each logical packet. If you are sending raw binary data, you can send the packet length first, and at the destination receive it and then call recv() with the packet length. -Speed! From aleaxit at yahoo.com Sat Oct 7 05:33:36 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 7 Oct 2000 11:33:36 +0200 Subject: Iterating over a stream with only readline() method [newbie question] References: Message-ID: <8rmu1b02bc1@news1.newsguy.com> "Syam Pannala" wrote in message news:slrn8ttc2s.6lo.syam at c544784-a.stcla1.sfba.home.com... > [Newbie Alert!!] Welcome! > i have a stream which provides only a readline() method (it can come from > a variety of sources including network and i dont want to buffer it so > that i can implement readlines()). OK. You have an object that has a slightly different interface from either a fileobject or a sequence. > What is the python idiom for iterating over this stream until it throws > EOFError ? Best solution may be to use the Adapter idiom, aka Wrapper idiom: it's often best when you want to slightly change an object's interface. For example: class AsSequence: def __init__(self, theobj): self.obj = theobj def __getitem__(self, i): try: return self.obj.readline() except EOFError: raise IndexError Here, we are adapting the actual object's interface (aka protocol), "Get next item by calling readline, raise EOFError when done", to the sequence interface/protocol needed by Python (specifically, the for statement), "Get next item by calling __getitem__ with increasing index, raise IndexError when done". This is all done in the __getitem__ method. The __init__ just does the typical "set argument to a field of self" initialization idiom. > for i in stream.readlines(): > ..use i .. > > i want the ..use i.. code not to change very much. Also, i think So you will now say: for i in AsSequence(stream): .. use i .. without any change at all to the ..use i.. code. The Adapter (aka Wrapper) idiom (aka Design Pattern: it's identified as such in the seminal "Design Patterns" book by the so-called Gang Of Four) is powerful, handy, and of very frequent use. > while 1: > try: > i = stream.readline() > expcept EOFError: > break > ... use i .. > > looks very inelegant, even though that is what i have used as the current > implementation. I agree with your assessment. I think the Adapter is much better. Alex From quinn at pfennig.ugcs.caltech.edu Fri Oct 27 00:18:28 2000 From: quinn at pfennig.ugcs.caltech.edu (Quinn Dunkan) Date: 27 Oct 2000 04:18:28 GMT Subject: Pretty report printing References: Message-ID: On Wed, 25 Oct 2000 15:08:36 +0100, Dale Strickland-Clark wrote: >I need to produce a bunch of standard reports from a database and am >considering Python. > >The reports need to be pretty but probably text only (although borders >and boxes would be nice). They should be previewable online and >printable to any Windows printer. > >I like the idea of using HTML but it doesn't understand the printed >page so headings, headers and footers are trickey. > >Other options include PDF (which I'd have to research cos I know >nothing about it) and driving Word or Excel through COM to build pages >- which isn't an attractive thought. > >How have others tackled this problem? I've written python scripts which generate LaTeX source. It should be easy to learn enough minimal LaTeX to produce the output and let it worry about table formatting, headers, footers, etc. Then you'd want to turn it in to postscript with dvips. If you expect the previewing will be done on windows machines without ghostscript, I'm pretty sure I've seen some ps->pdf filters about. This is a pretty unixy solution but it was super easy for me and should be a lot easier than generating pdf by hand :) LaTeX is not a pretty beast but it gets the job done and produces professional looking output. From rnd at rnd.donetsk.ua Wed Oct 4 16:14:52 2000 From: rnd at rnd.donetsk.ua (Dmitry Rud) Date: 4 Oct 2000 20:14:52 GMT Subject: Substring Detection? Pythonically? References: <20001004.123529.97857@Jeremy.cerebralmaelstrom.com> Message-ID: <87k8bobbyb.fsf@rnd.donetsk.ua> "Stephen Hansen" writes: > Okay, say I have three different strings: > #1: they > #2: that > #3: tommy > > And a user gives me a string -- 'the', I want it to match to 'they'. Then > say they give me a string, 'to', I want it to match to 'tommy'. A string > of 'th' or 't' is ambiguious, and i want a list returned, ['they','that'] > and ['they','that','tommy'] respectively. list = [ "they", "that", "tommy" ] word = raw_input( "Enter the word > " ) filter( lambda x, w = word: not x.find( w ), list ) or, for Python < 2.0: from string import find filter( lambda x, w = word: not find( x, w ), list ) or (could it be faster? :-\) : filter( lambda x, w = word: x[ :len( w ) ] == word, list ) -- rnd. From jasonic at nomadicsltd.com Wed Oct 25 22:34:33 2000 From: jasonic at nomadicsltd.com (Jason Cunliffe) Date: Wed, 25 Oct 2000 22:34:33 -0400 Subject: detecting param type References: <8t7lsj01usg@news2.newsguy.com> Message-ID: Alex Thanks very much... Alex Martelli > I would simply change the routine to: > > def append(self, date=now(), entry='entry', display=0): > self.eventdict.append(str(date), entry) > if display: > self.display() > > It does no harm to call str(date) 'again' even if date > is _already_ a string -- in that case it will just be a > very fast no-operation, probably faster than checking > for specific types! This is very cool. > One warning: the default value for the date parameter > is computed ONCE -- i.e., the now() function is called > just once, when the routine is defined. If that is not > what you desire, you must take a slightly different tack: > > def append(self, date=None, entry='entry', display=0): > if not date: date = now() > self.eventdict.append(str(date), entry) > if display: > self.display() > > this way, now() is called afresh each time if needed. > Just thought this could help... You bet!.. it is just this kind of direct improvement to my simple code from experienced pythoneers like yourself which makes me go aha!!.. and then encourages me think more deeply about what is happening when classes and methods are being instanced. As I develop my methods for this module, I find I am adding more and more keyword arguments with defaults and more detection clauses to act upon them, such as: def mymethod(index=0, display=0, sort='auto', event='something'): etc.. I like this because as I am experimenting in PythonWin interactive shell where I can see my arguments appear inline and I find the code is easier to maintain and more explicit. As things grow it seems like I should factor out the common ones and instead put them into a superclass and thus make faster changes later. For example if all my class methods have the same set of 4 or 5 key arguments, should'nt these go outside in one place where they can be improved. So my question is do you have any advice/strategy for better ways to handle lots of keyword arguments and class inheritance? hope this makes sense Thanks Jason From Michael.Burns at sas.com Tue Oct 24 18:01:00 2000 From: Michael.Burns at sas.com (Michael Burns) Date: Tue, 24 Oct 2000 17:01:00 -0500 Subject: problems with Linking and loading extensions to Python Message-ID: <20001024220102.9B1101CC02@dinsdale.python.org> A non-text attachment was scrubbed... Name: not available Type: text/enriched Size: 3411 bytes Desc: not available URL: From * at spam.ruud.org Sat Oct 14 06:22:46 2000 From: * at spam.ruud.org (Ruud de Rooij) Date: 14 Oct 2000 12:22:46 +0200 Subject: interchanging rows and columns References: Message-ID: <87lmvr3eo9.fsf@hobbes.home.ruud.org> johannes at zellner.org (Johannes Zellner) writes: > how can I turn > [[1, 2, 3], [4, 5, 6]] > into > [[1, 4], [2, 5], [3, 6]] The pythonic way to do these things seems to be to simply write a nested for loop, something like this: def transpose(m): n = [] for i in range(len(m[0])): r = [] for j in range(len(m)): r.append(m[j][i]) n.append(r) return n If you really want to use a solution that uses map, you could use something like: def transpose(m): return map(lambda i,m=m:map(lambda x,i=i:x[i], m),range(len(m[0]))) - Ruud de Rooij. -- ruud de rooij | *@spam.ruud.org | http://ruud.org From dberlin at redhat.com Mon Oct 2 20:06:58 2000 From: dberlin at redhat.com (Daniel Berlin) Date: 02 Oct 2000 20:06:58 -0400 Subject: example sources in both Python and C++ In-Reply-To: wmcclain@salamander.com's message of "Mon, 02 Oct 2000 23:27:53 GMT" References: Message-ID: wmcclain at salamander.com (Bill McClain) writes: > Here is something for the beginning Python programmer, or > anyone who wants to compare the language with C++. > > I have put up an astronomical package implemented in both > Python and C++. It is just a subroutine library and a few > simple applications, all with console interfaces: > > http://astrolabe.sourceforge.net/ > > This is probably not the best example for language comparison, > in that most of the code is numerical and would look much > the same in Fortran. But comparing cronus.py with cronus.cpp > gives some idea of how tasks are approached in both languages. > > Some notes from the home page: > > Years ago, I originally wrote the astrolabe routines in C. Now, I > always implement in Python first, then make a C++ version as a > more-or-less direct translation. The C++ source has a lot of > compromises required for compatability with different compilers, > which are, however, getting closer to the standard with time. > > The Python sources are obviously more compact than the C++ > versions and have less declarative overhead. To me, the most > unfortunate aspects of C++ are: > > * STL containers cannot have initialization lists, meaning that > inline data must first be held in C-arrays, then copied to > the containers at run-time. I use some macros to make this a > bit more natural-looking. Yes, this sucks. > * Template arguments cannot be local types. That means STL > containers must use types declared at the outer scope, which > is ugly. Wait, what? Explain what you mean, this is confusing. If you mean you can only use types in the outermost, or global scope, as template arguments, your compiler is severely broken. > * Functions may not return multiple values. Where Python can > have: > > ra, dec = func() > > C++ requires: > > void func(double &ra, double &dec); > double ra, dec; > func(ra, dec); > > ...or a struct for a return value, which would require more > declarations. In an alternative C-like language, this would > be just as strongly-typed as the function shown above: > > double, double func() > double ra, double dec = func(); You could overload operator , for a tuple like class, and use that > > -Bill > -- > http://www.python.org/mailman/listinfo/python-list From sdm7g at virginia.edu Wed Oct 25 00:49:47 2000 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Wed, 25 Oct 2000 00:49:47 -0400 (EDT) Subject: problems with Linking and loading extensions to Python In-Reply-To: <200010242201.PAA14026@scyther.omnigroup.com> Message-ID: On Tue, 24 Oct 2000, Michael Burns wrote: > What is the right combinations of ld options to use? > > Anybody have any examples that work for them? > > > Background: > > I am trying to get an extension to Python to link and load on Mac OS X public beta. > > > I have tried many combinations of ld options like -dyld, -bundle, -dylinker, -fvmlib, > > -preload > > > Some of them give me unresolved references or other ld complaints. Are you using Python 2.0 ? Take a look at the switches the python2.0/Modules/Makefile uses for building shared libraries: "-bundle -undefined suppress" I used the following command to link the python gtk module: cc -bundle -undefined warning gtkmodule.o -L/usr/local/lib -L/usr/X11R6/lib -lgtk -lgdk -lgmodule -lgthread -lglib -lXext -lX11 .libs/lib_gtkmodule.a -o _gtkmodule.so ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- "All operating systems want to be unix, All programming languages want to be lisp." From zxo102 at my-deja.com Mon Oct 30 18:34:28 2000 From: zxo102 at my-deja.com (zxo102 at my-deja.com) Date: Mon, 30 Oct 2000 23:34:28 GMT Subject: telnet.py in Python-1.5.2/Demo doesn't work in HP-UX.... References: <8rlgrk$u4t$1@nnrp1.deja.com> Message-ID: <8tl0i4$f1d$1@nnrp1.deja.com> There are two files named as telnet.py under Demo. Demo/sockets/telnet.py works fine but Demo/threads/telnet.py does not work on my HP-UX. Ouyang In article , Jeff Bauer wrote: > zxo102 at my-deja.com wrote: > > telnet.py in Python-1.5.2/Demo does not work on > > HP-UX. Does anybody know how to solve this > > problem? > > I just tried it on a client's HP-UX system and it > worked fine. > > $ uname -a > HP-UX bmc B.10.20 U 9000/813 2003582827 unlimited-user license > > Jeff Bauer > Rubicon Research > > Sent via Deja.com http://www.deja.com/ Before you buy. From ewalstad at yahoo.com Mon Oct 2 14:24:53 2000 From: ewalstad at yahoo.com (Eric) Date: Mon, 2 Oct 2000 11:24:53 -0700 Subject: Newbie-Can I loop thru all class variables? References: <6vQB5.58$QI1.115495@news.pacbell.net> Message-ID: > It sounds like you want user's variables, which are the attributes of > an instance (or instance variables, or data members), not CUser's > variables, which are the class variables. > > Instance variables are in user.__dict__; I think user.__dict__.keys() > is what you want. Yes, I am looking for instance variables, not class variables. Sorry for the confusion and thanks for the help! "__dict__" was just what I was looking for! Eric. From kc5tja at garnet.armored.net Thu Oct 12 19:21:22 2000 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 12 Oct 2000 16:21:22 -0700 Subject: hack to auto-define variables? References: Message-ID: On 12 Oct 2000 19:17:17 -0400, Alex wrote: >In the example you use to justify this travesty, you can do what you >describe with __getattr__, if your heart's set on it. Thanks for the example. I am already aware of how it could be done, and I have done it numerous times before. -- KC5TJA/6, DM13, QRP-L #1447 | Official Channel Saint, *Team Amiga* Samuel A. Falvo II | Oceanside, CA | From guido at python.org Mon Oct 16 23:35:02 2000 From: guido at python.org (Guido van Rossum) Date: Mon, 16 Oct 2000 22:35:02 -0500 Subject: Python 2.0 final release is out! Message-ID: I am happy to announce that Python 2.0 is released. I thank my colleagues at BeOpen PythonLabs and the many volunteers in the Python developer community for their incredible work on this release over the past months. Please pick up the new release at http://www.pythonlabs.com/products/python2.0/ There you will find a Windows installer, a source tarball, RedHat RPMs, downloadable and online documentation, and a long list of new features and fixed bugs. Among the new features in Python 2.0 are: - Augmented assignment, e.g. x += 1 - List comprehensions, e.g. [x**2 for x in range(10)] - Extended import statement, e.g. import Module as Name - Extended print statement, e.g. print >> file, "Hello" - Collection of cyclical garbage For a fuller discussion of the changes in Python 2.0 since Python 1.5.2, please see the article "What's New in Python 2.0" by A.M. Kuchling and Moshe Zadka: http://starship.python.net/crew/amk/python/writing/new-python/ All major reported bugs have been fixed in this final release. We've gone through an extremely thorough set of beta releases followed by a release candidate, and therefore we expect that this release will be stable and virtually problem-free. If you nevertheless run into a bug, use the SourceForge bug tracker to report it: http://sourceforge.net/bugs/?group_id=5470 --Guido van Rossum (home page: http://www.python.org/~guido/) From cigar20 at my-deja.com Tue Oct 17 06:32:46 2000 From: cigar20 at my-deja.com (cigar20 at my-deja.com) Date: Tue, 17 Oct 2000 10:32:46 GMT Subject: I want to impress the boss. References: <8sdvc6$jqq$1@nnrp1.deja.com> <39EAFE3C.7D13B8B3@engcorp.com> <8sgn6d$s10$1@nnrp1.deja.com> Message-ID: <8sh9se$9t9$1@nnrp1.deja.com> In article , "Mark Hammond" wrote: > > The questions: > > - The location of a complete set of Microsoft Word COM commands is > > asking too much? > > Actually there _was_ a pointer to the complete commandset (ie, the > makepy generated source file). No pointer to documentation yet tho. > > But it is too much to ask on this newsgroup. Check the Office 2000 > install options - it may be there, but disabled (that was true for > Office 97). Or try the Office 2000 developers kit. > > > - When interfacing to VSS it's up to me to build my own 'home grown' > > set of commands...(it's possibly not mature enough a program to have > a > > built in COM interface)? > > No - it has a complete COM interface. There was a pointer to some > sample code in Pythonwin that uses this interface. Again, you will > need to look for VSS resources to locate the object model > documentation... > > Mark. > > Thank you Mark. I was thinking after I wrote my last post that maybe I should haved asked my questions in a more COM related group. I know Python can do much more than 'glueing' and thought that not everyone here is using Python the same way I am. Thank you again I'll now quitely go do some research. (Yours was the the first book I bought on Python) Sent via Deja.com http://www.deja.com/ Before you buy. From josh at open.com Fri Oct 20 21:56:32 2000 From: josh at open.com (Joshua Muskovitz) Date: Fri, 20 Oct 2000 21:56:32 -0400 Subject: large file support References: <8sqn2l$ec$1@ncar.ucar.edu> Message-ID: <39f0f6b3_4@corp.newsfeeds.com> This is just a guess, so no flames when I'm completely wrong. :-) On some OSes, the maximum memory allowed *per process* can be smaller than the total memory. I've seen this on boxes with 4GB of RAM that only allow a maximum of 2GB memory spaces per process (this was on a linux/intel box, I believe). It has to do with how the paging space is managed, I think, and the number of address bits allowed in each process space. You might try checking with some IRIX gurus, though, just to be sure. Can you read the entire file in at one time using a different programming language? -- josh -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From jepler.lnk at lnk.ispi.net Fri Oct 13 18:23:44 2000 From: jepler.lnk at lnk.ispi.net (jepler epler) Date: Fri, 13 Oct 2000 22:23:44 GMT Subject: how do I listen on a socket without sucking up all the CPU time? References: <39d971f3_1@corp.newsfeeds.com> <39D9AA8D.EABDF6BA@businesscollaborator.com> Message-ID: On 12 Oct 2000 14:59:25 -0700, Samuel A. Falvo II wrote: >I've read the select() source in Linux's source code. From what I can see, >it apparently busy-waits on the selectors you give it -- I don't see any >calls to functions that put the process to sleep. /usr/src/linux/fs/select.c:do_select() does not busy-wait. The statements current->state = TASK_INTERRUPTABLE; // line 176 in my copy __timeout = schedule_timeout(__timeout); // line 216 in my copy together cause the program to yield the CPU after the FD array is scanned through once until the timeout expires or one of the files in the assembled 'poll_table' becomes ready. (2.2.12-20 from redhat 6.1) >If I'm wrong on this, and I sure hope I am, could someone please point out >where Linux does put the calling process to sleep? Maybe I just skipped >over it (I was reading for curiosity anyway). Quite likely, considering the >complete lack of documentation in it. Complete lack of documentation? % man 2 select | wc -l 198 The phrase near the top, "select waits for ..." and later "select can *block* indefinitely [when timeout is NULL]" both imply that select is "blocking" just like "read" from a socket with no data available. But, anyway, I think it's just common knowledge that select() doesn't merely sit and spin. That's the sort of thing you have to have from day one. I don't think anybody would be serving websites from their linux machine if there weren't a blocking, cpu-friendly select. Jeff From lss at excosoft.se Wed Oct 4 11:12:17 2000 From: lss at excosoft.se (lss at excosoft.se) Date: Wed, 04 Oct 2000 15:12:17 GMT Subject: Python as an embedded scripting language References: <8ren1o$cq3$1@nnrp1.deja.com> <8rf0ng02u9a@news2.newsguy.com> Message-ID: <8rfhca$u5$1@nnrp1.deja.com> Thanks! You're a lifesaver! The Python documentation I had seems to be outdated, but I found updated documentation on the web, although I couldn't find a version that contained a section 4.2 in "Extending and Embedding"? -- Ludvig In article <8rf0ng02u9a at news2.newsguy.com>, "Alex Martelli" wrote: > wrote in message news:8ren1o$cq3$1 at nnrp1.deja.com... > > Is it possible to embed Python as a scripting language in a C++ > > application and exposing the internals of the application to Python > > through use of dynamic extension modules (PYDs)? Or is it necessary to > > link the extension modules statically with the executable in order to > > give them access to its internal data, and thus also to link the Python > > interpreter in as well, since the extension modules must then be > > realized as builtin modules? This breaks PYDs altogether, though, since > > they are dependent upon a DLL Python core. > > Your application can embed Python residing in a DLL, and add its > own modules to it with PyImport_AppendInittab (or the more general > PyImport_ExtendInittab) before it calls Py_Initialize. > > > I would be thankful on any pointers on how to retain both Python's > > access to the application data structures and the ability to import > > PYDs. > > Section 5.3 in "Python/C API Reference Manual". For cross-platform > work, also note section 4.2 in "Extending and Embedding". > > Alex > > Sent via Deja.com http://www.deja.com/ Before you buy. From dcalvelo at pharion.univ-lille2.fr Tue Oct 3 05:10:43 2000 From: dcalvelo at pharion.univ-lille2.fr (Calvelo Daniel) Date: 3 Oct 2000 09:10:43 GMT Subject: questions References: <200010022127.e92LRNb18592@hera.cuci.nl> Message-ID: <8rc7qk$9su$1@netserv.univ-lille1.fr> Xiaoxia Dong wrote: : thank you very much for your help. I guess i did not make myself clear, I am : tyring to change the font of some : of the string i am going to write to a file and in overall i want my file : look pretty and elegant. Is there anyway i : can do it in python? Probablu several ways. If you don't have a preference for output formats, you may be interested in http://www.reportlab.com. Python-does-not-know-what-a-font-is-ly y'rs, Daniel. -- Daniel Calvelo Aros calvelo at lifl.fr From effbot at telia.com Mon Oct 16 18:22:46 2000 From: effbot at telia.com (Fredrik Lundh) Date: Mon, 16 Oct 2000 22:22:46 GMT Subject: Where do I find the "crypt" module? References: Message-ID: John Draper wrote: > When we installed our Python system on our server, we ran the CVS > depository to get all of the modules. But in looking at our Python > distributed files, I don't see the module anywhere on our system. the FAQ has the answer: http://www.python.org/doc/FAQ.html#4.81 > Can anyone please help me? I had no idea that none of the librarys would > be installed when we installed the system. reading the README file also helps, of course: "Configuring additional built-in modules --------------------------------------- You can configure the interpreter to contain fewer or more built-in modules by editing the Modules/Setup file. This file is initially copied (when the toplevel Makefile makes Modules/Makefile for the first time) from Setup.in; if it does not exist yet, make a copy yourself. Never edit Setup.in -- always edit Setup. Read the comments in the file for information on what kind of edits are allowed. When you have edited Setup, Makefile and config.c in the Modules directory, the interpreter will automatically be rebuilt the next time you run make in the toplevel directory. (When working inside the Modules directory, use "make Makefile; make".) The default collection of modules should build on any Unix system, but many optional modules should work on all modern Unices (e.g. try dbm, nis, termios, timing, syslog, curses, new, soundex, parser). From loewis at informatik.hu-berlin.de Sun Oct 1 14:24:30 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: Sun, 1 Oct 2000 20:24:30 +0200 (MET DST) Subject: Python2.0 beta 2 on MacOSX/Darwin In-Reply-To: <007e01c02b9b$38c2ce30$0101a8c0@jayk3> (jay.krell@cornell.edu) References: <007e01c02b9b$38c2ce30$0101a8c0@jayk3> Message-ID: <200010011824.UAA00784@pandora.informatik.hu-berlin.de> > libtool is the Gnu /bin/sh script for portably building shared libraries, > across various *nix platforms and presumably compilers (presumably Gcc > supports a unified command line syntax and such a script would not be needed > if everyone targeted Gcc..) I knew libtool as in "GNU libtool"; I just did not knew Apple ships libtool as part of their development platform for MacOS X (or, rather, I expected they would have a different tool with the same name). Do you know whether they have folded the -framework changes to libtool back into GNU libtool? Regards, Martin From rlboloNOSPAM at libero.it Tue Oct 31 14:35:48 2000 From: rlboloNOSPAM at libero.it (Super Bolo) Date: Tue, 31 Oct 2000 19:35:48 GMT Subject: Newbie - Please don't flame Message-ID: Hi all, i'm new to Python (really i'm still at the Hello World stadium)... question is: can i make .py files stand-alone exe files without invoking the interpreter so that they can run also on computers without interpreter installed?? Is Active Python for that purpose??? Greets from Italy, Lorenzo www.johnfante.it From aahz at panix.com Tue Oct 3 23:03:19 2000 From: aahz at panix.com (Aahz Maruch) Date: 3 Oct 2000 20:03:19 -0700 Subject: Newbie: How to convert "<" to "<" ( encoding? ) References: <8rdq3j$qm0$1@panix6.panix.com> Message-ID: <8re6ln$2pl$1@panix6.panix.com> In article , lynx
wrote: >aahz at panix.com (Aahz Maruch), in <8rdq3j$qm0$1 at panix6.panix.com>: >> >> Actually, it appears that there is in fact no HTMLescape() function. > >what about cgi.escape() ? Ah, there it is. Okay, I wasn't familiar with the cgi module. Thanks! There probably should still be a generic char-to-entity routine based on the htmlentitydefs module, but that's lower priority. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 There's a difference between a person who gets shit zie doesn't deserve and a person who gets more shit than zie deserves. --Aahz From bowman at acsu.buffalo.edu Thu Oct 12 16:15:02 2000 From: bowman at acsu.buffalo.edu (Charles Bowman) Date: Thu, 12 Oct 2000 16:15:02 -0400 Subject: Printing backspaces Message-ID: <39E61BC6.341FF228@acsu.buffalo.edu> I am trying to output row and column indices in the following code: #============================================================ row = -1 while(row < len(DataColumns[1])): col = 0 row = row + 1 while(col < len(DataColumns)): s = s + DataColumns[col][row] + ', ' col = col + 1 print '%d %d' % (col,row), r"\b\b\b\b\b\b\b" #=========================================================== (DataColumns has a total of 1272 numbers and I want to print it out as 106 rows by 12 columns) In checking the while loops, I printed out the rows and column indices while the while statements did their thing. But the printing comes at the expense of new lines with each new row and col index. As you can see from the print statement, I would like backspaces to be printed (going back to the left origin) after col and row are printed (no carriage returns or line feeds). Instead, I get \b\b\b\b\b\b\b printed after col and row followed by a new line. I have tried various arrangements of \b's in the print statement, without success. What am I missing? TIA Charles Bowman Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 IDLE 0.4 WinNT4.0 SP3, 48 MB RAM From lull at acm.org Wed Oct 4 09:18:07 2000 From: lull at acm.org (John Lull) Date: 4 Oct 2000 08:18:07 -0500 Subject: How many people are making COM objects with Python? References: <8r56ta$3mj$1@nnrp1.deja.com> Message-ID: <8abmtsgqfpe4svqj1amjan46agsqv7shp8@4ax.com> At the dawn of the third millenium (by the common reckoning), "Roger Upole" wrote (with possible deletions): > The biggest gotchas I know of are the bug in the COM events code, > where some events don't show up, Any documentation on this? Thanks. Regards, John From aleaxit at yahoo.com Fri Oct 20 04:35:06 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 20 Oct 2000 10:35:06 +0200 Subject: How can I string encoding to UTF-7. References: <8so8qc$her$1@news2.kornet.net> Message-ID: <8sp0dt0165s@news1.newsguy.com> "junwon,Seo" wrote in message news:8so8qc$her$1 at news2.kornet.net... > I have to string encoding/decoding to UTF-7. > Because, In IMAP protocol, Mailbox name is encoded UTF-7 string. > > Python have a UTF-7 module? Hmmm -- doesn't seem among the built-in codecs, offhand (UTF-8, UTF-16 in several variants, latin-1, mbcs, ascii, ..., but no UTF-7). Anybody knows where additional Python 2 codecs may be located, perchance...? Alex From thomas at cintra.no Fri Oct 20 09:20:04 2000 From: thomas at cintra.no (Thomas Weholt) Date: Fri, 20 Oct 2000 13:20:04 GMT Subject: Server-client-development / Data-extraction without databaseaccess Message-ID: <39f043a6.172071776@news.eunet.no> Hi, I got a PostgreSQL server going. I use a platform independant client to store data in pickled files which is later imported into the database. The problem arises when platforms without python postgresql-driver, namely Windows ( haven't found any postgresql-module so far ), wants to extract data from the database running on a Linux-box. I'm going to build a Web-interface, but being able to use a commandline or a GUI on Windows would be nice too. ( At least for the poor fools still using ehem .. that os ;-> ) So I thought of making a threaded server that could accept simple queries, actually keywords to look for and simple commands for data maintainence, and return some form of data the client could use. One solution would be to serve xml-data to the client and avoid the entire binary problem. But xml would benefit greatly from compression and sending binary files are more difficult according the Socket HowTo. If anybody could give hints, code or tips on how to send data, binary or plain text of arbitary size, between a multi-threaded server and a plain python client, I'd be a very happy man. Thanks From phd at phd.russ.ru Wed Oct 25 04:21:13 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Wed, 25 Oct 2000 08:21:13 +0000 (GMT) Subject: python snippet request: calculate MD5 checksum on 650 MB ISO cdrom image quickly In-Reply-To: Message-ID: On Tue, 24 Oct 2000, Warren Postma wrote: > A new function in the md5 module, md5.md5file(filename) would be nice, if > anyone is listening, for a future python 2.x release. ----- md5wrapper.py ----- #! /usr/local/bin/python """ User wrapper for md5 builtin object Written by BroytMann, Jun 1997. Copyright (C) 1997 PhiloSoft Design """ from md5 import md5 class md5wrapper: def __init__(self, init=None): if init: self._md5 = md5(init) else: self._md5 = md5() def update(self, data): self._md5.update(data) def digest(self): return self._md5.digest() def __repr__(self): str = self.digest() return "%02x"*len(str) % tuple(map(ord, str)) # This nice was suggested by Guido def md5file(self, f): if type(f) == type(''): # If f is string - use it as file's name infile = open(f, 'r') else: infile = f # else assume it is opened file (fileobject) or # "compatible" object (must has readline() method) try: while 1: buf = infile.read(16*1024) if not buf: break self.update(buf) finally: if type(f) == type(''): # If f was opened - close it infile.close() if __name__ == "__main__": print "This must print exactly the string" print "Test: 900150983cd24fb0d6963f7d28e17f72" print "Test:", md5wrapper("abc") ----- /md5wrapper.py ----- Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From aleaxit at yahoo.com Thu Oct 19 05:54:06 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 19 Oct 2000 11:54:06 +0200 Subject: contained execution References: <39EE9600.227A7F52@wasabimg.com> Message-ID: <8smgm501h5l@news1.newsguy.com> "Jeff Davis" wrote in message news:39EE9600.227A7F52 at wasabimg.com... > I am interested in using python as an embedded scripting language. I > have used python for a while (no expert though). Is there a way to say > "execute the following, but only use these functions/modules"? That way, > nobody could write a script to reformat a hard drive and embed it in my > program. What I am looking for is essentially a python equivelant of > "Safe.pm" (from PERL), although hopefully a little easier to use. See chapter 16 in the Library manual, "restricted execution", for tools and suggestions regarding the questions you pose. AMK's "Howto" about it, http://www.python.org/doc/howto/rexec/, is another exposition of these issues. Alex From aleaxit at yahoo.com Thu Oct 5 09:33:09 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 5 Oct 2000 15:33:09 +0200 Subject: very good reasons? References: <8r2k0n01u30@drn.newsguy.com> <8r2r07$53d$1@la-mail4.digilink.net> <39D7F021.C2D5091D@my.signature> Message-ID: <8ri09002d58@news1.newsguy.com> "Greg Ewing" wrote in message news:39D7F021.C2D5091D at my.signature... > Pete Shinners wrote: > > > > b = a.sort() or a.reverse() or a > > Yeeek! That must be the most misleading piece of > Python I've ever seen! It sounds like you're > either sorting or reversing or doing nothing, > when you're actually doing all three. > > If you really want an obfuscated way of writing > it, how about > > b = (a.sort(), a.reverse(), a)[-1] Hmmm -- it does work with the current implementation (because sort is called first, then reverse) but I wonder whether it's guaranteed to keep working for all time. Is left-to-right order of evaluation for tuple-constructor components guaranteed somewhere in the language specs? A pointer would be welcome... Alex From rjroy at takingcontrol.com Mon Oct 16 01:32:05 2000 From: rjroy at takingcontrol.com (Robert Roy) Date: Mon, 16 Oct 2000 05:32:05 GMT Subject: How can I get rid of lambda References: <39EA484C.C57D995A@gte.net> Message-ID: <39ea8dee.463036046@news1.on.sympatico.ca> I went a step further with your code and created a lookup dict for all 256 char values. 100,000 reps went from 9.2 seconds to 3.9 seconds. Append the following to the code you posted #-------------- # create a dict of characters and expansions l = {} for x in range(256): l[chr(x)] = unpack(chr(x)) #print l #print map(None, packedNumber) # do some timing import time # so the range call does not influence the timing reps = range(100000) # test using unpack s = time.clock() for x in reps: unpack(packedNumber) t = time.clock() print 'using unpack', t-s #test using the dict, note there is no need for function call # get rid of the dot lget = l.get s = time.clock() for x in reps: fnJoin(map(lget, packedNumber), '') t = time.clock() print 'using dict.get', t-s On Mon, 16 Oct 2000 00:11:29 GMT, Steve Williams wrote: >I'm working with IBM packed decimal data. The following code works OK, >but there are millions of rows and 10 to 50 columns per row. I want as >much speed as I can get. > >How can I avoid the lambda in the following unpack function? Or better, >is there a faster way? > >By the way, if you want a testimonial to Python's capabilities, do a >Google search on 'packed decimal' and have a look at some of the Java >solutions to this problem. > >=============================================== > >"""Unpack an IBM packed decimal string""" >import string > >#Get rid of the dots >fnJoin = string.join >fnTranslate = string.translate > >#Create translate tables for the left and right nybbles >_strSource = "" >for _i in range(256): _strSource = _strSource + chr(_i) >_trtLeftNybble = string.maketrans(_strSource, \ > "0"*16 + "1"*16 + "2"*16 + "3"*16 + "4"*16 + \ > "5"*16 + "6"*16 + "7"*16 + "8"*16 + "9"*16 + "."*96) >_trtRightNybble = string.maketrans(_strSource,"0123456789+-+-++"*16) >del _strSource >del _i > >def unpack(strPacked): > return fnJoin(map(lambda chrLeft, chrRight: chrLeft + chrRight,\ > fnTranslate(strPacked,_trtLeftNybble),\ > fnTranslate(strPacked,_trtRightNybble)),"") > >try: > packedNumber = '\x01\x23\x45\x67\x89\x0f' > print unpack(packedNumber) >except RuntimeError, e: > print e > >try: > packedNumber = '\x01\x23\x45\x67\x89\x0d' > print unpack(packedNumber) >except RuntimeError, e: > print e > > > From donn at u.washington.edu Wed Oct 25 19:03:44 2000 From: donn at u.washington.edu (Donn Cave) Date: 25 Oct 2000 23:03:44 GMT Subject: Multi-homed socket server? References: <39F74E25.C7473256@schlund.de> <39F74980.C24DC677@maddman.org> <39f749f4_4@corp.newsfeeds.com> Message-ID: <8t7osg$gf8i$2@nntp6.u.washington.edu> Quoth Carsten Gaebler : | Joshua Muskovitz wrote: |> This is just a guess, so take it for what it is. |> |> When you bind with INADDR_ANY, you are saying that you don't care which |> address it binds to. But I don't think this means "accept connections from |> any network adapter". I think it means "select an adapter somehow, bind to |> it, and accept connections on it". | | The ip man page says: "When INADDR_ANY is specified in the bind call the | socket will be bound to all local interfaces." So it should work. Right. And for the original poster, INADDR_ANY is spelled '' (i.e., an empty string supplied as the address parameter is so interpreted.) Donn Cave, donn at u.washington.edu From clarence at netlojix.com Thu Oct 26 10:03:00 2000 From: clarence at netlojix.com (Clarence Gardner) Date: Thu, 26 Oct 2000 07:03:00 -0700 Subject: C's syntax (was Re: Python Formatted C Converter (PfCC)) References: <8t0or303ee@news1.newsguy.com> <39F4FFB7.452EDDEC@alcyone.com> <8t3mdv025uo@news2.newsguy.com> <39F5B404.B5626FB7@alcyone.com> <8t4q8v11lpv@news1.newsguy.com> <39F65EB2.EE2E3B1C@alcyone.com> <8t6894040e@news1.newsguy.com> Message-ID: <972569139.1047789220@news.silcom.com> On Wed, 25 Oct 2000, Alex Martelli wrote: >I take a bus to work every day. It's cheap, fast, generally >punctual and clean. Most buses on that line are also painted >a horrid shade of orange, a color I wouldn't wish on my worst >enemies (with a possible exception for those who proclaim C's >syntax "pretty good":-). Do you truly believe this makes my >commuting 'hellish'...? How *superficial* can you get...? I would guess it actually makes your commute better -- from inside, that's one fewer bus that you don't have to look at :) Do you suppose we could let this thread die sometime soon? I'm usually in the "ignore it and it will go away" school, but this one doesn't seem to want to.... From cg at schlund.de Wed Oct 25 17:18:29 2000 From: cg at schlund.de (Carsten Gaebler) Date: Wed, 25 Oct 2000 23:18:29 +0200 Subject: Multi-homed socket server? References: <39F74980.C24DC677@maddman.org> <39f749f4_4@corp.newsfeeds.com> Message-ID: <39F74E25.C7473256@schlund.de> Joshua Muskovitz wrote: > > This is just a guess, so take it for what it is. > > When you bind with INADDR_ANY, you are saying that you don't care which > address it binds to. But I don't think this means "accept connections from > any network adapter". I think it means "select an adapter somehow, bind to > it, and accept connections on it". The ip man page says: "When INADDR_ANY is specified in the bind call the socket will be bound to all local interfaces." So it should work. cg. From cjc26 at nospam.cornell.edu Mon Oct 2 22:57:21 2000 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Tue, 03 Oct 2000 02:57:21 GMT Subject: listening socket doesnt answer References: <39D8334F.76DEFCD3@altavista.com> Message-ID: * Alexander K menulis: | | where do i best learn about the different address/protocol | families, and how they decide the format for the .bind() method? If you're on a *nix system, try "man socket" :) Or look for a file called socket.h, which is the C header file declaring the socket functions. Also the python library reference page for the socket modules says that it supports AF_UNIX and AF_INET protocols, but apparently nothing else.. | when dealing with a inet/stream socket i pass a tuple to bind, | right? like this .bind((hostname, port)) where hostname is a | string and port an integer. | but in the other cases? With Unix domain sockets, you just pass the filename since they don't have ports associated with them. So something like soc.bind('/tmp/blah') should work. -- cliff crawford http://www.people.cornell.edu/pages/cjc26/ "Man, the Internet is so cool." -Robert From johann at physics.berkeley.edu Tue Oct 10 17:15:04 2000 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 10 Oct 2000 14:15:04 -0700 Subject: ANNOUNCE: PySymbolic - Doing Symbolics in Python References: Message-ID: Pearu Peterson writes: > I have started a project > PySymbolic - "Doing Symbolics in Python" > PySymbolic is a collection of tools for doing elementary symbolic > calculations in Python. The project is in alpha stage. Neat! I'll take a look at it. A few weeks ago, I implemented an *extremely* simplified symbolic class. I just did basic manipulation of what I called "terms", which were composed of a constant times a number of variables raised to various powers. That was nice, but a real symbolic package would be great. Didn't Joe Strout start a project like this a while ago, too? --J -- Johann Hibschman johann at physics.berkeley.edu From echuck at mindspring.com Fri Oct 6 20:36:32 2000 From: echuck at mindspring.com (echuck at mindspring.com) Date: Sat, 07 Oct 2000 00:36:32 GMT Subject: Proposal: Python Class Files References: Message-ID: <8rlr6h$6bc$1@nnrp1.deja.com> In article , Michal Wallace wrote: > Class files would work like this: > > 1. Each class file contains one and only one class. Why? If we have Foo.pc, but the Foo class requires some supporting internal classes, I should be allowed to create them in the same module. However, they wouldn't get put in the containing name space. -Chuck -- http://webware.sourceforge.net Sent via Deja.com http://www.deja.com/ Before you buy. From tgagne at ix.netcom.com Thu Oct 5 19:16:43 2000 From: tgagne at ix.netcom.com (Thomas Gagne) Date: Thu, 05 Oct 2000 19:16:43 -0400 Subject: one possible approach References: <39DCFFC2.A26BF159@ix.netcom.com> Message-ID: <39DD0BDB.A8AAEA5F@ix.netcom.com> XSL's copy command might be useful, but I don't know (right now) how I would encorporate XSL with a C function (or python or whatever) to send that string down a socket. Maybe someone else does? I also thought there might be a spot inside the processor where I could get the file position of where the tag was found and send all the text from there upto and including the . -- .tom -------------- next part -------------- An HTML attachment was scrubbed... URL: From loewis at informatik.hu-berlin.de Mon Oct 9 10:43:25 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 09 Oct 2000 16:43:25 +0200 Subject: Can I use the XML-utilities with Python 1.6? - trying to upgrade XML Processing with Python-code References: <39E18E35.4CA0B552@yahoo.com> Message-ID: OlavB at yahoo.com writes: > I am trying to migrate to Python 1.6. I some f code based on "XML > processing with Python". I get some problems in the xml utility > (xml. libraries) with finding SaxBuiler, and it wants the > Python15.dll. You could use it with Python 1.6, but you will need to recompile all C modules - unless somebody else has already produced a binary distribution. Pretty much the same applies to PyXML, BTW: I made binaries only for 1.5.2 and 2.0b2. Personally, I'd recommend against using Python 1.6. If you want a stable system, you should use 1.5.2. If you want some of the more recent features, you should use 2.0 beta versions. That even includes xml libraries - although the interfaces probably slightly deviate from your book's code (Python 2.0 has SAX2 and minidom). Regards, Martin From marcc at yieldworks.com Sun Oct 29 01:34:25 2000 From: marcc at yieldworks.com (marc cheatham) Date: Sun, 29 Oct 2000 05:34:25 GMT Subject: os.execl problem on winnt References: <39FADF49.2080204@yieldworks.com> <8tfpf7$jnn$1@troll.powertech.no> Message-ID: <39FBB5B7.4B825409@yieldworks.com> That just what I was looking for, thanks for the info. Marc Syver Enstad wrote: > > What I want to be able to do is have Python start a external program and > > wait until that program is finished before it continues. > > Use the os.system call for the easiest way of obtaining what you want. The > documentation says that the exec functions > replace the process that calls exec.. with the new process, I guess that's > why you're having troubles. > > As long as you just want to run a program and wait for it to finish, > os.system will do fine, it searches the path for the process which is often > nice. If you want to do something else while the other process is running > you'll have to use the spawn functions if you're going to stay in the python > std library. The trouble with the spawn.. functions is that they don't > search the path, so under win32 you can use winexec or shellexecute if you > want to do that. From huaiyu_zhu at yahoo.com Wed Oct 11 04:12:37 2000 From: huaiyu_zhu at yahoo.com (Huaiyu Zhu) Date: Wed, 11 Oct 2000 01:12:37 -0700 (PDT) Subject: Possible bug (was Re: numpy, overflow, inf, ieee, and rich comparison) In-Reply-To: Message-ID: [Tim Peters] > We need a glibc expert! Anyone qualify? If there is none here, maybe someone cares to ask in some gcc or gnu news groups? > The 2.0 behavior (set errno to ERANGE on exp underflow) appears to be what > the glibc exp author believes POSIX mandates, and is one of their exp's > possible runtime behaviors, and your own little C program (which you posted > earlier) suggests that's the default behavior under gcc + glibc. So > presumably 1.5.2 config was such as to inhibit the default behavior. > However, nobody changed this on purpose, so it smells like an unintended > side effect of some other (currently unknown) config change. So can we set a flag to explicitly discount ERANGE? There are only 19 lines in the source code that contain ERANGE, and 8 lines containing math_error. All the latter are in Modules/{c,}mathmodule.c. Could we just add an ifdef IEEE754 on these 8 lines? This would go a long way to aleviate this problem before we find a perfect solution, if there is one. > I don't know what to do next. I can't pursue it myself, and you've seen > from the lack of replies to your posts that I'm the only who'll even listen > to you . Guido suggests that one big change in 2.0 is that we're > including a lot more std headers than we used to. It could well be that one > of those #defines some God-forsaken preprocessor symbol one of whose five > meanings (documented or not) is "use POSIX-conformant libm error reporting", > but which someone #include'd in 2.0 to make (who knows?) sockets work right > on some other flavor of Unix. Don't know. Unix config is a mess, and so is > glibc. Best hope now is for someone intimately familiar with glibc > internals to jump in and own this. I'm not interested in where this comes from - the only thing that matters is that it worked in 1.5.2 and breaks in 2.0. Whether the 1.5.2 behavior was intended or not, it's not a bug. The 2.0 behavior is a bug. If Posix conflicts with IEEE floating point arithmetic, then confirming to Posix in this regard is a bug. I would suggest the next thing to do is to introduce an IEEE754 flag and let those who do not like it to voice their opinions. Since this is the same behavior as 1.5.2 I doubt any running code would be broken by this. Huaiyu From aleaxit at yahoo.com Wed Oct 11 08:50:22 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 11 Oct 2000 14:50:22 +0200 Subject: helpplease!! References: <39e45032.5929225@news.atl.bellsouth.net> Message-ID: <8s1o0k030fe@news1.newsguy.com> "grass hopper" wrote in message news:39e45032.5929225 at news.atl.bellsouth.net... [snip] > this is going to sound stupid but i just don't no what it means whats > this e.g. mean. Is it like ect. so-on? "e.g." (for "exempli gratia", or "example given") is a common use in English to abbreviate the idiom "for example". > with .html. it works fine.But how ever i can't even get python to open > a image. One possibility is to use PIL, the Python Imaging Library module. However, while this can _open_ images (and let you work on them with various image-processing thingies) it's not necessarily best if what you want is to DISPLAY the file on the screen (and let the user interact, for example by clicking with the mouse...). > do i have to call on the browser to open a image? if so how do i do > this? You can do that, yes. For example, this very short Python program: import os os.system("start c:/foo.jpg") when run in a typical Windows installation, assuming you have a picture called c:/foo.jpg, will ask whatever application you have told Windows to associate to the extension .jpg (normally, for example, Internet Explorer) to open and display the image. But this is not necessarily a great help to you...! For example, if you do this twice for two image-files: import os os.system("start c:/foo.jpg") os.system("start c:/bar.jpg") the second image will be displayed in the same Internet Explorer window that was displaying the first one; so they will not both be showing onscreen at the same time -- only the second one will be left in view, and only using the browser's "Back" button will the end-user be able to view the first one (again, I am referring to a "typical" Windows installation). If you do want to use your browser, then, to display both images on-screen at once, you need to prepare (and feed to your browser) a little HTML sourcefile -- for example...: import os images = ["c:/foo.jpg", "c:/bar.jpg"] auxhtm = open("c:/foo.htm", "w") for image in images: auxhtm.write(" " % image) auxhtm.close() os.system("start c:/foo.htm") This will show both images at once, one below the other (if they're too large to be shown together in this way, the browser will show a scrollbar...). This minimalist approach could perhaps suffice if you're content of showing the images on screen in this fashion (perhaps with a little text label on each -- you need to generate a little bit more HTML for that, but not much), then let the user give his desired response...: > this is a short of the game > you are asked :which is the pic of a cow > there are 3 pic's to pick from like 01(pig.jpg) or 02(dog.jpg) or > 03(cow.jpg). ...by entering the number in response to a Python "input" call, i.e., from the keyboard (rather than clicking with the mouse on the desired image). > I really won't to learn python but this is really getting to me. I'll assume you mean "want" ("desire") rather than "won't" ("will not")... > would someone show me the code to do this or point me > in the right direction. > I won't it to run in windows as a stand alone game > I'm not asking for a handout just a hand > I won't to wright the game in python . My suggestion is perhaps the simplest way to go, but surely not the most powerful. You may use any of several Python graphical user interface frameworks to display the images on the screen, and detect mouse-clicks on one of them by the user... Alex From debl.spam.no.nonon at world.std.com Tue Oct 24 23:34:11 2000 From: debl.spam.no.nonon at world.std.com (David Lees) Date: Wed, 25 Oct 2000 03:34:11 GMT Subject: Spam be gone References: Message-ID: <39F654BB.93F5C705@world.std.com> This should not be said too loud, but compared with many newsgroups there is remarkably little spam in this group. david David Porter wrote: > > * Jack Morgan : > > > Why does this list include so much spam? Maybe, one a day. In fact, I do > > enjoy reading this list,but i don't enoy reading all that spam. > > The mailing list is linked to the newsgroup comp.lang.python. It is easy to > stop spam on mailing lists by only allowing mail from those subscribed, but > usenet is open to anyone. From olczyk at interaccess.com Thu Oct 19 13:42:10 2000 From: olczyk at interaccess.com (Thaddeus L. Olczyk) Date: Thu, 19 Oct 2000 17:42:10 GMT Subject: A suggestion for python 2.1. References: <39f09400.33100312@nntp.interaccess.com> <8smuqv$1o9$1@flotsam.uits.indiana.edu> Message-ID: <39ef27c1.3714328@nntp.interaccess.com> On 19 Oct 2000 14:01:03 GMT, raja at cs.indiana.edu (Raja S.) wrote: >since you seem to be running your scripts under Unix, why don't you just >use the conventional shell trick ? > Why do people always jump on stupid and rash assumptions. At no point do I say that I am using UNIX. There are no statements that rule out all other operating systems. The fact is that I am A REAL PROGRAMMER who writes REAL PROGRAMS that are used in REAL CIRCUMSTANCES, not some student who tools around on one computer. My scripts have to run on both Windows and UNIX ( linux, Solaris ) machines ( they should and probably do also run on any other OS but I cannot test those ). They need to run on different UNIXes that put python in different directories. The scripts can be placed in all sorts of different locations. Thus the need for tools like autoconfand automake. Maybe when you get out in the real world and do some real world programming you will understand this. As for the suggestion there are three points to consider in the propsal: 1) Compared to most other changes, this one is relatively easy to implement ( say compared to adding braces and removing indentation to denote blocks ). Most of the code has already been written to handle loading modules. 2) It will releave programmers of a lot of configuration nightmares when dealing with scripts that move around often. As ONE example ( note this is not the only example this is the one that I have recently experienced lest some dufus come along and complain that is to small a cicumstance ), often the build systems that I work with start out with a directory say foo and foo/pylib is where the scripts are stored. Later code is added and expanded on suddenly the project is in directory bar and foo is found in bar/a/b/c/foo. Either the scripts stay in foo/pylib, or ( preferably ) moved to bar/pyLib but with a lot of reconfiguration of build scripts. 3) One can use "shadow computation". For exmple youcan have two scripts called foo.py in directories a and b. Normally one wants to execute the a/foo.py script. Occasionally one wants to use b/foo.py. Initially define PYTHONSCRIPTPATH=a:b. Later redefine it PYTHONSCRIPTPATH=b. From apighin at my-deja.com Mon Oct 30 21:55:29 2000 From: apighin at my-deja.com (apighin at my-deja.com) Date: Tue, 31 Oct 2000 02:55:29 GMT Subject: Python processing of an input byte stream References: <8tkoso$84l$1@nnrp1.deja.com> Message-ID: <8tlcav$onl$1@nnrp1.deja.com> Wow! This is great. I will play with this tomorrow morning. If it really is this straight forward, then Python is one seriously powreful tool. Thanks again! In article , Erno Kuusela wrote: > | import sys, time > | ops = { > | 0x1 : lambda: 'Function (main) initialized', > | 0x2 : lambda a: "Key '%s' was pressed" % a, > | # etc. > | } > > | while 1: > | c = sys.stdin.read(1) > | if not c: > > probably works better if you replace the below 2 lines... > > | time.sleep(1) > | continue > > ... with > break > > :) > > | op = ops[c] > | nargs = op.func_code.co_argcount > | args = tuple(sys.stdin.read(nargs)) > | print apply(op, args) > > -- erno > Sent via Deja.com http://www.deja.com/ Before you buy. From the_brain at mit.edu Sun Oct 29 16:32:45 2000 From: the_brain at mit.edu (Alex) Date: 29 Oct 2000 16:32:45 -0500 Subject: Python/C++ Engineers Wanted References: <8tchu7$2gd$1@nnrp1.deja.com> <39FA5040.625CB8E2@gte.net> Message-ID: > Curious why they would need to advertise, though. I would think there > would be sufficient peoples around Boston, considering the kind of > credentials they're looking for. No way -- like everyone else, they're dying for good people. Alex. -- Speak softly but carry a big carrot. From tgagne at ix.netcom.com Sun Oct 15 19:54:40 2000 From: tgagne at ix.netcom.com (Thomas Gagne) Date: Sun, 15 Oct 2000 19:54:40 -0400 Subject: Symbolic debugger for Python Message-ID: <39EA43C0.19B195BD@ix.netcom.com> Does a symbolic debugger exist for Python with a capability similar to gdb to attach to another process? We have a lot of Python code running in the background as servers and it's difficult to debug them using "print" statements--or at least, it is more difficult. On a related note, I want to mention that Python has been working great as language to write server processes in. We do a lot of XML/DB work in Python using middleware and the performance has been great. -- .tom From gward at altavista.net Sat Oct 14 18:04:27 2000 From: gward at altavista.net (Greg Ward spamdrop - see sig for preferred) Date: 14 Oct 2000 22:04:27 GMT Subject: SMTP receive as well as send References: <39e8bfe4.2248931@news.demon.nl> <39e8ce9c@news.server.worldonline.co.uk> Message-ID: On Fri, 13 Oct 2000 22:20:17 +0100, Phil Harris wrote: > I may be talking out of the hole where the sun don't shine here, so someone > correct me if I'm wrong, but: > > SMTP is only for sending, isn't it? > POP3 is only for receiving, isn't it? Correct, if you're talking from the point-of-view of an ordinary Internet client, eg. the type of machine that sits on your desk. But mail servers have to handle the other side of things: when you connect to your ISP's POP server to pick up mail, the server is sending mail through POP (although it's an on-demand, "pull" type of transmission). When you send mail from your PC (using SMTP), you again connect to your ISP's mail server, which then receives your message using SMTP. There are a couple of books out there on programming Internet mail; one from O'Reilly and one from (I think) Addison-Wesley, so they're probably both pretty good. Anyone who thinks they want to write an SMTP server in Python (or any language) should probably get one of those books. And then they should head for one of www.{qmail,exim,postfix}.org to get a real SMTP server. Greg -- Greg Ward gward at python.net http://starship.python.net/~gward/ From effbot at telia.com Mon Oct 9 11:36:06 2000 From: effbot at telia.com (Fredrik Lundh) Date: Mon, 09 Oct 2000 15:36:06 GMT Subject: doubling slashes in a string References: <39de8a48_3@corp.newsfeeds.com> <8rmvbo02dfo@news1.newsguy.com> <8rs9dc0143f@news2.newsguy.com> Message-ID: Alex wrote: > Whoops! You're right. I had never noticed this lexical peculiarity, > and now I wonder about the rationale for it -- since backslashes play > no special role within a rawstring, why the peculiarly specific prohibition > about having an odd number of them _at the end_...? http://www.python.org/doc/FAQ.html#6.29 Why can't raw strings (r-strings) end with a backslash? (implementation note: r-string literals are parsed as ordinary string literals, but the escape codes are stored as is) From mfletch at tpresence.com Fri Oct 6 03:01:36 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Fri, 6 Oct 2000 03:01:36 -0400 Subject: Win32: ByRef equivalent in pythoncom for function callbacks? Message-ID: Okay, I've spent a bit of time trying to do this right with "for demand" to make a quick demo for DOM access via IE, and I got it working for two or three runs. Then somehow the world went screwy and the same code stopped functioning as it should. It's possible that I clobbered the working version with an older version, but I don't see any problem with my current code. I'm creating a Dispatch object for the IHTMLTextContainer interface of the DOM Body element, and this appears to be correct. This interface does define a scrollTop property (both put and get), but when I attempt to access the property, I get a com_error. Any pointers or slaps upside the head for obvious problems would be appreciated. Note: my original code using solely Dispatch objects with no type library was able to directly take self.Document.body.scrollTop, so I suppose it's possible that the dispatch object was on one run not able to get the IHTMLTextContainer module, and in using base Dispatch might have been able to do the same trick. To show this, replace the Dispatch call with: self.body = Dispatch( body._oleobj_, ## "HTMLBody", ## IHTMLTextContainer_CLSID, ) And you'll see that the body becomes a DispHTMLBody instance, which works properly, allowing you to use scrollTop as a property. From what I understand, however, this is not the proper way to get an interface handle. On the other hand, it works :o) . For the simplified demo, I'm just importing directly in the pythonwin interactive environment. The current (nonfunctional) code with traceback follows. Enjoy yourselves, Mike 8<____________ htmlwindow.py _________ '''Demo getting the IHTMLWindow2 pointer from a WebBrowser control ''' # from portals.htmldemo import htmlwindow from win32com.client import * from win32com.server import util, policy from win32com.client import gencache from pywin.tools.browser import Browse from pywin.debugger import set_trace ##from pdb import set_trace import pythoncom, traceback HTMLLib_CLSID = '{3050F1C5-98B5-11CF-BB82-00AA00BDCE0B}' IHTMLTextContainer_CLSID = '{3050F230-98B5-11CF-BB82-00AA00BDCE0B}' IHTMLBody2_CLSID = '{332C4425-26CB-11D0-B483-00C04FD90119}' try: htmlmodule = gencache.EnsureModule( HTMLLib_CLSID, 0, 4, 0, bForDemand=1 ) ## print dir( iemodule) ## print iemodule.DispHTMLBody except (ImportError, pythoncom.error): raise SystemExit( '''this demo requires IE 5.0 or above''' ) class IEEvents: ## def OnVisible( self, visible ): ## print 'visible', visible def OnDownloadComplete( self, *args): print 'NavigateComplete' try: print 'self.Document', self.Document body = self.Document.body print 'body', body if body: ## set_trace() self.body = Dispatch( body._oleobj_, "HTMLBody", IHTMLTextContainer_CLSID, ) print 'body is', self.body self.htmlwindow = self.Document.parentWindow self.SinkTest() except: traceback.print_exc() return 1 def SinkTest( self ): print 'SinkTest' sink = Sink(self.htmlwindow, self.body ) def transformarg(arg): if type(arg)==dispatchType: return Dispatch(arg) elif type(arg)==UnicodeType: return str(arg) return arg arg_transformer = lambda object, args: map(transformarg, args) class Sink: # as in Kitchen ;o) CLSID = CLSID_Sink = pythoncom.MakeIID('{3050F625-98B5-11CF-BB82-00AA00BDCE0B}') _arg_transformer_ = arg_transformer _public_methods_ = [ ## "Ononscroll", ] _dispid_to_func_ = { 1016 : "Ononresize", 1025 : "Ononafterprint", -2147418102 : "Ononhelp", -2147418112 : "Ononblur", -2147418111 : "Ononfocus", 1002 : "Ononerror", 1017 : "Ononbeforeunload", 1024 : "Ononbeforeprint", 1008 : "Ononunload", 1003 : "Ononload", 1014 : "Ononscroll", } def __init__( self, window, body ): self.window = window self.body = body advise( self.window, self) def Ononscroll( self, *args): try: event = self.window.event ## set_trace() print 'body', self.body print 'scroll', self.body.scrollTop except: traceback.print_exc() return 1 def advise( window, sink ): cpc = window._oleobj_.QueryInterface( pythoncom.IID_IConnectionPointContainer ) cp = cpc.FindConnectionPoint( # this is the clsID of the IHTMLWindow2 interface sink.CLSID_Sink, ) cookie=cp.Advise( util.wrap(sink) ) sink._olecp,sink._olecp_cookie = cp,cookie ie = DispatchWithEvents("InternetExplorer.Application", IEEvents) ie.Visible = 1 ie.Navigate( 'www.tpresence.com' ) 8<________________ traceback __________ ... body scrollTraceback (innermost last): File "/portals\htmldemo\htmlwindow.py", line 89, in Ononscroll except: File "D:\bin\lang\Python\win32com\client\__init__.py", line 347, in __getattr__ return apply(self._ApplyTypes_, args) File "D:\bin\lang\Python\win32com\client\__init__.py", line 341, in _ApplyTypes_ return self._get_good_object_(apply(self._oleobj_.InvokeTypes, (dispid, 0, wFlags, retType, argTypes) + args), user, resultCLSID) com_error: (-2147352573, 'Member not found.', None, None) body -----Original Message----- From: Mark Hammond To: Mike Fletcher; python-list at python.org Sent: 10/4/2000 9:07 AM Subject: RE: Win32: ByRef equivalent in pythoncom for function callbacks? > What I did was strip the particular event handler class out of the mshtml > Makepy interface file (which will not import, likely because > it's 1.9 MB), Note there is a new "for demand" option that will create a package, and only generate the specific interfaces when actually needed - for exactly this reason! Most of the gencache functions have a bForDemand param... Python talking to a DOM - that seems to be happening a bit, recently ;-) Mark. From evan at 4-am.com Mon Oct 30 19:12:37 2000 From: evan at 4-am.com (Evan Simpson) Date: Tue, 31 Oct 2000 00:12:37 GMT Subject: a simple example of Stackless Python References: <8tjrn2$esm$1@news.nuri.net> Message-ID: "June Kim" wrote in message news:8tjrn2$esm$1 at news.nuri.net... > It seems like there are few people who understand Stackless Python > and the stuffs, and I'm not one of them. Can anyone explain me > this simple code? The paper was not very helpful for me to understand. I'll give it a shot. "this = continuation.current()" creates a continuation object, and "this.update(n)" does two things: First, it updates the continuation object so that calling it will cause program execution to continue at that line, as though "this.update(n)" had just returned the value passed in the call. Second, it evaluates to n, so that the line acts as though it were "k = n". Thus, "this(k-1)" jumps to the "k = this.update(n)" line and makes it act as though it were "k = k-1". It means "continue at the point just after we were updated, with k-1 on top of the stack". The whole function behaves exactly like: k = n while k: k = k-1 ...and demonstrates how a continuation can be used to construct a simple loop. -- Cheers, Evan @ digicool & 4-am From loewis at informatik.hu-berlin.de Sun Oct 8 12:38:01 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 08 Oct 2000 18:38:01 +0200 Subject: Dictionaries from C References: <8ris22$rdf$1@nnrp1.deja.com> Message-ID: kellyk at my-deja.com writes: > I've been looking for an interface that works similar to Py_BuildValue > for dictionaries only in reverse. > > for example: > > PyObject *r= Py_BuildValue("{s:i, s:s}", "blah", 1, "blah2", "asdf"); > > will build a dictionary but I can't seem to find an easy way to reverse > the operation. There isn't a direct reverse function. Instead, you should use PyDict_GetItemString. Regards, Martin From tim_one at email.msn.com Fri Oct 27 19:43:47 2000 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 27 Oct 2000 19:43:47 -0400 Subject: PythonWin IDE sucks! In-Reply-To: <00102712405206.00566@quadra.teleo.net> Message-ID: [Dale Strickland-Clark] > OK. I give up. > > This newsgroup has to get the prize for some of the fragile, sensitive > egos on the net. [Patrick Phalen] > Really? I've been following it closely for over four years and have > somehow never noticed that. He's probably referring to me, Patrick: I was offended by his post, feel threatened by your response, and loathe my weakness for hitting the "Reply" button *almost* as much as I despise my life. But be that as it may, Dale's got a real problem. The interactive module edit<->run cycle under Python IDEs really is tricky, sometimes requiring non-trivial knowledge of how sys.modules is used & managed internally in order to avoid picking up stale definitions. Guido has pronounced kindly about ideas to, e.g., make IDLE fire up a new process each time, which avoids all module caching surprises, and effectively simulates the useful parts of the by-hand quit-and-restart procedure some people use today. I generally write a little driver program that reloads the world and fires off my test cases from scratch, and run that without quit-and-restart. Whatever, if you're expecting it to work by magic, you'll be disappointed today. or-if-not-you-maybe-dale-ly y'rs - tim From jjlucsy at concentric.net Fri Oct 6 14:26:18 2000 From: jjlucsy at concentric.net (Joel Lucsy) Date: Fri, 6 Oct 2000 14:26:18 -0400 Subject: base conversion References: Message-ID: Forgot to mention that I'd like the output to be considerably shorter than the original. I have already tried the base64 module. "Joel Lucsy" wrote in message news:DIoD5.53621$Q56.1189298 at news-east.usenetserver.com... > I'm looking to convert a number like > "5273030383518181846929222846464626075757", base 10, into a different base, > like 62 or 64. What could I do? > > -- > Joel Lucsy (jjlucsy at concentric.net) > > From Lisowski.Tomasz at sssa.SPAM-OFF.com.pl Wed Oct 18 09:13:01 2000 From: Lisowski.Tomasz at sssa.SPAM-OFF.com.pl (Tomek Lisowski) Date: Wed, 18 Oct 2000 15:13:01 +0200 Subject: Exception Handling in Python References: Message-ID: <8sk7im$8n$1@news.tpi.pl> U?ytkownik "Quinn Dunkan" napisa? w wiadomo?ci news:slrn8upe01.ero.quinn at zloty.ugcs.caltech.edu... > On Tue, 17 Oct 2000 06:10:29 GMT, Suchandra Thapa > wrote: > > I'm trying to figure out how to catch an exception, do some > >error handling and then reraising the same exception in python. > >Right now, I'm doing it using the following code: > > > >try: > > ... > >except Foo: > > ... > >except Bar: > > ... > >except Exception, x: > > ... > > raise x > >else: > > ... > > Other people have pointed out the argumentless 'except' and 'raise', but if > what you want to do is some "cleanup", you may really want 'finally': > > try: > try: > ... > except Foo: > ... > except Bar: > ... > else: > ... > finally: > ... IMHO the proper version is given below: try: try: ... finally: ... except Foo: ... except Bar: ... except: ... because after try ... except ... the exception IS already handled, so there is no need to surround it once more in a try ... finally ... construction, which in your case does not even know that an exception has been raised. My version includes try ... finally ... inside try ... except ... construction, which makes the necessary cleanup first, then responds to the exception. The other correction is that else: is replaced by except:, which handles all other exception types. Best regards Tomasz Lisowski From nickatvideosystemdotcodotuk Fri Oct 6 06:35:35 2000 From: nickatvideosystemdotcodotuk (Nick Trout) Date: Fri, 6 Oct 2000 11:35:35 +0100 Subject: wxPython on IRIX6.5 References: Message-ID: <39ddab36@news.xtml.co.uk> > CC -DSWIG_GLOBAL -DHAVE_CONFIG_H -DWXP_USE_THREAD -I. `wx-config --cflags` > -I/tsri/python/share/include/python1.5 > -I/tsri/python/sgi4DIRIX646/include/python1.5 > -I/mgl/prog/src/gtk/wxPython-2.2.1/src -O -OPT:Olimit=0 `gtk-config --cflags` > -c helpers.cpp > "/usr/include/stdarg.h", line 119: warning(1047): macro redefined differently > #define va_start(vp, parmN) (vp = ((va_list)&parmN + sizeof(parmN))) > ^ If you're getting a "macro redefined" warning then does this suggest you have a path conflict? ie. va_start is defined somewhere else and the correct definition may be the former one? The knock on effect is that nothing compiles properly? Try swapping path precidence or removeing some paths?? Hope that helps, sorry if that's too simplistic. You get a similar kind of thing happening if you try and compile a DirectX app with an old API. What I wouldnt give for some of your sunny Californian weather at the moment.... :-) Nick > "/usr/include/stdarg.h", line 124: warning(1047): macro redefined differently > #define va_arg(vp,mode) ((mode *)(void *)( vp = (va_list) \ > ^ > > "helpers.h", line 85: error(1136): too many arguments in function call > Py_DECREF(m_obj); > ^ > > "helpers.cpp", line 136: error(1136): too many arguments in function call > PyObject* sysargv = PySys_GetObject("argv"); > > "helpers.cpp", line 137: error(1136): too many arguments in function call > int argc = PyList_Size(sysargv); > ^ > > "helpers.cpp", line 141: error(1136): too many arguments in function call > argv[x] = PyString_AsString(PyList_GetItem(sysargv, x)); > ^ > > > and it goes on and on ! .... > I have built many extensions for Python wrapping C and C++ code .. but I have > no clue what the problem is here :( HELLLLLP > > -michel > > > -- > > ----------------------------------------------------------------------- > > >>>>>>>>>> AREA CODE CHANGE <<<<<<<<< we are now 858 !!!!!!! > > Michel F. Sanner Ph.D. The Scripps Research Institute > Assistant Professor Department of Molecular Biology > 10550 North Torrey Pines Road > Tel. (858) 784-2341 La Jolla, CA 92037 > Fax. (858) 784-2860 > sanner at scripps.edu http://www.scripps.edu/sanner > ----------------------------------------------------------------------- > > From knotwell at ix.netcom.com Fri Oct 6 18:34:55 2000 From: knotwell at ix.netcom.com (Brad Knotwell) Date: 06 Oct 2000 15:34:55 -0700 Subject: concurrent access to dbms (was best way to store dbm records?) References: <8rnu4o$emc$1@bob.news.rcn.net> <9f2vtss06scg26psv7gvfv8agt68jc91h3@4ax.com> <8rpeko$4jd$1@bob.news.rcn.net> Message-ID: "Michael B. Allen" writes: > I may have a different issue however. The docs on shelve(and I would imagine > dbm's in general) report that you cannot concurrently read from it if it is > open by a writer. If I have interpreted the docs correctly this is true even > if it is only open by a single writer. > Can I have may readers with one writer or might this corrupt the database?. > Or in the worst case will it mearly display possibly incomplete information > to a reader? In my experience (I use gdbm), if a writer has the file then no one else will be allowed access to it. Interestingly enough, this limitation doesn't appear to occur if you use bsddb routines. However, you, apparently, will only get the information that exists when you opened the database file. It appears that you won't receive any of the new information. > In my case I don't care if readers get realtime info. Can I just > periodically make a copy of the dbm for readers? I've done this in the past. The writer may still need to close its file descriptor first to sync all the written data to the disk. You could also do the following (there's probably a bazillion more and better options than this as well): o write a simple server that does all the dbm work (reads and writes) o use two dbm files--a massive read one and a miniature write one. When we hit a determined number of records or trigger time in the mini one, the updater sends the readers a shutdown msg, the readers close their file descriptor, the updater opens the massive db for write, writes out the records in the mini db, nulls out the mini db, closes the massive db, closes the mini db, and sends the readers a startup msg. The readers will then reopen the massive db for read. When we hit the number of records or time threshold again, the process starts over. o open/close the file as needed (depending on your traffic needs this might actually be okay) I like option #3 the best ;-). #2 is probably the performance winner (esp. in read-many, write-few environments), but is extremely error-prone (using signals or any other notification mechanism). I've seen #1 used, but I hate it for anything beyond extremely trivial records. Or you could just use a relational database. . .they'll have figured out the concurrency stuff way better than us mere mortals. > Also, how many records can I put in a dbm without taking a big performance > hit? 10000? I dunno. On a 200Mhz RS/6000, we were able to lookup an entry in a 200k member set in approximately one second (NOTE: from the command line. . .includes python's startup time). FWIW, we ended up using gdbm 'cause AIX's standard dbm module wouldn't allow records longer than 4500 (or something like that) bytes. > Thanks, > Mike --Brad From stephan.becker at oracle.com Fri Oct 6 09:47:16 2000 From: stephan.becker at oracle.com (Stephan Becker) Date: Fri, 06 Oct 2000 15:47:16 +0200 Subject: Does a PVM (Python Virtual Maschine) exists ? Message-ID: <39DDD7E4.E0BC5E26@oracle.com> Hello out there, I?am planing to write a middle tier application using python. This thing will be a kind a software like those nifty applets called Java Servlets running within a JVM of a application server or virtual middle tier of a database (Oracle 8i). I like to communicate with other instances of my persistent Python Servlet on different servers using the ORB protocoll or any other matching middle tier communication facility. This piece of Software will use a database connections (MySQL, Oracle ... ) and schould produce HTML dynamically like Servlet?s usually do. I?ve heard about JPython producing java classes runable on any JVM. But this cross compiled bytecode does not perform as good as python normaly performs. So what about a P(ython)VM ?? Any comments ? reagards Stephan -------------- next part -------------- A non-text attachment was scrubbed... Name: stephan.becker.vcf Type: text/x-vcard Size: 374 bytes Desc: Card for Stephan Becker URL: From pete at visionart.com Tue Oct 31 18:13:59 2000 From: pete at visionart.com (Pete Shinners) Date: Tue, 31 Oct 2000 15:13:59 -0800 Subject: Newbie - Please don't flame References: Message-ID: <8tnjln$2d5$1@la-mail4.digilink.net> "Super Bolo" wrote > can i make .py files stand-alone exe files without invoking the interpreter > so that they can run also on computers without interpreter installed?? Is > Active Python for that purpose??? heh, this has got to be the absolute #1 asked question for all newbies. (heck, i remember asking it myself after a week of getting started) there's a few methods for doing this, but all of them take some learning. http://www.python.org/doc/FAQ.html#8.11 you can also create executables that include your scripts and the needed components of the python interpreter, check out http://starship.python.net/crew/gmcm/distribute.html (note, i'm not sure about the status of these for python2) on the other hand, it is pretty easy to nowaday just tell people to install python. the windows installer is quite foolproof these days, and as long as you don't need any extra modules or packages, you can perhaps just provide an URL to python and tell people to install it. (if you name your scripts with the ".pyw" extension, they will run without opening a DOS box) From ahopkins at dynacare.com Fri Oct 27 14:50:06 2000 From: ahopkins at dynacare.com (Albert Hopkins) Date: Fri, 27 Oct 2000 18:50:06 GMT Subject: PythonWin IDE sucks! References: <7tuivs46osods22uumpvsvsap2jocrd4si@4ax.com> <8tc42n$lm3$1@nnrp1.deja.com> <798jvs4p780j4m9n2pnddj4cti22gpn9pd@4ax.com> <4ShK5.453$G4.40777@newsread2.prod.itd.earthlink.net> Message-ID: On Fri, 27 Oct 2000 17:42:33 +0100, Dale Strickland-Clark wrote: > >"sucks!" was meant to be light hearted - as indicated by the "!", >which is freqeuently used thus these days. I thought that "!" was used to place emphasis on something. So by that I thought you meant that PythonWin *really* sucks. Lightheartedness, I thought, was usually expressed with a smily :-) on the 'Net. >Now how about some intelligent discussion about how we can get this >fixed? I want to use Python to develop stuff. -- Albert Hopkins Sr. Systems Specialist Dynacare Laboratories ahopkins at dynacare.com It is easy to shield the outer body from poisoned arrows, but it is impossible to shield the mind from the poisoned darts that originate within itself. Greed, anger, foolishness and the infatuations of egoism - these four poisoned darts originate within the mind and infect it with deadly poison. From bowern at ses.curtin.edu.au Mon Oct 23 06:34:46 2000 From: bowern at ses.curtin.edu.au (Nick Bower) Date: Mon, 23 Oct 2000 18:34:46 +0800 Subject: large file support References: <8sqn2l$ec$1@ncar.ucar.edu> Message-ID: <39F41446.22DD065B@ses.curtin.edu.au> not sure if it helps, but don't forget the fromfile method in the array class. nick From gtalvola at nameconnector.com Fri Oct 13 10:36:15 2000 From: gtalvola at nameconnector.com (Geoff Talvola) Date: Fri, 13 Oct 2000 10:36:15 -0400 Subject: Programmer-Wanna-Be (Is Python for me?) References: <8s2354$ep2$1@nnrp1.deja.com> <1mxF5.36034$Cl1.869085@stones> Message-ID: <39E71DDF.E90E6971@NameConnector.com> Lokie wrote: > > 4. Is there a WYSIWYG editor (like Frontpage is for HTML)? Is this > > what Tkinter is? Is there a 'better' WYSIWYG editor for Python that I > > should use instead? > Good question, not seen one but I'm sure there was a thread in this group > about a RAD for Python a few months ago...... I've looked at the WYSIWYG GUI designers for Python (on Windows only), and in my opinion the best I've seen is wxDesigner for wxPython. Information is at http://www.roebling.de/ . It's a commercial product, but it's pretty cheap -- $19 for students for non-commercial use, $69 for a single user, or $199 for 10 users. It doesn't attempt to be a complete IDE like PythonWorks or Boa Constructor, but it appears to do a great job of quickly letting you lay out your GUI and spit out wxPython code. In fact, I like its approach to GUI layout better than VB's approach. Download the evaluation version and try out the samples. As a bonus, it will also work with wxWindows if you need GUIs in C++ programs. I haven't actually used it yet for a real project, but I'd like to try it the next time I need to put together a Python GUI. -- - Geoff Talvola Parlance Corporation gtalvola at NameConnector.com From aleaxit at yahoo.com Mon Oct 30 07:26:27 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 30 Oct 2000 13:26:27 +0100 Subject: PIL for Python 2.0 on Win32? Message-ID: <8tjpnj02um1@news1.newsguy.com> Can anybody suggest somewhere I could either download a pre-built version of the Python Imaging Library for Python 2.0 on Win32, or else the jpeg, zlib and tk (others I've forgotten...?) headers & libraries it relies on? E.g., I have the Tcl/Tk installation that come with Python 2, ditto for the zlib that also comes with it, etc, but not the headers that PIL needs to use them, and I'd rather not try and guess where to fetch ones in line with the binaries I have (the headers don't seem to be in the Python sources either). Thanks for any pointers! Alex From borcis at geneva-link.ch Tue Oct 24 04:22:01 2000 From: borcis at geneva-link.ch (Boris Borcic) Date: Tue, 24 Oct 2000 10:22:01 +0200 Subject: C's syntax (was Re: Python Formatted C Converter (PfCC)) References: <8t0or303ee@news1.newsguy.com> <39F4FFB7.452EDDEC@alcyone.com> Message-ID: <39F546A9.8BF2F72E@geneva-link.ch> Erik Max Francis wrote: > C is not a trivial language, so the rules are not trivial. If you have > sloppy thinking or are not familiar with the details of the language, > you will get yourself into trouble with a non-trivial language. To me this sounds like a lawyer's defense of legal language : it certainly *fails to convince* that it is *not* the case that a relatively opaque language gets promoted precisely for the benefit of permitting such ways of argumentation ; e.g. putting the load of responsibility for error on the shoulders of the ignorant, while clearing the experts for the responsibility of creating the occasions of error. BB -- "Aesthetic sense is to soul as eyes are to viewpoint" From fidelman at world.std.com Mon Oct 23 16:39:46 2000 From: fidelman at world.std.com (Miles R. Fidelman) Date: Mon, 23 Oct 2000 20:39:46 GMT Subject: ANY NEWS ON THE STARSHIP? References: <8su1su$euq$1@nnrp1.deja.com> <39F47496.22449099@holdenweb.com> <8t1ur1$8jt$1@panix3.panix.com> <39F481E4.989093B6@holdenweb.com> Message-ID: Steve Holden (sholden at holdenweb.com) wrote: : Aahz Maruch wrote: : > : Longer term, mirroring is going to be essential if Python is to : dominate the world effectively. It certainly would have helped in : the current situation. Longer term, something like CPAN is going to be needed. From aa8vb at yahoo.com Tue Oct 17 08:01:49 2000 From: aa8vb at yahoo.com (Randall Hopper) Date: Tue, 17 Oct 2000 08:01:49 -0400 Subject: Organizing Python Code In-Reply-To: ; from pinard@iro.umontreal.ca on Fri, Oct 13, 2000 at 10:02:37PM -0400 References: <39D7F3DE.D4104FE7@ix.netcom.com> <39D82B17.81958D15@esatclear.ie> <39DBB04C.1681E515@esatclear.ie> <39DBC391.EDF52FF8@my.signature> <39DD2319.6ECE412E@esatclear.ie> <39de333a$1_2@goliath2.newsfeeds.com> <39E01B59.EFFC865C@esatclear.ie> <39E61224.98D26349@boi.hp.com> Message-ID: <20001017080149.A2419982@vislab.epa.gov> Fran?ois Pinard: |[Bill Anderson] | |> rgrep is a recursive grep. |> (RedHat has it on their cd(s), dunno where else to get it) | |> rgrep -l "def foo" * | |> Or you can make a shell macro that combines find, xargs, and grep. | |Just use a recent `grep'. Let me see: | -r, --recursive ?quivalent ? --directories=recurse. I just use xargs since it's supported everywhere. ff '*.c' | xargs grep 'mystring' where ff is a 'find file script': find . -name "$1" -type f -print -- Randall Hopper aa8vb at yahoo.com From jhg at galdon.com Sat Oct 21 07:04:36 2000 From: jhg at galdon.com (Juan Huertas) Date: Sat, 21 Oct 2000 13:04:36 +0200 Subject: About urllib or urllib2 Message-ID: <8srt5b$d0e$1@diana.bcn.ttd.net> Is possible access to a internet page (url) knowing the username and password via urllib or urllib2? For example: In page http://www.xxx.zz/users/prog.asp is possible knowing username and password retrieve a file (zzz.txt). I can download the file via urllib ? Thak you. Juan Huertas. jhg at galdon.com From g_will at cyberus.ca Tue Oct 31 08:27:55 2000 From: g_will at cyberus.ca (Gordon Williams) Date: Tue, 31 Oct 2000 08:27:55 -0500 Subject: Extensions with LCC References: <39FD7EDC.EF818DA2@helsinki.fi> Message-ID: <8tmhal$2n0i$1@news2.ottawa.cyberus.ca> If you are looking to create an extension quickly you can use the Borland compiler. See below. Make sure that you download the correct version for the version of Python that you are using. Regards, Gordon Williams *** Creating Python Extensions Using Borland's Free Compiler V3.0*** I am pleased to announce a set of step-by-step instructions and examples to create extensions using the free Borland Command Line Compiler with the standard Python Windows Binary Distribution. This information can be found at http://www.cyberus.ca/~g_will/pyExtenDL.shtml . Version 3.0 updates the linking library to Python 2.0 and removes an obsolete patch for the Python 1.5.2 config.h file. I have also added a section about using VIDE (http://www.objectcentral.com/), a free and useful IDE for Borland and other compilers. ********************************************************************** ABSTRACT This paper describes the method used to create Python Extensions using the Borland 5.5 C++ Compiler (BCC). This command line compiler is available free from http://www.borland.com/bcppbuilder/freecompiler/. I describe the steps that are necessary to produce the extension from the C source code and how to set up the associated files for the compiler and linker. These extensions work with the standard Windows Distribution of Python. The process used to produce the extension is very easy and consists of running a simple batch file that I provide as part of this package. A section is provided on how to create extensions using VIDE to make it even easier. I also have some examples and a short reference section at the end of this paper that may be helpful. Gordon Williams g_will at cyberus.ca "Kimmo P??kk?nen" wrote in message news:39FD7EDC.EF818DA2 at helsinki.fi... > Hi, > I'm new to Python, so these questions may be trivial or some basics > may be not well understood (at least I feel puzzled enough :). > I'm trying to compile an extension to the Python. I'm working on > Windows NT and as a compiler I use (freely available) LCC compiler, From sholden at holdenweb.com Thu Oct 19 08:30:35 2000 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 19 Oct 2000 08:30:35 -0400 Subject: Perl rules - Python drools References: <8s6ksl$mea$1@ctb-nnrp2.saix.net> <39e77de7.28583100@news.davesworld.net> Message-ID: <39EEE96B.7C8C8891@holdenweb.com> Does the phrase "get a life" have any significance in this context? regards Steve "David T. Grove" wrote: > > On Fri, 13 Oct 2000 11:38:52 +0200, "Wayne Paterson" > wrote: > > > > > > > > >begin 666 cameleatingpython.jpg > > If you don't mind, I won't waste my time peeking at this. > > As an avid perl user: I should point out something. You are in > violation of trademark law. You are not permitted to use a camel in > association with the Perl language without specific written permission > from O'Reilly and Associates. You have also used a trademarked > O'Reilly symbol for an unauthorized attack on the Python community, > for which O'Reilly can seek additional legal remedies, since you are > misrepresenting O'Reilly and Associates to the public. Your email > address seems to indicate that you are making this attack on behalf of > your company. If this is true, your company may be held equally > liable. > > That I know of, there is no such restriction on using a python image > with the python language. That would be almost impossible for O'Reilly > to hold up in court. Maybe if O'Reilly had used a four-legged octopus > for their Python book, _that_ they could trademark, not that anyone > would use it. > > The disentanglement of Python from external corporate control, even in > an area such as this, is more than just a few major plusses for the > Python language... and I don't even particularly care for the Python > language. (I'm here to watch trends, learn what I can, enjoy > non-elitist community discussion, and make some objective personal and > business-level decisions.) > > You might consider thinking twice before trolling, there's likely to > be someone in the group who can slam you harder than you wanna be, you > wannabe. > > Pete > The Trollmeister -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ From gavrilov at iname.com Thu Oct 19 12:31:06 2000 From: gavrilov at iname.com (Alexander Gavrilov) Date: Thu, 19 Oct 2000 16:31:06 GMT Subject: Undocumented re bug??? References: <39EF1503.B34048EA@insight.co.il> Message-ID: I don't have this problem with Python 2.0 on WinNT4. I got the following: Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. IDLE 0.6 -- press F1 for help >>> import re >>> s="""MDKFWWHAAWGLCLVPLSLAQIDLNITCRFAGVFHVEKNGRYSISRTEAADLCKAFNSTLPTMAQMEKALS IGFETCRYGFIEGHVVIPRIHPNSICAANNTGVYILTSNTSQYDTYCFNASAPPEEDCTSVTDLPNAFDGPITITI VNRDGTRYVQKGEYRTNPEDIYPSNPTDDDVSSGSSSERSSTSGGYIFYTFSTVHPIPDEDSPWITDSTDRIPATT LMSTSATATETATKRQETWDWFSWLFLPSESKNHLHTTTQMAGTSSNTISAGWEPNEENEDERDRHLSFSGSGIDD DEDFISSTISTTPRAFDHTKQNQDWTQWNPSHSNPEVLLQTTTRMTDVDRNGTTAYEGNWNPEAHPPLIHHEHHEE EETPHSTSTIQATPSSTTEETATQKEQWFGNRWHEGYRQTPREDSHSTTGTAAASAHTSHPMQGRTTPSPEDSSWT DFFNPISHPMGRGHQAGRRMDMDSSHSTTLQPTANPNTGLVEDLDRTGPLSMTTQQSNSQSFSTSHEGLEEDKDHP TTSTLTSSNRNDVTGGRRDPNHSEGSTTLLEGYTSHYPHTKESRTFIPVTSAKTGSFGVTAVTVGDSNSNVNRSLS GDQDTFHPSGGSHTTHGSESDGHSHGSQEGGANTTSGPIRTPQIPEWLIILASLLALALILAVCIAVNSRRRCGQK KKLVINSGNGAVEDRKPSGLNGEASKSQEMVHLVNKESSETPDQFMTADETRNLQNVDMKIGV""" >>> o=re.compile('C.{15}A.{3,4}G.{3}C.{2}G.{8,9}P.{7}C') >>> r = o.search(s) >>> r.span() (52, 97) >>> o=re.compile('C.{15}A.{3,4}G.{3}C.{2}G.{8,9}P.{6}') >>> r = o.search(s) >>> r.span() (52, 95) >>> r.group() 'CKAFNSTLPTMAQMEKALSIGFETCRYGFIEGHVVIPRIHPNS' >>> o=re.compile('C.{15}A.{3,4}G.{3}C.{2}G.{8,9}P.{6}.') >>> r = o.search(s) >>> r.span() (52, 96) >>> o=re.compile('C.{15}A.{3,4}G.{3}C.{2}G.{8,9}P.{6}.C') >>> r = o.search(s) >>> r.span() (52, 97) >>> r.group() 'CKAFNSTLPTMAQMEKALSIGFETCRYGFIEGHVVIPRIHPNSIC' From glenfant at equod.com.nospam Thu Oct 19 12:15:59 2000 From: glenfant at equod.com.nospam (Gilles Lenfant) Date: Thu, 19 Oct 2000 18:15:59 +0200 Subject: DOS console control Message-ID: <8sn6ij$pve$1@reader1.imaginet.fr> Hi everybody, Does any of you experts know how to have a control of the cursor position, text/background colors, clearing screen (...) of a DOS console. An additional iint to have a control of the keyboard (ctrl and alt modifiers, cursor keys, function keys...) is welcome ! You'd say "wrong newsgroup". I reply "No, it's in Python". Thanks in advance. Gilles Lenfant From sabren at manifestation.com Sun Oct 8 15:17:46 2000 From: sabren at manifestation.com (Michal Wallace) Date: Sun, 8 Oct 2000 15:17:46 -0400 (EDT) Subject: future of Python: Stackless, Standard -> fragmentation ? In-Reply-To: <39E0A674.6444E3A9@appliedbiometrics.com> Message-ID: On Sun, 8 Oct 2000, Christian Tismer wrote: > I still consider these considerations ridiculous, born from > the fear these continuations could make it into Python somehow. > I never saw the argument "don't do this since JPython can't do it" > before I begun to break the holy stack. I always wondered what the big deal is myself, especially if you pack away the magic stuff in modules somewhere.. After all, JPython can use all sorts of modules that Python can't.. Kawa (scheme for java) does continuations with exceptions... They say you can't do co-routines with it, but that in java, those should be done with threads: http://www.delorie.com/gnu/docs/kawa/kawa-tour_19.html Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From phd at phd.russ.ru Fri Oct 13 11:30:53 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Fri, 13 Oct 2000 15:30:53 +0000 (GMT) Subject: How can i remove a scalar In-Reply-To: <39E7251D.C93C76D4@hotmail.com> Message-ID: On Fri, 13 Oct 2000, joonas wrote: > How can i empty a scalar. > In perl it would be > > delete($myscalar); Please, stop your perl habits. This is python newsgroup. Before asking questions it is *highly* recommended you'd read tutorials, FAQs and other documentation. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From Alain.Desilets at nrc.ca Tue Oct 31 15:35:20 2000 From: Alain.Desilets at nrc.ca (Alain Desilets) Date: Tue, 31 Oct 2000 15:35:20 -0500 Subject: How can I get a list of all public symbols in Python librararies References: <39FDC14E.50FAABBE@nrc.ca> Message-ID: <39FF2D05.AA33EF20@nrc.ca> Erno Kuusela wrote: > | In order to build support for dictation of Python code, I need a list of > | all the symbols (functions, methods, classes, variables) defined in the > | standard Python libraries. > [...] > | Any suggestions on what would be the easiest way to get such a list? > > one definition of what's public is what's documented - so you > could extract the symbols from the docs. the doc sources (tex) > would be quite easy to scan for these. Thanks for that hint. Is there a specification of the tex format somewhere as it is used by Python for documentation? > the other obvious way would be to use the python introspection > features to look for them. maybe you could use the pyclbr module, > which provides class browser support. also worth looking > at may be inspect and htmldoc by ka-ping yee, you can > find those at (bottom of page). While we are on this topic, what's the most commonly used HTML document generator? I have been using pythondoc but it seems to be an orphan project and it is a bit unstable. Does htmldoc supersede pythondoc? -- Alain D?silets Research Officer National Research Council Canada Institute for Information Technology Agent de recherche Conseil national de recherche Canada Institut de technologies de l'information email/courriel: alain.desilets at iit.nrc.ca From tonys111 at erols.com Wed Oct 4 11:56:16 2000 From: tonys111 at erols.com (Tony Sideris) Date: Wed, 4 Oct 2000 11:56:16 -0400 Subject: 4-byte string to integer References: <39DB493F.A7AA3E40@noaa.gov> Message-ID: <8rfjv1$8g0$1@bob.news.rcn.net> "j vickroy" wrote in message news:39DB493F.A7AA3E40 at noaa.gov... > How can a 4-byte string be converted to an unsigned integer using > Python? > > The byte order may be either big or little endian. > > Thnaks use the 'struct' module and unpack(). -Tony From gbreed at cix.compulink.co.uk Mon Oct 16 07:25:34 2000 From: gbreed at cix.compulink.co.uk (gbreed at cix.compulink.co.uk) Date: 16 Oct 2000 11:25:34 GMT Subject: how do i PUT or POST to a web server? References: <39e8e8ff.41ae1@newton.pacific.net.au> Message-ID: <8seoje$bi4$1@plutonium.compulink.co.uk> In article <39e8e8ff.41ae1 at newton.pacific.net.au>, astuart at NO.mira.SPAMnet (Andrew) wrote: > Hello > > Can anyone point me to an example of how I PUT or POST data to a web > server > using Python? Dunno about PUT, but for POST you supply a second value to urllib.urlopen like: file = urllib.urlopen(url, urllib.urlencode(dataAsDictonary)) If you want more low-level control, I've found this code to do much the same thing: import httplib, urllib def postDataReturnResponse(server, file, data): message = urllib.urlencode(data) h = httplib.HTTP(server) h.putrequest('POST', file) h.putheader('Accept', 'text/html') h.putheader('Content-type', 'application/x-www-form-urlencoded') h.putheader('Content-length', str(len(message))) h.endheaders() h.send(message) h.getreply() return h.getfile() From aahz at panix.com Fri Oct 6 12:54:15 2000 From: aahz at panix.com (Aahz Maruch) Date: 6 Oct 2000 09:54:15 -0700 Subject: PEP 4: Deprecation of standard modules References: Message-ID: <8rl03n$c0j$1@panix3.panix.com> [posted & e-mailed] In article , Martin von Loewis wrote: > >I just finished a first draft of a PEP on deprecating (and eventually >removing) modules from the standard Python library; it is available >from > >http://python.sourceforge.net/peps/pep-0004.html Looks pretty good. I think it could stand to be slightly more clear that a module must first be listed as deprecated and only after one or more releases as a deprecated module may it be obsoleted. I'll send you exact edits if you want. Main reason I'm posting this publicly is because I object to the deprecation/obsolence of the gopherlib module. One of my ISPs uses gopher as a way of reporting status information (see gopher://rexx.com), and there may well be other gopher servers out there. I'm hoping to rally support from other people who think gopher is not yet extinct. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 There's a difference between a person who gets shit zie doesn't deserve and a person who gets more shit than zie deserves. --Aahz From p.agapow at ic.ac.uk Fri Oct 27 11:29:12 2000 From: p.agapow at ic.ac.uk (Paul-Michael Agapow) Date: Fri, 27 Oct 2000 16:29:12 +0100 Subject: Binding arguments to parameter functions Message-ID: <1ej64j6.1r2g6nc1krebqsN%p.agapow@ic.ac.uk> I've just struck a problem that I'm sure can be solved in Python but not the way I was trying. The below is a very simplified example: Say you have a some objects with assorted properties in a list and you want to fetch objects from the list according to their properties. Hence: class simple_object: def __init__ (self, name): self.name = name A = simple_object ("bert") B = simple_object ("ernie") B = simple_object ("big bird") L = [A, B, C] You could write a function that accepts a function as a parameter, that assesses each object until one tests true: def findWithProperty (L, func): for item in L: if func (item): return item return None def isErnie (item): if item.name == "ernie": return 1 return 0 X = findWithProperty (L, isErnie) But how can you avoid writing a seperate function for each property & state? (e.g. to find on any given name, not just "ernie".) The below doesn't work, as findWithProperty doesn't know what "name" is: def findWithName (L, name): return findWithProperty (L, lambda x: x.name == name) I guess one solution might be to write a function wrapper that binds arguments to given parameters in the passed function but this seems like too much hard work. Any solutions? -- Paul-Michael Agapow (p.agapow at ic.ac.uk), Biology, Imperial College "Pikachu's special power is that he is monophyletic with lagomorphs ..." From roy at panix.com Sun Oct 15 20:36:32 2000 From: roy at panix.com (Roy Smith) Date: Sun, 15 Oct 2000 20:36:32 -0400 Subject: How can I get rid of lambda References: <39EA484C.C57D995A@gte.net> Message-ID: sandj.williams at gte.net wrote: > I'm working with IBM packed decimal data. The following code works OK, > but there are millions of rows and 10 to 50 columns per row. I want as > much speed as I can get. Python is great at lots of stuff. Getting the most speed possible out of 10s or 100's of millions of math operations is not one of them. This sounds like something you might want to write in a true compiled language. From jjlucsy at concentric.net Fri Oct 6 14:23:16 2000 From: jjlucsy at concentric.net (Joel Lucsy) Date: Fri, 6 Oct 2000 14:23:16 -0400 Subject: base conversion Message-ID: I'm looking to convert a number like "5273030383518181846929222846464626075757", base 10, into a different base, like 62 or 64. What could I do? -- Joel Lucsy (jjlucsy at concentric.net) From lss at excosoft.se Wed Oct 4 04:18:03 2000 From: lss at excosoft.se (lss at excosoft.se) Date: Wed, 04 Oct 2000 08:18:03 GMT Subject: Inefficiency of __getattr__ References: Message-ID: <8rep3p$e93$1@nnrp1.deja.com> If I may... I think the advantages of static typing best come to show when working with third-party libraries and APIs. Compare the following method signatures of an XML DOM API function, in Python and Java: def appendChild(self, newchild): ... public Node appendChild(Node newChild) {...} In the Python example, there's no way of easily telling what this function really wants for its 'newchild' parameter. Sure, anyone can figure out it's probably a DOM node, but what interface should this DOM node have in order for the method to work? Can I pass in my own DOM node implementation and expect it to work? Not unless I either subclass an existing node implementation from the same API (which can be dangerous or quite a hassle at times) or actually read the entire function and check exactly what attributes will need to be accessed from the node object (a bit more work than most would be willing to undertake). In the java example, Node is an interface, org.w3c.dom.Node. This interface specifies not only the exact interface of the method itself, but also indirectly the exact interfaces necessary for all objects passed to and from the function. Thus I don't have to worry about determining the necessary interfaces for the objects I pass in to the method, the compiler will do it for me. In the case of Java interfaces, there is an even more important advantage: they're standardized. Simply because the org.w3c.dom.Node interface exists and pretty much all Java DOM-based libraries use it I can make my own DOM node implementation (which implements this interface) and make it work with any XPath implementation available, for example. In Python, I would have to engage in extensive studies of the XPath library and adapt my DOM node implementation's interfaces for that particular library, and in the end it probably wouldn't work with any other available XPath implementations. Providing similar interface functionality in Python would be pretty easy, but what's the point if only I use interfaces and they aren't standardized? I think interfaces could be adapted to work with dynamic typing in Python also, however. The trick would be to get people to use them and agree on which interfaces to use. The basic advantage I see of static typing is: it allows the compiler to do validation and verification work automatically that otherwise would have required a lot of time from the programming, especially when working with 3rd party APIs. -- Ludvig Svenoniu Excosoft AB ludvig at excosoft.se / dominio at hem.passagen.se In article , kragen at dnaco.net (Kragen Sitaker) wrote: > In article , > wrote: > >>Every time I've argued static versus dynamic typing with a > >>static-typing fan, they've ended up concluding that what they really > >>hate is not dynamic typing but silent coercions. > > > >You haven't argued with me. :) > >C++ allows silent coercions in a few places that make sense -- cast to base > >class, call of user defined "operator T()" and call of user defined > >constructor, besides the "usual" numeric conversions and conversion of 0 to > >any pointer type (this can actually be a problem, like where stuff is > >defined to operate on integers and pointers, the language would be much > >better off with magic like > >#define NULL __null > >than #define NULL 0 where "_null" is compiler magic for the null pointer of > >any type and 0 favors being an integer before being a pointer.. > >std::vector's constructor runs into this problem). > > > >To keep things from a exploding combinatorially in the compiler, the > >language only allows one level of silent conversion. > > OK, so you agree that silent coercions cause problems in some cases in > C++, some of which cases are built into the language. > > So what's the advantage of static typing over dynamic typing? Does it > help you catch bugs, and if so, which ones? > -- > Kragen Sitaker > Perilous to all of us are the devices of an art deeper than we ourselves > possess. > -- Gandalf the Grey [J.R.R. Tolkien, "Lord of the Rings"] > > Sent via Deja.com http://www.deja.com/ Before you buy. From jaepstein_63 at yahoo.com Wed Oct 25 09:14:41 2000 From: jaepstein_63 at yahoo.com (jaepstein_63 at yahoo.com) Date: Wed, 25 Oct 2000 13:14:41 GMT Subject: Creating printed source code listings Message-ID: <8t6mbq$766$1@nnrp1.deja.com> Hi, This may be slightly off-topic, but here goes. While traversing source code online using Speedbar, etags, etc. is all very nice, sometimes what I really need is to print out a lot of code in a nice organized manner. In particular, it would be nice to have: (a) two page numbers: one local for each file, and the other global for the entire comprehensive listing (b) an index showing on which page(s) I can find references to a particular symbol. Distinguishing between a function definition and non-defining references would also be nice. At this point, I am mostly interested in such a tool for Python code, but would like it in the future for Perl, C, Java, Matlab, and Elisp. I would prefer to be able to control this somehow through NT Emacs, but both Unix-based solutions and non-Emacs-friendly solutions could also be OK. Thanks for any pointers, -Jonathan Sent via Deja.com http://www.deja.com/ Before you buy. From SBrunning at trisystems.co.uk Fri Oct 20 10:35:47 2000 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Fri, 20 Oct 2000 15:35:47 +0100 Subject: Import problem Message-ID: <31575A892FF6D1118F5800600846864D5B12EE@intrepid> > From: Sindh [SMTP:skodela at my-deja.com] > How can I import a module by giving a name of list elements. > > Eg: > for n in os.listdir('.'): > import n How about (untested): for n in os.listdir('.'): exec('import %s' % n) Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From max at alcyone.com Sat Oct 21 15:23:25 2000 From: max at alcyone.com (Erik Max Francis) Date: Sat, 21 Oct 2000 12:23:25 -0700 Subject: How to determine what called __cmp__ method? References: <39F13807.657E03AF@alcyone.com> Message-ID: <39F1ED2D.F2560A9C@alcyone.com> Fredrik Lundh wrote: > bzzt. try again. Argumentation by assertion, eh? -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ If I had another face, do you think I'd wear this one? \__/ Abraham Lincoln Product's Quake III Arena Tips / http://www.bosskey.net/ Tips and tricks from the absolute beginner to the Arena Master. From ats1 at ukc.ac.uk Sun Oct 8 12:25:33 2000 From: ats1 at ukc.ac.uk (Adam Sampson) Date: 08 Oct 2000 17:25:33 +0100 Subject: join() References: <8rjj82$dnb$1@nnrp1.deja.com> <39DD9A9A.7130@hvision.nl> <8rlrdr$6ed$1@nnrp1.deja.com> <8rntb8$fhb$1@panix6.panix.com> Message-ID: <87n1gfe1vm.fsf@cartman.azz.net> aahz at panix.com (Aahz Maruch) writes: > >What other things in Python have become non-intuitive in your opinion? > > print >> file, "foo" I don't see why that needs to be part of the language. class ShiftWriter: """A writer class which works like C++'s ostream. For instance: o = ShiftWriter(sys.stdout) o << "This is a list: " << [1, 2, 3] << "\n" """ file = None def __init__(self, file): self.file = file def __lshift__(self, arg): self.file.write(str(arg)) return self import sys o = ShiftWriter(sys.stdout) o << "This is a list: " << [1, 2, 3] << " and a number: " << 3 << "\n" o << "I hate C++.\n" If people want this (bleurgh), why not just add the __lshift__ method to file objects? -- Adam Sampson azz at gnu.org From matt at mondoinfo.com Tue Oct 24 16:43:44 2000 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Tue, 24 Oct 2000 20:43:44 GMT Subject: Scripting SSH with Python References: Message-ID: On Tue, 24 Oct 2000 13:21:30 -0700, Lenny Self wrote: >I am scripting SSH or actually rsync using ssh and I am in need of a >bit of help. When I make the SSH connection I am prompted to enter a >password... my problem is that I don't know how to look for this >promt and have the script submit the password for me. Can anyone >give me some help on this. >I have been experimenting with os.popen and os.popen3 but I am either >looking in the wrong spot or I am not doing it correctly. Lenny, You're on the right track but (as you've found) messing around with getting the IO to be correctly unbuffered and searching for the right strings quickly gets to be a nuisance. That's why there's Expect (which uses Tcl) and the various Expect-like Python modules. If you go to the Vaults of Parnassus: http://www.vex.net/parnassus/ and do a search for "expect" I bet that you'll find something that will make your life easier. Regards, Matt From mjackson at wc.eso.mc.xerox.com Thu Oct 26 09:54:30 2000 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 26 Oct 2000 13:54:30 GMT Subject: [Numpy-discussion] ? References: Message-ID: <8t9d2m$lqo$2@news.wrc.xerox.com> Konrad Hinsen writes: > boncelet at udel.edu@SMTP at python.org writes: > > But (donning my contrarian hat), while appealing to newcomers > > is a laudable goal, Python will die if it does not appeal to serious > > programmers writing serious code. The CS world is littered with > > dead teaching languages (anyone remember PLC?). IMHO, the > > right question to ask is "what do serious programmers want?" > > Making the bold claim to be a serious programmer, I'd say they want to > be able to specify either integer or float division, but they don't > care about the precise syntax, as long as both are straightforward to > do. Absolutely. I come from a Fortran background and have no trouble at all with 3/2 yielding 1. The problem is that code seldom looks like this: a = 3/2 Instead it looks like this: a = b/c and I have yet to find an algorithm for which "b/c yields integer if b and c are both integers, else float" is actually appropriate behavior! Particularly in my usual application domain (Python as an interactive steering and scripting language for Fortran and C modules) preventing inadvertent arrival of integers at such expressions is a major PITA. Give us div, or (better) //, for integer division. The purists can then overload it for their class-of-rationals. -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson I respect faith, but doubt is what gets you an education. - Wilson Mizner From paul.moore at uk.origin-it.com Thu Oct 26 06:04:08 2000 From: paul.moore at uk.origin-it.com (Paul Moore) Date: Thu, 26 Oct 2000 12:04:08 +0200 Subject: popen2.popen2,3,4 from Python 2.0 on NT 4.0 SP5 References: <39F767B2.266F4965@home.com> Message-ID: On Thu, 26 Oct 2000 05:11:24 +0200, David Bolen wrote: >Mark Tompkins writes: > >> I was doing some testing, and have hit the wall right off the bat. When >> I use popen2.popenX('cmd') to call the sqlplus utility, reading stdout >> of the cmd appears to hang when the read is past the last character in >> the buffer, or when there is no data (as what happens, if there is an >> error)???? [...] >Alternatively, the sqlplus utility could be waiting for stdin to close >for some reason - if you aren't going to be feeding input to the child >process that way, I'd suggest closing that handle, or not using a >popen# that gives it to you. Unless you've found that sqlplus doesn't >run without a valid stdin. If SQL*Plus is given a nonexistent script file, it reports an error and then goes into interactive mode. (In fact, if it is given a valid script which doesn't finish with an exit command, it also goes into interactive mode after running the script). To quit SQL*Plus, and hence get an EOF on stdout (which allows your stdout read to complete) you should close stdin (or send an exit command on it). Remember, the pipes are buffered, so even if you have some output, it may not be available to you because the pipe is waiting for EOF or for the buffer to fill. This is why popen2-style calls are prone to deadlock. You *have* to be careful of buffering issues and the like. But to summarise, close the stdin pipe before reading from the stdout pipe. (Actually, in this case, if you aren't writing anything to stdin, why use popen2 at all?) Hope this helps, Paul From Lisowski.Tomasz at sssa.com.pl Mon Oct 9 05:43:45 2000 From: Lisowski.Tomasz at sssa.com.pl (Tomek Lisowski (TPK)) Date: Mon, 9 Oct 2000 11:43:45 +0200 Subject: TkInter on VMS? Message-ID: <8rs3ua$p87$1@news.tpi.pl> Hi, Is there a Tkinter port on OpenVMS system (Alpha)? If not, are there any plans to create one? Regards Tomasz Lisowski From olivierS.dagenaisP at canadaA.comM Wed Oct 18 18:59:54 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Wed, 18 Oct 2000 22:59:54 GMT Subject: Bad documentation (no biscuit!) Message-ID: I have found the documentation provided with version 1.5.2 _and_ 2.0 to have a big hole in it! Specifically, the file is /lib/os-fd-ops.html and the problem is the constants/flags used with the os.open function: it isn't obvious what the flags stand for... After some searching on the net, I found the following descriptions for the flags: (from a Unix Java package or something) O_APPEND Open in append-only mode. O_CREAT Open with creation flag. O_EXCL Open with exclusive access flag. O_NDELAY Open with no-delay flag. O_NOCTTY Open but don't make it the control tty. O_NONBLOCK Open in non-blocking mode flag. O_RDONLY Open for read-only flag. O_RDWR Open for update flag. O_SYNC Open and keep-disk-synchronized flag. O_TRUNC Open and truncate flag. O_WRONLY Open for write-only flag. Can these be added to the documentation, in that sorted order? (plus an elaboration on what a control tty is and what non-blocking or no-delay do would be very nice..) Definitions for O_DSYNC, O_RSYNC and O_BINARY are still missing, anybody can fill them in? (although I have a good hunch as to what O_BINARY does...) am-I-the-only-one-who-isn't-familiar-with-those-flags-ly y'rs -- ---------------------------------------------------------------------- Olivier A. Dagenais - Software Architect and Developer "Someone called 'Type your name here' is impersonating me on the internet and is posting exactly the same things I am posting!" From MarkH at ActiveState.com Wed Oct 25 04:19:45 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 25 Oct 2000 08:19:45 GMT Subject: WIN32 questions References: Message-ID: "Drew Whitehouse" wrote in message news:wl7l6xwhjt.fsf at anu.edu.au... > One thing I *don't* need is users logging on and off. When the machine > boots up it should immediately login to a pre-defined account and stay > logged in. Does that simplify things ? Things are a bit complex in > that the programs running on the touch screen stations don't run > asynchronously. They all need to start a particular activity at the > same time, at the command of the control system. In this case, you don't really want a service. You probably want a simple, normal GUI application - either with or without a visible window. This would be run from the startup group, and can just manage the processes as it sees fit. As long as you can ensure no one is able to log on or off, it shouldn't be a problem. Mark. From not.this at seebelow.org Mon Oct 30 16:34:37 2000 From: not.this at seebelow.org (Grant Griffin) Date: Mon, 30 Oct 2000 21:34:37 +0000 Subject: C's syntax (was Re: Python Formatted C Converter (PfCC)) References: Message-ID: <39FDE96D.10FE1FCA@seebelow.org> Tim Peters wrote: > > [Grant Griffin] > > Just for the record, Backus also played "Mr. McGoo"-- ... > > [Alex Martelli] > > I'll trust you on this. Like many people with even mild physical > > disabilities, and like anybody with decent empathy, I have a hard > > time understanding what's supposed to be fun in sight-impairment. > > It's the comedy of misunderstandings. Mr. Magoo Now I just _knew_ I had spelled that wrong! I just couldn't remember the right way. (My eyesight is OK, but I think my memory needs new glasses. ) > enjoyed grand adventures > due to acting upon his flawed perceptions of the world (to which everyone > with a smidgen of introspection can relate, sight-impaired or not). A > better question is why Mr. Magoo prospered as long as it did: his > predicaments were so shallow that the cartoons rarely raised so much as a > chuckle. Yeah, I agree. Even if one removes one's "politically correct" hat (which, strangely, seems to disable the funnybone), the show really wasn't all that funny. Then again, the last time I saw it, I was so young that I probably didn't understand any of the satirical overtones of it--if any. It just seemed mostly stupid to me. But Backus was great as a voice actor: he managed to somehow make Magoo "entertaining"--if not actually "funny". > a-blow-to-someone-else's-groin-is-a-laff-riot-by-comparison-ly y'rs - tim if-Fatty-Arbuckle-were-politically-correct,-we'd-have-to-call-him -"Roscoe*" =g2 *see http://www.findagrave.com/pictures/2525.html -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From trentm at ActiveState.com Thu Oct 26 11:59:06 2000 From: trentm at ActiveState.com (Trent Mick) Date: Thu, 26 Oct 2000 08:59:06 -0700 Subject: TypeError In-Reply-To: <39F84AB2.1CB3C26D@hotmail.com>; from keisari_@hotmail.com on Thu, Oct 26, 2000 at 06:16:02PM +0300 References: <39F84AB2.1CB3C26D@hotmail.com> Message-ID: <20001026085906.D16027@ActiveState.com> On Thu, Oct 26, 2000 at 06:16:02PM +0300, joonas wrote: > The code that did the error is shown below. > ########## > speedgear = first - second > ########## It would help if you would also include the output of print type(first) print type(second) Trent -- Trent Mick TrentM at ActiveState.com From boncelet at udel.edu Tue Oct 24 11:27:54 2000 From: boncelet at udel.edu (Charles Boncelet) Date: Tue, 24 Oct 2000 11:27:54 -0400 Subject: [Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich comparison References: <39EB3D03.A00C78B6@jps.net> <39F4A4DE.9202540A@udel.edu> <8t3ota028jv@news2.newsguy.com> Message-ID: <39F5AA7A.2C5E35CE@udel.edu> Alex Martelli wrote: > "Charles Boncelet" wrote in message > news:39F4A4DE.9202540A at udel.edu... > [snip] > > > > > Guido thinks that 2/3 returning 0 was a design mistake, > [snip] > > I often want 2/3 to equal 0, but then again I learned FORTRAN years ago. > > > > My point is that if 2/3 = 0.667, then special syntax is needed for those > > applications that want 2/3=0. The current syntax is very simple, even > > if slightly confusing to a complete newby. > > Note that a prominent beginners' language, Pascal, avoids this > specific design mistake: 2/3 is 0.6666667, and you use 2 div 3 > if you want truncating-division. 2/3 returns a floating-point > number also in another language that may well be the only one > a beginner knows, Visual Basic in all of its forms. Therefore, > it is quite possible that people who have programmed before get > very surprised by the truncation -- not everybody is learning > Fortran, C or Java as their first language...:-). I certainly concede 2/3=0 may be startling to a newcomer, but feel that its as important or more so for a language to appeal to experienced programmers. E.g., Fortran, C, Java are survivors and lots of serious code are written in these languages. Pascal is a dying (dead?) language. Visual Basic is a survivor, but not because 2/3 = 0.667 :-) > > > I'd rather have 2/3 return a _rational_ number 2/3, as in > Scheme -- another reasonably popular beginners' language. > But that requires having rationals built-in, I guess...:-). Having never learned Scheme, I didn't know this. A built-in rational class is an interesting notion. Charlie -- Charles Boncelet 302-831-8008 Dept of Electrical and Computer Engineering 302-831-4316 (fax) University of Delaware boncelet at eecis.udel.edu http://www.eecis.udel.edu/~boncelet/ From g2 at seebelow.org Sat Oct 7 09:04:49 2000 From: g2 at seebelow.org (Grant Griffin) Date: Sat, 07 Oct 2000 14:04:49 +0100 Subject: JPython Status References: <8rfqga$9sd$1@nnrp1.deja.com> <8rhsrj$i8j$4@newsserver.rrzn.uni-hannover.de> Message-ID: <39DF1F71.FE520B68@seebelow.org> Bernhard Reiter wrote: > > In article , > "Ivan Frohne" writes: > > > > wrote in message = > > news:8rfqga$9sd$1 at nnrp1.deja.com... > >> While I see the importance of JPython, I would go as far as saying = > > that > >> JPython should be the main Python vehicle. Let's not forget that Java > >> is not open source. Scott McNealy is free to screw every one up, > >> whenever he feels like it. > > > > I guess you meant you would NOT want JPython to be the Python standard = > > bearer. > > But CPython is not really open source, either. > > This is not true. > Python qualifies as open source and free software. > Java implementations from Sun do not. And Sun has a firm grip > legal on the java specs. > > > Guido is free to screw every one up. > > He has less handles. He cannot withdraw the current Cpython > implementation for being free software. Heck, he and Tim Peters combined can't even make it _public domain_! not-that-there's-anything-wrong-with-the-current-license- -ly y'rs =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From robin at alldunn.com Sun Oct 15 00:16:28 2000 From: robin at alldunn.com (robin at alldunn.com) Date: Sun, 15 Oct 2000 04:16:28 GMT Subject: Where is wxPython? References: <39E33757.E9F81F9C@cicei.ulpgc.es> Message-ID: <8sbb2q$nq2$1@nnrp1.deja.com> In article <39E33757.E9F81F9C at cicei.ulpgc.es>, Enrique wrote: > Hi: > I have tried to download wxPython 2.2.1 from SourceForge (file > wxPython-2.2.1.EXE), but the file is not accesible (in fact no one file > in the site is downloadable) > Where else can I find wxPython 2.2.1? > I'm downloading from SourceForge okay right now (a bit slow though.) If it still doesn't work for you there's still some files at http://alldunn.com/wxPython/dist/ that I havn't cleaned up yet. -- Robin Dunn Software Craftsman robin at AllDunn.com http://wxPython.org Java give you jitters? http://wxPROs.com Relax with wxPython! Sent via Deja.com http://www.deja.com/ Before you buy. From MarkH at ActiveState.com Mon Oct 30 09:05:25 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Mon, 30 Oct 2000 14:05:25 GMT Subject: Using more than 7 bit ASCII on windows. References: <8tdlgd$r0t$1@news.nuri.net> <39FA90D9.7070403@ActiveState.com> <8tfpf7$jnn$2@troll.powertech.no> <39FCA0B5.6040606@ActiveState.com> <+k=9Obpkexxebyymyh8GKU+y+3g8@4ax.com> Message-ID: <39FD7F49.7000105@ActiveState.com> Paul Moore wrote: > I can accept this. But I still don't know how to enter a literal > string containing a "?" character into Python. More explicitly, Python > accepts the line > > >>> s = "?" > > But what does this *mean* (ie, what should I expect the semantics of s > to be?) This means that you have a Python string, containing a single character with ASCII value > 127. It so happens that given your current font and code page, this shows up as a British pound symbol. It is _not_ the canonical representation of a British pound symbol - it just happens to be that symbol in your code page. > No, I can be convinced. However, what I don't see is how I should > write a literal string which os.chdir will recognise as being composed > of the characters '1', '0' and '?' (ie, in whatever form necessary to > cause Python to change directory to the directory I created at NT's > command line with "mkdir 10?" in my Latin-1 setup.) *sigh* Pythonwin is still mis-behaving here :-( Well, in this case it is actually _behaving_. The following works for me from Pythonwin, but not a dos box. >>> os.getcwd() 'F:\\' >>> d="\\test?" >>> os.chdir(d) >>> os.getcwd() 'F:\\test\243' >>> print os.getcwd() F:\test? >>> In the dos box, I can't make it work :-( > BTW, if Python has chosen not to assign a meaning to characters above > 127 (my interpretation of your comment "Python has chosen not to have > a default character set"), does that not imply that string literals > containing characters >127 should raise an exception? When they need to be interpreted as a "character" and no encoding is available, this is exactly what happens (the dreaded "UnicodeError: ASCII encoding error: ordinal not in range(128)" exception). Unfortunately, Python's historic use of string objects for binary data (ie, as returned by file.read(), for example) means that rule can not be made for all strings everywhere. Python can not define a meaning for string characters > 127, as they only have one in the context of a code page (or encoding). The operating system may have a default encoding, and it is arguable that Python should use this as the default (although also good arguments against it). Either way, Python will still not itself have special meaning for bytes in string objects in this range. > Fair. So the question remains, how do I chdir to a directory named > "10?"? No idea. > (My issue is different from the display issue which started the thread > - sorry, it looks like my misunderstanding has muddied the waters by > linking 2 unrelated issues...) And my complete misunderstanding of _all_ the issues isn't helping either ;-) So that said, I would wait a few days for corrections to this post to appear before I believed any of it! Mark. From richard at NOhurricaneSPAM.dabsol.co.uk Thu Oct 19 14:25:18 2000 From: richard at NOhurricaneSPAM.dabsol.co.uk (Richard) Date: Thu, 19 Oct 2000 19:25:18 +0100 Subject: Pmw.ScrolledListBox Message-ID: Is it possible to disable the underlining that occurs in a Pmw.ScrolledListBox?? My intention is to run a Python application alongside Motif applications and the different behaviour may confuse the users. When I created a simple app with a Tkinter listbox, it didn't underline the selected item, however I can't get the same behaviour from a Pmw.ScrolledListBox. regards, Richard From johann at physics.berkeley.edu Fri Oct 27 16:18:22 2000 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 27 Oct 2000 13:18:22 -0700 Subject: [Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich , comparison References: <8t65060en@news1.newsguy.com> <39F7D93F.B5B201B4@home.com> <8tc1en0129j@news1.newsguy.com> <39F9C00B.B51361D9@san.rr.com> Message-ID: Darren New writes: > Alex Martelli wrote: >> mod (ideally) for truncating division >> remainder (currently existing but spelled %) > Better than spelling it with the *wrong* name. Why spell "remainder" as > "mod", which implies it is "modulo" when it isn't? Personally, I've never > found a need for "remainder" and often found a need for "modulo" and had to > fix it every time those two differ. What's 'remainder', if not the same as 'modulo'? I understand both of those terms to mean "least positive residue". Unfortunately python doesn't do this for negative divisors, which is a bit of a glitch. "r = a % m" should preferrably be in the range from 0 < r < |m|, right? This won't work with python's default division, where everything rounds to negative infinity. Fix that, and everything works. By the way, what is the logic behind "-1/-3 = 0"? That just seems broken. -1/3 = -1, so we should have -1/-3 = 1. If division were defined that way, we could simply let % give the least positive residue, and everyone would be happy. Is there any situation in which you would want -1/-3 = 0? --J -- Johann Hibschman johann at physics.berkeley.edu From lvirden at cas.org Sat Oct 28 12:57:25 2000 From: lvirden at cas.org (lvirden at cas.org) Date: 28 Oct 2000 16:57:25 GMT Subject: Tk with thread References: <7tuivs46osods22uumpvsvsap2jocrd4si@4ax.com> <00102712405206.00566@quadra.teleo.net> Message-ID: <8tf0hl$fc9$1@srv38.cas.org> According to Seung Chan Lim : :I'm just fooling around with threads and Tk... Danger Will Robinson... Tk is not thread safe yet. -- Even if explicitly stated to the contrary, nothing in this posting should be construed as representing my employer's opinions. From loewis at informatik.hu-berlin.de Sun Oct 8 13:07:40 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 08 Oct 2000 19:07:40 +0200 Subject: Code obfuscation / decompilers? References: <39de791e_4@corp.newsfeeds.com> <39DE9F04.59C95D24@pehr.net> <39dea172_4@corp.newsfeeds.com> Message-ID: "Joshua Muskovitz" writes: > But a "real" obfuscator, which took bytecode and munged it into > something really bizarre would help a lot more. Did you have a look at freeze? It is harder to extract the bytecode from compiled C that it is extracting it from pyc files. Regards, Martin From scarblac at pino.selwerd.nl Mon Oct 9 09:33:45 2000 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 9 Oct 2000 13:33:45 GMT Subject: doubling slashes in a string References: <39de8a48_3@corp.newsfeeds.com> <8rmvbo02dfo@news1.newsguy.com> <8rs9dc0143f@news2.newsguy.com> Message-ID: Alex Martelli wrote in comp.lang.python: > Whoops! You're right. I had never noticed this lexical peculiarity, > and now I wonder about the rationale for it -- since backslashes play > no special role within a rawstring, why the peculiarly specific prohibition > about having an odd number of them _at the end_...? They still have a special role - they escape quotes. r"\"" still needs to be equal to '"'. As a consequence, a single \ at the end of a raw string always escapes the quote, so the string isn't closed. > Oh well, then I guess my above-quoted suggestions will have to be reworded: > > newname = oldname.split('\\').join(r'\\') > newname = oldname.replace('\\', r'\\') Note that if he's doing things with pathnames on Windows, it might be a lot easier to use / instead of \ to start with (that works). Remco Gerlich From see at my.signature Wed Oct 4 19:56:01 2000 From: see at my.signature (Greg Ewing) Date: Thu, 05 Oct 2000 12:56:01 +1300 Subject: Organizing Python Code References: <39D7F3DE.D4104FE7@ix.netcom.com> <39D82B17.81958D15@esatclear.ie> <39DBB04C.1681E515@esatclear.ie> Message-ID: <39DBC391.EDF52FF8@my.signature> Russell Wallace wrote, concerning "import *": > > What problems do you see it causing? In my experience, the main thing you lose is the ability to easily track down which module a given identifier is coming from. This can be quite important when working on someone else's code, or your own code some time later. Recently I had occasion to work on a Borland Pascal program written by someone else, consisting of a few dozen source files spread over several directories. I found myself wishing that Borland Pascal had a more explicit import mechanism than just "uses modulename". It's certainly more work to maintain an explicit import list, but I find that it pays off in the long run. Another alternative is to just import the module name and always use qualified references. That gives you most of the same benefits for less work, at the expense of a slight runtime penalty. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From aleaxit at yahoo.com Mon Oct 23 12:36:30 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 23 Oct 2000 18:36:30 +0200 Subject: C's syntax (was Re: Python Formatted C Converter (PfCC)) References: <8t0or303ee@news1.newsguy.com> <39F45AF5.E7387466@alcyone.com> Message-ID: <8t1po201220@news1.newsguy.com> "Erik Max Francis" wrote in message news:39F45AF5.E7387466 at alcyone.com... [snip] > > foo * bar; > > That's just the way the language works. It's neither good nor bad. Having to "go non-local" to even _parse_ some code IS inherently bad. Why should the syntax tree change drastically depending on what is or isn't typedef's in some system headers...?! > It's certainly not ambiguous and confusing unless you _try_ to write > pathological code. If this happens to be the last declaration/first statement in a block (in C89; dunno if C99 admits declarations among statements), and you're trying to locally declare bar as a pointer to type foo, this will cause a silent error (by language syntax rules; no doubt the "any reasonable compiler will warn" argument will be used again?-) if foo, rather than naming a type, names a global numeric variable (and so does bar). You may consider using global variables "pathological code", but it's still a rather widespread practice, you know. The allegedly "pretty good syntax" of C admits overriding names in nested blocks, so this could happen even with no global variables involved (although the 'locality' in this case might make diagnosis less of a horror). > > Even from a human-factors point of view, such syntactic > > tripwires (over which people DO keep stumbling...) as > > if(a=0) ... /* oops, an assignment...! */ > > Any reasonable compiler will warn about this. Any reasonable language syntax would forego the need for such warnings. If you program in the language-syntax defined by "that subset of C which my favourite compilers will accept without warnings", then it's not C's syntax that you are using, but, rather, that specific subset. The subsetting is, no doubt, a good idea, to reduce a bit the horrors of C syntax. But the need for it militates _against_ the assertion that said syntax is "pretty good". > > or > > foo* bar, baz; /* NOT two pointers... */ > > That's a programmer error. In declaring pointers, the * is a declarator > and binds to the variable, not the type. That's why coding styles such Yes, it's a programmer error (as are the other programmer errors I was exemplifying here), aided and abetted by crazy language syntax. Why aren't you claiming that any reasonable compiler should warn against the crazy practice of declaring, _in a single declaration_, some foo's, some pointers to foo's, some arrays of foo's, some functions returning foo's, ...? Just because your favourite C compilers happen to be unreasonable on this issue?-) > as writing `int* p' end up only causing problems, because they imply > that the * binds to the type when it does not. Ah, shouldn't any reasonable compiler warn against them, then?-) > > struct foo { > > int bar; > > } /* forgot a semicolon... */ > > So what? So the compiler will take this as the returntype for the following function. > > /* int can be omitted and is implied -- how CRAZY! */ > > Not in C99. So you admit that the C syntax that has been defined in de-facto and de-jure standards for almost 30 years _IS_ crazy, and only claim "pretty good" status for the syntax of a newer language version -- a version that, AFAIK, is not the one currently implemented by widespread C compilers such as gcc, Microsoft Visual C++, Borland C++, ...? I'm glad that C99 has finally adopted C++'s innovation of forbidding implicit-int. This does reduce the horror of C's syntax (maybe in 10 years, C99 will be widespread enough that this will actually make a difference:-). Depending on what good and bad syntax ideas C99 has chosen to take from other C-derived syntaxes (Java's prohibition against inner-blocks declaring names that hide those defined in outer-blocks, C++'s ability to mix declarations and statements, C++'s oldish alternate typename(expression) syntax for casts [that counts as a _bad_ syntax idea:-)]...), the cosmetic surgery can be minor or major. I'm sure it will never be as major as to raise the syntax of C and its derivatives to the exhalted status of "pretty good", though... that would take _too_ much changing. Alex From scarblac at pino.selwerd.nl Mon Oct 9 09:35:34 2000 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 9 Oct 2000 13:35:34 GMT Subject: doubling slashes in a string References: <39de8a48_3@corp.newsfeeds.com> <39df8b97_1@corp.newsfeeds.com> Message-ID: Joshua Muskovitz wrote in comp.lang.python: > Bzzt. Thanks, but the point was to *double* the backslash. The intended > result is not a legal pathname. In fact, it is intended to go into yet > another interpreted language, and thus the backslashes needed to be escaped > (by doubling them). The original string was a valid path. Interestingly, > this is meant to work on a cross platform basis, and yet, only backslashes > need to be doubled, since they are the only special character needing to be > escaped. On a *nix box, the doubling is not necessary. Thus, the > split/join or replace is what is needed. I don't know if you can use it here, but slashes work just as well as backslashes under Windows. Remco Gerlich From stephen at cerebralmaelstrom.com Sat Oct 7 03:28:56 2000 From: stephen at cerebralmaelstrom.com (Stephen Hansen) Date: Sat, 07 Oct 2000 07:28:56 GMT Subject: Stupid Q: asyncore and disconnecting? References: <20001004.192340.98221@Jeremy.cerebralmaelstrom.com> Message-ID: <20001007.003034.22909@Jeremy.cerebralmaelstrom.com> Hmm, I was using handle_read(), could that be the cause of my error? What is the difference between handle_read() and handle_read_event()? Thanks. In article , kragen at dnaco.net (Kragen Sitaker) wrote: > In article <20001004.192340.98221 at Jeremy.cerebralmaelstrom.com>, Stephen > Hansen wrote: >>Okay, I am using asyncore to make a little server, and am wondering how >>to go about detecting a client disconnected? When I 'telnet' into it, >>then close the connection, the server doesn't know its closed, each >>read/poll still receives just balnk data..... and, shouldn't it not try >>to read if there is nothing to be read? > > A closed socket selects as readable, so you get handle_read_event(); but > when you try to read it, the read returns 0. I believe that that is the > only time read on a socket will ever return 0. (When I tried it, > reading from a nonblocking socket that was open, but had no data coming > in, raised an exception.) From sragsdale at my-deja.com Thu Oct 5 17:38:49 2000 From: sragsdale at my-deja.com (sragsdale at my-deja.com) Date: Thu, 05 Oct 2000 21:38:49 GMT Subject: Bad IRIX Tkinter Install : Error Message-ID: <8risd9$rj2$1@nnrp1.deja.com> As per the "debugging bad Tkinter installs" part of the python.org website, I'm having problems: /usr/people/soren/ 60> python2 Python 2.0b2 (#4, Oct 5 2000, 12:39:44) [GCC 2.95.2 19991024 (release)] on irix646 Type "copyright", "credits" or "license" for more information. >>> import _tkinter >>> import Tkinter >>> Tkinter._test() Traceback (most recent call last): File "", line 1, in ? File "/tip/td/python2/lib/python2.0/lib-tk/Tkinter.py", line 3063, in _test root = Tk() File "/tip/td/python2/lib/python2.0/lib-tk/Tkinter.py", line 1482, in __init__ self.tk = _tkinter.create(screenName, baseName, className) TclError: invalid command name "tcl_findLibrary" >>> _tkinter.TCL_VERSION '8.0' >>> _tkinter.TK_VERSION '8.0' Sent via Deja.com http://www.deja.com/ Before you buy. From qtmstr at optonline.net Sat Oct 28 09:10:43 2000 From: qtmstr at optonline.net (QuoteMstr) Date: Sat, 28 Oct 2000 13:10:43 GMT Subject: PythonLabs Team Moves to Digital Creations References: Message-ID: On Fri, 27 Oct 2000 22:45:02 -0400, Jim Fulton wrote: >These are indeed exciting times! More like interesting times. -- "Do not meddle in the affairs of wizards, for they are subtle and quick to anger." -- J.R.R. Tolkien From dberlin at redhat.com Tue Oct 3 00:52:54 2000 From: dberlin at redhat.com (Daniel Berlin) Date: 03 Oct 2000 00:52:54 -0400 Subject: example sources in both Python and C++ In-Reply-To: wmcclain@salamander.com's message of "Tue, 03 Oct 2000 02:43:54 GMT" References: Message-ID: wmcclain at salamander.com (Bill McClain) writes: > > > * Template arguments cannot be local types. That means STL > > > containers must use types declared at the outer scope, which > > > is ugly. > > Wait, what? > > Explain what you mean, this is confusing. > > If you mean you can only use types in the outermost, or global scope, > > as template arguments, your compiler is severely broken. > > Try this on your compiler and tell me what happens: > > *********** > #include > > class Legal { > int a; > }; > > int main() { > class Illegal { > int a; > }; > > list ok; // compiles > list nogood; // does not compile > return 0; > } > > // g++ > // temp.cpp:13: type `main()::Illegal' composed from a local type is not a valid template-argument > > // VMS > // %CXX-E-LOCALTYPTMPLARG, a template argument may not reference a local type > // at line number 13 in file CTS_DEVELOPER:[WMCCLAIN]TEMP.CPP;1 > *********** > > I'm too tired to turn on NT to try VC++. > > -Bill Correct, this is indeed illegal. You cannot use function local types as template arguments, because it would make instantiation very evil. 14.3.1 Template type arguments [temp.arg.type] 1 A template-argument for a template-parameter which is a type shall be a type-id. 2 A local type, a type with no linkage, an unnamed type or a type compounded from any of these types shall not be used as a template-argument for a template type-parameter. Why would you ever want to use a local type as a template argument? However, when you say outer scope, you are wrong. You can use a type declared in any scope, except the local one, as a template argument. IE nested classes, nested classes in a different namespace, whatever. --Dan From bruce_dodson.nospam at bigfoot.com Wed Oct 25 20:00:20 2000 From: bruce_dodson.nospam at bigfoot.com (Bruce Dodson) Date: Wed, 25 Oct 2000 21:00:20 -0300 Subject: XML DOM to JavaScript References: <39F70001.C4B173A9@yahoo.com> Message-ID: This should not be too difficult, especially if you can constrain yourself to JavaScript versions that can understand [] and {} literals, or if you don't mind if the client side executes a few extra lines to make it easier for the server. It would not be any harder, and might be less memory-intensive, to stream from XML to JS using SAX-style events. As an alternative to your alternative, if you find it too error-prone to generate JavaScript code on the fly, and you want to keep your client side lightweight, it might be worthwhile to send the tree in a line-oriented format like Pyxie uses, rather than "free-form" XML. A PYX data-island could be parsed very easily by JavaScript. (www.pyxie.org) Bruce wrote in message news:39F70001.C4B173A9 at yahoo.com... Greetings! My basic question is: How can I convert XML DOM to JavaScript data-structures? I have some XML-files that represents a data-structure, I would like to generate HTML in the browser from the same structure with JavaScript, I am already converting the DOM to CFML (ColdFusion) code. In ColdFusion there is this WDDX framework which converts the CFML DOM to Javacript statements which generates a similar structure in JavaScript. (WDDX seems to be intended as a standard for this kind of things, but I haven't found any references to WDDX and Python) Is there some way I can do this directly from Python. Essentially I would like to generate a .js file from the corresponding .xml file One alternative could be if I could somehow process the XML directly with JavaScript) Thanks! Olav From claird at starbase.neosoft.com Mon Oct 30 10:24:28 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 30 Oct 2000 09:24:28 -0600 Subject: Shall we declare Tkinter dead? No-one seems interested in it ;o) References: Message-ID: <720A6048D16EDEC7.B65F8091DC9DA03A.CA7514E132466A7B@lp.airnews.net> In article , Mike Fletcher wrote: . . . >version for the curious. It doesn't provide for nested mainloops, and it >may be a little too aggressive during shutdown (I was getting memory access >errors if I didn't call destroy on the widget when another micro-thread >called exit (instead of it being called as a callback)), but it does seem to >work (at least, with this trivial example). I did both the event "... nested mainloops ..."?!!? Mike, WHAT are you doing? I have a strong instinct that nested mainloops are a hint that there's pervesity afoot, and that I'd look for a different architecture. I know, though, that you're successful at what you do, so maybe it'll work for you. >and the WM_DELETE_WINDOW, if I understand correctly, either would indicate >that the root window is being destroyed. Sort of. Readers with further interest in this topic might want to notice, for example, . . . -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From flagg at moo.cus.org.uk Tue Oct 24 10:52:11 2000 From: flagg at moo.cus.org.uk (Dave Beynon) Date: 24 Oct 2000 15:52:11 +0100 Subject: A dll question Message-ID: <39f5a21b@news.telinco.net> Hi. Apologies if this question seems a bit dim, but I am having some trouble embedding some C++ code into a python program under windows NT. Currently I am using swig to generate a framework for my code and compiling under MS visual C++ 6.0. I get a dll generated, but python is refusing to pick up the dll. I am using python 1.5.2 btw. The interface definition is as follows: %module fact %{ #include %} class Fact { public: Fact(int n); int get_x(); } this is imported (or not) with the line import twinkle_lib the file is called twinkle_lib.dll Is there anything obvious that I am doing wrong? thanks David Beynon From jeremy at beopen.com Mon Oct 16 13:58:09 2000 From: jeremy at beopen.com (Jeremy Hylton) Date: Mon, 16 Oct 2000 13:58:09 -0400 (EDT) Subject: LONG_BIT == 64, can't compile Message-ID: <14827.16817.134891.712251@bitdiddle.concentric.net> > I just deleted the section in pyport.h generating the error, and > everything compiled just fine. Since I don't use large integers in > my programs I guess all will be fine until a solution to the problem > has appeared. So if your programs don't depend on the definition of > LONG_BIT you can try to hack your way around the problem. Hehe - I > know this isn't an optimal solution, but it's a fast hack to get > back in business !!! This is a pretty bizarre hack, since you can't do integer multiplication with the version of the interpreter you built. There is no way that, as you say, "everything compiled just fine." I am certain there were a bunch of compiler warnings in Object/intobject.c. If you want everything to actually compile correctly and the regression test to work (make test), you should explicitly set #define LONG_BIT to be 32 before the test in pyport.h. Jeremy From tgagne at ix.netcom.com Sun Oct 1 22:33:02 2000 From: tgagne at ix.netcom.com (Thomas Gagne) Date: Sun, 01 Oct 2000 22:33:02 -0400 Subject: Organizing Python Code Message-ID: <39D7F3DE.D4104FE7@ix.netcom.com> I'm trying to do a project with Python and I'm not convinced I've set things up properly. In writing C code I've grown accustomed to creating separate files for each function. This doesn't seem to really be the right thing to do in Python since the top of each would include a bunch of "import" or "from" statements. On the other extreme, I don't like having really big files either. What's everyone else doing? What's idiomatic? -- .tom From darrell at dorb.com Sun Oct 8 01:50:21 2000 From: darrell at dorb.com (Darrell Gallion) Date: Sun, 8 Oct 2000 01:50:21 -0400 Subject: Data distribution by frequency References: Message-ID: <014501c030eb$a62dc880$6401a8c0@home> The idea of measuring the network sounded like fun. So here's some quickie code to do some mapping. --Darrell import re, string, os, cPickle, time import threading, Queue exitAllThreads=0 class TraceThread(threading.Thread): def __init__(self, args): threading.Thread.__init__(self) self._outQueue=Queue.Queue(100) self._args=args def run(self): dest, sleepTime = self._args self._name=dest while exitAllThreads==0: buf=os.popen("tracert -d %s"%dest).read() if not self._outQueue.full(): self._outQueue.put(buf) time.sleep(sleepTime) class TraceRt: def __init__(self, destList, sleepTime): self._destThreads=[] for d in destList: th=TraceThread((d, sleepTime)) th.start() self._destThreads.append(th) self._stats={} def procStats(self, buf): res=re.findall("((?:\s+>> from cPickle import * >>> p=load(open("stats.dat")) >>> for k, v in p.items(): ... print k, v ... ... ('206.41.19.77', '208.50.169.86') [(970983801.78100002, 93)] ('157.130.219.121', '152.63.22.74') [(970983801.78100002, 10)] ('12.126.119.10', '206.41.19.77') [(970983801.78100002, 31)] ('206.204.250.130', '206.204.200.2') [(970983801.78100002, 15)] # (source, dest)[(current time, time between nodes)] From gavrilov at iname.com Tue Oct 24 17:31:28 2000 From: gavrilov at iname.com (Alexander Gavrilov) Date: Tue, 24 Oct 2000 21:31:28 GMT Subject: python snippet request: calculate MD5 checksum on 650 MB ISO cdrom image quickly References: Message-ID: I run test script Tim posted and got the following results on my system: Timing C:\Program Files\Microsoft Visual Studio\MSDN98\98VS\1033\MSDNVS98.CHQ w/ size 95823736 Time for getcrc32 is 29.852 Time for getmd5 is 29.444 Time for getsha is 31.513 The system is Windows NT4 SP6, Dual Pentium II 300 Mhz "Tim Peters" wrote in message news:mailman.972409263.1128.python-list at python.org... > [Warren Postma] > > I am writing some python scripts to manage downloading (and > > re-downloading) ISO images from FTP mirrors, and doing MD5 checksums > > on the received files to make sure they are intact. > > > > I noticed that there is an MD5 message digest module in Python. > > But it only accepts STRINGS. Is there some way to pass a WHOLE FILE to > > it, less awkwardly than having a WHILE loop that reads 1k chunks and > > passes it along to the MD5 module. > > You can read the entire file into a string at one gulp, via e.g. f.read(). > One-liner. > > > A new function in the md5 module, md5.md5file(filename) would be nice, > > if anyone is listening, for a future python 2.x release. > > > > I'll contribute a patch if anyone thinks it's a good idea. > > Alas, I don't: there's no magic to be had here. Such a function will have > to make up its own policy for chunking the file input, and one size doesn't > fit all. The "while" loop is trivial to write, and really has no bad effect > on speed even if written in Python (1Kb chunks are very small, btw -- why > not use 64Kb, or 1Mb, chunks? the "sweet spot" on your system is something > you can determine (see below), but a builtin md5file method can't guess for > you). > > > If there's already a one-to-ten line method that doesn't involve > > iterating (SLOWLY) over chunks of the file that got loaded into Strings > > that would be great. > > > > My current method is to use os.popen("md5 "+filename"), which > > then spawns a command line md5 utility, which seems to me to be kind > > of wasteful and slow. > > Why the emphasis on "SLOWLY" and "slow"? You may be missing that md5 is > *designed* to be slow <0.9 wink>! It's supposed to give *such* a good hash > that it's computationally intractable to fool it on purpose, and it does a > lot of work to achieve that. If you want a *faster* checksum, then e.g. use > crc32 instead. CRCs are easy to fool on purpose, but cheaper to compute. > I'll attach a little timing harness to compare crc32, md5 and sha speed; > plug in the name of a large file (TEST) and play w/ different chunking > factors to see what happens; you'll usually find that crc32 is faster than > md5 is faster than sha. > > import md5, binascii, sha, time, os > > def getcrc32(f, CHUNK=2**16): > result = 0 > while 1: > chunk = f.read(CHUNK) > if not chunk: > break > result = binascii.crc32(chunk, result) > return result > > def getmd5(f, CHUNK=2**16): > m = md5.new() > while 1: > chunk = f.read(CHUNK) > if not chunk: > break > m.update(chunk) > return m.digest() > > def getsha(f, CHUNK=2**16): > m = sha.new() > while 1: > chunk = f.read(CHUNK) > if not chunk: > break > m.update(chunk) > return m.digest() > > TEST = "/Python20/huge.html" > > print "Timing", TEST, "w/ size", os.path.getsize(TEST) > > # Warm up the system file cache, to avoid penalizing the first func. > f = open(TEST, "rb") > f.read() > f.close() > > for func in getcrc32, getmd5, getsha: > f = open(TEST, "rb") > start = time.clock() > func(f, 2**25) > finish = time.clock() > f.close() > print "Time for", func.__name__, "is", round(finish - start, 3) > > > From olivierS.dagenaisP at canadaA.comM Tue Oct 24 10:40:47 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Tue, 24 Oct 2000 14:40:47 GMT Subject: event loop problem References: <8t21ei$e5a$1@nnrp1.deja.com> <361J5.369195$Gh.11216252@news20.bellglobal.com> <8t3q6u02a6q@news2.newsguy.com> Message-ID: Ah, sorry, I didn't see any events hooks in the original post, so I assumed it was just a program that was gonna wait for nothing. -- ---------------------------------------------------------------------- Olivier A. Dagenais - Software Architect and Developer "Someone called 'Type your name here' is impersonating me on the internet and is posting exactly the same things I am posting!" > The use is "being in the background" and serving messages/requests/ > events that may happen throughout the session. Of course, this does > require the event-loop to be served (see rest of the thread). From aleaxit at yahoo.com Fri Oct 20 04:11:54 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 20 Oct 2000 10:11:54 +0200 Subject: newbie References: <8soeic$57gs$2@newssvr05-en0.news.prodigy.com> <9_PH5.99786$g6.44454168@news2.rdc2.tx.home.com> Message-ID: <8sov2g0142d@news1.newsguy.com> "Rainer Deyke" wrote in message news:9_PH5.99786$g6.44454168 at news2.rdc2.tx.home.com... > "LONNIE" wrote in message > news:8soeic$57gs$2 at newssvr05-en0.news.prodigy.com... > > > > I have been teaching myself python for about a month now for the simple > > reason that I have read alot of literature that says that its easy to jump > > from python to c++. I was just wondering if this was true also I have been > > teaching myself from online tutorials but I have been looking for a good > > book to go along with the literature that I have downloaded so far any > > suggestions would be nice. > > C++ is just plain difficult. If C++ is your goal, either C or Java might be > a good intermediate language. Both are both simple enough for beginners to > learn (although not as simple as Python). If C++ is your goal, then, after you've used Python to learn programming reasonably well, you may as well jump right into C++ with the aid of a good tutorial (I suggest Lippman and Lajoie's -- by far the best IMHO; it's published by Addison-Wesley). C++ is *horrendously* difficult (its main defect, again IMHO), but it ain't going to get any easier by spending lots of time and energy on typical C issues ("how do I get around the lack of automatic this and that and the other" when C++ does have such automatisms) and/or Java issues ("how do I get around the lack of multiple inheritance, templates, ..." when C++ does have such features) is not going to make C++ any easier. There's a widespread opinion that C is best learned before C++ since the latter is 'descended' from the former. I equate that to saying that Saxon should be learned before English... Alex From aahz at panix.com Thu Oct 19 01:17:13 2000 From: aahz at panix.com (Aahz Maruch) Date: 18 Oct 2000 22:17:13 -0700 Subject: Threads, again References: Message-ID: <8sm04p$j14$1@panix6.panix.com> In article , Alex McHale wrote: > >This may be a bit of a dumb question - but I, for the life of me, can't >understand why, when using the thread module, start_new_thread will only >pass a tuple of arguments to the function. Can anyone explain this to me? >Does this mean any function I want to thread, has to take 3 arguments? I'll answer that question if you want, but I strongly suggest that you use the threading module instead -- it'll make your life easier. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "real love can't be explained by simplistic platitudes." --piranha From keisari_ at hotmail.com Tue Oct 17 09:09:04 2000 From: keisari_ at hotmail.com (joonas) Date: Tue, 17 Oct 2000 16:09:04 +0300 Subject: Special printing Message-ID: <39EC4F70.5AA50246@hotmail.com> How can i print special characters like ``!"#??%%%/&(%()==?? i think that print "``!"#??/\%%%/&(%()==??" wont work. Joonas. From sdm7g at virginia.edu Thu Oct 26 15:06:57 2000 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Thu, 26 Oct 2000 15:06:57 -0400 (EDT) Subject: Python scoping In-Reply-To: <39f5e57b_1@corp.newsfeeds.com> Message-ID: On Tue, 24 Oct 2000, Joshua Muskovitz wrote: > > this tends to diminish the number of lines in a "scope", and thus > > optimizes for the chance that both ends are simultaneously visible > > on a single page, does it not ? > > Driving without my headlights at night tends to diminish my overall speed > and distance I prefer to travel, but it doesn't make my life easier or > safer, does it? If programming languages used enforced redundancy so that brace-block structure and indentation block structure must agree, then programming would be safer. A situation where the human eye uses indentation and the compiler uses braces is unsafe. If you aren't going to enforce redundancy, then you have a choice: make humans adapt to the compiler, or make the compilers adapt to human perception. I think python made the better & safer choice. ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- "All operating systems want to be unix, All programming languages want to be lisp." From tismer at appliedbiometrics.com Fri Oct 6 03:44:33 2000 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Fri, 06 Oct 2000 10:44:33 +0300 Subject: Are there Python code for a FIFO-like structure? References: Message-ID: <39DD82E1.8DC66A4B@appliedbiometrics.com> Will Ware wrote: > > Huaiyu Zhu (hzhu at users.sourceforge.net) wrote: > > I need something like a fifo, inplemented in a fixed length list... > > an IndexError is raised if the tail gets > > too close to the head. > > I'm not aware of any standard thing like that. Generally one would > implement a stack using list.append() and list.pop(), and I have > implemented FIFOs using list.append() and list.pop(0), but I hadn't > faced the constraint of keeping the list length constant. > > Since you can't do a put and a get literally simultaneously, you'll > have to tolerate a list length that oscillates between two adjacent > values. It might be useful to whip up a state diagram telling when > it's OK to do a put or a get based on the current list length. You'll > need to alternate puts and gets to prevent greater length variations. > See if this does what you want: > > class FixedLengthFifo: > def __init__(self, length): > self.length = length > self.lst = length * [None] > def put(self, x): > if len(self.lst) != self.length: > raise IndexError > self.lst.append(x) > def get(self): > if len(self.lst) != self.length + 1: > raise IndexError > return self.lst.pop(0) Hmm, why don't you really use a fixed length list, maintain two rotating pointers, and check that they behave well? I didn't implement it, but it is obvious (left as an exercise for the reader :-) But if the fixed length implementation is not the main goal, but to achieve O(1) behavior, then the attached linked list implementation might be helpful. It also allows for rotations (only efficient for smal deviations). ciao - chris -------- linkedlist.py --------- class LinkedList: def __init__(self, items=[]): self.data = None self.size = 0 for item in items: self.append(item) def __del__(self): self.data[:] = [] def append(self, item): if not self.data: thing = self.data = [] thing[:] = [item, thing, thing] else: a = self.data z = self.data[-1] new = [item, a, z] a[-1] = new z[1] = new self.size = self.size+1 def __len__(self): return self.size def _spot(self, key): if key < 0: if self.size + key < 0: [][key] # error if 2*abs(key) > self.size: key = self.size + key dir = 1 else: key = abs(key) dir = -1 else: if key >= self.size: [][key] # error if 2*key > self.size: key = self.size - key dir = -1 else: dir = 1 this = self.data while key: this = this[dir] key = key-1 return this def __getitem__(self, key): return self._spot(key)[0] def __repr__(self): lis = [] for i in range(self.size): lis.append(self[i]) return "LinkedList(%s)" % repr(lis) def insert(self, pos, item): if not self.size: if pos: [][pos] # error self.append(item) else: a = self._spot(pos) z = a[-1] new = [item, a, z] a[-1] = new z[1] = new self.size = self.size+1 def __delitem__(self, key): this = self._spot(key) nil, a, z = this a[-1] = z z[1] = a self.size = self.size-1 if key == 0: self.data = a def rotate(self, pos=1): """return the current value and rotate into new location""" ret = self.data[0] self.data = self._spot(pos) return ret def move(self, pos=0): """return the current value and move current into new location. With pos==0, the behavior is identical to rotate(1) """ if not pos or pos==self.size-1: return self.rotate() q = self._spot(pos+1) p = q[-1] this = self.data self.data = self.data[1] a = this[1] z = this[-1] a[-1] = z z[1] = a p[1] = this this[-1] = p this[1] = q q[-1] = this return this[0] -------- yp.tsildeknil --------- -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com From paul.moore at uk.origin-it.com Tue Oct 24 05:34:40 2000 From: paul.moore at uk.origin-it.com (Paul Moore) Date: Tue, 24 Oct 2000 11:34:40 +0200 Subject: Python equivalent of CPAN (Was: ANY NEWS ON THE STARSHIP?) References: <8su1su$euq$1@nnrp1.deja.com> <39F47496.22449099@holdenweb.com> <8t1ur1$8jt$1@panix3.panix.com> <39F481E4.989093B6@holdenweb.com> Message-ID: On Tue, 24 Oct 2000 11:11:10 +0200, Paul Moore wrote: >The same needs to be true of Python modules. I have an intense dislike >of packages which are a pain to build from sources, and which come >with mysterious binary installers which could, and often do, scatter >things everywhere. Keep out of my registry, and don't put things in my >SYSTEM(32) directory! Even if you uninstall cleanly, that's not >enough... > >This is close to being the killer distinction between Python and Perl >for me... Ack! I've just found the distutils stuff. Looks like someone's already solved this one. OK, so the issue now becomes why doesn't everyone use distutils for everything? If there are modules which are too complex for distutils to handle, then distutils should be improved. If it's lack of knowledge about distutils, let's publicise it. If it's just that distutils is very new, then let's encourage people to change as part of the work to support Python 2.0. BTW, just because a module is only a single .py file isn't a good reason for not using distutils (or if it is, then distutils needs to be better at handling trivial modules). Many, many modules on CPAN are one .pm file (plus documentation, and tests - that's one thing Perl's standard distribution modules encourage, is including tests and documentation in the package). OK, looks like I'm off to join the distutils sig. Paul. From rhicks at nospam.rma.edu Thu Oct 19 13:14:01 2000 From: rhicks at nospam.rma.edu (Robert) Date: Thu, 19 Oct 2000 17:14:01 GMT Subject: Python2.0 for Mac... but where is it? References: Message-ID: If it is anywhere it is here: http://www.cwi.nl/~jack/macpython.html Bob "jason keith" wrote in message news:B6156787.1555%jasonkeith at ozemail.com.au... > Apologies if this is staring me in the face but I've checked the web site > and ftp sites and the only Python for mac I can find is the 1.5.2. IS there > a final release Python2.0 for mac yet? > Thanks in advance. > Jason > From jbedal at hotmail.com Thu Oct 26 08:53:44 2000 From: jbedal at hotmail.com (John Bedal) Date: Thu, 26 Oct 2000 12:53:44 GMT Subject: msvcrt.getch() not working within IDLE References: <39F7CA9A.27C96C8A@bogusaddress.com> Message-ID: Thanks, Is there a popular alturnative method to capturing keyboard input character by character, I think th e input method is just a little to basic :-) -john "Joe Smith" wrote in message news:39F7CA9A.27C96C8A at bogusaddress.com... > > I would expect these calls to fail in a GUI program because I suspect (don't > feel like researching it) that they get input from a console window only not > from a GUI program. These calls are also windows specific, you might want to > look at other calls that are platform independent. > > John Bedal wrote: > > > Does msvcrt.getch() not work within the IDLE/Win98? it continuosly returns > > chr(255) > > > > Even msvcrt.kbhit() always returns false. Is there something I am doing > > wrong? > > > > -John > From root at rainerdeyke.com Mon Oct 30 16:46:52 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 30 Oct 2000 21:46:52 GMT Subject: How do you create constants? References: <39FAE133.9070001@yieldworks.com> <2nDK5.2916$QH2.270412@newsb.telia.net> <39FB0B4A.1238E8BC@yieldworks.com> Message-ID: "Huaiyu Zhu" wrote in message news:slrn8vroiv.2sc.hzhu at rocket.knowledgetrack.com... > So a hyperthetical Python with the const keyword might look like this: > > x = const "a string" # as current string > x = "a string" # a true class object that's mutable > x = [1, 2, 3] # as current list > x = const [1, 2, 3] # as current tuple > const x = [1, 2, 3] # x is fixed to a list whose contents can change > const x = const [1, 2, 3] # x is fixed to a const list (tuple) > x = const {1:2, 3:4} # a dict whose contents cannot change Two thoughts: 1. The usage "const x = ..." means that the __dict__ is made partially immutable. This is possible, but probably more trouble than it's worth. 2. It is not obvious wether const-ness applies to objects or references. I vote for the latter. a = [1, 2, 3] b = const a a[0] = 5 print b # --> '[5, 2, 3]' b[0] = 1 # Raises ConstError > Is this a good thing? > - It gives programmers more expresiveness when needed. > - It does not force a change in programming style if not wanted. > - It may allow substantial efficiency gains. Actually it would probably hurt performance, because there is more information to keep track of. > - It allows more consistency for things like augmented assignment. No. > - It may be combined with safe exec module to build other security modules. > > Any potential problems? > What's the implementational cost? Depends on the implementation. One bit/byte per object or per reference, which really makes four bytes because of alignment issues. Alternately, each type could have a const version, which means each object needs to be converted to the const type. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From Kimmo.Paakkonen at helsinki.fi Tue Oct 31 08:56:32 2000 From: Kimmo.Paakkonen at helsinki.fi (Kimmo =?iso-8859-1?Q?P=E4=E4kk=F6nen?=) Date: Tue, 31 Oct 2000 15:56:32 +0200 Subject: Extensions with LCC References: <39FD7EDC.EF818DA2@helsinki.fi> <8tmhal$2n0i$1@news2.ottawa.cyberus.ca> Message-ID: <39FECF90.F00A8D7F@helsinki.fi> Hi, Woohoo, I finally did it!!! I tried out the Borland compiler (and VIDE) as Alex and Gordon suggested, and after some debugging on my C file, I got it compiled and working!!! Many thanks for your quick help, and Gordon's help files really made it painless. One small suggestion though, on the official VIDE help pages there was some advice of setting the compiler settings so that it would not compile to Win2000, as it by default does. While I made those changes to .cfg files, I did not see them mentioned in Gordon's help text (well the switches were at their places in the VIDE part of the help file). But great many thanks for fast help!! Regards, Kimmo P??kk?nen Kimmo.Paakkonen at helsinki.fi From fredrik at effbot.org Tue Oct 31 18:13:30 2000 From: fredrik at effbot.org (Fredrik Lundh) Date: Tue, 31 Oct 2000 23:13:30 GMT Subject: Making the substitution string raw in re.sub() References: Message-ID: Joakim Hove wrote: > I'm using the re module to perform some substitutions on a string: > > OldString = "See for instance EXPAND(key1)" > newString = r"Volume {\bf 45}" > print re.sub(r"EXPAND\(\s*(\w+?)\s*\)" , newString , OldString , 1) > > But, when I run this the newString is not properly escaped, and > what I get is: > >>> See for instance Volume f 45} > > instead of: > > >>> See for instance Volume {\bf 45} > > Which is what I wanted. ANy tips to how I Could solve this?? re.escape is your friend: newString = re.escape(r"Volume {\bf 45}") From papadopo at my-deja.com Mon Oct 30 06:14:54 2000 From: papadopo at my-deja.com (papadopo at my-deja.com) Date: Mon, 30 Oct 2000 11:14:54 GMT Subject: config.h and C++ Message-ID: <8tjl7b$8cg$1@nnrp1.deja.com> Hi, I have configured and built Python 1.6 and 2.0 on Solaris 7 with the Sun C compiler. Now I see the following piece of code in config.h: /* Define as __inline if that's what the C compiler calls it. */ #define inline Why is this defined? It breaks havoc when writing C++ programs. Thanks, Dimitri Sent via Deja.com http://www.deja.com/ Before you buy. From aleaxit at yahoo.com Sat Oct 7 12:06:19 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 7 Oct 2000 18:06:19 +0200 Subject: future of Python: Stackless, Standard -> fragmentation ? References: <8rk7e5$47u$1@oslo-nntp.eunet.no> <8rkm43$kre$1@desig-bs01-s04.adtranzsig.de> Message-ID: <8rnhs0030ul@news1.newsguy.com> "Suchandra Thapa" wrote in message news:slrn8tt0f4.18d.ssthapa at localhost.localdomain... > Neil Schemenauer wrote: > > > >I understand it the .NET VM is more general and powerful then the > >Java VM. It was designed as a platform for multiple languages > >while the Java VM was not. Also, the .NET VM does not make the > >security guarantees that the Java VM does. > > But the .NET also has some of the limitations of JVMs. The biggest > one is that .NET doesn't have support for multiple inheritance. I think That's not really a problem in the 'virtual machine' level (after all, Intel machinecode has no such support either, yet we compile multiple inheritance of implementation for it...:-) -- rather, it's at the level of cross language interoperability conventions. Your components can inherit from components written in other languages (and be inherited by them) only at a single-implementation-inheritance level (no problem on multiple 'inheritance' of pure interfaces, of course). > the Eiffel implementation on .NET has to go through some contortions in > order to get Eiffel's use of MI to work properly. I don't think there's any issue with inheriting implementation between Eiffel classes (or, say, Python classes), but, when multiple languages are in play at the same time, then, only one cross-language implementation inheritance (probably even between languages capable of multiple implementation inheritance, say Python inheriting from Eiffel or vice versa, since there is no rigidly platform-level-specified way they should implement this, as there is for all other aspects of language interoperability). Alex From kogorman at pacbell.net Fri Oct 6 17:39:17 2000 From: kogorman at pacbell.net (Kevin O'Gorman) Date: Fri, 06 Oct 2000 14:39:17 -0700 Subject: Help a newbie use Python's OS module: Message-ID: <39DE4685.4C3EB1E9@pacbell.net> I've got a pretty basic book, and online docs, and I've done my best to RTFM, but I'm now at my frustration point. I can use os.fork() to create a child process, but I cannot get messages from the child to the parent through the pipe I've created. If anyone's got a little sample program that shows how this is done, I'd sure appreciate it. At the moment, my (non-working) version complains that the parent's attemts to read the pipe are failing. It looks like this: #! /usr/bin/python # $Id: fork.py,v 1.2 2000/10/06 04:17:32 kevin Exp kevin $ import string import sys import re import os print "Running $Id: fork.py,v 1.2 2000/10/06 04:17:32 kevin Exp kevin $" osi=sys.stdin oso=sys.stdout ose=sys.stderr rw=os.pipe() r=rw[0] w=rw[1] print "Reading on",r,", and writing on",w child=os.fork() if child==0: sys.stderr.write("In child\n") os.close(1) os.dup(w) sys.stdout=os.fdopen(1,"w") os.close(r) os.close(w) sys.stderr.write("Writing\n") print "foo" print "bar" print "foobuar" sys.stdout.close() sys.exit(0) os.close(0) os.dup(r) sys.stdin=os.fdopen(r) os.close(r) os.close(w) print "Stdin is ",sys.stdin print "about to read" lin=sys.stdin.readline() if not lin: print "Read failed",lin sys.exit(1) while lin: print lin lin=sys.stdin.readline() -- Kevin O'Gorman (805) 650-6274 mailto:kogorman at pacbell.net Permanent e-mail forwarder: mailto:Kevin.O'Gorman.64 at Alum.Dartmouth.org At school: mailto:kogorman at cs.ucsb.edu Web: http://www.cs.ucsb.edu/~kogorman/index.html Web: http://trixie.kosman.via.ayuda.com/~kevin/index.html From g2 at seebelow.org Sat Oct 7 16:34:41 2000 From: g2 at seebelow.org (Grant Griffin) Date: Sat, 07 Oct 2000 21:34:41 +0100 Subject: Is this a dream or a nightmare? (Was Re: XML) References: <39d1d3b2.43465571@news.telus.net> <39D19EBB.ABF18F23@engcorp.com> <39def2ae.8929692@news.davesworld.net> <8ro52a0q1o@news1.newsguy.com> <39dfa617.25953118@news.davesworld.net> Message-ID: <39DF88E1.A4181BC5@seebelow.org> David T. Grove wrote: > ... > Granted, python is very close to Perl in these respects, but it's > still more verbose. That seems to be the popular mythology, but when I've rewritten some of my old Perl scripts as Python, my experience has been exactly the opposite: the Python versions invariably are smaller files which have fewer lines. In fact, translation of Perl to Python mostly seems to be a "deletion" process: eliminating braces, $, @, %, and my--as well as manual function parameter list parsing (which--let's face it--is nothing short of dopey by 21st-century programming-language standards ;-), etc. Then again, maybe extensive use of one-liners in Perl could overpower those other factors. (In my own case, I'm not big on Perl's one-liners: even if I ever got really good at writing them, I'm pretty sure I couldn't read them 10 minutes later.) > Also, I must admit that "good programming practices" have hit me > pretty hard recently, when I've had to babysit some newbies from > another planet... er... country. My elses got unsnuggled and > > die unless @d = map {"$basedir/$_"} grep {!-d && -w} readdir(dir); > What in the heck does all _that_ mean? > ...which is perfectly logical and readable to me as a single > "thought"... "get me all the filenames in that directory or halt > immediately because you'll screw something up". OK, _now_ I see! 9If only Perl were as readable as a natural language. ) if-i-were-designing-a-programming-language-with-the-express-purpose -of-eliminating-lines,-i'd-pick-on-the-braces-before-the -semicolons-(or-maybe-just-eliminate-both-)-ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From graham73 at telocity.com Wed Oct 4 14:20:51 2000 From: graham73 at telocity.com (graham) Date: Wed, 04 Oct 2000 14:20:51 -0400 Subject: Class Browsers vs Static Types (Re: Inefficiency of __getattr__) References: <39DB62F6.EF943473@geneva-link.ch> Message-ID: Boris * (1+(is->cic)) > Marcin 'Qrczak' Kowalczyk wrote: >> It clearly indicates that if the program was written in a language >> without static typing *in the OCaml's style*, it would be hard to find >> that bugs basing only on runtime behavior, even if tests covered the >> whole code. > > This looks as if it could be universally assumed that typing bugs > would translate to bugs during program execution if they weren't > caught during compilation... Err, that's the point of a type system. If you have a piece of code that does true + 1 it will cause a run-time problem of some sort, unless the code isn't run. But the latter case is not very common, since no-one writes code that they don't intend to run. So I am not sure I understand your question ... graham Boris * (1+(is->cic)) > Marcin 'Qrczak' Kowalczyk wrote: >> One thing applying especially to Haskell: > > Why Haskell and not OCaml ? Haskell is pure, OCaml is not. graham From stephenk at cc.gatech.edu Tue Oct 24 14:53:30 2000 From: stephenk at cc.gatech.edu (Stephen Kloder) Date: Tue, 24 Oct 2000 14:53:30 -0400 Subject: Another re question References: <972336131.124972@fezzik.endicor.com> <39F4DB27.A8F09D53@cc.gatech.edu> <972411030.904033@fezzik.endicor.com> Message-ID: <39F5DAA9.F66CEC72@cc.gatech.edu> Kent Polk wrote: > On Mon, 23 Oct 2000 20:43:20 -0400, Stephen Kloder wrote: > > --------- > >>> findpid_pat = r'\012+0*\w.\w*[\t, ]+([\w_ ]+)' > >>> re.findall(findpid_pat,sid2pid) > ['1X4567', '1 4853', '1X0608'] > --------- > > Thanks. It works great in the cases I provided. Unfortunately, I > forgot about one case - where the first name can be blank (spaces). > > >>> sid2pid="\n1 1979 1X4567\n00031 1 4853\n1S0959 1X0608\n 3S4267\n" > >>> print sid2pid > > 1 1979 1X4567 > 00031 1 4853 > 1S0959 1X0608 > 3S4267 > > >>> findpid_pat = r'\012+0*\w.\w*[\t, ]+([\w_ ]+)' > >>> re.findall(findpid_pat,sid2pid) > ['1X4567', '1 4853', '1X0608'] > > which misses my (new) last case. > Assuming the first name cannot begin with a space and have nonspace characters: >>> sid2pid="\n1 1979 1X4567\n00031 1 4853\n1S0959 1X0608\n 3S4267\n" >>> findpid_pat = r'\012+0*..\w*[\t, ]+([\w_ ]+)' >>> re.findall(findpid_pat,sid2pid) ['1X4567', '1 4853', '1X0608', '3S4267'] Of course, if the names are always lined up, it may be better to use split() and string slices . . . -- Stephen Kloder | "I say what it occurs to me to say. stephenk at cc.gatech.edu | More I cannot say." Phone 404-874-6584 | -- The Man in the Shack ICQ #65153895 | be :- think. From parkw at better.net Thu Oct 5 22:13:19 2000 From: parkw at better.net (William Park) Date: Thu, 5 Oct 2000 22:13:19 -0400 Subject: Why is "while" ticking me off??? In-Reply-To: <39DD15A1.442E5A33@ix.netcom.com>; from tgagne@ix.netcom.com on Thu, Oct 05, 2000 at 07:58:25PM -0400 References: <39DD15A1.442E5A33@ix.netcom.com> Message-ID: <20001005221319.A12646@better.net> On Thu, Oct 05, 2000 at 07:58:25PM -0400, Thomas Gagne wrote: > I have a file that I want to read line-by-line, and stop reading when I run > out of lines. My first desire was to attempt: Try something like, for line in f.readlines(): ... Also, read online documentation on file objects and methods. ---William Park, Open Geometry Consulting From root at rainerdeyke.com Sun Oct 22 00:22:07 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Sun, 22 Oct 2000 04:22:07 GMT Subject: All permutations of a list References: <39F1FB22.6E9246E7@cs.utwente.nl> Message-ID: "Richard van de Stadt" wrote in message news:39F1FB22.6E9246E7 at cs.utwente.nl... > Then a collegue of mine impressed me with a recursive program > in the functional language Miranda/Amanda: > > ins a [] = [[a]] > ins a (x:xs) = (a:x:xs) : map (x:) (ins a xs) > > perms [] = [[]] > perms (x:xs) = concat (map (ins x) (perms xs)) > > 'ins a xs' returns a list of all possible extensions of > the list xs by inserting element a. > 'perms xs' returns the list of all possible permutations > of the list xs. > 'concat' joins lists. > > Is such an elegant recursive solution possible in Python? Here's a direct translation: def ins(a, list): if list == []: return [[a]] return [[a] + list] + map(lambda tail, head = list[0]:\ [head] + tail, ins(a, list[1:])) def perms(list): if list == []: return [[]] return concat(map(lambda tail, head = list[0]: ins(head, tail), perms(list[1:]))) def concat(list): return [o for l in list for o in l] This can be made more elegant by using Python idioms. For exampe, the function 'ins' could be rewritten like this: def ins(a, list): return [list[:i] + [a] + list[i:] for i in range(len(list) + 1)] -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From aleaxit at yahoo.com Sat Oct 7 07:06:08 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 7 Oct 2000 13:06:08 +0200 Subject: Fibonacci Sequence and Long numbers. References: <39DE3A2D.2E047F3D@seebelow.org> Message-ID: <8rn06v02eu0@news1.newsguy.com> "Grant Griffin" wrote in message news:39DE3A2D.2E047F3D at seebelow.org... [snip] > BTW, I was pondering the other day if there would be a way to do Fibo > using Python 2.0's new "list comprehension" feature. I still don't > comprehend those well enough to come up with the answer (in the whopping > 10 minutes I spent on it ;-), but maybe one of you folks can. I don't think so, because Python list comprehensions are not lazy. In Haskell, you basically can: fibonacci = 0:1:(zipWith (+) (tail fibonacci) fibonacci) but the key difference is not so much with the syntax sugar, or even the scoping -- it's with *when* the right-side references to the fibonacci list are evaluated. Python is "strict" (in FP terms): it fully evaluates the arguments before calling the function. Haskell is "lazy": it does evaluation just when the result is really needed. Compared to this key semantic issue, distinctions such as Haskell's zipWith (+) versus Python's map(operator.add are almost trivial...:-). You can get a taste of lazy programming, and other FP approaches, in Python, by downloading Bryn Keller's functional.py from http://sourceforge.net/projects/xoltar-toolkit/ But that just supplies the "bricks" -- you can use it to do some FP with Python if you already know what you're doing. Maybe a tutorial on the issue (why might you want to do that, etc) would be nice... Alex From Pieter_Claerhout at CreoScitex.com Tue Oct 17 11:00:06 2000 From: Pieter_Claerhout at CreoScitex.com (Pieter Claerhout) Date: Tue, 17 Oct 2000 17:00:06 +0200 Subject: Printing multiple lines Message-ID: <2B1262E83448D211AE4B00A0C9D61B03013015D0@msgeuro1.creo.be> Use triple quotes instead. print """firstline secondline thirdline""" Kind regards, Pieter Pieter Claerhout Application Support - CreoScitex Europe -----Original Message----- From: joonas [mailto:keisari_ at hotmail.com] Sent: Tuesday, October 17, 2000 4:54 PM To: python-list at python.org Subject: Printing multiple lines How can i print multiple lines for example ####### firstline secondline thirdline ####### i tried print "firstline secondline thirdline" but it didnt worked. Joonas -- http://www.python.org/mailman/listinfo/python-list From sandj.williams at gte.net Fri Oct 20 21:15:53 2000 From: sandj.williams at gte.net (Steve Williams) Date: Sat, 21 Oct 2000 01:15:53 GMT Subject: Announcing Jython, the sucessor to JPython References: Message-ID: <39F0EEE9.FB41BC6B@gte.net> Michael Ackerman wrote: > How about `PyJama'? > Rats, I was going to Pyprose that, but I thought it too PyJejune. From ge at nowhere.none Wed Oct 11 12:19:30 2000 From: ge at nowhere.none (Grant Edwards) Date: Wed, 11 Oct 2000 16:19:30 GMT Subject: pyGTK -- how to wait for modal dialog? References: Message-ID: In article , Grant Edwards wrote: >I've created a modal dialog box, but can't figure out how to >wait until the dialog is dismissed so I can find out which >button was pressed. Here's what I've figured out so far (it seems to work), is it the recommended idiom? class FooBar(GtkDialog): __super = GtkDialog def __init__(self,msg,buttonTextList): self.__super.__init__(self) self.__returnString = None self.set_modal(TRUE) [...] def clicked(self,buttonWidget,buttonText): self.__returnString = buttonText self.destroy() def wait(self): while self.__returnString is None: mainitereation() return self.__returnString The important thing is that mainiteration blocks until it receives an event -- this is the default behavior. -- Grant Edwards grante Yow! Mr and Mrs PED, can I at borrow 26.7% of the RAYON visi.com TEXTILE production of the INDONESIAN archipelago? From egibson at connect.com.au Sun Oct 29 20:21:54 2000 From: egibson at connect.com.au (Evan Gibson) Date: Mon, 30 Oct 2000 12:21:54 +1100 Subject: Python/C++ Engineers Wanted In-Reply-To: ; from Alex on Sun, Oct 29, 2000 at 04:32:45PM -0500 References: <8tchu7$2gd$1@nnrp1.deja.com> <39FA5040.625CB8E2@gte.net> Message-ID: <20001030122154.52168@connect.com.au> On Sun, Oct 29, 2000 at 04:32:45PM -0500, Alex wrote: > > > Curious why they would need to advertise, though. I would think there > > would be sufficient peoples around Boston, considering the kind of > > credentials they're looking for. > > No way -- like everyone else, they're dying for good people. That seems like a zero-sum game, unless the people dying aren't as good as the new people you get to replace them... Or you get multiple good people for each sacrificial victim. > Alex. -- Evan ~ThunderFoot~ Gibson ~ nihil mutatem, omni delendum ~ Walking on water... over pavement; Treading on miracles ground into everyday dust. From marcc at yieldworks.com Sat Oct 28 10:27:39 2000 From: marcc at yieldworks.com (marc cheatham) Date: Sat, 28 Oct 2000 14:27:39 GMT Subject: How do you create constants? References: Message-ID: <39FAE133.9070001@yieldworks.com> Tom wright wrote: > Hi All, > > I am a newbie to python, and I have the following question, > > in c++ I can create a constant through something like an enum, or a const > variable or a static. How do I go about doing something similar to this in > python, e.g. > > I want to create a python file/class which contains all my constants for > ease of use/maintenance. I then wish to use these from various other > files/classes. Now I understand that due to the scoping of python > variables, I can not simply reference variables in a separate module, but > how can I achieve something similar to my global defines file as in c++, by > the way, the defines would be constant strings and integers. > > I am sure there is an easy way to do this, but I havnt found it yet !! > > TIA for pointers > > Regards > > Tom > > PS I have RTFM, but if its there I have missed it I am not sure if Python has user defined constants, but a possible solution to the scoping problem could be creating a module called consts.py. Inside consts.py initialize varibles in with their "constant" value. Import that module into your other modules and use consts. to reference the pre-initialized variable. The drawback, of course, is anyone can change the value. Hope this helps. Marc From ht at cogsci.ed.ac.uk Mon Oct 23 11:09:52 2000 From: ht at cogsci.ed.ac.uk (Henry S. Thompson) Date: 23 Oct 2000 16:09:52 +0100 Subject: Desperately seeking freeze/Installer for 1.6 Message-ID: Can't find either of these -- how is one supposed to package stuff for distribution? I've tried hard to build Installer, but have been unable to get MSVC++ to compile zlibstat and Installer/Launch in such a way they can talk to each other. If anyone who has accomplished this task could mount the results, I'd be very grateful. ht -- Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh W3C Fellow 1999--2001, part-time member of W3C Team 2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440 Fax: (44) 131 650-4587, e-mail: ht at cogsci.ed.ac.uk URL: http://www.ltg.ed.ac.uk/~ht/ From wware at world.std.com Fri Oct 27 18:20:30 2000 From: wware at world.std.com (Will Ware) Date: Fri, 27 Oct 2000 22:20:30 GMT Subject: Python Formatted C Converter (PfCC) References: Message-ID: Gareth McCaughan (Gareth.McCaughan at pobox.com) wrote: > Find some > simple subset of Python... Write a > *translator* that turns this subset into C. That way, what > you're writing is more or less real Python; if you do this > right, you'll even be able to run the code in Python for > prototyping purposes... I got really intrigued with this idea and have started to tinker with it. Below appears an example of what it is currently able to do. To keep life simple, I am initially assuming everything is an int. I posted the translator to alt.sources. When deja.com notices it, I'll post their URL for it. Here's an example function to be translated: def silly(x, y): if y > 20: x = x + 1 return (6 * x + y * 3) / 7 and here is the resulting C output: #include "Python.h" #define None 0 PyObject * c_silly(PyObject *self, PyObject *args) { int stack[3]; int *sp = &stack[0]; int x; int y; if (!PyArg_ParseTuple(args, "ii", &x, &y)) return NULL; /*SET_LINENO */ Label_000: /* Python line number 175 */ /*SET_LINENO */ Label_003: /* Python line number 176 */ /*LOAD_FAST */ Label_006: *sp++ = y; /*LOAD_CONST */ Label_009: *sp++ = 20; /*COMPARE_OP */ Label_012: sp--; sp[-1] = (sp[-1] > sp[0]); /*JUMP_IF_FALSE */ Label_015: if (!sp[-1]) goto Label_035; /*POP_TOP */ Label_018: sp--; /*SET_LINENO */ Label_019: /* Python line number 177 */ /*LOAD_FAST */ Label_022: *sp++ = x; /*LOAD_CONST */ Label_025: *sp++ = 1; /*BINARY_ADD */ Label_028: sp--; sp[-1] = sp[-1] + sp[0]; /*STORE_FAST */ Label_029: x = *--sp; /*JUMP_FORWARD */ Label_032: goto Label_036; /*POP_TOP */ Label_035: sp--; /*SET_LINENO */ Label_036: /* Python line number 178 */ /*LOAD_CONST */ Label_039: *sp++ = 6; /*LOAD_FAST */ Label_042: *sp++ = x; /*BINARY_MULTIPLY*/ Label_045: sp--; sp[-1] = sp[-1] * sp[0]; /*LOAD_FAST */ Label_046: *sp++ = y; /*LOAD_CONST */ Label_049: *sp++ = 3; /*BINARY_MULTIPLY*/ Label_052: sp--; sp[-1] = sp[-1] * sp[0]; /*BINARY_ADD */ Label_053: sp--; sp[-1] = sp[-1] + sp[0]; /*LOAD_CONST */ Label_054: *sp++ = 7; /*BINARY_DIVIDE */ Label_057: sp--; sp[-1] = sp[-1] / sp[0]; /*RETURN_VALUE */ Label_058: return Py_BuildValue("i", sp[-1]); /*LOAD_CONST */ Label_059: *sp++ = None; /*RETURN_VALUE */ Label_062: return Py_BuildValue("i", sp[-1]); } static PyMethodDef foo_methods[] = { {"silly", c_silly, 1}, {NULL, NULL}}; DL_EXPORT(void) initfoo() { Py_InitModule("foo", foo_methods); } -- # - - - - - - - - - - - - - - - - - - - - - - - - # Resistance is futile. Capacitance is efficacious. # Will Ware email: wware @ world.std.com From entropiamax at jazzfree.com Fri Oct 20 06:54:26 2000 From: entropiamax at jazzfree.com (entropia) Date: Fri, 20 Oct 2000 12:54:26 +0200 Subject: Announcing Jython, the sucessor to JPython References: Message-ID: <39F02461.38CAB7D8@jazzfree.com> Oleg Broytmann escribi?: > On Fri, 20 Oct 2000, Daniel Dittmar wrote: > > > "Jython" kinda sticks in my larynx. How about "Javathon", or "Pythonava? > > How about "Jivethon"? > > PyJava? > Java is a Sun trademark and it can not appear in any name. > > Oleg. (All opinions are mine and not of my employer) > ---- > Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru > Programmers don't die, they just GOSUB without RETURN. > > -- > http://www.python.org/mailman/listinfo/python-list From daimun at home.com Mon Oct 23 23:29:13 2000 From: daimun at home.com (Alex McHale) Date: Tue, 24 Oct 2000 03:29:13 GMT Subject: MS Windows Clipboard Message-ID: I was just wondering if anyone could clue me in how to read data from the Windows clipboard? I have been reading through all the past posts regarding the clipboard; but none has had the information I'm needing. They all have to do with selections within the program itself. The idea is I need to be able to monitor the Windows clipboard for a certain type of data. Is there a way to do this in Python? Alex From raja at cs.indiana.edu Mon Oct 9 23:23:13 2000 From: raja at cs.indiana.edu (Raja S.) Date: 10 Oct 2000 03:23:13 GMT Subject: cardinal.py [was: numerals -> words] References: <8rsv4e$43a$1@flotsam.uits.indiana.edu> Message-ID: <8ru231$9kg$1@flotsam.uits.indiana.edu> Earlier I'd asked: raja at cs.indiana.edu (Raja S.) writes: >Common Lisp's format statement has a "~r" directive which can be used to >convert a numeral into it's English description: >* (format t "~r" 1992) >one thousand nine hundred ninety-two ... >Is there a pre-existing way of doing the equivalent in Python? >Thanks in advance. There doesn't seem to be any such module around. Hence I wrote one. I just needed minimal functionality. But, delightfully, getting the full functionality of Common Lisp's ~r wasn't that hard: a very general solution can be attained in just a few lines of recursive code. (I think) the code is reasonably robust, handles long ints and is easy to extend for a different number system (e.g., British 10^12 = billion). [Conversion routines between decimal<->roman numerals are also included.] Thought others might be interested. Best, Raja ### =========================================================================== ### cardinal.py """ Prints an integer as a cardinal English number or Roman numeral. The cardinal number algorithm is a straightforward recursive solution: Given any integer: xxx,xxx,xxx --- 6 3 0 <--- 'illion' powers recursively break it up into 3 digit chunks. Print each chunk separately using p_100s and attach a appropriate 'illion' suffix. * cardinal(1234) => 'one thousand two hundred thirty-four' * cardinal(-sys.maxint) => # sys.maxint == 2147483647 'negative two billion one hundred forty-seven million four hundred eighty-three thousand six hundred forty-seven' My terminology runs out for 10^66 onwards ... hence the largest number that can currently be handled is: * cardinal (10L**66 - 1) For fun the following functions have also been added below: * roman(1999) => 'MCMXCIX' * decimal('xxiv') => 24 * decimal(roman(2001)) => 2001 Note: as an experiment, String ports have been used in 'cardinal' to accumulate the result. I think it leads to cleaner code as opposed to using string.join. Some amount of exception handling has been added. Raja Sooriamurthi raja at cs.indiana.edu 10/09/2000 """ import sys, string, cStringIO, types nnames = { 0:'', 1:'one', 2:'two', 3:'three', 4:'four', 5:'five', 6:'six', 7:'seven', 8:'eight', 9:'nine', 10:'ten', 11:'eleven', 12:'twelve', 13:'thirteen', 14:'fourteen', 15:'fifteen', 16:'sixteen', 17:'seventeen', 18:'eighteen', 19:'nineteen', 20:'twenty', 30:'thirty', 40:'forty', 50:'fifty', 60:'sixty', 70:'seventy', 80:'eighty', 90:'ninety', } # these names obtained from CMUCL and Allegro CL's ~r format directive # this is pretty much centered towards American terminology # but can be easily modified for British terminology # e.g., billion = 10^12 etc illions = {0:'', 3:'thousand', 6:'million', 9:'billion', 12:'trillion', 15:'quadrillion', 18:'quintillion', 21:'sextillion', 24:'septillion', 27:'octillion', 30:'nonillion', 33:'decillion', 36:'undecillion', 39:'duodecillion', 42:'tredecillion', 45:'quattuordecillion', 48:'quindecillion', 51:'sexdecillion', 54:'septendecillion', 57:'octodecillion', 60:'novemdecillion', 63:'vigintillion', } MAX_POWER = 63 ## Don't know what 10^66 onwards is ## Hence if you to print a number >= 10^{63+3} an exception is raised ## in other wards the largest number that can be handled currently is ## cardinal (10L**66 - 1) ### For producing a cardinal number output is written to stdout. ### But in 'cardinal' sys.stdout is temporarily bound to a string port ### The result is finally read from the string port. ### Not sure if this will be faster than accumulating the result in a string ### and then 'join'ing the result. ### But using String ports certainly makes the code look cleaner. ### Raja 10/09/2000 ### ************************************************** ### cardinal ### ************************************************** ### The main function def cardinal (n): "Print the cardinal number of input n" assert (isinstance(n, types.IntType) or isinstance(n, types.LongType)), \ "input n=%s needs to be an int or a long" % n sb = cStringIO.StringIO() sys.stdout, stdout = sb, sys.stdout if (n==0): print "zero", if (n<0): print "negative", n=-n else: pass try: aux (n) except ArithmeticError, e: sb.close() sys.stdout = stdout raise e else: str = sb.getvalue() sb.close() sys.stdout = stdout return str ### ************************* ### aux ### ************************* ### The work horse def aux (n, power=0): if n==0: return q,r = divmod(n,1000) aux (q, power+3) if (r>0): p_100s(r) if (power>0): if (power<=MAX_POWER): print illions[power], else: raise ArithmeticError, "don't know the word for 10^%s" % power else: pass ### ************************* ### p_100s ### ************************* ### Handles 3-digit chunks def p_100s (n): "print a cardinal description of a number < 1000" assert 0 <= n < 1000, "%s does not lie in the range [0..99]" % n if n==0: return h, t = divmod(n,100) if (h>0): print "%s hundred" % nnames[h], if (t<20): print nnames[t], elif (t%10 != 0): # there is a units digit # print something like 'thirty-four' print "%s-%s" % (nnames[t/10*10], nnames[t%10]), else: print "%s" % nnames[t/10*10], ### ************************************************** ### roman ### ************************************************** # The order of the below tuple is important for 'roman' !! roman_numerals = ((1000,'M'), (900, 'CM'), (500,'D'), (400,'CD'), (100,'L'), (90,'XC'), (50,'L'), (40,'XL'), (10,'X'), (9,'IX'), (5,'V'), (4,'IV'), (1,'I')) def roman(n): "Convert a +ve integer into a roman numeral" n=int(n) # just in case a big num is passed in assert 00): l.append(rmn*q) if (r==0): break n=r return string.join(l,'') def rn2dn(rn): "Convert a single roman numeral digit into it's decimal value" for (d,r) in roman_numerals: if (r==rn): return d else: raise ArithmeticError, "%s is not a roman numeral digit" % rn ### ************************* ### decimal ### ************************* def decimal(r): "Convert a roman numeral into a decimal number" r=string.upper(r) ans=0 l = len(r) for i in range(l-1): if (rn2dn(r[i]) Message-ID: > I'm trying to benchmark python source with clock() function, but my > code below returns negative value. I am not sure if my code is wrong > or clock() is not suitable for getting CPU time... Any comment would > help me a lot. Thanks. I haven't used the clock function before, so I don't know whether or not it's more appropriate, but I have always used time.time for this sort of thing. You should check out the profiler, too. It's really easy to use. Alex. -- Speak softly but carry a big carrot. From olczyk at interaccess.com Sun Oct 29 11:26:13 2000 From: olczyk at interaccess.com (Thaddeus L. Olczyk) Date: Sun, 29 Oct 2000 16:26:13 GMT Subject: How totell a binary file from a nonbinary file. Message-ID: <39fe4f47.100441671@nntp.interaccess.com> There are some changes that I have to make to s directory of files ( in python of course ). Is there some simple way of telling whether a file is binary or not (from python of course )? From robin at alldunn.com Tue Oct 17 01:57:40 2000 From: robin at alldunn.com (robin at alldunn.com) Date: Tue, 17 Oct 2000 05:57:40 GMT Subject: Python 2.0 final release is out! References: Message-ID: <8sgpoh$tpl$1@nnrp1.deja.com> In article , Guido van Rossum wrote: > I am happy to announce that Python 2.0 is released. I have made a MS HTML Help version of the 2.0 docs. You can get it here: http://alldunn.com/python/py2docs.zip -- Robin Dunn Software Craftsman robin at AllDunn.com http://wxPython.org Java give you jitters? http://wxPROs.com Relax with wxPython! Sent via Deja.com http://www.deja.com/ Before you buy. From daimun at home.com Mon Oct 23 16:14:05 2000 From: daimun at home.com (daimun at home.com) Date: Mon, 23 Oct 2000 20:14:05 GMT Subject: Python Formatted C Converter (PfCC) References: Message-ID: <8t2665$isn$1@nnrp1.deja.com> I have indeed been humbled. I posted this message looking for feedback; and I certainly got that. No flames, so I'm happy. I do understand why this isn't such a great idea; and I am also interested in a few ideas that I have received regarding similar projects, yet not quite as .. (ambitious+ill_thought_out+misguided)/3. Thanks, and I hope this idea gone sour won't taint anyone's taste to future projects of mine. Alex PS - having to post this through Deja, because I'm at work. In case it shows the wrong email address, I'm daimun at home.com. Sent via Deja.com http://www.deja.com/ Before you buy. From DOUGS at oceanic.com Tue Oct 24 15:58:31 2000 From: DOUGS at oceanic.com (Doug Stanfield) Date: Tue, 24 Oct 2000 09:58:31 -1000 Subject: run a python application inside the python shell Message-ID: <8457258D741DD411BD3D0050DA62365907A3C4@huina.oceanic.com> If you are used to programming by putting together a procedural script you won't be able to easily do this. If the following were named breakfast.py: #!/usr/bin/env python import sys spam = 22 eggs = 3 ketchup = 0 rice = "the food of gods" if len(sys.argv) > 0: ketchup = 1 try: food = [('no','some','lots of')[int(spam/8.0)]] except IndexError: food = ['great heaps of'] food.append(eggs) food.append(rice) print "I want %s spam, %s eggs, and rice, %s." % tuple(food) if ketchup: print "Pour some of da kine ova hea." This is run from the command line: > spam.py -or- > python spam.py If you want to use this inside the interactive interpreter (I assume that is what you mean by the shell) rewrite to make it a module: #!/usr/bin/env python import sys def serve(spam,eggs,rice,ketchup=0): try: food = [('no','some','lots of')[int(spam/8.0)]] except IndexError: food = ['great heaps of'] food.append(eggs) food.append(rice) dish = "I want %s spam, %s eggs and rice, %s." % tuple(food) if ketchup: dish = dish + "\nPour some of dat ova hea." return dish if __name__ == '__main__': spam = 22 eggs = 3 ketchup = 0 rice = "the food of gods" print sys.argv if len(sys.argv) > 1: print serve(spam,eggs,rice,ketchup=1) else: print serve(spam,eggs,rice) This way it still runs from the command line as before or you can enter the interpreter and play with it: > 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 breakfast >>> print breakfast.serve(0,1,"lots of it") I want no spam, 1 eggs and rice, lots of it. >>> I hope that was what you were asking. ;-) -Doug- > -----Original Message----- > From: Hwanjo Yu [mailto:hwanjoyu at uiuc.edu] > Sent: Tuesday, October 24, 2000 8:25 AM > To: python-list at python.org > Subject: Q: run a python application inside the python shell > > > Hi, > > How to run a python application inside the python shell ? > Thanks in advance. > > > > -- > http://www.python.org/mailman/listinfo/python-list > From donod at home.com Wed Oct 18 22:25:05 2000 From: donod at home.com (Donald O'Donnell) Date: Thu, 19 Oct 2000 02:25:05 GMT Subject: str(list) calls repr() on elements? References: <39ED5964.4B00C029@home.com> Message-ID: <39EE5B85.D0EAC05C@home.com> I'm not sure what you mean here. If the elements are not strings, something has to convert them to strings before they can be printed. I ran a test to see when str() or repr() is called: >>> class nada: ... def __str__(self): ... return 'str' ... def __repr__(self): ... return 'repr' ... >>> n = nada() >>> n repr >>> print n str >>> str(n) 'str' >>> repr(n) 'repr' >>> str([n]) '[repr]' >>> repr([n]) '[repr]' >>> str((n,)) '(repr,)' >>> repr((n,)) '(repr,)' >>> str({n:n}) '{repr: repr}' >>> repr({n:n}) '{repr: repr}' >>> This seems to me to be undesirable behavior. I would expect that when the str or repr functions are applied to sequences or mappings, that the same (str or repr) function should be applied recursively to all component elements. Should this be considered a bug? Don O'Donnell Ulf Engstr?m wrote: > > OKi, I'm not familiar with the interior of repr and str, but I believe none > of the functions are called for each element of a list or a tuple, but > rather stringifying the whole list. > '[the,elements,will,just,be,part,of,the,string]' > Am I wrong here? > Ulf > > > It seems that the built-in function 'str', when applied to a list/tuple, > > constructs its result by calling 'repr' on the elements of the list/tuple, > > rather than 'str'. How come? > > > > e.g. > > >> str(1L) > > '1' > > >> repr(1L) > > '1L' > > >> str( [1L] ) > > '[1L]' # not '[1]' > > > > -Michael Dyck > > -- > > http://www.python.org/mailman/listinfo/python-list From mmueller at dgfz.de Tue Oct 24 10:21:46 2000 From: mmueller at dgfz.de (Mike Müller) Date: Tue, 24 Oct 2000 16:21:46 +0200 Subject: DLL in Python References: <8t1e4p$gok@micky.ibh-dd.de> <8t290k0hjb@news2.newsguy.com> <8t35kk$1j8@micky.ibh-dd.de> <8t3ep701srg@news2.newsguy.com> Message-ID: <8t45h8$6h0@micky.ibh-dd.de> Alex, thanks for your advise. I tried to compile the following *.cpp file, which is just a cut and paste from what you posted previously: include #include PyObject* module_object; BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { if(ul_reason_for_call == DLL_PROCESS_ATTACH) { Py_Initialize(); if(PyErr_Occurred()) { PyErr_Print(); return FALSE; } module_object = PyImport_ImportModule("testdll"); if(PyErr_Occurred()) { PyErr_Print(); return FALSE; } if(!module_object) return FALSE; } return TRUE; } __declspec(dllexport) int test_int4(int x, int y) { PyErr_Clear(); PyObject* result = PyObject_CallMethod( module_object, "test_int4", "ii", x, y); if(!result) { /* disaster -- make it known somehow, e.g: */ fprintf(stderr, "Error calling test_int4(%d,%d)\n", x, y); if(PyErr_Occurred()) { PyErr_Print(); } return 0; } else { PyObject* pintresult = PyNumber_Int(result); Py_DECREF(result); if(!pintresult) { /* other disaster -- make it known somehow, e.g: */ fprintf(stderr, "test_int4(%d,%d) returned non-int\n", x, y); if(PyErr_Occurred()) { PyErr_Print(); } return 0; } else { int intresult = PyInt_AS_LONG(pintresult); Py_DECREF(pintresult); return intresult; } } } Trying to compile this I get the following (German orginal with my translation between the lines): --------------------Configuration: Int4Py - Win32 Debug-------------------- Compiling... int4fromPy.cpp g:\projekte\spree\dll\int4py\int4frompy.cpp(6) : error C2146: Syntaxfehler : Fehlendes ';' vor Bezeichner 'APIENTRY' syntax error: Missing ';' in front of identifier 'APIENTRY' g:\projekte\spree\dll\int4py\int4frompy.cpp(6) : error C2501: 'BOOL' : Fehlende Speicherklasse oder Typbezeichner 'BOOL' : Missing memory class or type identifier g:\projekte\spree\dll\int4py\int4frompy.cpp(6) : fatal error C1004: Unerwartetes Dateiende gefunden Unexpected EOF found Error executing cl.exe. Int4Py.dll - 3 error(s), 0 warning(s) The translation may sound akward but that is all I can come up with. I looked through the VC++ help system and found an example showing the approach above. I am not sure if used a wrong option. Both, Multithreaded DLL and Debug Multithreaded DLL yield the same result. Fiddling for several hours with some other things I found in the help did not change anything. What could be the reason? Thanks. Mike From tegner at nada.kth.se Sun Oct 1 10:53:20 2000 From: tegner at nada.kth.se (Jon Tegner) Date: Sun, 01 Oct 2000 14:53:20 GMT Subject: rpmmodule Message-ID: <39D75018.B6952185@nada.kth.se> How can one get information about how to use this module (which is supplied by the rpm-python package)? Have checked the reference manual, the tutorial and learning python as well as searched the net (but I'm new to python, so it is not unlikely that I'm missing something obvious...). Thanks /jon From jhauser at ifm.uni-kiel.de Tue Oct 17 16:01:34 2000 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 17 Oct 2000 22:01:34 +0200 Subject: Text formatting question References: Message-ID: <87zok36xup.fsf@ifm.uni-kiel.de> Ka-Ping Yee has made a module for this, look for this and other amazing stuff at http://www.lfw.org/python/ HTH, __Janko -- Institut fuer Meereskunde phone: 49-431-597 3989 Dept. Theoretical Oceanography fax : 49-431-565876 Duesternbrooker Weg 20 email: jhauser at ifm.uni-kiel.de 24105 Kiel, Germany From aleaxit at yahoo.com Thu Oct 5 05:31:47 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 5 Oct 2000 11:31:47 +0200 Subject: Python/C API References: <39DC3EE1.A4568884@stud.informatik.uni-erlangen.de> Message-ID: <8rhi4a01ulk@news1.newsguy.com> "Joerg Baumann" wrote in message news:39DC3EE1.A4568884 at stud.informatik.uni-erlangen.de... [snip] > I?m trying to extend python and I have following problem with the C/API: > Howto make a new instance of a class defined in Python from C? [snip] > I?m searching for somthing like > > PyObject* > f=PyInstace_New(PyString_FromString("foo"),PyString_FromString("data")) PyObject_CallObject (or PyObject_CallFunction) are what you need, see 6.1 in the API reference manual. But of course you need the object for the class, just as you need the PyObject* for any other Python object to do something with it! PyRun_String (see part 2 in the reference manual) may be a quick & dirty way to get it, but you still need the object pointers for the globals & locals dicts. Alex From hartmut at oberon.noris.de Thu Oct 26 12:53:26 2000 From: hartmut at oberon.noris.de (hartmut Goebel) Date: Thu, 26 Oct 2000 17:53:26 +0100 Subject: Scripting SSH with Python References: Message-ID: <16600824@oberon.noris.de> Lenny Self (lenny at squiggie.com) schrieb: >I am scripting SSH or actually rsync using ssh and I am in need of a bit of >help. When I make the SSH connection I am prompted to enter a password... >my problem is that I don't know how to look for this promt and have the >script submit the password for me. Can anyone give me some help on this. I worked on the same problem some weeks ago. I'll publish the stuff next week and announce it here. (Sory, I'm ill this week.) >I have been experimenting with os.popen and os.popen3 but I am either >looking in the wrong spot or I am not doing it correctly. I used expect. +++hartmut | hartmut Goebel | hartmut at oberon.noris.de // | | Compiler Manufactur | Essich at irc \X/ | PGP fingerprint = BF DD D6 75 7C 03 21 52 47 65 50 7F 54 47 06 C7 From grante at visi.com Mon Oct 2 14:26:05 2000 From: grante at visi.com (Grant Edwards) Date: 2 Oct 2000 13:26:05 -0500 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Oct 2) Message-ID: <832C440E397F69B6.ABAE9E1D52294C5B.7E2E7E3E0B000752@lp.airnews.net> Michal Wallace shows how you figure out how to run IE browser via COM interface. http://deja.com/=dnc/getdoc.xp?AN=673333955 Steven D. Majewski mentions article on writing a PIC disassembler in Python. http://deja.com/=dnc/getdoc.xp?AN=672967549 Steven D. Majewski posts pointers on Python 2.0 on MacOSX/Darwin. http://deja.com/=dnc/getdoc.xp?AN=675564269 A.M. Kuchling requests comments on doc describing the new Python development process. http://deja.com/=dnc/getdoc.xp?AN=674544685 Robert Roebling announces wxDesigner 1.2 - a visual dialog editor for wxPython/wxWindows. http://deja.com/=dnc/getdoc.xp?AN=675090228 Webware 0.4 announced - a suite of Python components for developing web applications. http://deja.com/=dnc/getdoc.xp?AN=675379517 ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org although PythonLabs.com bills itself as "The Python Source", which is becoming increasingly true in 2000 http://www.pythonlabs.com/ PythonWare complements the digest you're reading with the daily python url http://www.pythonware.com/daily comp.lang.python.announce announces new Python software. Be sure to scan this newly-revitalized newsgroup at least weekly. http://deja.com/group/comp.lang.python.announce The Vaults of Parnassus ambitiously collects Python resources http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Consortium emerges as an independent nexus of activity http://www.python.org/consortium Cetus does much of the same http://www.cetus-links.de/oo_python.html Python FAQTS http://python.faqts.com/ Python To-Do List anticipates some of Python's future direction http://www.python.org/cgi-bin/todo.py Python Journal is at work on its second issue http://www.pythonjournal.com Links2Go is a new semi-automated link collection; it's impressive what AI can generate http://www.links2go.com/search?search=python Archive probing trick of the trade: http://www.dejanews.com/dnquery.xp?QRY=&DBS=2&ST=PS&defaultOp=AND&LNG=ALL&format=threaded&showsort=date&maxhits=100&groups=comp.lang.python Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://www.dejanews.com/dnquery.xp?QRY=~g%20comp.lang.python%20Python-URL%21 Suggestions/corrections for next week's posting are always welcome. [http://www.egroups.com/list/python-url-leads/ is hibernating. Just e-mail us ideas directly.] To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. Mention "Python-URL!". -- The Python-URL! Team-- Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and sponsor the "Python-URL!" project. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From sholden at holdenweb.com Fri Oct 27 08:35:07 2000 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 27 Oct 2000 08:35:07 -0400 Subject: Solved References: <39F83ED4.57ADB649@hotmail.com> <39F86026.D65F0CB7@hotmail.com> <39F873C9.B7C96FC1@holdenweb.com> <1L_J5.2993$jv2.337201@newsc.telia.net> <39F88034.2F13AC5D@hotmail.com> <39F94795.16E23866@hotmail.com> Message-ID: <39F9767B.865F2F83@holdenweb.com> joonas wrote: > > I solved the problem by asking in a Blender group. > > first.val - second.val > > Joonas. > Joonas: Thanks for the feedback. It's always nice to know how these things come out. You should at least have discovered that comp.lang.python will usually try to help if it thinks it can. (Do newsgroups actually think? Well, there is a sort of gestalt). regards Steve -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ From jurgen.defurne at philips.com Thu Oct 26 04:04:47 2000 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Thu, 26 Oct 2000 10:04:47 +0200 Subject: C's syntax (was Re: Python Formatted C Converter (PfCC)) Message-ID: <0056900013224812000002L022*@MHS> aleaxit at yahoo.com@SMTP at python.org on 25/10/2000 19:01:33 Sent by: python-list-admin at python.org To: python-list at python.org@SMTP cc: Subject: Re: C's syntax (was Re: Python Formatted C Converter (PfCC)) Classification: While this is also a rather sugary issue (excepting those languages, such as PL/I and Basic, which overload '=' to mean EITHER assignment OR comparison depending on context; THAT one is pretty bitter...!-), it interacts with letting assignment be an expression, _and_ the lack of a specific 'boolean' type exclusively accepted as argument to if/while, to produce a serious problem. Each of the three choices is arguably defensible by itself, but all three together mix badly. Python has chosen to NOT allow assignments as expressions; I'm not sure that is the "best" solution, but, it _is_ a solution. In a C context, though, I'd lean to a different solution -- syntax restriction on what is accepted in a 'condition' (comparisons, &&, ||, ..., yes, but not assignments, &, |, ...). Note that this I agree on not allowing '=' in a condition, but it is nice for testing bits if one can say if (var & 0x01) { } or var = (value & 0x01) ? ... : ... ; Jurgen From spahievi at vega.bg Wed Oct 25 17:05:26 2000 From: spahievi at vega.bg (Niki Spahiev) Date: Thu, 26 Oct 2000 00:05:26 +0300 Subject: Pretty report printing In-Reply-To: <39F707A9.7D007A41@holdenweb.com> References: <39F707A9.7D007A41@holdenweb.com> Message-ID: <573610736.20001026000526@vega.bg> 25.10.2000, 19:17:45, Steve Holden wrote: SH> I found the wxPython printing was broken on Windows 95 -- is it just me, SH> or have more recent releases (this was about six months ago) fixed the SH> problem? I am printing from wxPython 2.2 on win95 fine. -- Best regards, Niki Spahiev From world.domination at pus.org Tue Oct 31 09:09:21 2000 From: world.domination at pus.org (Guidoferatu van Rossumati) Date: Tue, 31 Oct 2000 09:09:21 -0500 (EST) Subject: PythonLabs Team Moves to Digital Creations References: <20001030.235855.937370163.4587@locutus.noreboots.com> Message-ID: <14846.53905.194421.965357@anthem.concentric.net> >>>>> "MO" == Mikael Olofsson writes: >> Yes, the PSU, which is completely different than the SPU, the >> Secret Python Underground. Word has it that if they both >> existed, they would not get along. MO> Not to mention the Secret Underground of Python... Or the Python Underground Society. From curtis01 at usa.net Mon Oct 2 02:03:06 2000 From: curtis01 at usa.net (curtis) Date: Mon, 02 Oct 2000 06:03:06 GMT Subject: Need your help ... Message-ID: <779gtsgsij63aoef8ma3i09tm7kovqqrl0@4ax.com> Need your expertise. Lone developer. Joint venture. Your experience/resume worth a lot. No coding. Won't waste your time. Degree not important. History/portfolio is everything. Non-instructional. No coding. Royalties. Please email me. (remove "nospam.") nospam.guru at patcurtis.com TIA From info at pythonware.com Tue Oct 24 09:24:28 2000 From: info at pythonware.com (PythonWare) Date: Tue, 24 Oct 2000 15:24:28 +0200 Subject: ANNOUNCEMENT: The Python Imaging Library, version 1.1.1 (oct 20, 2000) Message-ID: <005c01c03dbd$bdaa45e0$0900a8c0@SPIFF> more stuff from the real labs: The Python Imaging Library (PIL) adds image processing capabilities to your Python interpreter. This library supports many file formats, and provides powerful image processing and graphics capabilities. Version 1.1.1 is a maintenance upgrade. The changes include proper handling of TIFF files under Python 2.0, better plugin detection when using PIL as a package, and some bug fixes. Get your copy of the source kit here: http://www.pythonware.com/downloads.htm#pil11 For more information, including support options, see the product site: http://www.pythonware.com/products/pil/ enjoy, the pil team "Secret Labs -- makers of fine pythonware since 1997." From jo2red at my-deja.com Mon Oct 30 06:23:24 2000 From: jo2red at my-deja.com (jo2red at my-deja.com) Date: Mon, 30 Oct 2000 11:23:24 GMT Subject: PythonWin IDE sucks! References: <7tuivs46osods22uumpvsvsap2jocrd4si@4ax.com> <39FCEF41.503AFA9D@my.signature> Message-ID: <8tjln9$8oi$1@nnrp1.deja.com> In article <39FCEF41.503AFA9D at my.signature>, Greg Ewing wrote: ... > Are you still using the instance that you created the first ... Thank you Greg for a decent response. Most of the rest of this thread has dismayed me with its tone. Geoff Gardiner Sent via Deja.com http://www.deja.com/ Before you buy. From skodela at my-deja.com Fri Oct 20 12:46:21 2000 From: skodela at my-deja.com (Sindh) Date: Fri, 20 Oct 2000 16:46:21 GMT Subject: Pmw gurus , how to color the combobox Message-ID: <8spssq$cvn$1@nnrp1.deja.com> Hi folks I have an application in Pmw. I am trying to add color to combobox etc. I know i can use as following but was wondering if there is any more decent way of it. The way I do it is as follows: cb=Pmw.ComboBox(root) cb._arrobtn.configure(fg='red',bg='white') cb._entryWidget.configure............blah cb._ComboBox__listbox.configure........blah etc Any better suggestions! Thanks a lot sreekant -- A man needs to sleep for 36 hours a day atleast. Sent via Deja.com http://www.deja.com/ Before you buy. From aleaxit at yahoo.com Tue Oct 10 07:40:16 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 10 Oct 2000 13:40:16 +0200 Subject: super - is (should) it (be) a reserved word? References: Message-ID: <8ruvh10dcu@news2.newsguy.com> wrote in message news:mailman.971170103.16530.python-list at python.org... > What do the leading underscores do? In my example I was sure to use three If a class attribute or instance attribute name starts with __ (two leading underscores) but does NOT end with __ (two trailing underscores), then Python internally transforms this name to start with _Classname_. This ensures against accidental clashes between attribute names for base and derived classes. Alex From jennifer at isogen.com Fri Oct 20 16:14:23 2000 From: jennifer at isogen.com (jennifer at isogen.com) Date: Fri, 20 Oct 2000 15:14:23 -0500 (CDT) Subject: Where is wxPython? In-Reply-To: <39E33757.E9F81F9C@cicei.ulpgc.es> References: <39E33757.E9F81F9C@cicei.ulpgc.es> Message-ID: try the download page at wxPython.org On 10 Oct 2000 ecastro at cicei.ulpgc.es wrote: > Message from the Deja.com forum: > comp.lang.python > Your subscription is set to individual email delivery > This message was sent to jennifer at isogen.com > Deja.com: Best way to buy a PC > http://www.deja.com/channels/channel.xp?CID=13031 > > > Hi: > I have tried to download wxPython 2.2.1 from SourceForge (file > wxPython-2.2.1.EXE), but the file is not accesible (in fact no one file > in the site is downloadable) > Where else can I find wxPython 2.2.1? > > Thanks > > Enrique Castro > > > > > > _____________________________________________________________ > Deja.com: Before you buy. > http://www.deja.com/ > * To modify or remove your subscription, go to > http://www.deja.com/edit_sub.xp?group=comp.lang.python > * Read this thread at > http://www.deja.com/thread/%3C39E33757.E9F81F9C%40cicei.ulpgc.es%3E > > Sent via Deja.com http://www.deja.com/ Before you buy. From Gareth.McCaughan at pobox.com Sun Oct 22 18:43:14 2000 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Sun, 22 Oct 2000 23:43:14 +0100 Subject: Python Formatted C Converter (PfCC) References: Message-ID: Alex McHale wrote: > The object may sound like an odd one. But I'll give the rundown. If you > think it sounds stupid and pointless, good for you -- consider this all > academic. Just tell me so - no need to flame me if it's a horrible idea. > If you like the idea, awesome, let me know. .. > The project is, as I call it, a Python Formatted C Converter. What this > means, is that it takes a python-style coded C program and converts it into > compilable C code. I think it's a horrible idea :-). Here are some reasons. - A C program written in "Python style", with indentation instead of braces etc, is likely to be very painful for most C programmers to read or modify. - Debugging such a program will be horrible, since the debugger will presumably work on the derived C code rather than the original Python-style code. - C written with Python syntax will be nasty for language-aware text editors. Emacs and Vim, for instance, have special modes for editing C and Python: but none for editing 0.5*(C+Python). - Some features, as you've discovered, don't *have* natural translations. Switch statements. The preprocessor. goto. I don't mean that it's impossible to find equivalents for them; I mean that there isn't a "canonical" equivalent and you'll find that anything you do feels wrong. - If you write something substantial in this blend of C and Python, I predict that you'll find that the surface Pythonesque appearance misleads you and makes you do things that aren't legal in C, or that are legal but mean something other than what you think. - The things that really hurt about programming in C rather than in Python are mostly semantic, not syntactic. Slapping a Python-looking surface syntax on will only make you get more frustrated about the things you really can't do. If you have to write C, and find the Python syntax so much nicer than native C syntax, here's a suggestion. Find some simple subset of Python. Augment it with as many new constructs as you need (and as few as you can get away with). Write a *translator* that turns this subset into C. That way, what you're writing is more or less real Python; if you do this right, you'll even be able to run the code in Python for prototyping purposes (make the new constructs look like comments to Python). This is a much bigger undertaking than writing a simple preprocessor to turn almost-C into C; but it's also much more likely to be useful. In this case, your sample program would turn into something like #!return-type int def main(): #! type int x,y x,y = 3,2 if x Message-ID: In article , Neil Hodgson writes >Robin Becker: >> In article , Alex >> writes >> ... >> >You should judge more by your web server logs than the response here. >> >My own experience suggests there are a lot of shy people lurking >> >here. (Well, I would count as one of them, in your case. :) >> > >> >Alex. >> > >> If my crappy, about to go broke ISP, allowed such things I would check. >> I am monetarily constrained so use the cheapest available option. > > SourceForge is about as cheap as possible and provides information on the >number of times packages have been downloaded. The biggest problem with >moving to SourceForge is that the upload process is a bit complex requiring >ftp to copy the file to SourceForge and then interacting with some web pages >to park it correctly. > > Neil ... It's a bit ridiculous to put such nonsense on sourceforge by itself. I'm not a web expert programmer and certainly haven't the time to program it all up to look nice etc. Also from this side of the Atlantic it's a very slow interface sometimes although the cvs side is easy. There would be a case for a place for small python extensions to live together, but I'm not volunteering. -- Robin Becker From root at rainerdeyke.com Tue Oct 24 17:46:10 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Tue, 24 Oct 2000 21:46:10 GMT Subject: [Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich comparison References: <39EB3D03.A00C78B6@jps.net> <39F4A4DE.9202540A@udel.edu> <8t3ota028jv@news2.newsguy.com> <39F5AA7A.2C5E35CE@udel.edu> <8t4dl301a4@news2.newsguy.com> Message-ID: "Fredrik Lundh" wrote in message news:kKlJ5.2434$QH2.221699 at newsb.telia.net... > Rainer Deyke wrote: > > Everybody who expected 0.6666667, raise your hands. Put your hands down. > > Now, everybody who expected 0.6667 raise your hands. How about those who > > expected 0.66666666666666663 (the "real" result of 2.0/3.0 on my computer)? > > Anybody? > > the usability studies alex was referring to were > done in the alice project (www.alice.org). > > Alice uses python to control 3D objects, and they > found that users had real problems accepting that > > myBunny.moveForward(2/3) > > left the bunny standing there, instead of moving it > 2/3 units forward. Ah, a rigged experiment. This this special case, I agree that truncation seems unnatural, because movement is continuous. Did the experiment also show that people expect three calls to myBunny.moveForward(2/3) to be subtly different from one call to myBunny.moveForward(2)? > but for programmers, the real problem is that "/" in an > expression like "a/2" is sometimes an integer division, > and sometimes a floating point division, depending on > what data you happen to pass your function... I find that this is usually obvious from the context. If a floating point argument makes sense (which is almost never the case in my experience), convert to floating point before dividing. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From andrew.markebo at telelogic.com Sun Oct 1 16:56:06 2000 From: andrew.markebo at telelogic.com (Andrew Markebo) Date: 01 Oct 2000 22:56:06 +0200 Subject: Win32com and unicode problems - ordinal not in range(128) References: Message-ID: Duh.. reading the docs again.. rather.. the Tutorial for 2.0 ( I think I am using 1.6) I discover that you can do [unicodestring].encode('[encoding]') *sigh* :-) Well were are the good old times when men were men, small flurry things were small flurry things.. and strings were strings.. /A From pete at visionart.com Wed Oct 4 19:00:04 2000 From: pete at visionart.com (Pete Shinners) Date: Wed, 4 Oct 2000 16:00:04 -0700 Subject: 4-byte string to integer References: <39DB493F.A7AA3E40@noaa.gov> <39DB63FF.BAF3B4B5@gssec.bt.co.uk> Message-ID: <8rgclr$hkj$1@la-mail4.digilink.net> j vickroy wrote: > > How can a 4-byte string be converted to an unsigned integer using > Python? > > The byte order may be either big or little endian. i believe the struct module can do what you want. it translates back and forth between binary(ish) data and character buffers. it even handles endian issues. From arildh at stud.cs.uit.no Mon Oct 9 14:38:56 2000 From: arildh at stud.cs.uit.no (Arild Hansen) Date: Mon, 9 Oct 2000 20:38:56 +0200 Subject: Redhat 7.0, python 2.0b2 and tcl-8.3.1-46 problem ... Message-ID: <8rt2la$1rq$1@news.uit.no> Hello, I try to install python 2.0b2 on a Redhat 7.0 distribution. When I installed Redhat 7.0 I selected everything related to the Development sections (packages). When trying to install Python 2.0b2 everything works fine. When trying to install expat-1.1-1.i386.rpm everything works fine, BUT when I try to install Tkinter-2.0-8.0.1.i386.rpm I get the following errors: error: failes dependenies: libtcl8.0.so is needed by Tkinter-2.0-8.0.1 libtk8.0.so is needed by Tkinter-2.0-8.0.1 So I install Tcl/Tk version 8.0.5 (tcl-8.0.5-35.i385.rpm) but then I get several conflicts with the already installed (i.e. installed under the installation of Redhat 7.0) tcl package being version tcl-8.3.1-46. In other words, my system contains a new version of tcl that is not compatible / recognized by python 2.0 beta 2 and when I try to install an older version of tcl I am not allowd (yes, I know I can try rpm -U --force but this conflicts with other packages depending on the new version of tcl). So, how do I get python 2.0 beta 2 to work with tcl-8.3.1-46 ? Thx for all help, Arild Hansen From sholden at holdenweb.com Fri Oct 27 12:39:08 2000 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 27 Oct 2000 12:39:08 -0400 Subject: The starship returns ... Message-ID: <39F9AFAC.151D0C0F@holdenweb.com> ... and PythonLabs too. This is suddenly a very good day! -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ From jasonic at nomadicsltd.com Sat Oct 7 19:33:48 2000 From: jasonic at nomadicsltd.com (Jason Cunliffe) Date: Sat, 7 Oct 2000 19:33:48 -0400 Subject: Why is "while" ticking me off??? References: <39DD15A1.442E5A33@ix.netcom.com> <39DCE8B8.3100BE89@seebelow.org> Message-ID: > Personally, if I wanted to tinker with Python's syntax, my first choice > would be to turn "elif" into "else if". Perhaps there's some > parser-related reason this won't work, but I'm always bugged by "elif" > because I can never remember whether it's "elif", "elsif", or "elseif". > (BTW, if one _had_ to make "else if" into a single keyword wouldn't the > last make one make the most sense? But I suppose that Guido thought it > was best to follow the poor precedent of C...) I know what you mean... My mnemonic to remember 'elif' is 'helluva way to write else if' !!! try it :-) hth - Jason From aleaxit at yahoo.com Mon Oct 30 18:17:46 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 31 Oct 2000 00:17:46 +0100 Subject: A Suggestion (please read and respond) References: <8tk3so$fvm$1@newsreaderm1.core.theplanet.net> Message-ID: <8tkvp50ie0@news1.newsguy.com> "Franz GEIGER" wrote in message news:8tk3so$fvm$1 at newsreaderm1.core.theplanet.net... > Indeed, typos are very annoying and I hate to find them at runtime. > In a 1st step a kind of a lint program would do. There are several "lint for Python" scripts on the net, of course. But Python is good enough at 'introspection' that not much is needed for a task such as checking that a function has "declared" all local variables it defines, for example -- supposing, for example, that you decide you want the 'declaration' to be a line in the function's docstring, of the form, say: local: a, b,c,d For any function object f, the list of its local variable names (arguments excluded, assuming you don't want arguments to have to be declared as well) is easy to find -- let's sort it alphabetically, too, as long as we're at it: def localnamesof(f): "local: co, result" co=f.func_code result=list(co.co_varnames[co.co_argcount:]) result.sort() return result as are the lines in its docstring that are of the above 'local-declaration form': def declaredof(f): "local: result, line, words" result=[] for line in f.__doc__.split('\n'): words=line.split() if words and words[0]=='local:': result.extend(''.join(words[1:]).split(',')) result.sort() return result Now we have the list of local names defined in the function, localnamesof(f), and that of those declared in 'local:' lines -- and they're already sorted, too, so we just need to check equality: def checklocals(f): defined=localnamesof(f) declared=declaredof(f) if declared==defined: return 1 return 0 Of course, it's easy to give better diagnostics if the check fails, and information about those variable names if it succeeds; one may also choose to implement a specific declaration args: x, y in addition, etc, etc. Then, one gets into the _global_ variables business -- which is trickier for compile-time control, since the global variables are only first set when the module is imported (and so its global code executed), and others may be added later arbitrarily (even from outside the module). If we're OK with checking after import and don't care about highly dynamic behavior such as the latter, it's not too bad. Variables are going to be the entries in the module's directory (excepting those of type function and class, and the intrinsic ones such as __doc__ etc) -- those are easier to get. A bit trickier is taking into account that any function of the module may create or use variables there; but the co_names attribute of the functions' (and methods'...) code objects can help (with some care about those names which are not of global variables, but of local ones, built-ins, functions, ...). I think it's a good exercise to extend this -- and, worst case, one starts to play with the modules in section 17 of the Library Reference... If you try this, I predict you may have a much better grasp (and appreciation) of Python once you're done. Probably enough to agree with me that the result has little practical use... but, it _has_ been instructive to develop!-) Alex From olczyk at interaccess.com Thu Oct 19 02:19:24 2000 From: olczyk at interaccess.com (Thaddeus L. Olczyk) Date: Thu, 19 Oct 2000 06:19:24 GMT Subject: A graphical debugger for python in linux. Message-ID: <39ee90e7.32307375@nntp.interaccess.com> I've tried boa,idle and a few other debuggers for python on linux. I've also found each to com with one fundamental problem. There is no way to debug a python script with commandlin arguments. Typically I would want to run one this way ( assuing I did not use the proper shebang ): python foo.py a b c I would also lke to debug under these circumstances, but am unable because the debuggers can't accept commandline arguments. Can anyone help. From aleaxit at yahoo.com Sun Oct 8 12:47:54 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 8 Oct 2000 18:47:54 +0200 Subject: Integer multiplication overflow. References: <8ronb6$75e$1@nnrp1.deja.com> <8rphoh129t3@news1.newsguy.com> Message-ID: <8rq8j802t7o@news1.newsguy.com> "Fredrik Lundh" wrote in message news:TUYD5.681$YU1.66035 at newsc.telia.net... > Alex Martelli wrote: > > It doesn't have unlimited-precision rationals in the language or > > standard library (I don't know why -- it IS a strange omission) > > there's an implementation in the standard distribution: > > Demo/classes/Rat.py There does not seem to be such a file (nor, indeed, any Demo directory) in the 2.0b2 distribution (Windows version). Looking back a while, I was unable to find anything named rat*.py in any standard distribution of 2.0, 1.6, or 1.5.2 either (again, the for-Windows kinds). Looking with google, I can see several references to demo/classes/rat.py files on the web, under the filelists/manifests for various Python distributions (not for Windows, and not as recent as 1.5.2 final, as far as I can tell). > if it's good enough (I cannot tell), and someone contributes some > documentation, I'm sure it could be added to the standard library > in 2.1. I have not yet examined this Rat.py in depth (having not yet been able to put my hands on it...), but another implementation worth looking into is Lanny Ripple's yarn.py, which I was able to find under: ftp://ftp.lip6.fr/pub/python/contrib-09-Dec-1999/DataStructures/yarn.tar.gz No doubt there are others yet, since this module (from early '96) identifies itself as "yet another" rational numbers module... Alex From aleaxit at yahoo.com Sun Oct 8 09:30:11 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 8 Oct 2000 15:30:11 +0200 Subject: Installing 2.0 with a 1.5.* version in place References: <39e16234.203101046@nntp.interaccess.com> Message-ID: <8rpsv402ip0@news1.newsguy.com> "Thaddeus L. Olczyk" wrote in message news:39e16234.203101046 at nntp.interaccess.com... > Several questions about installing 2.0b2. > First when will 2.0final be ready? > If someone says this week, then I am not going to bother > until final is out (why do it twice in a short span?) Uh, what about "to contribute to the best of your abilities to the development process"...? If you can find a bug, and submit a bug report to sourceforge, you'll help Python 2.0 final have one bug less... > Second do I have to unistall 1.5.*, or can I just install 2.0 > over it? I've installed 1.6 and 2.0b1, then b2, side by side (to help test the new stuff while still using perhaps-more-solid one). Don't know if this holds for 1.5.2 and 2.0 as well. > Third what other "software packages" am I going to have to > update ( WinPython, IDLE, libraries...). Anything that doesn't come with Python itself (IDLE does, at least in the Windows distribution but I believe in the Unix one as well) will also need to be updated (many old .py scripts might still work, but they might break; .pyd's will definitely not work). Alex From mspal at sangria.harvard.edu Tue Oct 10 21:53:52 2000 From: mspal at sangria.harvard.edu (Michael Spalinski) Date: 10 Oct 2000 21:53:52 -0400 Subject: simple image processing in python References: Message-ID: >>>>> "Feiyi" == Feiyi Wang writes: Feiyi> I have a simple need of geting image size from either .jpg or Feiyi> .tif. I didn't find any suitable library from standard python Feiyi> distribution, and python imaging SIG got a distribution which Feiyi> seems pretty old (1997). Feiyi> I wonder what is usually/effective way to get it done? Look for PIL at www.pythonware.com --M. From olivierS.dagenaisP at canadaA.comM Fri Oct 20 19:01:15 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Fri, 20 Oct 2000 23:01:15 GMT Subject: ActivePython 2.0 Release References: Message-ID: <%84I5.366330$1h3.9686065@news20.bellglobal.com> I believe it is analogous to saying "What's so special about RedHat (or Mandrake, Debian, etc..) if I can download and build my own Linux?" It's all about packaging & distribution and I think ActiveState is on the right track. -- ---------------------------------------------------------------------- Olivier A. Dagenais - Software Architect and Developer "Someone called 'Type your name here' is impersonating me on the internet and is posting exactly the same things I am posting!" "Paul Prescod" wrote in message news:mailman.972079615.3589.python-list at python.org... > Before I start to describe the benefits of the ActivePython 2.0 > installation for windows, I'd like to make the point that as far as I > know, ActiveState is the first source for Python 2.0 binaries for > Solaris, > and Debian Linux (in addition to the more mainstream Windows and RPM > installations). Quality assured cross-platform distributions are a big > part of our mission. So looking only at the Windows installer does not > give the whole picture. > > Q. How does ActivePython benefit the Windows user? > > We strove to make ActivePython the easiest way to > get started with Python 2.0. It is certainly possible to download most > parts of the ActivePython product from various sites: > > * Python 2.0 core > * PythonWin environment > * Win32 APIs > * TKinter > * Indexed HTMLHelp versions of Python documentation > > If you are a Python expert and you know what you want and where to get > it, then ActivePython may not be of interest to you. On the other hand, > when you wish to distribute a program with dependencies on these various > packages you may want to point your customers at ActiveState's > distribution rather than at various download sites. > > In addition to the major advantages of multi-platform support and ease > of > installation, ActivePython is expected to be the first of many > ActiveState > Python-world products. We look forward to being able to point our > customers at a family of quality assured, cross-platform distributions > rather than multiple parts for multiple operating systems. Also, we are > not bound by anyone else's release schedule so we can release newer > versions on an accelerated schedule when we feel that will benefit our > customers. > > Q. Why use the Microsoft Installer (MSI)? > > My opinion is that an operating system should come with a standard > installation engine rather than having it bundled in each executable > distribution. This allows much safer and cleaner uninstallation and > dependency tracking because the operating system knows everything that > is going on. In my personal opinion, Microsoft, Red Hat, Debian etc. > have finally gotten this right. It is unfortunate that older versions of > Windows do not come with MSI. Even if we had Guido's time machine I > don't think we could correct that situation. I've railed against the > Windows installer situation for about a decade and it didn't have any > effect the first time! > > Q. How does ActivePython differ from PythonLabs in terms of > "standard-ness"? > > We have one minor bug fix and miscellaneous changes to the build system > and documentation to reflect our alternate documentation delivery > format. > The primary reason that there are so few differences is because > ActiveState contributes our improvements to the Python core to the > Python > development team. That ensures that we remain standard and everybody > benefits from our work. > > Q. What's in the package? > > ActivePython ships with TKinter and IDLE but not TK. This keeps our file > size down. IDLE is not in the start menu because it depends on TKinter > and > anyway it would be somewhat confusing for us to suggest two development > environments for the same product. > > We are certainly interested in feedback on our choice of extensions to > include and exclude. This is especially true of the GUI world where > there are many different libraries competing for support. > > ActivePython-Feedback at activestate.com is the best place to voice these > opinions because it is connected to our bug and feature request tracking > systems. > > Q. Why doesn't the license allow redistribution? > > ActiveState's license does not allow redistribution without contacting > us. Anyone who has created, tested and supported multiple platform > installations knows that this is a large effort and ActiveState depends > upon the publicity that accrues from having people download from our > site. This also helps us to quickly take obsolete versions (especially > betas) out of circulation and to ensure that our customers have the code > we expect them to have. > > Q. What does ActivePython contribute to the Python world? > > Guido has stated on various occasions that he hoped that multiple Python > distributions would arise and thrive. Out of the box, ActivePython is an > excellent platform for developing Windows, Linux or Solaris > applications. Those who are new to Python world and want to get up and > running, with lets say COM or MFC programming quickly and easily now > have a choice that gets them there. Choice is good. > > Also, not every ActiveState product will be groundbreaking and > revolutionary. Some are incremental improvements. Nevertheless, we have > announced many products that will take Python places it has never been > before and ActivePython is a part of that strategy. > > Paul Prescod > ActiveState Tool Corp. > From aleaxit at yahoo.com Mon Oct 30 14:41:35 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 30 Oct 2000 20:41:35 +0100 Subject: destructors order not guaranteed? References: <39FDBC9E.5030204@netscape.com> Message-ID: <8tkj6o05dm@news1.newsguy.com> "Gagan Saksena" wrote in message news:39FDBC9E.5030204 at netscape.com... > I was exploring the possibility of writing excursion classes in Python What's an excursion class? > but was disappointed to learn that the destructors order didn't seem to > be consistent. Here is a minimal case to show this anomaly-- Local namespaces, and global (module) namespaces, do indeed obey different rules regarding the order in which their entries are removed. Further, I do not believe that order is something you can rely upon, anyway. Consider a "global namespace". It is, in fact, a dictionary. When the dictionary itself (i.e., the namespace) is gone, it will 'decref' (decrement the reference count of) its entries in some order -- but that order is probably going to be the one of the dictionary keys ("variable names") themselves. *and the order of dictionary keys is clearly documented to be arbitrary and NOT to be relied upon*... a consequence of the use of hashing for dictionaries (which is required for speed reasons). So, the order in which the variables are removed may well turn out to be platform-dependent, to depend on what _other_ variables are around, whatever; definitely *NOT* something you can rely on in any way. If you *do* need to impose an order, "object X _must_ not be deleted before object _Y_" -- it's easy: just add to object _Y_ an attribute which refers to object _X_! As soon as object _Y_ is alive, you can thus be sure that object _X_ will be alive too. If both are destroyed, it *WILL* assuredly be in the order: Y first, X later. Doing it for an arbitrary grouping of objects (i.e., all the instances of a given class) is trickier. Basically I think this is one of the many tricky system level things that you cannot do without *weak references*, references that will let you indicate a given object *as long as that given object exists*, but *will go away if that object disappears, rather than keeping it alive*. Those are not built-in in Python, you have to supply them separately. See, e.g.: http://www.faqts.com/knowledge-base/view.phtml/aid/4484/fid/538/lang/ (though the link to the critical 'refhack' module it needs seems broken, sigh). Alex From hinsen at cnrs-orleans.fr Thu Oct 26 08:55:29 2000 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 26 Oct 2000 14:55:29 +0200 Subject: [Numpy-discussion] ? References: Message-ID: boncelet at udel.edu@SMTP at python.org writes: > > are used to. Which means they expect 2/3 to be a reasonable > > approximation to its true (rational) value, accepting roundoff > > problems. > > This is undoubtably correct. > > But (donning my contrarian hat), while appealing to newcomers > is a laudable goal, Python will die if it does not appeal to serious > programmers writing serious code. The CS world is littered with > dead teaching languages (anyone remember PLC?). IMHO, the > right question to ask is "what do serious programmers want?" Making the bold claim to be a serious programmer, I'd say they want to be able to specify either integer or float division, but they don't care about the precise syntax, as long as both are straightforward to do. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From glyph at no.spam Mon Oct 23 01:44:31 2000 From: glyph at no.spam (Glyph Lefkowitz) Date: 23 Oct 2000 00:44:31 -0500 Subject: Python Formatted C Converter (PfCC) References: Message-ID: "Alex McHale" writes: > The project is, as I call it, a Python Formatted C Converter. What this > means, is that it takes a python-style coded C program and converts it into > compilable C code. For example, consider this bastardized looking simple > program below: I have actually had very similiar ideas myself :) however, the project I'm working on (still in its infantile stages; I basically have 'struct' working and nothing else) is not just to make a translator, but to write a new language which allows C to be interfaced with other languages. The basic idea is to create a parser (not a preprocessor) which will have most of the functionality of C built-in, then develop extensions which can interface with other object-models available in C. The "compiler" (which generates C, C++, or Objective C code) is a type-oriented language. There would be built-in type-oriented polymorphism, and an overloadable "." operator, making an explicit distinction between run-time and compile-time dispatch. Basically it's going to be a playground for certain theories I have about object-orientation and high-level languages. However, I have to agree with the other posters in that writing *JUST* a preprocessor is a bad idea. At least make your preprocessor smart enough that it'll spot errors in the code before it opts to generate the C; there are few things more annoying than figuring out why the code will generate OK, but the *generated* code won't compile. (Also, there's the fact that C's syntax is actually pretty good for doing what C does) -- Glyph Lefkowitz Professional -- Software Engineer, Origin Systems Amateur -- Computer Scientist, Twisted Matrix Enterprises (My opinions are my own and do not reflect in any way on the policies or practices of my employer, etcetera etcetera.) From paulp at ActiveState.com Wed Oct 25 17:19:18 2000 From: paulp at ActiveState.com (Paul Prescod) Date: Wed, 25 Oct 2000 14:19:18 -0700 Subject: XML DOM to JavaScript References: <39F70001.C4B173A9@yahoo.com> Message-ID: <39F74E56.461A4ACA@activestate.com> OlavB at yahoo.com wrote: > > ... > In ColdFusion there is > this WDDX framework which converts the CFML DOM > to Javacript statements which generates a > similar structure in JavaScript. > (WDDX seems to be intended as a standard for > this kind of things, but I haven't found any > references to WDDX and Python) This should help: http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/xml/xml/marshal/wddx.py?cvsroot=pyxml I don't know how much use (i.e. testing) it has received so you may need to tweak it. Also, you could generate Javascript from Python using standard string processing and XML processing techniques. For instance, walk the DOM, going from each node to its children nodes, generating a big long string and then write it to a file. Paul Prescod From jh at web.de Thu Oct 26 15:14:56 2000 From: jh at web.de (Jürgen Hermann) Date: Thu, 26 Oct 2000 21:14:56 +0200 Subject: [ANN] MoinMoin Release 0.3 Message-ID: <8t9vpt$o94$02$1@news.t-online.com> A WikiWikiWeb is a collaborative hypertext environment, with an emphasis on easy access to and modification of information. MoinMoin is a Python WikiClone that allows you to easily set up your own wiki, only requiring a Web server and a Python installation. MoinMoin 0.3 features free-formatted WikiNames (which means you can have Japanese page names for example), a [[SystemInfo]] macro, inline code sequences, some usability enhancements, and quite some bugfixes. It is also tested with Python 1.6 and Python 2.0. Homepage: http://moin.sourceforge.net/ Download: http://download.sourceforge.net/moin/ New features: * Check for inline images with InterWiki links (Spam:eggs.gif) * New config variable "allow_extended_names", which enables markup for wiki names containing ANY character like this: ["any chars"] * New config variable "html_head" * New macro [[SystemInfo]] * Added inline code ("{{{" and "}}}" on the same line) * Support for new config variable "max_macro_size" Bugfixes: * Don't treat sequences with a double colon (CPP::Namespace) as an InterWiki link * The local part of InterWiki links is now correctly URL-escaped * Quickfix for a bug in 1.6's regular expressions * Fixed "SpamSpamSpam" bug (multiple entries in word list) * Anchor names get quoted in WordIndex and TitleIndex * Filtering of filenames in page_list() corrected * Escape &, <, > when sending the editor * Final(?) fix for japanese wiki names From sdm7g at virginia.edu Sun Oct 8 22:06:51 2000 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Sun, 8 Oct 2000 22:06:51 -0400 (EDT) Subject: Pyton on MacOS X is a link away ... In-Reply-To: Message-ID: I've done about a dozen builds of 2.0b2 trying to find the "right" way. I haven't tried 1.6 at all. Hey -- It's a BETA OPERATING SYSTEM -- why are you afraid of using a beta Python distribution? ;-) Nothing works right out of the box at the moment (and I'm not sure that anything even works exactly the same way twice! ) Currently, I'm building 2.0b2 with Tony Lownds patches at: http://tony.lownds.com/macosx/ ( Tony's patches don't seem to fix all of the build problems, but it tries to fix some of the broken Next stuff in the Makefile that'll make it impossible to 'make install' otherwise. ) configure --with-dyld --with-suffix=.x ( and maybe or maybe not --with-next-framework ) edit Setup to enable shared libraries but move the fcntlmodule line to before the *shared* enable. ( to avoid case-blind conflict between FCNTL.py and fcntlmodule.so ) [ test/test_fcntl will still fail unless you add 'darwin1.2' to the if test along with the other BSD's -- otherwise it falls thru to the default and tests with the wrong args. ] adding two more options that don't seem to get set right via the shell: OTHER_LIBTOOL_OPT="-lcc_dynamic -undefined warning" make configure will say that the compiler understands "-OPT:Olimit=0", but the compiler will complain about it for each file. configure will figure out that it supports posix threads and define _POSIX_THREADS in config.h, but since it's already defined in some system header somewhere, it'll complain about redefinition unless you comment out the extra one in config.h The deeper I dig into configure and Makefile.in, the more lost I get! ( The next specific stuff is, if not completely broken, at least seriously confusing! ) ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- "All operating systems want to be unix, All programming languages want to be lisp." From keisari_ at hotmail.com Fri Oct 27 05:15:01 2000 From: keisari_ at hotmail.com (joonas) Date: Fri, 27 Oct 2000 12:15:01 +0300 Subject: Solved References: <39F83ED4.57ADB649@hotmail.com> <39F86026.D65F0CB7@hotmail.com> <39F873C9.B7C96FC1@holdenweb.com> <1L_J5.2993$jv2.337201@newsc.telia.net> <39F88034.2F13AC5D@hotmail.com> Message-ID: <39F94795.16E23866@hotmail.com> I solved the problem by asking in a Blender group. first.val - second.val Joonas. Kalle Svensson wrote: > > On Thu, 26 Oct 2000, joonas wrote: > > > Btw i am not using Tkinter. > > I am using Blender, that is a 3d modelling software. > > > > I tried > > "speedgear.text = str(int(first.text) - 10)" > > and it gave me error,"name error text". > > > > Then i removed ".text" from objects and it gave me "object cant be > > converted to int". > > Ok, this is the situation. You have a button, which when it is stringified > (through str(button), print button, button.__str__() or whatever) > yields a string of digits. > int(a_string) makes an integer from a string of digits. > > Thus, perhaps you could use > int(str(first)) - int(str(second)) > to get the difference between the integers represented by the buttons? > > Yuck. > > HTH, > Kalle > -- > Email: kalle at gnupung.net | You can tune a filesystem, but you > Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) > Not signed due to logistical difficulties (I'm not at home). > If you doubt the authenticity of this message, please tell me. From fcarniel at freesurf.fr Mon Oct 30 05:00:40 2000 From: fcarniel at freesurf.fr (carniel) Date: Mon, 30 Oct 2000 11:00:40 +0100 Subject: Comparaison on GUI toolkit on python Message-ID: <8tjg8j$26sa$1@spartacus.freesurf.fr> I have a big multi plate forme (linux, mac, win) application to write. My criter is : rapidity, i need tree, table, frame, popup menu widget, and a graphic designer Actually i am looking wxWindows , qtPython, TK. Do you know other solution ? Where can i find a comparaison? Is this tool inproved ? where can i find some Designed, and Programming editor dedicate to python ? Thank you for you information? PS: Excuse me if this question is already asked in this groupe i fall in love with python, but it new for me From mfletch at tpresence.com Sun Oct 29 00:51:46 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Sun, 29 Oct 2000 00:51:46 -0400 Subject: Howto find same files? Message-ID: Here's a possibility: use os.path.walk to process each file in the tree of directories, with a dictionary shared as the arguments (see os.path.walk docs) for each file create a 5 or 6 element tuple with the "identifying" info, see the os, stat, and possibly sha/md5 modules. if the tuple is already a key in the dictionary: delete the current file, print a message to the console telling you that the duplicate was found. Print the name of the current file and the value associated with the key in the dictionary (see next step for what that will be). else: add a tuple:full_filename key to the dictionary Now, of course, with hundreds of thousands of files, that may take a while to run, but if it turns out to work for you, then hey, you're done and can go on to the next project. Enjoy yourself, Mike -----Original Message----- From: gregoire.favre at ima.unil.ch [mailto:gregoire.favre at ima.unil.ch] Sent: Saturday, October 28, 2000 5:16 PM To: python-list at python.org Subject: Howto find same files? Hello, two friends tell me that I should go to python to solve my problem: I have fetched some files (quite a lots) that I have put in /data (a lots of patchxxx.{gz,bz2} of lots of things, lots of midi files grabbed from newsgroups using newsfetch, some mp3,... too much files that I have put in some dirs (just for having one idea, >find /data|wc -l gives me 128291... that's too much for hand...). What I want to do is to find the files that are the same, a good start could be the files which have same name and same size, better would be to find files that are same size (I have for examples a lot of 1.mid...) and then do a kind of diff between then and if there are the same, rm the copies). I have read half of the python tutorials and I don't know how to begin... Would it be a good idea to create a files which contains the path,filename,size,md5sum and then working on it? Has someone another idea or as someone already programmed that? Thanks you very much, Greg Sent via Deja.com http://www.deja.com/ Before you buy. -- http://www.python.org/mailman/listinfo/python-list From effbot at telia.com Tue Oct 17 12:58:36 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 17 Oct 2000 16:58:36 GMT Subject: Checking whether an object has been created. References: <39EC83BC.797424B0@vibes.net> Message-ID: <0z%G5.1576$QH2.103864@newsb.telia.net> Olivier CARRERE wrote: > has anyone a clean method to check if an object has been instanciated? > > What I wish to do is to create an object if it hasn't been made before, > ie something like this : > > if not exists(objectReference): > objectReference=Object() > # perform stuff on objectReference objectReference = None ... if objectReference is None: objectReference = Object() ... From tim_one at email.msn.com Fri Oct 27 20:12:05 2000 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 27 Oct 2000 20:12:05 -0400 Subject: 64-bit ints <-> PyLongs? In-Reply-To: <20001026085748.C16027@ActiveState.com> Message-ID: [Kalle Svensson] > I'm writing a wrapper around a C library where some functions return, > or expect as arguments, 64-bit ints. Will PyLong_*LongLong work on > win32 (and preferably Mac too), and is LONG_LONG guaranteed to > be at least 64 bits. [Trent Mick] > ... > I am not sure if LONG_LONG is guaranteed to be 64-bits but I am > pretty sure that that is a safe assumption (Tim Peters will probably > correct me on that). I won't let anyone sneak code into Python that defines LONG_LONG to something *smaller* than 64 bits, so, ya, you can count on that much. Except: > The problem is not every platform will HAVE_LONG_LONG (though, again, > most common ones do). Aye, that's the rub. C89 doesn't guarantee that any integral type is available that wide. C99 does, though, so the few compilers that don't already play along will eventually die out. Note that C99 does not guarantee that any integral type has *exactly* 64 bits -- I really meant "smaller than" above. Luckily, that's what Kalle was asking about. Note that pyport.h will eventually grow typedefs (named after the C99 typedefs, but with "Py" at the start) for concepts like "signed integral type at least 64 bits wide". And so LONG_LONG will eventually be purged from the codebase in favor of those. if-i-had-a-free-second-i'd-do-that-right-now-instead-of-finishing- this-stupid-signoff-ly y'rs - tim From hei at adtranzsig.de Wed Oct 11 03:51:36 2000 From: hei at adtranzsig.de (Dirk-Ulrich Heise) Date: Wed, 11 Oct 2000 09:51:36 +0200 Subject: Request for Python Source Code References: Message-ID: <8s162e$i2d$1@desig-bs01-s04.adtranzsig.de> "Dave Brueck" schrieb im Newsbeitrag news:mailman.971190983.20602.python-list at python.org... > >I suppose (this is just an assumption) that Simoney invented it > >in the 70ies when writing assembler code. There, it might make sense > >to prefix a name of a variable with a type prefix. > >It doesn't make much sense from C upwards. > > Really? It's probably _most_ useful in a language like C where the > programmer is allowed to abuse data types at will, sometimes without so much > as a warning from the compiler. Because it's largely the programmer's > responsibility to keep track of whether something is an int or a pointer, > for example, having that information contained in the variable name can be > pretty handy. Funny. The compilers i use can distinguish between an int and a pointer. You're sure we talk about the same language? -- Dipl.Inform. Dirk-Ulrich Heise hei at adtranzsig.de dheise at debitel.net From gregj at pobox.com Mon Oct 2 06:55:56 2000 From: gregj at pobox.com (Greg Jorgensen) Date: Mon, 02 Oct 2000 10:55:56 GMT Subject: re module: findall erroneously remembering matches from previous groups? Message-ID: <0RZB5.136047$Ur3.1820143@news1.sttls1.wa.home.com> I'm using Python 1.6. >>> s = 'The {speed|quick|slow} brown {animal} jumps over the {z|lazy} dogs back.' >>> p = r'\{(.*?)(?:\|(.*?)(?:\|(.*?))?)?\}' >>> pat = re.compile(p) The pattern p matches occurences of: {aaa} or {aaa|xxx} or {aaa|xxx|yyy} In other words, aaa may be followed by |xxx or |xxx|yyy. The entire pattern must be enclosed in {...}. >>> pat.findall(s) [('speed', 'quick', 'slow'), ('animal', 'quick', 'slow'), ('z', 'lazy', 'slow')] I expected the second tuple to be ('animal', None, None), and the third tuple to be ('z', 'lazy', None). If I use search instead I get the expected results: >>> m = pat.search(s, 0) >>> m.groups() ('speed', 'quick', 'slow') >>> m = pat.search(s, m.end()) >>> m.groups() ('animal', None, None) >>> m = pat.search(s, m.end()) >>> m.groups() ('z', 'lazy', None) So is this a bug in findall(), or is this how it is supposed to work? I expected findall() to return the same list I'd get from this code: >>> def findall(pat, s): f = [] i = 0 while 1: m = pat.search(s, i) if not m: break f.append(m.groups()) i = m.end() return f >>> findall(pat, s) [('speed', 'quick', 'slow'), ('animal', None, None), ('z', 'lazy', None)] I haven't looked at the source for the re module yet... I am hoping that someone has seen this before. Thanks. Greg Jorgensen Deschooling Society Portland, Oregon, USA gregj at pobox.com From Gareth.McCaughan at pobox.com Sun Oct 29 14:43:30 2000 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Sun, 29 Oct 2000 19:43:30 +0000 Subject: C's syntax (was Re: Python Formatted C Converter (PfCC)) References: <8t0or303ee@news1.newsguy.com> <39F4FFB7.452EDDEC@alcyone.com> <8t3mdv025uo@news2.newsguy.com> <39F5B404.B5626FB7@alcyone.com> <8t4q8v11lpv@news1.newsguy.com> <39F5E620.C780A71C@seebelow.org> <8t6vj70spd@news1.newsguy.com> <39F73E41.C8EE143F@seebelow.org> <8t8sgn0ahc@news1.newsguy.com> <39F8985B.6909B5CF@seebelow.org> <8tbv0r01082@news1.newsguy.com> <39FB2080.D38CAD35@seebelow.org> Message-ID: Grant Griffin wrote: > If you speak true words of wisdom on some subject, the words stand on > their own. OTOH, no amount of assurance that you are an expert at a > subject is convincing, if the expertise you lend is not convincing in > itself. In other words, bragging doesn't help, and it probably actually > hurts your credibility. If someone says "Only those who don't like C criticize its syntax" and he replies by explaining that he uses C a *lot* and is happy to do so even though he dislikes the syntax, that seems entirely relevant. -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construc From lspakfasdf at www.dsic.com.tw Fri Oct 27 16:47:10 2000 From: lspakfasdf at www.dsic.com.tw (lspakfasdf at www.dsic.com.tw) Date: Fri, 27 Oct 2000 16:47:10 Subject: (no subject) Message-ID: <809.262262.619540@mail.mindspring.com> GET YOUR OWN 100 MEG WEBSITE FOR ONLY $11.95 PER MONTH TODAY! STOP PAYING $19.95 or more TODAY for your web site, WHEN YOU CAN GET ONE FOR ONLY $11.95 PER MONTH! DO YOU ALREADY HAVE A WEBSITE? ALL YOU HAVE TO DO IS TRANSFER THE DOMAIN TO OUR SERVERS AND UPLOAD YOUR DATA AND YOU ARE READY TO GO! YOUR NEW WEB SPACE CAN BE CREATED INSTANTLY WITH JUST A SIMPLE PHONE CALL TO OUR OFFICE. YOU CAN CHANGE THE DESIGN OF YOUR SITE AS MUCH AS YOU WANT with no extra charge! UNLIMITED TRAFFIC -- no extra charge! FRONT PAGE EXTENSIONS are FULLY SUPPORTED. A SET UP FEE OF $40.00 APPLIES for FIRST TIME CUSTOMERS. ALL FEES PREPAID IN ADVANCE FOR THE YEAR PLUS A $40.00 SET UP CHARGE. FOR DETAILS CALL 1 888 248 0765 if you are outside the USA, please fax 240 337 8325 Webhosting International From sholden at holdenweb.com Thu Oct 26 22:53:01 2000 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 26 Oct 2000 22:53:01 -0400 Subject: Is global really global. References: <39F8E1A1.C3F4E87A@holdenweb.com> Message-ID: <39F8EE0D.5DDDE80F@holdenweb.com> Steve Holden wrote: > ... > So options is global _to module main_. Where he should have written: So options is global _to module Peaks_. and apologises accordingly. -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ From hove at phys.ntnu.no Fri Oct 13 13:52:37 2000 From: hove at phys.ntnu.no (Joakim Hove) Date: 13 Oct 2000 19:52:37 +0200 Subject: File tests in Python Message-ID: Hello, I have just bought "Learning Python" by Mark Lutz and David Ascher, and browsed quickly through it. I like both the book and my first impression of Python very good. Previously I have used Perl quite a lot - but I never really got the hang of more "complex" datastructures in Perl. Writing List = [1,2,["List","in","List"]] in Python is just the way it _should_ be, really nice! However, there are two (at least right now) things I have enjoyed in Perl which I have not found equivalents of in Python. First Perl has an assorted set of file-test like this: $file = "myfile"; if (-x $file) { print "The file \"$file\" is executable \n"; } else { print "Sorry - can't run \"$file\" \n"; } How would I do this and related (is a directory/symbolic link/binary/..) tests in Python? Secondly a correct Perl-installation comes with a very neat program called perldoc - which is used to access the Perl documentation. Typing for instance: bash% perldoc -f localtime gives you the documentation for the localtime() function - very convenient! I know this is not a property of Perl - the programming language, but nevertheless, do I have access to something like this from python? [Standard Linux install of Python - using emacs as editor]. Joakim Hove -- === Joakim Hove www.phys.ntnu.no/~hove/ ====================== # Institutt for fysikk (735) 93637 / E3-166 | Sk?yensgate 10D # # N - 7491 Trondheim hove at phys.ntnu.no | N - 7030 Trondheim # ================================================ 73 93 31 68 ======== From aleaxit at yahoo.com Fri Oct 13 06:07:56 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 13 Oct 2000 12:07:56 +0200 Subject: Programmer-Wanna-Be (Is Python for me?) References: <8s2354$ep2$1@nnrp1.deja.com> <8s5b2h$73f$1@nnrp1.deja.com> Message-ID: <8s6n8202avb@news1.newsguy.com> wrote in message news:8s5b2h$73f$1 at nnrp1.deja.com... [snip] > I do have two more questions now (derived from previous replies). In > simple terms: 1)What is Boa Constructor? and 2)What is wxPython? > Should I be looking in to these? Are these for later on? (1) "Boa Constructor" is a visual-design tool for Python GUIs that use wxPython. (2) wxPython is a GUI toolkit that is a Python way to access the excellent wxWindows C++ GUI toolkit (currently portable between Unix/Linux flavors and Windows flavors, with Mac, BeOpen, &tc in the making AFAIK). I do believe that wxWindows/wxPython are excellent GUI toolkits, and Boa Constructor potentially a great way to build wxPython GUI's - but, yes, I don't think you need to worry about them right now. When learning carpentry from scratch, it's IMHO better to start by understanding wood, types of wood, wood working tools, and so on; how you, specifically, can _finish_ the external surfaces of wood artifacts, and what tools and auxiliary materials (including paint-types), you can use for that very specialized purpose, seems to me something that might be better left for a later stage of your initiation to the noble and ancient art of carpentry. No doubt, for many wooden artifacts, the exterior surfaces, with their finishing, are a key part of the "user experience" -- but 90% of the carpenter's art has to do with the *structure* that is behind those well finished surfaces (if they're present at all -- not a few wooden artifacts present no finished surfaces to the end-user, being actually embedded in other, larger artifacts, in which they play a purely structural role)... Alex From sdm7g at virginia.edu Fri Oct 27 11:17:47 2000 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Fri, 27 Oct 2000 11:17:47 -0400 (EDT) Subject: Python scoping In-Reply-To: <39F8B042.4F0558E5@simplyweb.net> Message-ID: On Thu, 26 Oct 2000, Michael Ackerman wrote: > "Steven D. Majewski" wrote: > > > > On Tue, 24 Oct 2000, Joshua Muskovitz wrote: > > > . > > A situation where the human eye uses indentation and the compiler > > uses braces is unsafe. > > Why is it unsafe? Doesn't it work well in Haskell? > Doesn't Haskell use the "offside rule" like Python, and make the compiler follow the same rules as the human eye ? ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- "All operating systems want to be unix, All programming languages want to be lisp." From hinsen at dirac.cnrs-orleans.fr Thu Oct 12 13:24:18 2000 From: hinsen at dirac.cnrs-orleans.fr (hinsen at dirac.cnrs-orleans.fr) Date: Thu, 12 Oct 2000 19:24:18 +0200 Subject: [Python-Dev] RE: [Numpy-discussion] RE: Possible bug (was Re: numpy, overflow, inf, ieee, and rich comparison) In-Reply-To: (sdm7g@virginia.edu) References: Message-ID: <200010121724.TAA15487@chinon.cnrs-orleans.fr> > The idea that your calculation should blow up and you should > check it and resubmit your job sounds just so ancient-20th-century- > Fortran-JCL-and-punched-cards-technology! Long-running jobs are still with us, even there's neither Fortran nor JCL in them. And for these applications, stopping is better than going on with nonsense values. On the other hand, as you point out, exceptions for math errors are a bit of a pain for interactive work. So how about making this a run-time option? I'd choose exceptions by default and Infs and Nans by specifying a command-line option, but there are certainly others who would prefer it the other way round. What matters most to me is that the choice is possible somehow. Konrad. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From sjuranic at condor.ee.washington.edu Fri Oct 13 13:54:07 2000 From: sjuranic at condor.ee.washington.edu (Steve Juranich) Date: Fri, 13 Oct 2000 10:54:07 -0700 Subject: C macros in Python. Message-ID: I was just wondering if there was anything available in Python like the __FILE__ and __LINE__ macros in C. I know about the __name__ attribute, but I'm not sure that does exactly what I'm looking to do. What I'd like to do is write some code that will tell me _exactly_ on which file and while line things went wrong. Thanks for the help. ---------------------------------------------------------------------- Stephen W. Juranich sjuranic at ee.washington.edu Electrical Engineering http://students.washington.edu/sjuranic University of Washington http://rcs.ee.washington.edu/ssli From boncelet at udel.edu Mon Oct 23 15:09:44 2000 From: boncelet at udel.edu (Charles Boncelet) Date: Mon, 23 Oct 2000 15:09:44 -0400 Subject: Python on the iPAQ References: <8sb2f2$hns$1@nnrp1.deja.com> Message-ID: <39F48CF8.D80F9169@udel.edu> edwardam at home.com wrote: > I just wanted to toot my own horn for a minute and mention that python > is now available for the Compaq iPAQ running under Linux from > www.handhelds.org. This is really a fun looking project and I'd even consider trying it on my IPAQ. That is, if I had my IPAQ. It's been backordered for months with no clear end in sight. Any chance python will work in the IPAQ under WinCE? Just curious. -- Charles Boncelet 302-831-8008 Dept of Electrical and Computer Engineering 302-831-4316 (fax) University of Delaware boncelet at eecis.udel.edu http://www.eecis.udel.edu/~boncelet/ From the_brain at mit.edu Sun Oct 29 13:26:02 2000 From: the_brain at mit.edu (Alex) Date: 29 Oct 2000 13:26:02 -0500 Subject: Backwards searching for regexps? Message-ID: Is there any way to search a string backwards from its end for a regexp, or will I have to roll my own? If not, is there a provision for this in the underlying C code that is not reflected in the python re module? Alex. -- Speak softly but carry a big carrot. From youngcho_sd at my-deja.com Mon Oct 30 11:58:07 2000 From: youngcho_sd at my-deja.com (youngcho_sd at my-deja.com) Date: Mon, 30 Oct 2000 16:58:07 GMT Subject: In memory persistence - used as CGI Message-ID: <8tk9aq$p80$1@nnrp1.deja.com> I'm using Python as a CGI language (for use both in MS IIS & Linux Apache). Is there a mechanism for in-memory persistence of data for use by different HTTP requests to different Python CGI pages? Specifically, I'm looking for something similar to an Application() variable in MS IIS 4. Thanks in advance... Young youngcho at alumni.ucsd.edu Sent via Deja.com http://www.deja.com/ Before you buy. From josh at open.com Tue Oct 24 20:39:23 2000 From: josh at open.com (Joshua Muskovitz) Date: Tue, 24 Oct 2000 20:39:23 -0400 Subject: How do I force a single instance of a python app? References: <39f5e46f_3@corp.newsfeeds.com> <8t54f9$9r4$1@drmanhattan.kryogenix.org> Message-ID: <39f62a22_4@corp.newsfeeds.com> A UDP listener (or an ICMP listener maybe) might work -- ICMP avoids the one-listener-per-port restriction, but then they have to puzzle out which one came first... :-) This unfortunately won't work for me as I'm trying to avoid sockets for reasons I won't go into. The file hack, which writes a timestamp to the file is a very interesting idea. This could possibly be simplified to simply deleting and creating the file and using the OS to find the file's timestamp, but this will probably annoy NT which doesn't like lots of temp files, and tends to fragment because of it. A file which contained a timestamp and a pid will probably do the trick. I can live with the dead zone (the period of time between file updates) -- the process doesn't have to restart immediately. Also, I was reading in the FAQ today that there is a way to trap when a python app is ending -- I can delete the file at that point to reduce the dead zone delay when the app behaves well. Thanks for the suggestions! -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From jhauser at ifm.uni-kiel.de Tue Oct 17 15:50:45 2000 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 17 Oct 2000 21:50:45 +0200 Subject: Compilation question References: <39EC7B07.A99DC481@level3.net> Message-ID: <873dhv8cx6.fsf@ifm.uni-kiel.de> You need to enable the readline module. Look for this into the file Setup in the Modules subdir of the source tree. If there is no Setup copy Setup.in to Setup in the same subdir and edit this. HTH, __Janko -- Institut fuer Meereskunde phone: 49-431-597 3989 Dept. Theoretical Oceanography fax : 49-431-565876 Duesternbrooker Weg 20 email: jhauser at ifm.uni-kiel.de 24105 Kiel, Germany From jackxh at my-deja.com Sat Oct 28 04:22:43 2000 From: jackxh at my-deja.com (jackxh at my-deja.com) Date: Sat, 28 Oct 2000 08:22:43 GMT Subject: Would anyone show me how to use htmllib? Message-ID: <8te2ch$8ou$1@nnrp1.deja.com> Hi I have read the python library reference. I am a python newbe, I think I have to overload some functions to get it working. Could anyone give to a example to show me how it works? Thanks Jack Xie Sent via Deja.com http://www.deja.com/ Before you buy. From aleaxit at yahoo.com Mon Oct 23 07:23:29 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 23 Oct 2000 13:23:29 +0200 Subject: win32all build 135 -- where? Message-ID: <8t17d90i38@news1.newsguy.com> ActiveState Python 2, including win32all build 135, has been out for days, but still I can't find said build 135 by itself anywhere. E.g., http://www.activestate.com/Products/ActivePython/win32all.html still lists only builds 132, 133, and 134. Any URLs will be welcome, thanks! Alex From klitzing at Pool.Informatik.RWTH-Aachen.DE Fri Oct 6 16:07:06 2000 From: klitzing at Pool.Informatik.RWTH-Aachen.DE (Philipp von Klitzing) Date: Fri, 6 Oct 2000 22:07:06 +0200 Subject: MySQLdb Win32 binary? Message-ID: <39DE4D0A.13924.226039F@localhost> Hi there, the subject pretty much says it: I am looking for a Win32 build of MySQLdb, preferably for Python 1.52 - is there anyone out there that could help me with this? Unfortunately I don't have access to a Windows C compiler. It'd be great if any reaction were sent e-mail to this address - thanks! Beste Gruesse, Philipp From bob at wildthink.com Thu Oct 12 09:34:51 2000 From: bob at wildthink.com (Robert Hicks) Date: Thu, 12 Oct 2000 13:34:51 GMT Subject: Python for Mac OS X? References: <39E4F04F.C760D01C@earthlink.net> Message-ID: Just keep watching here. Someone is in the build process now and working out the kinks. > From: Robert Biggs > Organization: EarthLink Inc. -- http://www.EarthLink.net > Newsgroups: comp.lang.python > Date: Wed, 11 Oct 2000 23:00:40 GMT > Subject: Python for Mac OS X? > > Where might I find a version of Python that would work on the recently > released Mac OS X Public Beta? It's Apple's new OS based on BSD. > > budncal at earthlink.net > From claird at starbase.neosoft.com Sat Oct 7 21:20:54 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 7 Oct 2000 20:20:54 -0500 Subject: future of Python: Stackless, Standard -> fragmentation ? References: <8rk7e5$47u$1@oslo-nntp.eunet.no> <39DF1E75.5589C2D7@seebelow.org> Message-ID: <8D0360D4F2D68681.273CE8B348024E73.C27F6DA30D1BA29E@lp.airnews.net> In article <39DF1E75.5589C2D7 at seebelow.org>, Grant Griffin wrote: . . . >That was very interesting, and it makes good sense. But I guess the >thing that confuses me, in that context, is the assertion I have read >that Stackless is 100% backwards compatible with CPython. Is the >"irreconcilable difference", then, in terms of the _new_ features or >capabilities that Stackless adds? If so, JPython programmers presumably >could happily continue to do without them, in the same way that CPython >programmers currently do; only programs that rely on the new features >would be incompatible with JPython. . . . Yes. In fact, parodists have occasionally sketched the "is Stackless fit for the core distribution?" counterargument as, "oh, sure, it's fine, until people start *using* its capabilities." The pro- Stackless crowd frequently talks about it as a pure win at the level of Python programming, because Py- thon is indistinguishable from Stackless Python, except that the latter is better. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From bjorn at roguewave.com Tue Oct 10 14:10:20 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Tue, 10 Oct 2000 12:10:20 -0600 Subject: sizeof? References: Message-ID: <39E35B8C.7FEF6F29@roguewave.com> On a related topic, is there a way to find out how much memory is being used at any given time (from Python). It could be potentially useful for performance optimizations... -- bjorn Remco Gerlich wrote: > > seung-won hwang wrote in comp.lang.python: > > Is there any operator to measure the size of the object in Python > > something like sizeof in C? I couldn't find any from the book > > and documents I have. Thanks! > > There is no way to find the exact number of memory bytes an object uses. > Consider that irrelevant. > > To find the length of a list, or a tuple, or other sequences, use len(). > > Remco Gerlich > -- > http://www.python.org/mailman/listinfo/python-list From kuchler at ajubasolutions.com Tue Oct 3 04:30:13 2000 From: kuchler at ajubasolutions.com (Dan Kuchler) Date: Tue, 03 Oct 2000 01:30:13 -0700 Subject: Events and the Listbox widget References: <39D9EB57.A0382403@inenco.no> Message-ID: <39D99915.3712C337@ajubasolutions.com> Hans Kristian Ruud wrote: > > I have generated a listbox, and wish to extract some information when a > user > clicks on an item: > > list = Listbox(canvas,width=15 ) > list.pack(side=TOP) > list.bind('', chooseSheet) > > def chooseSheet(event): > listbox = event.widget > selected = listbox.curselection() > setCurSheet( selected[0] ) > > My problem is that the list of selected values from > listbox.curselection() > is not updated until after chooseSheet is called, i.e. the function > > listbox.curselection() > > returns the PREVIOUS element that was clicked. > > Originally I had bound the function to root, and then it worked fine, > however > I do not want the function chooseSheet to be executed when I click on > buttons > and such that I have added later. > The problem is the order in which the bindings are getting called. The binding that causes selection to change isn't getting called until after your binding is getting called. This exact same question was answered in comp.lang.tcl just last week. Read Eric Melski's response at: http://x63.deja.com/viewthread.xp?AN=674921495 I hope that helps explain what is going on. --Dan From skip at mojam.com Tue Oct 10 10:27:44 2000 From: skip at mojam.com (Skip Montanaro) Date: Tue, 10 Oct 2000 09:27:44 -0500 (CDT) Subject: Compilation of Python 2.0c1 In-Reply-To: References: Message-ID: <14819.10080.393639.899281@beluga.mojam.com> Fr?d?ric> I've problems with python compilation (be it 1.6 or 2.0c1) on Fr?d?ric> my Mandrake system : the executable python produces a Fr?d?ric> segmentation fault in Modules/getbuildinfo.c, in the sprintf Fr?d?ric> call... according to gdb at least... Worked fine for me. Here's my config: % cat /etc/issue.net Linux Mandrake release 7.1 (helium) Kernel 2.2.16-9mdk on an i686 % gcc -v Reading specs from /usr/lib/gcc-lib/i586-mandrake-linux/2.95.3/specs gcc version 2.95.3 19991030 (prerelease) % rpm -q -a | egrep cc gcc-cpp-2.95.2-7mdk ... I configured with "./configure", compiled using "make OPT=-O3" and ran "make test" with no trouble: ... test_xmllib test_zipfile test_zlib test test_zlib skipped -- No module named zlib 81 tests OK. 25 tests skipped: test_al test_audioop ... -- Skip Montanaro (skip at mojam.com) http://www.mojam.com/ http://www.musi-cal.com/ From shindich at my-deja.com Tue Oct 24 18:27:35 2000 From: shindich at my-deja.com (shindich at my-deja.com) Date: Tue, 24 Oct 2000 22:27:35 GMT Subject: How do I force a single instance of a python app? References: <39f5e46f_3@corp.newsfeeds.com> Message-ID: <8t52ch$ulr$1@nnrp1.deja.com> In article <39f5e46f_3 at corp.newsfeeds.com>, "Joshua Muskovitz" wrote: > I need to prevent multiple copies of a python app from running > simultaneously on a single machine. In Windows and C++, this is done with > sending custom window messages to all top level windows, or using some other > kind of scheme. > > I'm looking for a platform neutral way to do this for my python apps - - the > second instance should somehow detect the first instance and should quietly > kill itself. It does not need to notify the first instance of anything. > Initial target platforms are Solaris and NT, but others will follow, so a > generic solution would be the best. File existence is a bad solution > because the first instance might (possibly) terminate before it could delete > the file. I need a semaphore which will absolutely go away when the first > instance dies, or else a way to reliably probe to see if the first instance > exists on the fly. > > Suggestions gratefully accepted! > > -- josh > > -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- > http://www.newsfeeds.com - The #1 Newsgroup Service in the World! > -----== Over 80,000 Newsgroups - 16 Different Servers! =----- > Using OS specific features like NT mutex is the easiest way to accomplish your goal. The biggest problem here is that different Python processes running on the same machine are not aware of each other. One way to solve your problem OS independently is to use a resource that common to all or most OS as a flag. For instance, you could use a socket or a file to indicate that your app is running. Both of the approaches mentioned above have their problems. The file approach causes problems if you app crashes. In that case there is no telling if the lock file is present because you app is running or because it crashed. Sockets are more reliable that way. But remember to set "KEEP ALIVE" option on your socket, otherwise, depening on your OS' implementation of sockets, you might never find out that the app crashed. (This is usually a problem for DOS and Windows 3.x IP stacks.) Good luck! Sent via Deja.com http://www.deja.com/ Before you buy. From mo at nospam.com Mon Oct 16 19:21:42 2000 From: mo at nospam.com (Mo) Date: Mon, 16 Oct 2000 16:21:42 -0700 Subject: Cross-referencing Python? Indexing program attached References: <39EB880A.172D0B4D@holdenweb.com> Message-ID: <39EB8D86.5B2ACBDD@nospam.com> Steve Holden wrote: > > Does anyone know of a godd cross-referencing program for Python? > A quick search on the web revealed little of relevance. > > To help me in getting to know some substantial chunks of code I > have hacked together (and it *is* a hack) a program which will > provide at least a listing of class, method and function definitions > in many cases. I attach it to see if others might find it useful. > > regards > Steve > -- > Helping people meet their information needs with training and technology. > 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ Steve, you might want to take a look at the recently GPLed Source-Navigator IDE. Python support was recently added by a net contributor. It works for most things but from what I understand it sounds like a bit more work on Xref support is needed. You might want to spend your time improving the Python support in Source-Navigator instead of writing your own from scratch. The project homepage is at: http://sources.redhat.com/sourcenav/ The download is at: ftp://ftp.freesoftware.com/pub/sourceware/sourcenav/releases/SN452.tar.gz Mo DeJong Red Hat Inc From colin at programmedintegration.com Fri Oct 20 16:41:50 2000 From: colin at programmedintegration.com (Colin Meeks) Date: Fri, 20 Oct 2000 20:41:50 GMT Subject: Passing parameters via URL Message-ID: I've written some code that produces a web page. I have the same code replicated several times, with small changes that I use throughout a site. How can I bring these all into one program so I can make a call like http://www.xyz.com/program.py?dothis or http://www.xyz.com.program.py?dothat and have the Python program determine what to do when it receives either dothis or dothat. Thanks. Colin From ste at edistar.com Fri Oct 20 09:47:07 2000 From: ste at edistar.com (root) Date: Fri, 20 Oct 2000 15:47:07 +0200 Subject: Python 1.4 and solid 3.5 Message-ID: <39F04CDB.1EDEF@edistar.com> Hi I'm looking for a python module to access a Solid database server version 3.5 that works with python version 1.4. Or if anyone knows any other way to access, please let me know. From tim_one at email.msn.com Mon Oct 30 15:58:52 2000 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 30 Oct 2000 15:58:52 -0500 Subject: URL implications of the recent move...? In-Reply-To: <8tjkif02qjo@news1.newsguy.com> Message-ID: [Alex Martelli] > So what URL[s] should be indicated as "the main > Python entry point" now that Pythonlabs is (no > more? or still alive but disjoint from BeOpen? > its webpage still calls it 'BeOpen Pythonlabs')...? > > I was starting to point to > http://www.pythonlabs.com > as an addition to > http://www.python.org > which seemed to be less actively maintained -- > what now, then? python.org remains the best bet. It's barely been maintained at all the last several months, but that's because CNRI didn't let go of it. CNRI promised-- at a Python Consortium meeting this summer --to relinquish control of it, but nothing has come of that yet. That's still The Plan, though: we would *like* to get the python.org content maintained under source control at SourceForge, and open up its maintenance to the community. More than one source has offered to host the site then too (Digital Creations among them), and a hosting move is necessary because python.org has outgrown the HW resources CNRI devotes to it. The future of pythonlabs.com is muddier; but even if Guido hadn't moved to DC, the plan was to keep python.org as the main community site and turn pythonlabs.com into a resource for hardcore Python developers. the-more-things-change-etc-ly y'rs - tim From jkraska1 at san.rr.com Wed Oct 25 00:19:58 2000 From: jkraska1 at san.rr.com (Courageous) Date: Wed, 25 Oct 2000 04:19:58 GMT Subject: Mapping Python to CORBA References: <39CA743C.4D20DF1@hks.com> <8qf9mj$8kd$1@pea.uk.research.att.com> <39CB94FF.5BC02E23@hks.com> Message-ID: <39F6603E.BF340B58@san.rr.com> > Python list -> IDL typedef sequence MyList; > or similar. Right, but can a CORBA any type also be a sequence or a hash table? (it's been a while, but I don't think so). The problems of moving from Python's unstructured environment to the more structured CORBA environment are legion. Everything must be decided on a case-by-case basis. If it were me, I'd make certain that I had look-aside metadata which I compared my python data to before I attempted to push it to CORBA. For this, you'll need some kind of friendly python IDL parser. C// From alan.gauld at gssec.bt.co.uk Wed Oct 11 06:16:15 2000 From: alan.gauld at gssec.bt.co.uk (Alan Gauld) Date: Wed, 11 Oct 2000 11:16:15 +0100 Subject: Why is "while" ticking me off??? References: <39DD15A1.442E5A33@ix.netcom.com> <39DDEC25.CEE0E16A@gssec.bt.co.uk> Message-ID: <39E43DEF.89B020EE@gssec.bt.co.uk> Huaiyu Zhu wrote: > I quote an example here: > > if val = dict1[key1]: > process1(val) > elif val = dict2[key2]: > process2(val) > elif val = dict3[key3]: > process3(val) > ... OR: if dict1[key1]: process1(dictl[key1]) elif dict2[key2]: process2(dictl[key2]) elif dict3[key3]: process3(dictl[key2]) ... OK, There could be a performance overhead. In which case you have no alrternative to do 2 lines per branch. > The entirely equivalent python code would require nested ifs > > val = dict1[key1] > if val: > process1(val) > else: Why use if/else if here when you used if/elif above? That just makes it look worse than it need be. Alan g. -- ================================================= This post represents the views of the author and does not necessarily accurately represent the views of BT. From w.janssen at ieee.org Tue Oct 24 16:33:30 2000 From: w.janssen at ieee.org (Bill Janssen) Date: Tue, 24 Oct 2000 13:33:30 PDT Subject: plagued by IOError: [Errno 0]? Message-ID: <00Oct24.133337pdt."3441"@watson.parc.xerox.com> I'm running a server that periodically, and unpredictably, keeps getting an IOError when opening a file. But the Errno is 0! What does this mean, and how can I get rid of it? I'm running on a Solaris 2.6 SPARC system, and the files being opened are relatively large (3.4 MB) on NFS-mounted file systems. Python 1.5.2. IOError: [Errno 0] Error: '/docRepository/NewRepoDoc/1' I'm doing an "open(fname, 'r')". Bill From jwbnews at scandaroon.com Sat Oct 28 00:02:31 2000 From: jwbnews at scandaroon.com (John W. Baxter) Date: Fri, 27 Oct 2000 21:02:31 -0700 Subject: PythonLabs Team Moves to Digital Creations References: Message-ID: In article , Guido van Rossum wrote: > ... > I am proud to have found a new home for my entire team: starting > today, Tim Peters, Barry Warsaw, Jeremy Hylton, Fred Drake and myself > are working for Digital Creations. > ... Sounds like a happy move. And my congratulations to all who were in the know for not letting the idea leak before its time. Not an easy thing. The future lies ahead. --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From michel at digicool.com Sun Oct 22 05:22:34 2000 From: michel at digicool.com (Michel Pelletier) Date: Sun, 22 Oct 2000 02:22:34 -0700 Subject: class mutex References: <39F1E7B8.D2E0F2AB@weihenstephan.org> Message-ID: <39F2B1DA.BA708A65@digicool.com> "Prof. Peter Stoehr" wrote: > > Hi out there, > > there is a class mutex shipped with python. I've tried to use it to > syncronise two processes created with os.fork() and failed :-( > Looking at the source code of mutex.py I found out, that it is > implemented in pure python. Thus, it does not implement a real > mutex-object as a python code can be interrupted after each step of the > byte-code. > Based on that, I have two questions: > 1) Does python provide a real mutex object. > 2) What is the use of the class mutex I do not know the answer to your questions and my suggestion may not be anything what you are looking for, but Zope comes with an ExtensionClass C extension module which has a Synchronized base class which you can use to ensure that only one thread of execution can execute a method of a class at any time. Also, doesn't fork create a new process? I wouldn't think any mutex would hold across process boundaries, only thread boundaries. Good luck, -Michel From loewis at informatik.hu-berlin.de Sun Oct 1 15:53:02 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 01 Oct 2000 21:53:02 +0200 Subject: Character set conversion between mac and pc References: <2B1262E83448D211AE4B00A0C9D61B030130157F@msgeuro1.creo.be> Message-ID: =?ISO-8859-1?Q?Fran=E7ois_Pinard?= writes: > I would surely like to have an option generating them for Python, but I > wonder what the most useful format would be. If input and output are 8-bit character sets, wouldn't a string usable for string.translate indeed be the best option? Manually massaging (if you want to leave a massage, speak after the bleep) your macintosh_IBM850 table, I'd get macintosh_IBM850= \ '\0\1\2\3\4\5\6\7' \ '\010\011\012\013\014\015\016\017' \ '\020\021\022\023\024\025\026\027' \ '\030\031\032\033\034\035\036\037' \ ' !"#$%&\'()*+,-./' \ '0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_' \ '`abcdefghijklmnopqrstuvwxyz{|}~\177' \ '\216\217\200\220\245\231\232\240' \ '\205\203\204\306\206\207\202\212' \ '\210\211\241\215\214\213\244\242' \ '\225\223\224\344\243\227\226\201' \ '\264\370\275\234\365\304\364\341' \ '\251\270\302\357\371\301\222\235' \ '\260\361\262\263\276\346\345\313' \ '\300\271\272\246\247\310\221\233' \ '\250\255\252\303\237\305\354\256' \ '\257\311\377\267\307\315\316\333' \ '\320\321\347\350\362\236\366\273' \ '\230\331\332\317\334\335\355\337' \ '\314\372\253\261\277\266\322\265' \ '\323\324\326\327\330\336\340\342' \ '\360\343\351\352\353\325\363\374' \ '\356\254\274\373\367\375\376\312' Provided I made no mistakes when producing this string - wouldn't that work for string.translate out of the box? > Suggestions most welcome! For Python 2.0, I'd like to see it generate conversion modules following the 'encodings' package. That, of course, would require that they convert from and to Unicode. Regards, Martin From ge at nowhere.none Mon Oct 2 12:53:21 2000 From: ge at nowhere.none (Grant Edwards) Date: Mon, 02 Oct 2000 16:53:21 GMT Subject: good python tutorials for C mother-tongues? References: <0L2C5.39$T34.2386@news.hananet.net> <8rae7k$407$1@panix2.panix.com> Message-ID: <543C5.3728$WJ3.588779@ptah.visi.com> In article <8rae7k$407$1 at panix2.panix.com>, Aahz Maruch wrote: >In article <0L2C5.39$T34.2386 at news.hananet.net>, >June Kim wrote: >> >>Are there any good python tutorials for professional programmers who's >>been brought up in C language? > >Start with http://www.pythonlabs.com/doc/manuals/python2.0/tut/tut.html After that, I'd recommend the book "The Essential Python Reference". It's not a tutuoral, but if you're an experienced programmer and have gone through the on-line tutuorial, then the language summary in the first few chapters of EPR is a good read. -- Grant Edwards grante Yow! Go on, EMOTE! I at was RAISED on thought visi.com balloons!! From aleaxit at yahoo.com Fri Oct 20 12:19:11 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 20 Oct 2000 18:19:11 +0200 Subject: newbie References: <8soeic$57gs$2@newssvr05-en0.news.prodigy.com> <9_PH5.99786$g6.44454168@news2.rdc2.tx.home.com> <8sov2g0142d@news1.newsguy.com> <0SXH5.72992$ib7.10053637@news1.rdc1.nj.home.com> Message-ID: <8sprk0028bl@news1.newsguy.com> "Brett g Porter" wrote in message news:0SXH5.72992$ib7.10053637 at news1.rdc1.nj.home.com... > > "Alex Martelli" wrote in message > news:8sov2g0142d at news1.newsguy.com... > > > > If C++ is your goal, then, after you've used Python to learn programming > > reasonably well, you may as well jump right into C++ with the aid of a > > good tutorial (I suggest Lippman and Lajoie's -- by far the best IMHO; > > it's published by Addison-Wesley). > I recommend Bruce Eckel's "Thinking in C++" -- you can download it for free > (full text!) at -- the first edition was the > book that finally turned me from a C programmer into a native-speaking C++ > programmer. The second edition is designed for someone with little or no C > experience. Then keep checking back to see if he's finally started writing > his "Thinking in Python" book. If he's taken away the need for previous C experience, then it may have reached or surpassed the L&J one -- I only knew version 1 and, while good, it _did_ need that previous experience. > > C++ is *horrendously* difficult (its > > main defect, again IMHO) > Well, yes and no. There's a sane and simple subset that's easily learned and > used. Most people never have need for the more obscure corners of the > language. But when I need them, I'm comforted knowing that they're there. No way. The "obscure pieces" slip in by mistake -- over and over again. One of my main roles here at work is as "obscure-stuff consultant" -- dozens of colleagues trying to use a not-wholly-insane and not-horribly- complex ('simple' would be a BIG overbid anyway -- *Python* is simple...) subset, who keep coming to me to understand what has happened in a given situation and how to fix it. > By the same token WRT Python -- hands up, everyone who _really_ understands > and can use the Beaudry hook. How far can you go as a Python programmer > without that? Pretty far, but I love knowing that it's there should I ever > need it. I use metaclasses through higher-level abstractions relying on Beaudry (ExtensionClass, py_cpp, ...), so the hook itself never intrudes (nor would I worry about it staying around, as long as ExtensionClass and py_cpp keep working by whatever means:-). Alex From muwanda at my-deja.com Fri Oct 13 14:40:01 2000 From: muwanda at my-deja.com (muwanda at my-deja.com) Date: Fri, 13 Oct 2000 18:40:01 GMT Subject: SQL server module?????? References: <8s7i1j$vkv$1@nnrp1.deja.com> <39E7502B.2EE777AE@holdenweb.com> Message-ID: <8s7ku1$28a$1@nnrp1.deja.com> thanks Steve... in the past I work with MySql, but we change to sqlserver.... if I have a trouble.... I ask you.... bye. regards oscar (muwanda) Sent via Deja.com http://www.deja.com/ Before you buy. From mjhand at concentric.net Mon Oct 23 13:09:05 2000 From: mjhand at concentric.net (Manus Hand) Date: Mon, 23 Oct 2000 17:09:05 GMT Subject: DESPERATE FOR NEWS ON STARSHIP OUTAGE Message-ID: <8t1rb9$8hn$1@nnrp1.deja.com> I fit the category described in the subject of this message. Anyone know anything about when whatever network problem that is preventing us from getting to starship.python.net and to beopen.com will be resolved? Anyone know if it's being worked? Can I badger someone more specific than the whole newsgroup? Please e-mail me any update you know of at mjhand at concentric.net. Thanks in advance, Manus Sent via Deja.com http://www.deja.com/ Before you buy. From aleaxit at yahoo.com Tue Oct 24 12:06:06 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 24 Oct 2000 18:06:06 +0200 Subject: event loop problem References: <8t21ei$e5a$1@nnrp1.deja.com> <8t3q4402a3u@news2.newsguy.com> Message-ID: <8t4caq031fl@news2.newsguy.com> "Geoff Talvola" wrote in message news:mailman.972399545.29613.python-list at python.org... [snip] > > > design flaw in NT that any one application can cause other applications to > > > hang if it's not processing its message loop. > > > > Only if those "other applications" *WANT* to hang; otherwise, > > they would be using SendMessageTimeout (to guarantee termination [snip] > The problem I have is that any one application that is *completely* *unrelated* > to another application can nevertheless cause that other application to hang by But, again, only if that "other application" *CHOOSES* to hang... and please note the other application is NOT "completely unrelated" -- it has explicitly asked the system "put me in touch with every other process that has top-level windows, and wait infinitely for each of them to answer". That "any one application" DOES have top-level windows, so it's in the set the "other application" has specifically "infinitely-waited" about. It may be silly to even provide a WAY to "wait forever" for something to happen (when it can never be guaranteed that it will happen at all), but all systems I know do provide such ways ("blocking system calls"); they're supposed to make life simpler than event-driven processing, I think (for some obscure reason...). Thus, doing so can hardly be called a "design flaw" in a specific operating system. > not processing its message loop. From what you're saying, it's a bug in those > applications, not in Windows -- I can accept that. However, it's not exactly I think the bug is in the application sending the "wait-forever" call (SendMessage with broadcast). It's explicitly putting itself at the mercy of every other application in the Universe -- can that ever make sense...? It's a pity that SendMessage without the timeout is hidden in the bowels of some libraries such as DDEML (I think it makes those libraries unusable for quality applications, but some suppliers of such applications clearly disagree with me!). > obvious when you have accidentally created a hidden window and therefore need to > be processing messages. I use Spy++ from Visual Studio to diagnose these > things, but usually I don't realize I've created a hidden window until I start > noticing things like PythonWin not starting up :-) Sure; I consider "not serving one's message-loop" a lesser bug (when one doesn't _know_ there are hidden windows being created on one's behalf by lower-level services...). > > > Starting up PythonWin is > > > another example of something you can't do if any program isn't processing > > > its messages. > > > > Really? I hadn't noticed. This is a bug in PythonWin, from > > my POW -- it should NOT be doing a broadcast SendMessage without > > a timeout (be it via DDEML or otherwise). Have you submitted > > this bug to ActiveState? > > I didn't know it *was* a bug, since I've seen so many other programs behave the > same way :-) Well, it's a _widespread_ bug, I guess (it also affects some applications I share responsibility for -- but let's not get into that:-). > > > But a better solution is to tell win32com to run in free-threading mode, in > > > which case it doesn't create a hidden window and everything works fine > > > > No, but it DOES freely create threads! Remember to protect > > all access to shared-data if you choose this route. Personally, > > I think serving the message-loop is simpler. > > For a single-threaded Python program using ADO, there's no shared data to worry If that Python program exposes COM stuff, and it tells COM it's free threaded, it's a risky gamble to call it "single-threaded". _IT_ does not explicitly start up more threads, BUT its code may be executed on other threads (e.g. in response to COM events, if it hooks any). And I don't think the Python-interpreter's single global lock will save your skin in that case -- the interaction level made "atomic" by that lock is the single-Python-bytecode-instruction, which I think is too semantically low (which is why Python multithreaded programs use their own locking strategies). > about. And what if your program structure contains long-running calculations > based on data from your ADO database? You have to contort your calculations to > insert PumpWaitingMessages() calls everywhere. A single-threaded, non-GUI > application shouldn't have to have a message loop, IMO. I disagree. _Particularly_ if that application "contains long-running calculations", it *should* be checkpointing regularly, *and* responding sensibly when the system tells it "we're about to go down, is that all right?" -- which it does by sending it appropriate messages. It's even more important when the system has advanced power management: if the application doesn't handle that, it has no way to tell the system "no, DON'T switch to low-power-mode, I need all the CPU I can get for my long-running calculations!", etc, etc. Of course one doesn't explicitly call PumpWaitingMessages() -- but one (IMHO) _does_ make sure a "globalobj.checkpoint()" is regularly called for these purposes. It costs nothing to 'pump' waiting messages in that regularly-called-anyway checkpoint function. It _would_ be nice if there was a way to have the Python interpreter provide the "call back to this function of mine regularly, please" functionality, in a way, but then you'd be back to the problem of making sure your state _is_ interruptible/checkpointable/re-entrant/...; by having _you_ call the checkpointing function, it's far easy to guarantee you're ready for checkpointing &c when you do call it (one of the key advantages of event-driven programming over multithreaded-programming... it's easier because you DO control WHEN you're done with an event and ready to proceed...). > In my experience, whether or not you're using free-threading mode, ADO will > create lots of threads and a hidden window for its own use anyway. The > difference is that in free-threading mode, the hidden window is in a different > thread and appears to have its messages processed automatically, whereas if you > use the default single-threaded apartment, the hidden window is created in the > main thread and you have to explicitly use PumpWaitingMessages everywhere. I'll freely admit I have not looked at the issue of ADO "creating lots of threads", and I do wonder where that extra 'hidden window' comes from (are there apartment-threaded objects in the ADO/OleDb internals, not just free-threaded ones...?). But I wonder how you _ensure_ that none of your code is ever executed on one of those other "lots of threads" -- maybe by exposing no COM functionality whatsoever, including not hooking any events. Seems a rather high price to pay, in general, though it may be OK for a lite/throw-away little thingy that doesn't need to receive events or be externally-automatable anyway. Alex From spahievi at vega.bg Mon Oct 9 14:46:16 2000 From: spahievi at vega.bg (Niki Spahiev) Date: Mon, 9 Oct 2000 21:46:16 +0300 Subject: copy_reg problem - UPDATE! PLEASE READ! In-Reply-To: References: <7ecD5.41113$g6.16721199@news2.rdc2.tx.home.com> Message-ID: <323424489.20001009214616@vega.bg> Have you checked ZODB from ZOPE? It deals with such problems. -- Best regards, Niki Spahiev From maddman at maddman.org Wed Oct 25 16:58:40 2000 From: maddman at maddman.org (the maddman) Date: Wed, 25 Oct 2000 13:58:40 -0700 Subject: Multi-homed socket server? Message-ID: <39F74980.C24DC677@maddman.org> I'm trying to write a multi-threaded Python server, and it's been surprisingly easy so far, but I want to bind the socket to any address, not just the address I get back from DNS. I tried binding to 'INADDR_ANY' but that didn't work. I have DSL with PPPoE, so one IP could change while the server is running, and I need it to work after that. Any one got some good sample code that I could learn from? From root at rainerdeyke.com Mon Oct 23 01:41:50 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 23 Oct 2000 05:41:50 GMT Subject: All permutations of a list References: <39F1FB22.6E9246E7@cs.utwente.nl> <39F393B5.A978CC9D@cs.utwente.nl> <9nNI5.110763$g6.50159527@news2.rdc2.tx.home.com> <8t08bb$lnvu5$1@ID-11957.news.cis.dfn.de> Message-ID: "Emile van Sebille" wrote in message news:8t08bb$lnvu5$1 at ID-11957.news.cis.dfn.de... > "Rainer Deyke" wrote in message > news:9nNI5.110763$g6.50159527 at news2.rdc2.tx.home.com... > > Here's my short Pythonic permutation function: > > > > def perms(list): > > if list == []: > > return [[]] > > return [[list[i]] + p for i in range(len(list))\ > > for p in perms(list[:i] + list[i+1:])] > > > > ... which permutes into... > > def perms3(list): > return not [list] or [[list[i]] + p for i in > range(len(list))\ > for p in perms(list[:i] + list[i+1:])] No. If 'list' is '[]', '[list]' evalutes to '[[]]'. 'not [[]]' evalutes to 0, effectively removing all special handling for the empty list. If the list of permutations of the empty list was redefined as the empty list, the following would work: def perms(list): return list and [[list[i]] + p for i in range(len(list))\ for p in (perms(list[:i] + list[i+1:]) or [[]])] If you're really desparate, you can save an additional line by using lambda: perms = lambda list: list and [[list[i]] + p for i in\ range(len(list)) for p in (perms(list[:i] + list[i+1:]) or [[]])] -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From pete at petes-place.com Fri Oct 13 17:41:19 2000 From: pete at petes-place.com (David T. Grove) Date: Fri, 13 Oct 2000 21:41:19 GMT Subject: Perl rules - Python drools References: <8s6ksl$mea$1@ctb-nnrp2.saix.net> Message-ID: <39e77de7.28583100@news.davesworld.net> On Fri, 13 Oct 2000 11:38:52 +0200, "Wayne Paterson" wrote: > > > >begin 666 cameleatingpython.jpg If you don't mind, I won't waste my time peeking at this. As an avid perl user: I should point out something. You are in violation of trademark law. You are not permitted to use a camel in association with the Perl language without specific written permission from O'Reilly and Associates. You have also used a trademarked O'Reilly symbol for an unauthorized attack on the Python community, for which O'Reilly can seek additional legal remedies, since you are misrepresenting O'Reilly and Associates to the public. Your email address seems to indicate that you are making this attack on behalf of your company. If this is true, your company may be held equally liable. That I know of, there is no such restriction on using a python image with the python language. That would be almost impossible for O'Reilly to hold up in court. Maybe if O'Reilly had used a four-legged octopus for their Python book, _that_ they could trademark, not that anyone would use it. The disentanglement of Python from external corporate control, even in an area such as this, is more than just a few major plusses for the Python language... and I don't even particularly care for the Python language. (I'm here to watch trends, learn what I can, enjoy non-elitist community discussion, and make some objective personal and business-level decisions.) You might consider thinking twice before trolling, there's likely to be someone in the group who can slam you harder than you wanna be, you wannabe. Pete The Trollmeister From thomas.svensson at era.ericsson.se Thu Oct 5 11:34:20 2000 From: thomas.svensson at era.ericsson.se (Thomas Svensson) Date: Thu, 05 Oct 2000 17:34:20 +0200 Subject: re.match question Message-ID: <39DC9F7C.67B71D52@era.ericsson.se> Hello, I'm matching a list of strings. I want "xxxBar" to be a match but not "xxxFooBar", xxx can be anything. I've tried the following: re.match('^.*?(?!Foo)Bar$', word) re.match('^.*?(Foo){0}Bar$', word) But they all returns a match. What am I doing wrong?? I think this should be an easy thing to do. Thanks for any help, Thomas From mfletch at tpresence.com Mon Oct 30 11:15:16 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Mon, 30 Oct 2000 11:15:16 -0500 Subject: Shall we declare Tkinter dead? No-one seems interested in it ;o) Message-ID: Nested mainloops are a Tkinter feature caused by such things as widget.wait() and managed by such things as widget.quit() . _I_ never even use Tkinter, I'm just trying to make it compatible with micro-threads (so other people can use it), so _I_ would _never_ use a nested mainloop. I agree, nested mainloops suggest the need for a different architecture: FxPy and wxPython spring to mind ;o) . >From that article looks as though just binding the destroy event should be sufficient. Cool. Success is in the eye of the foreclosing banker, Mike -----Original Message----- From: Cameron Laird [mailto:claird at starbase.neosoft.com] Sent: Monday, October 30, 2000 10:24 AM To: mfletch at tpresence.com Subject: Re: Shall we declare Tkinter dead? No-one seems interested in it ;o) ... "... nested mainloops ..."?!!? Mike, WHAT are you doing? I have a strong instinct that nested mainloops are a hint that there's pervesity afoot, and that I'd look for a different architecture. I know, though, that you're successful at what you do, so maybe it'll work for you. >and the WM_DELETE_WINDOW, if I understand correctly, either would indicate >that the root window is being destroyed. Sort of. Readers with further interest in this topic might want to notice, for example, ... From adjih at crepuscule.com Tue Oct 3 06:47:27 2000 From: adjih at crepuscule.com (Cedric Adjih) Date: 3 Oct 2000 10:47:27 GMT Subject: python source benchmark References: Message-ID: <8rcdfv$2be$1@ites.inria.fr> seung-won hwang wrote: > Hello, > > I'm trying to benchmark python source with clock() function, but > my code below returns negative value. I am not sure if my code is > wrong or clock() is not suitable for getting CPU time... Any comment > would help me a lot. Thanks. > > My code: > scl=time.clock() > ... > fcl=time.clock() > print "Execution Time: =", fcl-scl > Reference: > clock () > Return the current CPU time as a floating point number expressed in > seconds. The precision, and in fact the very definition of the meaning of > ``CPU time'', depends on that of the C function of the same name, but in > any case, this is the function to use for benchmarking Python or timing > algorithms Well according to Linux documentation for clock(3): BUGS The C standard allows for arbitrary values at the start of the program; take the difference between the value returned from a call to clock() at the start of the pro? gram and the end to get maximum portability. Note that the time can wrap around. On a 32bit system where CLOCKS_PER_SEC equals 1000000 this function will return the same value approximately every 72 minutes. Since CLOCKS_PER_SEC is actually defined to be 1000000 in /usr/include/bits/time.h, on my Linux machine, you will have a wrap-around after 72 minutes (or less) under the same circumstances. On Unix, there is a os.times() that probably suffers from the same problem, and a module resource (resource.getrusage(...)), which isn't compiled in on my machine. I usually use the /bin/time command, time.time() (on a lightly loaded machine), or the profile module of Python for computing the time spent in a program (as another person indicated here). -- Cedric From the_brain at mit.edu Mon Oct 2 21:08:20 2000 From: the_brain at mit.edu (Alex) Date: 02 Oct 2000 21:08:20 -0400 Subject: Q: generating machine code References: <39D92F01.8684059@uiuc.edu> Message-ID: > How to generate platform-dependent machine object code from python > sources, so I don't need python interpreter to run a python program ? Check out freeze. I've never used it, but I'm pretty sure it lets you generate stand-alone programs. It doesn't generate object code directly from python source code, though. Alex. -- Speak softly but carry a big carrot. From nospam at nospam.com Sun Oct 1 10:04:09 2000 From: nospam at nospam.com (Tom) Date: Sun, 01 Oct 2000 14:04:09 GMT Subject: New Python development process (SourceForge considered Harmful?) References: <8qss6t$7i$1@saltmine.radix.net> <8erA5.37729$dZ2.13446193@news3.rdc1.on.home.com> Message-ID: No, I can't. I believe there is a delay based on the way that pages appear: the ad appears quickly, then there is a considerable delay before the rest of the content is sent. This is common technique on the internet. On the other hand, if you've looked at the source, and the delay isn't there, then I'm wrong and I retract my comments. Tom. "Martin von Loewis" wrote in message news:p6qr9612bj3.fsf at informatik.hu-berlin.de... > "Tom" writes: > > > So, they already display banner ads, and they already use a delay before > > displaying page content (after the ad is displayed). If I was wrong, and > > they were really dedicated to the productivity of their users, they wouldn't > > use this 'after ad' delay. > > I don't believe there is a deliberate after-ad delay on SF. The source > code of SF is available (this is the alexandria project) - can you > point to the exact place where such a delay is implemented? > > Regards, > Martin > From cigar20 at my-deja.com Tue Oct 17 01:13:51 2000 From: cigar20 at my-deja.com (cigar20 at my-deja.com) Date: Tue, 17 Oct 2000 05:13:51 GMT Subject: I want to impress the boss. References: <8sdvc6$jqq$1@nnrp1.deja.com> <39EAFE3C.7D13B8B3@engcorp.com> Message-ID: <8sgn6d$s10$1@nnrp1.deja.com> Ok... Now that we've all had our turn at stating "I'm new to Python" (and don't yet know much). Focus....Focus! :) The questions: - The location of a complete set of Microsoft Word COM commands is asking too much? - When interfacing to VSS it's up to me to build my own 'home grown' set of commands...(it's possibly not mature enough a program to have a built in COM interface)? Answers: - What's the hurry? I understood you could do things quickly in Python. Why must I show patience? :) Sent via Deja.com http://www.deja.com/ Before you buy. From akuchlin at mems-exchange.org Fri Oct 6 14:51:11 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 06 Oct 2000 14:51:11 -0400 Subject: Any parser generator available? References: <39DDF5A2.130F2656@home.com> Message-ID: <3d1yxtn6qo.fsf@kronos.cnri.reston.va.us> The links at the following URL might be helpful: http://starship.python.net/crew/amk/python/string.html#parsing Several different systems, but no clear primary choice. (Be nice to fix that...) --amk From robin at jessikat.fsnet.co.uk Sun Oct 22 08:34:57 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sun, 22 Oct 2000 13:34:57 +0100 Subject: Is this a bug in Python2.0 or yet another feature of Windows? References: <8su86i$fen$1@news.nuri.net> Message-ID: In article <8su86i$fen$1 at news.nuri.net>, June Kim writes >With Python 2.0 Final Release, > > >>>> from array import array >>>> z=array('c','hello world') >>>> `z` #Note that these are back-quotes > >It returns a nice "python20.dll" error, whereas run on python 1.6, >it returns what we expect, the string form of the array. > >- June ... looks bad to me under win32 as well. -- Robin Becker From kogorman at pacbell.net Wed Oct 11 16:38:41 2000 From: kogorman at pacbell.net (Kevin O'Gorman) Date: Wed, 11 Oct 2000 13:38:41 -0700 Subject: Help a newbie use Python's OS module: References: <39DE4685.4C3EB1E9@pacbell.net> <8rlkbc$a7b0$1@nntp6.u.washington.edu> Message-ID: <39E4CFD1.7D112212@pacbell.net> Donn Cave wrote: > > Quoth Kevin O'Gorman : > > | I can use os.fork() to create a child process, but I cannot > | get messages from the child to the parent through the pipe > | I've created. > | > | If anyone's got a little sample program that shows how this > | is done, I'd sure appreciate it. > | > | At the moment, my (non-working) version complains that the > | parent's attemts to read the pipe are failing. It looks > | like this: > | > | > | #! /usr/bin/python > | # $Id: fork.py,v 1.2 2000/10/06 04:17:32 kevin Exp kevin $ > | > | import string > | import sys > | import re > | import os > | > | print "Running $Id: fork.py,v 1.2 2000/10/06 04:17:32 kevin Exp kevin $" > | > | osi=sys.stdin > | oso=sys.stdout > | ose=sys.stderr > | > | rw=os.pipe() > | r=rw[0] > | w=rw[1] > | print "Reading on",r,", and writing on",w > | child=os.fork() > | if child==0: > | sys.stderr.write("In child\n") > | os.close(1) > | os.dup(w) > | sys.stdout=os.fdopen(1,"w") > | os.close(r) > | os.close(w) > | > | sys.stderr.write("Writing\n") > | print "foo" > | print "bar" > | print "foobuar" > | sys.stdout.close() > | sys.exit(0) > | > | os.close(0) > | os.dup(r) > | sys.stdin=os.fdopen(r) ## <----- > | os.close(r) > | os.close(w) > | > | print "Stdin is ",sys.stdin > | print "about to read" > | lin=sys.stdin.readline() > | if not lin: > | print "Read failed",lin > | sys.exit(1) > | while lin: > | print lin > | > | lin=sys.stdin.readline() > > I think you will recognize the nature of the problem right away. > Try sys.stdin = os.fdopen(0), in the parent. > > I find dup2() easier to use than dup(). I rarely use file objects > in this kind of thing, because of their buffering. In this example > I don't see any problems with either of those, though. > > Donn Cave, donn at u.washington.edu Right on, of course. Thanks for the help. Everything will be so much easier now that I have a working example. I must admit, though, that I didn't quite understand the comment about no using file objects. Doesn't it get cumbersome to direct output to the raw descriptors? What do you use? I didn't see anything like fprintf, or a way to set sys.stdout to a descriptor (a bare int doesn't work). ++ kevin -- Kevin O'Gorman (805) 650-6274 mailto:kogorman at pacbell.net Permanent e-mail forwarder: mailto:Kevin.O'Gorman.64 at Alum.Dartmouth.org At school: mailto:kogorman at cs.ucsb.edu Web: http://www.cs.ucsb.edu/~kogorman/index.html Web: http://trixie.kosman.via.ayuda.com/~kevin/index.html From jwbnews at scandaroon.com Mon Oct 16 13:47:31 2000 From: jwbnews at scandaroon.com (John W. Baxter) Date: Mon, 16 Oct 2000 10:47:31 -0700 Subject: Newbie Mac question re: Tkinter References: <39EB30B5.52BF@lenti.med.umn.edu> Message-ID: In article <39EB30B5.52BF at lenti.med.umn.edu>, Martin Wessendorf wrote: > Hello all-- > > I've just started trying to learn Python and have installed 1.5.2 on my > Mac 6100 under system 7.5 (...I always try to be at the cutting > edge...). The "Vise" installer claimed that it was installing Tk along > with Python, and at the completion of the installation its window stated > that the installation had been successful. However, when I tried > running some of the Tk demo's I got an error message in the Python > interpreter window stating that the Tkinter module couldn't be found. > > I've searched for things with Tkinter in their name and found two items > in the PIL directory; I've put that directory was in my path using the > preference editor program. Still no luck. > > I also tried re-running the configuration applet, also to no avail. > > Any suggestions? Should I just scrap the thing and re-install? In 1.5.2, the Tk stuff is largely broken (I never actually tried it in the 1.5.2 release...I played with it in an earlier release). In the new 2.0c1 release (out late last week, to be replaced by 2.0 this week barring problems), it is somewhat less broken. I was able to run a few of the Tk demos, some of which worked and some only partly worked (none I tried crashed). Since you're just starting out and seem to want to use Tk, it's probably better to start with 2.0. See: http://www.cwi.nl/~jack/macpython.html --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From tdelaney at avaya.com Mon Oct 23 23:46:39 2000 From: tdelaney at avaya.com (Delaney, Timothy) Date: Tue, 24 Oct 2000 14:46:39 +1100 Subject: C's syntax Message-ID: You are kidding aren't you? One thing I've learned in my time is that people don't stop making the same mistakes over and over. The difference is that when the error occurs you are able to identify the error immediately (oh hell ... I know what that is ... it's a typo ... I've put an assignment instead of a comparison ...). Obviously, this only works if you are making localised changes, not monolithic ones. For monolithic changes it's even *more* important. Anything which is capable of reducing the number of errors which don't *need* to be caught by the compiler (and that you have the discipline to stick with) or that is going to change a compiler *warning* to a compiler *error* is a Good Thing (TM). > > It's a good coding habit to get into, to ensure that particular > > slip will be caught by any standard compiler, rather than relying > > on specific warning-relater features that NOT all compilers have. > > It is largely unnecessary. It is a novice programming error, one that > actual programmers do not make unless they are very green. Given that > any reasonable compiler will warn about such constructs, > making a major > change in style for an error that advanced programmers do not make is > overkill, to say the least. Tim Delaney Avaya Australia From mcunni01 at uoguelph.ca Mon Oct 16 13:34:18 2000 From: mcunni01 at uoguelph.ca (Mark Cunningham) Date: Mon, 16 Oct 2000 13:34:18 -0400 Subject: Install Interupted.got it working References: <39EAB1D0.36883936@uoguelph.ca> <39EABB8A.14FE315E@uoguelph.ca> Message-ID: <39EB3C1A.E3044DE1@uoguelph.ca> make sure your #!/usr/local/bin/python is on the top line. From not.this at seebelow.org Thu Oct 19 16:42:49 2000 From: not.this at seebelow.org (Grant Griffin) Date: Thu, 19 Oct 2000 21:42:49 +0100 Subject: scanf in python...? References: <39ebd839.159714@news> <8sje3e$it4$1@nntp9.atl.mindspring.net> Message-ID: <39EF5CC9.F4826121@seebelow.org> Andrew Dalke wrote: > > Tony Waterman wrote in message <39ebd839.159714 at news>... > >Does python have any way to mimic scanf ? > > http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.033.htp > > ========= > > Python FAQ Entry > > 4.33. Is there a scanf() or sscanf() equivalent? > > Not as such. > For simple input parsing, the easiest approach is usually to split the line > into whitespace-delimited words using string.split(), and to convert decimal > strings to numeric values using string.atoi(), string.atol() or > string.atof(). (Python's atoi() is 32-bit and its atol() is arbitrary > precision.) If you want to use another delimiter than whitespace, use > string.splitfield() (possibly combining it with string.strip() which removes > surrounding whitespace from a string). There's a subtle thing going on here that I think the FAQ entry should be revised to explain. In my own "scanf" journey (wherein I discovered some of the many, non-obvious ways to do scanf ), I have tended to use "float()", "int()" etc. rather than "string.atof()" and "string.atoi()". To the uninitiated, that would be the more obvious (and concise) approach. But what about this?: Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 >>> int('0x13') Traceback (most recent call last): File "", line 1, in ? ValueError: invalid literal for int(): 0x13 So "int" evidently can't figure out what "0x" means. But what about string.atoi()? >>> import string >>> string.atoi('0x13') Traceback (most recent call last): File "", line 1, in ? File "c:\apps\python20\lib\string.py", line 215, in atoi return _int(s, base) ValueError: invalid literal for int(): 0x13 Durn. It's no smarter than int(). Or _is_ it? What if we gave it a little hint? <>... >>> string.atoi('0x13',16) 19 Cool! So it just seems to ignore the "0x" part. Or _does_ it?... >>> string.atoi('0x13',10) Traceback (most recent call last): File "", line 1, in ? File "c:\apps\python20\lib\string.py", line 215, in atoi return _int(s, base) ValueError: invalid literal for int(): 0x13 Nope--it seems to think it knows what "0x" means. But for _some_ strange <> reason it wants us to _reassure_ it. (I guess the poor little thing just lacks self-confidence. ) Now, in 1.5.2, I seem to recall that "string.atoi()" allowed you to specify the base, but "int()" didn't. <> So let's just confirm that: Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 >>> int('0x13',16) Traceback (innermost last): File "", line 1, in ? TypeError: int requires exactly 1 argument; 2 given Yup. But in 2.0 we evidently can: >>> int('0x13',16) 19 That's nice, Dear. So, I would recommend to whomever is in charge of such things that the FAQ answer at top be ammended to include the possible use of "float()" and "int()" as alternatives to "string.atof()" and "string.atoi()", and that it explain that you have to tell int() or string.atoi() the base, if not base 10. (And don't you go trying to tell it the _wrong_ base, fella--it's run into your type before!) of-all-personality-traits-computers-can-display,-neurosis-is-the -most-charming- ly y'rs, =g2 p.s. If anybody can explain to me any good reason why int() and string.atoi() aren't allowed to interpret "0x" (and, heck--maybe even "0X" ) without including the "base" argument, I'd sure be interested to know. -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From aleaxit at yahoo.com Wed Oct 11 05:48:24 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 11 Oct 2000 11:48:24 +0200 Subject: how do I register a local-server-only COM object in Python? Message-ID: <8s1dav02iog@news1.newsguy.com> The normal Python COM object registration procedures register both an in-process and local-server object. It would appear the latter is required for the former to work. How do I change things so that _only_ the local (i.e., out-of-process) server is registered? The need for this comes from having a COM server that needs to be shared among clients (system-unique), as per the sample 'shared-dictionary' I just posted, and use it from languages where I can't specify what kind of server I want (e.g., VBScript)... Alex From NOSPAM at pacificnet.net Thu Oct 19 20:40:39 2000 From: NOSPAM at pacificnet.net (Ian Lipsky) Date: Fri, 20 Oct 2000 00:40:39 GMT Subject: script delimiters Message-ID: If replying via email please replace NOSPAM with merk Right now (although i havent tried this) i think i should be able to create html files and put tags within the html to execute python code. What i wanted to know if there was someway to shorten this down to using delimiter characters? So i could do something like: <% if something: %> some html text saying something is true <%else:%> some html text saying something isnt true rest of my html Basically, i want to know if there is a way to have some python script pages that i could lay out similar to asp pages. Not sure if the scenario i listed aboe is possible given how indentation works in python. If replying via email please replace NOSPAM with merk thanks From dale at out-think.NOSPAMco.uk Sat Oct 28 05:22:21 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Sat, 28 Oct 2000 10:22:21 +0100 Subject: PythonWin IDE Rules! References: <7tuivs46osods22uumpvsvsap2jocrd4si@4ax.com> Message-ID: "Bill Wilkinson" wrote: >hmm. I don't really want to respond to this post as written, it is just too >vile and sad. > >Nonetheless, for those reading this thread, I want to point out that the >issue at hand is easy to work around, and indeed you will be missing out on >a wonderful tool if you don't take the time to learn how to use PythonWin. > > >Some points for everyone to note: > >In the module pywin.framework.scriptutils, there is a function called >GetActiveFileName that will return the full path of the file currently being >edited. Using the path you can write functions to execute your script any >way you want. > >You can map keys to run your functions by making a new cfg file in the pywin >directory. This is in the documentation. From the help menu choose >PythonWin and then look at "keyboard bindings". This is really sharp, and >I have had great fun with it. Almost as much fun as I have customizing VIM >;) . > >I use the debugger with a helper function that calls the current file in a >separate process. This all seems quite natural. > >My config files currently allow me to run my scripts in the following >ways(each has its own key bindings). >1. Within the current running version of pythonwin, but in its own name >space, and with some module clean up. I never have name space problems. >2. In a separate process using the debugger. >3. In a new console. > >Truly, if you use Python under Windows, give this further study, you will >realize that it is a great tool. Mark has consistently made improvements to >this app and it has become a really powerful tool. Combined with Scintilla >(Thanks Neil), the look of ones code can be spectacular both on screen and >on paper. > >Word has it that Mark has even more improvements on the horizon, but you >don't need to wait for them. Read the docs, browse the code, experiment. >You will be glad you did. > >Bill > Thanks for the pointers. I have saved this post for later when I get time to study it more closely. Have you changed PythonWin or just the cfg file? Does debugging in a separate process allow the use of breakpoints? I tried to add a Windows command to the tools menu and failed miserably. I gave up in the end. -- Dale Strickland-Clark Out-Think Ltd Business Technology Consultants From rcameszREMOVETHIS at dds.removethistoo.nl Sun Oct 1 19:54:40 2000 From: rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) Date: Sun, 01 Oct 2000 23:54:40 GMT Subject: [1.5.2] Buglet in Mailbox-module? References: <8FBFE5F1rcamesz@127.0.0.1> <8r3a8v$5c$1@panix2.panix.com> <8FC037529rcamesz@127.0.0.1> <8r7ope$ca6$1@panix2.panix.com> Message-ID: <8FC11705Crcamesz@127.0.0.1> Aahz Maruch wrote: >You don't have a Reply-To: header; you probably have Xnews >configured incorrectly. Oops! You're right; it should be fixed now, though. Sorry about that. Robert Amesz From r.b.rigilink at cable.a2000.nl Mon Oct 2 02:48:34 2000 From: r.b.rigilink at cable.a2000.nl (Roeland Rengelink) Date: Mon, 02 Oct 2000 08:48:34 +0200 Subject: help with popen, one-way IPC. References: Message-ID: <39D82FC2.F597FA54@cable.a2000.nl> Brian Alexander wrote: > > Hello; > > I have a program that might possibly be writing to stdout (not a python > program) and would like to use redirection in Python to collected the > output. I'm having a little trouble with the call to popen(), though. > > I thought it was this: > > otherapp_stdout = popen( "appname", "r") > > while otherapp_stdout.readline != "\n" > # do stuff with each line. > > Is this the right idea. Communication only needs to be one way. > > Many thanks in advance, > > Brian. Hi Brian, You're on the right track. There are basically two ways to do this. import os otherapp_stdout = os.popen( "appname", "r") lines = otherapp_stdout.readlines() # get all output at once for line in lines: print line or: import os otherapp_stdout = os.popen( "appname", "r") while 1: line = otherapp_stdout.readline() # get them one at a time if line == '': # an empty line means EOF break print line Because assignment is a statement, there is no result that can be used as a condition for while or if Note the difference between readlines() (returning a list of lines) and readline() (returning one line at a time). Also note that an empty line denotes end-of-file. Don't confuse a blank line (i.e. containing only the newline character '\n') for the empty line marking EOF Hope this helps. Roeland From wware at world.std.com Mon Oct 23 08:36:54 2000 From: wware at world.std.com (Will Ware) Date: Mon, 23 Oct 2000 12:36:54 GMT Subject: Python Formatted C Converter (PfCC) References: Message-ID: Gareth McCaughan (Gareth.McCaughan at pobox.com) wrote: > Find some > simple subset of Python... Write a > *translator* that turns this subset into C. That way, what > you're writing is more or less real Python; if you do this > right, you'll even be able to run the code in Python for > prototyping purposes... > ...even this probably > isn't worth the effort it would take... I've heard of people doing this sort of thing in Lisp/Scheme. This actually sounds like quite a valuable idea. One thing that would be quite helpful in constraining Python to make the translation easier would be to avoid dynamic typing, for instance by using some sort of Hungarian notation. I despise it as much as the next person, but it would be a convenient way to signal to the translator the type of a variable. Prefixes like "i", "u", "l", "f", "d" could stand for int, unsigned int, long, float, and double. When such a thing was assigned a constant value, it would be easy to check whether it fit within the range (oops, assigned a negative value to an unsigned int, flag a warning). Where Python allows lists, you probably want to declare fixed-length arrays of fundamental types or pointers. It would also be handy if the process of translation, compilation, and linking could all be controlled from within Python. It's possible within Python to get a parse tree for a function, which can be used for identifying blocks (translating indentation into braces), knowing where to declare variables, knowing their scope, etc. So the translator could take a function as an argument and return a string of C source code. The name might be mapped in some predictable way, e.g. "foobar()" might become "c_foobar()". Then it's not too hard to put a wrapper around it to turn it into a module, write it to a file, and call the compiler and linker. -- # - - - - - - - - - - - - - - - - - - - - - - - - # Resistance is futile. Capacitance is efficacious. # Will Ware email: wware @ world.std.com From josh at open.com Tue Oct 3 09:35:45 2000 From: josh at open.com (Joshua Muskovitz) Date: Tue, 3 Oct 2000 09:35:45 -0400 Subject: how do I listen on a socket without sucking up all the CPU time? References: <39d971f3_1@corp.newsfeeds.com> Message-ID: <39d9df0c_1@corp.newsfeeds.com> > Why is the socket set to non-blocking? Why not set it to > blocking so that the thread blocks until there's data to read? This is one of those "um" questions. The answer is "um, well, the prototype code I was given to start with set it to non-blocking." The only reason I can thing of is that a separate thread needs to be able to use the same socket to send requests (send and recv operate on the same socket in different threads), but this may not be a valid reason either. select.select worked great, but now I've got other problems, namely figureing out why I'm no longer catching the KeyboardInterrupt exception I used to be able to catch. - j -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From see at my.signature Fri Oct 27 00:41:18 2000 From: see at my.signature (Greg Ewing) Date: Fri, 27 Oct 2000 17:41:18 +1300 Subject: [Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich comparison References: <39EB3D03.A00C78B6@jps.net> <39F4A4DE.9202540A@udel.edu> <8t3ota028jv@news2.newsguy.com> <39F5AA7A.2C5E35CE@udel.edu> <8t4dl301a4@news2.newsguy.com> <39F6E187.52EB03BB@udel.edu> Message-ID: <39F9076E.5C7253E7@my.signature> Charles Boncelet wrote: > > the > right question to ask is "what do serious programmers want?" As a serious programmer, what I want is a straightforward and efficient way to specify the operation I want performed. Truncating and non-truncating division are very different operations, used for very different purposes. Which one I want depends on the algorithm I'm implementing. Whenever I write a division in my code, I know which one I want. But the only way I can tell Python which one to use is indirectly, by manipulating the types of operands I feed to the / operator. To me, this is so obviously wrong that I can't understand how any serious programmer could think it was right. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From sholden at holdenweb.com Thu Oct 26 22:03:15 2000 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 26 Oct 2000 22:03:15 -0400 Subject: Zope question: collaborative environments? References: <39F8C8EC.EB2DC75D@UTS.Itron.com> Message-ID: <39F8E263.C2A5825E@holdenweb.com> Tom Bryan wrote: > > I plan to search more in the Zope archives and maybe discuss this question > on one of their myriad of mailing lists or discussion boards, but I was > hoping that someone might have a quick answer. > > I'm a developer, and I'd like to create a combination discussion board, > bug tracking system, and general collaborative environment. I was > thinking of using Zope, but I have never even looked at Zope. Am I crazy > even to consider using Zope when we won't have any dedicated staff to > develop stuff for/in Zope and maintain it? Is Zope easy enough to use, > simple enough to maintain, and complete enough as a product that I could > get something set up with just a couple of weeks of work and then simply > use it? > > Any advice before I waste a lot of time digging into this topic would be > much appreciated. (The time frame is very tight. My boss is planning to > lend me one of his personal machines to play put on my network at home as > a zope or sourceforge or ??? server so that I can evaluate it next week. > He definitely wants something in place in the next few weeks.) > > ---Tom I might, tongue-in-cheek, suggest that you spend your time looking for a work environment where they don't set deadlines before they understand the scope of the task. If you find it, perhaps you'll let us all know. Good luck with the collaborative development environment! regards Steve -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ From where at there.com Thu Oct 19 08:07:16 2000 From: where at there.com (Someone) Date: 19 Oct 2000 12:07:16 GMT Subject: Calling Python from C++ Message-ID: <8smo5k$1s@dispatch.concentric.net> I'm looking for more information and examples of calling (or embedding) Python from C++ in a Win98 app. I have been to the www.python.org site, read the tutorials, read the Extension/Embedding doc, read the Python/C API doc, read the FAQ and looked over the referenced example in ../demo/embed. Is there more about embedding somewhere else? I'm especially looking for examples of how others made large lists of C++ objects availble to be read from the embedded Python routines. Thanks in advance for any suggestions. Eric From fidelman at world.std.com Tue Oct 24 09:34:12 2000 From: fidelman at world.std.com (Miles R. Fidelman) Date: Tue, 24 Oct 2000 13:34:12 GMT Subject: Python equivalent of CPAN (Was: ANY NEWS ON THE STARSHIP?) References: <8su1su$euq$1@nnrp1.deja.com> <39F47496.22449099@holdenweb.com> <8t1ur1$8jt$1@panix3.panix.com> <39F481E4.989093B6@holdenweb.com> Message-ID: Paul Moore (paul.moore at uk.origin-it.com) wrote: : On Mon, 23 Oct 2000 22:39:46 +0200, fidelman at world.std.com (Miles R. : Fidelman) wrote: : >Longer term, something like CPAN is going to be needed. : Complete with some form of standardised build process for modules, and : a standard installation structure. On Perl, I always build from source : - it's trivial, just perl Makefile.PL, nmake, nmake test, nmake : install. : This is close to being the killer distinction between Python and Perl : for me... it's even easier than that, if you have the cpan module installed: perl -MCPAN -e shell and then: install gets, makes, tests, and installs the module, and any missing modules that it depends on. The cpan module even checks and updates itself! I don't know how much easier it can get. This really is the killer distinction. (note: I don't even like perl that much as a language - I prefer to do my web programming in PHP - but as a collection of easy-to-find and easy-to-install facilities, perl and cpan beat everything else out there by a wide margin) From mksql at my-deja.com Fri Oct 27 14:05:45 2000 From: mksql at my-deja.com (Matt) Date: Fri, 27 Oct 2000 18:05:45 GMT Subject: PythonWin IDE sucks! References: <7tuivs46osods22uumpvsvsap2jocrd4si@4ax.com> <8tc42n$lm3$1@nnrp1.deja.com> <798jvs4p780j4m9n2pnddj4cti22gpn9pd@4ax.com> Message-ID: <8tcg5j$pt$1@nnrp1.deja.com> In article <798jvs4p780j4m9n2pnddj4cti22gpn9pd at 4ax.com>, dale at out-think.NOSPAM.co.uk wrote: > Matt wrote: > > >PythonWin is a tool for working with the Python language. The > >usefulness of the tool has no impact on the usefullness of the language. > > What nonsense. Of course it does. The usefulness of the language is > directly linked to how quickly you can churn out working code. The IDE > is a critical factor in this. Since using PythonWin is not a requirement to develop Python code, you can use any editor (as I do), there is no link between PythonWin and productivity in Python. Would you characterize the Java language as unusable if you did not care for Sun's development tools? Or C++ as useless if you experienced problems with Visual Studio? > > > >If my understanding is correct, the author of PythonWin has provided us > >a very useful editor and debugger for Python on the Windows platform, > >that currently can be used at no monetary expense. Given that this is > >not commercial software, and that it is a work inprogress, I would > >expect some bugs. Personally, I find the price/performance ratio quite > >acceptable. > On the whole, I agree. But if you don't point out poor features, they > won't get fixed. Correct. But often, obvious trolling ("sucks!") runs the risk of being ignored by those with serious goals in mind. If you have a legimate bug to point it out, make it known in a manner that will get your issue addressed seriously. > >> What can I do about it? > > > >Learn the language, and if you do not like the PythonWin tool, use > >another. > > If everyone who has, in the past, disliked a feature of Python went > elsewhere, I suspect the user community would be pretty small right > now. That isn't the way to improve software. This is not a Python feature discussion, but a discussion of a tool. There is a large distinction. To use the logic above, you would condem a language in wide use on multiple platforms, due to issues on a single platform. I use Python regularly, and began by using PythonWin to learn the language. I now do most of my Python development using another editor, because the editor is useful for other tasks. Therefore Python productivity can be attained without using PythonWin, even though I have found PythonWin to be very useful in some instances. ... > Why are you so defensive about this? I'm not attacking you, Python or > PythonWin. I'm pointing out a problem that I think needs attention. Since neither Python nor PythonWin is mine to defend, I am merely criticising your method of criticisim. Sent via Deja.com http://www.deja.com/ Before you buy. From olivierS.dagenaisP at canadaA.comM Fri Oct 20 14:35:54 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Fri, 20 Oct 2000 18:35:54 GMT Subject: sockets supported in jpython on solaris ? References: <8sq27u$jfg@slip.net> Message-ID: The 'dir' function doesn't print anything to the screen, it returns a list. Unless you typed this in the interactive window, try: import socket print dir ( socket ) ??? -- ---------------------------------------------------------------------- Olivier A. Dagenais - Software Architect and Developer "Someone called 'Type your name here' is impersonating me on the internet and is posting exactly the same things I am posting!" "Emmett McLean" wrote in message news:8sq27u$jfg at slip.net... > Hi, > > I tried the following script : > > import socket > dir(socket) > > and nothing happened. > > Thanks, > > Emmett > From aleaxit at yahoo.com Tue Oct 31 10:26:58 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 31 Oct 2000 16:26:58 +0100 Subject: C's syntax (was Re: Python Formatted C Converter (PfCC)) References: <8t0or303ee@news1.newsguy.com> <39F4FFB7.452EDDEC@alcyone.com> <8t3mdv025uo@news2.newsguy.com> <39F5B404.B5626FB7@alcyone.com> <8t4q8v11lpv@news1.newsguy.com> <39F5E620.C780A71C@seebelow.org> <8t6vj70spd@news1.newsguy.com> <39F73E41.C8EE143F@seebelow.org> <8t8sgn0ahc@news1.newsguy.com> <39F8985B.6909B5CF@seebelow.org> <8tbv0r01082@news1.newsguy.com> <39FB2080.D38CAD35@seebelow.org> <8tgpr201ipj@news1.newsguy.com> <39FE7EC7.89DC9747@seebelow.org> Message-ID: <8tmols025jf@news1.newsguy.com> "Grant Griffin" wrote in message news:39FE7EC7.89DC9747 at seebelow.org... [snip] > I hope you realize the non-applicability of your example. (If not, I No: it's a close analogy. If somebody _in good faith_ was truly unable to spot some of the obvious defects in C's syntax (this does not apply to you, see later), then clearly his or her command of it, and experience using and teaching it, would have to be quite scarce -- just like, I suspect, the Italian knowledge of the average reader of this newsgroup. > think there's a good chance the rest of us do. ) If, instead of If someone (again, someone _in good faith_) truly could not see the analogy's full applicability, I trust they now can. And I've seen posts from others, in direct answer to yours, clearly defending the relevance of my displaying my qualifications regarding C, in defense to baseless insinuations hinging on "not liking it" -- in a far more concise way than is my wont (you'll notice I _never_ claim concision as one of my strong points). > tangentializing about Italian, Not a 'tangent' (quite differently from your repeated attempts at introducing meta-themes about 'bragging'...), but rather a strict analogy. > you were to make any well-reasoned and > insightful points about failings in C's syntax (any at all: honestly, we > get more curious each time you dodge the question!) then there's a very Far from "dodging the question", I have repeatedly answered it, making several "points about failing in C's syntax". See, for example: http://x58.deja.com/getdoc.xp?AN=685615011 http://x58.deja.com/getdoc.xp?AN=685727921 You replied to the latter message, for example, completely failing to answer any of the points I had raised, but rather reiterating the feeble attempts at humour that appear to be your hallmark, as well as advancing your first attempt to sidetrack the discussion into a metadiscussion about 'bragging'. That specific attempt having failed, you insisted in that purpose, apparently trying to drive the theme *away* from C syntax; and now, 6 days later, you claim I "dodge the question" of specific points on C's syntax?! It's been a while since I stopped crediting you with being in good faith -- I just hope your obvious dishonesty can become as clear to other readers as it is to me (what is your motive, I could not care less about; like any other culprit of wilful misbehaviour, you're surely quite able to rationalize some excellent-to-yourself justification; at this point, though, it's only _other_ readers, people of good faith, that are of any interest to me). I don't claim my points are 'well-reasoned and insightful', I claim, rather, that they are _completely obvious_ to any sensible person. Dennis Ritchie, inventor of C, an _eminently_ sensible person, does NOT try to 'defend' many of these peculiarities of C's syntax -- he accepts they're flaws, and _explains_ the historical accidents and mistakes that ['thanks' to the inevitable need of keeping backwards compatibility] led to such flaws being in the language's syntax. > good chance that most everyone here would understand (if not agree.) > The reason is that nearly all of us here speak Italian...er, I > mean..."C". So, to repeat one example, you claim to be SO deliriously happy that if(a&3==3) does not test whether a has both lowest bits set, but just the _single_ lowest bit, that you can't even *understand* somebody (e.g., Dennis Ritchie -- or, me) considering this aspect of C's syntax a DEFECT...? > p.s. I'm really impressed with that stuff about co-authoring with a > prominent Italian linguist, but I'm still gonna say that when I helped > Al Gore invent the Internet, that was even cooler. Please see, e.g., the Korpuslinguistik at: http://www.uni-duisburg.de/FB3/ROMANISTIK/PERSONAL/Burr/corpus/biblio.htm Your reference for your contribution to Mr Gore's "invention"...? Alex From dcalvelo at pharion.univ-lille2.fr Mon Oct 2 06:17:39 2000 From: dcalvelo at pharion.univ-lille2.fr (Calvelo Daniel) Date: 2 Oct 2000 10:17:39 GMT Subject: Reg Exp: Need advice concerning "greediness" References: <8r4om7$9bd$1@newsreaderm1.core.theplanet.net> Message-ID: <8r9nc3$8re$1@netserv.univ-lille1.fr> Franz GEIGER wrote: : Hello all, : I want to exchange font colors of headings of a certain level in HTML files. : I have a line containing a heading level 1, e.g.:

Heading Level 1

. : Now I want to split this into 3 groups: Everything before "COLOR=xyz", : "COLOR=xyz" itself, and everything after "COLOR=xyz". : I tried: : sRslt = "

Heading Level 1

"; : print re.findall(re.compile(r'(.*?FONT.*?)(COLOR=.*?)*([ |>].*)', re.I | : re.S), sRslt); Beware of quotes in your example: >>> sRslt = "

Heading Level 1

" >>> sRslt '

]+?)(COLOR=.*?)?([ |>].*)', re.I | re.S), sRslt); [('

Heading Level 1

')] I used a negated character class to force an end for the first group before a cpossible COLOR tag. Otherwise, what I think is happening is that your non-greedy search is indeed non-greedy, but the null-match of '(COLOR=.*?)*' is included into it. BTW, I changed that '*' to '?', which is what you meant, if I read correctly. HTH, DCA -- Daniel Calvelo Aros calvelo at lifl.fr From max at alcyone.com Sun Oct 22 03:33:49 2000 From: max at alcyone.com (Erik Max Francis) Date: Sun, 22 Oct 2000 00:33:49 -0700 Subject: Python Formatted C Converter (PfCC) References: Message-ID: <39F2985D.F00AD9E0@alcyone.com> Alex McHale wrote: > That is *basically* the way it goes, as it stands. The aim is to > eventually be able to code something like this: > --- > def main( ): > int x, y = 2, 3 > int w,z > w,z = 4,5 ... > --- > You get the idea. The def call will probably be used - as an aide > in > prototyping. This is an extremely bad idea. Python is not C, and C is not Python. Trying to make one look like the other defeats the purpose of either. Pray tell, how do you declare a "PythonC" function as returning a value of a particular type? You have to be able to do it, and pretending like C can be recast into Python ignores that fact. C and Python are quite different languages. Don't try to make them the same, because you are setting yourself up to fail. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Think twice before you speak to a friend in need. \__/ Ambrose Bierce Product's Quake III Arena Tips / http://www.bosskey.net/ Tips and tricks from the absolute beginner to the Arena Master. From tdelaney at avaya.com Mon Oct 30 17:58:44 2000 From: tdelaney at avaya.com (Delaney, Timothy) Date: Tue, 31 Oct 2000 09:58:44 +1100 Subject: CPython vs. Jython/JPython Message-ID: > Java isn't necessarily slower than C. (I should expand that > a little: Java *apps* aren't necessarily slower than C > *apps*) There was an article published in the October 2000 Oh - I know that. I've pushed Java for that very reason at some contracts. However, it is a fact that JPython is considerably slower than CPython on the same platform (don't have any stats to back me up here though ...). Jython is at the moment probably fairly similar. Tim Delaney Avaya Australia From tyler at tylereaves.com Sun Oct 22 20:31:31 2000 From: tyler at tylereaves.com (Tyler Eaves) Date: Mon, 23 Oct 2000 00:31:31 GMT Subject: How to get file uploading to work in cgi? Message-ID: <39f385e1.31879927@news.geeksnet.com> Here is my code: if formokay==1: thefilename='' theauthor=form['author'].value print theauthor for x in string.split(theauthor)[:]: thefilename=thefilename+string.lower(x) thefilename=thefilename+form['filename'].value+'.rcd' out=open('/home/ultracoa/ultracoastercentral-www/'+thefilename,'wb') track=form['thetrack'] print track out.write(track.file.read()) out.flush() out.close() here's the problem. In my form I used: But how come it returns the file name? Here is a sample trace back (I have sys.stderr redirect to stdout) test Tyler Eaves MiniFieldStorage('thetrack', 'C:\\Program Files\\Reactor Software\\Ultra Coaster\\coasters\\darkabyss.rcd') Traceback (innermost last): File "uccsubmit.py", line 37, in ? out.write(track.file.read()) AttributeError: 'None' object has no attribute 'read' If anyone wants to see the form, it is at http://www.ultracoastercentral.com/cgi-bin/ucc.py?submit Also, because I was bored, I changed my whole website to a Python CGI :) --- Tyler Eaves Visit Ultra Coaster Central! The internet's largest repository of Ultra Coaster Tracks! http://www.ultracoastercentral.com -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From ecastro at cicei.ulpgc.es Tue Oct 10 12:38:16 2000 From: ecastro at cicei.ulpgc.es (Enrique) Date: 10 Oct 2000 16:38:16 +0000 Subject: Where is wxPython? Message-ID: <39E33757.E9F81F9C@cicei.ulpgc.es> Hi: I have tried to download wxPython 2.2.1 from SourceForge (file wxPython-2.2.1.EXE), but the file is not accesible (in fact no one file in the site is downloadable) Where else can I find wxPython 2.2.1? Thanks Enrique Castro From TBryan at UTS.Itron.com Fri Oct 27 13:55:02 2000 From: TBryan at UTS.Itron.com (Tom Bryan) Date: Fri, 27 Oct 2000 13:55:02 -0400 Subject: The starship returns ... References: <39F9AFAC.151D0C0F@holdenweb.com> Message-ID: <39F9C176.9D897CD1@UTS.Itron.com> I heard that we should be receiving some official news about what's been going on with the Starship soon. ---Tom From aahz at panix.com Thu Oct 12 17:52:20 2000 From: aahz at panix.com (Aahz Maruch) Date: 12 Oct 2000 14:52:20 -0700 Subject: Synchronizing CGI processes? References: Message-ID: <8s5bqk$m0h$1@panix3.panix.com> In article , Olivier Dagenais wrote: > >I am writing a client-server system in Python and the only free >Python-supporting internet server I can find supports Python as CGI scripts. >(Incidentally, if you know of any free hosting solutions that would allow me >to host a server written in Python with say, Medusa please say so!) The >multiple independent process nature of CGI is the source of a very puzzling >synchronization problem: how on earth can I guarantee synchronization >between two (or more) concurrent CGI sessions? (I need to synchronize >writes to a simple, one-user database... I'm using "Gadfly" for the >curious...) Hmmmm.... I'd call this a "locking" problem rather than a "synchronization" problem. And you're right: there are few good cross-platform mechanisms for this. Here's a question: does your service permit you to run a stand-alone process? If so, make that a socket-based database server. This would also make your code run generally faster. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Isn't it interesting that the same people who laugh at science fiction listen to weather forecasts and economists?" -- Kelvin Throop III From dale at out-think.NOSPAMco.uk Tue Oct 3 09:18:18 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Tue, 03 Oct 2000 14:18:18 +0100 Subject: Global Module Index Message-ID: Is it me, or has the Global Module Index vanished in 1.6? Dale Strickland-Clark Out-Think Ltd Business Technology Consultants From rodsenra at correionet.com.br Mon Oct 30 18:37:44 2000 From: rodsenra at correionet.com.br (Rodrigo Senra) Date: Mon, 30 Oct 2000 21:37:44 -0200 Subject: CPython vs. Jython/JPython References: <9BfL5.14315$w6.6473179@news3.rdc1.on.home.com> <20001030095524.D5375@dman.rh.rit.edu> Message-ID: <39FE0648.3D096458@correionet.com.br> D-Man wrote: > > Java's implementation (from Sun) is proprietary. However, you can get a compiled version for free. > > There are also other implementations (gcj allows compiling to native machine code, kaffe provides a bytecode compiler and VM -- for Linux at least > In addition to the excellent arguments already presented, CPython can be built on solid ground (C is *stable*). A exclusively Python implementation over non-proprietary JVM (like kaffe, gcj,etc) could mean builting it over moving sands. I stress my respect for those efforts, nevertheless they are miles away from C's stability. IMHO, such a decision (strict Python/Java impl.) could force us to stop developing Python itself to work *hard* in the underground. ,/\/\/\p BTW : To whom this might interest, some brazilian snakes names for you to name your python projects: (sucuri,coral,anaconda,gib?ia,cascavel... last but not least p?ton) ;o) -- Rodrigo Senra Home Page: http://www.ic.unicamp.br/~921234 rodsenra at correionet.com.br (OU|or) Rodrigo.Senra at ic.unicamp.br Engenheiro de Computa??o @ GPr Sistemas Ltda http://www.gpr.com.br Mestrando (MSc Student) IC - UNICAMP Tema: Reflex?o Computacional From bkhunter at best.com Tue Oct 10 14:31:45 2000 From: bkhunter at best.com (Bill Hunter) Date: Tue, 10 Oct 2000 18:31:45 GMT Subject: Is this a dream or a nightmare? (Was Re: XML) References: <39d1d3b2.43465571@news.telus.net> <39D19EBB.ABF18F23@engcorp.com> <39def2ae.8929692@news.davesworld.net> <39dfabb5.27391600@news.davesworld.net> Message-ID: I paid for Code Magic. Installed it. Gave it a quick test drive ... not any kind of fair evaluation, mind you ... it didn't work its way into my day to day toolkit. The version I got was pretty Perl-oriented and I was hoping for (expecting?) something that had a Python flavor to it. A real IDE for Python would be wonderful. No criticism implied of IDLE or PythonWin - I'd just like to wake up some morning and find something that didn't make my VB-centric colleagues roll their eyes. And sure, I'd pay some money for it. Bill On Sat, 07 Oct 2000 23:23:04 GMT, pete at petes-place.com (David T. Grove) wrote: >Anyway, let's get off that subject. I have another issue or two that I >need some help with. I need to determine the future of CodeMagic >itself. Just a quick question before I bring it up... how many of you >actually use it? From coursesm at sbdhcp-4022.statenisland-ny.est.tcg.com Mon Oct 9 09:44:08 2000 From: coursesm at sbdhcp-4022.statenisland-ny.est.tcg.com (Stephen Coursen) Date: 9 Oct 2000 13:44:08 GMT Subject: Zope tag nesting madness! References: <8rrt4i$f05$1@nnrp1.deja.com> Message-ID: On Mon, 09 Oct 2000 07:46:26 GMT, noahspurrier at my-deja.com wrote: >Hello, > >How do I nest tags inside of tags? > >In general I want to pass an to a ZSQL Method, >but must be an INTEGER. This syntax will not work: > )"> >The manager editor will compain about this and will not even let me >submit this change. I get this error: > invalid syntax > , for tag )">, > >The problem here is that I have to pass id as an INTEGER. The editor >will accept this syntax: > >but article_id is NOT a string, so the database complains if >I try to run it with this syntax. Essentially it seems like I can >only do this if I want to pass my parameters as strings. >How do I pass integers? > Try: ... Within the quotes, you can enter valid Python code, such as variable references, without resorting to using DTML tags. HTH, Steve Coursen [snip] From loewis at informatik.hu-berlin.de Tue Oct 3 11:25:50 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 03 Oct 2000 17:25:50 +0200 Subject: compilation of python? References: Message-ID: Mohammed Ennasar writes: > Thanks in advance. You don't ask a question, or for help... I assume your question is: Is that a problem? Should I do anything about it? Without further details, I'd say: probably no; just go ahead and install Python. If you feel uncomfortable about that advice, you should give more details: what operating system, what python version? You may want to run test_popen2 separately, to see exactly what test failed, and post information about that. Regards, Martin From paul.moore at uk.origin-it.com Tue Oct 24 05:11:10 2000 From: paul.moore at uk.origin-it.com (Paul Moore) Date: Tue, 24 Oct 2000 11:11:10 +0200 Subject: Python equivalent of CPAN (Was: ANY NEWS ON THE STARSHIP?) References: <8su1su$euq$1@nnrp1.deja.com> <39F47496.22449099@holdenweb.com> <8t1ur1$8jt$1@panix3.panix.com> <39F481E4.989093B6@holdenweb.com> Message-ID: On Mon, 23 Oct 2000 22:39:46 +0200, fidelman at world.std.com (Miles R. Fidelman) wrote: >Steve Holden (sholden at holdenweb.com) wrote: >: Aahz Maruch wrote: >: > >: Longer term, mirroring is going to be essential if Python is to >: dominate the world effectively. It certainly would have helped in >: the current situation. > >Longer term, something like CPAN is going to be needed. Complete with some form of standardised build process for modules, and a standard installation structure. On Perl, I always build from source - it's trivial, just perl Makefile.PL, nmake, nmake test, nmake install. And I know exactly where all the "bits" go on install, because it's standardised, and every module conforms. The same needs to be true of Python modules. I have an intense dislike of packages which are a pain to build from sources, and which come with mysterious binary installers which could, and often do, scatter things everywhere. Keep out of my registry, and don't put things in my SYSTEM(32) directory! Even if you uninstall cleanly, that's not enough... This is close to being the killer distinction between Python and Perl for me... Paul. From aleaxit at yahoo.com Mon Oct 30 09:44:33 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 30 Oct 2000 15:44:33 +0100 Subject: __getitem__ AttributeError References: <39FD86B3.E13ABF1E@savaco.com> Message-ID: <8tk1qh05aa@news1.newsguy.com> "Jeroen Valcke" wrote in message news:39FD86B3.E13ABF1E at savaco.com... > In python I call a method of a selfdeclared class and I keep getting the > error: > H:\progs\python>python listslides.py > Traceback (innermost last): > File "listslides.py", line 18, in ? > for slide in slidelist: > AttributeError: __getitem__ > > What am I doing wrong? You are trying to iterate over a slidelist.Slidelist instance in a for statement, at line 18 in listslides.py: > for slide in slidelist: and class Slidelist does not define a __getitem__ method, so its instances cannot be indexed with [] nor iterated on with for. If I understand your intentions correctly, the __getitem__ method you may need in the Slidelist class may be one that just delegates to the self.slidelist attribute of the instance (you _are_ naming *quite a few* disparate things "slidelist", here, aren't you...?), i.e.: class Slidelist: def __init__(self): self.slidelist = [] def __getitem__(self, index): return self.slidelist[index] # etc, rest of class snipped Alex From sabren at manifestation.com Fri Oct 6 11:08:06 2000 From: sabren at manifestation.com (Michal Wallace) Date: Fri, 6 Oct 2000 11:08:06 -0400 (EDT) Subject: Proposal: Python Class Files Message-ID: Proposal for a Python Enhancement Proposal: Python Class Files A common python practice is to create modules with one class each. This is especially true when building multi-file packages. This practice makes for maintainable code, but causes some small irritations for the developer, because imported classes are wrapped in a module you don't need. ### somepackage/__init__.py #### # three ways of importing classes into a package: from Class1 import Class1 import Class2 # Class3 is defined in Class3.py, but not imported ### a calling script: import somepackage obj1 = somepackage.Class1() # works, but returns somepackage.Class1.Class1 try: obj2 = somepackage.Class2() # Error except: obj2 = somepackage.Class2.Class2() try: obj3 = somepackage.Class3() # Error except: obj3 = somepackage.Class3.Class3() ####### That internal module is ugly... If you want to get rid of it, you have to either write some sort of lazy-loading facility or put a bunch of "from X import X" lines in your top level package, which makes python do more work than it really needs to. What I'd suggest instead is adding an import hook for modules that contain only one class. Basically, if the file is called Class1.pc then "import Class1" creates a new class, not a module. Class files would work like this: 1. Each class file contains one and only one class. 2. The class name must match the filename (minus the .pc extension) 3. All statements in the file must be inside the class definition. 4. Class files may be run directly via "python Class1.pc". In this case, python looks for a __main__ method. This replaces the "if __name__=='__main__'" idiom for these files. 5. When class files are imported, the class is defined in the calling namespace. 6. Calling "from package import *" would import all the classes defined in .pc files, EXCEPT classes beginning with an underscore. 7. Calling "import package" would import all class files into the package namespace. One alternative for 7 might be to load stubs of a new type called "ClassFile", which would allow for lazy loading and might improve speed. When you instantiate a ClassFile, only then does it read the actual file. #### Some modules are designed to work like singleton objects. (For example, asyncore). I believe modules in general should behave more like instances. This proposal is NOT meant to cover these situations. I'm talking about importing classes, not instances here. What do y'all think? Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From paulb at infercor.no Thu Oct 12 04:53:57 2000 From: paulb at infercor.no (Paul Boddie) Date: Thu, 12 Oct 2000 10:53:57 +0200 Subject: Python Server Pages alternative References: <8s1hbl$j9s@staff.cs.usyd.edu.au> Message-ID: <39E57C25.5D2F1D6D@infercor.no> Bob Kummerfeld wrote: > > The "Python Server Pages" project looks interesting but if you want a > simpler but still powerful package to do similar things I suggest "Poor Man's > Zope" or PMZ. You can find it in the Vaults of Parnassus. There are lots of different modules/packages/frameworks doing similar things. Take a look at: http://www.paul.boddie.net/Python/web_modules.html Yes, PMZ is there! Regards, Paul From hwanjoyu at uiuc.edu Mon Oct 2 22:22:10 2000 From: hwanjoyu at uiuc.edu (Hwanjo Yu) Date: Mon, 2 Oct 2000 21:22:10 -0500 Subject: Q: saving data made in interactive window Message-ID: Hi, I have made some functions and saved some values in some variables in interactive command. How can I see all the codes and variables that I made and saved values ? And How to save those codes and variables to a file ? Thanks. From fredrik at effbot.org Mon Oct 30 12:52:58 2000 From: fredrik at effbot.org (Fredrik Lundh) Date: Mon, 30 Oct 2000 17:52:58 GMT Subject: Passing tuples transparently as function parameters (like for Threads) References: Message-ID: <_ziL5.3151$QH2.299923@newsb.telia.net> David Perry wrote: > Hey all! This may be an RTFM, but if it is, please point me at > the right FM. (: how about checking the FAQ? http://www.python.org/doc/FAQ.html#4.31 How do I call a function if I have the arguments in a tuple? Use the built-in function apply(). ::: for the full story on apply, see the fine manual: http://www.python.org/doc/current/lib/built-in-funcs.html in 2.0, you can also use syntactic sugar: func(*args, **kw) is the same thing as apply(func, args, kw). From jon+python-list at unequivocal.co.uk Wed Oct 25 07:18:56 2000 From: jon+python-list at unequivocal.co.uk (Jon Ribbens) Date: Wed, 25 Oct 2000 12:18:56 +0100 Subject: [Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich comparison In-Reply-To: ; from hinsen@cnrs-orleans.fr on Wed, Oct 25, 2000 at 10:56:00AM +0200 References: <39EB3D03.A00C78B6@jps.net> <39F4A4DE.9202540A@udel.edu> <8t3ota028jv@news2.newsguy.com> <39F5AA7A.2C5E35CE@udel.edu> <8t4dl301a4@news2.newsguy.com> Message-ID: <20001025121856.A13593@snowy.squish.net> Konrad Hinsen wrote: > What we are discussing here is not whether you should use floating > point, but what the most reasonable interpretation for a certain > syntax is. Yes, which is the question I was addressing. '/' should not produce a floating point value unless it is given a floating point value to operate on, for the reasons I gave in my previous posting. Cheers Jon From jcm at bigskytel.com Tue Oct 24 21:27:00 2000 From: jcm at bigskytel.com (David Porter) Date: Tue, 24 Oct 2000 19:27:00 -0600 Subject: Spam be gone In-Reply-To: ; from j-morgan@gol.com on Wed, Oct 25, 2000 at 10:24:09AM +0900 References: Message-ID: <20001024192700.A6282@bigskytel.com> * Jack Morgan : > Why does this list include so much spam? Maybe, one a day. In fact, I do > enjoy reading this list,but i don't enoy reading all that spam. The mailing list is linked to the newsgroup comp.lang.python. It is easy to stop spam on mailing lists by only allowing mail from those subscribed, but usenet is open to anyone. From junaftnoon at nospamplzyahoo.com Fri Oct 20 17:03:33 2000 From: junaftnoon at nospamplzyahoo.com (June Kim) Date: Sat, 21 Oct 2000 06:03:33 +0900 Subject: compiling Python-2.0 on SunOS Unix machine Message-ID: <8sqbvl$o55$1@news.nuri.net> when testing the installation with "make test", I got one CRASH: test_pwd test test_pwd crashed -- exceptions.IndexError: list index out of range What is the problem? From mjackson at wc.eso.mc.xerox.com Fri Oct 13 11:51:45 2000 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 13 Oct 2000 15:51:45 GMT Subject: How can i remove a scalar References: <39E7251D.C93C76D4@hotmail.com> Message-ID: <8s7b2h$dch$1@news.wrc.xerox.com> joonas writes: > How can i empty a scalar. > In perl it would be > > delete($myscalar); How can I impress upon someone that he or she really ought to read the basic documentation rather than posting a series of trivial questions? On comp.lang.perl.misc it would be READ THE @#$%ING MANUAL YOU @#$%ING @#$%ER but we're much more polite here. . . :-) -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson I respect faith, but doubt is what gets you an education. - Wilson Mizner From jay.krell at cornell.edu Mon Oct 2 01:37:00 2000 From: jay.krell at cornell.edu (jay.krell at cornell.edu) Date: Sun, 1 Oct 2000 22:37:00 -0700 Subject: Import libraries and Borland C (Was: Wholly unnecessary flame.) Message-ID: <021201c02c32$caa63110$0101a8c0@jayk3> -----Original Message----- From: Martin von Loewis To: jay.krell at cornell.edu Cc: python-list at python.org Date: Sunday, October 01, 2000 11:46 AM Subject: Import libraries and Borland C (Was: Wholly unnecessary flame.) >> Oh, there is also the question of "ABI", how the compiler layouts out... > >It seems that you are right in the "general" case. In the specific >case of Borland C++ builder... > >As a Unix person, I feel the entire concept of import libraries is >flawed... You're mostly right. The import libraries are a little useful though, to seperate your "build environment" from your "installed environment". They let the list of stuff you can link against be different than the stuff you happen to have exported on your system. Import .libs can omit "private" exports. Import .libs can contain stuff from newer versions (like doing Win2k development on Win95). Import .libs can munge the names slightly, like between _CreateFileA at 20 and CreateFileA. I should just be able to point the linker to %windir%\system32\kernel32.dll though, at least optionally. It'd be equivalent to dumping the exports into a .def file and making an import .lib out of that, which is easy and a surprisingly little known technique. People think the import .libs are so magic and that they are stuck if they aren't provided -- even forgetting about LoadLibrary/GetProcAddress -- you don't need import .libs at all. The pre-VC6 import .lib format also implies that originally surprisingly very little work was done to support .dlls directly in the linker, but rather the work was moved into lib. Today lib and link are the same -- look at the size and imports of lib.exe, dumpbin.exe, editbin.exe. Identical small size, very few imports, including spawn. They are just stubs that run link.exe. >But then, even *if* Borland C could link with the VC++ compiled >python20.dll, you still could not build extension modules with >it. python20.dll uses stdio, and that comes from >msvcrt40.dll. However, Borland C has a different implementation of >stdio. Opening a file with the Borland function, and passing that >(through python.dll) to a Microsoft function causes a crash. It shouldn't be hard to point Borland C at the VC stdio headers and msvcrt.dll, but I don't actually know. This isn't a problem of differing compilers/linkers but of there being no one stdio on the platform with a frozen binary interface. Even Microsoft gives you three -- libc, libcmt, msvcrt.lib.. Like Bruce Dodson later said, just don't pass FILE* across .dll boundaries. Likewise there's no guarantee of being able to delete/free new or malloced memory across .dll boundaries. At least not w/o specifying and making available functions to work with them. Or drop down to something more guaranteed, like CoTaskMemAlloc and CreateFile. - Jay From glenfant at nospam-e-pack.net Tue Oct 10 06:13:12 2000 From: glenfant at nospam-e-pack.net (Gilles Lenfant) Date: Tue, 10 Oct 2000 12:13:12 +0200 Subject: List of running processes Message-ID: <8rupu6$5es$1@reader1.imaginet.fr> Hi, Does any of U know how to get a list of the running processes (something like "ps -u 0") that has an identical interface under Unix and Windows. I did not find anything for this in the "os" package! Any hint welcome. Gilles Lenfant From akuchlin at mems-exchange.org Tue Oct 24 14:36:21 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 24 Oct 2000 14:36:21 -0400 Subject: Another re question References: <972336131.124972@fezzik.endicor.com> <39F4DB27.A8F09D53@cc.gatech.edu> <972411030.904033@fezzik.endicor.com> Message-ID: <3dy9zeulwa.fsf@kronos.cnri.reston.va.us> kent at tiamat.goathill.org (Kent Polk) writes: > >>> findpid_pat = r'\012+\d |0*\w*[\t, ]+([\w ]+)' > I don't understand how a empty string matches in this last >case. Separately they are: > > >>> findpid_pat = r'\012+\d *\w*[\t, ]+([\w ]+)' > >>> findpid_pat = r'\012+0*\w*[\t, ]+([\w ]+)' Oh no they're not; they're '\d ' and '0*\w*[\t, ]+([\w ]+)'. '|' has lower precedence than concatenation, so everything after the | is in the second branch. Try: findpid_pat = r'\012+(?:\d |0*)\w*[\t, ]+([\w ]+)' (How I caught this: by uncommenting the p.dump() commend in Lib/sre_parse.py. It would be nice to have a way to request a dump of the bytecode for an SRE pattern.) --amk From dalke at acm.org Fri Oct 27 16:08:45 2000 From: dalke at acm.org (Andrew Dalke) Date: Fri, 27 Oct 2000 14:08:45 -0600 Subject: Compiling Python on multiple platforms... References: Message-ID: <8tcnd3$34r$1@slb7.atl.mindspring.net> Bjorn Pettersen asked: >Question 2: Are there any of the above platforms where readline doesn't >work? No problems on Solaris, IRIX or Linux. >Question 3: Are there any of the above platforms where Tkinter doesn't >work? (is this a separate install?) Again, no problems. You do need to install Tcl/Tk for Solaris and IRIX, but it usually comes default on Linux machines. >Question 4: Are there any of the above platforms where PIL doesn't work? Again, no problems. Andrew dalke at acm.org From aleaxit at yahoo.com Mon Oct 9 09:56:06 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 9 Oct 2000 15:56:06 +0200 Subject: doubling slashes in a string References: <39de8a48_3@corp.newsfeeds.com> <8rmvbo02dfo@news1.newsguy.com> <8rs9dc0143f@news2.newsguy.com> Message-ID: <8rsj3p01hhs@news2.newsguy.com> "Remco Gerlich" wrote in message news:slrn8u3i4t.fgl.scarblac at pino.selwerd.nl... > Alex Martelli wrote in comp.lang.python: > > Whoops! You're right. I had never noticed this lexical peculiarity, > > and now I wonder about the rationale for it -- since backslashes play > > no special role within a rawstring, why the peculiarly specific prohibition > > about having an odd number of them _at the end_...? > > They still have a special role - they escape quotes. r"\"" still needs > to be equal to '"'. If r"\"" really needs to be equal to '"', then we're in serious trouble, at least in Python 2.0: Python 2.0b2 (#6, Sep 26 2000, 14:59:21) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. IDLE 0.6 -- press F1 for help >>> r"\"" '\\"' >>> i.e., r"\"" rather seems to be equal to \\\". Still, you're right, that quote IS playing a role -- it inserts itself in the string AND also inserts the following quoting-character (while, without the \, said following quoting-character would otherwise terminate the rawstring). Whether it "should" do either or both things is moot, it definitely IS doing them both. > As a consequence, a single \ at the end of a raw > string always escapes the quote, so the string isn't closed. Yep, pretty clear now. > > Oh well, then I guess my above-quoted suggestions will have to be reworded: > > > > newname = oldname.split('\\').join(r'\\') > > newname = oldname.replace('\\', r'\\') > > Note that if he's doing things with pathnames on Windows, it might > be a lot easier to use / instead of \ to start with (that works). I think the original poster explained that he needs to prepare a string to be passed to another program (dunno if by system, popen, or what else), so he *cannot* assume that / will work just the same as \ (on the commandline of many DOS and Windows programs, the equivalence does not hold). I guess the doubling is what he needs to protect the backslashes from one level of stripping (whoever may be doing that...). Alex From donn at oz.net Thu Oct 5 01:25:14 2000 From: donn at oz.net (Donn Cave) Date: 5 Oct 2000 05:25:14 GMT Subject: imaplib & except References: Message-ID: <8rh3bq$eej$0@216.39.151.169> Quoth "BSD UNIX" : ... | I'm trying to talk to an IMAP server using imaplib. I can not figure out | how to catch an exception on the initial request. | | I know once a connection is established that "except .error" will | work, however if the initial request never succeeds, then the is | never created--so how do I catch the exception? The error is really an attribute of the class. As such, it's effectively an attribute of the instance as well, but you can use it directly from the class. E.g., try: imap = imaplib.IMAP4('testhost') except imaplib.IMAP4.error: print 'caught' It's a shame that the error displays as 'imaplib.error', that looks to me like a kind of defect in the way exceptions are implemented in general. Donn Cave, donn at oz.net From kthangavelu at earthlink.net Tue Oct 17 03:57:20 2000 From: kthangavelu at earthlink.net (Ender) Date: Tue, 17 Oct 2000 07:57:20 GMT Subject: Web Development References: <8qloh6$djs$1@nnrp1.deja.com> Message-ID: In article <8qloh6$djs$1 at nnrp1.deja.com>, "Charles Medcoff" wrote: bobo is the old object database that underpins zope you can find more about zope at zope.org it includes xml abilities, rdbms integration and much more > > I've just read Richard Jones paper from the HOWTO's on Bobo and Medusa. > I've downloaded Medusa but cannot seem to find Bobo. Does this still > exist and if so how do I get it? > > The link for bobo_handler.py is also not working. Is this still > available? > > Any other suggestions greatly appreciated. > > Regards, Chuck From paul.robinson at businesscollaborator.com Thu Oct 12 10:14:04 2000 From: paul.robinson at businesscollaborator.com (Paul Robinson) Date: Thu, 12 Oct 2000 15:14:04 +0100 Subject: 2.0c1 zipfile problem References: <39E5C16D.584F96D2@holdenweb.com> Message-ID: <39E5C72C.CD19B2E7@businesscollaborator.com> Steve Holden wrote: > > z.close How about z.close()? The 2.0 docs say "You must call close() before exiting your program or essential records will not be written". Paul Robinson Business Collaborator Development Manager Enviros Software Solutions WWW: http://www.businesscollaborator.com From wolfson at midway.uchicago.edu Sun Oct 1 22:52:28 2000 From: wolfson at midway.uchicago.edu (Ben Wolfson) Date: Mon, 02 Oct 2000 02:52:28 GMT Subject: "CPAN" SIG? References: Message-ID: In article , Mike Fletcher wrote: >Alternatives: > > PANC[ake] (Python Archive Network, Comprehensive -- all known >extensions) > (Out of the) Coding-PAN (into the compiler) > PythAN (use a flat southern "an" for the AN) > PyAN (pronounce as Pie-an, or even Pain, I suppose) > PytAN (pittan) > Dist-sys (carrying on from dist-utils) PAIN: Python Archive International Network. -- Barnabas T. Rumjuggler's page of dumbth: members.home.net/rumjuggler puto deus fio. -- Vespasian, last words From schorsch at schorsch.com Wed Oct 25 07:26:52 2000 From: schorsch at schorsch.com (Georg Mischler) Date: Wed, 25 Oct 2000 11:26:52 GMT Subject: os.system limitations on Windows NT References: <39F6A9CE.80407@cms.tecmath.de> Message-ID: <8t6g1o$21i$1@nnrp1.deja.com> Markus Kohler wrote: > Hi, > I trying to execute a command with a large list of arguments. > When I do os.system("link " + args) the program crashes. > When I write the arguments to a file (fileName) and use > > os.system ("link @" + fileName) > > the arguments are truncated at an arbitrary point. > > I'm using Python 1.5.2 > > Anyone knows a workaround/solution for this > problem ? os.system() starts a command shell to interpret the arguments and then pass them to the actual program you told it to call. Windows shells, such as command.com for Win9x and cmd.com for NT/w2k, have an arbitrary limit on the lenght of argument lists. As long as you can't avoid the use either os.system() or os.popen(), there's no easy way around the problem.  A possible workaround might be to pass some of the arguments in the form of environment variables (which again have limits of their own), or just shorten the arguments in some other way. All those limits are defined in terms of a maximum number of chararcers, though I don't remember the exact values. Note that unix shells may have similar limits, but the acceptable sizes are usually much bigger there. The "correct" solution would be to use Mark Hammond's win32 extensions to Python, and work with win32process.CreateProcess(), which doesn't appear to have any of this kind of limitations. Have fun! -schorsch -- Georg Mischler -- simulations developer -- schorsch at schorsch.com +schorsch.com+ -- lighting design tools -- http://www.schorsch.com/ Sent via Deja.com http://www.deja.com/ Before you buy. From jkraska1 at san.rr.com Mon Oct 30 01:48:32 2000 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 30 Oct 2000 06:48:32 GMT Subject: CPython vs. Jython/JPython References: Message-ID: <39FD1AA7.927E9223@san.rr.com> > It will still be *many* times slower than CPython due to the > overhead of JNI. I'm not sure if I follow; IIRC, the JNI is faster than CPython's native dispatch. > If Python was written in Java, I highly doubt we would *ever* have seen the > wonderful Stackless implementation come about. You wouldn't be able to do a proper stackless environment in Java without Sun's cooperation, because true stacklessness would require alterations to the JVM. > Personally, I can't think of any advantages of having the reference > implementation in Java which Python doesn't already have. I agree. Indeed Java is not the second coming of Jesus. Please do not treat it this way. C// From heinz.eriksson at era.ericsson.se Mon Oct 2 07:34:43 2000 From: heinz.eriksson at era.ericsson.se (Heinz Eriksson) Date: Mon, 02 Oct 2000 13:34:43 +0200 Subject: "CPAN" SIG? References: <87bsx333fp.fsf@cartman.azz.net> Message-ID: <39D872D3.DB9F9FC2@era.ericsson.se> Adam Sampson wrote: > > wolfson at midway.uchicago.edu (Ben Wolfson) writes: > > > PAIN: Python Archive International Network. > > How about the "Standard Python Archive of Modules"? Or "Olsen's Standard Python Archive of Modules"! (The one without the gannet module). /hz From mats at laplaza.org Mon Oct 23 09:45:08 2000 From: mats at laplaza.org (Mats Wichmann) Date: Mon, 23 Oct 2000 13:45:08 GMT Subject: large file support References: Message-ID: <39f43fc1.2385650@news.laplaza.org> On Fri, 20 Oct 2000 21:53:51 -0700 (Pacific Daylight Time), David Ascher wrote: >On 21 Oct 2000, Fred Clare wrote: > >> How does one read large files into Python? I have a 4 gigabyte >> file on an SGI (that has over 30 GB main memory), but when I use >> >> f = open("file","rb") >> s = f.read() >> >> on this file, I get "MemoryError". Trying the I/O from the os module >> produces the same result. In fact I get the MemoryError even when >> trying to read 2GB files. When I run configure before building python, it >> indicates that large file support *is* enabled. > >I'm not sure what the status of large file support is on SGI's. Quite good, and has been for many years. > One >thought, however, is that you may be better off using mmap to deal with >the file, as the OS can be much more efficient about what parts of the >data to load from disk. This is a good suggestion. SGI's use the LP64 code model (as do most folks, I believe): longs and pointers (in C) are 64-bit, integers remain 32-bit. Just a reminder to make sure there aren't any C int's trying to handle the large data. Mats Mats Wichmann (Anti-spam stuff: to reply remove the "xyz" from the address xyzmats at laplaza.org. Not that it helps much...) From aleaxit at yahoo.com Tue Oct 24 06:17:24 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 24 Oct 2000 12:17:24 +0200 Subject: C's syntax References: <8t0or303ee@news1.newsguy.com> <8t1964$v8a$1@news7.svr.pol.co.uk> <17WI5.58198$oN2.2362868@news20.bellglobal.com> <39F45B51.320AA63F@alcyone.com> <8t1nr90105v@news1.newsguy.com> <39F4FEAF.FA466927@alcyone.com> Message-ID: <8t3nt4027fk@news2.newsguy.com> "Erik Max Francis" wrote in message news:39F4FEAF.FA466927 at alcyone.com... [snip] > > Visual C++ may not be "reasonable", but it's still one of the most > > widespread on the market, and does NOT give this warning at normal > > warning-levels (and the system header files spew oodles & oodles of > > warnings if you try to enable warnins at pedantic-level, so one > > does not normally use that). > > One should never be running at the default warning level. One should be > turning as many warnings on as one can stand. ...because C is full of trip-wires just waiting for your foot. Yes, I agree -- I also think that one of the best books ever on C was Koenig's "C Traps and Pitfalls", exactly because it concentrated on the many, MANY ways C can trip you up (many of them related to its tortured syntax, though, of course, not all) and the good habits you should acquire to ameliorate the situation a bit. I fully agree with Koenig (a great programmer, and a great expert in C, and later C++, by the way) that "Even C experts come across problems that require days of debugging to fix" (from the preface of his book, cfr the URL http://www.research.att.com/~ark/bibliography/pitfalls.html). "if(a=0)" is not one of them (once you're experienced, you'll find the error in far less than 'days'), but there is no reason to go looking for it, any more than there is to use "intervals with bounds included" in loops, rather than the far less error prone idiom of "lowerbound included, upperbound excluded" which Koenig first proposed in this book. [Python's range() builtin, its sequence-slices, etc, work on said idiom too, by the way; _that_ one is not C-specific!-)] But, as I said, you just can't turn the warning level up all the way (to /W4) with Visual C++, if you have any system headers -- you'll get swamped with warnings about constructs being non-portable (of course system headers DO include many non-portable constructs...!-). The default /W3 is pretty strict... but it does NOT warn of "if(a=0)". > > It's a good coding habit to get into, to ensure that particular > > slip will be caught by any standard compiler, rather than relying > > on specific warning-relater features that NOT all compilers have. > > It is largely unnecessary. It is a novice programming error, one that > actual programmers do not make unless they are very green. Given that > any reasonable compiler will warn about such constructs, making a major > change in style for an error that advanced programmers do not make is > overkill, to say the least. Koenig wrote his landmark book with about a decade's worth of C experience (one could hardly have more back then, since that was about the language's age inside Bell Labs:-), and he disagreed with you, recommending the "if(0==a)" idiom. And why not? One may as well get used to the idioms that are most effective in the language one is using -- taking advantage of humans' already mentioned ability to grow used to anything, after all. Keeping the constant on the left rather than on the right has absolutely no bad side-effects. (using "if(!a)" may be an even better style for this specific case, but there remain "if(1==a)" and so on:-). "actual programmers" DO make typos all of the time -- else why would you recommend keeping warnings as severe as possible, or think that "if(a=b)" will be warned against by "any sensible compiler"?! A language with good syntax will, among other things, tend to have common typos produce compile-time-errors. But when the syntax is NOT good, every little bit spent avoiding its traps and pitfalls helps. Of course, this little idiom is no panacea, but, besides constants, it helps distinguish at a glance two very similar, common, and semantically different idioms: while(a=nextitem()) ... i.e., loop copying each next-item to variable a (to be used in the loop-body) and exit when next-item returns 0; and while(nextitem()==a) ... i.e., loop _comparing_ each next-item to variable a, and exit when a next-item is observed that _differs_ from a. "gcc-witout-warnings" syntax forces you to write the first case with doubled-parentheses, but that is not what C syntax says. So, for generality, it's much better to get used to write the second case with the function-call on the left of the comparison operator. Nothing (except switching to a language with better syntax!-) will really protect you from the specific typo: while((a==nextitem()) ... where you MEANT to assign-to-a (as suggested -- to the human reader knowledgeable of such things -- by the doubled parentheses) but are in fact *comparing*-to-a instead since a 'keyboard stutter' ended up doubling the equal-sign... Alex From ngps at madcap.dyndns.org Fri Oct 27 22:27:14 2000 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 28 Oct 2000 02:27:14 GMT Subject: Python IDEs and eXtreme Programming References: <8t6umj$qma$1@clematis.singnet.com.sg> <39F8068D.ED61EAA@python.com> Message-ID: <8tddi2$rva$1@dahlia.singnet.com.sg> According to Thomas A. Bryan : > > worked with the usual Windows-type IDEs. I believe I am unlikely > > to find up to 10 Python programmers who can do vim and CVS. ;-) > > Of course not...but maybe Xemacs and CVS. ;-) Heh. > Sounds like fun; tell us when/where the positions are open. Yup, if this (ever) becomes more concrete. Cheers. -- Ng Pheng Siong * http://www.post1.com/home/ngps From pinard at iro.umontreal.ca Mon Oct 9 13:34:42 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 09 Oct 2000 13:34:42 -0400 Subject: Request for Python Source Code In-Reply-To: Peter Hansen's message of "Sun, 08 Oct 2000 17:47:55 -0400" References: <4oeD5.1592$jBx.66322493@news.randori.com> <8rkdmk$he5$1@desig-bs01-s04.adtranzsig.de> <39E0EB8B.2D9EDCCB@engcorp.com> Message-ID: [Peter Hansen] > Hungarian notation actually referred to as a "Best Practice". There ought to be something good about so-called Hungarian notation... I prefer to think that the examples I saw, so far, were not using the concept cleanly. One bigger example I'm working on in these days is just dessicating, as after a few days in the code, I feel dried inside and out. Oh, the code does not seem to have many bugs, but on the other hand of this pure straightedness, there is no fantasy, no flower, no pleasure. I think I would much prefer risking a few bugs, after all :-). -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From dnew at san.rr.com Fri Oct 6 13:00:04 2000 From: dnew at san.rr.com (Darren New) Date: Fri, 06 Oct 2000 17:00:04 GMT Subject: How can you copy (clone) a string? References: Message-ID: <39DE0516.D06D1DCE@san.rr.com> Paul Robinson wrote: > Perhaps if you explain what your "bonafide need" is someone would > suggest a reason a) why you don't need to do it or b) how you can do it > in an alternative way. I think the answer is "use C" in this case. Hey, watch where you're throwing those tomatos! -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. The tragedy of the commons applies to monitizing eyeballs, too. From nospam at nospam.com Sun Oct 15 10:28:51 2000 From: nospam at nospam.com (Tom) Date: Sun, 15 Oct 2000 14:28:51 GMT Subject: Newbie problem with wxListCtrl References: <39E936E0.3BADC7D8@home.com> Message-ID: Frank, You need to insert items, as well as setting the item's string. So, before your line: self.lc.SetStringItem(i, 0, "%d" % i) Add a line like this: self.lc.InsertStringItem(i, label); Where label is a string that serves no purposes (doesn't get displayed) that I've deteremined. It's all the same on the Win32 api - this is a common mistake. Tom. "Frank P. Miles" wrote in message news:39E936E0.3BADC7D8 at home.com... > Hello all -- > > I'm trying to use wxPython for a database front-end project. Perhaps I > haven't > stared at the source code enough, but the documentation hasn't been > enough to get around > the basic problem of using wxListCtrl. Here's a simple bit of code: > > > #! /usr/bin/python > > from wxPython.wx import * > > class MyFrame(wxFrame): > def __init__(self, parent): > wxFrame.__init__(self, parent, -1, "test", size=(400, 200)) > self.lc = wxListCtrl(self, -1, style = > wxLC_REPORT|wxSUNKEN_BORDER) > self.lc.InsertColumn(0, "Column 0 Long enough") > self.lc.InsertColumn(1, "B-Column Real long") > for i in range(10): > self.lc.SetStringItem(i, 0, "%d" % i) > self.lc.SetStringItem(i, 1, "boogers all!") > self.lc.SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER) > self.lc.SetColumnWidth(1, wxLIST_AUTOSIZE_USEHEADER) > > class MyApp(wxApp): > def OnInit(self): > frame = MyFrame(NULL) > frame.Show(true) > self.SetTopWindow(frame) > return true > > app = MyApp(0) > app.MainLoop() > > <\end of code> > > No data are printed, nor are the column headings of sufficient length. > I've tried this both under Linux and Win98, with the same result, so > it would seem that it's my code, not a system configuration problem. > The wxPython demo works fine in both. I've tried other insertion > methods > other than SetStringItem -- though perhaps not the 'right' one. > > Any insights as to how to fix this -- or documentation that will clarify > my confusion would be appreciated! > > -frank From timr at probo.com Sat Oct 7 16:45:15 2000 From: timr at probo.com (Tim Roberts) Date: Sat, 07 Oct 2000 13:45:15 -0700 Subject: best way to store dbm records? References: <8rnu4o$emc$1@bob.news.rcn.net> Message-ID: <9f2vtss06scg26psv7gvfv8agt68jc91h3@4ax.com> "Michael B. Allen" wrote: >Hi! > >I was wondering what the best/simplest way to store dbm records is? This is >how I am currently adding records: > > # create dbm record > p = '102' > s = getfield(msg, 'from') > a = getfield(msg, 'authors') > v = getfield(msg, 'version') > d = getfield(msg, 'description') > x = getfield(msg, 'fixes') > o = getfield(msg, 'obsoletes') > r = getfield(msg, 'requires') > f = getfield(msg, 'flags') > dbmrecord = (a,v,d,x,o,r,f) > db[p] = `dbmrecord` A shelve can do this all for you. A shelve is just a dbm that holds pickled objects. Create a class to hold the data: class EMailIndex: self.key = '' ... fields = ( 'from', 'authors', 'version', 'description', 'fixes,' 'obsoletes', 'requires', 'flags' ) idx = EMailIndex() idx.key = '102' for name in fields: idx.__dict__[name] = getfield(msg, name) db = Shelve.open( dbname, 'w' ) db[idx.key] = idx db.close() Later, you can get the object back intact. >>>db = Shelve.open( dbname, 'r' ) >>>xxx = db['102'] >>>xxx.authors ds-0.1 -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From jasonic at nomadicsltd.com Fri Oct 27 15:19:55 2000 From: jasonic at nomadicsltd.com (Jason Cunliffe) Date: Fri, 27 Oct 2000 15:19:55 -0400 Subject: Zope question: collaborative environments? References: <39F8C8EC.EB2DC75D@UTS.Itron.com> <39F8EEC4.76941E04@engcorp.com> <39F9AB9E.8A043196@UTS.Itron.com> Message-ID: Tom Reading your second post, and also Jerry Spickelmire's more encouraging reply... I would like to say that despite my scary previous warning.. it sounds after all that like Zope might be fine for you folks :-) - You appear to have solid in-house Python skills + are willing to hire more - Your boss sounds cool - You do not really need the 'supergroupware' app which we lunged at - There is a lot of ready-to-run Zope components which will quickly get you going.. - You arrive at Zope at a good time. The book will be out soon and the on-line text is already available: http://www.zope.org/Members/michel/ZB/ My suggestion print this out and comb bind at once to help you decide to zope or not to zope! - Zope install very fast on nay machine and can be tested. I run it typically on my sony win98 laptop in the background most of the time. No problem moving work to Linux box the other side of the world. - ZODB can be imported and exported singly or in hierarchical pieces. This alone without any plugins means it is immediately 'collaborative' ware. Intelligent ZODB use alone without any other Zope products allows for some very good 'applications'. Since you can FTP right into the ZODB you caninfact use Python's own FTPlib to embed some very handy routines to update the ZODB. A great plus is you can take your site with you offline .. good for backup but also good for faster development. You will have to have a good strategy for versioning though. - It is about 6 lines of code to make Zope pages which will automatically add links whenever users upload new material. Add a few more lines, perhaps via python method and you can certainly track these. - Zope has good undo features which may be handy for you. - Anything you want to do special you can do in Python and use as Python External Methods. This is very effective and easy to update... Later and as your Zope Zen advances and the need arises you can convert these to become reusable Zope Products. In practice you may not need or want to. For example you can probably rapidly connect 'Perforce' python objects to Zope in this manner. - Permission give you very wide control from root folder down to object level. - There is very technically responsible and responsive online zope community. Ask and ye shall be answered not at all or in mountains of precision.. As Jerry says, Zope _is_ addictive.. Just when you are about to give the zopelist reading or demo download fix, up comes another great idea, cool hack or tantalizing new 'product' is announced. enjoy! Jason > a bug tracking system like Bugzilla, document repository, etc.). I was > hoping that Zope + plugins + a few weeks of scripting by an experienced > Python coder would give us something basic and usable while providing us > with a platform for future improvements and extensions as time permits. > > > and over time dedicate at least a fraction of somebody's time to > > improving and developing it. We have a lot of faith in Zope's future, > > and I recommend it on that basis. But it won't take a few weeks to get > > what you want! > > I guess the question is whether a few weeks would get us something that > would be usable by the developers without causing a huge administration > burden or training requirement for the developers. Another major option > is SourceForge, but I hesitate to use it because no one here knows PHP > and because we would only populate it with a single project. I also set > one up a few months ago, and it was non-trivial to get everything set up > at first. > > I'd personally like to hire a Python/Unix hacker college student here in > Raleigh who would be willing to dive into Zope for a 10-20 hours per week > job. My boss said that he'd hire one if we could find him. Anyone > interested? > > Tom From hei at adtranzsig.de Fri Oct 27 04:10:55 2000 From: hei at adtranzsig.de (Dirk-Ulrich Heise) Date: Fri, 27 Oct 2000 10:10:55 +0200 Subject: Importing a module with dashes. References: Message-ID: <8tbd3o$8rq$1@desig-bs01-s04.adtranzsig.de> > C++ is to programming as sex is to reproduction. Better ways might > technically exist but they're not nearly as much fun. > -- Nikolai Irgens A masochist outing. -- Dipl.Inform. Dirk-Ulrich Heise hei at adtranzsig.de dheise at debitel.net From aleaxit at yahoo.com Tue Oct 31 06:48:33 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 31 Oct 2000 12:48:33 +0100 Subject: In memory persistence - used as CGI References: <8tk9aq$p80$1@nnrp1.deja.com> <8tkn1b09kg@news1.newsguy.com> <8tl1i6$fuv$1@nnrp1.deja.com> Message-ID: <8tmbsa01pi3@news1.newsguy.com> "Robin Dunn" wrote in message news:8tl1i6$fuv$1 at nnrp1.deja.com... > In article <8tkn1b09kg at news1.newsguy.com>, > "Alex Martelli" wrote: > > wrote in message > > news:8tk9aq$p80$1 at nnrp1.deja.com... > > > I'm using Python as a CGI language (for use both [snip] > > No, each CGI 'hit' is served by a completely separate > > process (I think this holds for both IIS and Apache), [snip] > > have to go to disk, and/or use cookies. > > Or use something like FastCGI, but then you have to funnel all requests > through a single process which is fine for light or medium loads, but > can cause throughput issues at a high load. If CGI is not required, then multiple processes might still be acceptable -- the mmap builtin module (new in 2.0, I believe) will allow them to share the memory areas to which objects get 'in-memory persisted'. It works on both Unix and Windows. The memory may be backed by the filesystem rather than the pagingfile, but that shouldn't be an issue. Alex From jeffrey at Digicool.com Wed Oct 4 16:06:58 2000 From: jeffrey at Digicool.com (Jeffrey P Shell) Date: Wed, 04 Oct 2000 16:06:58 -0400 Subject: Substring Detection? Pythonically? References: <20001004.123529.97857@Jeremy.cerebralmaelstrom.com> Message-ID: in article YPLC5.167$YU1.7871 at newsc.telia.net, Fredrik Lundh wrote:: > Stephen Hansen wrote: >> Okay, say I have three different strings: >> #1: they >> #2: that >> #3: tommy >> >> And a user gives me a string -- 'the', I want it to match to 'they'. Then >> say they give me a string, 'to', I want it to match to 'tommy'. A string >> of 'th' or 't' is ambiguious, and i want a list returned, ['they','that'] >> and ['they','that','tommy'] respectively. > > import re, string > > class Matcher: > def __init__(self, names): > self.names = string.join(map(lambda x: "{%s}" % x, names), "") > def find(self, name): > return re.findall("{(" + re.escape(name) + "[^}]*)}", self.names) All I can say is wow. From root at rainerdeyke.com Fri Oct 6 14:14:01 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 06 Oct 2000 18:14:01 GMT Subject: Why is "while" ticking me off??? References: <39DD15A1.442E5A33@ix.netcom.com> <39DDEC25.CEE0E16A@gssec.bt.co.uk> Message-ID: "Huaiyu Zhu" wrote in message news:slrn8ts3ul.177.hzhu at rocket.knowledgetrack.com... > val = dict1[key1] > if val: > process1(val) > else: > val = dict2[key2] > if val: > process2(val) > else: > val = dict3[key3] > if val: > process3(val) > else: > ... > > Huaiyu for key, dict, process in [(key1, dict1, process1), (key2, dict2, process2),\ (key3, dict3, process3), ...]: val = dict[key] if val: process(val) break :-) -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From frank at canyon-medical.com Mon Oct 9 18:38:04 2000 From: frank at canyon-medical.com (Frank Sergeant) Date: Mon, 9 Oct 2000 16:38:04 -0600 Subject: What's wrong with ActiveState? (was: Is this a dream or a nightmare? (Was Re: XML)) References: <39d1d3b2.43465571@news.telus.net> <39D19EBB.ABF18F23@engcorp.com> <39def2ae.8929692@news.davesworld.net> <39e1f314.11798695@news.davesworld.net> Message-ID: "David T. Grove" wrote in message news:39e1f314.11798695 at news.davesworld.net... > I should have noticed this in the earlier thread. How was this > document seen? To my knowledge, there has never been any link to it > from anywhere on the site. Naturally, since more than 2 or 3 minutes have passed, I no longer remember how I got there. Possibly I browsed to something that had a search box, typed something into it (perhaps 'ActiveState'), and found it that way. -- Frank frank at canyon-medical.com From jeremyh at flashcom.com Tue Oct 3 17:09:19 2000 From: jeremyh at flashcom.com (Jeremy Howard) Date: Tue, 3 Oct 2000 14:09:19 -0700 Subject: Problem with using PythonWin and ActiveX COM Object Message-ID: I've asked this before but never really got an answer. I'm working for a company that is using Siebel CRM software. This software comes with COM objects for accessing their system from external applications. Below is the VB code that works and the Python code that doesn't. If anyone has a solution I'd really appreciate it. VB Code... Dim iErr as Integer Dim objSiebel as Object Set objSiebel = CreateObject("SiebelDataServer.ApplicationObject") objSiebel.LoadObjects("ConfigFile", iErr) the vb code above works fine with no problems. Python Code... import win32com.client iError = 0 objSiebel = win32com.client.Dispatch("SiebelDataServer.ApplicationObject") objSiebel.LoadObjects("C:\\siebel\\bin\\psblprd.cfg", iError ) the python code above throws the following error.. Traceback (most recent call last): File "C:\Python16\Pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript exec codeObject in __main__.__dict__ File "C:\Development\Java\MX\testSiebel.py", line 7, in ? objSiebel.LoadObjects("C:\\siebel\\bin\\psblprd.cfg", sError ) File "", line 2, in LoadObjects com_error: (-2147352571, 'Type mismatch.', None, 2) I'm not sure why this is happening. I was under the impression that the variabel iError would be an integer if assigned a numeric value (ie iError = 0). Thanks in advance Jeremy Howard jeremyho at flashcom.com From berning at teuto.de Thu Oct 19 06:50:06 2000 From: berning at teuto.de (Ulrich Berning) Date: Thu, 19 Oct 2000 12:50:06 +0200 Subject: Stopping a python thread References: <8sksk4$b6c$1@nnrp1.deja.com> <8sl2ug$h1l$1@panix2.panix.com> Message-ID: <39EED1DE.800396A1@teuto.de> Aahz Maruch wrote: > What do you need to do this for? The standard response is that the > spawned thread should determine when it should stop processing work and > execute a "return". That will kill the thread automatically. There are > a variety of ways of signalling the thread to exit. If the spawned thread blocks in a system call like read() or write() there is no way to tell the thread to stop working. Therefore the pthreads standard defines a number of system calls that must be defined as cancellation points e.g. read(), write(), open(), creat(), wait(), ... With a call to pthread_cancel() you can tell a thread to stop working even if it hangs in such a blocking call. Cancellation is a missing feature in the python threads implementation I think. Without cancellation, there is no chance to write multithreaded servers in python that can do a clean shutdown with the possibility to call cleanup handlers for every canceled thread. --- Ulli Berning From mhagger at alum.mit.edu Tue Oct 17 14:25:04 2000 From: mhagger at alum.mit.edu (Michael Haggerty) Date: Tue, 17 Oct 2000 18:25:04 GMT Subject: Which Web server is the most suitable for Python CGI Programming? References: <8sfd3p$2fh$1@news2.kornet.net> Message-ID: "junwon,Seo" writes: > Whici Web sever are the most suitable for Python CGI Programming? > Performence, Speed, Scalibiliry.... We are using AOLserver + PyWX. (I am a PyWX developer.) AOLserver is a free, open source, mature, multithreaded web server. http://pywx.idyll.org > Please. benchmarking.. In a quick-n-dirty benchmark, we found that AOLserver+PyWX served about 230 trivial Python-generated pages per second on a single-processor Pentium 3/500MHz under Linux. Michael -- Michael Haggerty mhagger at alum.mit.edu From gobry at lithsun15.epfl.ch Tue Oct 10 07:42:39 2000 From: gobry at lithsun15.epfl.ch (=?iso-8859-1?Q?Fr=E9d=E9ric?= Gobry) Date: 10 Oct 2000 13:42:39 +0200 Subject: Compilation of Python 2.0c1 Message-ID: Hi, I've problems with python compilation (be it 1.6 or 2.0c1) on my Mandrake system : the executable python produces a segmentation fault in Modules/getbuildinfo.c, in the sprintf call... according to gdb at least... Has somebody solved a similar problem ? My system : gcc 2.95.3 (but the RPM says 2.95.2-7mdk) glibc 2.1.3 Thanks, Fr?d?ric From cobrien at Radix.Net Thu Oct 12 08:56:01 2000 From: cobrien at Radix.Net (Cary O'Brien) Date: 12 Oct 2000 08:56:01 -0400 Subject: Zope & Python References: <39c208eb$0$231@hades.is.co.za> <39E4B7DA.2C18D688@motorola.com> <8s3vik$b5u$1@taliesin2.netcom.net.uk> Message-ID: <8s4cd1$5on$1@saltmine.radix.net> I've been thinking about this a lot lately. I am going to rant now. My big gripe with most web development systems is that they mix presentation with business logic. Yuck. Bad idea. Trust me. (more comments below). [snip] > >Anyway XML should be your glue now. > I'm not convinced. Ok, it is a cross language data format, which is a good idea (rather than a python pickle or a serialized java object), but there are other data formats like whatever the heck Corba uses and Tuxedo FML buffers. Ok, FML is proprietary but it is cross-language. All the CPUS are now going to spend all their time packing and unpacking giant XML trees rather than doing real work. [snip] >> > b) If we develop web applications in accordance with the Java Servlet >API, >> > we can upgrade the platform from Apache+Tomcat running on Linux to Sun's >> > Java Webserver, or IBM Websphere, or BEA Weblogic (BEA is the industry >> > leader in OLTP middleware), or any number of other commercial >> > implementations. What is the upgrade path for Zope? > >You'll only need that upgrade path when some architect or business decision >makers decides that we must have J2EE/EJB compliance on the middle tier. But >tell me, in 2-5 years time when we decide that we need fully >parallel/distributed architectures not tiering, what is your upgrade path >from Java middleware? > Middleware. Think middleware. My current leaning is to use language independant middleware (Corba or Tuxedo) to define the interfaces and connect things together. Then different versions of the same things, implemented in different languages, can all coexist. >> > c) Java allows a wide choice of compilers, debugging and profiling >tools, >> > modelling tools, middleware, and libraries for everything under the sun. >It >> > is a mainstream language for commercial applications, with a relatively >> > large pool of programming expertise and with support from most major >> > industry players (besides Microsoft). Python may be gaining popularity, >but >> > is way behind Java. > How many broken java programs have you dealt with? How many mystery JVM errors have you seen? How much time have you spent fighting with JVM incompatibilities. Now change java to python and JVM to PVM. Different story, eh? But my *MAJOR* gripe about Java is that it doesn't play well with others. Look at JINI. If you want to talk JINI you *MUST* have a JVM so that you can load the interface code. What if I don't want to pay the cpu and memory price for a JVM? What if I don't want to download someone elses java classes into my interpreter? OK, so XML and XMLRPC are going go be the lingua fraca (?sp) of the new software world. Ok. Rant over. Fire away. -- cary From g2 at seebelow.org Sat Oct 14 16:21:26 2000 From: g2 at seebelow.org (Grant Griffin) Date: Sat, 14 Oct 2000 21:21:26 +0100 Subject: This is really cheesing me off... References: Message-ID: <39E8C046.D1C4C1F6@seebelow.org> Dale Strickland-Clark wrote: > > Env: Win2K, Python 1.6, PythonWin > > How do you develop multi-module projects without haveing to constantly > quit and restart PythonWin? I had the same problem--and I gravitated to the same solution. Then I gave up on PythonWin. It's a darn shame, too, because PythonWin is otherwise a really strong product. In the last several months, I've taken to using MS Visual C++ (MSVC) as my Python IDE. It doesn't do Python syntax highlighting, and it doesn't have a Python debugger. But other than that, it's almost as good of a Python IDE as PythonWin. As I understand it, PythonWin's problem stems from the fact that is partly written in Python: the Python interpreter can't be totally re-initialized--except by exiting and restarting PythonWin. (It seems like there ought to be a way to somehow run separate interpreters for PythonWin and user code. But maybe there isn't.) I'm unclear whether IDLE has the same problem. I'm gonna to give it a try soon. In any case, if a Python IDE were available with a debugger that worked as smoothly as MSVC's does on C/C++ programs, that would really be valuable. btw,-isn't-msvc's-debugger-written-in-msvc?--ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From daimun at home.com Mon Oct 23 23:25:23 2000 From: daimun at home.com (Alex McHale) Date: Tue, 24 Oct 2000 03:25:23 GMT Subject: Preparing a Python Program for Distribution Message-ID: I posted this from deja.com, but it has never shown up. If it magically does show up; sorry for the repeats. Hi there, I was wondering - is there any good way to distribute a Python program for Unix or MS Windows (the latter being the primary focus for the program of mine which has sparked this question), without requiring them to already have installed Python? IE - is there a way to distribute the interpreter with the program, in such a way to not bloat the distribution? Alex From mikael at isy.liu.se Mon Oct 23 07:24:58 2000 From: mikael at isy.liu.se (Mikael Olofsson) Date: Mon, 23 Oct 2000 13:24:58 +0200 (MET DST) Subject: C's syntax (was Re: Python Formatted C Converter (PfCC)) In-Reply-To: <8t0or303ee@news1.newsguy.com> Message-ID: On 23-Oct-00 Alex Martelli wrote: > [snip a lot of stuff] > a clear case of "Stockholm Syndrome"...:-) Being a Swede, I sure would like to know what the Stockholm Syndrome is. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 23-Oct-00 Time: 13:23:36 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From piet at cs.uu.nl Thu Oct 26 04:54:42 2000 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 26 Oct 2000 10:54:42 +0200 Subject: Web client References: Message-ID: >>>>> piet at cs.uu.nl (P) writes: P> This cookie module is voor the server-side not for the client side. P> I did some code for client side cookies not too long ago, but I cannot find P> it now. It may be at home, I'll have a look into it. It is quite simple, P> not even a separate module. Here is the code. It is for accessing the translation facility from altavista.com. the first time you access that page (http://babel.altavista.com/translate.dyn) you get a cookie. Then you supply the cookie if you want to translate a HTML page. In this case the cookie is given as cookie in the headers, and also in the `form'. The standard urllib.urlopen doesn't have a facility to specify additional headers in the request, so I coded my own urlopen. Maybe the new urllib2 module in Python 2.0 has this facility, but I haven's seen that yet, and there is no doc. from urllib import * from mimetools import Message def urlopen(url, data=None, headers=None): u = FancyURLopener() if headers: if type(headers) == type({}): headers = headers.items() for kw, val in headers: u.addheader(kw, val) return u.open(url, data) babel = "http://babel.altavista.com/translate.dyn" form = {'doit':'done', 'BabelFishFrontPage':'yes', 'bblType':'url', 'url':'http://www.cs.uu.nl/', 'lp':'en_fr'} start = urlopen(babel) headers = start.info() message = start.read() #print message cookie = headers.getheader("set-cookie") print cookie clist = string.split(cookie, ';') print clist session=string.split(clist[0],'=')[1] print session page = urlopen(babel+';$sessionid$'+session, urlencode(form), [('Cookie', clist[0]),('Referer', babel)]) print page.info() out = open('transout.html','w') out.write(page.read()) out.close() -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From kc5tja at garnet.armored.net Thu Oct 12 19:00:48 2000 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 12 Oct 2000 16:00:48 -0700 Subject: Zope availability (was Re: pythonlabs.com website down -- 2.0c1 still available!) References: <200010102316.SAA20071@cj20424-a.reston1.va.home.com> <8s143u$2eq$1@oslo-nntp.eunet.no> <39E4D842.3BEBCB32@digicool.com> <39E54171.8181501F@engcorp.com> <39E63789.7ED224EE@digicool.com> Message-ID: On Thu, 12 Oct 2000 18:13:29 -0400, Jim Fulton wrote: >> I'm sure there are many, many of us who would be only too happy to help >> beat up on a victimize-me.zope.org site which was explicitly made >> available as a target for testing new releases of Zope technology... :-) > >This is certainly something we should consider. And while you're at it, please give Zope better support for virtual domains. ;-) What I have now works, but is hokey. -- KC5TJA/6, DM13, QRP-L #1447 | Official Channel Saint, *Team Amiga* Samuel A. Falvo II | Oceanside, CA | From tbryan at python.com Thu Oct 19 07:50:52 2000 From: tbryan at python.com (Thomas A. Bryan) Date: Thu, 19 Oct 2000 07:50:52 -0400 Subject: Low cost web hosting with Python References: Message-ID: <39EEE01C.C5C5EEE5@python.com> buckensat at yahoodot.com wrote: > Any recommendations for a low cost (or even free, ok I doubt it > but...) web hosting service that allows Python CGI scripts? > > For learning purposes only, not as a real web app server. That's one of the purposes of the Starship. http://starship.python.net The PSA prerequisite is currently being discussed on and off of the PSA mailing list, so you may want to contact the webmaster at starship.python.net first. ---Tom one of the Starship Sys Admins From ari_deja at ivritype.com Mon Oct 23 10:20:56 2000 From: ari_deja at ivritype.com (Ari Davidow) Date: Mon, 23 Oct 2000 14:20:56 GMT Subject: tuple/string compare Message-ID: <8t1hg5$v9p$1@nnrp1.deja.com> Well, here's one of those newbie confusions. I'm trying to compare data from two sources. The first source goes to a database, fetches what's there, and pops it into a dictionary, such that I get a tuple: crsr.execute(""" select url from table where root_url = :1 """, (myRootUrl,)) myOldStuff = crsr.fetchall() Then, I go read a page on the web with the URLs I need, use re to get exactly the string I want, and I'm left with ... a string. So, now, I'm trying to figure out if this new string matches a key in the dictionary, and of course, there never is a match because the string never matches the tuple: ('foo.html',) is in the dictionary foo.html is my string, newUrl if myOldStuff.has_key(newUrl): print "bingo" else: pass There must be a way to do this so that it works. Preferably, it seems as though I should be able to retrieve the database material and save it as a string into the hashtable. In fact, I do save the current root URL successfully as a string: (('/foo.html',):'www.bar.com') if myOldUrls != []: for row in myOldUrls: allOldUrls[row] = myRootUrl So, is there some way to make something work like: if myOldUrls != []: for row in myOldUrls: allOldUrls[row] = myRootUrl row = just the string from the former, immutable tuple or some better way to approach this? -- Ari Davidow ari at ivritype.com Sent via Deja.com http://www.deja.com/ Before you buy. From sholden at holdenweb.com Fri Oct 13 14:59:42 2000 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 13 Oct 2000 14:59:42 -0400 Subject: C macros in Python. References: Message-ID: <39E75B9E.E1A17F24@holdenweb.com> Steve Juranich wrote: > > I was just wondering if there was anything available in Python like the > __FILE__ and __LINE__ macros in C. I know about the __name__ attribute, but > I'm not sure that does exactly what I'm looking to do. > > What I'd like to do is write some code that will tell me _exactly_ on which > file and while line things went wrong. > > Thanks for the help. > > ---------------------------------------------------------------------- > Stephen W. Juranich sjuranic at ee.washington.edu > Electrical Engineering http://students.washington.edu/sjuranic > University of Washington http://rcs.ee.washington.edu/ssli -- The "approved" means of accessing this information would, I believe, be the use of the traceback standard module. This will involve learning the structure of the traceback objects it deals with, but you should be able to get everything you need - it's intended to allow customized exception responses such as you describe. regards Steve Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ From piet at cs.uu.nl Wed Oct 18 11:43:51 2000 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 18 Oct 2000 17:43:51 +0200 Subject: evaluating a string References: <8sgiuh$ope$1@nnrp1.deja.com> <39ED5741.AEC63540@student.gu.edu.au> <39ED58C9.8BF96A8A@student.gu.edu.au> <39ED5E17.E80595AD@student.gu.edu.au> Message-ID: >>>>> Joal Heagney (JH) writes: JH> Okay, sorry about that. How embarassing. Perhaps I should code before opening JH> my mouth, huh? Anycase, here is a baby implementation of a string evaluator JH> that doesn't get hung up on integer division. >>>> def string_eval(text): JH> ... splittext = re.split("/", text) JH> ... text2 = "" JH> ... for i in range(len(splittext)-1): JH> ... text2 = text2 + splittext[i] + ".0/" JH> ... text2 = text2 + splittext[-1] JH> ... return eval(text2) JH> ... >>>> string_eval("1+2*3/4") JH> 2.5 >>>> If you want to have fractional answers then you should also accept fractional input. So what about "1+2*3.6/4" -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From SBrunning at trisystems.co.uk Fri Oct 20 09:18:56 2000 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Fri, 20 Oct 2000 14:18:56 +0100 Subject: ActivePython 2.0 Release Message-ID: <31575A892FF6D1118F5800600846864D5B12EA@intrepid> > From: eff at my-deja.com [SMTP:eff at my-deja.com] > Dale wrote: > > Yes, but how is this better then Python 2.0 + Win32all? > > hint: have you checked the license? I think that Dale meant better for *us*, not better for *ActiveState*. ;-) Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From maxm at normik.dk Mon Oct 9 05:15:21 2000 From: maxm at normik.dk (=?ISO-8859-1?Q?Max_M=F8ller_Rasmussen?=) Date: Mon, 9 Oct 2000 11:15:21 +0200 Subject: doubling slashes in a string Message-ID: <7BD10B680501D411B9DF009027E06F32011C26@exchange> Well being lazy as I am I would just use one of the following forms: print r'c:\temp\test.txt' print 'c:/temp/test.txt' None of that backslash nonsense to me. -------------------------------------- From: Joshua Muskovitz [mailto:josh at open.com] Man, I just have to say, I *love* python. I was struggling with the problem of how to take a pathname and double all of the backslashes in it, so that (for example) From olivierS.dagenaisP at canadaA.comM Thu Oct 12 17:20:22 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Thu, 12 Oct 2000 21:20:22 GMT Subject: Synchronizing CGI processes? Message-ID: I am writing a client-server system in Python and the only free Python-supporting internet server I can find supports Python as CGI scripts. (Incidentally, if you know of any free hosting solutions that would allow me to host a server written in Python with say, Medusa please say so!) The multiple independent process nature of CGI is the source of a very puzzling synchronization problem: how on earth can I guarantee synchronization between two (or more) concurrent CGI sessions? (I need to synchronize writes to a simple, one-user database... I'm using "Gadfly" for the curious...) At this stage, I am only exploring ideas and haven't tried to implement any of them, mostly because I would rather be sure of the atomicity of the synchronization mechanisms than to discover that I was being lucky with my 2-user tests and it starts breaking six months down the road. So far, I can only think of the following: - use a file as a binary semaphore: if it exists, return "busy" to the client, if it doesn't exist, create it and be on your way. Since I can not assume what OS/webserver will be running my server, I don't know if I can assume checking for a file and creating a file are atomic operations! - use an environment variable as a binary semaphore. The value of the variable would allow me to synchronize operations, however (since I can not assume what platform) I do not know if reading/writing an environment variable is atomic and, even worse, if it can be persistent across independent (sibling) processes! It seems most cool synchronization solutions available in Python are only good for threads. :( What are my options? Can anybody clear up some of my assumptions/questions? Like I said, I cannot assume what platform my server will be running, so it could be Win95 with a simple webserver, NT4/W2K Server or any Unix/Linux! Thanks for any help you can provide... -- ---------------------------------------------------------------------- Olivier A. Dagenais - Software Architect and Developer "Someone called 'Type your name here' is impersonating me on the internet and is posting exactly the same things I am posting!" From smnordby at yahoo.com Wed Oct 11 18:58:35 2000 From: smnordby at yahoo.com (Steve) Date: Wed, 11 Oct 2000 15:58:35 -0700 Subject: Programmer-Wanna-Be (Is Python for me?) References: <8s2354$ep2$1@nnrp1.deja.com> Message-ID: <39E4F09B.E61C0669@yahoo.com> fifeclub at my-deja.com wrote: > > 1. First of all, is Python what I'm looking for: a way to create > Windows (or other OS's) applications? Yes. > 2. Is Python RELATIVELY one of the easiest ways to do this? Yes, and I will cautiously say absolutely, not just relatively. > 3. What about Visual Basic? (the most commonly used) Why should I not > choose VB instead? Visual Basic ties you to the Microsoft and their platforms, which you indicated you may not want to do. Python is cross platform, Open Source, and supported by a group of enthusiastic and knowledgeable programmers. Python's syntax will be better preperation if you want to learn Java, C, or C++. > 4. Is there a WYSIWYG editor (like Frontpage is for HTML)? Is this what > Tkinter is? Is there a 'better' WYSIWYG editor for Python that I should > use instead? Programming is unlike document mark-up (HTML), so "What You See Is What You Get" doesn't really make sense to me in this context. The analogous tool in programming might be an Integrated Development Environment, or IDE. Python comes with a helpful editor, IDLE, but it is not a full IDE. > 5. What's the deal with Tk/Tcl? Why is this so closely tied with Python > and Tkinter if Python is it's own language? (The install instructions > say I may need to install Tk/Tcl too (what ever that is)) Tkinter is the Python interface to the graphical user interface Tk, which is based on the Tcl language. Tk is the primary (but not the only) GUI used with Python. It is also cross platform. > 6. Where should I start? (I've already downloaded and installed > Python2.0b2 but haven't attempted to write anything) Do I need to > download anything else? You probably should start by downloading and installing version 1.6 rather than the beta of 2.0. The installation includes Guido's tutorial, but if you haven't programmed before, first try Josh Cogliati tutorial: http://www.honors.montana.edu/~jjc/easytut/easytut/ or Alan Gauld's excellent tutorial: http://members.nbci.com/alan_gauld/tutor/tutindex.htm After doing one or both of these, then the tutorial and the documentation that comes with the Python download will make more sense. After that, there are many excellent books on Python, and their authors frequent this newsgroup. Best of luck! -Steve- > > -Thanks > -Mike > > Sent via Deja.com http://www.deja.com/ > Before you buy. From effbot at telia.com Fri Oct 20 12:57:26 2000 From: effbot at telia.com (Fredrik Lundh) Date: Fri, 20 Oct 2000 16:57:26 GMT Subject: Undocumented re bug??? References: <39EF1503.B34048EA@insight.co.il> Message-ID: Benny wrote: > I'm experiencing a werid re behaviour. Whenever the digit 7 is present > in a range specifier, the re fails, although the pattern exists in the > string. > > Here's a real-life example: > > Python 1.6b1 cannot be: nobody should use 1.6b1 in real life... > Anyone seen this before? Has it got anything to do with not working on > the Sabbath? :-) according to SRE in 1.6b1, "7" is not a valid decimal digit. it was probably Someone's way of telling me not to work on Sundays ;-) From tbryan at python.com Tue Oct 31 06:26:57 2000 From: tbryan at python.com (Thomas A. Bryan) Date: Tue, 31 Oct 2000 06:26:57 -0500 Subject: Low cost web hosting with Python References: <39EEE01C.C5C5EEE5@python.com> Message-ID: <39FEAC81.3FD44515@python.com> buckensat at yahoodot.com wrote: > > Can anyone post more details about the starship? I have tried to get > details via the URL listed below as well as e-mail, but have had a hard > time finding specifics about what services the starship is suposed to > provide etc. There was some Starship downtime during the transition from BeOpen to Pythonlabs. You mail to the webmasters got through, and I sent you a reply. Tell me if you didn't get it. ---Tom From NospaMapierce at escapeNospaM.com Sat Oct 28 19:27:38 2000 From: NospaMapierce at escapeNospaM.com (Andrew Pierce) Date: Sat, 28 Oct 2000 23:27:38 GMT Subject: how do I exit gracefully? Message-ID: Sorry if this is a banal question, but how to I gracefully exit a python program instead of the 'normal' method of running out of lines of code to execute? I dug around the FAQ and DejaNews and found sys.exit() and os._exit() but both of these methods raise exceptions. What happens when a python program terminates normally by running out of code, that is, when python runs out of executable statements does it raise an exception (it doesn't seem to near as I can tell)? Is there a way for me to cause this same procedure (whatever it is) to happen early? I have a number of checks that need to pass for a cgi-script and if any of them fail I'd like a graceful (and preferably silent) way to end the script. Thanks for any help. -Andy Pierce From thomas at xs4all.net Tue Oct 31 16:41:53 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 31 Oct 2000 22:41:53 +0100 Subject: Rounding Bug in Python 2.0! - ugh In-Reply-To: <8tncdk$frm$1@news2.ottawa.cyberus.ca>; from g_will@cyberus.ca on Tue, Oct 31, 2000 at 04:10:20PM -0500 References: <8tncdk$frm$1@news2.ottawa.cyberus.ca> Message-ID: <20001031224153.L12812@xs4all.nl> On Tue, Oct 31, 2000 at 04:10:20PM -0500, Gordon Williams wrote: > When I switched from python 1.5.2 to 2.0 final I had a surprise in some code > that was working previously. > It comes down to: > >>> x=3.8999999999999999 > >>> round(x,3) > 3.8999999999999999 > >>> > >>> x=3.123456 > >>> round(x,3) > 3.1230000000000002 > Someone is going to start talking about machine round off errors, but this > is a BIG UGH!! Is it really ? The *only* difference here is that the interactive interpreter now shows the floating point value as closely as expected. Nothing about the *return value* of round() changed. > It is not what is intuitively expected. Can we go back to the good old days > when 1.5.2 lied to us and gave us the answer that we expect and need!! It has nothing, absolutely nothing, to do with 2.0 or 1.5.2. It doesn't have anything to do with rounding, either. It has everything to do with approximation, and the fact that some floating point values cannot be expressed in a specific floating point format. Trust me. If you want to see the old behaviour, try using 'str()' on the return value of round: >>> x = 3.8999999999999999 >>> str(round(x,3)) '3.9' What happens is that 'round' grabs 'x', which is approximately 3.8999999999999999, tries to 'round' it to 3.899, and returns the floating point value that comes closest to that. But the problem is, 3.8999999999999999 *is* the closest thing to 3.899 the machine can supply. This is exactly how it behaved in 1.5.2, but you probably didn't notice, because 'str()' does rounding to 'sane' numbers. The difference between 2.0 and 1.5.2 is that 'repr()' used to do the same rounding as 'str()', and no longer does. 'repr()' is supposed to give as detailed information as possible, so it should show as many digits as is feasible. If you want to know *why* most machines can't approximate 3.899 better, buy a book that explains IEEE floating point :) O'Reilly's "High Performance Computing" does an excellent job, for instance. In short, don't use 'repr()' if you don't *want* an exactest-possible representation of a value :) Gosh-now-I-know-what-Tim-must-feel-like-when-people-ask-him-about-FP-ly y'rs, ;) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From sgclift at earthlink.net Wed Oct 18 01:37:38 2000 From: sgclift at earthlink.net (Steve Clift) Date: Tue, 17 Oct 2000 22:37:38 -0700 Subject: scanf in python...? Message-ID: <3.0.6.32.20001017223738.00835b50@mail.earthlink.net> "Terry Reedy" wrote: > "Tony Waterman" wrote in message >> Does python have any way to mimic scanf ? I just bought Python on >> Win32 and I can't find anything in there about it, or on the >> python.org html tutorial. Also; how many ways to mimic scanf are >> there? > > xscanf(x, format, pointer1, pointer2, .... pointern) is not directly > possible in Python because Python does not have pointers. > > However, it would be possible to write a scan(string,format) function that > would return a tuple of values. Since Python uses C formats for the % > operator, it would add a nice symmetry. [IE, scan(format%tuple,format) == > tuple]. That's approximately what the sscanf module I wrote about 5 years ago does (I got fed up with all the hooplah involved in reading tables of mixed data types using the standard Python facilities). You can find it by doing a web search on sscanfmodule.c. I have no way of compiling it to be useful under Windows, unfortunately. Steve From gerrit at NOSPAM.nl.linux.org Tue Oct 31 06:59:39 2000 From: gerrit at NOSPAM.nl.linux.org (Gerrit Holl) Date: 31 Oct 2000 11:59:39 GMT Subject: make uninstall References: <8tj865$ub0$1@nnrp1.deja.com> Message-ID: On Mon, 30 Oct 2000 07:32:21 GMT, fritzlein at my-deja.com wrote: > I (as myself, not root) installed python 2.0b1 > (or something like that) to play with on a Linux > machine that isn't mine (i.e. I don't know the > root password, so I can't sail in and kill > everything). I'm done playing for now and I want > to clean up my mess. I still have the unzipped > tarball and the makefile and everything it made > in a temporary directory, but of course the > install put stuff in /usr/local and I don't know > where else, and I'd like to get rid of it all. I don't understand. If you didn't install as root, how can he have put files in /usr/local? You shouldn't have writing access there. > Please forgive such a newbie question, but "make > uninstall" is the only method I know to get rid > of a program, that just gives me Yau can simply remove the different parts with "rm". If it's not installed as RPM that isn't dangerous anyway. regards, Gerrit. -- **************************************************************************** * Save Mother Earth! -- Earth First! -- visit http://www.earthfirst.org/! **************************************************************************** From spamfranke at bigfoot.de Fri Oct 27 10:32:45 2000 From: spamfranke at bigfoot.de (Stefan Franke) Date: Fri, 27 Oct 2000 14:32:45 GMT Subject: Hyphenation algorithm in Python? References: <39f983fd.3380109@news.btx.dtag.de> Message-ID: <39fa9209.4728193@news.btx.dtag.de> In the meantime I managed to compile libhnj and pyHnj myself. If anyone else is interested, just mail me. Thanks anyway, Stefan On Thu, 26 Oct 2000 19:20:42 GMT, spamfranke at bigfoot.de (Stefan Franke) wrote: >I'm looking for a hyphenation algorithm in Python. On parnassus I found >an interface to libhnj, but since I'm on a Win32 machine, I'm not able >to compile it. > >Does anyone know about a Python-only algo or an Win32 compiled >version of libhnj?. > >Thanks in advance, >Stefan From donn at u.washington.edu Thu Oct 26 12:29:45 2000 From: donn at u.washington.edu (Donn Cave) Date: 26 Oct 2000 16:29:45 GMT Subject: plagued by IOError: [Errno 0]? References: <39F78AE1.AEE0C16@cs.utwente.nl> Message-ID: <8t9m5p$gf8k$1@nntp6.u.washington.edu> Bill Janssen wrote: | I'm running a server that periodically, and unpredictably, keeps | getting an IOError when opening a file. But the Errno is 0! What | does this mean, and how can I get rid of it? | | I'm running on a Solaris 2.6 SPARC system, and the files being opened | are relatively large (3.4 MB) on NFS-mounted file systems. Python 1.5.2. | | IOError: [Errno 0] Error: '/docRepository/NewRepoDoc/1' | I'm doing an "open(fname, 'r')". This should not happen, of course. If you have a system error reporting facility (I don't know Solaris), that would be one place to check for an explanation. The only thing I can guess your program could do is "try again". I would be tempted to get away from the file object I/O, because it's implemented on C stdio and inherits problems typical of C software. But that's long odds, and probably not worth it if the input is going to be line oriented or otherwise unsuitable for posix I/O. Donn Cave, donn at u.washington.edu From robin at alldunn.com Fri Oct 20 12:44:03 2000 From: robin at alldunn.com (Robin Dunn) Date: Fri, 20 Oct 2000 16:44:03 GMT Subject: ActivePython 2.0 Release References: <634vusk9nco8qem70ddo43t4qpgid30s1l@4ax.com> <8sp2he01b00@news1.newsguy.com> Message-ID: <8spsoh$csm$1@nnrp1.deja.com> > > One little plus (from my POV) I noticed in their previous build is > that the docs in the Windows build are in CHM, which I find quite > preferable to bare HTML (built-in index and search, etc), although > there were lots of defects in the .CHM themselves (missing/wrong > indices, etc). > I've built a .CHM from the BeOpen python docs. You can get it at http://alldunn.com/python/py2docs.zip. I just did a quick hack on a python script (included) I had laying around from 1.5.2 to make it find the extra docs added since then. The script produces the stuff needed for the MS HTML Help compiler. I havn't found anything missing yet, but no guarantees... -- Robin Dunn Software Craftsman robin at AllDunn.com http://wxPython.org Java give you jitters? http://wxPROs.com Relax with wxPython! Sent via Deja.com http://www.deja.com/ Before you buy. From hinsen at cnrs-orleans.fr Wed Oct 25 04:56:00 2000 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 25 Oct 2000 10:56:00 +0200 Subject: [Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich comparison References: <39EB3D03.A00C78B6@jps.net> <39F4A4DE.9202540A@udel.edu> <8t3ota028jv@news2.newsguy.com> <39F5AA7A.2C5E35CE@udel.edu> <8t4dl301a4@news2.newsguy.com> Message-ID: Jon Ribbens writes: > My opinion is that floating point is Dangerous and To Be Avoided > unless you know what you're doing. The language should not create I don't disagree, but defining / as integer division doesn't solve the problem. If integer division is not what is called for in a certain algorithm, its presence is a bug and will sooner or later be detected and fixed (by substituting float division). What we are discussing here is not whether you should use floating point, but what the most reasonable interpretation for a certain syntax is. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From gibert at home.com Thu Oct 5 11:16:54 2000 From: gibert at home.com (Ricardo Gibert) Date: Thu, 05 Oct 2000 15:16:54 GMT Subject: type() and types References: Message-ID: "Terry Hancock" wrote in message news:mailman.970707849.16385.python-list at python.org... > Hi, > I'm implementing a new object class in Python to > do fuzzy logic, and for various reasons I need > to check the type of variables to determine if they > are fuzzy logic values. > > It seems like the "right" way to do this is to > somehow provide type() the capability to do this, > and this seems to be how some of the standard > modules work (since they provide new types), but > amongst "Learning Python" the "Python Reference > Manual" and the "Python Library Reference" I'm > not able to figure out how this is done. Maybe > I'm just being thick, but I couldn't find anything > about it. What am I missing? > > Does anyone know how to do this? > TiA! > > -- > Terry Hancock > hancock at earthlink.net > Maybe this will help: http://www.ourobourus.com/logic.py From linuxqna at chollian.net Fri Oct 20 09:01:17 2000 From: linuxqna at chollian.net (junwon,Seo) Date: Fri, 20 Oct 2000 22:01:17 +0900 Subject: How can I send mail to 'Cc'address in smtplib? Message-ID: <8spfg4$s7$1@news2.kornet.net> First, mycode follows.. Each address is string. Examply "python at python.org mailto:python1. at python.org" If each address contain Space, Space mean multiuser send.. But, 'Cc'address isn't running. How can I send mail to 'Cc' address? ------------------------------------------------- import smtplib import string class smtp: def __init__(self, fromadr, toadrs, ccadrs, subject, body): self.smtphost = 'ns.philemon.co.kr' self.server = smtplib.SMTP(self.smtphost) self.fromadr = fromadr self.toadrs = string.split(toadrs) self.ccadrs = string.split(ccadrs) self.subject = subject self.body = body self.rfc822 = self.getrfc822() def getrfc822(self): envelop = ('From: %s\r\nTo: %s\r\nCc: %s\r\nSubject: %s\r\n\r\n' % (self.fromadr, string.join(self.toadrs,', '), string.join(self.ccadrs,', '), self.subject)) return envelop + self.body def send(self): self.server.sendmail(self.fromadr, self.toadrs, self.rfc822) self.server.quit() mymail = smtp('fromaddress','toadrs','ccadrs','subject','body') mymail.send() ------------------------------------------------- From steveamyers at my-deja.com Fri Oct 27 14:35:51 2000 From: steveamyers at my-deja.com (steveamyers at my-deja.com) Date: Fri, 27 Oct 2000 18:35:51 GMT Subject: Python/C++ Engineers Wanted Message-ID: <8tchu7$2gd$1@nnrp1.deja.com> Keep reading if any of the following interest you: Linux, Beowulf, Apache, Zope, Python, C++, Macy's, the Gap, JC Penney, Solaris, Boston. Our Company: TSI develops custom mathematical optimization models to help major retailers determine merchandise markdown strategies that maximize gross profit. Our mathematical modeling techniques use a retailer's own sales history to help them understand and anticipate what customers will buy and at what price. Our solutions are producing increases in gross margin dollars for many of the nation's leading retailers including Ann Taylor, Best Buy, Gymboree, Macy's West, J.C. Penney, Ross Stores, and The TJX Companies. Our Culture: TSI represents a highly dynamic, exciting, entrepreneurial career opportunity for high- energy, motivated individuals with the requisite combination of analytical expertise and business acumen. We constantly set aggressive targets at TSI and then strive to exceed them. As TSI continues its rapid growth the firm expects its associates to play mission critical roles early in their careers. There is no limit to the level of responsibility, professional growth, or financial reward an associate at TSI can achieve. The key is contribution -- how your efforts contribute to the success of our clients, and in turn, to the success of this talented, fast paced, high achieving team. How do we do what we do? We've got a beowulf cluster. A Beowulf is a linux based, commodity parts supercomputer. Our web based front end runs Apache and Zope and it all plugs into our solaris E450s running Oracle. Most of our software development is in python or C++. We use Extreme Programming Methodology, so there is a lot of teamwork, mentoring, and support. We are currently seeking to add several members to our development team. The successful candidate will possess 2-3 years experience developing software in C++/Python on a UNIX/LINUX platform in a business environment. TSI believes in strength through diversity. Our developers have worked on Lotus Notes and Improv, NASA's X-ray orbital telescope and the air traffic control system for the US. Our math people also have varied backgrounds: some pure math folks, some astrophysicists, some electrical engineers, and some economics people. Salaries are very competitive and include paid medical/dental, 401(k), annual bonus, stock options and a fun, casual environment. We're located on the red line 2 blocks from Kendall Square and MIT in beautiful Cambridge, MA. Please send your resume to smyers at grossprofit.com. Thanks! Sent via Deja.com http://www.deja.com/ Before you buy. From gehlker at fastq.com Thu Oct 26 12:18:25 2000 From: gehlker at fastq.com (Chris Gehlker) Date: Thu, 26 Oct 2000 09:18:25 -0700 Subject: Absolute newbie install question Message-ID: <39F85952.270A891F@fastq.com> I'm trying to run Python on OS X but when I open a terminal window and type "python" it says: [localhost:~] chrisg% python Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] 'import site' failed; use -v for traceback Python 2.0 (#2, 10/21/00, 15:40:22) [GCC Apple DevKit-based CPP 5.0] on Darwin1.2 Type "copyright", "credits" or "license" for more information. >>> Calling on my aging and always limited unix knowledge, I was able to determine that the python executable is at: Mac OS X/bin/python while there is a lot of Python related stuff in a hierarchy under: Mac OS X/lib/python2.0/ I'm assuming that Python just needs to be told where this stuff is but I have no idea how to do it. I did look at python.org for information on how to solve this problem but I either couldn't find or didn't recognize the answer. Is there an absolute newbie faq someplace? -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From jhylton at my-deja.com Wed Oct 25 22:20:26 2000 From: jhylton at my-deja.com (Jeremy Hylton) Date: Thu, 26 Oct 2000 02:20:26 GMT Subject: Python 2.0 and pyexpat References: Message-ID: <8t84d5$g3u$1@nnrp1.deja.com> In article , Paul Prescod wrote: > You need expat 1.1. Get it here: > > ftp://ftp.jclark.com/pub/xml/ > You can also download expat as a Linux RPM from http://www.python.org/2.0/ -- -- Jeremy Hylton, Sent via Deja.com http://www.deja.com/ Before you buy. From erno-news at erno.iki.fi Fri Oct 27 18:59:42 2000 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 28 Oct 2000 01:59:42 +0300 Subject: UTF-8 usage in Python 2.0 References: <1ej6pys.13l2czx178nfctN@paris11-nas9-37-62.dial.proxad.net> Message-ID: | On the professional side, I receive html files translated to french. | They are coded in html entity. I need to translate them to UTF-8. I | currently use Tidy to do this, but I need to do some manual | modifications after it. you can use the unicode() built-in function to convert old-fashioned 8-bit strings to unicode, using various character sets (i don't remember what character set macos uses, but you get the idea): s = unicode('k??pi?', 'latin-1') now s is a unicode string equivalent to the unicode string constant u'k\N{LATIN SMALL LETTER A WITH DIAERESIS}\N{LATIN SMALL LETTER A WITH DIAERESIS}pi\N{LATIN SMALL LETTER O WITH DIAERESIS}' you can convert it back to a 8-bit string with s.encode(encoding-name). for example s.encode('utf-8') -> 'k\303\244\303\244pi\303\266' -- erno From raja at cs.indiana.edu Mon Oct 9 13:26:38 2000 From: raja at cs.indiana.edu (Raja S.) Date: 9 Oct 2000 17:26:38 GMT Subject: numerals -> words Message-ID: <8rsv4e$43a$1@flotsam.uits.indiana.edu> Common Lisp's format statement has a "~r" directive which can be used to convert a numeral into it's English description: * (format t "~r" 1992) one thousand nine hundred ninety-two * (format t "~R" 1992) one thousand nine hundred ninety-two * (format t "~R" 47) forty-seven * (format t "~R" 2000) two thousand * (format t "~R" 2001) two thousand one Is there a pre-existing way of doing the equivalent in Python? Thanks in advance. Raja Thought I'd ask first before building something custom. Should be straight forward to do for a limited range though the CL folks have pretty much gone all the way !! * (format t "~R" 1234567890123456789012345678901234567890) one duodecillion two hundred thirty-four undecillion five hundred sixty-seven decillion eight hundred ninety nonillion one hundred twenty-three octillion four hundred fifty-six septillion seven hundred eighty-nine sextillion twelve quintillion three hundred forty-five quadrillion six hundred seventy-eight trillion nine hundred one billion two hundred thirty-four million five hundred sixty-seven thousand eight hundred ninety * From junaftnoon at nospamplzyahoo.com Sat Oct 21 17:09:12 2000 From: junaftnoon at nospamplzyahoo.com (June Kim) Date: Sun, 22 Oct 2000 06:09:12 +0900 Subject: detrail the trailing space in print statement Message-ID: <8st0m9$l15$1@news.nuri.net> for i in (a list of a huge size): do something quite complex print f(i), do something else In this code, what I really want to do is printing out "f(i)" as a stream. I can remove the newline character by adding a comma but cannot remove the trailing space which is automatically inserted at the end of the object. (adding up the f(i) objects in the loop, and outputting the whole stuff in one string out of the loop sounds not very good, 'cuz it will take up a large size of memory) Any comments? From hans.kristian.ruud at inenco.no Mon Oct 2 07:15:33 2000 From: hans.kristian.ruud at inenco.no (Hans Kristian Ruud) Date: Mon, 02 Oct 2000 11:15:33 GMT Subject: Accessing a COM object from Python References: <39D317F2.B0346D5A@inenco.no> Message-ID: <39D86CCD.AA33B640@inenco.no> Martin von Loewis wrote: > Hans Kristian Ruud writes: > > > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, > > pythoncom.IID_IDispatch) > [...] > > Any ideas??? > > It appears that CoCreateInstance failed. That, in turn, would indicate > that either your server is not properly registered, or does not > provide an IDispatch interface. > It turned out that I had the Distributed COM Server incorrectly configured, so that pythoncom tried to execute the application in question on my own PC, instead of the correct remote computer. > > Regards, > Martin Thanks for your advice, -- Hans Kristian From jorgen at bos.nl Mon Oct 16 08:54:36 2000 From: jorgen at bos.nl (Jørgen Teunis) Date: Mon, 16 Oct 2000 14:54:36 +0200 Subject: python + ldap + ERROR!! HELP! References: <971690230.373315@proxy.bos.nl> Message-ID: <971700850.511588@proxy.bos.nl> So...... after installing python 1.6 this problem is solved...... now i've to learn how it works. Thanks for sofar! Greatings J?rgen "J?rgen Teunis" schreef in bericht news:971690230.373315 at proxy.bos.nl... > So.... after a lot of work, installing, > making.................................. guess what.... it still won't > work... > can anybody explain what this wonderfull error means? > > Thanks, > J?rgen > > Traceback (innermost last): > File "ldap.cgi", line 3, in ? > import _ldap > ImportError: ld.so.1: python: fatal: relocation error: file > /usr/local/lib/python1.5/site-packages/_ldapmodule.so: symbol ldap_bind_s: > referenced symbol not found > > From matt at mondoinfo.com Sun Oct 22 14:29:56 2000 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Sun, 22 Oct 2000 18:29:56 GMT Subject: Reverse NS Lookup References: Message-ID: On Sun, 22 Oct 2000 17:43:03 GMT, Simon Faulkner wrote: >How do I find the domain name of an IP address? If you're running under Unix, you could open a pipe from nslookup (or another similar command line tool) and parse the result: import os import string def main(): p=os.popen("/usr/bin/nslookup 208.185.174.123") while 1: l=p.readline() if l[:6]=="Name: ": domainName=string.strip(l[6:]) break p.close() print domainName While that's not hard, it leaves you vulnerable to a change in nslookup's output format. Alternatively, you can prolly use the dns code that's in the source distribution's Demo directory. I've been using Anthony Baxter's improved version of that code. You can find information about it at: http://www.vex.net/parnassus/apyllo.py?i=632080673 If you're using that code, all you need to do is: >>> import DNS >>> DNS.ParseResolvConf() >>> DNS.revlookup("208.185.174.123") You should be aware that a very small number of evil spammers deliberately put false information in their reverse lookup databases and that a fair number of clueless admins don't put any data in them. Regards, Matt From sjuranic at condor.ee.washington.edu Thu Oct 26 20:47:10 2000 From: sjuranic at condor.ee.washington.edu (Steve Juranich) Date: Thu, 26 Oct 2000 17:47:10 -0700 Subject: Is global really global. Message-ID: So far, I really love Python. However, the most confusing part of it for me is definitely the whole namespace business. I'm writing a suite of modules that are supposed to work in concert. In the "main" module, I read in a file that specifies all of the run-time paramters that the program is supposed to use. Here is where I define the "options" structure: global options options = read_options(parfile) Where the read_options function works a little magic on the file and returns the table (one of my own classes) that contains all of the information that the user specified in a parameter file (or "parfile"). This all happens in a module called "Peaks.py". Later on, I try and test some values in "options" via: if options.no_coda: # Eventually, here's where I'd remove the coda, but for # now, just... raise NotImplementedError, \ "I can't deal with the no_coda option yet." Please ignore the fact that I don't have the option implemented yet. <0.5 wink> The test above happens in a module called "Locator.py". But the above test when I try to run it, gives me: condor (peaks)$ Peaks.py parfile.peaks first_list First Traceback (most recent call last): File "./Peaks.py", line 75, in ? main_loop() File "./Peaks.py", line 66, in main_loop peaks = Locator.f0_peak_locator(frames) File "./Locator.py", line 23, in f0_peak_locator if options.no_coda: NameError: options Why is this happenning even though I specified "options" as a global? This causes me to suspect that "global" means something different in Python than it does in C (which isn't a bad idea). Am I misunderstanding the meaning of "global", or is something else afoot? How do I work around this? I know using globals isn't good anyway, but I'm to the point that I _really_ need to show my professor that I've been doing more than sitting on my thumb for the past couple of weeks (read: I need to get something done _quickly_). Thanks for the help. trying-to-adjust-to-life-in-grad-school-ly y'rs, ---------------------------------------------------------------------- Stephen W. Juranich sjuranic at ee.washington.edu Electrical Engineering http://students.washington.edu/sjuranic University of Washington http://rcs.ee.washington.edu/ssli From aleksei.guzev at bigfoot.com Wed Oct 4 14:07:05 2000 From: aleksei.guzev at bigfoot.com (Aleksei Guzev) Date: Thu, 5 Oct 2000 00:07:05 +0600 Subject: Unicode and win2k Message-ID: I mentioned a problem with cyrillic letters in Python strings. These do work well while simple output and even while I use Cyrillic strings as dictionary keys. But problem was using Russian words as entries of wxPython's menus. These are correctly displayed but the vlue returned from wxPython to my code IS NOT MY STRING and looking for the result in a dictionary fails. Printing error message consequently fails because it uses str() Aleksei Guzev From thehaas at my-deja.com Fri Oct 20 11:32:54 2000 From: thehaas at my-deja.com (thehaas at my-deja.com) Date: Fri, 20 Oct 2000 15:32:54 GMT Subject: A suggestion for python 2.1. References: <39f09400.33100312@nntp.interaccess.com> <8smuqv$1o9$1@flotsam.uits.indiana.edu> <39ef27c1.3714328@nntp.interaccess.com> <8snf03$dhu$1@nnrp1.deja.com> <8FD38670Fduncanrcpcouk@194.238.50.13> Message-ID: <8spoj6$8p0$1@nnrp1.deja.com> In article <8FD38670Fduncanrcpcouk at 194.238.50.13>, duncan at rcp.co.uk (Duncan Booth) wrote: > >Really? > I think the command line stuff may be an NT only trick (presumably also > Win2K but I haven't checked). Win9X is pretty broken in this respect. > On NT, if you also remember to modify the PATHEXT environment variable to > include .py, then you don't need to include the extension when running a > script. > I think you are right - sorry for the confusion. I've only ran Python- Win on NT - never on 9x. Sorry for the confusion. Mike Sent via Deja.com http://www.deja.com/ Before you buy. From loewis at informatik.hu-berlin.de Sun Oct 1 04:58:00 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 01 Oct 2000 10:58:00 +0200 Subject: Character set conversion between mac and pc References: Message-ID: Pieter Claerhout writes: > does anyone has a module which is able to convert text in a > macintosh characterset to a windows characterset? If not, how would > one accomplish this in Python? I think you will have to use the > string.translate function, but I couldn't find out how this one > works? The critical piece of information here is the translation table: you need to know which character in the mac character set corresponds to which on in the windows character set. Such information is available from many places, e.g. in /usr/share/i18/charmaps on a Linux system, or in the encodings directory of Python 2. With this information, you construct a string of 256 characters. The index into the string is the ordinal of a Mac character, the character at the index is the corresponding Windows character. To actually construct a table, you'd need to specify which Mac charset (roman, greek, cyrillic) and which Windows codepage. With Python 1.6/2.0, you can convert the original string to Unicode, then convert it back to the target code mac="..." universal = unicode(mac,"mac-roman") windows = universal.encode("cp1252") Regards, Martin From kthangavelu at earthlink.net Tue Oct 17 04:52:38 2000 From: kthangavelu at earthlink.net (Ender) Date: Tue, 17 Oct 2000 08:52:38 GMT Subject: Mass Text Indexing Tools Message-ID: Does anyone know of some good mass text indexing/searching tools (preferrable open source) that are accessible from python. i've tried using popen2 calls to grep but it starts to flag around 50Mbs. text material consists of around a hundredb thousand small files (emails). From duncan at rcp.co.uk Tue Oct 24 04:39:51 2000 From: duncan at rcp.co.uk (Duncan Booth) Date: 24 Oct 2000 08:39:51 GMT Subject: C's syntax (was Re: Python Formatted C Converter (PfCC)) References: <8t0or303ee@news1.newsguy.com> <39F4FFB7.452EDDEC@alcyone.com> Message-ID: <8FD76AC73duncanrcpcouk@194.238.50.13> wolfson at midway.uchicago.edu (Ben Wolfson) wrote in : >So with > >int (*a)[5]; > >you start with a)[ and proceed outwards? > One of the best description of this comes out of Microsoft's manuals (see http://msdn.microsoft.com/library/devprods\vs6\visualc/vclang/_clang_interp reting_more_complex_declarators.htm for the source of this excerpt): [I don't believe it! Microsoft actually have backslash separators in their URL!] A simple way to interpret complex declarators is to read them ?from the inside out,? using the following four steps: 1. Start with the identifier and look directly to the right for brackets or parentheses (if any). 2. Interpret these brackets or parentheses, then look to the left for asterisks. 3. If you encounter a right parenthesis at any stage, go back and apply rules 1 and 2 to everything within the parentheses. 4. Apply the type specifier. char *( *(*var)() )[10]; ^ ^ ^ ^ ^ ^ ^ 7 6 4 2 1 3 5 In this example, the steps are numbered in order and can be interpreted as follows: The identifier var is declared as 1. a pointer to 2. a function returning 3. a pointer to 4. an array of 10 elements, which are 5. pointers to 6. char values. From aleaxit at yahoo.com Wed Oct 25 05:31:17 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 25 Oct 2000 11:31:17 +0200 Subject: C's syntax References: <8t0or303ee@news1.newsguy.com> <8t1964$v8a$1@news7.svr.pol.co.uk> <17WI5.58198$oN2.2362868@news20.bellglobal.com> <39F45B51.320AA63F@alcyone.com> <8t1nr90105v@news1.newsguy.com> <39F4FEAF.FA466927@alcyone.com> <8t3nt4027fk@news2.newsguy.com> <8t4gv3$81f$1@newsg3.svr.pol.co.uk> <8t4q8s01lpv@news1.newsguy.com> <39F65E15.E48A2144@alcyone.com> Message-ID: <8t69ia0550@news1.newsguy.com> "Erik Max Francis" wrote in message news:39F65E15.E48A2144 at alcyone.com... > Alex Martelli wrote: > > > No. But the desperate need for warnings to ameliorate > > some of the ill-effects of its tortured syntax, oh yes, it > > most definitely _is_ one of C's weaknesses. > > There is no need for amelioration, because what you describe is a novice > error, extremely rarely made by competent C programmers. If you're so You've stated this repeatedly, bringing no proof. You have not rebutted Koenig's opinion (in his book on "C Traps and Pitfalls"), based on long experience using C and teaching it to very competent programmers, that this just isn't so. I concur with Koenig, based on now-even-longer experience (his book was written only about 10 years after C was invented). Your bare, unsupported statement disagree. Bring proof, or shut up. It's first of all a keyboard issue. "stutter" and its reverse _happen_. Word processors' checkers warn you about repeated words (e.g., "I was was happy") exactly because of that: they ARE a common mistake, NOT rarely made by competent English writers. > worried about accidentally invoking that bit of trivial user error, then > there's no need to use weird syntax (always putting the lvalue on the "if(0==c)" is perfectly valid C syntax. Now, you're calling this syntax "weird". So, will you agree that C syntax IS weird, or will you keep contradicting yourself...? > You are doing a fairly good job of misrepresenting what other people are > saying. Only in as much as "other people" (I can't see anybody else but you...) assert contradictions. It's easy, then, since from a contradiction anything can be formally deduced. You, for example, claim that the C syntax "if(0==c)" is weird, and that any compiler should be able to stop you from using the C syntax "if(c=0)", and in the same breath keep claiming that this syntax (of which some parts you call weird, others any compiler should be able to warn against...) is "good". This is quite clearly self-contradictory, so it's fun to poke holes in the sum total of your contentions. And flamewars have always been a good part of Usenet's fun...:-). Alex From hs at paradise.nirvananet Fri Oct 27 21:28:37 2000 From: hs at paradise.nirvananet (Hartmann Schaffer) Date: 27 Oct 2000 21:28:37 -0400 Subject: Python scoping References: <8tab8k024o3@news1.newsguy.com> Message-ID: <8tda45$626$1@paradise.nirvananet> In article , Steve Horne wrote: >On Fri, 27 Oct 2000 00:28:15 +0200, "Alex Martelli" > wrote: > >>I recall that in PL/I you may, if you wish, recall the label in >>the END clause (or was it Ada...? darn -- big languages, long >>ago...): couldn't that be used for 'multiple closure' (i.e. it also close all blocks that started within foo that weren't terminated yet)> > ... hs From SBrunning at trisystems.co.uk Fri Oct 27 10:17:14 2000 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Fri, 27 Oct 2000 15:17:14 +0100 Subject: Keywords searching via regexp Message-ID: <31575A892FF6D1118F5800600846864D5B1361@intrepid> > On 27-Oct-00 Eugene A.Tyurkin wrote: > > I have a list of keywords: keywords = > ['qwerty','is','a','good','keyboard'] > > and want to find any of them in some text > > The question is: how to write correct regexp to find them? > > Notice, that I don't want to find words like 'goody', I want exectly > my > > keywords > > But I also want to find strings like 'qwerty', #good# etc > > Here what I've tryed: > > > > regexp = r"[^w]*\s+(" + string.join(keywords.'|') + r")"[^\w]*\s+" > > aaa = re.compile(regexp) > > ... > > > > It works fine, but it never find the word at the beginnig or the end > of > > line. Try (untested): regexp = r'\b(' + '|'.join(keywords)+ r')\b' Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk I wouldn't recommend alcohol and drugs to anyone. But they have always worked for me. - Hunter S. Thompson ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From loewis at informatik.hu-berlin.de Tue Oct 3 11:20:51 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 03 Oct 2000 17:20:51 +0200 Subject: Printing under Tkinter References: <39D832AA.DB10EF4D@hotmail.com> Message-ID: Sreekant Kodela writes: > Is there a decent printing support under Tkinter especially for win32. Not that I know of. Canvases can produce PostScript - that's about it. Regards, Martin From nkauer at my-deja.com Sat Oct 28 16:52:47 2000 From: nkauer at my-deja.com (Nikolas Kauer) Date: Sat, 28 Oct 2000 20:52:47 GMT Subject: PythonLabs Team Moves to Digital Creations References: Message-ID: <8tfeat$72q$1@nnrp1.deja.com> In article , "Tom" wrote: > Some of this sounds good, but some is a bit scary. I concur with Tom. Take a moment and compare: --- announcement, May version Guido and the Python Team Join [com/org] What changes is how much time we have for Python. Previously, Python was a hobby or side project, which had to compete with our day jobs; at [com/org] we will be focused full time on Python development! This means that we'll be able to spend much more time on exciting new projects like [future Python version]. [...], and we'll work with their marketing department. Marketing for Python, you ask? Sure, why not! We want the Python user and developer community to grow at an even faster pace than today. This should benefit everyone: the larger the community, the more resources will be available to all, and the easier it will be to find Python expertise when you need it. We're also planning to make commercial offerings (within the Open Source guidelines!) to help Python find its way into the hands of more programmers, especially in large enterprises where adoption is still lagging. ---------- --- announcement, October version PythonLabs Team Moves to [com/org] [...] We will be spending part of our time on core Python development [...] and part of our time on Python infrastructure improvements that also benefit [main product of com/org]. [...] [com/org] has no desire to monetize or brand the Python language or specific Python distributions. All future work we do on Python as [com/org] employees will be owned by a non-profit organization yet to be created. We think of this new organization as the Python Software Foundation. [...] [com/org] are one of the oldest companies active in the Python community, one of the companies most committed to Python, and they have a great product! Plus, we know they have deep financial backing. We trust that [com/org] will provide a stable home for Python for many years. ----------- Obviously, the Python team/community and the New Economy business world (branding, marketing, profits etc.) didn't hit it off. Nevertheless, IMHO the exciting growth that Python currently experiences calls for a stable foundation, and a Python team working full time on Python. So, here's the announcement I'd like to see Guido post next year: --- PythonLabs Team moves to Python Software Foundation [...] What changes is how much time we have for Python. Previously, Python development was only part of our day jobs, and we also had to develop the main product of our employer; at PSF we will be focused full time on Python development! The Python Software Foundation is a non-profit organization that has no desire to monetize or brand the Python language or specific Python distributions. We trust that PSF will provide a stable foundation for Python for many years. ----------- The catch is of course how to pay for it, but I could imagine that something similar to the Python Consortium may be able to provide the necessary funding. Nikolas Sent via Deja.com http://www.deja.com/ Before you buy. From max at alcyone.com Mon Oct 23 23:19:19 2000 From: max at alcyone.com (Erik Max Francis) Date: Mon, 23 Oct 2000 20:19:19 -0700 Subject: C's syntax (was Re: Python Formatted C Converter (PfCC)) References: <8t0or303ee@news1.newsguy.com> Message-ID: <39F4FFB7.452EDDEC@alcyone.com> Rainer Deyke wrote: > int (*a)[5], *(b[5]); > > It looks like 'a' is an array of pointers and 'b' is a pointer to an > array, > but the opposite is the case. Makes perfect sense, if you that you read C declarations from the inside out. C is not a trivial language, so the rules are not trivial. If you have sloppy thinking or are not familiar with the details of the language, you will get yourself into trouble with a non-trivial language. But then that's true of a trivial language as well. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Who, my friend, can scale Heaven? \__/ _The Epic of Gilgamesh_ REALpolitik / http://www.realpolitik.com/ Get your own customized newsfeed online in realtime ... for free! From erno-news at erno.iki.fi Wed Oct 11 08:51:31 2000 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 11 Oct 2000 15:51:31 +0300 Subject: Possible bug (was Re: numpy, overflow, inf, ieee, and rich comparison) References: Message-ID: now that i read the post again, i see that you've already recompiled - nevermind. -- erno From MarkH at ActiveState.com Sun Oct 29 17:15:47 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Sun, 29 Oct 2000 22:15:47 GMT Subject: Using more than 7 bit ASCII on windows. References: <8tdlgd$r0t$1@news.nuri.net> <39FA90D9.7070403@ActiveState.com> <8tfpf7$jnn$2@troll.powertech.no> Message-ID: <39FCA0B5.6040606@ActiveState.com> Paul Moore wrote: > Yes, the whole setup for non-ASCII characters seems to be very odd, if > not broken. It is :-( I will fix it. If the code works in Python.exe (as yours appears to) it should work in Pythonwin.exe. > Looks like the net result is that Latin-1 and the like are now > as hard as the multi-byte character sets, rather than making the > multi-byte stuff as easy as Latin-1. Don't forget that Latin-1 is not Unicode. Python has chosen not to have a default character set. So you are correct, that the "accidental" behaviour of Python strings with characters > 127 were often "useful" as they used the current code page. with Unicode, such accidents can't happen - you must be explicit. > Someone please tell me I'm wrong, and explain how I should have done > this. You'll need to convince me that the fact that > > >>> os.chdir('10?') > > doesn't work is not a bug, first... I doubt you are able to be convinced, but it is a feature. The string you reference has no meaning without knowledge of the character set. Asian speakers would be happy to tell you why an assumption of "Latin-1" for the default character set is not always appropriate. That said, I still agree Pythonwin should behave the same as Python.exe - but _neither_ of them will allow your chdir() to work (but both _should_ correctly display the string) Mark. From allanwind at mediaone.net Mon Oct 16 16:51:31 2000 From: allanwind at mediaone.net (Allan M. Wind) Date: Mon, 16 Oct 2000 16:51:31 -0400 Subject: Which Web server is the most suitable for Python CGI Programming? In-Reply-To: <1dJG5.354199$1h3.9101580@news20.bellglobal.com>; from olivierS.dagenaisP@canadaA.comM on Mon, Oct 16, 2000 at 08:06:21PM +0000 References: <8sfd3p$2fh$1@news2.kornet.net> <1dJG5.354199$1h3.9101580@news20.bellglobal.com> Message-ID: <20001016165131.A12902@digit-safe.dyndns.org> On 2000-10-16 20:06:21, Olivier Dagenais wrote: > Apache would create a new process for each concurrent CGI instance. On some > operating systems, creating new processes is slow/slower. See www.fastcgi.com (and in particular mod_fastcgi). /Allan -- Allan M. Wind email: allanwind at mediaone.net P.O. Box 2022 finger: awind at digit-safe.dyndns.org (GPG/PGP) Woburn, MA 01888-0022 USA From jdries at mail.com Sat Oct 21 11:01:02 2000 From: jdries at mail.com (Jan Dries) Date: Sat, 21 Oct 2000 16:01:02 +0100 Subject: Eval the caller within a method? References: <8srn4j$lr8$1@newsreaderm1.core.theplanet.net> Message-ID: <39F1AFAE.1332FE92@mail.com> Franz GEIGER wrote: > > I wonder if in Python there is a possibility to evaluate the method which > called a method within that method like it is in Perl. > > Any ideas? Given you run the following python program (saved in file loginfo.py) from sys import exc_info def caller_info(): try: raise StandardError except StandardError: caller = exc_info()[2].tb_frame.f_back.f_back.f_code return (caller.co_name,caller.co_filename,caller.co_firstlineno) def log_info(msg): print "Message '%s' from function %s in file %s at line %s " % ((msg,) + caller_info()) def my_function(): log_info("some diagnostics") my_function() the output is: "Message 'some diagnostics' from function my_function in file loginfo.py at line 13" which I believe is what you were looking for. The trick is in the traceback object you can obtain once you get an exception. That contains the current stack frame (where the exception occured). Each stack frame has, among other things, a ref to the previous (the caller) frame (named f_back) and a ref to a code object named f_code. The latter has various members with info about the function. Regards, Jan From python9999 at my-deja.com Thu Oct 12 09:06:52 2000 From: python9999 at my-deja.com (python9999 at my-deja.com) Date: Thu, 12 Oct 2000 13:06:52 GMT Subject: pyGTK -- why can't I center a window? References: Message-ID: <8s4d18$aqt$1@nnrp1.deja.com> for setting any widget in gtk to center position you just have to do these simple steps. for example win=GtkDialog() win.set_position(WIN_POS_CENTER) win.show() bye satish Sent via Deja.com http://www.deja.com/ Before you buy. From tyler at tylereaves.com Sun Oct 29 09:20:31 2000 From: tyler at tylereaves.com (Tyler Eaves) Date: Sun, 29 Oct 2000 09:20:31 -0500 Subject: PyCounter 0.2 Available Message-ID: <2fcovs8i0imp8hg1ms8pkt8pgqss5mskl1@4ax.com> Version 0.2, of PyCounter, the Python hit counter, is available at http://www.tylereaves.com/python New Features in 0.2: Graphical Counters Commas when using text --- Tyler Eaves Visit Ultra Coaster Central! The internet's largest repository of Ultra Coaster Tracks! http://www.ultracoastercentral.com -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From the_brain at mit.edu Thu Oct 19 23:00:48 2000 From: the_brain at mit.edu (Alex) Date: 19 Oct 2000 23:00:48 -0400 Subject: Perl rules - Python drools References: <8s6ksl$mea$1@ctb-nnrp2.saix.net> <39e77de7.28583100@news.davesworld.net> <39EEE96B.7C8C8891@holdenweb.com> <9ZNH5.352184$Gh.10679486@news20.bellglobal.com> Message-ID: > > YHBT. YHL. HAND. > > I've read about that somewhere. What does it mean?? Something like "You have been trolled. You have lost. Have a nice day." Alex. -- Speak softly but carry a big carrot. From olivierS.dagenaisP at canadaA.comM Mon Oct 23 08:31:01 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Mon, 23 Oct 2000 12:31:01 GMT Subject: C's syntax (was Re: Python Formatted C Converter (PfCC)) References: Message-ID: <9cWI5.58227$oN2.2363172@news20.bellglobal.com> Unless you're "pulling our leg", http://web2.airmail.net/ktrig246/out_of_cave/sss.html -- ---------------------------------------------------------------------- Olivier A. Dagenais - Software Architect and Developer "Someone called 'Type your name here' is impersonating me on the internet and is posting exactly the same things I am posting!" "Mikael Olofsson" wrote in message news:XFMail.001023132458.mikael at isy.liu.se... On 23-Oct-00 Alex Martelli wrote: > [snip a lot of stuff] > a clear case of "Stockholm Syndrome"...:-) Being a Swede, I sure would like to know what the Stockholm Syndrome is. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 23-Oct-00 Time: 13:23:36 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From not.this at seebelow.org Sat Oct 28 11:35:19 2000 From: not.this at seebelow.org (Grant Griffin) Date: Sat, 28 Oct 2000 16:35:19 +0100 Subject: How do you create constants? References: Message-ID: <39FAF237.87444C5A@seebelow.org> Tom wright wrote: > > Hi All, > > I am a newbie to python, and I have the following question, > > in c++ I can create a constant through something like an enum, or a const > variable or a static. How do I go about doing something similar to this in > python, e.g. > > I want to create a python file/class which contains all my constants for > ease of use/maintenance. I then wish to use these from various other > files/classes. Now I understand that due to the scoping of python > variables, I can not simply reference variables in a separate module, but > how can I achieve something similar to my global defines file as in c++, by > the way, the defines would be constant strings and integers. > > I am sure there is an easy way to do this, but I havnt found it yet !! Python _does_ provide constants in two specific ways, strings and tuples. The term "immutable sequence" is used to characterize this. (I guess "immutable" must be a fancy word for "constant". ). You can think of tuples as "constant lists". However, unlike most other languages, Python doesn't have scalar constants; if you want those, you'll have to fake them somehow (as others have suggested.) if-you-can't-trust-yourself,-who-_can_-you-trust?--ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From mswiatek at home.com Thu Oct 26 21:24:45 2000 From: mswiatek at home.com (Marcin Swiatek) Date: Fri, 27 Oct 2000 01:24:45 GMT Subject: statistical modules for python? References: <87n1fsppkw.fsf@lumen.med.iupui.edu> Message-ID: Once upon a time there was a package, up there, on Parnassus. The 'crunchy' section, module stats.py. As far, as I remember, there were some ANOVA methods implemented. It worked with NumPy as well as on plain lists. Regards, -M- From BgPorter at NOartlogicSPAM.com Fri Oct 20 14:17:55 2000 From: BgPorter at NOartlogicSPAM.com (Brett g Porter) Date: Fri, 20 Oct 2000 18:17:55 GMT Subject: newbie References: <8soeic$57gs$2@newssvr05-en0.news.prodigy.com> <9_PH5.99786$g6.44454168@news2.rdc2.tx.home.com> <8sov2g0142d@news1.newsguy.com> <0SXH5.72992$ib7.10053637@news1.rdc1.nj.home.com> Message-ID: "Rainer Deyke" wrote in message news:Ot_H5.100984$g6.45105501 at news2.rdc2.tx.home.com... > "Brett g Porter" wrote in message > news:0SXH5.72992$ib7.10053637 at news1.rdc1.nj.home.com... > > Well, yes and no. There's a sane and simple subset that's easily learned > and > > used. Most people never have need for the more obscure corners of the > > language. But when I need them, I'm comforted knowing that they're there. > > The standard C++ library throws exceptions. Operator 'new' throws an > exception on failure. Thus, unless your sane subset uses the C library and > 'malloc' instead of 'new', your code is either exception-safe or incorrect - > and 90% of all C++ code isn't the former. > I have no interest in a Python vs C++ flame war. Love 'em both. Big sloppy kisses all around. If I was writing middleware or plain old apps, I could use Python for everything. But I don't, most of the time. I work on projects where I need to approach realtime, or move huge amounts of data, or interact with hardware. I've learned where the danger spots with C++ are -- they don't scare me, and the greater expressive potential of C++ over C makes it a simple choice for me. -- // Brett g Porter * Senior Engineer, Application Development // BgPorter @ artlogic . com * http://www.artlogic.com // Art & Logic * Custom software solutions for hardware products // Windows * MacOS * Embedded Systems From johann at physics.berkeley.edu Tue Oct 10 13:43:50 2000 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 10 Oct 2000 10:43:50 -0700 Subject: Newbie Q: (NumPy) how to write an array in a file ? References: <39E33793.ADEDAAEC@Noveltis.fr> <8rvf4a011p2@news2.newsguy.com> Message-ID: Alex Martelli writes: > "binary format" is *NOT* portable. If you write binary data on a > big-endian machine, you can't just transparently re-read it on a > little-endian machine -- it's even worse for floating-point data > in different formats! There's a CDF module out there somewhere, which sounds like precisely what you need, if portability is important. See http://starship.python.net/crew/hinsen/netcdf.html -- Johann Hibschman johann at physics.berkeley.edu From daimun at home.com Thu Oct 19 23:39:23 2000 From: daimun at home.com (Alex McHale) Date: Fri, 20 Oct 2000 03:39:23 GMT Subject: Lets Talk More Threads References: <67DH5.155361$Qx4.5103925@news1.rdc1.il.home.com> <8sn4oa$qe$1@panix3.panix.com> Message-ID: Indeed, I was merely misreading. It was one of those things where your mind picks it up as one thing, and no matter how many times I read it, I still read it wrong. I misread 'at most once' for 'at least once'. Sorry for the bad post. On the plus hand, I've got it working beautifully for what I was wanting :). Alex "Aahz Maruch" wrote in message news:8sn4oa$qe$1 at panix3.panix.com... > In article <67DH5.155361$Qx4.5103925 at news1.rdc1.il.home.com>, > Alex McHale wrote: > > > >Using the Thread class, which I'm extremely happy with, I've run into > >a problem. The documentation on the class suggests that you can > >obj.start( ) a thread multiple times. Yet, when I do this, I get an > >error to the effect of "thread already started" What I'm needing to do > >is have a thread which I can resurrect over and over. > > If you tell me where in the docs it says this, I can either get it fixed > or explain why your reading is wrong. The simplest good way to deal with > this is to use a Queue object to pass work to the thread. > -- > --- Aahz (Copyright 2000 by aahz at pobox.com) > > Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ > Hugs and backrubs -- I break Rule 6 > > "real love can't be explained by simplistic platitudes." --piranha From -$Paul$- at verence.demon.co.uk Sun Oct 15 17:42:54 2000 From: -$Paul$- at verence.demon.co.uk (Paul Wright) Date: 15 Oct 2000 21:42:54 -0000 Subject: SMTP receive as well as send References: <39e8bfe4.2248931@news.demon.nl> <39e9d941.419253@news.demon.nl> Message-ID: <8sd8cu$r4$1@verence.demon.co.uk> In article <39e9d941.419253 at news.demon.nl>, benny wrote: >Hi folks, > >Aha. Okay, it looks like I'm more confused than I thought & the setup >on the other side is more confused than I thought since it 'says' it >uses SMTP for in and out and never mentions POP at all. Sigh... looks >like it expects an SMTP client for sending and an SMTP server as a >receiver which it then leaves to sort things out however it wants. > >Many thanks everyone for the assistance and clarification and my >apologies for being unclear. I am very grateful for the help. If this is Demon, they do run a POP3 server as well, or at least the UK end of Demon does, so I assume the Netherlands (.nl?) end does too. -- ----- Paul Wright ------| "When in deep water, it's a good idea to keep your -paul.wright at pobox.com--| mouth shut." http://pobox.com/~pw201 | From hzhu at users.sourceforge.net Wed Oct 18 14:19:10 2000 From: hzhu at users.sourceforge.net (Huaiyu Zhu) Date: Wed, 18 Oct 2000 18:19:10 GMT Subject: all i want to do is plot a matrix!!! References: Message-ID: On Tue, 17 Oct 2000 09:39:32 +0100, taz wrote: > >i've looked in DISLIN, numpy, Pthyon imaging library... > >all i want to do is import an image (say .png, .gif) to a matrix of colour >values (rgb) so i can manipulate them with my own maths functions, do >lookups etc etc ... > >and be able to plot the images in a window... Here's a program I've played with, which displays an image of mandelbrot set with a faked rgb colormap, using the view function in NumTut (comes with Numeric). There may be better alternatives. Please let me know if you find one. #!/usr/bin/env python # view Mandelbrot set. Distribute freely. # # Rob Hooft, 1996. ASCII-art using Numeric Python 1.0beta1 # Tim Lavoie, 2000. Additional kluges and hackery, b/w view. # Huaiyu Zhu, 2000. Change to class, rgb view, some ckeanup and speedup. from Numeric import arange, NewAxis, zeros, where, greater, \ tanh, array, transpose from NumTut import view from time import time, sleep def color(x,a,b,c): """ Hacked rgb color map. Three control parameters, roughly: a is green, b is red, c is blue """ r = (tanh(-a*(x-b))+1)/2 b = (tanh(a*(x-c))+1)/2 g = 1-r-b return r, g, b def viewrgb(rgb, wtime=None): """ view rgb """ c = array(rgb) c = transpose(c,(2,1,0)) print c.shape view(c) wait(wtime) def wait(wtime): if wtime is None: input("Press Enter") else: sleep(wtime) class Mandelbrot: fraccode = 0 def __init__(self, frac='z*z+c'): self._time = time() self.fraccode = compile(frac, '', 'eval') def set_size(self, x0=-2.1, x1=0.7, y0=-1.2, y1=1.2, nx=20, ny=20): """Set the bounding box (x0, y0, x1, y1) and resolutions (nx, ny)""" self.xx = arange(x0, x1, (x1-x0)/nx) self.yy = arange(y1, y0, (y0-y1)/ny)*1j def calc(self, c0, z0, maxiter=30): """ Calculating Mandelbrot set. Initial value z Not updating c produces fancy bands outside the set result set to z.real is colored result set to finished is black and white""" print time() - self._time c = self.xx + self.yy[:,NewAxis] z = zeros(c.shape) finished = zeros(c.shape) print z.shape, c.shape, time() - self._time fraccode = self.fraccode for iter in range(maxiter): z = eval(fraccode) finished = greater(abs(z), 2) c = where(finished, c0, c) # external bands z = where(finished, z0, z) self.result = z.real #self.result = finished # black and white print z.shape, c.shape, time() - self._time def view(self, a=3, b=.2, c=1.3): "View result in rgb color" viewrgb(color(self.result, a, b, c), wtime=0) print time() - self._time if __name__ == "__main__": f = Mandelbrot() test_params = 1 if test_params: f.set_size(nx=160, ny=160) for c0 in [0.0, 0.15, 0.25]: for z0 in [1.0, 1.1, 1.25, 1.4]: f.calc(c0, z0, maxiter=30) f.view() else: print "This will take a while ..." f.set_size(x0=-0.712, x1=-0.707, y0=0.267, y1=0.272, nx=512, ny=512) f.calc(0.15, 1.1, maxiter=190) f.view() raw_input("Press Enter ...") From matt at mondoinfo.com Mon Oct 2 20:57:55 2000 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Tue, 03 Oct 2000 00:57:55 GMT Subject: Deselecting Radio Buttons References: <8rau6d$12sl$1@earth.superlink.net> Message-ID: On Mon, 2 Oct 2000 17:20:13 EDT, OneDay at A.Time wrote: >It must be possible to deselect a radio button after selecting it. >Would someone please tell me how? >PMVar = IntVar() >PMBut = Radiobutton(root, text="Select for P.M.", value=2, \ > variable=PMVar, padx=50) >PMBut.grid(row=1, column=2,sticky=E) >PM = PMVar.get() There are two ways to set radio buttons under program control. The buttons have select() and deselect() methods. Those methods work fine except that if you use deselect(), the related variable can take on a value you may not expect. It's simpler in my experience to control which button is selected by setting the value of the variable. If you want no radio button to be selected, set the variable to a value that isn't one of the radio buttons' values. In your case, PMVar.set(0) should work. Regards, Matt From sholden at holdenweb.com Thu Oct 12 13:07:21 2000 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 12 Oct 2000 13:07:21 -0400 Subject: Most Effective Way to Build Up a Histogram of Words? References: <39E5D3CF.62C6CE8E@holdenweb.com> <8s4nku$df7$1@news.nuri.net> Message-ID: <39E5EFC9.1DB4E2C@holdenweb.com> June Kim wrote: > > > Thank you for your clear and clean code. Mostly Simon Brunning's, in fact. > The problem, however, is that I might run through several of a few MB files, > summing up to tens of mega bytes when added into one file . As long as you are only processing one file at a time, this will probably be OK. Don't forget, the table grows with the number of unique words rather than with the filesize. > Therefore, to do the sorting all at once might sound somewhat unfeasible > or ineffecient. Am I trying to make Python a panacea here? ( I know it has > no snake oil though) > I can only repeat, try it and see. You may be pleasantly surprised. Enhance the code you have with a loop to iterate over all the files you want to read, and go take a cup of your favorite beverage :-) If it works you can deal with more complex issues later, but you will have proved its practicality. > Best Regards, > June regards Steve -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ From jon+python-list at unequivocal.co.uk Thu Oct 26 11:48:39 2000 From: jon+python-list at unequivocal.co.uk (Jon Ribbens) Date: Thu, 26 Oct 2000 16:48:39 +0100 Subject: dynamically loaded modules (.so files) does not work under openbsd In-Reply-To: <39f8228f.c8259@nancy.pacific.net.au>; from kiyolee*remove*@ctimail.com on Thu, Oct 26, 2000 at 11:24:59PM +1100 References: <39f791a1.1bcb7@nancy.pacific.net.au> <39F7CB6E.7B8D1CF2@san.rr.com> <39f8228f.c8259@nancy.pacific.net.au> Message-ID: <20001026164839.C11873@snowy.squish.net> Kiyo Kelvin Lee wrote: > So do I. It works under linux. So I am wondering if it's a problem of > OpenBSD. It is. See: http://sourceforge.net/bugs/?func=detailbug&bug_id=117070&group_id=5470 Cheers Jon From ahopkins at dynacare.com Mon Oct 30 12:00:32 2000 From: ahopkins at dynacare.com (Albert Hopkins) Date: Mon, 30 Oct 2000 17:00:32 GMT Subject: Creating printed source code listings References: <8t6mbq$766$1@nnrp1.deja.com> Message-ID: Sounds great! Let me know when you'll have this finished. --albert On Wed, 25 Oct 2000 13:14:41 GMT, jaepstein_63 at yahoo.com wrote: >Hi, > >This may be slightly off-topic, but here goes. While traversing source >code online using Speedbar, etags, etc. is all very nice, sometimes what >I really need is to print out a lot of code in a nice organized manner. >In particular, it would be nice to have: > (a) two page numbers: one local for each file, and the other global >for the entire comprehensive listing > (b) an index showing on which page(s) I can find references to a >particular symbol. Distinguishing between a function definition and >non-defining references would also be nice. > >At this point, I am mostly interested in such a tool for Python code, >but would like it in the future for Perl, C, Java, Matlab, and Elisp. > >I would prefer to be able to control this somehow through NT Emacs, but >both Unix-based solutions and non-Emacs-friendly solutions could also be >OK. > >Thanks for any pointers, > >-Jonathan > > >Sent via Deja.com http://www.deja.com/ >Before you buy. -- Albert Hopkins Sr. Systems Specialist Dynacare Laboratories ahopkins at dynacare.com Never trust a man who praises compassion while pointing a gun at you. -Eric S. Raymond From jwbnews at scandaroon.com Sun Oct 29 16:36:56 2000 From: jwbnews at scandaroon.com (John W. Baxter) Date: Sun, 29 Oct 2000 13:36:56 -0800 Subject: Using more than 7 bit ASCII on windows. References: <8tdlgd$r0t$1@news.nuri.net> <39FA90D9.7070403@ActiveState.com> <8tfpf7$jnn$2@troll.powertech.no> <1ej9fob.1tk3yaiz3glm9N@paris11-nas5-49-35.dial.proxad.net> Message-ID: In article <1ej9fob.1tk3yaiz3glm9N at paris11-nas5-49-35.dial.proxad.net>, never wrote: > >>> os.chdir('HD:') > >>> os.getcwd() > 'HD:' > >>> os.chdir('Textes ? garder') > >>> os.getcwd() > 'HD:Textes \210 garder:' > >>> > > So I don't understand ? I think it is repr() trying to give you a string which can be compiled into the original. Try print os.getcwd() instead. Whether repr() is being wise in this case is another issue. --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From Peter.Rupp at ual.com Tue Oct 3 10:08:46 2000 From: Peter.Rupp at ual.com (Peter.Rupp at ual.com) Date: Tue, 3 Oct 2000 09:08:46 -0500 Subject: How can you copy (clone) a string? Message-ID: All, I have a bonafide need to create copies of strings in a python program (as opposed to a reference to the original). I tried using the 'copy' module using both it's 'copy' and 'deepcopy' methods to no avail. I'm using the "id" function to determine whether I have a new string or a reference to an existing string. Let me illustrate...... from copy import * a='a' id(a) 1073972424 b=deepcopy(a) id(b) 1073972424 Huh? This is supposed to give me a new string refererence...as noted in the book 'Python Essential Reference' by David M. Beazley (pp. 95 in the last paragraph under the heading "NOTES", where he describes the feature as "This module can be used with simple types such as integers and strings, but there's little need to do so." Well, I really do have a need here ;-) Any help or suggestions would be appreciated...please respond via email as I cannot get news here. Thanks in advance. ==pete== P. A. Rupp - United Airlines Corp. peter.rupp at ual.com 847-700-3226 From thomas at cintra.no Fri Oct 20 10:26:00 2000 From: thomas at cintra.no (Thomas Weholt) Date: Fri, 20 Oct 2000 14:26:00 GMT Subject: Need the Request/URL running SimpleHTTPRequestHandler Message-ID: <39f05567.176615659@news.eunet.no> Hi, I'm trying to extend SimpleHTTPRequestHandler ( I've subclassed it ) and I need to get hold of the url the user submitted, or the request. If I could get any deeper, like getting it allready at the "protocoll"-level, like seeing what command the browser sent, like GET etc. that would be nice too. Thanks From rhymewright at poetic.web Sat Oct 21 01:36:42 2000 From: rhymewright at poetic.web (Bud) Date: Fri, 20 Oct 2000 22:36:42 -0700 Subject: Cultural practices (was: Announcing Jython, the sucessor to JPython (fwd)) References: <4B59CD4D5EC85ECD.2233701BB177DE7D.A05C52BC7B51EE72@lp.airnews.net> Message-ID: <39F12B6A.286040D3@poetic.web> Cameron Laird wrote: > > In article , > Lulu of the Lotus-Eaters wrote: > >"Alex Martelli" > >|And "Nike" was a term for "victory" (in Greek) from since > >|well before anybody raised coffee in the island of Java. > >|So why would it be 'more protectable' as a trademark...? > > > >'Nike' we can probably date from around 8th Century B.C., I imagine (I > >am not a Greek philologist, however). When did coffee cultivation > >begin? When did it begin on Java? > > > >Just curious. > > I love trivial trivia, :) Here's some info, just for fun: Nike, who carried a wreath to award to the victor in a battle or contest, was the goddess of Victory. Wings enabled this youthful goddess to fly down to earth to guide the victorious side. The most famous image of her is a statue in the Louvre. She was also known as Victoria. From:Grose Educational Media Greek Mythology go to: http://www.entrenet.com/~groedmed/mythnik.html to see an image of a Greek Revenue Stamp with her picture. Bud Please change ".web" to ".com" for corrected E-Mail Address From jhauser at ifm.uni-kiel.de Tue Oct 17 03:26:21 2000 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 17 Oct 2000 09:26:21 +0200 Subject: Pointing to function from class References: <8sgrd7$2u3c$1@nntp1.ba.best.com> Message-ID: <87k8b8dj36.fsf@ifm.uni-kiel.de> If your goal is to call a class function from the outside, you can do it the other way araound, namely generate an unbound function. class base: def SomeFunc(self): print 'Here' f = base().SomeFunc f() HTH, __Janko Adam Clark writes: > Hi. > > I want something like this: > > def SomeFunc () : > # doesn't take self and can be called from outside a class > > class Class : > f = SomeFunc > > c = Class() > c.f() > > I can't keep the class from trying to bind the function. > > Help! > Thanks > Adam -- Institut fuer Meereskunde phone: 49-431-597 3989 Dept. Theoretical Oceanography fax : 49-431-565876 Duesternbrooker Weg 20 email: jhauser at ifm.uni-kiel.de 24105 Kiel, Germany From drdjr at my-deja.com Wed Oct 18 20:19:04 2000 From: drdjr at my-deja.com (drdjr at my-deja.com) Date: Thu, 19 Oct 2000 00:19:04 GMT Subject: python resources/python vs php Message-ID: <8slelk$qvg$1@nnrp1.deja.com> Hello all, I am researching web development environments and it's narrowed down to php vs python (not zope). One of my main goals is to minimize development time and effort, and ease of supportability. I want to use an open source solution, as the ecommerce product my company (the company I work for, not "my" company:-) is developing will also released as open source. Regarding python, I have run into a couple of problems: 1. There is a dearth of information covering python in a web server environment (books, websites), as compared to php and perl. 2. The python related web application frameworks (psp, webware, etc.) all seem to be in early stages of development (besides zope) and most are poorly documented, and there is no clear "killer way to go". With php, everything is right there in one neat package, it is all very well documented and there are tons of books and sites to learn from. Also, php is php, there aren't all these variations of how to do it!! With python, it seems I need to cobble something together from very little documentation. Even the python documentation itself at python.org/doc/ leaves much to be desired. I'm finding all kinds of people swearing by webware or pmz or zope or psp etc., and I've found numerous self-promoting posts in this newsgroup. So I have hope!! However, I've only found the few examples that come with each package to learn from. Compare that to the wealth of documentation, books, and websites dedicated to php (php.net phpbuilder.net, webdever.org?net?...), the info on python solutions is really lacking. So, which way should I go? PHP(please! save me from the dark side!!)? python server pages or python serverpages or webware?? We really need something stable, complete, and well documented. I'm hoping that I just haven't found the resources for python that I'm looking for. I would very much like to use python. Thanks very much, Dan Daffer Sent via Deja.com http://www.deja.com/ Before you buy. From daniel.hops at eed.ericsson.se Wed Oct 11 02:40:00 2000 From: daniel.hops at eed.ericsson.se (Daniel Hops) Date: Wed, 11 Oct 2000 08:40:00 +0200 Subject: Sybase DB-Client module searched Message-ID: <39E40B3F.A8B9A911@eed.ericsson.se> I am looking for a python module to let me connect to a sybase 11 server. I already downloaded ctsybasemodule0.1b-r4, but I don't understand how to install it. It looks like I have to recompile python to get it working, which is not very easy, as our Sysops dont support python and I had to fight to install it in my /home dir. Isn't there any other choice or other module which lets me contact sybase servers? Regards Daniel Hops The passage that I dont understand / which dont works follows (I think it has to be used in the compilation process of python). Isnt there any option for which I dont have to recompile python? "To install ctsybasemodule, add a line like the following to your modules/Setup file. ctsybase dbi.c ctsybasemodule.c -I$(SYBASE)/include -L$(SYBASE)/lib -lblk -l ct -lcs -lsytcl -lcomn -lintl -ltli # -linsck Recompile python, and you should be all set. I don't know if this module works as a dynamically loadable module. I'd love to hear about it one way or the other. " -- ("`-''-/").___..--''"`-._ UNIX *is* user-friendly, he is just very `6_ 6 ) `-. ( ).`-.__.`) picky about who his friends are... (_Y_.)' ._ ) `._ `. ``-..-' _..`--'_..-_/ /--'_.' ,' (il),-'' (li),' ((!.-' From hoopy_frood at my-deja.com Mon Oct 2 17:19:50 2000 From: hoopy_frood at my-deja.com (hoopy_frood at my-deja.com) Date: Mon, 02 Oct 2000 21:19:50 GMT Subject: Python equivalent of Java Vector Message-ID: <8rau5e$afv$1@nnrp1.deja.com> I've been asked another Python question that's over my head, so I asked the querant to re-phrase it a bit so I could ask y'all. Here is his question: "Does Python have something equivalent to Java's Vector? For instance, most of the time if you want to use an array you have to declare the size up front. Java has a Vector class which is an array of objects which grows as you add things to it. "Just curiousity on my part really, but if you are serious about using Python productively, you probably need to answer that. In Java, for instance, if I want an array of String I say "String tmp[]=new String[5]" and I have an array of Strings with 5 slots. If I didn't know how many Strings I was going to have though, I could say "Vector tmp=new Vector()" then every time I wanted to add a String, say "String tmpvalue" I could say "tmp.addElement(tmpvalue)". Then, I could say "tmp.size()" to see how many elements were in the Vector, and I can even to a "tmp.elementAt(int x)" to retrieve a value. So, I think the terminology would be that Java supports dynamic arrays of objects. I was wondering if Python had the equivalent." Appreciatively, Rob Andrews Sent via Deja.com http://www.deja.com/ Before you buy. From rupole at msn.com Wed Oct 4 12:37:33 2000 From: rupole at msn.com (Roger Upole) Date: Wed, 04 Oct 2000 16:37:33 GMT Subject: How many people are making COM objects with Python? References: <8r56ta$3mj$1@nnrp1.deja.com> <8abmtsgqfpe4svqj1amjan46agsqv7shp8@4ax.com> Message-ID: The only references I've seen were right here on clp. One poster (Syver Enstad) identified a pattern whereby the missing events all have an IDispatch pointer in the parameter list. Roger Upole "John Lull" wrote in message news:8abmtsgqfpe4svqj1amjan46agsqv7shp8 at 4ax.com... > At the dawn of the third millenium (by the common reckoning), "Roger > Upole" wrote (with possible deletions): > > > The biggest gotchas I know of are the bug in the COM events code, > > where some events don't show up, > > Any documentation on this? > > Thanks. > > Regards, > John > From aleaxit at yahoo.com Sun Oct 15 10:07:47 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 15 Oct 2000 16:07:47 +0200 Subject: Testing existance of variable References: Message-ID: <8sce1k0f3r@news2.newsguy.com> "Steve George" wrote in message news:H5hG5.575$7u4.11173 at news.dircon.co.uk... > Hi, > > I've just started playing with Python and CGI and need to know if > something exists in the environment. According to the O'Reilly CGI text > you would do this in Perl as follows: > > my $remote_id = $ENV{REMOTE_HOST} || $ENV{REMOTE_ADDR}; > > I can't seem to find a Python equivalent. As far as I have got is: > > if os.environ.has_key('REMOTE_HOST') or os.environ.has_key('REMOTE_ADDR'): > remote_id = os.environ['REMOTE_HOST'] or os.environ['REMOTE_ADDR'] > > However, this fails with an exception for KeyError if one of them doesn't > exist. The only thing I can think to do is to try and catch the exception, > but this feels so long winded that I wondered if there is a shorter > answer. One possibility, just for example: enget = os.environ.get remote_id = enget('REMOTE_HOST',None) or enget('REMOTE_ADDR', None) Binding the bound method os.environ.get to the name enget is just a minor abbreviation. The key is that method.get, which looks up a key (first argument) and returns the second argument if the key's not there. Python's "or" works quite like Perl's "||"... Alex From thomas at xs4all.net Sun Oct 29 14:37:26 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 29 Oct 2000 20:37:26 +0100 Subject: how do I exit gracefully? In-Reply-To: ; from NospaMapierce@escapeNospaM.com on Sun, Oct 29, 2000 at 04:55:46PM +0000 References: <39FB6DC1.84C12A34@python.com> Message-ID: <20001029203726.X12812@xs4all.nl> On Sun, Oct 29, 2000 at 04:55:46PM +0000, Andrew Pierce wrote: > in article mailman.972837503.8498.python-list at python.org, Thomas Wouters at > thomas at xs4all.net wrote on 10/29/00 11:36 AM: > > Actually, sys.exit() does raise an exception, but that's besides the point > > ;) My bet is the exception the original guy was talking about was > > 'NameError'. He probably forgot to import sys and/or os before using them. > > Uh no. I did remember to import sys and/or os. :) The point is I didn't > want to clutter error logs with sys.exit() calls. The solution of: > > try: > main() > except SystemExit: > #we're ok > except: > #error processing here > Looks good to me. I still don't know what (if anything) python does at the > "normal" program termination of running out of instructions to execute. :/ Ahh, like that. Well, that can never happen: if you are inside the try:, there is always still code to execute :) And if you are outside the try, it's irrelevant whether a SystemExit exception was raised, or the interpreter just stops. (The interpreter does just stop, since it's useless to raise that exception, but that's besides the point.) If you run out of code in a function, it will silently return None. If you run out of a try/except without raising an exception, it will run the 'else' or 'finally' block, if any, and then continue past the 'try' statement. If you use os._exit(), you're taking the dirty route out. No exception is raised, no cleanup is done, and the interpreter just exits. In general, don't use it, unless you know what you're doing, and you really need it. (For instance, you are a database driver, and you encountered an internal inconcistency. You do not want to write your pending, possibly bad and harmful, data to the database in that case, but you might want to do it if the exception was, for instance, KeyboardInterrupt (^C). -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From s713221 at student.gu.edu.au Wed Oct 18 04:23:51 2000 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Wed, 18 Oct 2000 18:23:51 +1000 Subject: evaluating a string References: <8sgiuh$ope$1@nnrp1.deja.com> <39ED5741.AEC63540@student.gu.edu.au> <39ED58C9.8BF96A8A@student.gu.edu.au> Message-ID: <39ED5E17.E80595AD@student.gu.edu.au> Okay, sorry about that. How embarassing. Perhaps I should code before opening my mouth, huh? Anycase, here is a baby implementation of a string evaluator that doesn't get hung up on integer division. >>> def string_eval(text): ... splittext = re.split("/", text) ... text2 = "" ... for i in range(len(splittext)-1): ... text2 = text2 + splittext[i] + ".0/" ... text2 = text2 + splittext[-1] ... return eval(text2) ... >>> string_eval("1+2*3/4") 2.5 >>> Joal Heagney/AncientHart From jeffrey.hobbs at ajubasolutions.com Thu Oct 19 12:35:51 2000 From: jeffrey.hobbs at ajubasolutions.com (Jeffrey Hobbs) Date: Thu, 19 Oct 2000 09:35:51 -0700 Subject: SF corpsed? References: Message-ID: <39EF22E7.4C058D08@ajubasolutions.com> Robin Becker wrote: > I can't seem to get any decent access to sourceforge. Anybody else > having troubles? I find that SF tunes out from time to time, but I am currently logged in without problem, and project pages respond. (9:30am PST). -- Jeffrey Hobbs From jdries at mail.com Sun Oct 15 01:28:18 2000 From: jdries at mail.com (Jan Dries) Date: Sun, 15 Oct 2000 06:28:18 +0100 Subject: Wholly unnecessary flame. (was Re: pyXML!) References: <39D03630.155AD70A@engcorp.com> <8s9uak$n7i$1@nnrp1.deja.com> <39E8C32F.E6A630ED@seebelow.org> Message-ID: <39E94072.13A0435B@mail.com> > > > > > > 1 > > > > > > > > 3 > > > > > > 1 > > > > > > 4 > > [snip] > > > > > > > > The point is that the XML is self-documenting - > > it's clear to anyone that this denotes the number > > 3.14159... . > > I dunno...to uninitiated folks like me, the more immediate conclusion is > that XML is verbose. An shorter way to express it would be to write 3.1415926536 The first line defines the element pi to be of type (IEEE 754) double, and the second line assigns the proper value to it. But-that-doesn't-change-the-fact-that-XML-is-verbose-ly y'rs, Jan From jhauser at ifm.uni-kiel.de Wed Oct 11 12:16:16 2000 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 11 Oct 2000 18:16:16 +0200 Subject: ANNOUNCE: PySymbolic - Doing Symbolics in Python References: Message-ID: <873di39wvj.fsf@ifm.uni-kiel.de> victor at idaccr.org (Victor S. Miller) writes: > The second (and newer) is LiDIA from University of Darmstadt > (http://www.informatik.tu-darmstadt.de/TI/LiDIA/). It's free for > non-commercial use. It's written in C++. It has pretty much the same > capabilities as gp (plus some more). It would also be much easier to > integrate into Python (I think) since it has a clean interface to a > storage allocator (you can put in your own), and all other hooks to > the system. One question,as you seem to have looked into this. Would it be possible to evaluate the these symbolic expressions with NumPy arrays? This would mean transfering a symbolic expression into working code? __Janko -- Institut fuer Meereskunde phone: 49-431-597 3989 Dept. Theoretical Oceanography fax : 49-431-565876 Duesternbrooker Weg 20 email: jhauser at ifm.uni-kiel.de 24105 Kiel, Germany From frohne at gci.net Fri Oct 6 19:57:55 2000 From: frohne at gci.net (Ivan Frohne) Date: Fri, 6 Oct 2000 15:57:55 -0800 Subject: JPython Status References: <8rfqga$9sd$1@nnrp1.deja.com> <8rhsrj$i8j$4@newsserver.rrzn.uni-hannover.de> Message-ID: "Tom" wrote in message news:ghlD5.89867$dZ2.36249254 at news3.rdc1.on.home.com... > On the contrary, Sun is quite likely to charge for Java once it becomes well > established - that is what they developed it for, and that is what they have > fought hard to maintain the necessary conditions for (ie. maintaining the > necessary control). I'm not suggesting that they will be charging > end-users, just more stuff like the existing fee for J2EE. > > So if you like free (as in $ or source), then you need to consider the > future that is being prepared for you, not just the conditions today. No argument. I'm an end-user. --Ivan Frohne From effbot at telia.com Sat Oct 7 12:19:51 2000 From: effbot at telia.com (Fredrik Lundh) Date: Sat, 07 Oct 2000 16:19:51 GMT Subject: restricting import to current package References: Message-ID: Jeff wrote: > Is there a way to do something like: > from . import mymodule > In other words: > try to import mymodule from the same package (or directory) as this module > If mymodule is not there, raise ImportError how about: try: path = sys.path[:] sys.path = [os.path.dirname(__file__)] import mymodule finally: sys.path = path From tgagne at ix.netcom.com Sat Oct 7 00:56:58 2000 From: tgagne at ix.netcom.com (Thomas Gagne) Date: Sat, 07 Oct 2000 00:56:58 -0400 Subject: super - is (should) it (be) a reserved word? References: <39DD4E57.53C27A3F@ix.netcom.com> <39DD865E.D97E4D09@cable.a2000.nl> <8rkpsr$bpa$1@nnrp1.deja.com> <39DE2905.1E62C763@ix.netcom.com> <8rliak0crt@news1.newsguy.com> Message-ID: <39DEAD1A.1201A557@ix.netcom.com> Alex Martelli wrote: > "Grant Edwards" wrote in message > news:wAqD5.4401$WJ3.791257 at ptah.visi.com... > [snip] > > Personally, I would like some way to refer to _a_ superclass. > > If there's more than one, it's an error or undefined or > > arbitrarily picks one. Almost all of the code I see/write uses > > self.__class__.__bases__[0] satisfies this request, I think. > > Would the saving of about three characters to call it, say, > self.__class__.__super__ be worth introducing a 'shortcut'...? > > Alex Three characters wouldn't be enough of a shortcut. I really ought to be something as short as 'super', which says all it needs to. I supposed I've never found much need for multiple inheritance (except maybe in GP) but not in the planned ecologies which are the programs I write. I like the idea of 'super' being useful when there's single inheritence, and its behavior being undefined, or even an error, when thee are multiples. -- .tom From tanzer at swing.co.at Tue Oct 10 01:20:18 2000 From: tanzer at swing.co.at (Christian Tanzer) Date: Tue, 10 Oct 2000 07:20:18 +0200 Subject: super - is (should) it (be) a reserved word? In-Reply-To: Your message of "Mon, 09 Oct 2000 12:01:33 EDT." Message-ID: Michal Wallace wrote: > you could also call it __super and then you don't have to put the > classnames in the __init__ (because python does it for you for > variables starting with [and not ending with] double underscores): > > > class Pie(Dessert): > __super = Dessert > def __init__(self): > print "pie is a..." > self.__super.__init__(self) > > class BananaCremePie(Pie): > __super = Pie > def __init__(self): > print "banana creme pie is a..." > self.__super.__init__(self) If you do that, then you'd better not call one of your classes `_X' and one of its descendent classes `X' -- if you do, you'll get a name clash between `_X.__super' and `X.__super'. That name clash leads to infinite recursion in turn. Cheers, Christian PS: Is that a bug or a feature? -- Christian Tanzer tanzer at swing.co.at Glasauergasse 32 Tel: +43 1 876 62 36 A-1130 Vienna, Austria Fax: +43 1 877 66 92 From nas at arctrix.com Fri Oct 6 09:42:21 2000 From: nas at arctrix.com (Neil Schemenauer) Date: Fri, 6 Oct 2000 06:42:21 -0700 Subject: super - is (should) it (be) a reserved word? In-Reply-To: ; from ge@nowhere.none on Fri, Oct 06, 2000 at 08:27:08PM +0000 References: <39DD4E57.53C27A3F@ix.netcom.com> <39DD865E.D97E4D09@cable.a2000.nl> <8rkpsr$bpa$1@nnrp1.deja.com> <39DE2905.1E62C763@ix.netcom.com> Message-ID: <20001006064221.A4793@glacier.fnational.com> On Fri, Oct 06, 2000 at 08:27:08PM +0000, Grant Edwards wrote: > Personally, I would like some way to refer to _a_ superclass. self.__class__.__bases__[0] Neil From eugene.leitl at lrz.uni-muenchen.de Mon Oct 30 04:43:31 2000 From: eugene.leitl at lrz.uni-muenchen.de (Eugene Leitl) Date: Mon, 30 Oct 2000 01:43:31 -0800 (PST) Subject: Python Labs Move In-Reply-To: <39FCE915.C1DC844C@san.rr.com> References: <39FCE915.C1DC844C@san.rr.com> Message-ID: <14845.17091.157414.58824@lrz.uni-muenchen.de> Courageous writes: > Guido's a good fellow, I'm sure, but Python is bigger than > him now. Look at it on the bright side: so far Python has It is always better to keep the future of a major project in hands of a single person who's immune to a sellout. In case it forks, one can still stick to the one true branch (Guido's Python). From robin at jessikat.fsnet.co.uk Wed Oct 11 13:29:18 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 11 Oct 2000 18:29:18 +0100 Subject: [ANNOUNCE] cCopy 0.2 References: <7xK$7KA$p145Ewoi@jessikat.fsnet.co.uk> Message-ID: In article , Alex writes > >> Copying is obviously not very popular with pythoneers as only one >> response was received about the utility or otherwise of speeding it >> up. > >You should judge more by your web server logs than the response here. >My own experience suggests there are a lot of shy people lurking >here. (Well, I would count as one of them, in your case. :) > >Alex. > If my crappy, about to go broke ISP, allowed such things I would check. I am monetarily constrained so use the cheapest available option. -- Robin Becker From akuchlin at mems-exchange.org Wed Oct 25 17:43:01 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: Wed, 25 Oct 2000 17:43:01 -0400 Subject: Quixote mailing list created Message-ID: A mailing list has been created to discuss the use and development of the Quixote Web development framework. To subscribe, go to: http://www.mems-exchange.org/mailman/listinfo/quixote-users --amk From dale at out-think.NOSPAMco.uk Thu Oct 12 13:29:18 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Thu, 12 Oct 2000 18:29:18 +0100 Subject: Most Effective Way to Build Up a Histogram of Words? References: <39E5D3CF.62C6CE8E@holdenweb.com> <8s4nku$df7$1@news.nuri.net> Message-ID: "June Kim" wrote: < big snip> >> -- >> Helping people meet their information needs with training and technology. >> 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ >> >> > >Thank you for your clear and clean code. >The problem, however, is that I might run through several of a few MB files, >summing up to tens of mega bytes when added into one file . >Therefore, to do the sorting all at once might sound somewhat unfeasible >or ineffecient. Am I trying to make Python a panacea here? ( I know it has >no snake oil though) > >Best Regards, >June Given that there are only a few thousand words in popular use it's probably unlikely you're going to hit more than 100,000 words. Even with very wasteful storage, that should still occupy less than a few megaytes. Dale Strickland-Clark Out-Think Ltd Business Technology Consultants From junaftnoon at nospamplzyahoo.com Tue Oct 17 10:02:51 2000 From: junaftnoon at nospamplzyahoo.com (June Kim) Date: Tue, 17 Oct 2000 23:02:51 +0900 Subject: Python 2.0 cyclic garbage collection -- newbie's question Message-ID: <8shmbo$m7k$1@news.nuri.net> I was happy to see Python 2.0 final release and installed it right after its release. Reading "What's New in Python 2.0" by A.M. Kuchling and Moshe Zadka, it seemed like the cyclic garbage collection has been added, but is not ON by default -- for the performance matter or whatever. However, when I followed these lines, it seemed the other way around: >>> import gc >>> gc.is_enabled() 1 ,which means the optional cyclic garbage collection is already on. Is the cyclic garbage collection ON before the gc module is imported? From fakeadress at microsoft.com Wed Oct 25 02:26:05 2000 From: fakeadress at microsoft.com (Martijn van der Kooij) Date: Wed, 25 Oct 2000 08:26:05 +0200 Subject: How do I force a single instance of a python app? References: <39f5e46f_3@corp.newsfeeds.com> <8t54f9$9r4$1@drmanhattan.kryogenix.org> <39f62a22_4@corp.newsfeeds.com> Message-ID: <8t5ufr$nu4$1@porthos.nl.uu.net> > The file hack, which writes a timestamp to the file is a very interesting > idea. This could possibly be simplified to simply deleting and creating the > file and using the OS to find the file's timestamp, but this will probably > annoy NT which doesn't like lots of temp files, and tends to fragment > because of it. > > A file which contained a timestamp and a pid will probably do the trick. I > can live with the dead zone (the period of time between file updates) -- the > process doesn't have to restart immediately. Also, I was reading in the FAQ > today that there is a way to trap when a python app is ending -- I can > delete the file at that point to reduce the dead zone delay when the app > behaves well. > If you keep a file opened and only close it when your app is ready the file can not be opened a second time, this way you are sure there is an other app running if you can not create the file, otherwise as soon as you create a lock file (and keep it open) you are sure this is the only instance. (This works at least at Windows) Martijn van der Kooij From jgraves3 at austin.rr.com Thu Oct 19 12:13:13 2000 From: jgraves3 at austin.rr.com (jay graves) Date: Thu, 19 Oct 2000 16:13:13 GMT Subject: New - Need Help References: Message-ID: <39ef1bab.7121125@news-server.austin.rr.com> On Thu, 19 Oct 2000 03:46:44 -0000, dmw16 at home.com wrote: >I dont have any prior compiled language programing experience(I know >HTML, that is it) and I am looking to start learning a language. I >was planning on making python my first. Is this a good idea? If it >is, does anyone know of any good beginnering online tutorials and/or >books? >thanks, >-doug wardell Learning is Python is a good book and I would recommend it but if you are a total neophyte I would like to point you to: "How to Think Like a Computer Scientist (Python version)" The link I have is currently unreachable but a Google search revealed a mirror. http://www.eleceng.uct.ac.za/courses/EEE103W/python/yhslug.tux.org/obp/thinkCS/thinkCSpy/ HTH Jay From luthi at vaw.baug.ethz.ch Wed Oct 11 04:10:42 2000 From: luthi at vaw.baug.ethz.ch (Martin Luethi) Date: 11 Oct 2000 10:10:42 +0200 Subject: Possible bug (was Re: numpy, overflow, inf, ieee, and rich comparison) References: Message-ID: I just tried out these examples on Linux (SuSE 6.4 on PIII) and Solaris 5.7 (on Sparc architecture) and I get different behaviour with for the expressions. Both Python interpreters have been compiled with a nearly identical version of gcc Python 1.6b1 (#1, Aug 23 2000, 16:12:27) [GCC 2.95.1 19990816 (release)] on sunos5: >>> print exp(-746.0) Traceback (most recent call last): File "", line 1, in ? OverflowError: math range error Python 1.6 (#1, Oct 3 2000, 20:47:38) [GCC 2.95.2 19991024 (release)] on linux2: >>> print exp(-746.0) 0.0 >From this I suspect some libc incompatibility. Hope this helps.... Martin L?thi From kuncej at mail.conservation.state.mo.us Fri Oct 6 10:40:08 2000 From: kuncej at mail.conservation.state.mo.us (Jeff Kunce) Date: Fri, 6 Oct 2000 09:40:08 -0500 Subject: restricting import to current package References: <39dcd16c.72134234@news1.on.sympatico.ca> Message-ID: > >Is there a way to do something like: > > from . import mymodule > >In other words: > > try to import mymodule from the same package (or directory) as this module > > If mymodule is not there, raise ImportError > > > import mymodule > see the tutorial on intrapackage references Not really. That will look *first* in the current package, but then will go merrily down sys.path looking for any other mymodule it can find. When you say: from mypackage import mymodule python will look for mymodule *exclusively* in mypackage. I want to do the same thing for the (unspecified) current package. --Jeff From aleaxit at yahoo.com Thu Oct 26 15:36:09 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 26 Oct 2000 21:36:09 +0200 Subject: MS Windows Clipboard References: <8t3m1n025h1@news2.newsguy.com> <8t6fmn0bg9@news1.newsguy.com> Message-ID: <8ta16b01n0d@news2.newsguy.com> "Mark Hammond" wrote in message news:gvKJ5.15107$Ab3.80813 at news-server.bigpond.net.au... [snip] > > > > Calling win32clipboard.GetClipboardData(1) is clearly the > > > > way to get at the data we want. It's documented as > > > > returning "the handle of a clipboard object in the specified > > > > format", so we might worry about using a PyHANDLE to [snip] > > A third Very Good Thing. Although getting the handle might > > not be a bad idea either (e.g, for a DragQueryFile I'd like > > the bare HDROP...). > > Maybe it would make sense to add a new optional param, indicating the > type of the result. You could ask the the "default" (current > behaviour), or explicitly for one of either string, unicode, or > integer handle. I'm not sure we expose enough functions to make the > handle useful, but it does provide room for growth. What an excellent idea! > unicode would _not_ provide an encoding option - it would assume > standard Windows UCS2. If you want to assume an encoded Unicode > string, you would ask for a string object, and make the conversion > yourself. Makes sense. Non-UCS2 Unicode would only come from custom datasources anyway. > What would this param look like - maybe a simple string "string", > "unicode", "handle", with None or "" == default? Or maybe type(""), type(u""), type(PyHandle)...? Alex From root at rainerdeyke.com Thu Oct 5 17:10:01 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Thu, 05 Oct 2000 21:10:01 GMT Subject: Python/C API References: <39DC3EE1.A4568884@stud.informatik.uni-erlangen.de> <8rhi4a01ulk@news1.newsguy.com> <39DCC9F3.C9816CBA@stud.informatik.uni-erlangen.de> Message-ID: "Joerg Baumann" wrote in message news:39DCC9F3.C9816CBA at stud.informatik.uni-erlangen.de... > Thank you for your hints. > This workes for me: > > a=PyImport_AddModule("xyz"); > b=PyModule_GetDict(a); > // no Py_DECREF(a) > a=PyDict_GetItemString(b,"foo"); > // no Py_DECREF(b) > b=Py_BuildValue("(s)",_ptemp); > c=PyObject_CallObject(a, b); > Py_DECREF(b); > // c holds xyz.foo("test") with refcount 1 An even simpler solution would be to do a PyObject_CallMethod on the module itself. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From josh at open.com Fri Oct 6 21:22:05 2000 From: josh at open.com (Joshua Muskovitz) Date: Fri, 6 Oct 2000 21:22:05 -0400 Subject: Code obfuscation / decompilers? Message-ID: <39de791e_4@corp.newsfeeds.com> Hi, I'm sure that other commercial developers have had this concern, namely, how do I prevent others from figuring out how my code works (without the original source, that is...)? Do code obfuscators exist for Python? Conversely, are there any bytecode to source code decompilers? These would be of great help in convincing myself that my code is relatively safe from prying eyes as well. All pointers welcome... -- josh -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From ngps at madcap.dyndns.org Wed Oct 25 11:44:25 2000 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 25 Oct 2000 15:44:25 GMT Subject: Q: python and distributed object like CORBA References: Message-ID: <8t6v4p$lqg$1@coco.singnet.com.sg> According to Hwanjo Yu : > Is there a distributed object supported for python like CORBA or RMI ? > If not, isn't there any way of implementing it in python ? pyro dopy ILU fnorb 3(?) OmniOrb bindings Ask www.vex.net/parnassus. I'm presently beginning to build a tuple spaces thingy based on Zope's ZEO. More on that when there's more to show - like when the Starship comes back and I can download amk's ZODB/ZEO packages. ;-) -- Ng Pheng Siong * http://www.post1.com/home/ngps From nospam at nospam.com Sat Oct 28 11:51:38 2000 From: nospam at nospam.com (Tom) Date: Sat, 28 Oct 2000 15:51:38 GMT Subject: PythonLabs Team Moves to Digital Creations References: Message-ID: Some of this sounds good, but some is a bit scary. In particular: > We will be spending part of our > time on core Python development (including Jython and Mailman) and > part of our time on Python infrastructure improvements that also > benefit Zope. If Python itself is good, and is being actively developed, then other companies and individuals will develop 'infrastructure'. For example, it appears that WingIDE, Boa, and ActiveState's Visual Python IDE will all be ready in the near future - this is evidence of the momentum that Python currently has. However, if work on the core of Python were to slow, or if it's direction was guided by the interests of one particularly product (ie. Zope), then this might discourage the development of all other 'infrastructure' projects, and would hurt the Python community. Tom. "Guido van Rossum" wrote in message news:mailman.972693760.7272.python-list at python.org... > To all Python users and developers: > > Less than half a year ago, I moved with my team to BeOpen.com, in the > hope of finding a new permanent home for Python development. At > BeOpen, we've done several good things for Python, such as moving the > Python and Jython development process to SourceForge, and the > successful release of Python 2.0. > > Unfortunately, BeOpen.com's original plans for PythonLabs didn't work > out as hoped, and we weren't able to reach mutual agreement on > workable alternative plans -- despite trying for months. > > I am proud to have found a new home for my entire team: starting > today, Tim Peters, Barry Warsaw, Jeremy Hylton, Fred Drake and myself > are working for Digital Creations. We will be spending part of our > time on core Python development (including Jython and Mailman) and > part of our time on Python infrastructure improvements that also > benefit Zope. > > Python will remain Open Source; Digital Creations has no desire to > monetize or brand the Python language or specific Python > distributions. All future work we do on Python as Digital Creations > employees will be owned by a non-profit organization yet to be > created. We think of this new organization as the Python Software > Foundation. In the meantime (while the PSF is under construction) I > will own such copyrights personally. > > We're excited to be working for Digital Creations: they are one of the > oldest companies active in the Python community, one of the companies > most committed to Python, and they have a great product! Plus, we > know they have deep financial backing. We trust that Digital > Creations will provide a stable home for Python for many years. > > Digital Creations has also offered to take over hosting of the > python.org and starship sites. On behalf of the Python community, > we're grateful for this support of the two prime community sites for > Python, and we expect to be implementing the transitions shortly. > > These are exciting times for the PythonLabs team -- and also for > Python and its community. Mainstream successes for Python are showing > up everywhere, and we're proud to be a part of such a smart and > friendly community. A great year lies ahead! > > --Guido van Rossum (home page: http://www.python.org/~guido/) > From python at teleo.net Fri Oct 27 15:32:37 2000 From: python at teleo.net (Patrick Phalen) Date: Fri, 27 Oct 2000 12:32:37 -0700 Subject: PythonWin IDE sucks! In-Reply-To: References: <7tuivs46osods22uumpvsvsap2jocrd4si@4ax.com> Message-ID: <00102712405206.00566@quadra.teleo.net> [Dale Strickland-Clark, on Fri, 27 Oct 2000] :: OK. I give up. :: :: This newsgroup has to get the prize for some of the fragile, sensitive :: egos on the net. Really? I've been following it closely for over four years and have somehow never noticed that. :: probably have emailed Mark directly, however, I was half expecting :: someone to reply that I was being a twat [...] OK, you're a twat. Or more accurately a twit!! Feel better now? Notice that I've included two exclamation marks in the above, so that you'll know that I'm being doubly light hearted. From jeremy at beopen.com Tue Oct 10 02:52:48 2000 From: jeremy at beopen.com (Jeremy Hylton) Date: Mon, 9 Oct 2000 23:52:48 -0700 (PDT) Subject: Python 2.0 release candidate 1 Message-ID: <200010100652.XAA74600@python.beopen.com> Python 2.0c1 is released. The BeOpen PythonLabs and our cast of SourceForge volunteers have fixed many bugs since the beta releases last month. Please pick up the new release at http://www.pythonlabs.com/products/python2.0/ There's a tarball, a Windows installer, RedHat RPMs, online documentation, and a long list of fixed bugs. The final release of Python 2.0 will be next week. We would appreciate feedback on the release candidate in order to fix any remaining bugs before the final release. Confirmation of build and test success on less common platforms is also helpful.n All major reported bugs have been fixed in the release candidate. We do not plan to make any changes between now and the final release, except to fix bugs reported in the next week. We encourage potential users of Python 2.0 to try the release candidate with their programs and report any remaining bugs. To report a new bug, use the SourceForge bug tracker http://sourceforge.net/bugs/?func=addbug&group_id=5470 Python 2.0 has many new features, including the following: - Augmented assignment, e.g. x += 1 - List comprehensions, e.g. [x**2 for x in range(10)] - Extended import statement, e.g. import Module as Name - Extended print statement, e.g. print >> file, "Hello" - Collection of cyclical garbage For a fuller discussion of the changes in Python 2.0, please see the article "What's New in Python 2.0" by Andrew Kuchling and Moshe Zadke: http://starship.python.net/crew/amk/python/writing/new-python/ -- Jeremy Hylton From root at rainerdeyke.com Thu Oct 26 12:21:46 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Thu, 26 Oct 2000 16:21:46 GMT Subject: [Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich , comparison References: <39F6639E.B74867EE@home.com> Message-ID: "Konrad Hinsen" wrote in message news:m3wvewc4hh.fsf at chinon.cnrs-orleans.fr... > "Rainer Deyke" writes: > > > Floating points should not be part of the core language. The correct way to > > implement floating points is in terms of integers, preferable within the > > language (as opposed to a C extension). > > If you don't like floating point numbers, you are free not to use > them. Many of us do need them, know how to deal with them, and need > them in a usable form, i.e. with decent performance and accessible > from C modules, which implies using the binary format provided by the > CPU. Your proposal is completely unrealistic. Given current CPU design, one might as well take advantage of it, yes. However, if the CPU was designed to do floating point calculations in terms of integers, the result would be a cleaner architecture and faster overall performance (given that integer operations are much more common than floating point operations). I am deliberately overstating my position as a counter to the ridiculous proposition that floating point operations be allowed to sneak into my code through the division of integers. Neither is viable at this point, simply due to the amount of previously existing code. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From zessin at my-deja.com Sat Oct 7 07:40:42 2000 From: zessin at my-deja.com (Uwe Zessin) Date: Sat, 07 Oct 2000 11:40:42 GMT Subject: Python on VMS References: <8qvn64$5gi$1@nnrp1.deja.com> <8i8WxEA8lS15EwwX@gol.com> <8r6qtm$96o$1@nnrp1.deja.com> <8r7ku8$pjf$1@nnrp1.deja.com> <8ra5gk$jqb$1@nnrp1.deja.com> <8rled2$s0l$1@nnrp1.deja.com> Message-ID: <8rn23q$1bg$1@nnrp1.deja.com> In article <8rled2$s0l$1 at nnrp1.deja.com>, timwkelly at my-deja.com wrote: [...] > Tried to download the new objects and I get an error. Please try again, I think I've found the problem. -- Uwe Zessin Sent via Deja.com http://www.deja.com/ Before you buy. From sholden at holdenweb.com Mon Oct 9 13:42:36 2000 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 09 Oct 2000 13:42:36 -0400 Subject: PEP 4: Deprecation of standard modules References: <8rstuh$c3$1@panix3.panix.com> Message-ID: <39E2038C.924EFEFA@holdenweb.com> Aahz Maruch wrote: > > [posted with cc to fdrake because of doc issues] > > In article , > Michal Wallace wrote: > > > >Why deprecate modules at all? Why not just move them out of the > >standard distribution and make a home (page) for outcast modules.. As > >long as you can get to this stuff from parnassus, everyone should be > >happy. Or am I missing something? > > Well, that's the whole point of deprecating modules. Before taking the > step of removing modules from the standard distribution, you want to > make sure that people get some advance warning so they can switch to the > appropriate new modules (which is the main reason modules have been > deprecated in the past; see regex and regsub, for example). They are > also almost always modules that people are not currently using. > > But this does suggest to me that perhaps there ought to be a prominent > section in each release for newly deprecated modules; I'm not sure > whether this PEP is sufficient. There is a section in the library > reference for obsolete modules; I believe current practice is to ship > obsolete modules in the standard distribution for at least one release, > just in case. > > Fred, if you want to talk with me about it off-line, feel free to, but > we should probably include Martin von Loewis. > -- > --- Aahz (Copyright 2000 by aahz at pobox.com) > > Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ > Hugs and backrubs -- I break Rule 6 > > "[I have a] windmill fetish." --Darkhawk Would it help to have a specific directory for depracated modules that would raise a warning whenever modules were imported from it? This could be done relatively simply, and switched off by an option for production code containing the depracated modules. regards Steve -- Helping people meet their information needs with training and technology. 703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/ From junaftnoon at nospamplzyahoo.com Thu Oct 26 04:31:47 2000 From: junaftnoon at nospamplzyahoo.com (June Kim) Date: Thu, 26 Oct 2000 17:31:47 +0900 Subject: python and distributed object like CORBA References: Message-ID: <8t8q64$h6q$1@news.nuri.net> Hi Hwanjo. There is a great introductory article on CORBA using Python. You can find it in the Linux World magazine. http://www.linuxworld.com/linuxworld/lw-1999-09/lw-09-corba_1_p.html "Hwanjo Yu" wrote in message news:EntJ5.5080$l12.80649 at vixen.cso.uiuc.edu... > Hi, > > Is there a distributed object supported for python like CORBA or RMI ? > If not, isn't there any way of implementing it in python ? > Thanks in advance. > > From fifeclub at my-deja.com Thu Oct 12 09:44:04 2000 From: fifeclub at my-deja.com (fifeclub at my-deja.com) Date: Thu, 12 Oct 2000 13:44:04 GMT Subject: Programmer-Wanna-Be (Is Python for me?) References: <8s2354$ep2$1@nnrp1.deja.com> Message-ID: <8s4f72$cok$1@nnrp1.deja.com> > * COMPLICATED DISTRIBUTION > > Distributing a Python application can be complicated. If you say: > "This is a great program, but to use it, you must first install > Python, PIL and Tk and set up the following environment > variables..." you have already lost 95 % of your potential users. > > There are methods of packing everything you need to run the > program into a single executable, for example "Gordon's installer" > but... if you are a beginning programmer it will take some time > to learn how to use them. (Someone really needs to write an > installer that is easier to use.) > > // Niklas > Whoa. This is something I haven't come across before! I realize it will take me a lot of time and effort to learn Python, but in the end I envisioned the fruits of my labor to be self-sufficient applications that would be executable on Windows (or other OS's). Is this a major issue or is it just a matter of 're-packaging' the final program thru a 'finishing' application. Sent via Deja.com http://www.deja.com/ Before you buy. From mal at lemburg.com Wed Oct 18 07:15:59 2000 From: mal at lemburg.com (M.-A. Lemburg) Date: Wed, 18 Oct 2000 13:15:59 +0200 Subject: sizeof? References: Message-ID: <39ED866F.1E5B9FA3@lemburg.com> Remco Gerlich wrote: > > seung-won hwang wrote in comp.lang.python: > > Is there any operator to measure the size of the object in Python > > something like sizeof in C? I couldn't find any from the book > > and documents I have. Thanks! > > There is no way to find the exact number of memory bytes an object uses. > Consider that irrelevant. Not quite true: have a look at sizeof() in mx.Tools (see my Python Pages). > To find the length of a list, or a tuple, or other sequences, use len(). > > Remco Gerlich -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From aleaxit at yahoo.com Mon Oct 23 12:04:04 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 23 Oct 2000 18:04:04 +0200 Subject: C's syntax References: <8t0or303ee@news1.newsguy.com> <8t1964$v8a$1@news7.svr.pol.co.uk> <17WI5.58198$oN2.2362868@news20.bellglobal.com> <39F45B51.320AA63F@alcyone.com> Message-ID: <8t1nr90105v@news1.newsguy.com> "Erik Max Francis" wrote in message news:39F45B51.320AA63F at alcyone.com... > Olivier Dagenais wrote: > > > To get around this, we were taught to put the constant on the other > > side, so > > that if we forgot an '=', we would get a compiler error: > > > > if ( 0 = a ) /* is bad */ > > if ( 0 == a ) /* is good */ > > Which is a common coding style, but is really unnecessary. Any > reasonable compiler will warn against statements such as `if (a = 0) Visual C++ may not be "reasonable", but it's still one of the most widespread on the market, and does NOT give this warning at normal warning-levels (and the system header files spew oodles & oodles of warnings if you try to enable warnins at pedantic-level, so one does not normally use that). If I recall correctly (it _was_ a while ago), vendor-supplied C compilers on many Unix systems did not supply that warning either. > ...'. Simply look at the warnings, there's no reason to write things in > an unnatural order. It's a good coding habit to get into, to ensure that particular slip will be caught by any standard compiler, rather than relying on specific warning-relater features that NOT all compilers have. Alex From akuchlin at mems-exchange.org Wed Oct 25 15:38:05 2000 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 25 Oct 2000 15:38:05 -0400 Subject: ANY NEWS ON THE STARSHIP? References: Message-ID: <3dem143e5e.fsf@kronos.cnri.reston.va.us> Miles Fidelman writes: > > Great! You said you will start a SIG on a Python CPAN? > actually, somebody else said that I think this clearly falls within the province of the already-existing Distutils-SIG (http://www.python.org/sigs/distutils-sig/). --amk From paul.moore at uk.origin-it.com Fri Oct 27 09:00:24 2000 From: paul.moore at uk.origin-it.com (Paul Moore) Date: Fri, 27 Oct 2000 15:00:24 +0200 Subject: MS Windows Clipboard References: <8t3m1n025h1@news2.newsguy.com> <8t6fmn0bg9@news1.newsguy.com> <8ta16b01n0d@news2.newsguy.com> Message-ID: <33r5OSRm=gidrgnmJUqLe=tsbYNP@4ax.com> On Fri, 27 Oct 2000 01:13:20 +0200, "Mark Hammond" wrote: >"Alex Martelli" wrote in message >news:8ta16b01n0d at news2.newsguy.com... >> "Mark Hammond" wrote in message > >We are discussing a new optional param for the Win32 clipboard >functions that would specify the type of the returned data. While we're on the subject, I recall from Perl's clipboard module a function which waits for the clipboard to change. The Python module doesn't have this, and I'm not sure how I would implement it. (It's not the sort of thing which is needed very often, I guess, but I have a specific application which would be cleaner with it...) I think I need a clipboard viewer, with a hidden window to receive notification messages. But it sounds quite messy to implement. Two questions - first, are all the pieces available in win32all to implement this myself, and second, would it be worth adding a method like this to win32clipboard? Thanks, Paul Moore From gustav at morpheus.demon.co.uk Wed Oct 25 17:58:55 2000 From: gustav at morpheus.demon.co.uk (Paul Moore) Date: Wed, 25 Oct 2000 22:58:55 +0100 Subject: Where is wxPython? References: <39E33757.E9F81F9C@cicei.ulpgc.es> <8t216i$dvu$1@nnrp1.deja.com> <8t54hu$hl$1@nnrp1.deja.com> <8t77t1$ndf$1@nnrp1.deja.com> <8t7isq$1qj$1@nnrp1.deja.com> Message-ID: <6qlevso3jjeu349r7tbc8veijsi89prk24@4ax.com> On Wed, 25 Oct 2000 21:21:39 GMT, Robin Dunn wrote: >> > Actually, I believe that you should be able to put the DLL in the >> > same directory as the DLL which uses it (ie, the wxPython PYD >> > file). I've done this with other modules and it seems to work. >> I'm sure I tried that before and it didn't work... But it *is* >> working for me now with both 1.5.2 and 2.0. Perhaps it >> is a win2k thing, which version of windows are you running? >> > >Well I just tried it on win98 and it worked, so I must have screwed >something up when experimenting before. I'll change my installer script >right now. I'm using WinNT, and it works there. The manuals document it for all versions of Windows, except WinCE... Paul. From claird at starbase.neosoft.com Mon Oct 9 12:07:53 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 9 Oct 2000 11:07:53 -0500 Subject: What's wrong with ActiveState? (was: Is this a dream or a nightmare? (Was Re: XML)) References: <39d1d3b2.43465571@news.telus.net> <39D19EBB.ABF18F23@engcorp.com> <39def2ae.8929692@news.davesworld.net> Message-ID: In article , Frank Sergeant wrote: > >"David T. Grove" wrote in message >news:39def2ae.8929692 at news.davesworld.net... > >David, I enjoyed your rant about ActiveState in this post and in the >interview with "Pete" on the www.CodeMagicCD.com web site. It had always >annoyed me that ActiveState allowed one to download only a >non-redistributable "distribution" of Perl. I feared (and I believe it has >been realized) they would take Python in the same direction. . . . I'm not getting it. David T. Grove, at several points in this thread, has warned against the ActiveState disease. I have a definite impression that he has strong emotions about this, but not what the sub- stance behind them is. I'm sufficiently curious to ask for details. I think the accusation is some combination of: 1. ActiveState is technically incompetent: it promises VisualPerl, but doesn't deliver it on schedule; 2. ActiveState is morally flawed: it lays off programmers; 3. ActiveState impedes Perl development by buy- ing off P5P (roughly, the Perl maintenance crew) members to distort their decisions and/or advertising deceptively about its schedule for releasing new source into the core distribution; 4. ActiveState is impure for some combination of selling a Perl distribution, allowing people to believe that Win!Perl is available only from ActiveState, and/or polluting ActivePerl with Microsoft-oriented goop. Do I have that right? The Pete interview mentioned above is, I believe, the one at . -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From juergen.erhard at gmx.net Sat Oct 21 03:02:43 2000 From: juergen.erhard at gmx.net (=?ISO-8859-1?Q?=22J=FCrgen_A=2E_Erhard=22?=) Date: Sat, 21 Oct 2000 09:02:43 +0200 Subject: I want to impress the boss. In-Reply-To: (message from Marty Backe on Sun, 15 Oct 2000 22:38:32 -0700) References: <8sdvc6$jqq$1@nnrp1.deja.com> Message-ID: <21102000.1@sanctum.local.jae.ddns.org> >>>>> "Marty" == Marty Backe writes: [...] Marty> What's the mad rush all about? Python isn't going anywhere. Python might not (although I'd rather think it's going places ;-) But maybe Chris' company would/will... and we all know that when Perl/PHP et al have taken hold (not to mention Ja... Ja... sorry, I can't get myself to say it ;-), it's hard to get Python in. Bye, J -- J?rgen A. Erhard juergen.erhard at gmx.net phone: (GERMANY) 0721 27326 My WebHome: http://members.tripod.com/Juergen_Erhard The 80-20 rule for an NT project: 20% time for real coding -- 80% time for working around NT bugs -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 248 bytes Desc: not available URL: From MarkH at ActiveState.com Sat Oct 28 03:43:30 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Sat, 28 Oct 2000 07:43:30 GMT Subject: anyone using Pythonwin with a different char set on Windows? References: <8tdlgd$r0t$1@news.nuri.net> Message-ID: <39FA90D9.7070403@ActiveState.com> June Kim wrote: > Is there anyone who uses Pythonwin with a different character set on > Windows? -- Japanese, Chinese, European and so on. A few people - and they all have trouble :-( The good news is that Python 2.0 users on Windows NT/2000 can grab an update from http://starship.python.net/crew/mhammond/win32/Downloads.html Mark. From mjhand at concentric.net Sun Oct 22 02:36:14 2000 From: mjhand at concentric.net (Manus Hand) Date: Sun, 22 Oct 2000 06:36:14 GMT Subject: ANY NEWS ON THE STARSHIP? Message-ID: <8su1su$euq$1@nnrp1.deja.com> Anyone know anything about the starship's inaccessibility? How long it will last, etc.?? Thanks, Manus (usually you could mail me at python.net, but.... mjhand at concentric.net for now) Sent via Deja.com http://www.deja.com/ Before you buy. From jicman at cinops.xerox.com Mon Oct 2 12:35:22 2000 From: jicman at cinops.xerox.com (Jose Isaias Cabrera) Date: Mon, 2 Oct 2000 12:35:22 -0400 Subject: grabbing a cookie Message-ID: <8radpp$hhc$1@news.wrc.xerox.com> Hi all! Using import httplib I did a POST to a server to login to it with the following http connection: h = httplib.HTTP(host,port) I used the code reply, msg, hdrs = h.getreply() to get the reply, the message and the headers (duh!). In the headers (hdrs), I have a cookie returned with a header "Set-Cookie". I could print the header (hdrs) to STDOUT, by using print hdrs and I get Date: Mon, 02 Oct 2000 16:21:07 GMT Server: Apache/1.3.0 (Unix) Set-Cookie: AmberUser=%b7%07%0eS%cbm%8f%3b%9b%88%27%2a%1c%d3%ed%b000080%981%a7%e6%02%10%bf; path=/ Connection: close Content-Type: text/xml but I can not get the content of the cookie into a variable because I can't not search through it or anything. If I use the line, for x in hdrs: print x it gives me the error Traceback (innermost last): File "C:\MYPROG~1\MyHTTP.py", line 93, in ? Cookie = gologin(loginID,password) File "C:\MYPROG~1\MyHTTP.py", line 70, in gologin for x in hdrs: File "d:\Program Files\Python\Lib\rfc822.py", line 356, in __getitem__ return self.dict[string.lower(name)] TypeError: read-only character buffer, int So, the question is, how can I get the cookie into a variable that I can use to sent to that server? Or how can I read this information given back by the server in some kind of bin-hex mode? thanks for your help, jose -------------- next part -------------- An HTML attachment was scrubbed... URL: From albro at humnet.ucla.edu Thu Oct 5 14:04:12 2000 From: albro at humnet.ucla.edu (Daniel M. Albro) Date: Thu, 05 Oct 2000 11:04:12 -0700 Subject: python logic and AI links References: Message-ID: <8rifit$5dc$1@news.service.uci.edu> You mentioned writing a prolog interpreter -- I haven't put this on a web page anywhere or anything, although I could if anyone cares, but I have written an implementation of Prolog (using the Warren Abstract Machine) in python. Not everything possible is there (no I/O or hooks for system routines, for example), but it would certainly be a start. If anyone is interested in it I'll put it up on my web page... - Dan Albro In article , Michal Wallace wrote: > > > It seems there's at least a small handful of logic programming and AI > modules out there... Anyone interested in tying some of this stuff > together? > > I've started a sourceforge project for logic programming in python > http://plato.sourceforge.net (for "python logic and truth objects").. > There's nothing there yet, but I was thinking about making a simple > prolog interpreter, plus maybe some generic AI objects.. > > Actually, I have two specific projects in mind: a stock trader, and an > automated therapist (like eliza, but done right.. [see > http://www.manifestation.com/sabrina/ ) for some old, mostly random > thoughts about what it might be like..] From dubois at users.sourceforge.net Tue Oct 31 18:00:46 2000 From: dubois at users.sourceforge.net (Paul F. Dubois) Date: Tue, 31 Oct 2000 23:00:46 GMT Subject: Windows zip of Numerical Python 17.1.1 available Message-ID: Numerical 17.1.1 is available in both source and prebuilt Windows versions at: http://sourceforge.net/projects/numpy Windows users, simply extract into your top level Python 2.0 directory, typically c:\python20. Thank you to Pete Shinners for putting the Windows file together. It is too late to change for the 17 series but in future I will make releases that have whole numbers only as names and add files to that release as they become available. That makes it a little clearer that you should take the most recent file of the desired type. From robin at jessikat.fsnet.co.uk Thu Oct 19 13:01:14 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 19 Oct 2000 18:01:14 +0100 Subject: SF corpsed? References: <39EF22E7.4C058D08@ajubasolutions.com> Message-ID: In article <39EF22E7.4C058D08 at ajubasolutions.com>, Jeffrey Hobbs writes >Robin Becker wrote: >> I can't seem to get any decent access to sourceforge. Anybody else >> having troubles? > >I find that SF tunes out from time to time, but I am currently >logged in without problem, and project pages respond. (9:30am PST). > Mr Hobbs! Nice to hear from you here. I'm trying various updates and all are giving messages like cvs server: Diffing . cvs server: failed to create lock directory in repository `/cvsroot/pingo/pingo' : Permission denied cvs server: failed to obtain dir lock in repository `/cvsroot/pingo/pingo' cvs [server aborted]: read lock failed - giving up I am also unable to login etc. -- Robin Becker From nospam at nospam.com Thu Oct 5 15:44:51 2000 From: nospam at nospam.com (Tom) Date: Thu, 05 Oct 2000 19:44:51 GMT Subject: New Python development process (SourceForge considered Harmful?) References: <39e0d75b.78955419@news.telus.net> Message-ID: "David" wrote in message news:39e0d75b.78955419 at news.telus.net... > On Thu, 5 Oct 2000 15:28:41 +0000 (GMT), Oleg Broytmann > wrote: > > >Hi! > > > >On Thu, 5 Oct 2000, Tom wrote: > >> Personally, I've got too many ads in my life, so I prefer to pay for things, > > > > Not all people want this, and not all people can afford this. There > >"connected" countries with low salaries, and having free services is really > >big advantage for poor us. Take it a bit easier :) > > > >> rather than have to put up with lots of ads. > > > > Why not just filter ads out? To make the letter more pythonic - I can > >publish URLs of filtering proxies, and most of them are in Python. I > >actually use one these proxies - and is pretty satisfied (I hacked it a bit > >and sent patches to author...) > > Another option is to create a HOSTS file that sends requests for ad servers > to the garbage bin: > > www.adserver.com 127.0.0.1 But aren't there thousands of different ad servers? Do you mean that I should do this just for those sites that are particularly annoying? Or am I missing something? Tom. > > and so on. > > The HOSTS file exists on Windows and Linux environments. Addresses in it > are inserted into the domain name lookup process prior to actually > contacting a DNS. Basically, it cuts 'em off at the pass. > From pmoore at mjs400.co.uk Sat Oct 28 19:11:04 2000 From: pmoore at mjs400.co.uk (Peter Moore) Date: Sat, 28 Oct 2000 23:11:04 +0000 Subject: PythonWin IDE sucks! References: <7tuivs46osods22uumpvsvsap2jocrd4si@4ax.com> Message-ID: <39FB5D09.B2D6F987@mjs400.co.uk> Dale Thanks for the post, I found it informative, concise and non-offensive and what looks like a fundamental issue. You sound like a guy trying to use open-source tech. in an industrious manner. When I develop professionally I RELY on end-user feedback - and have gained a thick skin as result. In motor racing, apparently the feedback from the top class drivers is a serious competetive factor in determining the success of a team. "Fix it yourself or be more polite" comments made to drivers probably didn't help Ferrari win the constructors championship this year. Peter Dale Strickland-Clark wrote: > > I've sort of mentioned this before and all I got was general murmors > of agreement but no solution. > > This is such a huge irritation and time waster for me that if it isn't > sorted out I can't really consider Python for future large projects. > > To test a module, I import it into PythonWin using the Import/Reload > button and then instantiate a class in the Interactive Window. > > After a failure, I fix the offending code and Import/Reload again. > However, the same failure occurs showing the original line with it's > original contents. The changed module hasn't been loaded. > > Why is this? > > What can I do about it? > > The only way to fix it is to quite and reload PythonWin but then you > have to arrange windows, reestablish breakpoints and watches, etc. > and it all takes far too long. > -- > Dale Strickland-Clark > Out-Think Ltd > Business Technology Consultants From thomas at xs4all.net Tue Oct 31 17:43:10 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 31 Oct 2000 23:43:10 +0100 Subject: newbie puzzled with thread In-Reply-To: <8tnh8j+86iu@eGroups.com>; from mpaindav@arinc.com on Tue, Oct 31, 2000 at 10:31:47PM -0000 References: <8tnh8j+86iu@eGroups.com> Message-ID: <20001031234310.M12812@xs4all.nl> On Tue, Oct 31, 2000 at 10:31:47PM -0000, mpaindav at arinc.com wrote: > I am compiling a source that has "import thread" in it.... and it > compile on one box but not on the other. However, on both machine, > there is no thread.py, just a thread.h. (I have python 1.5.2 on both) > Where is the catch? Does it has to do with setting the sys.path? > Thanks for any suggestion. The 'thread' module is not a Python module, but a C module. If you look for 'threadmodule.so', there is a chance you'll find it on the machine(s) that do have threads enabled, but not on the machine that doesn't. Even then, it might be compiled in statically, in which case you can't see it outside of Python. Rest assured that if 'import threads' fails, your python does not have threads enabled, and you need to recompile from source to enable it. (It isn't just a matter of a missing library, the entire Python interpreter needs to be 'threaded' for it to work properly.) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From fredrik at effbot.org Tue Oct 31 18:13:31 2000 From: fredrik at effbot.org (Fredrik Lundh) Date: Tue, 31 Oct 2000 23:13:31 GMT Subject: how to extract only text from a html ? References: Message-ID: Hwanjo wrote: > Could someone please tell me how to get rid of all the tags in a html ? > It seems that the htmllib.HTMLParser is not helpful to do it. here's one way to do it: html = """

header

this is some html

some more text

: COLOR="#FF0000">Heading Level 1

. > > : Now I want to split this into 3 groups: Everything before "COLOR=xyz", > : "COLOR=xyz" itself, and everything after "COLOR=xyz". > > : I tried: > : sRslt = "

Heading Level 1

"; > : print re.findall(re.compile(r'(.*?FONT.*?)(COLOR=.*?)*([ |>].*)', re.I | > : re.S), sRslt); > > Beware of quotes in your example: > > >>> sRslt = "

Heading Level 1

" > >>> sRslt > '

]+?)(COLOR=.*?)?([ |>].*)', re.I | re.S), sRslt); > [('

Heading Level 1

')] > > I used a negated character class to force an end for the first group before > a cpossible COLOR tag. Otherwise, what I think is happening is that your > non-greedy search is indeed non-greedy, but the null-match of '(COLOR=.*?)*' > is included into it. BTW, I changed that '*' to '?', which is what you meant, > if I read correctly. > > HTH, DCA > > -- Daniel Calvelo Aros > calvelo at lifl.fr From sandj.williams at gte.net Fri Oct 27 23:59:17 2000 From: sandj.williams at gte.net (Steve Williams) Date: Sat, 28 Oct 2000 03:59:17 GMT Subject: PythonWin IDE sucks! References: <7tuivs46osods22uumpvsvsap2jocrd4si@4ax.com> <8tc42n$lm3$1@nnrp1.deja.com> <798jvs4p780j4m9n2pnddj4cti22gpn9pd@4ax.com> <8tcg5j$pt$1@nnrp1.deja.com> Message-ID: <39FA4FB6.210DC39B@gte.net> Matt wrote: > In article <798jvs4p780j4m9n2pnddj4cti22gpn9pd at 4ax.com>, > dale at out-think.NOSPAM.co.uk wrote: > > Matt wrote: > > > > >PythonWin is a tool for working with the Python language. The > > >usefulness of the tool has no impact on the usefullness of the > language. > > > > What nonsense. Of course it does. The usefulness of the language is > > directly linked to how quickly you can churn out working code. The IDE > > is a critical factor in this. > > Since using PythonWin is not a requirement to develop Python code, you > can use any editor (as I do), there is no link between PythonWin and > productivity in Python. [snip] Not [tmesis] so. I put <> at the end of my code. If I run something from the command line and it returns immediately, I know I have a syntax error. But how do I find the error without running something like PythonWin? It's very easy for me to maintain something in a text editor and then 'check it out' in PythonWin and then 'inadvertently' make a fix in PythonWin. I eat a lot of chocolate-covered sugar bombs for breakfast and forget to take my Ritalin sometimes. When I do that, I'm in serious trouble. The last time it happened was about 4 hours ago. When I started as a Python newbie (four weeks ago), that was a real show-stopper. I spent a day on that very problem. But now I know better. I *still* make the mistake, however. The real thrill, is when you don't have <> at the end of your code and you find you've run off the end of the world and into the middle of some code you were working on an hour ago or some library code. The magic keystrokes in PythonWin are alt-f4. From scott at zenplex.com Tue Oct 24 08:51:05 2000 From: scott at zenplex.com (scott at zenplex.com) Date: Tue, 24 Oct 2000 16:51:05 +0400 Subject: Q: Folder Monitor Message-ID: Hello All, I'm trying to write a program that will monitor a folder for file access. I figure I have at least two variables 1) check time and 2) a wait delay.. After writing a few lines I ran into some problems. Basically I was using a sleep function to pause long enough for the file to finish copying, then use mtime to check if the file actually finished copying. The problem I have if more then one file hits the folder and my sleep routine is running my script basically is stalled. So my question is can another function be used say the select module or poll()? Or better yet can anyone point me in some direction. thanks Scott From dcalvelo at pharion.univ-lille2.fr Wed Oct 4 10:38:07 2000 From: dcalvelo at pharion.univ-lille2.fr (Calvelo Daniel) Date: 4 Oct 2000 14:38:07 GMT Subject: Getting a cookie References: Message-ID: <8rffcf$g1k$1@netserv.univ-lille1.fr> Jose Isaias Cabrera wrote: [snip context] : print hdrs : : and I get : : Date: Mon, 02 Oct 2000 16:21:07 GMT : Server: Apache/1.3.0 (Unix) : Set-Cookie: Blah-blah=78s82%23^%%%^ : Connection: close : Content-Type: text/xml Which is *one* string. : but I can not get the content of the cookie into a variable because I can't : not search through it or anything. If I use the line, : : for x in hdrs: : print x : : it gives me the error [snip] If you want to parse the 'hdrs' string to obtain the 'Set-Cookie' fields, try something like: >>> hdrs = """Date: Mon, 02 Oct 2000 16:21:07 GMT ... Server: Apache/1.3.0 (Unix) ... Set-Cookie: Blah-blah=78s82%23^%%%^ ... Connection: close ... Content-Type: text/xml""" >>> for each_line in string.split( hdrs,'\n' ): ... field, content = string.split( each_line, ': ') ... if field=='Set-Cookie': print content ... Blah-blah=78s82%23^%%%^ The standard module 'mimetools' might be useful to you too. HTH, DCA -- Daniel Calvelo Aros calvelo at lifl.fr From aahz at panix.com Wed Oct 11 22:36:10 2000 From: aahz at panix.com (Aahz Maruch) Date: 11 Oct 2000 19:36:10 -0700 Subject: Python Guru Available For Contract Work References: <8s2m8b$co$1@nnrp1.deja.com> <39e516c3.13120104@news.telus.net> Message-ID: <8s382q$nlq$1@panix3.panix.com> [contextectomy] In article <39e516c3.13120104 at news.telus.net>, David wrote: > >My penis is 10.5" long. Beat that! No, thank you. You're not my type. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 'Gender' isn't a definition, it's a heuristic. --Aahz From fcnpereira at home.com Sat Oct 7 21:36:06 2000 From: fcnpereira at home.com (Fernando Pereira) Date: Sun, 08 Oct 2000 01:36:06 GMT Subject: future of Python: Stackless, Standard -> fragmentation ? References: <8rk7e5$47u$1@oslo-nntp.eunet.no> <8rkm43$kre$1@desig-bs01-s04.adtranzsig.de> <8rkpk301ir@news2.newsguy.com> Message-ID: <071020002136061255%fcnpereira@home.com> In article <8rkpk301ir at news2.newsguy.com>, Alex Martelli wrote: > "Dirk-Ulrich Heise" wrote in message > > I suppose that that VM shares the same disadvantages > > the Java VM has? Does anybody know more? (I suspect > A specific example I've > seen mentioned is tail-recursion-optimization, which is > crucial for functional-programming languages. And could also come in handy for Stackless, although I don't know enough about the internals of Stackless or MSIL to be sure. Tail call optimization allows long-running processes in functional and logic languages, which are implemented with tail calls rather than loops, to run in constant space by reusing activation records (the idea goes at least as far back as Steele and Sussman's 1976 classic "Lambda: The Ultimate Imperative"). -- F From jwbnews at scandaroon.com Thu Oct 5 16:24:48 2000 From: jwbnews at scandaroon.com (John W. Baxter) Date: Thu, 05 Oct 2000 13:24:48 -0700 Subject: New Python development process (SourceForge considered Harmful?) References: Message-ID: In article , phd at mail2.phd.pp.ru wrote: > Why not just filter ads out? To make the letter more pythonic - I can > publish URLs of filtering proxies, and most of them are in Python. I > actually use one these proxies - and is pretty satisfied (I hacked it a > bit > and sent patches to author...) And, the few of us using Macs can set up iCab's ad filtering. It doesn't do badly (I have it only partially on at the moment, I believe). But I don't know whether iCab can operate SourceForge (the ECMA Script support [once known as LiveScript, then JavaScript] isn't completed yet). --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From mats at laplaza.org Tue Oct 10 17:25:35 2000 From: mats at laplaza.org (Mats Wichmann) Date: Tue, 10 Oct 2000 21:25:35 GMT Subject: Documentation links busted: known problem? Message-ID: <39e387a3.33143968@news.laplaza.org> Is it a known problem that the 2.0 documentation is broken? The generated html is missing the NAME tags for all sections, so that the top-of-page contents have noplace to jump to. To get real specific, I'm just looking at tut/node6.html. At the top: Subsections

and here's a link """ import htmllib, formatter import StringIO # create memory file file = StringIO.StringIO() # convert html to text f = formatter.AbstractFormatter(formatter.DumbWriter(file)) p = htmllib.HTMLParser(f) p.feed(html) p.close() if p.anchorlist: file.write("\n\nlinks:\n") i = 1 for anchor in p.anchorlist: file.write("%d: %s\n" % (i, anchor)) i = i + 1 text = file.getvalue() print text ## header ## ## this is some html ## ## some more text ## ## and here's a link[1] ## ## links: ## 1: link From max at alcyone.com Sun Oct 29 13:12:56 2000 From: max at alcyone.com (Erik Max Francis) Date: Sun, 29 Oct 2000 10:12:56 -0800 Subject: QUERY_STRING error References: <39FC1FF6.76FDABE3@NOUSPAMMhotmail.com> <39FC622D.BC469906@olen.to> Message-ID: <39FC68A8.1481EA3F@alcyone.com> Joonas wrote: > But the script works ... You were just saying that the script _didn't_ work. Weren't you showing it raising an exception? > ... and know that QUERY_STRING is in my environment. Are you sure about that? How do you know that? -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ War is the province of chance. \__/ Karl von Clausewitz Fat Boy and Little Man / http://www.fatboyandlittleman.com/ Watch Fat Boy and Little Man go about their antics. From loewis at informatik.hu-berlin.de Tue Oct 3 12:00:14 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 03 Oct 2000 18:00:14 +0200 Subject: How can you copy (clone) a string? References: Message-ID: "Tom" writes: > Well, 'need' might not be the right word, and maybe it isn't correct Python > design, but I don't think we can say that there is no situation where one > might want to do this. I can certainly say that. Why can't you? Martin From tdelaney at avaya.com Mon Oct 30 01:26:06 2000 From: tdelaney at avaya.com (Delaney, Timothy) Date: Mon, 30 Oct 2000 17:26:06 +1100 Subject: import x as y Message-ID: > > Just wondering, as a python 'advanced' novice, is there any > advantage > > of: > > > > import x as y > > > > ratheer than > > > > import x > > y=x > > ? > > > > Or is it just the elimination of the extra line? > > And the namespace polution: the "as" version doesn't create a variable > named x. > The "as" version is equivalent to > > import x;y=x;del x > > It happened so much, it has been decided to make it a one-liner. Further to this ... import x y = x del x *does* pollute the local namespace for a short while (if you already have x in the local namespace it will get rebound to the module). Does import x as y still pollute for that period of time, or is x *never* in the local namespace? And if you have an x before you import, will that x still be bound to whatever it was? Tim Delaney Avaya Australia From g2 at seebelow.org Wed Oct 4 17:06:49 2000 From: g2 at seebelow.org (Grant Griffin) Date: Wed, 04 Oct 2000 22:06:49 +0100 Subject: web hosting with python cgi References: <8rdk5o$97j$1@news5.svr.pol.co.uk> <39DAD76E.81BE5463@seebelow.org> Message-ID: <39DB9BE9.45D70C63@seebelow.org> Alain TESIO wrote: > > It's quite expensive, for the price of 20 Mb on seagull you get 400 Mb on webaxxs.net, > with a real access (telnet). They are unwilling to do the least change however, python is > still 1.4 but I compiled 1.52 on my account. The connection is very reliable. I guess "expensive" is a function not just of what you pay versus what you get, but also a function of what you need. Both of my sites run just fine on 20 Mb, so I wouldn't get any extra value out of extra space. However, I _do_ value the service I get: it's saved me several times. with-service-vendors,-you-get-what-you-pay-for-ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From peter at engcorp.com Thu Oct 12 00:43:29 2000 From: peter at engcorp.com (Peter Hansen) Date: Thu, 12 Oct 2000 00:43:29 -0400 Subject: Zope availability (was Re: pythonlabs.com website down -- 2.0c1 still available!) References: <200010102316.SAA20071@cj20424-a.reston1.va.home.com> <8s143u$2eq$1@oslo-nntp.eunet.no> <39E4D842.3BEBCB32@digicool.com> Message-ID: <39E54171.8181501F@engcorp.com> Jim Fulton wrote: > > Thomas Weholt wrote: > > The main Zope homepage was also down for a long time some > > weeks ago. It doesn't exactly do a good job at marketing Zope as a viable > > platform. Could we get some info on how the problem occurred so we can avoid > > it? > > We sometimes use zope.org as a bit of petri dish. For example, > during the time you refered to above, we used zope.org > to test (and, as it turned out, debug) a new release of ZEO. > Maybe we shouldn't use zope.org this way, but it sure is convenient > having a site that gets hit hard to try new software out on. :) My opinion is that you (and we, by extension) would be better off *NOT* using zope.org this way, as the various times it has been offline, though possibly all due to experimentation, have combined to give me a moderate concern about how suitable Zope might be for "high availability" applications. I have not experienced any problems using it which could not be directly attributed to the fact that it was running on Win98, but I certainly haven't made the (internal) site a target for much abuse yet. Although www.pythonlabs.com was apparently offline only briefly, I was looking for it at the time. I have to agree with Thomas' warning that this kind of thing, while perhaps helping Zope *development*, does not help Zope marketing. I'm sure there are many, many of us who would be only too happy to help beat up on a victimize-me.zope.org site which was explicitly made available as a target for testing new releases of Zope technology... :-) -- Peter Hansen From breiter at usf.Uni-Osnabrueck.DE Tue Oct 10 18:28:04 2000 From: breiter at usf.Uni-Osnabrueck.DE (Bernhard Reiter) Date: 10 Oct 2000 22:28:04 GMT Subject: fcgi.py for Windows needed (and socket.fromdf documentation bug found) References: <8s030t$7c5$4@newsserver.rrzn.uni-hannover.de> Message-ID: <8s055k$dcq$2@newsserver.rrzn.uni-hannover.de> In article , Neil Schemenauer writes: > On Tue, Oct 10, 2000 at 09:51:25PM +0000, Bernhard Reiter wrote: >> fcgi.py, which seem to be the way to do fcgi scripts in python >> does not support Windows platforms. > > I spent a bit of time trying to get this working for Quixote and > eventually gave up. Sockets and file descriptors are not the > same thing on Windows. The Perl fcgi module goes through > considerable contortions to work around this. If you get this > working I would be happy to hear about it. At least we are two with the same problem... And hints on what you have tried already? My problem is that I do not have access to a proprietory MSC++v6 compiler all the time so all the windows code in the mod_fastcgi modules makes not much sense to me. Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) From not_such_a_brain_after_all at mit.edu Mon Oct 30 14:59:41 2000 From: not_such_a_brain_after_all at mit.edu (Alex) Date: 30 Oct 2000 14:59:41 -0500 Subject: Q: string array (newbie) References: <8tkfi6$v4u$1@nnrp1.deja.com> Message-ID: > Is there a better way to represent such data than by using a list of > strings (1) or list of lists (2)? What if such string array will be > read from a web form by a CGI script (POST)? Thanks a lot for your > help It's simple enough to convert between the two representations using the .split and .join string methods, so choose your favourite representation, and switch when needed. Alex. -- Speak softly but carry a big carrot. From peter at engcorp.com Sun Oct 8 18:15:15 2000 From: peter at engcorp.com (Peter Hansen) Date: Sun, 08 Oct 2000 18:15:15 -0400 Subject: Measuring productivity by lines of code References: Message-ID: <39E0F1F3.E827603C@engcorp.com> Michal Wallace wrote: > Do people really pay by line of code? I want THAT job.. :) > > # old way: for x = 1 to 10 > > # new way: :) > x = 1 > x = 2 > x = 3 ... Don't laugh. I once maintained (read, rewrote) some code for an embedded system with a tiny LCD screen, written by an electrical engineer just learning C. The code I started with included a huge module containing many functions such as this: printHELLO(void) { lcdpos = 0; lcdmove(lcdpos); lcdout('H'); lcdmove(++lcdpos); lcdout('E'); lcdmove(++lcdpos); lcdout('L'); lcdmove(++lcdpos); lcdout('L'); lcdmove(++lcdpos); lcdout('O'); } These were then called by a higher-level module, with if statements to decide which function to call. I made judicious use of strings, for loops, and switch statements.... It was not the first time I've been guily of negative productivity (counting lines of code produced), as I ended up shrinking a 32K ROM image to about 19K in a couple of days... To stay a little on-topic, just the other day I rewrote some code written by an aspiring electrical engineer who was just learning Python (but was experience in C). I had negative productivity again, after removing a huge number of return value tests (judicious use of exceptions), explicit argument testing (use getopt module), and program logic (went OOP with some parts). Not quite a 25-to-1 ratio, but at least two or three to one... and it's maintainable now. -- Peter Hansen From dubois at users.sourceforge.net Tue Oct 31 16:19:29 2000 From: dubois at users.sourceforge.net (Paul F. Dubois) Date: Tue, 31 Oct 2000 21:19:29 GMT Subject: Python 9 Paper Submissions Message-ID: The deadline for submitting a paper to the Python 9 conference is next Monday, November 6. Knowing the work habits of the Python community, I made the deadline a Monday instead of Friday. Instead of partying all weekend as usual, why not write up your work and submit it at: http://python9.org Note that the guidelines on formatting only apply to the final paper; we'll take it in any readable electronic form for now. If you want to do a poster, submit your abstract as a normal paper and just say in it that you only want it considered as a poster. From jacobs at darwin.epbi.cwru.edu Wed Oct 11 20:54:00 2000 From: jacobs at darwin.epbi.cwru.edu (Kevin Jacobs) Date: 12 Oct 2000 00:54:00 GMT Subject: Possible bug (was Re: numpy, overflow, inf, ieee, and rich comparison) References: Message-ID: <8s3238$nr4$1@slate.INS.CWRU.Edu> Huaiyu Zhu wrote: > [Guido van Rossum] >> No, the configure patch is right. Tim will check in a change that >> treats ERANGE with a return value of 0.0 as underflow (returning 0.0, >> not raising OverflowError). > What is the reason to do this? It looks like intetionally subverting ieee > even when it is available. I thought Tim meant that only logistical > problems prevent using ieee. > If you do choose this route, please please please ignore ERANGE entirely, > whether return value is zero or not. > The only possible way that ERANGE could be useful at all is if it could be > set independently for each element of an array, and if it behave as a > warning instead of an exception, ie. the calculation would continue if it > is not caught. Well, then, Inf and NaN serve this purpose perfectly. > It is very reasonable to set errno in glibc for this; it is completely > unreasonable to raise an exception in Python, because exceptions cannot be > set to individual elements and they cannot be ignored. My $2.0e-2: Huaiyu is absolutely right on this one. Python is fighting IEEE 754 tooth and nail, effectively preventing it from ever working. While the changes necessary to fix this in general may be too dramatic for 2.0, it is an inevitable that it will have to be done. There is simply too much need for it and virtually no reason not to. The devil is in the details, as always. Here is a micro plan for workable IEEE754 support: 1) Detect if a platform supports IEEE arithmetic and traps. 2a) If so, compile/link with the options to enable it and use a default set of traps so that non-scientific/numerical users have sane behavior. This seems to be defined as always trapping overflow and division by zero. Provide a default SIGFPE handler that translates IEEE traps into Python arithmetic exceptions. 2b) Provide a simple interface to set and query FPU control flags. This includes rounding modes, and traps. Define functions to get NaN, Inf and test fp class. 3a) If the system is not IEEE 754-ready, provide virtually the same emulation currently provided. Implement the same FPU control interface, but raise an exception if the option isn't available (i.e. rounding mode control). The easiest thing to emulate are traps. E.g, use the current set of errno checks augmented with pseudo-IEEE 754 flags. if( errno == ERANGE && fpu_control.trap_underflow ) { // raise exception } And yes, I am volunteering to help out with the implementation. After some discussion, I'll start work on a PEP. -Kevin -- -----------> Kevin Jacobs <-----------|-------> (216) 778-8211 <-------- Informatics Consultant | Department of Epidemiology Primary mail: jacobs at theopalgroup.com | & Biostatistics Alternate mail: jacobs at darwin.cwru.edu | Case Western Reserve University ---------------------------------------------------------------------------- From smk_dc at yahoo.com Mon Oct 2 18:37:41 2000 From: smk_dc at yahoo.com (S. Murthy Kambhampaty) Date: Mon, 2 Oct 2000 18:37:41 -0400 Subject: win32com: Trouble using Excel's "SaveAs" method for Workbooks and Worksheet objects Message-ID: <39d90e35@news.digitalselect.net> I am trying to program Python to make Excel write comma separated variable (CSV) files. I'm having trouble using Excel's "SaveAs" method for Workbook and Worksheet objects from Python with the win32comm extensions. Wondering if anybody's had any success using the SaveAs method for Worksheets and Workbooks provided by COM. I have: 1. Followed directions for building excel8.py from excel8.olb 2. Created a Workbook object with a single sheet in it called xlBook2 (creation script shown below) 3. Issuing xlBook2.SaveAs(Filename=r'd:\temp\test01.csv', FileFormat='xlCSVWindows') produces the following error message: "Traceback (innermost last): File "", line 1, in ? File "d:\Python16\win32com\gen_py\00020813-0000-0000-C000-000000000046x0x1x2.py", line 17017, in SaveAs com_error: (-2147352567, 'Exception occurred.', (1004, 'Microsoft Excel', 'SaveAs method of Workbook class failed', 'XLMAIN8.HLP', 0, 0), None)" Any help/suggestions would be appreciated. Thanks, smk Python script for creating xlBook2 follows: # Begin python script import excel8, os os.chdir(r'C:\Temp') xlApp = excel8.Application() xlApp.Workbooks.Open(r'C:\Temp\Test1002.XLS') # xlBook = xlApp.Workbooks(1) # xlSheet = xlApp.Workbooks(1).Worksheets('Page (6)') xlApp.Workbooks('Test1002.XLS').Worksheets('Page (6)').Activate() xlSheet.Copy() xlBook2 = xlApp.Workbooks(2) # end Python script From fgranger at teleprosoft.com Mon Oct 30 07:39:53 2000 From: fgranger at teleprosoft.com (Fran=?ISO-8859-1?B?5w==?=ois Granger) Date: Mon, 30 Oct 2000 13:39:53 +0100 Subject: UTF-8 usage in Python 2.0 References: <1ej6pys.13l2czx178nfctN@paris11-nas9-37-62.dial.proxad.net> Message-ID: in article snwK5.3183$jv2.357271 at newsc.telia.net, Fredrik Lundh at effbot at telia.com wrote on 28/10/00 9:46: > Fran?ois Granger wrote: >> I looked throught the new features of Python 2 but I did not found an >> easy way to do something similar to what I did with this 8859 >> modification. > > # macroman to latin1 > outdata = unicode(data, "macroman").encode("latin1") Even simpler ! Next question, what if my source is encoded in html entity ? I wrote this really stupide piece of (can I call it ?) code to serve as a pre-filter: from entity88591 import entitydefs #... def htmlTo88591(s): for entity in entitydefs.keys(): s=string.replace(s, '&' + entity + ';', entitydefs[entity]) return s I guess that someone will write one line to substitute to this ?? > I've-never-met-macro-man-ly yrs /F Neither me, is it someone I should meet ? ;-) Salutations, Francois Granger -- fgranger at teleprosoft.com - tel: +33 1 41 88 48 00 - Fax: + 33 1 41 88 04 90 From dsh8290 at rit.edu Mon Oct 30 09:52:31 2000 From: dsh8290 at rit.edu (D-Man) Date: Mon, 30 Oct 2000 09:52:31 -0500 Subject: CPython vs. Jython/JPython In-Reply-To: <39FD1AA7.927E9223@san.rr.com>; from jkraska1@san.rr.com on Mon, Oct 30, 2000 at 01:48:32 -0500 References: <39FD1AA7.927E9223@san.rr.com> Message-ID: <20001030095231.C5375@dman.rh.rit.edu> BTW, I posted my other message before I saw the rest of the replies at the bottom of the folder :-) > > Personally, I can't think of any advantages of having the reference > > implementation in Java which Python doesn't already have. > > I agree. Indeed Java is not the second coming of Jesus. Please > do not treat it this way. I'm not treating it that way any more than calling a python script portable does. Python claims the same portability that Sun claims of Java. I have heard of a few problems Java had in being portable, but the goal is there and will hopefully be reached in the near future. Java is nicer than C in some respects, but doesn't provide the low-level access needed for system programming/device drivers. -D From aleaxit at yahoo.com Fri Oct 27 06:02:45 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 27 Oct 2000 12:02:45 +0200 Subject: [Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich comparison References: <39EB3D03.A00C78B6@jps.net> <39F4A4DE.9202540A@udel.edu> <8t3ota028jv@news2.newsguy.com> <39F5AA7A.2C5E35CE@udel.edu> <8t4dl301a4@news2.newsguy.com> <39F6E187.52EB03BB@udel.edu> <39F9076E.5C7253E7@my.signature> Message-ID: <8tbk710kd0@news1.newsguy.com> "Greg Ewing" wrote in message news:39F9076E.5C7253E7 at my.signature... > Charles Boncelet wrote: > > > > the > > right question to ask is "what do serious programmers want?" > > As a serious programmer, what I want is a straightforward > and efficient way to specify the operation I want performed. I agree, but would add "readable" and "concise" to the desiderata (to make them properly "slightly self contradictory": there are often such slight self contradictions). > Truncating and non-truncating division are very different > operations, used for very different purposes. Which one > I want depends on the algorithm I'm implementing. Whenever > I write a division in my code, I know which one I want. > But the only way I can tell Python which one to use > is indirectly, by manipulating the types of operands > I feed to the / operator. Good point. Although you could make the same point for numeric addition versus sequence concatenation. When polymorphism is applied to operations which are not really the same, such issues do arise. A further problem here is that there is a fairly natural mapping of either operation to the same types of arguments, as they are both numbers (and number-type objects are sometimes implicitly coerced...). Being able to easily obtain the remainder of a floating point division (just a % b) but not as easily the corresponding ("truncated-to-integer") quotient is a rarer, but pretty irking problem too. If I want both quotient and remainder, divmod is great. If I only want the remainder, % works. If I only want the quotient... no close equivalent (not even just a typecast on an operand). Having div and mod operators (or functions, but ideally with the ability to use them in infix syntax) would restore symmetry. And we could abandon the peculiar overload of the % operator to mean totally different things (formatting OR remainder...?!). (Of course, the total incompatibility with current Python means this is a proposal for Python3000). > To me, this is so obviously wrong that I can't understand > how any serious programmer could think it was right. If one never needs or wants floating-point, I guess it's easy to convince oneself that nobody else should ever want or need it either (particularly since it does give problems unless used carefully and craftily). Alex From frank at canyon-medical.com Sun Oct 8 00:10:34 2000 From: frank at canyon-medical.com (Frank Sergeant) Date: Sat, 7 Oct 2000 22:10:34 -0600 Subject: Is this a dream or a nightmare? (Was Re: XML) References: <39d1d3b2.43465571@news.telus.net> <39D19EBB.ABF18F23@engcorp.com> <39def2ae.8929692@news.davesworld.net> <39dfabb5.27391600@news.davesworld.net> Message-ID: "David T. Grove" wrote in message news:39dfabb5.27391600 at news.davesworld.net... > I've been fighting these bastards for more than > two years now. I know what their goals are, and how they get there. If > this community shows any acceptance of them, you can kiss python > goodbye within five years. > When I heard that ActiveState was going Python, I was furious at Guido > for allowing it. (Did ActiveState require special permission from Larry Wall for its use of Perl?) > >> The true beauty of perl is shown in how rapidly a program can be created: > >> a good average for comparison is 1 line of perl for every 25 lines of C, > >> TclTk, Python, or Visual Basic, and every 100 lines of C++. > > > >I was surprised to see that ratio of 1 to 25 for Perl to Python. Could you > >say a little about your reasoning in that regard? > > Did that in a later post in this thread. I read it. Thanks for clarifying it. ("I just picked a number out of thin air" -- Avogadro) > First rude pythonista I've > found so far. Well, second. (Is "pythonista" politically correct? I > don't know the right word. In Perl it would be "japh".) I've always like the term Pythonista. > >Is your PerlMagic port of Perl freely redistributable? > > Of course. That's the whole point of it. Thanks. I'm glad to hear it. Sometime back I was considering Perl for something (I've forgotten what) and didn't understand how I could distribute a Windows version of it freely along with my application. I guess I thought I'd have needed ActiveState's version and was thoroughly put off by it not being redistributable. > Anyway, let's get off that subject. I have another issue or two that I > need some help with. I need to determine the future of CodeMagic > itself. Just a quick question before I bring it up... how many of you > actually use it? This is the first time I'd heard of it (well, I vaguely remember some talk on the newsgroup maybe a year or so ago). Anyway, I downloaded the beta version (1.0.0 or 1.0.1 or something) today and took a quick look. So, no, I haven't actually been using it, but I'll probably try it out some more now that it is installed. I mostly use Emacs for my Python work and I keep hoping I'll get around to trying Idle or PythonWin eventually. -- Frank frank at canyon-medical.com From nas at arctrix.com Thu Oct 12 03:59:03 2000 From: nas at arctrix.com (Neil Schemenauer) Date: Thu, 12 Oct 2000 00:59:03 -0700 Subject: Python 2.0c1: Minor problem In-Reply-To: <39E5C58F.D949D166@erols.com>; from edcjones@erols.com on Thu, Oct 12, 2000 at 10:07:11AM -0400 References: <39E5C58F.D949D166@erols.com> Message-ID: <20001012005903.A17999@glacier.fnational.com> On Thu, Oct 12, 2000 at 10:07:11AM -0400, Edward C. Jones wrote: > When I run a Python program of mine I get the message: > > WARNING: Python C API version mismatch for module getdate: > This Python has API version 1009, module getdate has version > 1007. > WARNING: Python C API version mismatch for module _mysql: > This Python has API version 1009, module _mysql has version > 1007. > > The program ran properly. What do these messages mean? What > should I do about them? The extension modules getdate and _mysql have to be recompiled for Python 2.0. Neil From peter at engcorp.com Sun Oct 1 17:31:56 2000 From: peter at engcorp.com (Peter Hansen) Date: Sun, 01 Oct 2000 17:31:56 -0400 Subject: Secure Passwords in Memory References: Message-ID: <39D7AD4C.E54C3247@engcorp.com> "Eric Gillespie, Jr." wrote: > > I searched DejaNews and found some similar topics, but nothing > which really answered my question. I need to get the root > password from the user to exec a program which requires root > privileges. I would like to immediately zero out the memory used > to store the password. > > This is easy in a language such as C, but i don't want to write a > module just for this. I doubt 'del pw' or I would be cautious about assuming whatever technique you come up with is *really* clearing out the password, even if you wind up writing it in C. Have you considered other areas such as virtual memory? If the process can be swapped out at any time, your OS could be placing multiple copies of the password in the filesystem, and when it is later swapped back in, in other places in memory. Without having *full* control over the region of memory where the password is stored, you're probably wasting much of your time with this and lulling yourself or your users into a false sense of security. -- Peter Hansen From r.b.rigilink at cable.a2000.nl Mon Oct 9 20:32:30 2000 From: r.b.rigilink at cable.a2000.nl (Roeland Rengelink) Date: Tue, 10 Oct 2000 02:32:30 +0200 Subject: super - is (should) it (be) a reserved word? References: Message-ID: <39E2639E.6A32F32E@cable.a2000.nl> Grant Edwards wrote: > > In article , Michal Wallace wrote: > > >> Alex Martelli wrote: > >> > > >> > self.__class__.__bases__[0] satisfies this request, I think. > >> > >> Not when there is more than one level of inheritance > >> involved. The class you want to find the base class > >> of isn't the class of self, it's the class where the > >> currently executing method was defined, and there's > >> currently nothing in Python that keeps track of that. > > Excellent point. I should have thought of that. > > >Why do you need that? Calling a method of a class > >climbs the hierarchy for you, all the way up to where > >the method was first defined or last overridden. > > The example I most often run into is in an __init__ method > where I want to initialize the features my subclass is adding > and then pass control and the remaining arguments on up to the > __init__ method one layer up. The "super" that I want access > to is the parent of the class containing the reference to > "super", not the parent of the class of "self". > I think this is close to what you're looking for, although I strongly recommend using standard idiom to solve standard problems. i.e. use: class A(B): def __init__(self): B.__init__(self) or any of its variants. Roeland -- import types, sys class SuperCaller: '''SuperCaller() class that allows one to write super.do(self) as a smart version of self.__class__.bases[0].do(self): It is smart in the sense that 'do' is searched for among the complete inherentance hierarchy (depth first). The search is started in the class that defined the method that invokes super.do(), not in the class from which self was instantiated. E.g: name-resolution works the same way as with inheritance. (see tets() for an example). You can do: class AClass: def do(self): print 'Hi', class BClass(AClass): def do(self): super.do(self) print 'Ho', class CClass(BClass): def do(self): super.do(self) print 'He' and expect CClass().do() to result in Hi Ho He needs super = SuperCaller() to be defined in *Class' namespace Violates "explicit is better than implicit" in the most horrible way!''' method_name = None calling_code = None def __getattr__(self, method): # What do we want to call, and what wants to do it? SuperCaller.method_name = method try: raise Exception except Exception: frame = sys.exc_info()[2].tb_frame.f_back SuperCaller.calling_code = frame.f_code return self.super_caller def __repr__(self): return '' def find_calling_class(self, cls): '''find out what the class is from which SuperCaller.calling_code was calling super.method()''' for val in cls.__dict__.values(): if (type(val) == types.FunctionType and val.func_code == SuperCaller.calling_code): return cls for super in cls.__bases__: cls = self.find_calling_class(super) if cls: return cls def find_method(self, cls): '''find self.method among the bases of class cls''' for super_cls in cls.__bases__: if super_cls.__dict__.has_key(SuperCaller.method_name): return super_cls.__dict__[SuperCaller.method_name] method = self.find_method(super_cls) if method: return method def super_caller(self, *pars, **kw): # pars[0] is an instance # First find the calling class, then find a method among its bases cls = self.find_calling_class(pars[0].__class__) meth = self.find_method(cls) if not(meth): raise AttributeError, "No method %s in bases of %s" % \ (SuperCaller.method_name, pars[0].__class__) # In 2.0: return meth(*pars, **kw) return apply(meth, pars, kw) super = SuperCaller() def test(): class A: def __init__(self): print 'A.__init__ called by', self class B(A): def __init__(self): super.__init__(self) # A.__init__ print 'B.__init__ called by', self class C(B): pass class D(C): def __init__(self): super.__init__(self) # B.__init__ print 'D.__init__ called by', self class E: pass class F(E, D): def __init__(self): super.__init__(self) # D.__init__ print 'F.__init__ called by', self print 'Constructing F' F() if __name__ == '__main__': test() From beroul at yahoo.com Sat Oct 28 00:32:49 2000 From: beroul at yahoo.com (Benjamin Geer) Date: Sat, 28 Oct 2000 05:32:49 +0100 Subject: question about embedding Python using C++ and SWIG Message-ID: <39FA56F1.A6F105A5@yahoo.com> I've been trying to figure out how to write a C++ application that embeds a Python interpreter, into which users of the application can feed scripts, which can in turn access the application's own C++ classes (via SWIG-generated wrappers). I've got it working, but there's a problem that has me perplexed. Here's what I've done so far: The main problem I struggled with was this: how can the user's script, running inside an embedded interpreter, obtain instances of shadow classes wrapping the objects that make up the running application? I solved this problem by putting most of the application's classes in a shared library, and making them accessible through a C++ singleton. This library (including the singleton class, and the function that provides the singleton instance) is wrapped in a SWIG-generated Python module. The application's command-line executable just contains a main() function, which (in this toy example) just initialises a Python interpreter, and feeds it a Python script supplied by the user. The user's Python script simply needs to do this: import fooapp # the SWIG wrapper for the application's shared library from fooapp import Bar, Baz # some subsystems of the application app = fooapp.getApp() # get the application singleton # Manipulate the application app.doThis() app.dothat() # Get objects representing subsystems of the application bar = app.getBar() baz = app.getBaz() ...etc. Here's the problem: this only works if the Python interpreter itself has been built as a shared library. If I statically link libpython2.0.a into the application's command-line executable, something odd happens. When the program tries to run the script through the interpreter, Python throws this exception: ImportError: /usr/local/lib/python2.0/lib-dynload/fooappc.so: undefined symbol: PyInt_FromLong Any ideas about why this might be happening? Since I don't want to rely on the user having gone to the trouble (on Unix) of building Python as a shared library, I'd like to find a way around this. Also, am I barking up the wrong tree? Is there a better way to accomplish what I'm trying to do? I'm using Python 2.0 and SWIG 1.1 on a Linux system (kernel 2.2.5-15, glibc 2.1). -- Benjamin Geer http://www.btinternet.com/~amisuk/bg From Wolfgang.Grafen at marconi.com Wed Oct 18 11:03:04 2000 From: Wolfgang.Grafen at marconi.com (Wolfgang Grafen) Date: Wed, 18 Oct 2000 17:03:04 +0200 Subject: Splitting strings References: <39EDB7C3.1D82C920@hotmail.com> Message-ID: <39EDBBA8.D35E89B3@marconi.com> joonas wrote: > > i have a string "8643" how can i split it into variables: > firstvar, secondvar, thirdvar and fourthvar. > > Then variables would contain: > > firstvar = 8 > secondvar = 6 > thirdvar = 4 > fourthvar = 3 > > Try this: >>> firstvar,secondvar,thirdvar,fourthvar = map(None,"8643") >>> >>> print """\ ... firstvar = %s ... secondvar = %s ... thirdvar = %s ... fourthvar = %s ... """%(firstvar,secondvar,thirdvar,fourthvar) firstvar = 8 secondvar = 6 thirdvar = 4 fourthvar = 3 regards Wolfgang From jorgen at bos.nl Mon Oct 16 05:57:36 2000 From: jorgen at bos.nl (Jørgen Teunis) Date: Mon, 16 Oct 2000 11:57:36 +0200 Subject: python + ldap + ERROR!! HELP! Message-ID: <971690230.373315@proxy.bos.nl> So.... after a lot of work, installing, making.................................. guess what.... it still won't work... can anybody explain what this wonderfull error means? Thanks, J?rgen Traceback (innermost last): File "ldap.cgi", line 3, in ? import _ldap ImportError: ld.so.1: python: fatal: relocation error: file /usr/local/lib/python1.5/site-packages/_ldapmodule.so: symbol ldap_bind_s: referenced symbol not found From pearu at ioc.ee Fri Oct 13 14:16:47 2000 From: pearu at ioc.ee (Pearu Peterson) Date: Fri, 13 Oct 2000 20:16:47 +0200 Subject: ANNOUNCE: PySymbolic - Doing Symbolics in Python In-Reply-To: <8s6e8m0248c@news1.newsguy.com> References: <8s6e8m0248c@news1.newsguy.com> Message-ID: On Fri, 13 Oct 2000, Alex Martelli wrote: > Neither does it run for me, but I least I can easily understand > why -- the package relies on upper/lower case distinction being > significant in matching filenames, and this doesn't work well on > Windows' case-preserving-but-insensitive filesystems. In other > words, on Windows, you just can't rely on Parser.py and parser.py > being distinguishable files, and therefore parser and Parser > being distinct Python modules, as the current version of Symbolic > does. > > Pearu, it's a 10-minute editing job, but, if you want, I'll > zip and send you the edited directory, of course! No, it is fixed now. Thanks. > Huaiyu, I know that Pearu was testing with 1.5.2, but, might > there be some issues with your current installation...? Have > you tried it with Release Candidate 1...? Or maybe you have > an older version of Symbolic.py earlier on sys.path...? I am also use Python 2.0b2 for tests and with success. Regards, Pearu From aleaxit at yahoo.com Fri Oct 6 05:50:44 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 6 Oct 2000 11:50:44 +0200 Subject: Why is "while" ticking me off??? References: <39DD15A1.442E5A33@ix.netcom.com> Message-ID: <8rk7jl01g4q@news1.newsguy.com> "Steve Lamb" wrote in message news:slrn8tq8sp.aj6.grey at teleute.rpglink.com... > On Thu, 05 Oct 2000 19:58:25 -0400, Thomas Gagne wrote: > >while line = fp.readline(): > > do something with 'line' > > Perlism? > > >I'm obviously not approaching this in the Python idiomatic way. > > while 1: > line = fp.readline() > if not line: > break > do something with 'line' Yes, this is canonical, but it's one of the few things I dislike in Python. I much prefer a wrap-into-a-sequence approach -- I have in my site.py this definition: class lazyseq: def __init__(self, func, termtest=None): self.func=func self.term=termtest if not self.term: self.term = lambda x, y: not x def __getitem__(self, index): item = self.func() if self.term(item, index): raise IndexError return item which lets me do for line in lazyseq(fp.readline): do something with line For a more general approach to introducing functional programming idioms (laziness in particular) into Python, see functional.py at: http://sourceforge.net/projects/xoltar-toolkit/ Alex From bk at xk7.com Thu Oct 19 06:25:07 2000 From: bk at xk7.com (Burkhard Kloss) Date: Thu, 19 Oct 2000 11:25:07 +0100 Subject: Low cost web hosting with Python References: Message-ID: <971951392.593519@master.nyc.kbcfp.com> Hurricane Electric (http://www.he.net/) do full Linux access from USD 9.95 a month. They don't install python for you, but since you have a login prompt you can install it yourself. 'been using them for a while, and no complaints so far. Burkhard From loewis at informatik.hu-berlin.de Sun Oct 1 04:02:18 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 01 Oct 2000 10:02:18 +0200 Subject: Wholly unnecessary flame. (was Re: pyXML!) References: <7BD10B680501D411B9DF009027E06F32011BD9@exchange> <39d2d532.43850056@news.telus.net> <7j6A5.861$jk1.56216@newsc.telia.net> <39d24589.6203856@news.telus.net> Message-ID: root at 127.0.0.1 (David) writes: > Question: Why was VC chosen as the development platform, instead of an > open-source compiler? Chosen by whom? By Mark Hammond? Probabably because that was the compiler he had available, and knew best. By BeOpen? Probably following tradition, and knowing that extension writers expect VC++-compatible import libraries. > Question: Are any VC-specific features/code/tweaks being used? Why would > the developers choose to bind the code to VC, rather than aim for > cross-compiler compatibility? Answer: not that I know of. > Question: Are build files so different between compilers that there is no > automatic tool for converting from build to build? Answer: Yes. > Question: Why wouldn't every Windows-platform code release include a binary > file, to accomodate the vast numbers of Windows users who don't have VC, > don't know how to operate the VC compiler and, frankly, really would rather > get on with using the code instead of wrestling with compiling it? Answer: I don't understand the question. What is a "Windows-platform code release"? You mean "Windows 95", "Windows NT", or "Windows 2000"? And what is a "binary file"? Windows includes many binary files... > From my perspective, it makes absolutely no sense for any developer to (a) > not distribute binaries for their Windows port; and (b) to force users to > install a commercial compiler to create binaries. Which developer did not distribute binaries for their Windows port? I agree: If there are no binaries, it's not a Windows port. Regards, Martin From quinn at mark.ugcs.caltech.edu Thu Oct 12 15:58:29 2000 From: quinn at mark.ugcs.caltech.edu (Quinn Dunkan) Date: 12 Oct 2000 19:58:29 GMT Subject: Most Effective Way to Build Up a Histogram of Words? References: <8s4hc3$a5a$1@news.nuri.net> Message-ID: On Thu, 12 Oct 2000 23:20:43 +0900, June Kim wrote: >Thank you Mr. Brunning. > >"Simon Brunning" wrote in message >news:mailman.971358210.26293.python-list at python.org... >> > From: June Kim [SMTP:junaftnoon at nospamplzyahoo.com] >> > What is the most effective way, in terms of the execution speed, >> > to build up a histogram of words from a multiple of huge text >> > files? >> >> June, >> How huge? As a first cut, I'd try something like this (untested) - > >The files are of a few MBs. Provided you have more than a few MBs of free memory, slurping the whole file oughta work fine. >> file = open('yourfile.txt', r) >> filedata = file.read() >> words=filedata.split() >> histogram {} >> for word in words: >> histogram[word] = histogram.get(word, 0) + 1 >> for word in histogram.keys(): >> print 'Word: %s - count %s' % (word, str(histogram[word]) >> >> This should work unless the file is *really* huge, in which case you'll >need >> to read the file in a chunk at a time. But if you can squeeze the file in >> one gulp, do so. >> > >and then how could I sort the dictionary according to the >frequency order? a = map(lambda t: (t[1], t[0]), historgram.items() a.sort() for freq, word in a: print word, freq Also, if you're using python 2.0, you could use a slightly more efficient historgram.setdefault(word, 1) instead of: histogram[word] = histogram.get(word, 0) + 1 and a clearer list comprehension replaces the map: a = [(freq, word) for (word, freq) in historgram.items()] ... but as to which one is faster, I believe the last argument concluded that sometimes the function call overhead hurts map more than the "can't precalculate size" thing hurts a comprehension or explicit loop, but sometimes it's the reverse :) I wonder if a = [None] * len(historgram) i = 0 for word, freq in historgram.items(): a[i] = freq, word i = i + 1 would really be any faster. From paulp at ActiveState.com Wed Oct 25 17:24:47 2000 From: paulp at ActiveState.com (Paul Prescod) Date: Wed, 25 Oct 2000 14:24:47 -0700 Subject: Python 2.0 and pyexpat References: Message-ID: <39F74F9F.9B67C212@activestate.com> You need expat 1.1. Get it here: ftp://ftp.jclark.com/pub/xml/ Paul Prescod ActiveState Tool Corp. From darked at my-deja.com Mon Oct 30 13:44:25 2000 From: darked at my-deja.com (darked at my-deja.com) Date: Mon, 30 Oct 2000 18:44:25 GMT Subject: Q: string array (newbie) Message-ID: <8tkfi6$v4u$1@nnrp1.deja.com> Dear All, I'm struggling with representation of an 12x8 array of strings. My array looks like this: """ a01 a02 a03 a04 a05 a06 a07 a08 a09 a10 a11 a12 b01 b02 b03 b04 b05 b06 b07 b08 b09 b10 b11 b12 c01 c02 c03 c04 c05 c06 c07 c08 c09 c10 c11 c12 d01 d02 d03 d04 d05 d06 d07 d08 d09 d10 d11 d12 e01 e02 e03 e04 e05 e06 e07 e08 e09 e10 e11 e12 f01 f02 f03 f04 f05 f06 f07 f08 f09 f10 f11 f12 g01 g02 g03 g04 g05 g06 g07 g08 g09 g10 g11 g12 h01 h02 h03 h04 h05 h06 h07 h08 h09 h10 h11 h12 """ Is there a better way to represent such data than by using a list of strings (1) or list of lists (2)? What if such string array will be read from a web form by a CGI script (POST)? Thanks a lot for your help Greetings Darek Kedra Add 1: A = "a01 a02 a03 a04 a05 a06 a07 a08 a09 a10 a11 a12" my_array =[A, B, C, etc ] Add 2: A = ['a01', 'a02', .... 'a12'] my_array =[A, B, C, etc ] Sent via Deja.com http://www.deja.com/ Before you buy. From Drew.Whitehouse at anu.edu.au Tue Oct 24 22:02:20 2000 From: Drew.Whitehouse at anu.edu.au (Drew Whitehouse) Date: 25 Oct 2000 13:02:20 +1100 Subject: WIN32 questions Message-ID: Hi, Can some of the win32 gurus help me with a few things... I want to have a win2k system startup (and shutdown) a full-screen GUI program on a dozen other win2k systems. Can I do this without having the operator logon to each of the systems manually (it's a kiosk like facility) ? Should I be using an NT Service ? Is there a way to trap the closing of a window from a command line python program ? ie a user double clicks on a python app icon, it runs continuously in a console window and eventually they hit the kill button. (try: .. finally: .. doesn't handle this). I need to do various cleanup actions before the program dies, which leads me to my next question. I notice that win32com clients that don't exit normally don't properly cleanup server instances ie there is a pythonw.exe left running in the background (motivation for the previous question). How do I clean-out these orphaned instances ? Finally, does anyone have a method/module for reading a joystick/gamepad from wxPython ? Thanks, Drew -- ;; Drew.Whitehouse at anu.edu.au Sci-Viz/VR Programmer ;; Australian National University Supercomputer Facility From thomas.heller at ion-tof.com Fri Oct 6 10:53:29 2000 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Fri, 6 Oct 2000 16:53:29 +0200 Subject: ExtensionClass and the buffer interface Message-ID: <00b901c02fa5$337ec830$4500a8c0@thomasnotebook> ExtensionClass (from a recent zope distribution) does not support the buffer-interface at all. Has someone made a patch? Thomas From the_brain at mit.edu Mon Oct 9 13:22:27 2000 From: the_brain at mit.edu (Alex) Date: 09 Oct 2000 13:22:27 -0400 Subject: Function wrapper in Python References: <39E1F408.A03AF6E7@yahoo.com> Message-ID: Try os.execv and friends. They do roughly what you want, except for the error handling. Alex. -- Speak softly but carry a big carrot. From fgeiger at datec.at Wed Oct 4 09:56:30 2000 From: fgeiger at datec.at (Franz GEIGER) Date: Wed, 4 Oct 2000 15:56:30 +0200 Subject: Reg Exp: Need advice concerning "greediness" References: <8r4om7$9bd$1@newsreaderm1.core.theplanet.net> <8r9nc3$8re$1@netserv.univ-lille1.fr> Message-ID: <8rfd16$arr$1@newsreaderg1.core.theplanet.net> > I used a negated character class to force an end for the first group before > a cpossible COLOR tag. Otherwise, what I think is happening is that your That did the trick. > is included into it. BTW, I changed that '*' to '?', which is what you meant, > if I read correctly. Yes. As fascinating reg exp are, they are not always easy to understand and use, especially for newbies. Thanks a lot and best regards Franz Calvelo Daniel schrieb in im Newsbeitrag: 8r9nc3$8re$1 at netserv.univ-lille1.fr... > Franz GEIGER wrote: > : Hello all, > > : I want to exchange font colors of headings of a certain level in HTML files. > > : I have a line containing a heading level 1, e.g.: