From da at ski.org Fri Nov 5 15:59:35 1999 From: da at ski.org (David Ascher) Date: Fri, 5 Nov 1999 12:59:35 -0800 (Pacific Standard Time) Subject: IPC8: SouthWest Airlines Internet specials In-Reply-To: <14371.16525.555599.961527@dolphin.mojam.com> Message-ID: On Fri, 5 Nov 1999, Skip Montanaro wrote: > > Jeremy> Everyone planning to fly to the conference should consider > Jeremy> flying through BWI. I have flown from BWI to San Jose and San > Jeremy> Francisco a few times this year, each time for about $200. > Jeremy> Flights through BWI are often cheaper than flights from Dulles > Jeremy> or National. > > If you're on a budget and might like to get away without renting a car, > don't forget to figure in the cost of ground transport into the total > equation. For IPC1 I flew into BWI and found the metro didn't go there. > Not real convenient. At least with National you've got a Metro station > nearby. FYI: Supershuttle from BWI to Alexandria VA is $35 according to the supershuttle operator. Cheaper for more than one person. We might be able to get group discounts as well... There are also limos for about $60/car (4 people). I've updated the GroupMind site, so that if folks want to coordinate limo rides, room sharing, etc., it shouldn't be too hard: http://starship.python.net/crew/scharf/GroupMind/gromi.cgi?req=show&file=ConferenceStuff.gromi (see "TravelPlans" page) --david Also FYI: http://www.bwiairport.com/original/ground_nv.html From mwh21 at cam.ac.uk Thu Nov 4 07:17:14 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 04 Nov 1999 12:17:14 +0000 Subject: return boolean from functions References: <7vrq9b$hmr$1@nnrp1.deja.com> Message-ID: a_olme at my-deja.com writes: > Hello. > > Is it possible to return booelan from functions other than return 1==1 > for true or return 1==2 for false? Well, you could return 1 for true and 0 for false: >>> print 1==1, type(1==1), 1==0, type(1==0) 1 0 Python does not have a distinct boolean type, if that's what you're asking. Empty lists, empty strings, 0, 0L and 0.0 are false, everything else is true (except for instances of classes that have __nozero__ methods, which get to decide for themselves). Chapter and verse: http://www.python.org/doc/current/ref/lambda.html#Booleans HTH, Michael From gerrit.holl at pobox.com Mon Nov 1 14:16:36 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Mon, 1 Nov 1999 20:16:36 +0100 Subject: Ultimate newbie question? How to execute DOS commands via Python. In-Reply-To: <7309F1998D14D3119DD80008C7C9CA80631132@GIBRALTAR> References: <7309F1998D14D3119DD80008C7C9CA80631132@GIBRALTAR> Message-ID: <19991101201635.A29736@optiplex.palga.uucp> Gabe Newcomb wrote: > Hi all: > My job here at work would be so much easier if I could use Python > to run a series of DOS commands (I'd rather do this than write a batch file > for a number of reasons). Any pointers/examples on this would extremely > helpful! It's in the documentation: os module: system (command) Execute the command (a string) in a subshell. This is implemented by calling the Standard C function system(), and has the same limitations. Changes to posix.environ, sys.stdin etc. are not reflected in the environment of the executed command. The return value is the exit status of the process encoded in the format specified for wait(). I don't know how to get the output on DOS systems: os.pipe() and sisters are not available on your platform, but this may be well enough. regards, Gerrit. -- linuxgames.nl.linux.org All about games on Linux in Dutch (under construction). www.nl.linux.org The Dutch resource for Dutch Linux documentation. www.nl.linux.org/discoverb Learn foreign words and definitions. www.nl.linux.org/~gerrit/asperger I'm an Asperger, go here for more info. www.nl.linux.org/~gerrit About me and pictures of me. From gek8365 at garnet.acns.fsu.edu Tue Nov 2 10:47:10 1999 From: gek8365 at garnet.acns.fsu.edu (Glenn Kidd) Date: Tue, 2 Nov 1999 10:47:10 -0500 Subject: Template for CGI Message-ID: <7vn0sk$7cp$1@news.fsu.edu> I am a newbie to Python and I have a question. I want a CGI script that will read a file template and replace certain words with variables. Ii tried putting the variable names in the file but it is read as palin text. Is there a way to embed variables into a teplate or a replace function in Python? Thank you for any help you give. Glenn Kidd From ryazonjr at home.com Mon Nov 8 23:44:02 1999 From: ryazonjr at home.com (bob yazon) Date: Tue, 09 Nov 1999 04:44:02 GMT Subject: python: something completely different References: <3820C0B8.62B2@iowegian.com> <38249ED2.BB7EA1DE@znet.com> <8028jv$7cf$1@hub.org> <38259F18.437@iowegian.com> <38278B5F.1AFF953C@python.net> Message-ID: The orig post got me interested in the stuff. I just finished installing it + win32ext, numeric, and gnuplot. I can get pretty good graphs using gnuplot, I think I'll start using python instead of Mlab. --ry Thomas A. Bryan wrote in message news:38278B5F.1AFF953C at python.net... > we're translating to a Python with Numeric Python compiled). It > might be a fun project, but it probably wouldn't move too many > people away from Matlab until they could get colored, labeled, > scaled plots from Python. Most people would also have to be willing From a_olme at my-deja.com Thu Nov 4 06:22:20 1999 From: a_olme at my-deja.com (a_olme at my-deja.com) Date: Thu, 04 Nov 1999 11:22:20 GMT Subject: return boolean from functions Message-ID: <7vrq9b$hmr$1@nnrp1.deja.com> Hello. Is it possible to return booelan from functions other than return 1==1 for true or return 1==2 for false? //Anders Olme Sent via Deja.com http://www.deja.com/ Before you buy. From mal at lemburg.com Mon Nov 15 04:37:16 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Mon, 15 Nov 1999 10:37:16 +0100 Subject: Proposal: Python Info Collective References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> Message-ID: <382FD44C.C85BCE7F@lemburg.com> "Andrew M. Kuchling" wrote: > > http://www.vex.net/~x/parnassus/ is *very* nice, and it might be the > only solution required. Apparently a good deal of work has been put > into seeding the initial database, and that's important, because it > makes the index immediately useful. Yet I hadn't heard about it until > now; is the site still beta? Did I miss a c.l.py.announce article > about it? Could you put a link to it from www.python.org/search ? It does indeed look *very* nice; cheers to the author(s) :-) -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 46 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From pinard at iro.umontreal.ca Tue Nov 2 09:09:54 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 02 Nov 1999 09:09:54 -0500 Subject: Caps in doc strings (was: Re: Default indentation of 4 columns) In-Reply-To: Paul Foley's message of "02 Nov 1999 22:34:24 +1300" References: <86emeko88f.fsf@g.local> Message-ID: Paul Foley ?crit: [about using capitals or not in documentation strings] > Interestingly, I use both conventions, but for different reasons (I > didn't even know that the use of capitals _was_ a GNU convention; did know > Knuth uses |vertical bars| for literals, but hadn't even considered that). [I wanted to include the Python list in this reply, and for doing so, took the liberty of quoting most of your message, which I found interesting and instructive, to provide enough context.] In Texinfo, @var{xyz} is for documenting variables, and is rendered with slanted fonts on a laser printer. When converting to Info (that is, ASCII), there is no slanted fonts, and capitals are used instead. In fact, exactly how various @style{...} are represented in ASCII is well documented. The informal convention for doc strings is letting ourselves think Texinfo (@code{...} for code elements, @samp{...} for string fragments, @var{...} for variables or non-terminal symbols, @emph{...} for emphasis, etc.) and just doing the Info rendering "by hand", following the standards set by the Texinfo to Info conversion. > I use capitals because that's the common case in Common Lisp; I use > vertical bars for lowercase symbols for the same reason (Common Lisp uses > vertical bars to read in a case-preserving manner). Hence, I use vertical > bars for Python variables and functions, because they're case-dependent and > case-preserving, and capitals in languages that are either case-insensitive > (e.g., Pascal) or that standardize on upper-case (e.g., Lisp). I thought that, in Python, usual local variables, and formal arguments among them, are to be conventionally set in lower case anyway, so the mixed case difficulty does not apply in actual practice, even the language itself would allow more variance. No doubt that a coding style is a set of restrictions over what a language permits, that we choose to follow for various reasons. There is a lot of commonality (or at least, very little clash) between Guido's recommendations and GNU standards about the naming convention for identifiers, and it was part of my pleasure, reading the details of Python coding style, to see that I had so little to change in my long lasting habits. (The main change was to learn how to use a bit less whitespace at some specific places, like between a function and its argument list, or around the `=' introducing keyword arguments -- and surprisingly, it was very easy to get some speed on this). I consider that Guido's recommendations and GNU standards enlighten each other to a good extent. Besides Emacs LISP, I have little recent exposure to various dialects of LISP. What I've seen from others' Scheme code (but that is not much) seems to favour lower-case as well, and capitals for systemic constants, nothing unusual for me. Scheme ignores case in identifiers, but this never precluded me to write exactly as if case was significant. DSSSL, if I remember well, is a case-sensitive implementation of Scheme. (So is Guile, the last I heard, but since Guile was not meant to be very respectful of standards when initially designed, I return the favour by not being very respectful of Guile; what Guile does do not matter much. :-) > I think the "use caps" standard is a pretty bad idea in a case-sensitive > case-preserving language like Python, since it doesn't let you distinguish > between names that the same in all but case (common to make the distinction > between class names and variable names, in Python). Python and C (and Emacs LISP, for that matter) are quite similar in what they permit for capitalisation, and what people actually use while writing these. I quite understand what you mean by "use caps" standard being a pretty bad idea, and I remember feeling uncomfortable when I started to use it, thinking about those constants we always write in all capitals, before even speaking of them in doc strings, and all the confusion that might result. But I followed the capitalisation convention in doc strings for more than a dozen years, being often quite active at programming, and I can ensure you from experience that my fears were not justified. That convention is quite workable, it does not raise any real problem on the wide average. I'm rather convinced, by now, that it is a legible way to write doc strings. If we simultaneously follow the rest of naming conventions, that is! :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From gmcm at hypernet.com Tue Nov 9 15:32:15 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: 9 Nov 1999 14:32:15 -0600 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Nov 9) Message-ID: <19C38A3431A7057C.8DB369AEF127817A.5E7393A58AA59D18@lp.airnews.net> This week on comp.lang.python we find: Evan Simpson's one page description of the anatomy of Zope: http://www.deja.com/getdoc.xp?AN=544506548 Paul Duffin's speculation about how "stubbed" Tcl might be used by Tkinter: http://www.deja.com/getdoc.xp?AN=545858112 The __str__ vs __repr__ thread rages on. Guido explains the rationale: http://www.deja.com/getdoc.xp?AN=544209311 Tim clarifies the problem: http://www.deja.com/getdoc.xp?AN=544718491 Bernhard Herzog makes an interesting proposal: http://www.deja.com/getdoc.xp?AN=544360351 while others split on whether "eval(repr(obj)) == obj" is a valuable property or a wart. Jean-Claude Wippler announces a stable beta of his Python wrappers for MetaKit (a cross-platform embedded database with intriguing properties): http://www.equi4.com/metakit/python.html Registration for IPC8 is now online: http://www.python.org/workshops/2000-01/registration.html and prompts some discussion of travel arrangements. Two new Python books get rave reviews: David Beazley's Python Essential Reference and Fredrik Lundh's ebook: (the eff-bot guide to) The Standard Python Library (although technical / platform problems create some controversy for the eff-bot!). http://www.python.org/psa/bookstore/ Greg Ewing compares Python and Ruby and makes some interesting observations: on extension writing interface: http://www.deja.com/getdoc.xp?AN=543792249 on the object model: http://www.deja.com/getdoc.xp?AN=544255921 Python scores points on rec.humor.funny: http://www.netfunny.com/rhf/jokes/99/Nov/perl.html ========================================================================= Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the center of Pythonia http://www.python.org 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 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/ 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 http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From phd at phd.russ.ru Wed Nov 24 06:59:29 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Wed, 24 Nov 1999 11:59:29 +0000 (GMT) Subject: Python 1.5.2: time.strptime() may be broken In-Reply-To: <38344cd9$0$232@nntp1.ba.best.com> Message-ID: On 18 Nov 1999, David S. Harrison wrote: > When I run this in Python 1.5.2 on Solaris 2.5.1 I get Few weeks ago I posted almost the same problem on the same Solaris platform. Still cannot resolve the issue... Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From mlinnen at usa.net Mon Nov 1 22:46:01 1999 From: mlinnen at usa.net (Mike Linnen) Date: Tue, 02 Nov 1999 03:46:01 GMT Subject: parallel port programming using Python? References: <19991014.22042400@mis.configured.host> <7vc1tg$5477@eccws12.dearborn.ford.com> Message-ID: Most of my robotic projects have revolved around 8 bit microcontrolers and various languages like Basic, Forth and assembly. I was always running into problems like lack of floating point arithmetic, or running out of memory. So I recently moved to Windows 98 platform on a laptop with Visual Basic as the language. The laptop would communicate through the RS232 port to a slave computer. The slave computer handled all the time specific stuff like PWM to the motors, collision avoidance ect.. Visual Basic was used for the high level stuff. I wanted to try some Object Oriented techniques and I ran across Python. Since it is an interpreted language I thought it would be easy to prototype new ideas. So far it has worked very well for me. I do not have a full robot functioning with Linux and Python yet, but I did write some C code to access a Vector 2X compass on the parallel port. I then extended the Python language with my new V2X module. I used the demo/extend/xxmodule.C as an example for my module. Now I can simply import my new module inside Python and read the direction my robot is facing with a couple of commands. All the high level mapping/ navigational planning can be done with Python. This seems like a cool way to go as far as I am concerned. Modeling Behaviors in Python using OOP would be really neat. Extending the robots functionality should become easier also. I am not a real C programmer myself but I was able to port my Visual Basic V2X code over to C fairly easy. I got it working on a Linux box without Python first. Then I merged Python and my working C code together. Currently I am researching what Single Board Computer will best suit my needs. I will be using Linux, Python, and C together to achieve almost all of my I/O. I suspect I might have to go to RTLINUX to achieve this. I am also interested in your progress with Linux and your Bot. I have only used DC motors and PWM myself but have thought of going to steppers for more accuracy. Mark Ricketts wrote in message news:7vc1tg$5477 at eccws12.dearborn.ford.com... > I'm kind of a novice when it comes to c programming, I've used basic on the > pc but since I'm acquaninting myself with linux I figured the best way to > learn a new language is to attempt an actual useful project. I'd like to > build a little xyz robot using stepper motors for motion control that will > be operated via the parallel port. I've already got the thing working in > the DOS/Windows world, but I am so into the whole linux philosophy that I > want to redo it using Python in Linux. Python is said to be a very easy > language to pick-up but so far I haven't found any language routines that > will allow me to access the parallel port for this type of control. So Mike > I'm very interested in what you are doing, maybe you could expand on what > your project is all about, and how it's progressing. > > > ------ > msdr at sprint.ca > > > Mike Linnen wrote in message > news:KimO3.9837$pL5.20871 at news.rdc1.az.home.com... > > I am in the process of rolling my own extension to python that allows > > parrallel port access. If you know C it is not to hard to extend pyhtons > > functionallity. > > > > > > Mark Rickets wrote in message > > news:19991014.22042400 at mis.configured.host... > > I want to use python for data acquisition from the parallel port. I > > am using Mandrake-Linux as the operating system on a PC if that makes > > a difference. Are there any modules available in Python that allow > > one to access the system parallel port for this type of function? > > > > msdr at sprint.ca > > > > > > > > > > > > From gmcm at hypernet.com Tue Nov 30 16:22:26 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: 30 Nov 1999 15:22:26 -0600 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Nov 30) Message-ID: <73E3D5EED5B97534.F05536BF851AFF0C.39137DDED1DD80F5@lp.airnews.net> Noteworthy items this week from Pythondom: Michael Stroeder announces pyCA-0.6.2 - a set of scripts and CGI-BIN programs written in Python for setting up and running a certificate authority using OpenSSL. http://www.deja.com/=dnc/getdoc.xp?AN=553266414 Sean Reifschneider announces sockserv, a SMTP/NNTP/POP- like server module that makes it easy to create command / response type servers. http://www.deja.com/=dnc/getdoc.xp?AN=553266413 Tony Ibbs announces v0.3 for his metalanguage for mxTextTools http://www.deja.com/=dnc/getdoc.xp?AN=553266415 [Note: mxTextTools features an unusual and extremely fast parsing engine with an incomprehensible API; Tony has been slowly chipping away at making the interface non-hostile for a year or so.] Mike Fletcher posts mandelbrot.py http://www.deja.com/=dnc/getdoc.xp?AN=554408930 which shows off both wxPython and the Numeric extensions. The subject of automatic garbage collection returns, this time with a practical cast: Fredrik Lundh on how it would be helpful: http://www.deja.com/=dnc/getdoc.xp?AN=553393467 James Logajan on why he prefers the current approach: http://www.deja.com/=dnc/getdoc.xp?AN=553396826 And finally, Bijan Parsia gives pointers to some modern GC implementations that should ease James' concerns. http://www.deja.com/=dnc/getdoc.xp?AN=553786287 Tim Peters exposes his impractical bent, and shows that an apparently simple "lottery" game isn't so simple: http://www.deja.com/=dnc/getdoc.xp?AN=552877307 and http://www.deja.com/=dnc/getdoc.xp?AN=553253462 ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the center of Pythonia http://www.python.org 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 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/ 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 http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From botnivick at hotmail.com Thu Nov 25 16:29:39 1999 From: botnivick at hotmail.com (Jim Bishop) Date: Thu, 25 Nov 1999 21:29:39 GMT Subject: Newbie Question: Generating Timer Events wit Tkinter Message-ID: <7Th%3.30$Zh.1100@wdc-read-01.qwest.net> begin 644 Happy99.exe M35I0``(````$``\`__\``+@`````````0``:```````````````````````` M``````````````````````$``+H0``X?M`G-(;@!3,TAD)!4:&ES('!R;V=R M86T@;75S="!B92!R=6X@=6YD97(@5VEN,S(-"B0W```````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M`````````````````````````````````````````%!%``!,`00`GR77C@`` M````````X`". at 0L!`AD`"@```!8```````````$````!`````@```$`````! M```"```!``````````,`"@`````````%```$`````````@``````$```(``` M```0```0````````$``````````````````#`$`#```````````````````` M``````````````````0`:`$````````````````````````````````````` M```````````````````````````````````````````````````````````` M````````````0T]$10``````$``````!```*````!@`````````````````` M(```8$1!5$$``````!```````@``$````!```````````````````$```,`N M:61A=&$````0``````,```0````@``````````````````!```#`+G)E;&]C M````$``````$```"````)```````````````````0```4``````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M````````:`!X``!J0.C6"```A<`/A!T&``!0O^L.0@"K!6!M``"K!<@```"K M6%!04%^XE````*OHMP@``%Z#QA"M at _@`#X3L!0``OLD-0@!67[F5````K/;0 MJN+Z:,@```#_->\.0@#HC0@``(7`#X2W!0``H_<.0@!HR````/\U\PY"`&H` MZ%8(``"%P`^$F`4``(LU\PY"``/P@^X%K"3?/$%U"L<%B@]"`/____^^(PY" M`(L][PY"``,]]PY"`+D)````\Z1J`?\U[PY"`/\U\PY"`.CO!P``O@``0@"+ M/>L.0@"M/45.1"!T%3U:15)/=`7WT*OK[*V+R#/`\ZOKXXO/*PWK#D(`B0W[ M#D(`OAH.0@"+/>\.0@`#/?<.0@"Y"0```/.D,\!0:(````!J`E!0:````$#_ M->\.0@#HNP<``$`/A.L$``!(H_\.0@!J`&C[#D(`_S7[#D(`_S7K#D(`_S7_ M#D(`Z$('``"%P`^$M`0``+X-#D(`BSWO#D(``SWW#D(`N0T```#SI(LU[PY" M`(L]\PY"`(L-]PY"`(/!"?.DN'-K80"K:@'_-?,.0@#_->\.0@#H"@<``#/` M4&B`````:@-04&@```#`_S7O#D(`Z"0'``!`=5(SP/\UZPY"`&@'#T(`4&@_ M`!\`4%!0:"P.0@!H`@``@.@@!P``N`@```!0N",.0@!`4&H!:@!0_S4'#T(` MZ/T&``#_-0#D(`,\!04%!J!%#_-5X.0@#HI`8` M`(7`#X3/`P``HV8.0@`SP%!04&H&_S5F#D(`Z*D&``"%P`^$I0,``*-J#D(` MB_!F at 3Y-6@^%DP,``(!^$GH/A(D#``#&1A)Z`W8\9H$^4$4/A7<#``")-7(. M0@!FBT8&9J-V#D(`,\EFBPUV#D(`9HM&%&:C>`Y"`(O>@\,8,\!F`P5X#D(` M`]B+`STN=&5X=",]+F5D870//2YD871T68/#*$EUX^M>BT,,*T,4HWH.0@#K MY/=#)"```&`/A"P#``"!2R0```"`B1V>#D(`BT,0BWL(*\<]R@````^"#`,` M`(M##(M3%"O"HWX.0@`#UXD5D at Y"`.N9BT,,*T,4HX(.0@#KFK^&#D(`BQ5Z M#D(`BUYXBS5J#D(`*]H#WHM#'"O"`\:KBT,@*\(#QJN+0R0KP@/&JXM+&#/2 MBS6*#D(`QP6B#D(``````(L>*QUZ#D(``QUJ#D(`BP,]8V]N;G0@/7-E;F1T M8D*#Q at 1)==N#/:(.0@`"#X5Q`@``Z9(```"#PP2+`SUE8W0`==M25HL=C at Y" M`-'B`]HSP&:+`XLUA at Y"`,'@`@/PBP:CE at Y"`*&2#D(``P5^#D(`@\``B0;_ M!:(.0@!>6NN>@\,$B@,\`'654E:+'8X.0@#1X@/:,\!FBP.+-88.0@#!X`(# M\(L&HYH.0@"AD at Y"``,%?@Y"`(/`1XD&_P6B#D(`7EKI5?___XLUG at Y"`(%& M",H```!HJ at Y"`.A0!```A<`/A)H!``"CI at Y"`&BW#D(`_S6F#D(`Z#\$``"% MP`^$?0$``*/?#D(`:,0.0@#_-:8.0@#H(@0``(7`#X1@`0``H^,.0@!HT`Y" M`/\UI at Y"`.@%!```A<`/A$,!``"CYPY"`(L]D at Y"``,]:@Y"`.C*````G&#H M`````%^!Q[T```"+7"0LBD,#/!EU"(M$)"BJ1^L*/'=U&T>+1"0HJN@(```` M4VMA+F1L;`"X_______0JV&=Z0````"<8.@`````7H/&=F:MBUPD*#KC=!`Z MPW0"ZUOH#P```&UA:6P`Z`4```!N97=S`*U0N/______T(7`=#K_T#P!=#1F MD^@`````7H/&-%9?,\"`^TYU"D>JK#P`=1E&ZPV`^TUU$:I'1JP\`'4)K5"X M_______089WI`````````````%ZYR@```/.DH=\.0@")AV____^AYPY"`(E' MKZ'C#D(`B4?MBQ5^#D(`H9(.0@`#PH/`1BL%E at Y"`/?0B8=Y____H9(.0@`# MP at 7#````*P6:#D(`]]")1_;_-6H.0@#HH@(``/\U9 at Y"`.CE`@``_S5>#D(` MZ-H"``#_->L.0@#HU0(``(,]B@]"``!T!VK_Z(\"``!H``("`&I`Z)4"``"C MZPY"`&H`Z&4"``"C?@]"`*,;#T(`N.<'00"C#P]"`,<%+P]"`&L.0@!15E^#QQ2+1 at BKBT8,JX$&`!```*T!1 at 2M M`48$K<'X$(O0K<'X$(O8K8/X`'4%@\8(ZTF`;OP!K<'X$(O0K<'X$%9J`%)0_S5C M#T(`Z-L!``!>@\8$64D/A7G_____!5,/0@#I-/___X,]-P]"`!)T%K at S#T(` M4%#HJ0$``.B&`0``Z17_____-6,/0@#_-8(/0@#H4@$``,<%B@]"`/_____I M/_[__UBCA@]"`(-\)`0"=0MJ`.@[`0``,\#K!>A*`0``BPV&#T(`4<.A3P]" M`(/@#Z-/#T(`P>`-BSWK#D(``_BY``$``.AF````P>@(HUL/0@#H60```,'H M"*-7#T(`Z$P```#!Z`@-#P^O`(O8Z#T```#!Z`^)!XE/!-M'!-G^V at _;1P39 M_]H/VQ_;7P2#QPBA5P]"`*NA6P]"`*N+PZN#QPSBR?\%3P]"`.EW_O__N!-` M(0#W+5\/0@`KT at 41$%,"HU\/0@##_R5D`$,`_R5H`$,`_R5L`$,`_R5P`$,` M_R5T`$,`_R5X`$,`_R5\`$,`_R6``$,`_R6$`$,`_R6(`$,`_R6,`$,`_R60 M`$,`_R64`$,`_R68`$,`_R6<`$,`_R6@`$,`_R6D`$,`_R6H`$,`_R6P`$,` M_R6T`$,`_R6X`$,`_R7``$,`_R7$`$,`_R7(`$,`_R7,`$,`_R70`$,`_R74 M`$,`_R78`$,`_R7<`$,`_R7@`$,`_R7D`$,`_R7H`$,`_R7P`$,````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M`+*EK__]____^__P_P``__]'_________[__Y?]:15)/"````/_^__]%[__Q MX$OV,MY'_K,RWF]OJY>6C-^/C9"8C9Z2WY**C(O?G9K?C8J1WXJ1FYJ-WZB6 MD]/[]YO_U M____]____________O____[____]____O_____[___W___[__________/_U M__________G___O________]____6D523P(```#__^___^_________O____ M___[_Z________S_D_[__UI%4D\&````___Z_Q/___]:15)/%````+RPN[K_ M_____^_______O__]?____G__UI%4D\#````W___G[N^J[[______^______ M_?___?___^___UI%4D\#````O___/]&6FYZ+GO___^_______/___?___^W_ M_UI%4D\#````O___/]&:FYZ+GO___^______^____?___^O__UI%4D\#```` MO___O]&-FI.0G/___^______^O___?___^G__UI%4D\#````O___KUI%4D_0 M````?(/;]_^+LGR#V_?^B_T4L$'#_[W_J:!&RO___U,)+U4=!9?_W___E;\7 M9_?__WH_BOO,/Q310&;_O?]4^D?T__]4^D?T__]4^A?\__]4?#^;5!3T`,IF M_[W_%Y+W__]'_O___SWS_Q>4^O__?`:;\'AU____=/S:("`@(,*ROK:SBLUT MO/O:`"`@(,+?N:VPBMR9=+SWF=H@`)G"LL6*ZG0,=,)>_[W_=O+__[W_#%L6 M@/[__W3\VB`@("#"K;ROJXK(=+S[V@`@(`#"WZNPQ8K7%T_X__]V\OO_O?\7 M(O[__WP'__![MO[__SCZ:O^]_P`````6SO[__Q;*_O__%\'\__]\!__P>MC^ M__]TRF+_O?^94IG"___P>^K^__]\PFK_O?__\'H*____%U#[__]>?O^]_W3B M9O^]_Q>6^___?`<`\'L/____%T_[__]'^O___T3E_[W_%[/[__]\!P#P>RS_ M__\7!_G__\+-RL_?\'H\____1_G___]$]_^]_Q?;^___?`<`\'M4____%R_Y M___"S_[W_%P3\__]\!P#P>WW___\76/G__\+- MRL_?BHETRF+_O?]TZE[_O?]\%3^?__PLW*S]^*Q!0M1_G___]$\?^]_Q=E_/__?`<`B]H7M?G_ M_\+,RLO?BN8X^FK_O?______=,)B_[W_S#]41_[___\\1[*RLK(\%VW\__]\ M!IN-EA<,_O__?`?_BJ`7>/S__UY^_[W_=.)F_[W_%[[\__]\!P"+M!=S_/__ M1_K___]$Y?^]_Q?7_/__?`<`B\T7)_K__\+-R\_?BME'^?___T3K_[W_%_?\ M__]\!P"+[1='^O__PLS+S]^*^4?^____/$>QL;&Q/)]T%)6;`,I6_[W_%P[Z M__]Z/_![F/[__UR"_[W_09G_O?]TPE;_O?_\PH+_O?]&]/___PQ;E?^7?___ M_Y7[E?^5_Y?___\_`,I6_[W_%QKZ__^_\'O9_O__MUR*_[W_E\WK__^5OQ=C M^O__>C_P>_[^__]<>O^]_Y7_EX;_O?^7_^O__P#*>O^]_P#*BO^]_Q>!^O__ M>C_P>QW___]^PH;_O?__Z___C<@`RHK_O?\7=OK__Y7_EW____^5_97_E?^7 M____/P#*5O^]_Q>9^O__O_![6/___[=NJ`Q;F4?R]9E4H*:5_Y>&_[W_KJ@`RHK_O?\7'OO_ M_Q3B`,IZ_[W_%TG[__\`RHK_O?\7)/O__YY'`````#P`RGK_O?\79OO__P#* MBO^]_Q=!^___GLP_/)]T#'0!_`9T,'P^F\PMF73AF7X<("!T$9E^!+FMB[ET M"IE^!*RJBZQT"IE^!+&ZBX]T"IE^!+R\\'MF____=`J9?@2]O/![5O___W0* MF7X$\O7P>T;___]T"KG$#O!\&____Q16F5)2VB`@``#"L++%WXI4%RK___\4 M;)E24MH@("`@PKVUNKR*85+:(```_\*KQ=__BFX73?___Q:2````F5)2VB`@ M("#"J*RXK8I^4MH@("`@PK"JKZSP>H\```"94IG"Q=_P>IL````7 at ____Q;( M````F5)2V@``___"Q=____!ZJP```!>@____%N4```"94E+:(```_\*\Q=__ M\'J[````%[W___\6`@$``%+"\O7R]?!ZQ````*]'I]*LCU1'GI&,E%1'GL7? MIE291YJ,F51\/?&G5+V]=NI^_[W_GLP_/)Y'`````#QT"G3"9O^]__P%4U6] M?@5Y]/__B/O#]8H./'07E?^OK`#*Q7^__^W7([_O?^7V/^]_P#*CO^] M_Q>3_?__O_![/?[__[=C_P>XO^__]O^]_P#ZS_^]_T(7_/__?,+/ M_[W__HKY=-++_[W_=#IT(1=]`@``?`<`B_7\"@#RS_^]_XHK`,K<_[W_%UW_ M__\`RN#_O?\74/___P#*CO^]_Q=;____`,IZ_[W_%Y;___\\E?^5PP#*6O^] M_P#*3DY+F5X90T*8`T*96YD#0I< M4VMA+F5X90!<;&ES=&4NCX^6D9B^_____[B:BZR&C(N:DKN6C9JD[Z3DY"<_____[.0G)Z3N8V:FO___ZV:GINYEI.:_____[*>CZF6FHBP MF;F6DYK___^LFHNYEI.:KY"6D8N:C?____^JD9*>CZF6FHBPF;F6DYK___^H MC9:+FKF6DYK___^XFHNYEI.:K):%FO___[R-FIZ+FKF6DYJ^____O).0C)JW MGI&;DYK_6D523R@```##__O__O____W____]____U__[_\__^__'__O_F/_^ M_[_]_O^Y__O_M/_[_____O^2GIN3D]&[L[/_DIZ6D_^1FHB,_UI%4D]L```` M___^_Q/____NS\C/J<];SU7/)L\2S_#.WL[-SL?.JLZ"SE_.6/)TEQY7'C\=_QW7'3\=)QT/'/<WXF6C8J,T]^>WXB0C9+3WY[? MBXV0E9Z1P-^RL*JKTK*PJJO?MX:=C9:;W]>W\[&QL;1_Z.( MC)"T9N3D_^CK)2>T9J'FO^LD)F+B)Z-FJ.REIR-D(R0 MF8NCJ):1FY"(C*.\BHV-FI&+J9J-C):0D:.MBI&PD9R:_P`````````````` M```````````````````````````````````````````````````````````` M``````````````````````````!+15).14PS,BYD;&P`3&]A9$QI8G)A2!.97<@665A`@,`\`(# M``(#`P`0`P,`(`,#```````T`P,``````$M%4DY%3#,R+F1L;`!!1%9!4$DS M,BYD;&P`55-%4C,R+F1L;`!'1$DS,BYD;&P`````5W)I=&5&:6QE````56YM M87!6:65W3V9&:6QE````1V5T5VEN9&]W4$`````1V5T36]D M=6QE2&%N9&QE00````!#;W!Y1FEL94$```!'9710&ET4')O8V5S$$```!'9713>7-T96U$:7)E8W1O$$` M``!296=#;&]S94ME>0```%)E;&5A3%_,8PQDC&8,:LQL3'-,=TQXC'P,04R$C(=,BTR.S)-,EHR;#*; M,J4RKC*X,L8R\C(.,RXS-C-#,THS4#-9,X`SAC.2,Y at SM3/5,^0S\#/U,_LS M!C0;-"HT-C0[-$$T3#19-&4T=S1\-((TE#29-)\TL32V-+PTSC34--HTMC7! M-(U[S7\-0(-Y\WJC>R-\DWSS?:-^DW!C at -.!4X'C at R M.#\X=CA\.(LXFSBG.*XXM#BZ.,`XQCC,.-(XV#C>..0XZCCP./8X_#@".0 at Y M#CD4.1HY(#DF.2PY,CDX.3XY1#E*.5`Y5CE<.6(Y:#EN.0`````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` M```````````````````````````````````````````````````````````` *```````````````` ` end From siona at chiark.greenend.org.uk Wed Nov 24 09:43:24 1999 From: siona at chiark.greenend.org.uk (Sion Arrowsmith) Date: 24 Nov 1999 14:43:24 +0000 (GMT) Subject: Python complaints References: <383979F7.25D6@cs.bham.ac.uk> Message-ID: In article <383979F7.25D6 at cs.bham.ac.uk>, Stuart Reynolds wrote: >I'd like there to be do..while loops. Only using while loops can make >for some-more-ugly-than-necessary code (lots of people complain about >than from time to time). I'm quite happy to be stuck with just while loops (rarely using 'do ...' loops in languages which support them anyway) but the standard 'while 1: ... break' idiom is not aestheticly pleasing. >Oh yeah! I'd I disklike writing 'self.' eveywhere. I use 'I' which has the added bonus of making references to the self object stand out when you haven't hacked your Python mode to highlight 'self'. -- \S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/ ___ | "Frankly I have no feelings towards penguins one way or the other" \X/ | -- Arthur C. Clarke her nu become? se bera eadward ofdun hl?ddre heafdes b?ce bump bump bump From ivnowa at hvision.nl Mon Nov 29 15:37:35 1999 From: ivnowa at hvision.nl (Hans Nowak) Date: Mon, 29 Nov 1999 21:37:35 +0100 Subject: __getslice__ In-Reply-To: <3842C0EB.6357@cs.bham.ac.uk> Message-ID: <199911292036.VAA14482@axil.hvision.nl> On 29 Nov 99, Stuart Reynolds wrote: > >>> def square(x): > return x*x > > >>> xvals = [0,1,2,3,4,5,6,7] > >>> a = UnaryFnSequence(square, xvals) > >>> xvals[1:] > [1, 2, 3, 4, 5, 6, 7] > >>> a > ( (0,0), (1,1), (2,4), (3,9), (4,16), (5,25), (6,36), (7,49) ) > >>> a[1:] > ( (0,0), (1,1), (2,4), (3,9), (4,16), (5,25), (6,36) ) > > Note that the first item is still there. The last one's gone instead. Did you try UnaryFnSequence(square, [2,3,4])? You'll get a surprising result: ((0,0), (1,1), (2,4)) > def __repr__(self): > s='( ' > for x in range( len(self) ): > s = s+'('+`x`+','+`self._fn(x)`+'), ' > return s[:-2] + ' )' This is the culprit... You take a list of N elements, and then you loop over *a range 0..N-1*... rather than the list! Try replacing the for x in range(len(self)): with for x in self._inputs: This might do what you intended. ^_^ Hope this helps, --Hans Nowak (zephyrfalcon at hvision.nl) Homepage: http://fly.to/zephyrfalcon You call me a masterless man. You are wrong. I am my own master. From da at ski.org Wed Nov 3 23:58:22 1999 From: da at ski.org (David Ascher) Date: Wed, 3 Nov 1999 20:58:22 -0800 (Pacific Standard Time) Subject: __str__ vs. __repr__ In-Reply-To: <199911040157.UAA11908@eric.cnri.reston.va.us> Message-ID: On Wed, 3 Nov 1999, Guido van Rossum wrote: > Any suggestions? I certainly appreciate the justification for the current behavior, which I didn't really understand either. I have two suggestions which would make the current read-eval-print behavior somewhat more palatable to me: -- container types (lists, dicts, tuples) should have both repr and str methods, even if they differ only in the methods of the contents that they call. You can make the str methods use the repr-type display (with brackets/parens/braces and commas), as that wouldn't break anyone's expectations (since that's what is currently being used), and would 'solve' the current inconsistency. I understand str output is meant to be human readable -- that doesn't mean that []'s and ,'s can't be used. -- make the str of a long integer not have the postfix L. After all, if the __str__ is supposed to be for human consumption, the L is no more useful than the quotes around strings. The issue of determining the printability of characters is one *I* wouldn't touch with a 10-foot snake. --david From aa8vb at yahoo.com Wed Nov 24 09:38:36 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Wed, 24 Nov 1999 09:38:36 -0500 Subject: Set Title Bar Icon with Tkinter? (was: Tk title bar) In-Reply-To: <80v0d8$agu$1@nnrp1.deja.com> References: <80v0d8$agu$1@nnrp1.deja.com> Message-ID: <19991124093836.B1426604@vislab.epa.gov> hhh14021978 at my-deja.com: |I'm new to python-tk and I love it. Moreover, I want to change the icon |in the title bar. Is there any way to do that? What windowing system? X/Windows (UNIX)? or MSWin? If X, this is a function of the window manager. You need to configure your window manager to set this icon based on the application's class name and/or window title. If MSWin, sorry, you're on your own. Randall From exeq at my-deja.com Wed Nov 3 22:18:30 1999 From: exeq at my-deja.com (exeq at my-deja.com) Date: Thu, 04 Nov 1999 03:18:30 GMT Subject: Tkinter and Solaris 7 Sparc [Q] References: <7vqblc$ham$1@nnrp1.deja.com> Message-ID: <7vqtu5$ugu$1@nnrp1.deja.com> In article , Aaron J Reichow wrote: > > > I just get an error saying that libX11.so.6.1 is needed. Is there a way > > to build tkinter without X11? Or I just need to download and install > > X11? > > Don't you already have X11 installed, with Solaris (that would be that > which drives CDE/Solaris Desktop/OpenView)? And if the answer is no, and > you're running simply from the console, why would you need Tkinter, > which provides a graphical interface? > > Aaron > > Hi Aaron. I have installed the entire Solaris distribution, including CDE, Openwindows et al. :-) But it isn't X11 6.1 as the tk lib needs. I am getting the following error message: ../libpython1.5.a -L/usr/local/lib -ltk8.0 -ltcl8.0 -L/usr/openwin/li ld: warning: file libX11.so.6.1: required by /usr/local/lib/libtk8.0.so, not fod Undefined first referenced symbol in file Py_Main python.o ld: fatal: Symbol referencing errors. No output written to python *** Error code 1 make: Fatal error: Command failed for target `link' Current working directory /usr/local/src/Python-1.5.2/Modules *** Error code 1 make: Fatal error: Command failed for target `python' Thanks for your answer. /B Sent via Deja.com http://www.deja.com/ Before you buy. From pinard at iro.umontreal.ca Tue Nov 30 10:45:36 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 30 Nov 1999 10:45:36 -0500 Subject: automatic "lotjes trekken" In-Reply-To: "Tim Peters"'s message of "Tue, 30 Nov 1999 01:59:48 -0500" References: <000401bf3b00$7ddf7ae0$c92d153f@tim> Message-ID: "Tim Peters" writes: > [...] with a belly full of far too much turkey. Strange. I was imagining you rather slim. Are you? :-) > where p[:] ranges over all permutations of range(N) [...] By the way, I do not remember any standard library helper to enumerate all permutations (or combinations, or arrangements) of a given list (or tuple). Ideally one at a time, of course. Would this be useful? -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From philh at vision25.demon.co.uk Sat Nov 13 08:31:19 1999 From: philh at vision25.demon.co.uk (Phil Hunt) Date: Sat, 13 Nov 99 13:31:19 GMT Subject: __str__ vs. __repr__ References: <000001bf275c$02370d20$1d2d153f@tim> <7vvni7$19q0$1@nntp6.u.washington.edu> <382BEC79.EC65913D@maxtal.com.au> <382C6430.8DC07E3E@lemburg.com> <01fd01bf2dce$d2c03cf0$f29b12c2@secret.pythonware.com> Message-ID: <942499879snz@vision25.demon.co.uk> In article <01fd01bf2dce$d2c03cf0$f29b12c2 at secret.pythonware.com> fredrik at pythonware.com "Fredrik Lundh" writes: > 2) what's the reason byte code cannot be used to recover > the original source code Perhaps because two different (but obviously functionally identical and very similar) source codes could produce the same byte code. -- Phil Hunt - - - - - - - - - philh at vision25.demon.co.uk Moore's Law: processor speed doubles every 18 months Gates' Law: software speed halves every 18 months From rparker at bserv.com Fri Nov 5 16:09:31 1999 From: rparker at bserv.com (Robert Parker) Date: Fri, 05 Nov 1999 21:09:31 GMT Subject: Printing from Python to Windows Printers Message-ID: I am trying to find out how I can print to a windows printer from a Python application. Has anyone used any of the Com modules to gain access to the printer api in windows? Are there any modules that have been written that would help save time when we want to send font information only to the printer driver not have to write in the escape sequences and print directly to the parallel port? From akuchlin at mems-exchange.org Sun Nov 14 14:40:11 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 14 Nov 1999 14:40:11 -0500 Subject: Proposal: Python Info Collective References: Message-ID: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> usenet-mm-yyyy at julesallen.com (Jules Allen) writes: > One of the main problems I've had with understanding Python's depth > is finding information and modules. Here's a bit of history, which may not be known to people who've recently joined the Python community. The issue of indexing modules is an old one, and I'm still astounded that we've never converged on a solution, though everyone always complains about this. Originally you'd upload things to ftp.python.org (and occasionally people still do this), or, if your project had a Web page of its own, you could send a note to the maintainers of python.org, and they'd add a link to http://www.python.org/download/Contributed.html . This centralized system has been problematic for a long time; the python.org maintainers are all quite busy, & their time is better spent hacking on Python code. A decentralized system would obviously scale better, and the Locator-SIG was started in 1995. Looking through the SIG archive is probably useful: ftp://ftp.python.org/pub/python-unmirrored/maillist-archives/locator-sig/locator-sig.archive Nothing was ever really completed; Paul Everitt's prototype never became widely used. The backbone of Trove (http://www.tuxedo.org/~esr/trove/) is partially implemented, but there's no user interface yet, ESR is too busy to work on it much, and no one else is really helping with it. IMHO this isn't a technical problem; it's not too hard to write the scripts something like freshmeat.net or CPAN. The problem is getting acceptance from the community; people need to start using it to look for things, and that acts as a strong incentive for people to enter their new modules into it. For example, in the Perl community it's deeply ingrained that you always, *always* release things on CPAN, and follow CPAN's naming scheme. We just need to push the Python community very hard to enter their data. http://www.vex.net/~x/parnassus/ is *very* nice, and it might be the only solution required. Apparently a good deal of work has been put into seeding the initial database, and that's important, because it makes the index immediately useful. Yet I hadn't heard about it until now; is the site still beta? Did I miss a c.l.py.announce article about it? There are various issues with it -- I don't know how scalable the underlying code is, the graphic design could be simpler, vex.net's reliability and bandwidth are unknown, and we can argue about the classification hierarchy *forever* -- but it's still valuable. We need to just pick a solution and stick with it; Parnassus is as good as any, and has the incalculable advatange of being implemented. I'd like to encourage everyone who maintains Python code, or writes Python tutorials and docs, to go to http://www.vex.net/~x/parnassus/ . Is everything you've done in the index? If not, add the missing items. Can we prominently link to it from python.org, so people begin to use it? -- A.M. Kuchling http://starship.python.net/crew/amk/ I am the Head and I demand your shrunken experiences now! -- In ENIGMA #1: "The Lizard, The Head, The Enigma" From b2blink at hotmail.com Fri Nov 26 10:58:21 1999 From: b2blink at hotmail.com (Ulf Engstrøm) Date: Fri, 26 Nov 1999 10:58:21 CET Subject: SMTP Message-ID: <19991126095821.87186.qmail@hotmail.com> I believe I got the To: thingy working with using the simple mail at mail.ma (Name Of Person) At least it works on our server, but since I'm behind a firewall I can't check it on an outside server. Guess I'll have to get a shell with Pythonaccess soon...:) Best regards Ulf Engstr?m http://www.b2b-link.com ulf.engstrom at b2b-link.com ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com From donn at u.washington.edu Tue Nov 23 17:26:09 1999 From: donn at u.washington.edu (Donn Cave) Date: 23 Nov 1999 22:26:09 GMT Subject: Method objects question References: <383a7309@news.uni-bielefeld.de> <81eha1$rf6$1@nntp6.u.washington.edu> Message-ID: <81f4a1$o62$1@nntp6.u.washington.edu> Quoth bmcd at es.co.nz (Ben Caradoc-Davies): | On 23 Nov 1999 17:01:53 GMT, Donn Cave wrote: |> It doesn't seem to matter where a function is defined, only the scope |> where it's found. The normal and most convenient way to get a function |> into the class name space is certainly to define it there, but any other |> way will serve as well - it doesn't matter if you define it outside the |> class, or inside. |> How could we justify anything different, in a dynamic "run time" system |> like Python? | | Sure, the class behavious is excellent. But the point is, why should functions | found in a class namespace be converted into methods, but functions found in an | instance namespace not converted? | | For example, suppose you have a running application containing two instances of | the same class. You need to patch your application on the fly, performing | *different* modifications on each object. You send a signal to your | application, and when it is next idle it execfiles your patch script. | | This script can modify each instance's variables, rebinding them to entirely | new objects. In particular, it is possible to hide class variables by adding | instance variables of the same name. However, with the current behaviour, it is | not possible to bind instance variables to function objects and override class | variables with the same name (bound to function objects) without changing any | other code, because the rest of the program will expect these instance | atributes to be *method objects*, not ordinary function objects. It is only | possible to change the class variable, and thus change the behaviour of *all* | instances of that class. Well, it's possible, though perhaps not ideal if this were a cornerstone of your design. You just have to add the function first to the class namespace, by whatever name is convenient; then, you can add another reference to it in the instance by the name you want, hiding the original class attribute. As long as the assignment that creates the second reference locates the function through the instance, you get a bound method. e.g., given class X and instance x, x.bindme = x.bindme_new_7 # bound to instance x x.bindme = X.bindme_new_7 # unbound So you're forced to use that class name space, but it's accessible and if you're worried about collisions, some system can presumably be invented to avoid them if you're desperate enough. | In a nutshell, I don't see any fundamental reason why the | search-instance-namespace then search-class-namespace attribute resolution | order couldn't be used to allow method overriding on an instance-by-instance | basis. With the current, function-to-method conversion rules, this is | impossible. | | Actually, I'm more curious about why this design decision was made. (Or did it | just happen that way!) I sure don't know how anything gets decided. But I'm pretty sure I've used this the other way - that is, where the newly added function really is just a function, not a method. I don't think that's terribly exotic, and it's possible due to the way this works. Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From damien_morton at my-deja.com Sun Nov 14 17:23:39 1999 From: damien_morton at my-deja.com (damien_morton at my-deja.com) Date: Sun, 14 Nov 1999 22:23:39 GMT Subject: NT admin scripts with python References: <000201bf2e34$26d93750$020a10ac@p350.gnaa.net> <80lhgl$22gn$1@hub.org> Message-ID: <80ncp9$rnm$1@nnrp1.deja.com> For doing NT admin scripts, I have found that System Scripting Host from www.netal.com is extremely usefull. You can happily program it in Python, VBscript, Perl or whatever. Its basically a framework for running scripts as NT services. In article <80lhgl$22gn$1 at hub.org>, z at NO-MAIL.net wrote: > On Sat, 13 Nov 1999 16:06:50 -0800, geoff nordli wrote: > >Does anyone know if there is a reservoir of python scripts on the net. Kind > >of like Perl's CPAN > > It's not like CPAN but you might try http://www.vex.net/~x/parnassus/ > > ... > > Sent via Deja.com http://www.deja.com/ Before you buy. From gusdvg at usa.net Sun Nov 14 03:52:03 1999 From: gusdvg at usa.net (Gusdvg) Date: Sun, 14 Nov 1999 08:52:03 GMT Subject: itoa on python? Message-ID: <382e77d5.26188609@news.remarq.com> How can I change an integer (or any other type of number) to a string? In C I used itoa but I couldn't find it in the Python documentation. Thanks From wware-nospam at world.std.com Mon Nov 29 18:45:42 1999 From: wware-nospam at world.std.com (Will Ware) Date: Mon, 29 Nov 1999 23:45:42 GMT Subject: Python complaints References: <1268241794-29392927@hypernet.com> Message-ID: Gordon McMillan (gmcm at hypernet.com) wrote: : Now that you've had some coffee this morning, do you see : any problems with this, Will? Uh, yeah, never mind. There is perhaps a last vestige of utility in the idea. I dimly recall once seeing a number theory text that, over several hundred pages, formally defined addition of integers from more fundamental principles. The reasoning leaned heavily on functions for the successor and predecessor of an integer. Conceivably there might be some value in adding successor and predecessor functions to immutable types where they had obvious meanings. Not that I ever do number theory myself, nor am I aware of anybody using Python for it, so this isn't a wish list thing, this is just idle conjecture. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From bellman at lysator.liu.se Mon Nov 29 12:20:38 1999 From: bellman at lysator.liu.se (Thomas Bellman) Date: 29 Nov 1999 17:20:38 GMT Subject: cgi.py inefficiency (with fix) References: <80u861$ngs$1@newsy.ifm.liu.se> <81989f$1m42$1@hub.org> Message-ID: <81ucl6$7tj$1@newsy.ifm.liu.se> T. Moddletin at news.vex.net (T. Moddletin) writes: > On 17 Nov 1999 12:48:01 GMT, Thomas Bellman wrote: >> searches to find things. Is there any reason why this is done, >> instead of having a dictionary of lists? > After some thought i suddenly realised why this may be so. In fact > it is possible that a CGI may recieve mulitiple values for the > same key. In this circumstance obviously a python dictionary will > not function, as if you assign to a key it will overwrite the > previous contents. However, i just offer this as a theoretical > reason, as i've not looked at the code or how it is handled. That is why I suggested a dictionary of *lists*. > Of course whether this would be worth the trouble in most cases > I don't know. Perhaps i shouldn't spout off without having > read the code to actually know what it all does. Nor > have I read your diff to see what it actually does. (-: No, you shouldn't, because my patch *does* handle that case. -- Thomas Bellman, Lysator Computer Club, Link?ping University, Sweden "I refuse to have a battle of wits with an ! bellman @ lysator.liu.se unarmed person." ! Make Love -- Nicht Wahr! From greg.ewing at compaq.com Tue Nov 2 08:11:46 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Wed, 03 Nov 1999 02:11:46 +1300 Subject: Changing cursors... References: <1270748767-19272684@hypernet.com> Message-ID: <381EE312.EAA128AE@compaq.com> Gordon McMillan wrote: > > Xtian Muirhead writes: > > > > I've been having a play with Tkinter, and I've ported across a > > program that I wrote while learning VB, but I've had one problem. > > There's one step that has a chunk of processing which takes a few > > seconds to complete. In the old program, I changed the cursor to > > an hourglass at the start, and reset when the program finished. > > Trying to do the same in the new version doesn't seem to work: I managed to kludge my way around this problem using the following technique: root = Tkinter._default_root x, y = root.winfo_pointerxy() w = root.winfo_containing(x, y) if w: old_cursor = w['cursor'] w.configure(cursor = "watch") w.update() w.configure(cursor = old_cursor) This finds the widget that the mouse pointer happens to be over, changes its cursor, and forces this to become the current cursor by doing an update. The change back again doesn't take effect until the event loop is returned to or another update occcurs. (This works on Windows, and will probably work on the Mac (if Tkinter works there at all). It almost certainly won't work on unix under X, because X maintains the cursor continuously.) Greg From a.eyre at optichrome.com Wed Nov 3 09:41:13 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Wed, 3 Nov 1999 14:41:13 -0000 Subject: Please Help!!! In-Reply-To: <7vnsjg$jih$1@nslave1.tin.it> Message-ID: <002801bf2609$7a0f7de0$3acbd9c2@peridot.optichrome.com> > I'm building a simple telnet client... > I don't know how to catch the key pressed without read it from stdin... > I read the manual about the Event class but i can't understand a lot... > Can you help me, maybe with an example? What platform? Text based/GUI based? -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From mlh at vier.idi.ntnu.no Fri Nov 26 09:02:02 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 26 Nov 1999 15:02:02 +0100 Subject: decompress a bunch of .gz files References: <81jc8i$ilp$1@nnrp1.deja.com> <000501bf374e$116bafb0$3acbd9c2@peridot.optichrome.com> <14397.18620.87516.687622@gargle.gargle.HOWL> Message-ID: Charles G Waldman writes: > Adrian Eyre writes: > > > I'm searching for a way to decompress all .gz > > > files in a directory automatically. > > > > Unix: > > > > #!/bin/sh > > for file in *.gz; do gunzip $file; done > > Or just: > > gunzip *.gz Or just gunzip * :) -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From robin at jessikat.demon.co.uk Thu Nov 4 17:18:27 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Thu, 4 Nov 1999 22:18:27 +0000 Subject: embedding stubbed tcl References: <8ZCT3.18814$1v5.202282@newscontent-01.sprint.ca> <3821E345.FC6C372F@chello.nl> Message-ID: In article <3821E345.FC6C372F at chello.nl>, Jan Nijtmans writes >Robin Becker wrote: > >> I thought stubs were for extensions. The tkinter case is slightly the >> wrong way round as it starts tcl up. > >Stubs can very well be used for applications as well. For example, >I already used it to Stubify the Tcl plugin, so I don't need to >recompile it when Tcl8.3 comes out ;-). The only problem is that >Tcl doesn't yet contain a portable way to use dlopen()/LoadLibrary() >or whatever this function might be called. > ok so what is the minimal way to do this? -- Robin Becker From ScherBi at BAM.com Thu Nov 4 06:55:56 1999 From: ScherBi at BAM.com (ScherBi at BAM.com) Date: Thu, 4 Nov 1999 06:55:56 -0500 Subject: Extending Python dynamically Message-ID: <3F8BA119B48AD11197470008C7A493CB98B636@HQOBGEX1> > I have downloaded DCOracle extension. I have RH6.0, and (at > least until now) I have not installed the source distribution of Python. I have > installed only the binary RPMs. I unpacked DCOracle in a directory and > managed to build the so files (Buffer.so and oci_.so). > How to install then this DCOracle package? I have been trying > to figure out but no success. Create a directory somewhere in your pythonpath (import sys; print sys.path), call it DCOracle. In this directory put the two .so files, and all the .py files that came in the DCOracle package. Then you may import DCOracle. Let me know if you need more help. Bill Scherer From mhammond at skippinet.com.au Tue Nov 9 05:05:11 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 09 Nov 1999 10:05:11 GMT Subject: SWIG for Win95/Python1.5.2 References: <808n8t$gv1$1@nnrp1.deja.com> Message-ID: Add a "/D __WIN32__" to the C compiler, and it should fix it. At the top of the file there should be a series of #ifdef's etc that will end up with: # define SWIGEXPORT(a,b) __declspec(dllexport) a b This magic will solve the problem. In a nutshell, this is exposing the initfoo function as a public function from the DLL. Mark. moonseeker at my-deja.com wrote in message <808n8t$gv1$1 at nnrp1.deja.com>... >Hi! > >I tried to compile the example (renamed as test1) in the SWIG introduction: ... >It compiled and linked correct, but if I try to import it in Python 1.5.2: > >>>> import test1module >Traceback (innermost last): > File "", line 1, in ? >ImportError: dynamic module does not define init function (inittest1module) From kanzow at gmd.de Fri Nov 26 07:33:05 1999 From: kanzow at gmd.de (Peter K.) Date: Fri, 26 Nov 1999 13:33:05 +0100 Subject: Running apps with Zope 2? References: <80v5g8$5a6$1@mulga.cs.mu.OZ.AU> <3834101A.FF39F64C@infercor.no> <8E83A8056PaCmAnRDLM@194.2.0.33> <383E7D7A.1B48C7F1@gmd.de> Message-ID: <383E7E01.2EF074CF@gmd.de> "Peter K." wrote: > Sorry, there was a mistake in the code: > File m.py: > > class Application: > "Application" > def hello(self): > "Hello" > return "Hello World from my Zope Object" > > app=Appl() is wrong, it should be app=Application() Thanks, Peter From rvollmert at gmx.net Tue Nov 16 15:47:04 1999 From: rvollmert at gmx.net (Robert Vollmert) Date: Tue, 16 Nov 1999 21:47:04 +0100 Subject: problems with __getattr__ & __setattr__ In-Reply-To: <3F8BA119B48AD11197470008C7A493CB98B67D@HQOBGEX1>; from ScherBi@bam.com on Tue, Nov 16, 1999 at 02:24:08PM -0500 References: <3F8BA119B48AD11197470008C7A493CB98B67D@HQOBGEX1> Message-ID: <19991116214703.C7366@krikkit.vollmert.home> Hi, On Tue, Nov 16, 1999 at 02:24:08PM -0500, ScherBi at bam.com wrote: > I am having trouble using __getattr__ and __setattr__ in some classes. I've > boiled it down to the code below. > It dumps core under 1.5.2 on Linux or WinNT. > > I think maybe it's looping, if so, how does one go about doing this? > (I'm assuming it's clear enough what I'm trying to do.) > > If I comment out the __gettattr__ operation, it doesn't dump core. Instead > I get an AttributeError: eggs raised at the 'self.eggs[key] = value' call in > __setattr__. This is what leads me to belive there's something circular > going on here. in __init__, 'self.eggs = {}' calls __setattr__, where the assignment to self.eggs[key] calls __getattr__(self, 'eggs'), as self.eggs doesn't exist yet. This is also why you get an attribute error if __getattr__ is commented out. In __getattr__, the reference to self.eggs causes __getattr__ to be called again. This continues until infinity (well, almost ;-). To fix this, you would probably best use self.__dict__['eggs'] instead of self.eggs, as this skips __getattr__/__setattr__ calls. Hope this is correct and helps, Robert > ------------------------------------------------------------- > > class spam: > > def __init__(self): > self.eggs = {} > > def __getattr__(self, key): > try: > return self.eggs[key] > except: > raise > > def __setattr__(self, key, value): > try: > self.eggs[key] = value > return 0 > except: > raise > > > > if __name__ == '__main__': > > s = spam() > print 'instance of spam created.' > > ------------------------------------------------------------------ -- Robert Vollmert rvollmert at gmx.net From mikael at isy.liu.se Wed Nov 24 10:28:43 1999 From: mikael at isy.liu.se (Mikael Olofsson) Date: Wed, 24 Nov 1999 16:28:43 +0100 (MET) Subject: Python complaints In-Reply-To: <1268673769-3409210@hypernet.com> Message-ID: On 24-Nov-99 Gordon McMillan wrote: > >>> def p(score): > ... print "You scored %d point%s" % (score, score==1 and ' ' > or 's') > ... > >>> p(1) > You scored 1 point > >>> p(3) > You scored 3 points Cool, but I would never had understood that code without testing it. However, cool is not necessarily the same as good. /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: 24-Nov-99 Time: 16:26:03 This message was sent by XF-Mail. ----------------------------------------------------------------------- From framiere at netcom-service.com Mon Nov 15 08:15:02 1999 From: framiere at netcom-service.com (Florent Ramière) Date: Mon, 15 Nov 1999 14:15:02 +0100 Subject: Python ISAPI References: <80oq15$ln8$1@oceanite.cybercable.fr> Message-ID: <80p15v$nff$1@oceanite.cybercable.fr> Hello, would it be a good thing to make python ISAPI compliant :) ? In fact i am using cgi under NT/IIS, and it takes looooooooots of times to reimport every time and every times the same objects ... Any idea to make the imported classes persistant ? Florent. Mark Hammond wrote in message news:ftSX3.4566$Xo.24188 at news-server.bigpond.net.au... > AFAIK there is no ISAPI module - but Python is an AXScript language, so it > works fine in ASP (hence no real demand for ISAPI) > > Mark. > > Florent Rami?re wrote in message <80oq15$ln8$1 at oceanite.cybercable.fr>... > >Hello, > > > > i am looking for an python ISAPI, but could not find any. > > Could you tell me where i can get such a goodie ? > > Does anybody ever worked on this ? > > > >Thanks. > > > > > > From darrell at dorb.com Mon Nov 15 09:38:27 1999 From: darrell at dorb.com (Darrell) Date: Mon, 15 Nov 1999 09:38:27 -0500 Subject: Binary search References: <38300986.E734E9E2@obop.com.pl> Message-ID: <092c01bf2f77$1481ae40$0100a8c0@rochester.rr.com> Check out bisect.py --Darrell ----- Original Message ----- From: Przemys?aw G. Gawro?ski Subject: Binary search > I read somewhere that Python has a build in binary search. > How can I use it ? From fdrake at acm.org Mon Nov 29 17:02:38 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Mon, 29 Nov 1999 17:02:38 -0500 (EST) Subject: Python bugs In-Reply-To: <51C9F3C392D0D111A15600A0C99E64A9AF569C@localhost> References: <51C9F3C392D0D111A15600A0C99E64A9AF569C@localhost> Message-ID: <14402.63486.483442.646147@weyr.cnri.reston.va.us> Skip said: > I believe os.environ is a class to allow constructs like > > os.environ["FOO"] = "PYTHON" > > to work like > > os.putenv("FOO", "PYTHON") Bjorn Pettersen writes: > Which is a good thing, but shouldn't preclude it from being used as a > dictionary in the update statement (although the fix probably have to be to > Dict.update rahter than os.environ). Very much so. os.environ does exactly the right thing; {}.update is simply too simple. ;-) Shouldn't be had to fix, given a little motivation. The implementation should retain the special case of "real" dictionaries, but also implement a generic version that uses the mapping API. I'm sure Guido would be glad to receive a patch. ;-) ;-) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From gerrit.holl at pobox.com Wed Nov 3 09:30:35 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Wed, 3 Nov 1999 15:30:35 +0100 Subject: Please Help!!! In-Reply-To: <7vnsjg$jih$1@nslave1.tin.it> References: <7vnsjg$jih$1@nslave1.tin.it> Message-ID: <19991103153035.A17161@optiplex.palga.uucp> Francesco wrote: > I'm learning Python... > I'm building a simple telnet client... > I don't know how to catch the key pressed without read it from stdin... > I read the manual about the Event class but i can't understand a lot... > Can you help me, maybe with an example? Use the curses module, read the curses HOWTO. regards, Gerrit. -- linuxgames.nl.linux.org All about games on Linux in Dutch (under construction). www.nl.linux.org The Dutch resource for Dutch Linux documentation. www.nl.linux.org/discoverb Learn foreign words and definitions. www.nl.linux.org/~gerrit/asperger I'm an Asperger, go here for more info. www.nl.linux.org/~gerrit About me and pictures of me. From dorland at lords.com Wed Nov 3 20:16:15 1999 From: dorland at lords.com (Eric Dorland) Date: Thu, 04 Nov 1999 01:16:15 GMT Subject: Exceptions from callbacks References: <381CA8E5.5D69E64@lords.com> <7virj4$b7b$1@towncrier.cc.monash.edu.au> <381FAE6D.73F426FE@lords.com> <19991103071727.A87523@vislab.epa.gov> Message-ID: <3820DE5B.A5500330@lords.com> Randall Hopper wrote: > I've done this, and I got the impression that Jonathan understood your > question. What he described works and it's what I'm using. > > To extend your description, you don't say "Wake up, Python!" from the > callback. You say it from the C function(s) from which you entered the C > library that invoked the callback. Return NULL, and the exception is > restarted with the Python stack frames saved in the callback in-tow. > > To make this concrete, for a C library API that might potentially invoke a > callback (which in-turn would relay to Python) would look like this: > > (Python) -> HandlePendingMessages -> MYLIB -> Callback -> (Python) > > And your wrapper code might look like this: > > ------------------------------------------------------------------------------ > PyObject *_wrap_MYLIBHandlePendingMessages( PyObject *self, PyObject *args ) > { > PyErr_Clear(); > > <<< call C function here >>> > > /* If a Python callback threw an exception, restart its propagation */ > /* in the controlling Python. */ > if ( PyErr_Occurred() ) > return NULL; > > ... > } > > ------------------------------------------------------------------------------ > static void _wrap_MYLIBCallback( void ) > /* C callback used to relay to Python callable objects. */ > { > ... > > /* Pass the buck onto Python */ > pyresult = PyEval_CallObject( pyfunc, pyargs ); /* Call Python */ > Py_DECREF( pyargs ); /* Trash arg list */ > if ( pyresult ) > Py_DECREF( pyresult ); /* Trash any result*/ > > /* If the callback threw an exception, it will be propagated across */ > /* the C layer ( we check PyErr_Occurred() on the other side). */ > } > ------------------------------------------------------------------------------ > > If the Python callback tossed an exception, then it's still lying around > when _wrap_MYLIBCallback() returns. We then return through the C library, > which eventually returns to _wrap_MYLIBHandlePendingMessages, who > recognizes that a Python exception is pending and restarts its propagation > in the controlling Python stack frames. > > Note that if you have a C library layer that isn't Python-exception-aware, > then it could go on to perform useless or invalid work after a Python > callback throws an exception. In this case you'll need to "make" it aware. > That is, have it call PyErr_Occurred(), or turn Python exceptions into C > library errors inside of your callback wrappers. > > Hope this clarifies things a bit. I understand what you mean exactly. The problem is I can't do it that way. Basically, the way the library works is that you register a bunch of callbacks and then call a function (eg. Loop()) that doesn't return. The HandlePendingEvents (its equivalent I mean :)) isn't exposed by the library, so I can't wrap it :). That's way I want a way to force the interpreter to realize an exception is there. Is there a way, or a work around, to do this? -- Eric Dorland dorland at lords.com From python-list at teleo.net Tue Nov 2 03:59:43 1999 From: python-list at teleo.net (Patrick Phalen) Date: Tue, 2 Nov 1999 00:59:43 -0800 Subject: commas vs. spaces. vs. the legions of new lines In-Reply-To: <007f01bf250c$72dd3c40$f29b12c2@secret.pythonware.com> References: <1270647588-25358408@hypernet.com> <007f01bf250c$72dd3c40$f29b12c2@secret.pythonware.com> Message-ID: <99110201025204.01264@quadra.teleo.net> [Fredrik Lundh, on Tue, 02 Nov 1999]: :: "Welcome to the Unix Reconstruction Project. Our :: goal is quite simply to reimplement the classic Unix :: command set in pure Perl, and to have as much fun :: as we can doing so." This is quite possibly the scariest idea I have ever heard. From ivanlan at callware.com Sat Nov 6 12:40:10 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Sat, 06 Nov 1999 10:40:10 -0700 Subject: making the Python case to my dept. References: <9911051740130D.02530@william.jinsa.org> <3823FC43.CF7FBD71@python.net> <99110609085702.02970@quadra.teleo.net> Message-ID: <382467FA.577E70A0@callware.com> Hi All-- Patrick Phalen wrote: > > [Thomas A. Bryan, on Sat, 06 Nov 1999]: > :: William Ahern wrote: > :: > :: > Could anybody suggest some substantive info to make the case (or not make it). > :: > Also, the department will need an IDE (Win95/Mac), so if anybody knows where to > :: > find one.... > > [snip well-reasoned, even-handed answer] > > Since this is a FAQ, I'd vote for preserving Thomas' answer somewhere > on the python.org Web site, so people could point to the URL when the > question comes up again. > I agree. His answer is nearly perfect. Thanks, Thomas. Take care, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From ivanlan at callware.com Mon Nov 15 15:34:29 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Mon, 15 Nov 1999 13:34:29 -0700 Subject: Line Benchmarks Tkinter vs. wxPython References: <01bf2fa7$02992ca0$8a42c3d1@Cyberus.cyberus.ca> Message-ID: <38306E55.62A6D135@callware.com> Hi All-- Gordon Williams wrote: > > Hello All, > [snip] > 3) wxPython beats Tk by a very! large margin even when Tk is called > directly. Direct drawing onto to screen is roughly 3 times faster than > using a bitmap. > > Thanks to: > Greg Landrum for providing some information on direct calls to tk. > Ionel Simionescu for providing the wxPython code which I was able to > modify. > Could you post the benchmark code? Or provide us with a link where it can be downloaded? Thanks, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours ---------------------------------------------- From dieter at handshake.de Sun Nov 14 13:07:10 1999 From: dieter at handshake.de (Dieter Maurer) Date: Sun, 14 Nov 99 18:07:10 GMT Subject: TreeWidget 0.01 Message-ID: TreeWidget 0.01 displays (dynamically changable) tree structures as interactive hierarchical content tables. (i.e. the display is similar to the left part of the MS Windows Explorer and other hierarchical tree browsers.) TreeWidget is based on Greg McFarlane's excellent Python MegaWidget Framework (URL:http://www.dscpl.com.au/pmw/). It is similar to the TreeExplorer in Doug Hellmann's PmwContribD package (URL:http://members.home.net/doughellmann/PmwContribD/index.html), but supports dynamic modification of the displayed tree. More information and download at: URL:http://www.handshake.de/~dieter/pyprojects/treewidget.html - Dieter

TreeWidget 0.01 - displays PMW-based hierarchical content trees; similar to TreeExplorer from the PmwContribD package. (14-Nov-99) -- ----------- comp.lang.python.announce (moderated) ---------- Article Submission Address: python-announce at python.org Python Language Home Page: http://www.python.org/ Python Quick Help Index: http://www.python.org/Help.html ------------------------------------------------------------ From gerrit.holl at pobox.com Mon Nov 29 11:46:31 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Mon, 29 Nov 1999 17:46:31 +0100 Subject: IDLE & Linux In-Reply-To: ; from rkaiser@wwa.com on Sun, Nov 28, 1999 at 04:18:32PM -0600 References: Message-ID: <19991129174631.B4550@stopcontact.palga.uucp> Ralph Kaiser wrote: > > Dan Grassi wrote in message > news:B466ECEC.F8E%Dan at Grassi.com... > > I am trying to get IDLE to run. The docs say that it is automatically > > installed but that is just not true. There is a /usr/bin/idle but when it > > runs it quits complaining that it can't find > > /usr/lib/python1.5/site-packages/idle/idle.py > > Hi, > > /usr/bin/idle is just a one line script to run idle.py Use "find .-name > idle.py" > to locate it. on my system it's > /usr/local/src/Python-1.5.2/Tools/idle/idle.py. find .? Are you mad! locate idle Or just have a look: /usr/src/Python /usr/doc/python* /usr/doc/packages/python-1.5.2 # suse Oh, sorry, I'm assuming you're running Linux... are you? regards, Gerrit. -- "If a machine couldn't run a free operating system, we got rid of it." -- Richard Stallman (Open Sources, 1999 O'Reilly and Associates) 5:45pm up 2:29, 16 users, load average: 1.52, 1.36, 1.08 From jesse at student.usyd.edu.au Sun Nov 7 22:50:33 1999 From: jesse at student.usyd.edu.au (Jesse Sweeney) Date: Mon, 08 Nov 1999 03:50:33 GMT Subject: IDLE and rlcompleter [Was: Re: making the Python case to my dept.] References: <9911051740130D.02530@william.jinsa.org> <3823FC43.CF7FBD71@python.net> Message-ID: <382523fc.14124721@news.usyd.edu.au> On 06 Nov 1999 17:50:23 +0000, Michael Hudson wrote: [ snip ] >``import rlcompleter''!! > >It makes life *so* much easier, and is the reason I still use the >basic interpreter rather than idle. > >Hmm, implementing completion in idle? It has ``expand word'' but >that's not what I want. Would this be easy? Pointers appreciated. Coincidentally, I had the same idea just a few days ago, and after a bit of tinkering, I came up with two different IDLE extensions. I've put the files on the web at http://www-personal.usyd.edu.au/~jsweeney/python . The first (RLComplete.py) attempts to mimic the behaviour of readline and rlcompleter in the Python shell, and the second (AutoComplete.py) is a bastard child of rlcompleter and the current "Expand Word". Obviously, unlike "Expand Word" these only work in the Python shell, not in the file-editing windows. (Now that I think about it, this would probably be pretty useful in those editing windows, but that would take some partial compilation of some sort I suppose, which is way too much work for me.) To add these to IDLE, put the two files in your IDLE directory, (or just the one you want -- I'm flexible!), and add "RLComplete" and "AutoComplete" to the list of names in extend.py (also in your IDLE directory). Problems and inconsistencies are documented in the module docstrings. Let me know of any bugs. Cheers, Jesse. From tbryan at python.net Wed Nov 24 06:28:10 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Wed, 24 Nov 1999 06:28:10 -0500 Subject: Upgrading Python on Windows Message-ID: <383BCBCA.5804D43E@python.net> I have Python-1.5.1 installed on a Windows95 machine. I now want to upgrade to Python-1.5.2. I can't find any documentation about upgrading on a Windows box. I don't need the Python-1.5.2 installation anymore. I've already downloaded py152.exe, but I'd like advice before I proceed. Should I uninstall Python-1.5.1 first? How do I do that (run unwise.exe?)? Should I also uninstall the current version of Tcl/Tk and reinstall it with the Python-1.5.2 installation? I-can-troubleshoot-a-UNIX-install,-but-Windows-scares-me-ly yours ---Tom From bparsia at email.unc.edu Sat Nov 27 12:27:54 1999 From: bparsia at email.unc.edu (Bijan Parsia) Date: Sat, 27 Nov 1999 12:27:54 -0500 Subject: Python complaints References: <867lj85g4c.fsf@g.local> <383CC835.B585EBDD@Lugoj.Com> <383D9C63.3A7E5806@Lugoj.Com> <86ogci2tfm.fsf@g.local> <86aeo0283v.fsf@g.local> Message-ID: <1e1xf0n.w5dt9t1qn1y4qN%bparsia@email.unc.edu> Gareth McCaughan wrote: > Markus Stenberg wrote: > > [I said:] > >> Garbage collectors have got a *lot* better since the days when > >> GC meant half-second pauses waiting for the machine to sweep > >> through all its memory. Let alone 20 seconds. > > > > Where can I admire such a beast? At least none of the Java > > implementations(*) I have tried(**) have one. say, for 128MB of trash, it's > > consistent N second sweep (0.5-10, depending on hardware). > > In a modern Lisp implementation. Modern Smalltalks are probably > just as good. (Unfortunately, "modern" might have to imply > "commercial" here; I'm not sure of the quality of the GC in > the various free implementations of those languages.) Yep, they're as good. As for trying 'em out, the are non-commercial (i.e., limited to non-commercial uses unless you purchace a licence) of VisualWorks (http://www.cincom.com) for many platforms (the latest version, 5i, is available for Linux and Windows, but not yet for PowerMac). VW allows you to do all sorts of things with it's gc via a class called, IIRC, Memory Policy. There is a non-commercial version of Dolphin Smalltalk (http://www.object-arts.com/), albeit for Windows only. But it's a nice smallish Smalltalk (VW can be overwhelmning, particularly at first). (I'll add that Dolphin is rather inexpensive and is definitely worth it) I believe Smalltalk MT may have a demo version. As for Free/Open Source, there's Squeak (http://www.squeak.org), which is massively cross platform (even runs on WinCE & Sharp's ICruise). There's a very clear description of Squeak's gc in the "Back to The Future" paper (ftp://st.cs.uiuc.edu/Smalltalk/Squeak/docs/OOPSLA.Squeak.html). An edited quote: "Two policy refinements reduced the incremental garbage collection pauses to the point where Squeak became usable for real-time applications such as music and animation...We have been using this storage manager in support of real-time graphics and music for over a year now with extremely satisfactory results. In our experience, 10 milliseconds is an important threshold for latency in interactive systems, because most of the other critical functions such as mouse polling, sound buffer output and display refresh take place at a commensurate rate." There also was a Real Time Squeak project which was, alas, canceled, but the bits and pieces are filtering their way into the main distribution. A paper describing the work was given at the OOPSLA '99 "VM Workshop" (http://www.squeak.org/oopsla99_vmworkshop/). The particular paper is "Experience Report: Building a Real Time OS Kernel in Smalltalk". There have been other RT Smalltalks, I believe. Gnu Smalltalk has be revived, but I don't *believe* it's settled on a gc mechanism yet, although it may just borrow Squeak's (in concept if not in code). Note: I was confused by the term "non-deterministic" wrt to GC. My first thought was that it referred to the fact that, generally, one doesn't know exactly *when* garbage will be collected, only that it *will* be, at some point, if necessary ;) This is certainly an important issue for such matters as finalization. But it seems to have been used to refer to the "pausing" problem. But I don't think that's necessarily "non-deterministic", per se. It isn't that hard to predict how long a stopping gc will take for a given memory space! ;) Cheers, Bijan Parsia From sk at fyemf.fys.ntnu.no Mon Nov 8 10:01:31 1999 From: sk at fyemf.fys.ntnu.no (Steinar Knutsen) Date: 8 Nov 1999 15:01:31 -0000 Subject: What are Aspects? (Re: How can I make my assertions smarter?) References: <7vvq63$ehm$1@nntp4.atl.mindspring.net> <3826C32A.FB47EF6@compaq.com> Message-ID: <806okb$qkr$1@fyemf.fys.ntnu.no> In article , Magnus L. Hetland wrote: >Greg Ewing writes: > >> Smacks of the legendary come-from statement, somehow... > >Sounds cool... Only a myth? Well, it depends. INTERCAL defines COME FROM. :) http://www.tuxedo.org/~esr/intercal/ (For those who haven't heard of it, INTERCAL is perhaps the most twisted programming language ever implemented.) -- Steinar From hniksic at iskon.hr Tue Nov 16 04:44:05 1999 From: hniksic at iskon.hr (Hrvoje Niksic) Date: 16 Nov 1999 10:44:05 +0100 Subject: list.without()? References: Message-ID: <9t9g0y6ojoa.fsf@mraz.iskon.hr> mlh at vier.idi.ntnu.no (Magnus L. Hetland) writes: > Is there a function or method in the standard language that can > non-destructively return a list without a specified element? What's wrong with destructively removing the element from a copy? It will be faster than using `filter' and friends as other proposed, and guaranteed to work. In fact, (shallow) copying is the pretty much standard way of turning any destructive operation non-destructive. If you want it bundled in a function, you can do this: def without(list, element): copy = self[:] copy.remove(element) return copy If you want to use classes, you can inherit from UserList. If your only problem with this approach is having a temporary variable, then you don't need to lobby for adding a new method -- you can simply lobby for the `remove()' method to return self. In that case, you could write: newlist = somelist[:].remove(element) Or, for that matter: newlist = somelist[:].sort() Or: for elem in dict.keys().sort(): ... But neither is likely to be successful. Adding a new builtin method for a task that can be accomplished with two lines of code doesn't sound promising. And the destructive methods rarely return self, "to remind you [that they modify the list in place]." From olivier at scripps.edu Wed Nov 10 15:37:32 1999 From: olivier at scripps.edu (Olivier Roche) Date: Wed, 10 Nov 1999 12:37:32 -0800 Subject: random function Message-ID: <3829D78B.7FC142F4@scripps.edu> Hi everybody By looking at the index of the python documentation index i haven't seen any random function description. Could somebody tell me if a random function to generate random number (between 0 and 1) exists ? Thanks, Olivier From henk_p at my-deja.com Tue Nov 16 13:48:07 1999 From: henk_p at my-deja.com (henk_p at my-deja.com) Date: Tue, 16 Nov 1999 18:48:07 GMT Subject: PyApache References: Message-ID: <80s8sk$cr7$1@nnrp1.deja.com> Maybe you can try my Python Script Interface, It provides persistent python scripting to any CGI capable webserver. It was announced recently on the python announce news group. You can download it directly from: http://huizen.dds.nl/~d50/psi0.02.tgz Let me know if it is usable to you. Henk. Sent via Deja.com http://www.deja.com/ Before you buy. From brainsite at altern.org Thu Nov 4 08:42:53 1999 From: brainsite at altern.org (brainsite at altern.org) Date: 4 Nov 1999 13:42:53 GMT Subject: FREE Porn, without membership!!! No pop-ups!!! Everythings FREE!! Message-ID: <7vs2gt$28jm2528@michener.tea.state.tx.us> *********************************** * XXXMonkey - 100% Free Pure Porn * *********************************** Goto XXXMonkey and enjoy the taste of FREE porn. There is no membership, just pics you freely can save on YOUR harddisk. From TEENS to ASIANS, everything is there. Go and check: http://get.to/muchxxx (with 1 small pop-up) http://watch.at/xxxmonkey (no pop-ups) Keep in mind: This site is just new!! It must grow, so the archive isn't big YET!! From wtanksle at hawking.armored.net Sat Nov 27 15:04:56 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 27 Nov 1999 20:04:56 GMT Subject: Python complaints References: <000601bf36be$f1bf5e80$292d153f@tim> <81ivhe$12l$1@mach.vub.ac.be> Message-ID: On 25 Nov 1999 09:29:18 GMT, Thomas Hamelryck wrote: >Tim Peters (tim_one at email.msn.com) wrote: >: There is one (& only one) area where Python's indentation gets in my way a >: bit: conceptual blocks that can't be written as blocks. These typically >Right. Another example occurs in OpenGL, eg. >glBegin(GL_POLYGON) > glVertex2f(-0.5, -0.5) > glVertex2f(-0.5, 0.5) > glVertex2f(0.5, 0.5) > glVertex2f(0.5, -0.5) >glEnd() Good point -- the forced indentation here would be annoying. A try/finally block wouldn't be totally amiss, but perhaps a function definition would be better. Either way is merely a workaround, but the try/finally block has some useful meaning: it communicates that the stuff in the block is in some way atomic. >This makes the code more readable, but it's not allowed in Python. I've >got used to the indentation rule in Python, and I'm not annoyed by it that >much anymore, but I still think it is a major mistake. I think it's the best decision that could have been made. All hail Guido. ;-). >Thomas Hamelryck//Free University Brussels (VUB) -- -William "Billy" Tanksley From kaleissin at nvg.org Sat Nov 27 22:42:52 1999 From: kaleissin at nvg.org (Kaleissin) Date: 28 Nov 1999 03:42:52 GMT Subject: Anyone looked at pike? Message-ID: Specifically: why they claim it's faster? http://pike.idonex.se/manual/tutorial/tut_introduction.html#introduction.3 Though, why anyone would want Yet Another C-Like Syntax is beyond me... tal. From kvijayan at calum.csclub.uwaterloo.ca Sat Nov 27 01:08:13 1999 From: kvijayan at calum.csclub.uwaterloo.ca (Kannan Vijayan) Date: 27 Nov 1999 06:08:13 GMT Subject: [].extend only accepts list? References: Message-ID: <81nsgd$mk5$1@watserv3.uwaterloo.ca> Quinn Dunkan (quinn at groat.ugcs.caltech.edu) wrote: > Is there any reason why the extend method of lists shouldn't accept any > sequence? the extend method checks to see if the argument is a list. You can easily get past this by using the list() function y = ["one", 2, "three"] y.extend(list(("four", 5.0, 3*2))) y -> ["one", 2, "three", "four", 5.0, 6] you can use this method with any sequence, including strings, and tuples. -kannan From dgrisby at uk.research.att.com Fri Nov 5 12:01:49 1999 From: dgrisby at uk.research.att.com (Duncan Grisby) Date: 5 Nov 1999 17:01:49 -0000 Subject: C++ extension modules on NT References: <7vuqa8$fvi$1@pineapple.uk.research.att.com> Message-ID: <7vv2ht$hd3$1@pineapple.uk.research.att.com> In article <7vuqa8$fvi$1 at pineapple.uk.research.att.com>, Duncan Grisby wrote: [...global constructors in DLL...] >On NT, however, the constructors are never called, and the global >objects contain garbage. The document "Extending and Embedding the >Python Interpreter" mentions this problem in section 1.11, and says >that the problem doesn't occur if the Python interpreter's main() >function is compiled with C++. Unfortunately, this appears to be >incorrect, and the constructors still aren't called. Following up to my own post, it turns out that the problem I was having was something else (to do with dllimport), and the constructors _are_ being called. So now my question is: are there any platforms for which the comment in the documentation is true? Cheers, Duncan. -- -- Duncan Grisby \ Research Engineer -- -- AT&T Laboratories Cambridge -- -- http://www.uk.research.att.com/~dpg1 -- From pycloutier at videotron.ca Mon Nov 29 00:56:01 1999 From: pycloutier at videotron.ca (Pierre-Yves Cloutier) Date: Mon, 29 Nov 1999 00:56:01 -0500 Subject: Recursion? Message-ID: <38421570.9C3D9AEC@videotron.ca> Can I use recursion in python? thanks Pierre-Yves Cloutier From kyriacou at umbc.edu Tue Nov 23 15:39:30 1999 From: kyriacou at umbc.edu (Stelios Kyriacou) Date: 23 Nov 1999 15:39:30 -0500 Subject: whrandom seed question Message-ID: <81eu22$411al$1@umbc7.umbc.edu> Hi, I tried today the random number generator in python and have the following question: Shouldn't the following 3 lines produce the same number? >>> whrandom.seed(0,0,0); print whrandom.random() 0.39613674715 >>> whrandom.seed(0,0,0); print whrandom.random() 0.170188890936 >>> whrandom.seed(0,0,0); print whrandom.random() 0.831213988577 >>> I am used to the matlab randn function which does produce the same number since i restart the seed: >> rand('seed',0); rand(1) ans = 0.2190 >> rand('seed',0); rand(1) ans = 0.2190 >> Am I missing something??? Thanks very much in advance. Stelios From tim_one at email.msn.com Wed Nov 24 17:09:25 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 24 Nov 1999 17:09:25 -0500 Subject: CRC-module In-Reply-To: <383C1089.1D0F7C18@bibsyst.no> Message-ID: <000801bf36c8$92ee19a0$292d153f@tim> [Thomas Weholt] > Ok, so I`ve looked into zlib.crc32 and zlib.adler32. They seem easy > enough to use, but I thought crc-codes had characters and numbers in > them, not just a plain integer like the methods above return. Bits is bits. Whether you choose to view them as integers, or characters, or little stick men struggling to avoid falling into little holes is all in your head. That is, don't worry about it! > ( As you can see, I`m a complete ass on this subject, In that case, I'll be toilet paper. > but don`t have time to do the proper research myself, and was hoping > for a "quick fix" ... ) > > A friend of mine mentioned that I should try SHA-1 instead, for more > accuracy. Can anybody give me an example on how to compute crc-codes, > using zlib or preferrably some more accurate method, for single files ?? > > If this is all it takes : > > crc = module_name.crc_method(file) > > and comparison is done like : > > if (crc1 == crc2): print "Equal." > else : print "Different." > > then all I need is the name of the most effective/accurate module to > use. That's about it. Strictly it should be: if crc1 == crc2: print "Probably equal." else: print "Definitely different." Equality of hash codes does not guarantee equality of files under any method, it merely makes it likely. Throw two random but unequal files at one of the xxx32 methods, and there's (exactly) 1 chance in 2**32 (about 1 in 4 billion) that they'll return the same hash code. The odds for MD5 are about 1 in 2**128, and for SHA-1 about 1 in 2**160. Like everything else, it's a tradeoff. CRCs are cheap to compute, but very easy to fool on purpose (it's trivial to construct any number of distinct files that have the same CRC hashcode). The other methods are expensive to compute, but extremely difficult to fool on purpose (in fact, it's believed to be computationally infeasible). This reflects their design goals: CRCs were designed to catch transmission errors (accidents of nature), while MD5 and SHA-1 were designed to stop malicious people with large piles of money (accidents of nature ). > If, for some strange reason, I should use one module instead of another, > that info would be interesting too. In practice, I like a two-step approach: 1. Compute CRCs. If they're different, the files are definitely different, and you get out cheap. 2. Compute SHA-1. If they're different too, the files are also definitely different. If they're the same, then since the CRC and SHA-1 methods are unrelated, it's reasonable to expect that the odds of a false match are about 1 in 2**32 * 2**160 == 2**192 now. This is even smaller than the chance Python2 will have curly-brace block delimeters. which-in-turn-is-smaller-than-the-chance-you'll-wake-up-in-a-womb-ly y'rs - tim From stalnaker at acm.org Thu Nov 25 17:31:14 1999 From: stalnaker at acm.org (Max M. Stalnaker) Date: Thu, 25 Nov 1999 14:31:14 -0800 Subject: urllib.urlopen-bug? References: <943390670.1482784211@news.teleweb.at> Message-ID: I think you get html on a 404, so it is not really a *server* error. But consider: errcode, errmsg, headers = h.getreply() if errcode!=200: return "Markus Krutz" wrote in message news:943390670.1482784211 at news.teleweb.at... > Hi, > I've got a problem using the urlopen-function from the urllib. > According to the library reference, an IOError-exception should be raised on > two conditions: > 1) The connection can't be made. > 2) The server returns an error. > On 1) an exceptions is raised, but if I do a > urllib.urlopen("http://www.python.org/nonexistingdocument.html") > no exception is raised, although I think this is a typical 404-Error. > In my opinion this should result in raising an exception... > Any hints on other ways how to check for the existence of a net resource? > (I'm using python v1.5.2) > > greetings > Markus > From fredrik at pythonware.com Tue Nov 2 03:29:56 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 2 Nov 1999 09:29:56 +0100 Subject: commas vs. spaces. vs. the legions of new lines References: <1270647588-25358408@hypernet.com> Message-ID: <007f01bf250c$72dd3c40$f29b12c2@secret.pythonware.com> Gordon McMillan wrote: > > So the unix old-timers know a billion and one ways to > > convert Dos to Unix text files. Why discourage someone from > > making a pure python implementation... > > I will make the observation that one can classify Pythonistas > into those who think recoding common utilities in pure Python > is evil, and those who think it a worthy goal, with very few > people in the middle. also see: http://language.perl.com/ppt/index.html "Welcome to the Unix Reconstruction Project. Our goal is quite simply to reimplement the classic Unix command set in pure Perl, and to have as much fun as we can doing so." From akuchlin at mems-exchange.org Wed Nov 10 13:27:15 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 10 Nov 1999 13:27:15 -0500 Subject: statics everywhere. Why? References: <80cam4$phe$1@rtpnews.raleigh.ibm.com> Message-ID: <3d9046p5h8.fsf@amarok.cnri.reston.va.us> "Arinte" writes: > Embedding python in a c application, why do I need to make the functions > that python call and variables for callbacks static? In the modules that come with Python, all of these functions are defined as static. I think this is simply done to keep those symbols private, to avoid causing collisions when you link libpython.a into your application; you'd be unhappy if a get_group_num() function in the re module conflicted with a get_group_num() function in your code. For your own internal application, it's up to you whether such symbols should be kept private or not. (Note that this applies to functions and global variables defined as 'static'; the 'static' keyword means something different inside a C { } block.) -- A.M. Kuchling http://starship.python.net/crew/amk/ The Kappamaki, a whaling research ship, was currently researching the question: How many whales can you catch in one week? -- Terry Pratchett & Neil Gaiman, _Good Omens_ From salvadorej at my-deja.com Thu Nov 4 20:12:18 1999 From: salvadorej at my-deja.com (salvadorej at my-deja.com) Date: Fri, 05 Nov 1999 01:12:18 GMT Subject: Problems Building Python under Cygwin Message-ID: <7vtath$n1j$1@nnrp1.deja.com> I'm having some problems building Python under Cygwin on Windows NT 4. 1) the first problem I had was relatively easy to deal with. Towards the end of the make process, there's a command to copy the python executable from the Modules directory. The problem is, the makefile expects to copy something called 'python', but the executable produced was 'python.exe' (presumably because I'm under Windows). So cp can't complete this command, and the makefile chokes. Fortunately, at this point, the make process is pretty much done, so all I had to do was go into the Modules directory, and copy python.exe to the directory above, and it worked. SO: did I mess up? Or is this something wrong with the makefile/configure setup that needs to be fixed? 2) the second problem I haven't solved. What I really wanted Python for was to build Zope from scratch. When I went to build Zope, it informed me that I needed not the "vanilla" version of Python, but Python compiled with thread support. OK. I go back, make clean, and try configure --with-threads. And partway through the make, I get this: cd Modules ; make OPT="-g -O2" VERSION="1.5" \ prefix="/usr/local" exec_prefix="/usr/local" all gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c ./threadmodule.c ./threadmodule.c:38: #error "Error! The rest of Python is not compiled with thread support." ./threadmodule.c:39: #error "Rerun configure, adding a --with-thread option." ./threadmodule.c:40: #error "Then run `make clean' followed by `make'." make[1]: *** [threadmodule.o] Error 1 make: *** [Modules] Error 2 Hmmmm. I thought I did that. So I re-did the configure, did the make clean again, and then make. Same result. For good measure, I rm -rf'd the whole Python directory, and then untarred it again, did configure with both the --with-thread and --with-threads options, and tried to make again. Same result. Hints? =================================================================== "The best laid plans of mice and men are about equal" Email: iowa_s8ong at hot8mail.com Remove Eights from email to reach me. Sent via Deja.com http://www.deja.com/ Before you buy. From mhammond at skippinet.com.au Thu Nov 18 06:54:07 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 18 Nov 1999 11:54:07 GMT Subject: Python in Windows CE? References: <19991118102301.910.qmail@hotmail.com> Message-ID: Ulf Engstr?m wrote in message <19991118102301.910.qmail at hotmail.com>... >>You will probably want to check out the Python CE >>mailing list: >> >> http://www.egroups.com/group/python-ce/ >While both CE and Python attempt to be portable, it appears that the current >situation is not at all portable. It appears there is no way we can write a >win32 Python program, and have it work on both CE, and Win95/NT. "No way" isnt quite correct. The Python shell also runs on the desktop. Its true that you basically cant take a program written for the desktop and expect it to run unchanged. Unicode issues at least will prevent this before Python 1.6. >At the most basic level, simple win32 wrappers are in differently named >modules. For example, the CE port has win32reg for the registry functions, >but in the existing win32 ports, they exist in win32api. This is not to >suggest my scheme is anywhere near ideal, but IMO a common strategy is >needed. Agreed, and it is slowly happening. Many modules are built from the same code base - indeed, all "new" modules are. win32api doesnt exist on CE, and, again, is unlikely to until at least Python 1.6. But many modules are as identical as the platform allows. Pythonwin is not there, and wont be until at least CE3.0 :-) >Has any solutions to this been found? And are there any other compability >problems? A number. But not alot more than there are between the platforms themselves - eg, there is _no_ language that allows you to take an existing win32 app and have it run on CE. C++ definately cant. VB is probably the closest, but I have never used it on CE. And I have to be honest - if you need to do anything non trivial, it is likely you will need to have a C compiler for CE, and add a few new "swig" declarations, particularly for the GUI stuff. At least for now :-) Mark. From mehta at mama.indstate.edu Thu Nov 11 11:08:49 1999 From: mehta at mama.indstate.edu (mehta at mama.indstate.edu) Date: Thu, 11 Nov 1999 16:08:49 GMT Subject: docs Message-ID: <80epm7$vbo$1@nnrp1.deja.com> Hello, I have noticed for the local docs of python in IE5 on winnt pages randomly donot get rendered but are left as raw html in browser as I go back and forth using browser buttons. has any one experienced same problem? Sent via Deja.com http://www.deja.com/ Before you buy. From wware-nospam at world.std.com Mon Nov 8 17:54:30 1999 From: wware-nospam at world.std.com (Will Ware) Date: Mon, 8 Nov 1999 22:54:30 GMT Subject: Stackless python progress? References: <38274626.5D8C1EC2@ptway.com> Message-ID: Brian Haskin (haskin at ptway.com) wrote: > also has there been any work on combining > 'microthreading' and the stackless stuff? I was the one doing the microthread stuff. I've been too busy to play with it recently. Implementing microthreads in terms of Stackless Python is the Right Thing To Do(tm) from an engineering standpoint, but I haven't had time to devote to it lately. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From I.Clarke at strs.co.uk Thu Nov 11 07:09:29 1999 From: I.Clarke at strs.co.uk (Ian Clarke) Date: Thu, 11 Nov 1999 12:09:29 +0000 Subject: Tk Vs GTK - a comparison anyone? Message-ID: <382AB1F9.85F78EAD@strs.co.uk> Could anyone who is familar with using both Tk and GTK from Python give a quick rundown of how they compare (speed, development time (ie. which is more developer friendly?), level of integration with Python, flexibility etc). Cheers, Ian. -- Ian Clarke Email: I.Clarke at strs.co.uk Homepage: http://www.gnu.demon.co.uk/ Also see: http://freenet.on.openprojects.net/ "All we see and all we seem is but a dream within a dream" From ivanlan at callware.com Tue Nov 30 09:48:57 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Tue, 30 Nov 1999 07:48:57 -0700 Subject: bug in tkinter canvas event handling? References: <38429BB0.1BFFB54B@sage.att.com> <3843C0A0.94990E64@home.com> Message-ID: <3843E3D9.9C68E2A1@callware.com> Hi All-- Doug Hellmann wrote: > > "Garrett G. Hodgson" wrote: > > > > ok, i'm back with another tk problem. > > what i want to do is attach a callback to a shape in a canvas > > that will tell me which domain level object was picked. > > > > seems simple, but i don't get what i expect. in particular, > > if i press a mouse button while pointing to one object, then drag > > to another and release, the release event callback tells me i > > was pointing to the first object. i've distilled it down to a > > small test case, attached below. > > > > this seems like a bug to me, but experience has shown that it's > > probably a misconception on my part about how the event handling > > is supposed to work. > > This behavior surprised me at first, too. It's as though the first > canvas object is grabbing the pointer so that all events go to it. I > got around the problem by looking for the x,y coords of the release > event and then finding the object(s) under that point on the canvas. > Actually, this isn't a bug. All windowing systems (the ones I know about, anyway) behave this way by design; the down-click does indeed grab the mouse pointer, and does not let go until the up-click (or is that up-chuck?). You can see this behaviour even in windows, which hacks away at expected pointer motion with gleeful abandon. Click on a scrollbar, begin moving it, move the pointer out of the scrollbar, *watch the scrollbar snap to its previous position*, move the pointer back into the scrollbar, and finally *watch the scrollbar snap back under the pointer.* This is repulsive and incorrect behaviour <0.9 barf>, but it couldn't be done without a mouse pointer grab by the object underneath the pointer on the down-click. -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours ---------------------------------------------- From news at dorb.com Wed Nov 10 23:14:38 1999 From: news at dorb.com (Darrell) Date: Wed, 10 Nov 1999 23:14:38 -0500 Subject: ASCII delimited files References: <942231502.1914033961@news.interbusiness.it> Message-ID: If comma delimited files are what your after then I have some 'C' code for you. This came up on the Zope list a week ago and there was a regular expression solution. Li Dongfeng "Re: [Zope] Comma delimited file and the re python object" """ Tests for splitQuote.pyd """ from splitQuote import * import time txt=r''' "Bond, James", 13, 45 'That\'s "absolutely","possible."', 1999, 8, 30 """now"",""is"\'"",the,555,"""time""" ''' #""" print split.__doc__ buf=txt*2 print 'Buf len:',len(buf) t1=time.time() l=split(buf) print 'Num records:',len(l) print "Time: %.2f"%(time.time()-t1) for x in range(4): print l[x] valid=[['Bond, James', '13', '45'], ['That\\\'s "absolutely","possible."', '1999', '8', '30'], ['""now"",""is"\\\'"', 'the', '555', '""time""'], ['Bond, James', '13', '45'], ['That\\\'s "absolutely","possible."', '1999', '8', '30'], ['""now"",""is"\\\'"', 'the', '555', '""time""']] assert(l==valid) -- --Darrell Roger Irwin wrote in message news:942231502.1914033961 at news.interbusiness.it... > Is there any function or module available for parsing ASCII delimited files, > before I go and re-invent the wheel writing my own. > > BTW, I know it is simple to do, but I was thinking along the lines that a > 'standard' could easily be substituted for a C version for large files. > From pereira at research.att.com Tue Nov 2 23:27:52 1999 From: pereira at research.att.com (Fernando Pereira) Date: Wed, 3 Nov 1999 04:27:52 GMT Subject: A Comparison of Python and Ruby Extension Interfaces (Re: Comparison between Python and "Ruby") References: <3819BCDA.AC4FD4CA@strs.co.uk> <87k8o2x67f.fsf@ev.netlab.co.jp> <7vjtrc$hmm$1@newshost.accu.uu.nl> <38204614.2EAC6051@compaq.com> Message-ID: <021119992327527678%pereira@research.att.com> In article <38204614.2EAC6051 at compaq.com>, Greg Ewing wrote: > * Since Ruby has mark-and-sweep garbage collection, there > is no manipulation of reference counts. There weren't > actually any examples of this in the Python dbm module, > though. What's the effect of this on portability? For instance, how are pointers to live objects from the C stack handled? As is well-known, this cannot be done portably. > > * Ruby seems to be able to raise exceptions without > having to explicitly propagate them back out of routines, > which eliminates a lot of result testing and returning of > -1's and None's that goes on in Python extension code. Same comment. There is no portable way of unwinding the C stack. What does that mean for Ruby's portability? These were pretty ugly problems when I devoted quite a bit of effort to them in the 80s (Prolog<->C integration back then), and they can only have become worse with new architectures and more highly optimizing C compilers. -- F From robin at alldunn.com Thu Nov 18 14:35:32 1999 From: robin at alldunn.com (Robin Dunn) Date: Thu, 18 Nov 1999 11:35:32 -0800 Subject: Freezing wxPython apps References: <80v14b$b1s$1@nnrp1.deja.com> Message-ID: yinger wrote in message news:80v14b$b1s$1 at nnrp1.deja.com... > Is there a way to 'freeze' a wxPython app so that it can be distributed > without requiring wxPython to be installed on the client? > I havn't tried freeze on a wxPython app yet, but there shouldn't be a problem so long as you distribute the binary extension modules too. For Win32 though, Gordon's tool is definitly the way to go, as Carrie mentioned. -- Robin Dunn Software Craftsman robin at AllDunn.com http://AllDunn.com/robin/ http://AllDunn.com/wxPython/ Check it out! From ivanlan at callware.com Sun Nov 7 21:21:37 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Sun, 07 Nov 1999 19:21:37 -0700 Subject: pythonistas or pythoneers? References: <07111999.2@sanctum.jae> Message-ID: <382633B1.50993D93@callware.com> Hi All-- "Juergen A. Erhard" wrote: > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > I'm confused: are we pythoneers or pythonistas? > > I tend to go for pythoneers... sounds more pythonic. > > Or are these two levels of experience? If so, what's higher? > Be confused no longer; as we are all guerilla programmers, we are of course Pythonistas! -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From billtut at microsoft.com Wed Nov 24 09:59:36 1999 From: billtut at microsoft.com (Bill Tutt) Date: Wed, 24 Nov 1999 06:59:36 -0800 Subject: COM Message-ID: <4D0A23B3F74DD111ACCD00805F31D8100DB915AC@RED-MSG-50> app.Quit() del app Will do the trick. Bill > -----Original Message----- > From: Le Guennec [mailto:jy.lg at wanadoo.fr] > Sent: Thursday, November 18, 1999 5:22 AM > To: python-list at python.org > Subject: COM > > > I've created a app variable : > app = win32com.client.dispatch('Excel.Application') > > how can I free this object and close Excel properly? > > Thanks > > > > > > -- > http://www.python.org/mailman/listinfo/python-list > From aahz at netcom.com Thu Nov 25 00:43:33 1999 From: aahz at netcom.com (Aahz Maruch) Date: 25 Nov 1999 05:43:33 GMT Subject: CRC-module References: <000801bf36c8$92ee19a0$292d153f@tim> Message-ID: <81iia5$pj5$1@nntp9.atl.mindspring.net> In article <000801bf36c8$92ee19a0$292d153f at tim>, Tim Peters wrote: > >In practice, I like a two-step approach: > >1. Compute CRCs. If they're different, the files are definitely different, > and you get out cheap. > >2. Compute SHA-1. If they're different too, the files are also definitely > different. If they're the same, then since the CRC and SHA-1 methods > are unrelated, it's reasonable to expect that the odds of a false match > are about 1 in 2**32 * 2**160 == 2**192 now. This is even smaller than > the chance Python2 will have curly-brace block delimeters. In practice, the likelihood of two files having the same MD5 or SHA is nearly infinitesimal, provided they're the same length. Check the first hundred or thousand characters for equality and you're essentially done. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Question authority: ask me anything! From janssen at parc.xerox.com Tue Nov 30 22:31:47 1999 From: janssen at parc.xerox.com (Bill Janssen) Date: Tue, 30 Nov 1999 19:31:47 PST Subject: '==' vs. 'is' behavior In-Reply-To: Your message of "Mon, 29 Nov 1999 21:13:40 PST." Message-ID: <99Nov30.193151pst."3757"@watson.parc.xerox.com> Actually, the presence of "is" and "==" in Python is one of the nicer features. "is" is the Lisp "eq", while "==" is the Lisp "equal". These are really the two comparisons from Lisp that make the most sense. Java, on the other hand, only gives you "eql"! Ugh! Bletcherous! Bill From phd at phd.russ.ru Thu Nov 25 04:56:36 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Thu, 25 Nov 1999 09:56:36 +0000 (GMT) Subject: Listing a dictionary In-Reply-To: <383CFEE5.951376A0@obop.com.pl> Message-ID: On Thu, 25 Nov 1999, [iso-8859-2] Przemys?aw G. [iso-8859-2] Gawro?ski wrote: > How can I list all the keys in a dictionary ? dict.keys() Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From parkw at better.net Fri Nov 19 08:02:02 1999 From: parkw at better.net (William Park) Date: Fri, 19 Nov 1999 08:02:02 -0500 Subject: Python Chinese In-Reply-To: <19991119121544.5006.qmail@hotmail.com> References: <19991119121544.5006.qmail@hotmail.com> Message-ID: <19991119080202.A439@better.net> On Fri, Nov 19, 1999 at 01:15:44PM +0100, Ulf Engstr?m wrote: > Is there any way to use Python with Chinese and other asian chars? > If not, are there any plans to make this compability? > Best regards > Ulf Engstr?m > > http://www.b2b-link.com > ulf.engstrom at b2b-link.com What do you mean by "compability"? All Python has to do is handle strings in 8-bit clean fashion, then you can cut, paste, and search 8-bit characters as you like. Unfortunately, I can't find out right now. William Park From a.eyre at optichrome.com Wed Nov 24 04:29:11 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Wed, 24 Nov 1999 09:29:11 -0000 Subject: Embedded Python 1.5.1 crashes under WIN32 In-Reply-To: <3832F6FB.68AAA96E@tu-bs.de> Message-ID: <002901bf365e$5dd9e510$3acbd9c2@peridot.optichrome.com> > What I want to do is to call PyRun_SimpleFile from my main program. This > works fine under Irix 6.5, but the same thing crashes inside > PyRun_SimpleFile when compiled with VC6.0SP2 under Win32, which is a > great pity. Make sure you aren't mixing runtime DLLS. i.e. only build debug (MSVCRTD) code with the debug lib (python15_d.lib) and same for release (MSVCRT + python15.lib) -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From simon at george.maths.unsw.edu.au Tue Nov 30 20:07:49 1999 From: simon at george.maths.unsw.edu.au (Simon Evans) Date: 1 Dec 1999 01:07:49 GMT Subject: Plotting a single pixel (possible newbie question) Message-ID: <821sd5$7h0$1@mirv.unsw.edu.au> I'm relatively new to Python, which I use for several small numerically-oriented projects that are refreshingly different from my workday giant Fortran simulations. I've installed and used both Tkinter and DISLIN (a scientific graphing extension), but what I'm really missing is the ability to do the simplest graphics task of all: lighting up a single pixel. You'd think it wouldn't be too much to ask... Does anyone know of a graphics extension that offers this simple facility, or a method of doing it in the ones I have? I'd like to do it by some other method than drawing a line with a length of one pixel! ================================================================= Simon Evans (simon at maths.unsw.edu.au) Physical Oceanography Group School of Mathematics, University of New South Wales, Australia. ================================================================= From greg.ewing at compaq.com Thu Nov 4 10:38:08 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Fri, 05 Nov 1999 04:38:08 +1300 Subject: Some more Ruby observations (Re: Comparison between Python and "Ruby") References: <3819BCDA.AC4FD4CA@strs.co.uk> <87k8o2x67f.fsf@ev.netlab.co.jp> <7vjtrc$hmm$1@newshost.accu.uu.nl> Message-ID: <3821A860.5D32AFCC@compaq.com> Here are some random observations from studying the Ruby source code: * It seems to have a notion of "tainted" strings, and can be run in various security modes where certain operations using tainted strings are disallowed. * It doesn't use bytecode. The evaluator seems to operate directly on a parse tree. I don't know what implications this has for execution speed. * Here is an interesting little diagram I came across. Note that Ruby appears to have metaclasses of some flavour or other. /* * Ruby's Class Hierarchy Chart * * +------------------+ * | | * Object---->(Object) | * ^ ^ ^ ^ | * | | | | | * | | +-----+ +---------+ | * | | | | | * | +-----------+ | | * | | | | | * +------+ | Module--->(Module) | * | | ^ ^ | * OtherClass-->(OtherClass) | | | * | | | * Class---->(Class) | * ^ | * | | * +----------------+ * * + All metaclasses are instances of the class `Class'. */ Greg From mal at lemburg.com Thu Nov 4 03:59:09 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Thu, 04 Nov 1999 09:59:09 +0100 Subject: Module for generic platform information: platform.py References: <3815782E.FC516671@lemburg.com> Message-ID: <38214ADD.1C7AB1CD@lemburg.com> There is a new release of the platform.py module available at: http://starship.skyport.net/~lemburg/platform.py To see if it works on your platform, simply run the script. Many thanks go out to all those who have helped so far. The list of supported platforms is constantly growing :-) Note that this module is a fast moving target. I plan to release version 1.0 as the final version. Still needed: ? support for WinCE ? support for MS-DOS (PythonDX ?) ? support for Amiga, VMS and other platforms running Python ? support for additional Linux distributions ? debugging of the WinXX code and the JPython code for Java The module now includes support for Win95,98,2000,NT (still needs some debugging though), MacOS, MacOS X Server, Linux (RedHat, Suse, Debian, Slackware, Mandrake), FreeBSD, Solaris, HP UX, IRIX, OSF (DEC Digital Unix), Java, plus probably some others that I've forgotten in the list... Enjoy, -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 57 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From donn at u.washington.edu Tue Nov 2 12:48:56 1999 From: donn at u.washington.edu (Donn Cave) Date: 2 Nov 1999 17:48:56 GMT Subject: __str__ vs. __repr__ References: <19991102073422.B134170008@vislab.epa.gov> <1270634443-26149069@hypernet.com> <000701bf24ef$e2d29b20$0f2d153f@tim> Message-ID: <7vn868$p18$1@nntp6.u.washington.edu> Quoth Randall Hopper : ... | Thanks. That's the source of my confusion. I wanted to follow the | language convention. But Python's internals currently don't follow it, so | the point is somewhat moot. | | For consistency, would it make sense to change this for Python 1.5.3 (that | is, have sequence and dict types pass 'str-vs-repr'ness down)? I'd go back to an earlier followup on this and try to refine the critical point, why __str__? The man said __str__ is intended to be ``friendly''. I think it might help to be a little more specific about whose friend this string is. For me, anyway, __str__ is for an object whose data model supports a string value. For example, if we toss a TypeError exception value into a context where a string is expected, it might act like a string 'illegal argument type for built-in operation'. This isn't just an abridged representation. In a sense it doesn't represent the object at all directly, but rather allows the object to substitute a data value that the programmer expects will be useful, based on some insight into the meaning of the object and its data in some context. In this context, that string value is friendly, but in any other context, it's deceptive and inappropriate. In the distribution library, you'll find lots of __repr__ methods and relatively few __str__ methods, I guess because it's relatively unusual to find a string value that's really friendly in a broad enough context for a library class. Now there is no such accounting for the context in which sequences and dicts will be used, they're used everywhere. The string value of these objects should directly represent them as the kind of objects they are, and I think it follows that in this context their contents should be rendered in the same literal way - to substitute __str__ values instead would only compromise that representation. Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From kuncej at mail.conservation.state.mo.us Mon Nov 15 12:43:15 1999 From: kuncej at mail.conservation.state.mo.us (Jeffrey Kunce) Date: Mon, 15 Nov 1999 11:43:15 -0600 Subject: DBF interface Message-ID: >Is there a DBF file interface module ? Yet another python dbf interface. dbfpy.tgz at http://starship.python.net/crew/jjkunce/ --Jeff From gawron at obop.com.pl Mon Nov 29 08:00:49 1999 From: gawron at obop.com.pl (=?iso-8859-1?Q?Przemys=B3aw?= G. =?iso-8859-1?Q?Gawro=F1ski?=) Date: Mon, 29 Nov 1999 14:00:49 +0100 Subject: mktime() ??? Message-ID: <38427901.10B1965D@obop.com.pl> Hello In library reference it's writen, that mktime from time module raises an exeption when it cann't construct a correct time from a tuple parameter. I tryied the following: mktime((1999, 23, 29, 0, 0, 0, 0, 0, 0 )) (the month number is incorect), and mktime((1999, 23, 49, 0, 0, 0, 0, 0, 0 )) (the month, and day aren't correct). Well, neither one of them has raised an exeption. Is it a bug or am'I not understanding somthing in the docs ? Thanks for help Przemek -- Przemyslaw G. Gawronski UIN:8358522 mailto:gawronskip at usa.net mailto:gawron at obop.com.pl From usenet-mm-yyyy at julesallen.com Sun Nov 14 15:56:09 1999 From: usenet-mm-yyyy at julesallen.com (Jules Allen) Date: Sun, 14 Nov 1999 20:56:09 GMT Subject: Proposal: Python Info Collective References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> Message-ID: In article <3d1z9sq2uc.fsf at amarok.cnri.reston.va.us>, Andrew M. Kuchling wrote: | The issue of indexing modules is an old one, and I'm still astounded | that we've never converged on a solution, though everyone always | complains about this. Thanks for the History lesson! This helps put it all in perspective but why *something* hasn't been built before now is kind of weird. The best part of your story for me is confirmation that open source projects don't do well without strong leadership. No ESR or an ESR-like figure to crack the whip, no Trove. | http://www.vex.net/~x/parnassus/ is *very* nice, and it might be the | only solution required. Apparently a good deal of work has been put | into seeding the initial database, and that's important, because it | makes the index immediately useful. Yet I hadn't heard about it until | now; is the site still beta? Did I miss a c.l.py.announce article | about it? The author was still tweaking it when he contacted me after my initial post. I urged him to post the URL for further inspection. But that's not necessary now as it's been outed! Monday morning will be a good test of how robust it really is! By the looks of the vex.net server (Apache/1.3.6 (Unix) PHP/3.0.7), this could well be a straight cgi app so go easy on it. | We need to just pick a solution and stick with it; Parnassus is as | good as any, and has the incalculable advatange of being implemented. See the lazy bit above. I think it's fabulous and it's bookmarked and already soothing my info itch. Cheers, Jules -- Want to reply via email? Put the current month and year in my email address. From ivanlan at callware.com Tue Nov 2 14:14:02 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Tue, 02 Nov 1999 12:14:02 -0700 Subject: Barf Message-ID: <381F37FA.3899AAEF@callware.com> Hi All-- I just noticed something rather interesting. I ran this script: ----------cut here----------------- #!/usr/local/bin/python from Tkinter import * import tkMessageBox import sys def die(): sys.exit(0) def callee(): print "I was called; few are chosen" def about(): tkMessageBox.showinfo("tkmenu","This is tkmenu.py Version 0") root = Tk() bar = Menu(root) filem = Menu(bar) filem.add_command(label="Open...", command=callee) filem.add_command(label="New...", command=callee) filem.add_command(label="Save", command=callee) filem.add_command(label="Save as...", command=callee) filem.add_separator() filem.add_command(label="Exit", command=die) helpm = Menu(bar) helpm.add_command(label="Index...", command=callee) helpm.add_separator() helpm.add_command(label="About", command=about) bar.add_cascade(label="File", menu=filem) bar.add_cascade(label="Help", menu=helpm) root.config(menu=bar) root.mainloop() ----------cut here----------------- It works fine, but if I move the mouse pointer out of the info box (select Help->About) and back to the main window, I get a segmentation violation. This is running on Windows NT 4.0, SP 5; Dell 400MHZ PII Cpu, 128MB ram. It does *not* happen on Windows 98, running the identical version of Python 1.5.2 (latest download, but not CVS). Also, it makes no difference whether I run it 'python tkmenu.py' or just 'tkmenu.py' (using MKS toolkit). Is this a known bug? -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From tony at lsl.co.uk Wed Nov 17 05:12:06 1999 From: tony at lsl.co.uk (Tony J. Ibbs (Tibs)) Date: Wed, 17 Nov 1999 10:12:06 -0000 Subject: ANN: Metalanguage (v0.3) for mxTextTools Message-ID: <0e7401bf30e4$344f1d20$f0c809c0@lslp7o.lsl.co.uk> This is to announce v0.3 (tiepin) of my metalanguage translator for mxTextTools. Marc-Andr? Lemburg provides mxTextTools, a package of fast text manipulation tools for use with Python. The tagging engine within that package takes as input a set of tuples, the Tag Table, which tells it what to do. Although simple in format, these tuples aren't particularly readable, and indeed Marc-Andr? himself says: "I admit, these tables don't look very elegant. In fact I would much rather write them in some meta language that gets compiled into these tables instead of handcoding them. But I've never had time to do much research into this, so unless someone volunteers, it will stay like this for some time." This version of the metalanguage translator implements enough notation to allow its own tag tables to be written in the metalanguage. Although it doesn't yet support various things (notably, strings with escaped quotation marks, function calls, and embedded tables with T/F conditions) it already provides enough power for most of my own needs, and should hopefully be useful to other people. Significant advantages of using the metalanguage are: * it avoids the problem of counting (and recounting) offsets between tuples * it avoids the pitfall of forgetting a comma between two tuples (which on my Windows machine at home is enough to crash Python) * it enforces indentation for meaning in the same way that Python itself does * it provides an "if" construct * obviously, I believe it to be more readable than the bare tuple notation Licensing: I like the Python Powered license at http://starship.python.net/~just/pythonpowered/ so please apply that with suitable amendments. Although Marc-Andr? is aware of this work, it is in no way his fault (apart from the quote above and some helpful comments, for which thanks), so don't blame him... Note that mxTextTools v1.1.1 or later is required to use the translator. The metalanguage description and translator is available at http://www.tibsnjoan.demon.co.uk/mxtext/Metalang.html mxTextTools itself is available at http://starship.python.net/crew/lemburg/mxTextTools.html

Metalanguage v0.3 for mxTextTools - A little language (and its translator) to make it easier to write mxTextTools tag tables. (16-Nov-99) -- Tony J Ibbs (Tibs) tony at lsl.co.uk http://www.tibsnjoan.demon.co.uk/ Feet first with 5 wheels... My views! Mine! Mine! (Unless Laser-Scan ask nicely to borrow them.) From jam at quark.emich.edu Sun Nov 21 03:42:45 1999 From: jam at quark.emich.edu (Jeff) Date: Sun, 21 Nov 1999 03:42:45 -0500 Subject: Order of keyword arguments In-Reply-To: <38379233.ADE65CDB@corrada.com> References: <38379233.ADE65CDB@corrada.com> Message-ID: <19991121034245.A21255@quark.emich.edu> On Sun, Nov 21, 1999 at 01:33:23AM -0500, Andres Corrada wrote: > Hi, > Can one access the order in which keyword arguments were passed to a > function? I want to call a function with the keyword syntax: f( > foo='theFooString', bar='theBarString' ) and use the fact that foo was > listed first so I can do something like: > > def f( **kw ): > > Process keyword arguments remembering the order in which the were used > to call the function. > Print first keyword > Print second keyword > . > . > . > keyword arguments are passed as a dictionary, and thus the 'order' of the arguments will not be preserved. what is the advantage you see to being able to obtain that information? wouldn't a redesign of the interface keep things simpler and increase the likelihood of success? hope that helps. regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From Gaetan_Corneau at baan.com Tue Nov 30 14:06:19 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Tue, 30 Nov 1999 14:06:19 -0500 Subject: WinNT and python as text filter... Message-ID: <816010E2456BD111A48700805FBBE2EEFDF877@ex-quebec-u1.baan.com> > >If so, there is a bug in the NT command prompt - you need to > specify the > >full path to Python.exe on the command line, and it will work... This is exactly the problem I have reported a few months ago. I have access to many tests machines, and two of them had this problem from time to time. After a reboot, it disappeared, and I haven't seen it again since :) ______________________________________________________ Gaetan Corneau Software Developer (Quality Assurance Team) BaaN Supply Chain Solutions http://www.baan.com E-mail: Gaetan_Corneau at baan.com Tel: (418) 266-8252 ______________________________________________________ "Profanity is the one language all programmers know best" From karanvasudeva at usa.net Sun Nov 7 00:31:51 1999 From: karanvasudeva at usa.net (Karan Vasudeva) Date: Sun, 07 Nov 1999 05:31:51 GMT Subject: exec / execfile namespace problem References: <000b8d9b.b9d3bdca@usw-ex0101-003.remarq.com> <1270182562-5943662@hypernet.com> Message-ID: <8032s8$jk4$1@nnrp1.deja.com> Thanks a lot for the advice. I guess since I do know what the code is doing, I really should structure it that way. Thanks, y'all. Karan. In article <1270182562-5943662 at hypernet.com>, gmcm at hypernet.com wrote: > Karan Vasudeva has problems with exec: > > > .... my > > problem is, when i call my script from another script (by doing > > an exec, thats what i need to do, you see), the interpreter stops > > at httplib.py as it can't find that socket called self.sock . > > This appears to be a namespace issue. I just want to know how to > > do this right. > > exec is pretty much only used when you don't know what > you'll be running at the time you wrote it. If you know what > you're running at the time you write it, there's no reason to use > exec. You probably just want: > > import cool > > and maybe: > cool.main(args) > > Many python scripts have the form: > ----------------- > def main(): > # whatever > > def otherthing(): > # stuff used by main, or usable by others > > if __name__ == '__main__': > main() # if invoked as a script, run main() > --------------------------------- > > Then they can run as the top level script, or they can be > imported, and any functions, classes etc. used by the > importer. > > - Gordon > > Sent via Deja.com http://www.deja.com/ Before you buy. From alex at somewhere.around.here Wed Nov 24 23:51:36 1999 From: alex at somewhere.around.here (alex) Date: 25 Nov 1999 15:51:36 +1100 Subject: preprocessor for Python? References: Message-ID: > I'm looking for some macro facilities so I can include debug > statements that are removed when I need to test performance. There was a post a while back where it was stated that the __debug__ variable is evaluated at compile time, and blocks beginning with if 0: are not compiled. So if you set __debug__=0, then any block beginning with if __debug__: will not be compiled into the program. You can probably get the straight dope by searching for __debug__ on deja. HTH. Alex. From steve at acer.spvi.com Tue Nov 2 17:20:28 1999 From: steve at acer.spvi.com (Steve Spicklemire) Date: Tue, 2 Nov 1999 17:20:28 -0500 (EST) Subject: Python director XTra.... cute 'robot' toy for mac In-Reply-To: <199910291511.KAA26339@acer.spvi.com> (message from Steve Spicklemire on Fri, 29 Oct 1999 10:11:55 -0500 (EST)) References: <199910291511.KAA26339@acer.spvi.com> Message-ID: <199911022220.RAA21086@acer.spvi.com> There's a 'start' of a 'robot' toy for the mac at: http://opensource.spvi.com It's a macromedia projector that imports a module (called robots.py) in the movie's folder and uses it to calculate the trajectory of a sprite in the movie. This is really crude, but shows a 'proof of concept' that could be really cool.... The windows version is also (almost) ready. You have to have MacPython installed for this to work. -steve From gerrit.holl at pobox.com Mon Nov 1 14:31:20 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Mon, 1 Nov 1999 20:31:20 +0100 Subject: C-Python tutorial? Message-ID: <19991101203120.A29797@optiplex.palga.uucp> Hello, I have learned python as my first langauge some time ago. Is there a C tutorial for python programmers, that covers C programming, espaccialy for extending it with python? I think not. Can anyone write one? I would be very grateful! regards, Gerrit. -- linuxgames.nl.linux.org All about games on Linux in Dutch (under construction). www.nl.linux.org The Dutch resource for Dutch Linux documentation. www.nl.linux.org/discoverb Learn foreign words and definitions. www.nl.linux.org/~gerrit/asperger I'm an Asperger, go here for more info. www.nl.linux.org/~gerrit About me and pictures of me. From pjensen at columbus.rr.com Thu Nov 4 01:32:50 1999 From: pjensen at columbus.rr.com (Philip H. Jensen) Date: Thu, 4 Nov 1999 01:32:50 -0500 (EST) Subject: Python and Literate Programming Message-ID: Greetings. I'm a recent convert to Python, and wish I had looked into it years ago. As I said in a posting on my local Linux UG's mailing list, "I like everything about Python, whereas there are many things about Perl that I don't like." Incidentally, I'm also a booster for Modula-3, and of course Python has well-known and intentional similarities to M3. But one of my other enthusiasms is Literate Programming, and I'm wondering about the possibilities for it in Python. Documentation texts can be easily accomodated, as can pretty-printing. But for me, the core of LP, which I use (e.g. in CWEB) even if I never run the program through CWEAVE, is >> factoring <<. Here's how it might look in a Python-friendly form. if not dictionary.has_key(word): then elsewhere in the program: : code... *** Now, personally I would like to see this in the language itself, but that seems unlikely. What would be essential, though would be 1) a hook whereby "import foo" would see if there was a "foo.pyw" more recent than "foo.py", and if so, would invoke a pytangle program, and 2) a means for file and line information to be passed along, so that error messages would refer to the .pyw source. Any interest? If I myself were to work on patches along these lines, could they become candidates for inclusion in the mainstream source tree? (I have some other Python development ideas, but will save them for later postings.) Phil Jensen pjensen at columbus.rr.com From x at x.x Mon Nov 29 17:35:36 1999 From: x at x.x (Eric Jacobs) Date: Mon, 29 Nov 1999 17:35:36 -0500 Subject: performance of tuple-less Python? References: "Greg Wilson"'s message of "Mon, 29 Nov 1999 11:29:30 -0500" <1268223702-30481186@hypernet.com> Message-ID: <3842FFB8.C2146DCE@x.x> Gordon McMillan wrote: > > I'm guessing that not being able to find something you stuck > in the dictionary qualifies as a performance penalty ;-). > > To spell it out: > 1) hash based on id(list_object): > d = {[1] = 'x'} > d[[1]] -> KeyError Actually, this behavior can be useful at times. I was working on a graphviz grapher to plot Python's internal ASTs. If I converted them to lists, Python would complain becauses lists are not hashable. But when I used tuples, I saw that Python was cleverly performing common subexpression analysis. So that in f(x + 1, x + 1, x + 1) there would be only one subtree representing "x + 1", pointed to three times. I had to explicitly state the id() operation to get it to the way (I thought) it should look. > 2) hash based on value: > lst = [1] > d[lst] = 'x' > lst.append(2) The penalty would be that the dictionary would have to be reindexed at this point, because the hash and compare behavior of lst would have changed. > d[lst] -> KeyError > > - Gordon From guido at cnri.reston.va.us Wed Nov 3 17:24:55 1999 From: guido at cnri.reston.va.us (Guido van Rossum) Date: Wed, 03 Nov 1999 17:24:55 -0500 Subject: Python Conference Hotel Change Message-ID: <199911032224.RAA10668@eric.cnri.reston.va.us> The Foretec conference staff has this message about the upcoming Python conference: Due to construction delays, the Hilton Alexandria Old Town will not be completed in time for the Eighth International Python Conference. However, we are pleased to announce that we have secured an equally desirable facility for the conference. The new facility is the Key Bridge Marriott in Arlington, Virginia. The Key Bridge Marriott is conveniently located on the Virginia side of the Key Bridge in the Rosslyn business district with easy access to restaurants, shops, and the Rosslyn metro stop. It overlooks the Potomac River, and is a 15 minute walk across the bridge to historic Georgetown in Washington, DC. (I should add that Georgetown is, if possible, an even better location than old town Alexandria for the typical Python conference evening activities. --Guido :-) --Guido van Rossum (home page: http://www.python.org/~guido/) From billtut at microsoft.com Wed Nov 10 07:38:00 1999 From: billtut at microsoft.com (Bill Tutt) Date: Wed, 10 Nov 1999 04:38:00 -0800 Subject: Using GNU C complier as the "default" windows complier Message-ID: <4D0A23B3F74DD111ACCD00805F31D8100DB9151B@RED-MSG-50> cygwin isn't thread safe at this moment in time. If anything, Python should be compiled using mingw32 instead of cygwin. Esp, in order to get the Win32 extensions to be useful. However.... I have no idea if the Win32 extensions actually can be compiled successfully using mingw32 as a substantial portion of them are C++, and even if they could be compiled, there would be binary incompatability problems due to using C++. (C++ mangling is different for all C++ compilers...) So given those two things, and neither Mark, I, or anybody else atm seems to care enough to bother trying to see if it'll work. The binary compatability problem is the biggest problem though. If a MSVC compiled Python install can't make use of a mingw32 Win32 extension DLL (or vice versa) then even bothering with trying becomes counter productive. (unless your willing to invest time in submitting changes to the source code to remove the C++ mangling issues) i.e. Turn all exported C++ objects into COM objects or something so you can just use COM vtbls to communicate. Needless to say, thats a lot of work that I'd rather not do. (I expect Mark won't be to gung ho to do that work either... :) ) Bill > -----Original Message----- > From: Werner Fouche [mailto:wfouche at mindspring.com] > Sent: Wednesday, November 10, 1999 3:59 AM > To: python-list at python.org > Subject: Re: Using GNU C complier as the "default" windows complier > > > > "Mike Callahan" wrote in message > news:ma4W3.7794$Ur4.223420 at news.rdc1.tn.home.com... > > This a question from a newbie but I was thinking...why > doesn't the default > > Python code for windows use the GNU C complier for windows > instead of the > MS > > complier. Would it be possible to distribute the GNU > package along with > the > > Python package and thus make it easier to compile, extend, and embed > Python, > > use freeze, etc? I know it would take some work, but it > seems it would > make > > windows Python a lot more like unix Python. Just a thought... > > > > > > I had the same idea on the weekend. So I installed Cygwin > (http://www.cygnus.com/cygwin) on my NT system and after running > "./configure" got Python to compile and run. However, I could > not get Python > threads to work. > > > > -- > http://www.python.org/mailman/listinfo/python-list > From thamelry at vub.ac.be Wed Nov 24 08:32:21 1999 From: thamelry at vub.ac.be (Thomas Hamelryck) Date: 24 Nov 1999 13:32:21 GMT Subject: Python complaints References: <81gj3i$fe3$1@mach.vub.ac.be> <005201bf367e$4901fef0$f29b12c2@secret.pythonware.com> Message-ID: <81gpd5$332$1@mach.vub.ac.be> Fredrik Lundh (fredrik at pythonware.com) wrote: : Thomas Hamelryck wrote: : > I don't want to start the discussion about indentation again; it's no use : > since indenting blocks is here to stay. The point is that if you want to : > write code that looks ugly or unreadable you will succeed in doing that, : > indentation or not. In many cases, using a variable indentation (depending : > on what construct you are using or the length of a line) leads to code : > that is visuably much more appealing. : you make that sound like a scientific fact. can : you point us to some research, or is it just yet : another random opinion? Eh...this is my opinion, yes. Do you call everything you don't agree with a "random opinion"? Of course it is not a "scientific fact": readability of code is in the eye of the beholder to a great extent. When it comes to private attributes in python we are all "consenting adults", but when it comes to code readability the indentation rules need to be enforced. I think there's a contradiction here. But again, I am very fond of python despite the indentation rules. : (if it is, we simply disagree. and for the record, : my opinion is based on many years of experience : from using Python with casual programmers, and : from hacking in huge Python programs written by : other programmers... what's your opinion based : on?) On using python myself (for about a year now) and looking at other people's code. Again I'd like to mention that Python's advantages far outweigh the strict indentation rules. Cheers, -- Cheers, ------------------------------------------------ Thomas Hamelryck//Free University Brussels (VUB) Intitute for Molecular Biology// ULTR Department Paardestraat 65//1640 Sint-Gensius-Rode//Belgium ------------------------------------------------ From nikolai at micon.no Tue Nov 9 18:19:43 1999 From: nikolai at micon.no (Nikolai Kirsebom) Date: Wed, 10 Nov 1999 00:19:43 +0100 Subject: MS Word COM error w/ Borders property References: <38289ED8.9BA2645A@alliedsignal.com> Message-ID: Try the following: for i in range(word.ActiveDocument.Tables(1).Borders.Count): print word.ActiveDocument.Tables(1).Borders(i+1).LineStyle and you'll have all the line styles of the first table in your active document. Nikolai From fdrake at acm.org Fri Nov 5 11:08:19 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Fri, 5 Nov 1999 11:08:19 -0500 (EST) Subject: __str__ vs. __repr__ In-Reply-To: References: <199911041325.IAA14001@eric.cnri.reston.va.us> Message-ID: <14371.243.373402.279764@weyr.cnri.reston.va.us> Just van Rossum writes: > As a step towards a Unicode-savvy Python, would it be an idea to define > Unicode versions of repr(), str(), ob.__repr__() and ob.__str__()? Perhaps it would be more useful for file objects to offer an attribute or query method that allowed client code to determine if the stream supports unicode? -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From a.eyre at optichrome.com Mon Nov 15 09:27:18 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Mon, 15 Nov 1999 14:27:18 -0000 Subject: [Python] header (fwd) In-Reply-To: <1269958983-19391623@hypernet.com> Message-ID: <002a01bf2f75$85166620$3acbd9c2@peridot.optichrome.com> > Huh? I filter (in Pegasus mail) on "python-list@" in To: and > CC: and get them all. I filter "From:" for "python-list-admin at python.org" Does that not work? -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From gawron at obop.com.pl Thu Nov 25 04:18:29 1999 From: gawron at obop.com.pl (=?iso-8859-2?Q?Przemys=B3aw?= G. =?iso-8859-2?Q?Gawro=F1ski?=) Date: Thu, 25 Nov 1999 10:18:29 +0100 Subject: Listing a dictionary Message-ID: <383CFEE5.951376A0@obop.com.pl> How can I list all the keys in a dictionary ? Thank you Przemek -- Przemyslaw G. Gawronski UIN:8358522 mailto:gawronskip at usa.net mailto:gawron at obop.com.pl From pinard at iro.umontreal.ca Mon Nov 1 19:09:33 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 01 Nov 1999 19:09:33 -0500 Subject: Produce .pyc without execution In-Reply-To: Michael Hudson's message of "01 Nov 1999 21:29:34 +0000" References: <002001bf244e$8e187600$3acbd9c2@peridot.optichrome.com> Message-ID: Michael Hudson writes: > I think installing .pyc's but not .py's is mischevious, if only > because meaningful tracebacks are nice. We have to be careful in our search for virtue. Richard Stallman always wanted packages to install un-stripped binaries, for reasons like above. The disk space it takes, as well as the principle, is not very acceptable for a lot of users, and Linux packagers defeat it quite systematically, so far that I know. It surely required a lot of doing and many fights (I do know some of them :-) before the thing could be done with more ease than difficulty within GNU, and I've been told that some of the last problems are going to be solved in the next release of Autoconf, if not already. I do not follow this file closely anymore, now, as helping GNU is too exhausting. My opinion is that quality packages should not traceback anyway, and rather produce their own user-oriented diagnostics. The installation process should be oriented more towards users than towards debugging, for anything else than alpha software. Even for Emacs, Linux packagers set things so LISP sources are optional. Oh, no doubt that having sources installed is a good things for many users, but in the long run, we are going to have more and more users who are not especially programmers, or not especially interested in the inner details of everything they use, so we should silence our natural proselytism :-). > > What would be ideal is a way for `compile_dir' to produce `.pyc' in > > the build hierarchy directly from the source hierarchy at `make all' > > time, and that `make install' just move these ready `.pyc' files into > > the installation directories. > It shouldn't be all that hard to adapt Lib/py_compile.py & > Lib/compileall.py as appropriate to effect this. I hope that people responsible for these packages are listening! :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From mwh21 at cam.ac.uk Tue Nov 23 18:06:31 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 23 Nov 1999 23:06:31 +0000 Subject: whrandom seed question References: <81eu22$411al$1@umbc7.umbc.edu> Message-ID: kyriacou at umbc.edu (Stelios Kyriacou) writes: > Hi, > > I tried today the random number generator in python > and have the following question: > > Shouldn't the following 3 lines produce the same number? > > >>> whrandom.seed(0,0,0); print whrandom.random() > 0.39613674715 > >>> whrandom.seed(0,0,0); print whrandom.random() > 0.170188890936 > >>> whrandom.seed(0,0,0); print whrandom.random() > 0.831213988577 > >>> Use the source luke! >From /usr/lib/python1.5/whrandom.py: def seed(self, x = 0, y = 0, z = 0): if not type(x) == type(y) == type(z) == type(0): raise TypeError, 'seeds must be integers' if not (0 <= x < 256 and 0 <= y < 256 and 0 <= z < 256): raise ValueError, 'seeds must be in range(0, 256)' if 0 == x == y == z: # Initialize from current time import time t = long(time.time() * 256) t = int((t&0xffffff) ^ (t>>24)) t, x = divmod(t, 256) t, y = divmod(t, 256) t, z = divmod(t, 256) # Zero is a poor seed, so substitute 1 self._seed = (x or 1, y or 1, z or 1) So >>> whrandom.seed(1,1,1); print whrandom.random() 0.0169309061997 >>> whrandom.seed(1,1,1); print whrandom.random() 0.0169309061997 >>> whrandom.seed(1,1,1); print whrandom.random() 0.0169309061997 as expected. > Am I missing something??? New one on me that! You'd think None would be a better default. Regards, Michael From reic0024 at ub.d.umn.edu Tue Nov 16 10:16:44 1999 From: reic0024 at ub.d.umn.edu (Aaron J Reichow) Date: Tue, 16 Nov 1999 09:16:44 -0600 Subject: Directory chooser in Tk In-Reply-To: <14385.23296.680071.39959@gargle.gargle.HOWL> References: <38304E78.F92C8596@callware.com> <19991116071917.A711753@vislab.epa.gov> <14385.23296.680071.39959@gargle.gargle.HOWL> Message-ID: > > |I need a dialog similar to the askopenfilename() dialog, but for > > |directories. Is there such a beast? > > I needed the same thing. I just wound up using askopenfilename(), choosing any file in the directory I wanted, and then using os.path.split() to dump the name of the file and retain the path in another variable. Not elegant, but it works. Aaron From akuchlin at mems-exchange.org Tue Nov 30 15:05:09 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 30 Nov 1999 15:05:09 -0500 Subject: '==' vs. 'is' behavior References: <382C2C6A.64A8F2C2@theriver.com> <14380.12036.197083.409565@weyr.cnri.reston.va.us> <8E7F86267duncanrcpcouk@news.rmplc.co.uk> <015301bf3b0a$685a3fc0$f29b12c2@secret.pythonware.com> Message-ID: <3dbt8bhhje.fsf@amarok.cnri.reston.va.us> Fran?ois Pinard writes: > I'm a bit minimalist while programming. Or, to say the same thing another > way, I rather like Arvo Part's music. When a program source is just In the article at http://www.itknowledge.com/tpj/issues/vol1_1/tpj0101-0002.html (excerpted in Linux Journal, Larry Wall writes, as part of an extended metaphor: And languages specialize in other ways: BASIC is like pop music. Tune into REXX for your easy listening classics. Tcl is fuzzy like jazz - you get to improvise a lot, and you're never quite sure who is interpreting what. Python is like MTV - it rocks, but it gets to be much of a sameness after half an hour or so. (Out-of-context quoters can have fun by inserting ellipses after "it rocks". :) ) At the time I thought the Python comparison was a bit odd, and didn't really see the point. Python is more like a collection of tiny interacting modules; no one module is very complicated, but put them together and they intermesh and interweave in a beautiful way over time. [1] Over time the modules fall together in slightly different patterns, and, though the difference between iterations is slight, the resulting shift can completely change the effect of the whole piece. Ergo, Python is a Steve Reich composition. [2] -- A.M. Kuchling http://starship.python.net/crew/amk/ Persichetti could do everything and do it well, but you didn't really care. -- Steve Reich, on his former composition teacher Vincent Persichetti [1] I imagine Lisp and Scheme fans think of programs in those languages in an analogous way. [2] A comparison to Terry Riley's "In C" would be even closer -- it's an open score where each musician has a melody, and they play it as often as they like, whenever they like, as long as they don't stray too far from the path -- but I like Reich better. From mcfletch at vrtelecom.com Tue Nov 2 22:34:21 1999 From: mcfletch at vrtelecom.com (Mike Fletcher) Date: Tue, 2 Nov 1999 22:34:21 -0500 Subject: Addition to documentation: Zen of Python, was( RE: Comparison between Python and "Ruby" ) In-Reply-To: <381F9EB4.63FA033F@python.net> Message-ID: Okay, that reminds me, when is this going to make it into the official documentation? If it were me, I'd put it right onto the first page (doc/index.html) of the official docs, right under the listing of available documents ;) . It does such a great job of getting people into the "frame" of Python (at least those with some background in computer programming). So, how about it? And lets start a Python monastery somewhere, I'd look great in a black-and-green robe ;) , Mike ... Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those! -- Tim Peters From mwh21 at cam.ac.uk Mon Nov 1 16:24:12 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 01 Nov 1999 21:24:12 +0000 Subject: __str__ vs. __repr__ References: <19991101121709.A134039715@vislab.epa.gov> <19991101202118.B29736@optiplex.palga.uucp> Message-ID: Gerrit Holl writes: > Randall Hopper wrote: > > > > 1) Is there a convention for what __str__ and __repr__ should return for > > classes? > > __str__ should return a string, __repr__ may also return, for example, a > dictionairy. Ehh? No, I don't think so: >>> class Class: ... def __repr__(self): ... return {} ... >>> Class() Traceback (innermost last): File "", line 1, in ? TypeError: repr not string >From the reference manual (which I could paraphrase, but there'd be no real point): __repr__ (self) Called by the repr() built-in function and by string conversions (reverse quotes) to compute the ``official'' string representation of an object. This should normally look like a valid Python expression that can be used to recreate an object with the same value. By convention, objects which cannot be trivially converted to strings which can be used to create a similar object produce a string of the form "<...some useful description...>". __str__ (self) Called by the str() built-in function and by the print statement to compute the ``informal'' string representation of an object. This differs from __repr__() in that it does not have to be a valid Python expression: a more convenient or concise representation may be used instead. The idea is that eval(repr(x)) == x should be true as much as is possible, whereas str(x) should be fit for human consumption. > > 2) Or, whatever they return, should they return the same value? It's worth noting that the *only* type I know of that has a different `str' to its `repr' is the string type: >>> print str("hello") hello >>> print repr("hello") 'hello' Regards, Michael From gerrit.holl at pobox.com Sat Nov 20 07:06:49 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Sat, 20 Nov 1999 13:06:49 +0100 Subject: Naming: fp In-Reply-To: References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> Message-ID: <19991120130649.A18627@optiplex.palga.uucp> Hello, > A file object fp that points to the mailbox file. Why is a file object often called 'fp'? -- "We all know Linux is great...it does infinite loops in 5 seconds." (Linus Torvalds about the superiority of Linux on the Amterdam Linux Symposium) From mikael at isy.liu.se Fri Nov 5 06:49:08 1999 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 05 Nov 1999 13:49:08 +0200 (MET) Subject: Apply a function to each list member? In-Reply-To: <19991105215504.A497@Ridcully.home> Message-ID: On 05-Nov-99 Malcolm Tredinnick wrote: > Correct. In fact, since we're being precise, let me point out that > (mathematically speaking), all functions are maps (or mappings), but not > all mappings are functions. The point is that a function should have only a > single "output" for any given input (i.e. it should be many-to-one or > one-to-one, not one-to-many). So some mapping that sends, say, the number 2 > to the numbers 3 and 4 is not a function (but a mapping that sends both the > numbers 3 and 4 to the number 2 is a function, since for each input there > is only a single output). Ahh, there we got it. Good thing someone has got it straight. > (Hmm .. I've just realised that a few of my recent postings have had > amazingly little to do with Python. I promise to stick to the topic from > now one. Swear! :-) ) I-think-I-should-get-in-line-ly y'rs /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: 05-Nov-99 Time: 13:47:18 This message was sent by XF-Mail. ----------------------------------------------------------------------- From dnagata at creo.com Sat Nov 13 17:14:46 1999 From: dnagata at creo.com (Dale Nagata) Date: Sat, 13 Nov 1999 14:14:46 -0800 Subject: finding out console user (Win95) References: <941814380.235290@cdwork.cvt.stuba.sk> Message-ID: <382DE2D6.29D1@creo.com> Radovan Garabik wrote: > > I am porting my script from unix to windows, and I need to find > console user under win95 (under WinNT I can use os.environ['USERNAME'], > which is not exactly console user, but good enough for me). > Something like cuserid() or getlogin() as implemented in > Cygwin would be ideal.... > Is there a simple way to find it? > The following should work on both Win95 and NT: import win32api print win32api.GetUserName() This will get the correct account name even if the USERNAME environment variable is set to something different. -- Dale Nagata | tel : +1 604.451.2700 ext. 2254 (UTC-0800) Software Developer | fax : +1 604.437.9891 Creo Products Inc. | pgr : +1 604.691.8279 Burnaby BC Canada | http://www.creo.com/ From tre17 at student.canterbury.ac.nz Tue Nov 16 21:37:01 1999 From: tre17 at student.canterbury.ac.nz (Tim Evans) Date: 17 Nov 1999 15:37:01 +1300 Subject: problems with __getattr__ & __setattr__ References: <3F8BA119B48AD11197470008C7A493CB98B67D@HQOBGEX1> Message-ID: ScherBi at BAM.com writes: > I am having trouble using __getattr__ and __setattr__ in some classes. I've > boiled it down to the code below. > It dumps core under 1.5.2 on Linux or WinNT. > > I think maybe it's looping, if so, how does one go about doing this? > (I'm assuming it's clear enough what I'm trying to do.) > > If I comment out the __gettattr__ operation, it doesn't dump core. Instead > I get an AttributeError: eggs raised at the 'self.eggs[key] = value' call in > __setattr__. This is what leads me to belive there's something circular > going on here. > > > Thanks, > Bill > > -------------------------------------------- > class spam: > > def __init__(self): > self.eggs = {} > > def __getattr__(self, key): > try: > return self.eggs[key] > except: > raise > > def __setattr__(self, key, value): > try: > self.eggs[key] = value > return 0 > except: > raise > > if __name__ == '__main__': > > s = spam() > print 'instance of spam created.' > ----------------------------------------------- I think I see the problem here. In __init__ you try to set an attribute (self.eggs = {}), which will cause __setattr__ to be called. In __setattr__ you get the eggs attribute, which does not exist, so the attribute access is passed to __getattr__. In __getattr__ you access the eggs attribute again, which as it does not exist will again be passed to __getattr__, causing an infinite loop. To demonstrate this add a print statement at the start of each method that prints the name of the method. The result is: ----------------------------- % python broken.py __init__ __setattr__ __getattr__ __getattr__ __getattr__ __getattr__ __getattr__ __getattr__ __getattr__ ... zsh: segmentation fault python broken.py ----------------------------- To solve this problem I would recommend not using __getattr__ and __setattr__ unless you really need it. If you don't want to use s.eggs['foo'] then you could define __setitem__ and __getitem__ to shorten this to s['foo'] -- Tim Evans From init__self at my-deja.com Mon Nov 8 11:21:48 1999 From: init__self at my-deja.com (Python Addict) Date: Mon, 8 Nov 1999 11:21:48 -0500 Subject: IPC8: Call the 800 number! Message-ID: <3826f6ac.0@news.bestsoftware.com> There seems to be a problem between the chairs and the keyboards at the 703-524-6400 Key Bridge Marriott hotel -- the reservation agents don't seem to know about the conference and were unable to speak to anybody that did. Therefore they wouldn't honor the $129 rate. I even tried rep fishing but got the same person again (bah!). However, the 800 number *does* know about the conference and was more than happy to take my money. You might want to try them first. From mhammond at skippinet.com.au Tue Nov 2 17:43:37 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 3 Nov 1999 09:43:37 +1100 Subject: Reading .lnk files In-Reply-To: <381F5CD1.8714622F@callware.com> Message-ID: <004301bf2583$b47a7150$0501a8c0@bobcat> Sure is. For more details, see the COM help file on PyIShellLink. Mark. # DumpShortcut.py # A demo of how to dump a shortcut using Python. # This code dumps the shortcut specificed as sys.argv[1] from win32com.shell import shell import pythoncom def DumpIt(fileName): # Get the shell interface. sh = pythoncom.CoCreateInstance(shell.CLSID_ShellLink, None, \ pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink) # Get an IPersist interface persist = sh.QueryInterface(pythoncom.IID_IPersistFile) persist.Load(fileName) # Get the data print "Path name:", sh.GetPath(shell.SLGP_SHORTPATH)[0] print "Args:", sh.GetArguments() print "Description:", sh.GetDescription() print "Working directory:", sh.GetWorkingDirectory() if __name__=='__main__': import sys DumpIt(sys.argv[1]) # demo of usage: C:\>DumpShortcut.py IDLE.lnk Path name: L:\src\PYTHON~1.2\PCbuild\pythonw.exe Args: l:\src\python-cvs\tools\idle\idle.pyw Description: Working directory: L:\src\python-cvs\tools\idle From piers at cs.su.oz.au Wed Nov 24 23:10:15 1999 From: piers at cs.su.oz.au (Piers Lauder) Date: Thu, 25 Nov 1999 15:10:15 +1100 Subject: threading and timeouts Message-ID: <943504970.076.346131773@cs.usyd.edu.au> Are timeouts possible inside threads? Eg: escaping from an attempt to use smtplib.SMTP().sendmail() inside a child thread if the remote host is being extremely slow. It doesn't seem possible to use the traditional signal(SIG_ALRM,...) approach because signals only work inside the main thread. The only option I can think of is to re-write the smtplib module to use `select', but does anyone know of a simpler solution? From jsight at mindspring.com Tue Nov 30 21:14:58 1999 From: jsight at mindspring.com (Jesse D. Sightler) Date: Tue, 30 Nov 1999 21:14:58 -0500 Subject: Python complaints References: <81bmmi$279$1@nnrp1.deja.com> <3841EE77.6B5D6AC9@wjk.mv.com> <38435C43.B238EC15@mindspring.com> Message-ID: <384484A2.AF4BE448@mindspring.com> Michael Hudson wrote: > > wware-nospam at world.std.com (Will Ware) writes: > > > Will Ware wrote: > > > I find myself grumbling about having to type "x = x + 1". The really > > > clean thing to do, given that integers are objects, would be to define > > > increment and decrement methods, so you'd type something like "i.incr()". > > > > Jesse D. Sightler (jsight at mindspring.com) wrote: > > > Wouldn't this be impossible, since Integers are also immutable? So, eg, > > > i.incr() could only return an incremented version of i, but not actually > > > increment i? > > > > Right, this is what Gordon was pointing out. A "++" method could not > > magically reach out of its object, find the "i" variable, and bind it > > to the incremented value. > > Hate to be awkward, but when it comes to things like this, there's > very little like this that can't be done in Python! > > >>> def incr(var): > try: > raise 1/0 > except ZeroDivisionError: > import sys,dis > f = sys.exc_traceback.tb_frame.f_back > loadins = f.f_code.co_code[f.f_lasti - 3:f.f_lasti] > loadop = ord(loadins[0]) > name = dis.opname[loadop] > loadarg = ord(loadins[1]) + 256*ord(loadins[2]) > vname = f.f_code.co_names[loadarg] > f.f_locals[vname] = f.f_locals[vname] + 1 > > > >>> x=1 > >>> incr(x) > >>> x > 2 Ack, and I though Perl was the only language that made you do stuff like that. :) Could you please explain this little piece of code? It sure looks like byte-code dependant, self-modifying crazyness to me. :) --------------- Jesse D. Sightler http://www.biddin.com/delorean/ From Gaetan_Corneau at baan.com Thu Nov 25 10:46:27 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Thu, 25 Nov 1999 10:46:27 -0500 Subject: Python and COM: a bug? (long) Message-ID: <816010E2456BD111A48700805FBBE2EEFDF831@ex-quebec-u1.baan.com> Mark, I got help and traced the C++ code. Here's a partial description of the COM object hierarchy. ITK.AdapterManager (Root class) | | ITKAdapter (Used to connect to data sources. Ex: OLEDB) | | ITKConnection (Actual connection to data source) | | ITKClass (Meta-data) | | ITKDataObject (Actual data) Here is a small example of usage. Suppose tou have an Oracle database you want to access using OLEDB. In that database, you have an employee table, with the following fields: Name, address, ID, etc. To get a list of all employees names, I write: fromwin32com.client.dynamic import Dispatch am = Dispatch("ITK.AdapterManager") ad = am.GetAdapter("OLEDB") Conn = ad.NewConnection() Conn.Open("/dsn:HPD380 /user:gc /pwd:qwerty") for Employee in Conn.Classes("Employee").GetObjects(): print Employee.Name What do we use all that for? In an integration server that manipulates abstract data, reading from a source, writing to a destination. The server lets you define data magppings graphically (for simple one to one field mapping). All that stuff has nothing to do with COM. The objects containing the data are C++ object. But when the mapping is complex, we create a COM wrapper over those C++ object (ITKDataObject) and send them to a script using ActiveX Scripting. So, the problem is this. When I access "Employee.Name", I get the ID for the Name property of Employee, but the Python COM caches it for ITKDataObject (which, according to what Bill and you told me, is OK). If I access the name property from another object (I mean another table), say department, then the pythoncom tries to access the property usinf the ID generated on the fly by Employee. > Yes - VBScript does indeed re-query for the DISPID before each call - > ie, it does not cache the items. I would put money on the fact that > this is your problem. > > I am quite confident that we do not have anything this fundamental > broken. So our code is not OK. You are right, I was wrong. I'm glad I didn't bet, and, more important, I'm glad I have enough experience to fall in finger-pointing mode. I was *quite* sure our code was OK, but I would have been a fool if I had said I was 100% sure :) > If it is the problem, you are clearly breaking the rules, and there is > a good chance that later versions of VBScript, or indeed any other COM > compatible language would also break. Now, this is a potentially severe bug. For the time being, the integration server is "locked" so all scripts must be written in VBScript, but it may not be so in future version. Another thing that could go wrong is that there is a new version of VBScript available. I haven't tried it yet, but I will: maybe this version uses caching. > ob = pythoncom.CoCreateInstance("Your.ProgID", None, pythoncom.CLSCTX_ALL, pythoncom.IID_IDispatch) > > dispid = ob.GetIDsOfNames("foo") > print dispid > > dispid2 = ob.GetIDsOfNames("foo") > print dispid2 > > if dispid != dispid2: > print "Eeek" That test would be useful (I would put it as an attachment to my bug report) if I could make it work with the architecture I described earlier. I mean, I must compare dispids from ITKDataObjects. I tried Employee.GetIDsOfNames("Name"), but I get: File "d:\Apps\Python\win32com\client\dynamic.py", line 400, in __getattr__ raise AttributeError, "%s.%s" % (self._username_, attr) AttributeError: .GetIDsOfNames I tried a couple of things (like QueryInterface), but nothing worked. Anyway, thanks a lot for your help! I have endured this bug for six months without being able to point what the problem was! Thanks, ______________________________________________________ Gaetan Corneau Software Developer (Quality Assurance Team) BaaN Supply Chain Solutions http://www.baan.com E-mail: Gaetan_Corneau at baan.com Tel: (418) 266-8252 ______________________________________________________ "Profanity is the one language all programmers know best" From donn at oz.net Sun Nov 7 13:53:53 1999 From: donn at oz.net (Donn Cave) Date: 7 Nov 1999 18:53:53 GMT Subject: open( "file","mode") difference between script and commandline? References: <941942257@bigfoot.com> Message-ID: <804hs1$jm2$0@216.39.151.169> Quoth Michael Praschl : | im using python 1.5.2 for BeOS Life can be sweet! | and im having a problem with file opening. when i use | | >>> f = open( "filename","w" ) | | in the command line interface, this works perfectly ok. but when i use | the same function from a script, i get the following error: | | Traceback (innermost last): | File "Signmail.py", line 19, in ? | f = open( "/tmp/workfile", "w" ) | TypeError: illegal argument type for built-in operation | | can anybody tell me why this is? and what i can do about it? Yes, but it's just lucky that you handed us the clue in the next question. You apparently start your program with from os import * Now this imports an "open", the POSIX 1003.1 open() function whose arguments are (string, int [, int]) You may want to use this function some day, but what you should do the minute you read this message is remove all "from module import *" from your programs and start fixing up the module references. The problem you just had is a terrific example of the pernicious problems posed by this practice. | the second problem i found while i was trying to get around this. i have | a multiline string (linefeeds) in the variable reply, and want to do the | following: | | system( "echo >/tmp/pgpBeMail `reply`" ) #reply is within this "\" | apostrphys (in case the newsreaders cant show them correctly) | | in this case the file is empty after the call. i tried also turning to | this "/" apostrophys and to normal ones, but then the file contains | "reply" as expected, but not the contents of "reply" [Of course this will be os.system() once you've fixed that.] Python string quoting isn't the art it is with some other more shell-like interpreted languages. You quote to get a string, and then what's inside the quotes is pretty much the literal contents of the string, there's no provision for evaluating variables in there. So the shell got your ` intact, and tried to execute "reply", since that's its cue for a command expansion. Now the string you need here should to include its own quotes around the data you want to echo, to keep the shell from getting tangled up interpreting that data - so you want the system() call to look like system( "echo > /tmp/pgpBeMail 'some reply data'" ) And note that echo will add a newline to the end anyway. So a couple of ways to generate this might be os.system("echo > /tmp/pgpBeMail '%s'" % reply) os.system("echo > /tmp/pgpBeMail '" + reply + "'") Donn Cave, donn at oz.net From gmcm at hypernet.com Thu Nov 25 08:16:12 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 25 Nov 1999 08:16:12 -0500 Subject: Python complaints In-Reply-To: <19991125141028.G17130@longford.cs.monash.edu.au> References: <383D1AA2.35E8F0EC@compaq.com>; from Greg Ewing on Fri, Nov 26, 1999 at 12:16:50AM +1300 Message-ID: <1268586725-8644924@hypernet.com> Toby J Sargeant wrote: > Just throwing this up in the air, and seeing what comes back... > > class Acquire: > def __init__(self,lock): > self.lock=lock > lock.acquire() > > def __del__(self): > self.lock.release() > > def function(mutex): > _a=Acquire(mutex) > # do stuff. > > It relies on Acquire.__del__() being called as soon as _a goes > out of scope, but that doesn't seem likely to change for the > moment. (Of course doing this in JPython is a recipe for > disaster... or at least extreme inefficiency) > > It also has the advantage that you can exit the function in many > ways (including by exception), and the lock will be released > regardless. Most unfortunately, exiting by exception will foul you up because the traceback will have a reference to the Acquire instance. You can clear it when you catch the exception, but since the consequences of forgetting to do that are both disastrous and mysterious, I think this idiom is best left to C++ (where I use it all the time). - Gordon From R.M.Everson at ex.ac.uk Tue Nov 2 09:25:34 1999 From: R.M.Everson at ex.ac.uk (R.M.Everson) Date: Tue, 2 Nov 1999 14:25:34 GMT Subject: Drawing (directed) graphs Message-ID: Hello, Does anyone know of Python code for drawing graphs of the graph-theoretic type? Ideally, I'd like to be able to interactively add nodes and edges etc and add data to structures associated with the nodes and edges. Many thanks Richard Everson. -- Exeter University R.M.Everson at ex.ac.uk http://www.dcs.ex.ac.uk/academics/reverson From thamelry at vub.ac.be Wed Nov 24 06:44:50 1999 From: thamelry at vub.ac.be (Thomas Hamelryck) Date: 24 Nov 1999 11:44:50 GMT Subject: Python complaints References: Message-ID: <81gj3i$fe3$1@mach.vub.ac.be> Mikael Olofsson (mikael at isy.liu.se) wrote: [snip] : I prefer to write readable, understandable code. To me, that means=20 : (among other things) indenting blocks. Hence, I already indent blocks : in every programming language, if the language allows me to. So, block=20 : delimiters like begin...end or {} are simply redundant to me. [snip] I don't want to start the discussion about indentation again; it's no use since indenting blocks is here to stay. The point is that if you want to write code that looks ugly or unreadable you will succeed in doing that, indentation or not. In many cases, using a variable indentation (depending on what construct you are using or the length of a line) leads to code that is visuably much more appealing. Cheers, ------------------------------------------------ Thomas Hamelryck//Free University Brussels (VUB) Intitute for Molecular Biology// ULTR Department Paardestraat 65//1640 Sint-Gensius-Rode//Belgium ------------------------------------------------ From claird at starbase.neosoft.com Tue Nov 30 18:14:31 1999 From: claird at starbase.neosoft.com (Cameron Laird) Date: 30 Nov 1999 23:14:31 GMT Subject: performance of tuple-less Python? References: <1268226961-30285235@hypernet.com> <943917954snz@vision25.demon.co.uk> Message-ID: <28AA06A136A68C1C.67A20460768084FC.DEC7E9AA6FF8E72D@lp.airnews.net> In article , Quinn Dunkan wrote: . . . >See any purely functional language, like haskell. You can simulate mutability >in haskell by passing monads around, but you might be surprised at how much >you can get done with no side effects. Indeed; people often *are* "surprised at how much you can get done with no side-effects." > >And what was that party trick of changing 1 to equal 2 in forth? Maybe that's >more at the language level though, but I don't know much about forth (one of >these days...). There are several languages in which "1" can name a variable, which might happen to have the value 2. I can't think of one, though, in which the integers are mutable in the sense of this thread. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From tismer at appliedbiometrics.com Tue Nov 16 15:20:23 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Tue, 16 Nov 1999 21:20:23 +0100 Subject: list.without()? References: <11A17AA2B9EAD111BCEA00A0C9B41793034AAEE7@molach.origin.ea.com> Message-ID: <3831BC87.CD6ECCC4@appliedbiometrics.com> "Stidolph, David" wrote: > > so ... > > def without(source, element): > while element in source: > source.remove(element) > > Is that what you are looking for? It would help if I had read the earlier > posts! :) Semantically, yes. Proactically, I'm more keen on speed, and i guess the single try catcher is more efficient than to look up every thing twice. (Didn't measure it, but I'm quite sure). ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From mhammond at skippinet.com.au Tue Nov 16 19:22:49 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 17 Nov 1999 00:22:49 GMT Subject: Time object (COM) References: <816010E2456BD111A48700805FBBE2EEFDF7D7@ex-quebec-u1.baan.com> Message-ID: Gaetan Corneau wrote in message <816010E2456BD111A48700805FBBE2EEFDF7D7 at ex-quebec-u1.baan.com>... >Hi, > >I have a COM object with a property that looks like this when I print it: >

FXPy-0.99.87 - interface to the FOX cross-platform GUI library. (19-Nov-99) From malcolmt at smart.net.au Fri Nov 5 05:55:04 1999 From: malcolmt at smart.net.au (Malcolm Tredinnick) Date: Fri, 5 Nov 1999 21:55:04 +1100 Subject: Apply a function to each list member? In-Reply-To: ; from Mikael Olofsson on Fri, Nov 05, 1999 at 11:06:17AM +0200 References: Message-ID: <19991105215504.A497@Ridcully.home> On Fri, Nov 05, 1999 at 11:06:17AM +0200, Mikael Olofsson wrote: > I guess the terminology originally is taken from mathematics. A map is > a mathematical concept, similar to a function. Perhaps you should say > that a function is a map, rather than the other way around. Correct. In fact, since we're being precise, let me point out that (mathematically speaking), all functions are maps (or mappings), but not all mappings are functions. The point is that a function should have only a single "output" for any given input (i.e. it should be many-to-one or one-to-one, not one-to-many). So some mapping that sends, say, the number 2 to the numbers 3 and 4 is not a function (but a mapping that sends both the numbers 3 and 4 to the number 2 is a function, since for each input there is only a single output). (Hmm .. I've just realised that a few of my recent postings have had amazingly little to do with Python. I promise to stick to the topic from now one. Swear! :-) ) Cheers, Malcolm Tredinnick From ionel at psy.uva.nl Wed Nov 24 13:47:20 1999 From: ionel at psy.uva.nl (Ionel Simionescu) Date: Wed, 24 Nov 1999 19:47:20 +0100 Subject: Absolute newbie question References: Message-ID: <81hbol$5ng@mail.psy.uva.nl> Check: http://www.python.org/doc/ Philip Tellis wrote in message news:Pine.SOL.3.96.991124165729.11616B-100000 at giasbma... | Where are the man pages for python? I am new to python, and would like to | look through the man pages before I start. Someone please help. | | Philip | | From boud at rempt.xs4all.nl Tue Nov 30 01:57:06 1999 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 30 Nov 1999 06:57:06 GMT Subject: XPython (X11) References: <383E5350.1E07536A@xrce.xerox.com> <81ms2n$126$1@essle.valdyas.org> Message-ID: <81vsg2$g8$2@essle.valdyas.org> Bernhard Reiter wrote: > True. But I want that over an integrated API and GNOME and KDE > don't offer that yet. And they also don't offer it cross platform. > wxWindows at least tries to get there. I'm curious as to what you mean by an 'integrated API' - just curiosity. >>And yeah, last I heard you had to buy the Troll Kit for PyQt under >>Win32. > Dropping platform compatibility, that a huge point. Oh well, platform compatibility that costs money is still platform compatibility. -- Boudewijn Rempt | http://denden.conlang.org From mwh21 at cam.ac.uk Wed Nov 17 13:14:10 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 17 Nov 1999 18:14:10 +0000 Subject: Python equivalent to the perl `backtick` operator? References: Message-ID: "Kevin Howe" writes: > How do you execute a program from python? > > In Perl you would do it like this: > > $varName = `programName`; import commands varName = commands.getoutput("programName") - or probably better - result, varName = commands.getstatusoutput("programName") HTH, Michael From tismer at appliedbiometrics.com Tue Nov 16 15:28:07 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Tue, 16 Nov 1999 21:28:07 +0100 Subject: list.without()? References: Message-ID: <3831BE57.366ED454@appliedbiometrics.com> Mike Fletcher wrote: > > Hmm, actually, it's only cheap for certain subsets of the problem (which I > took to be the common case). In particular, it shines for small numbers of > instances in lists of fairly arbitrary size. It falls down completely when > you are removing large numbers of instances (such as all of them). I just > tested five algos, testing 1 instance in middle of list, and a list composed > of only elements to be removed, findings, module, and raw test results > below... Oh well, I overlooked that you have the try inside the while. That's bad. I thought I had read this: def without( source, element): temp = source[:] try: while temp: temp.remove( element ) except: return temp return temp Did you try this (I didn't, have no time). cheers - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From gmcm at hypernet.com Mon Nov 29 08:05:01 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Mon, 29 Nov 1999 08:05:01 -0500 Subject: Python complaints In-Reply-To: Message-ID: <1268241794-29392927@hypernet.com> Will Ware wrote: > I find myself grumbling about having to type "x = x + 1". The > really clean thing to do, given that integers are objects, would > be to define increment and decrement methods, so you'd type > something like "i.incr()". Then you'd want to go around looking > for other objects for which it made sense to increment and > decrement. Long ints and floats can do what integers do. > Sequences (lists, tuples, strings, xranges) might grow and shrink > in length. No good idea what to do for dictionaries. -- Now that you've had some coffee this morning, do you see any problems with this, Will? I mean, assuming you don't really want 0 == 1 to be sometimes true? Seems to me that "++" would have to be an operator that, for immutable operands, magically rebound the operand; while calling an __incr__ method on mutable objects. - Gordon From parkw at better.net Sun Nov 7 11:46:36 1999 From: parkw at better.net (William Park) Date: Sun, 7 Nov 1999 11:46:36 -0500 Subject: Python and generating images for web In-Reply-To: <3824F7AC.4B1BC7F6@yahoo.com> References: <3824F7AC.4B1BC7F6@yahoo.com> Message-ID: <19991107114636.A4281@better.net> On Sat, Nov 06, 1999 at 10:53:16PM -0500, Alexander Stepanov wrote: > Hello, > > > I am a newcomer to web programming and python. I need to create a > small web application to make some charts based on user's data input. > > Is it possible to generate gif or png images on a fly using Python? > > I will appreciate if you point me out accessible chart/plot modules > and libraries as well as documentation and working sites. Any > additional information is strongly welcome. > > (I am in a process of comparison Perl and Python to solve this > problem. I plan to use the application under WindowsNT4.0 environment > + Perl? or Python interp-r). > > Sincerely, Alexander email: a_stepanov at yahoo.com I don't know about others, but I use 1. Python script to generate data plot in PiCTeX format 2. TeX and 'dvips -E' to produce EPS file 3. ImageMagick 'convert' to convert to GIF file All the steps can be called from Python script, although I usually do them manually. Yours truly, William Park From mikael.johansson at helsinki.xx Fri Nov 12 10:21:40 1999 From: mikael.johansson at helsinki.xx (Mikael Johansson) Date: Fri, 12 Nov 1999 17:21:40 +0200 Subject: print "foo", without a space References: <000b01bf2ccb$70ba3d20$fd2d153f@tim> Message-ID: <382C3084.C7B01C10@helsinki.xx> Hello All! > > Is there another way of getting print to not make a newline than > > using: > > print "foo", ? > > No. OK, thanks to all who replied, this was what I really wanted to know. The other tricks where known to me, but the .softspace thingie seemed interesting (even if not that usable :-) The reason for me wanting the print-statement to not make an auto- space was just to have one simple output-command. The reason for this again is that I've been assisting in a thermodynamics course here at the university. I've been responsible for trying to get the students to do some small proggies (calc. Gibbs energies etc.), and none of them had any programming experience to start with, so I chose Python as it seemed (and still seems) a nice and quite easily adoptable language. I hadn't programmed Python before either, but now I love it :-) But anyway, the concept of stdout and so on are a bit too complicated to get through to the students in the very limited time I have (it's not supposed to be a programming course after all). Have a nice day, Mikael J. From garry at sage.att.com Mon Nov 29 10:28:48 1999 From: garry at sage.att.com (Garrett G. Hodgson) Date: Mon, 29 Nov 1999 15:28:48 GMT Subject: bug in tkinter canvas event handling? Message-ID: <38429BB0.1BFFB54B@sage.att.com> ok, i'm back with another tk problem. what i want to do is attach a callback to a shape in a canvas that will tell me which domain level object was picked. seems simple, but i don't get what i expect. in particular, if i press a mouse button while pointing to one object, then drag to another and release, the release event callback tells me i was pointing to the first object. i've distilled it down to a small test case, attached below. this seems like a bug to me, but experience has shown that it's probably a misconception on my part about how the event handling is supposed to work. anyone have any ideas? ------------------------- code follows ----------------------- from Tkinter import * def Up( id ): print 'Up:', id def Down( id ): print 'Down:', id root = Tk() canvas = Canvas( root ) canvas.pack() Wid = 40 Hgt = 25 x, y = 100, 64 shape1 = canvas.create_oval( x-Wid, y-Hgt, x+Wid, y+Hgt, fill='red' ) x, y = 200, 64 shape2 = canvas.create_oval( x-Wid, y-Hgt, x+Wid, y+Hgt, fill='blue' ) canvas.tag_bind( shape1, "<1>", lambda e: Down( 'shape1' ) ) canvas.tag_bind( shape1, "", lambda e: Up( 'shape1' ) ) canvas.tag_bind( shape2, "<1>", lambda e: Down( 'shape2' ) ) canvas.tag_bind( shape2, "", lambda e: Up( 'shape2' ) ) root.mainloop() -- Garry Hodgson "Hey, mister, can ya tell me, garry at sage.att.com where a man might find a bed?" Software Innovation Services He just grinned and shook my hand, AT&T Labs "No", was all he said. From flognat at hotmail.com Wed Nov 3 16:35:54 1999 From: flognat at hotmail.com (Flogg) Date: Wed, 03 Nov 1999 21:35:54 GMT Subject: dejasearch.py - an www.deja.com client, Alpha version comments wanted Message-ID: <7vq9rq$fv9$1@nnrp1.deja.com> Did anyone try it out, and got it to work?? I tried it outside our firewall/proxy and Deja seemed to behave a little bit different, so I have updated the archive. p.s. lets hope I don't mess this up so you see this message 3 times.. /Andy -- The eye of the beholder lies on the beauty. Sent via Deja.com http://www.deja.com/ Before you buy. From michel at digicool.com Tue Nov 30 17:15:30 1999 From: michel at digicool.com (Michel Pelletier) Date: Tue, 30 Nov 1999 17:15:30 -0500 Subject: [Zope-dev] Re: Exposing COM via XML-RPC or Something Else Message-ID: <613145F79272D211914B0020AFF64019276318@gandalf.digicool.com> > -----Original Message----- > From: Thomas Heller [mailto:thomas.heller at ion-tof.com] > Sent: Tuesday, November 30, 1999 2:52 PM > To: Brian Lloyd; 'Edward Muller'; python-list at python.org > Cc: zope-dev at zope.org > Subject: [Zope-dev] Re: Exposing COM via XML-RPC or Something Else > > > > You might want to take a look at MS' SOAP (Simple Object Access > > Protocol) spec - it's not fully baked yet, but it basically takes > > xml-rpc several steps further, allowing you to communicate with > > SOAP-enabled objects (COM or otherwise) using XML over HTTP. We in > > Zope-land are keeping a close eye on this, as publishing objects > > via HTTP is the core idea of Zope already. > > Zope and SOAP sounds very similar. > Is this by accident? Yup -Michel From mcfletch at vrtelecom.com Wed Nov 10 12:49:30 1999 From: mcfletch at vrtelecom.com (Mike Fletcher) Date: Wed, 10 Nov 1999 12:49:30 -0500 Subject: Python company worth $100M In-Reply-To: <80c97t$r6$1@nntp9.atl.mindspring.net> Message-ID: Nope, don't think you're missing anything. If I recall correctly, the asyncore docs even mention their assumption that the processing to be done per call is trivial. Since all other channels are "blocked" while the compute-heavy call is processing, the system will suffer performance degradation for all other clients. Thread-pools seem to be a decent approach for longer-running calls. Cheers, Mike -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Aahz Maruch Sent: November 10, 1999 12:16 PM To: python-list at python.org Subject: Re: Python company worth $100M In article <033201bf2b73$ad1e49e0$f29b12c2 at secret.pythonware.com>, Fredrik Lundh wrote: > > [ Searchbutton.com ] >and if you look at the technical credits page, what do you >find? > > http://www.searchbutton.com/misc/technicalCredits > >asynclib again, of course ;-) Actually, we're moving away from asyncore in favor of threads. Unless we're missing something obvious, asyncore just doesn't do well with compute-heavy processes. -- > I wrote: > > a slightly hairer design issue is what combinations > > of pattern and string the new 're' will handle. > -- http://www.python.org/mailman/listinfo/python-list From cramu at my-deja.com Thu Nov 4 06:13:14 1999 From: cramu at my-deja.com (cramu at my-deja.com) Date: Thu, 04 Nov 1999 11:13:14 GMT Subject: Template for CGI References: <7vn0sk$7cp$1@news.fsu.edu> Message-ID: <7vrpo8$hbu$1@nnrp1.deja.com> Hi There is a sophisticated way of doing it. Take a look at "Generating Dynamic Documents From Templates" from http://www.python.org/doc/Publications.html Ramu In article <7vn0sk$7cp$1 at news.fsu.edu>, "Glenn Kidd" wrote: > I am a newbie to Python and I have a question. I want a CGI script that > will read a file template and replace certain words with variables. Ii > tried putting the variable names in the file but it is read as palin text. > Is there a way to embed variables into a teplate or a replace function in > Python? Thank you for any help you give. > > Glenn Kidd > > Sent via Deja.com http://www.deja.com/ Before you buy. From news at dorb.com Thu Nov 4 20:23:56 1999 From: news at dorb.com (Darrell) Date: Thu, 4 Nov 1999 20:23:56 -0500 Subject: Namespace question... References: <7vqgib$l8v$1@nnrp1.deja.com> <3820D46C.517EA278@x.x> Message-ID: Untested code: sys.modules['__main__'].Version I'm not sure this is a good idea. If your code becomes part of some greater application it won't work. A slight improvement might be something like this. sys.modules['__keeperOfTheVersion']=sys.modules[__name__] -- --Darrell Eric Jacobs wrote in message news:3820D46C.517EA278 at x.x... > oofoe at my-deja.com wrote: > > > > Hi! > > > > How can you access the global namespace in python 1.5.1? I'd like to get > > a version string which is declared in the main script file. However, > > each module also has a version string which overrides the original one. > > I tried to access it as __main__.Version, similarly to $main::Version in > > Perl, which is what I'm more familiar with. Of course, it didn't work. > > > > I have something like this: > > > > module file foo.py: > > ------------------------------ > > Version = '$Id$' > > > > def bar(): > > print "Version is: ", __main__.Version > > > > main program: > > ------------------------------ > > Version = '$Id$' > > > > import foo > > > > foo.bar() > > > > ------------------------------- > > > > I'd certainly appreciate any pointers. The namespace stuff seems to get > > a little hazy around issues like this. > > Import it first! Use import __main__. > > I think some of this confusion arises because there is no global > namespace in the sense of a area that exists above all modules > (a good design design, IMO). The word global simply refers to > variables at the level of the module, as opposed to within a > function. > > -- > http://www.python.org/mailman/listinfo/python-list From jblazi at netsurf.de Thu Nov 11 07:15:37 1999 From: jblazi at netsurf.de (Janos Blazi) Date: Thu, 11 Nov 1999 13:15:37 +0100 Subject: TKinter question Message-ID: I was given the advice to look at the Tk Table and tixGrid features (widgets?) in Tk. Can I use these features in Tkinter and is their use documented somewhere? Janos Blazi From skaller at maxtal.com.au Thu Nov 25 18:10:03 1999 From: skaller at maxtal.com.au (skaller) Date: Fri, 26 Nov 1999 10:10:03 +1100 Subject: Python complaints References: <38397696@news.xtml.co.uk> Message-ID: <383DC1CB.371505FF@maxtal.com.au> Nick Trout wrote: > > | Basically, I'd be really interested to learn: what _don't_ people like > | about Python > It would be *really* nice if someone sped up Tkinter (ie. direct tk calls > rather than through Tcl which is the way I think it works at the moment). > Its quite a pain if you have a large GUI or you're trying to work with GL. > Its a shame with this being the defacto GUI and bundled with Python that it > is so sluggish. It is very usable though. Viper will support a builtin, high speed GUI interface. The current Linux implementation uses GTK. On my 166MHz Intel box, it flies. On a real computer, well, who knows :-) Note that this is so, even though there are FOUR levels of wrapping around the GTK calls, a C wrapper, then and ocaml wrapper, then a Viper wrapper, and finally a Python wrapper! [A windows port would probably use native MS-Windows] Seriously, Tk is archaic. Forget it. For CPython, wxWindows or pyGtk would be better choices. For JPython, obviously Swing is the GUI of choice. -- John Skaller, mailto:skaller at maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia homepage: http://www.maxtal.com.au/~skaller voice: 61-2-9660-0850 From Gaetan_Corneau at baan.com Wed Nov 24 11:37:03 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Wed, 24 Nov 1999 11:37:03 -0500 Subject: Python and COM: a bug? Message-ID: <816010E2456BD111A48700805FBBE2EEFDF822@ex-quebec-u1.baan.com> Bill, > How is this "O" written? > Is it an ATL C++ COM object that uses IDispatchImpl? (i.e. a > dual interface) Is it a C++ COM object that implements IDispatch on its own? > (not a dual interface) > Is it a C++ COM object that uses OLEAUT's builtin IDispatch, but just > doesn't use ATL? (i.e. a dual interface) > > My hunch would either be a bug in Python dispid code, or your > COM object has a bug in some custom IDispatch code. I'm not sure. I know it is implemented using ATL 3.0, but I don't know the details (and since I'm a newbie in COM/C++/ATL, I can't tell the difference). I'll ask. [Half an hour later] :) OK. You may well be right about a bug in our code. I was told that the interface is not dual and that the dispids are created dynamically the first time a property is used. So maybe there is a problem in this code and that the fact that I have never encountered the problem in VBScript is pure luck. I'm still not sure, because a lot of people are using those COM objects in dozens of VB Scripts and none have reported this kind of problem. But, hey, I have seen much stranger occurences than that already :) What I'll do is write a test script in Python that just tries to reproduce the problem. If I can finally find a way to reproduce it on demand, I'll ask our resident COM expert to trace the code to see if the problem is on our side. If its not, maybe I'll have some more clues. One way or another, this is one potentially very dangerous bug, for us at least, so I'll invest more time and effort to find what the problem is. > I also don't think we try to optimize any calls. COM doesn't > give one enough > information to even bother optimizing anything other than > caching Name -> DispID mappings. That's what I meant by "optimization". > > And sometimes, I get something like that: > > > > >>> Object > > > > > >>> P = Object.Parent # Parent is an attribute that is the > object that > > created the current object > > >>> P > > > > >>> P = Object.get_Parent() > > >>> P > > > > > >>> > > > > What really helps in cases like this is to have the IDL for your > dispatch/dual interface so that we can examine whats > happening much easier. > :) I put it in attachment. > > The otherthing to note is that the > > occurs because you > aren't wrapping the typelibrary with Python helper classes. Using > win32com.client.EnsureModule("") allows you to support a > couple of features that are impossible to deterimine without > the typelib. I forget exactly what those are off the top of my head. That's something I don't know about. My (naive) question is: why doesn't VBScript require such a step? > The answer believe it or not is, "Python is the most powerful > scripting > language on the planet for Win32 programming." its multi threaded, COM > happy, ActiveX Scripting Engine happy, and really easy to > talk to. VBScript > on the other hand... Don't get me started... :) You certainly don't have to convince *me* of that :) Just the fact that I can develop my Python scripts to test those COM objects from an INTERACTIVE COMMAND LINE is a *major* feature. I can play with the objects in a Korn Shell interactively to find the recipe, instead of the usual edit/save/run/debug cycle. Thanks a lot, ______________________________________________________ Gaetan Corneau Software Developer (Quality Assurance Team) BaaN Supply Chain Solutions http://www.baan.com E-mail: Gaetan_Corneau at baan.com Tel: (418) 266-8252 ______________________________________________________ "Profanity is the one language all programmers know best" -------------- next part -------------- A non-text attachment was scrubbed... Name: ITKCOMAPI.idl Type: application/octet-stream Size: 26334 bytes Desc: not available URL: From mlh at vier.idi.ntnu.no Tue Nov 2 10:27:49 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 02 Nov 1999 16:27:49 +0100 Subject: Drawing (directed) graphs References: Message-ID: R.M.Everson at ex.ac.uk (R.M.Everson) writes: > Hello, > > Does anyone know of Python code for drawing graphs of the > graph-theoretic type? Ideally, I'd like to be able to interactively > add nodes and edges etc and add data to structures associated with the > nodes and edges. OK - so this isn't really an answer to your question... (I.e. it is not a Python-implementation)... But Graphviz is really good IMO... http://www.research.att.com/sw/tools/graphviz/ I'm sure you could SWIG it and script it from Python... And - maybe we should have something like this for PIDDLE too? > > Many thanks > Richard Everson. -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From cgw at fnal.gov Wed Nov 10 11:54:10 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Wed, 10 Nov 1999 17:54:10 +0100 (MET) Subject: Intelligent strptime? In-Reply-To: <19991110171256.A5196@optiplex.palga.uucp> References: <19991110171256.A5196@optiplex.palga.uucp> Message-ID: <14377.41778.712189.7874@gargle.gargle.HOWL> Gerrit Holl writes: > > Does there exist an intelligent strptime? "26/11/99", for example, can _only_ > mean the 26th November of this year, and the chance that "14:11:12" means > 14 november 1912 is very small. Is there a module/function that guesses the > format? There isn't doubt very often, only for 12/11/99, US is 11 december, > Europe is 12 November (isn't it?). I think that there's an ambuguity between US-style MM/DD and European-style DD/MM whenever the day of the month is 12 or less. Of course when DD==MM then the ambuguity doesn't matter (e.g. 3/3/99). But that still leaves 11 days in each month which have this ambiguity, which comes to 132 days per year. So, given a 365-day year, 36% of the dates are ambiguous, which doesn't make "guessing" look like a very attractive option to me. From trekkan at yahoo.com Sun Nov 28 14:01:30 1999 From: trekkan at yahoo.com (Troy) Date: Sun, 28 Nov 1999 11:01:30 -0800 Subject: Parsing text Message-ID: As you will be able to tell, I am new to Python so please forgive any newbie things I might do. =) What I would like to do is take a variable and parse out each of the pieces. Most commonly delimited by spaces. Example text: This is a test I would like to be able to pull out any of "This", "is", "a", "test" and be able to drop any element into a variable that I wanted. I hope this explains it enough. Thanks for any help you may be able to provide. One other thing, is there a way to tell if a substring exists in a string? in a basic sort of way if 'abc' isin '123abc456' Something to that effect anyway. Thanks for your time! Troy From mwh21 at cam.ac.uk Fri Nov 19 09:18:58 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 19 Nov 1999 14:18:58 +0000 Subject: Beginning programming with Python References: <382B3A53.5816B2@callware.com> <382B3D79.74CD3E0F@email.sps.mot.com> <80p9ds$ppo$1@newshost.accu.uu.nl> <38317787.19AFDAF5@compaq.com> <812rg4$b6$1@essle.valdyas.org> <00ef01bf3271$10a8bb90$f29b12c2@secret.pythonware.com> <813a3h$jc0$2@newshost.accu.uu.nl> Message-ID: m.faassen at vet.uu.nl (Martijn Faassen) writes: > Not to mention you couldn't write: > > if foo: print "Foo!" > > without the colons. Not that I'd mind terribly if that usage went > away though; it is scattered all across the Zope sources which I was > browsing through last night, and I don't think that construction > adds to readability. The ':' in my opinion does, though. Even though > I forget it myself on occasion. I don't forget it very often, largely because python-mode goes obviously screwy if you leave it out... Cheers, Michael From tomr at cnri.reston.va.us Wed Nov 24 07:29:05 1999 From: tomr at cnri.reston.va.us (Tom Reinhardt) Date: Wed, 24 Nov 1999 07:29:05 -0500 Subject: Python complaints References: <38397696@news.xtml.co.uk> <221119992150405215%zippy@cs.brandeis.edu> <383a8909@news.xtml.co.uk> Message-ID: <383BDA11.5A479E60@cnri.reston.va.us> Nick Trout wrote: > > How do you write large/complicated applications in Lisp, the syntax with all > those brackets drives me mad! > I can't resist this one: From someone who had written a few, much easier than you might think. Lisp programmers have always enjoyed rich programming environments, hosting features that are still lacking in many so-called modern languages. Good type checking, syntax/language-directed editors, tightly coupled debuggers, etc., were available before the first CADR (gasp!) machines in the eighties. In fact, Lisp is syntactically regular making it less taxing than C++ or even Python (still haven't got the hang of when to use ":"'s and backspaces) for extended efforts. Finally, most modern Lisp dialects provide a rich (meta)object substrate as well as GUIs. > I've never heard of this clever type checking. It sounds like a very good > idea. It would be nice to be able to choose whether to have typing on or > off. I know you can run a Lint checker over Python but whats a compiler > for?! To keep you honest, and to allow you to design the algorithm independent of machine or micro(source level) optimization concerns. > > N > > "Patrick Tufts" wrote in message > news:221119992150405215%zippy at cs.brandeis.edu... > | In article <38397696 at news.xtml.co.uk>, Nick Trout > | wrote: > | > | > | Basically, I'd be really interested to learn: what _don't_ people like > | > | about Python > | > > | > The lack of typing is a problem sometimes but a real bonus when writing > | > stuff quickly. I think speed of execution is my main complaint but I > believe > | > that is being addressed in the next version (ie. a jump table for > bytecode > | > execution was mentioned etc.). > | > | Python could follow the Common Lisp model where variables can be typed > | or not, and the compiler is welcome to actually use the information if > | it feels like it. > | > | The best current implementation of Common Lisp for type-declarations > | and doing smart things with them is CMU Common Lisp. CMU CL has a > | compiler called ... Python ... which does some amazing things with both > | explicit and IMPLICIT type declarations. > | > | For the latter, the compiler can often prove what the type must be even > | where there are no declarations, and then use the type-specific numeric > | operators to improve the efficiency of the code while maintaining > | complete code safety. > | > | Here's an example: > | > | (defun foo (x) (mod x 4)) ; return x mod 4, always an integer > | > | (defun bar (x) (^ 2 x)) ; return 2^x, always an integer > | > | (defun baz (a b) (+ (foo a) (bar b))) ; foo(a) + bar(b) > | > | The compiler determines that an in BAZ, an integer add can be used > | instead of the general, type-checking add. The compiler increases the > | speed of the code by eliminating the type-check, and minimizes the > | memory used by choosing the integer representation for numbers instead > | of a general numeric representation. > | > | If the Python language is going to be extended to allow for type info, > | I would love to see as much as possible borrowed from the CMU CL Python > | compiler, as it's one of the finest intelligent compilers I know of. > | And it has a cool name. > | > | More info on CMU CL: http://www.cons.org/cmucl/ > | > | And a bit on the CMU Python compiler's type-checking (chap 4.5.2 of the > | CMU CL User Manual by Robert A. MacLachlan, CMU tech report > | CMU-CS-92-161): > | > | http://www.mindspring.com/~rtoy/software/cmu-user/node98.html#SECTION005 > | 52000000000000000 > | > | --Pat > | > | * foo bar and baz can also return bignums. I'm ignoring this case to > | make the example clearer. From hinsen at cnrs-orleans.fr Thu Nov 4 05:22:15 1999 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 04 Nov 1999 11:22:15 +0100 Subject: eff-bot Python book ... revisited References: <7va9hf$ngi$1@marcie.fissiontech.com> <00fd01bf23cb$e4b6ed30$f29b12c2@secret.pythonware.com> <381C952F.2E8F30EC@callware.com> <99103116022800.00566@quadra.teleo.net> Message-ID: Patrick Phalen writes: > I printed the book both sides, using inexpensive paper, on my LaserJet. > Whenever I do this, the first pass (odd pages only) subjects one > surface to intense heat, buckling/warping the stack. This makes it > nearly impossible to feed the stack back through for the second (odd) > pass without jamming the printer. It's a problem with cheap paper. Of course more expensive paper isn't necessarily better, but the paper that is better is usually more expensive. > However, this time, I let the stack sit for several days, to allow the > moisture in the fibers to reequalize (?) -- and it worked. You can speed it up by keeping it under pressure (a 16-ton weight will do nicely ;-) -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From none at fake.net Thu Nov 11 01:53:56 1999 From: none at fake.net (me) Date: Thu, 11 Nov 1999 06:53:56 GMT Subject: Win32api.... can it create a Windows shortcut (.lnk) file? Message-ID: <8KtW3.51128$Rx2.608380@news1.rdc1.bc.home.com> I'm just trying to find an easy to create shortcuts on Windows platforms through Python... it doesn't seem to be a simple matter though. I've gone through all the Win32 docs, and found nothing, and have started writing (with limited success) a C function to do it. Is there an easy way? q:] Thanks, Kevin Cazabon kcazabon at home.com From aa8vb at yahoo.com Mon Nov 1 12:17:09 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Mon, 1 Nov 1999 12:17:09 -0500 Subject: __str__ vs. __repr__ Message-ID: <19991101121709.A134039715@vislab.epa.gov> 1) Is there a convention for what __str__ and __repr__ should return for classes? 2) Or, whatever they return, should they return the same value? 3) If so, why have both in the language? Searching the archives yields an example with odd behavior that suggests they should generally return the same value: class c: def __str__(self): return 'foo' def __repr__(self): return 'bar' >>> str(c()) 'foo' >>> str([c(), c(), c()]) '[bar, bar, bar]' -- Randall Hopper aa8vb at yahoo.com From pinard at iro.umontreal.ca Tue Nov 30 11:32:52 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 30 Nov 1999 11:32:52 -0500 Subject: Python complaints In-Reply-To: Dan Schmidt's message of "30 Nov 1999 09:26:11 -0500" References: Message-ID: Dan Schmidt writes: > Mark Carroll writes: > | Basically, I'd be really interested to learn: what _don't_ people > | like about Python? > The main thing I find frustrating is that lambdas are not very > powerful. So do I. They are a bit awkward and do not fit so well in the language. Moreover, they are not really needed. The solution should be to eradicate lambda's instead of making them more powerful. This is easily done here: by choice, I just never use them. But I would even prefer not having the choice, for the benefit of Python being a bit simpler. > Much of the time that I would use a simple 'map {}' in Perl, I find that > I have to write a separate function [...] Writing two more lines is not such a big deal, given that usually, people are using `lambda's rather sparingly, anyway. Eradicating `lambda's would probably never yield a source code bloat. By the way, I find `map' rather useful, even if I read recently that Guido somewhat regretted having introduced it in Python. I guess one could write his/her own `map' function, it is just simpler for the community that the order and meaning of arguments is decided once and for all in the library. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From xtian at regurgitator.zzn.com Sat Nov 6 00:52:45 1999 From: xtian at regurgitator.zzn.com (Xtian Muirhead) Date: Sat, 6 Nov 1999 18:52:45 +1300 Subject: ~ 1 = -2 ??? References: Message-ID: <800fpr$ahh4u$1@titan.xtra.co.nz> Les Schaffer wrote in message news:m2vh7hk1ys.fsf at netmeg.net... > i am doing some bit operations, and dont understand the following: > > >>> ~ 1 > -2 > > huh???? i would have thought that bitwise invert of 1 would be > > 0001 --> 1110 = 13 (base 10) > > what marble am i missing? > > les schaffer Integers are stored in twos-complement format. (Which means...) The top bit of the integer is treated as having a negative value. This means that FFFFFFFF is equal to 1 + 2 + 4 + 8 + ... + 1073741824 - 2147483648 = -1 So, 1 is 00000001, inverted is FFFFFFFE, which is 2 + 4 + 8 + 16 + ... + 1073741824 - 2147483648 = -2 This means that the largest positive integer value is 2147483647, while the largest negative value is -2147483648. It's better than having the top bit just be a sign bit 'cause it avoids confusing -0 problems. (And it gives us one more value. Yay!) HTH, HAND Xtian xtian at regurgitator.zzn.com "As I bit into the nectarine, it had a crisp juicyness that was very refreshing, until I realised that it wasn't a nectarine at all, but a HUMAN HEAD!!!" From karanvasudevaNOkaSPAM at usa.net.invalid Sat Nov 6 05:26:17 1999 From: karanvasudevaNOkaSPAM at usa.net.invalid (Karan Vasudeva) Date: Sat, 06 Nov 1999 02:26:17 -0800 Subject: exec / execfile namespace problem Message-ID: <004aa0e3.c3e96526@usw-ex0101-002.remarq.com> Hi, I'm trying to do this: execfile('cool.py') and this: import fileinput chunk = '' for line in fileinput.input('cool.py'): chunk = chunk + line exec(chunk) where 'cool.py' is this: (in part) import httplib import time import whrandom h = httplib.HTTP('') h.putrequest('GET', '/favicon.ico') This fails with this error message at the command prompt: Traceback (innermost last): File "testSlave.py", line 1, in ? execfile('cool.py') File "cool.py", line 8, in ? h.putrequest('GET', '/favicon.ico') File "httplib.py", line xx, in putrequest self.send(str) File "httplib.py", line xx, in send self.sock.send(str) AttributeError: sock (I changed two line numbers to xx, they were different but thats irrelevant) I've tried to change self.sock to sock, but that didn't help. Guess I'm stumbling around in the dark being an absolute newbie at this. Any help would be appreciated. Regards, Karan. * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free! From init__self at my-deja.com Mon Nov 8 14:49:28 1999 From: init__self at my-deja.com (init__self at my-deja.com) Date: Mon, 08 Nov 1999 19:49:28 GMT Subject: IPC8: Call the 800 number! Message-ID: <8079g6$fd4$1@nnrp1.deja.com> There seems to be a problem between the chairs and the keyboards at the 703-524-6400 Key Bridge Marriott hotel -- the reservation agents don't seem to know about the conference and were unable to speak to anybody that did. Therefore they wouldn't honor the $129 rate. I even tried rep fishing but got the same person again (bah!). However, the 800 number *does* know about the conference and was more than happy to take my money. You might want to try them first. Sent via Deja.com http://www.deja.com/ Before you buy. From duncan at rcp.co.uk Mon Nov 15 08:08:14 1999 From: duncan at rcp.co.uk (Duncan Booth) Date: 15 Nov 1999 13:08:14 GMT Subject: '==' vs. 'is' behavior References: <382C2C6A.64A8F2C2@theriver.com> <14380.12036.197083.409565@weyr.cnri.reston.va.us> Message-ID: <8E7F86267duncanrcpcouk@news.rmplc.co.uk> fdrake at acm.org (Fred L. Drake, Jr.) wrote in <14380.12036.197083.409565 at weyr.cnri.reston.va.us>: > It's working just fine! Note that the "small" integers (through 99) >are always reused, so the "is" relationship will hold. It's not very >useful, but reusing the integer objects saves a lot of allocation of >small numbers, and makes real-world code a lot faster. > It isn't just small integers though that can be reused. Consider: >>> a = 999 >>> b = 999 >>> print a is b 0 Put the same lines into a file and run it and it will print 1, or in interactive mode put the lines into a function definition and again it prints 1. When compiling anything identical constants are folded together. From fredrik at pythonware.com Tue Nov 30 03:03:09 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 30 Nov 1999 09:03:09 +0100 Subject: '==' vs. 'is' behavior References: <382C2C6A.64A8F2C2@theriver.com> <14380.12036.197083.409565@weyr.cnri.reston.va.us> <8E7F86267duncanrcpcouk@news.rmplc.co.uk> Message-ID: <015301bf3b0a$685a3fc0$f29b12c2@secret.pythonware.com> Fran?ois Pinard wrote: > By the way, is there common wisdom (or rather, maybe, usage-standards-to-be) > about using `is' instead of `=='? according to the eff-bot: foo is None type(foo) is type(bar) # same type foo is bar # same instance use '==' for everything else (unless you know what you're doing, of course). From leef_me at my-deja.com Tue Nov 23 13:11:25 1999 From: leef_me at my-deja.com (Lee Fletcher) Date: Tue, 23 Nov 1999 18:11:25 GMT Subject: trouble with python 1.5.2 install on win98 Message-ID: <81elc8$8i2$1@nnrp1.deja.com> Hoping for some guidance to my problem w/Python, I have installed py152.exe on (2) Win98 machines: 1 at work, 1 at home The installation at home runs. I am having trouble running IDLE at work. It accesses the hard drive but never becomes a running program. Starting from the beginning, I have d/l and run py152.exe. I accepted all default suggestions for installation of python, tk & tcl. I tried the "verify that the interpreter works " code on the http://www.python.org/download/download_windows.html page, both examples work I tried accessing IDLE from the "start menu" but no results. I rebooted (windows restart) to make sure any pending "setups" were finished. I tried accessing IDLE from the "start menu" >Again< but >still< no results. I have tried deja & faq searches from the ptyhon help page, but did not see anything that applies to this. Please, can you make any suggestions on what I have done wrong? Thanks, Lee Sent via Deja.com http://www.deja.com/ Before you buy. From claird at starbase.neosoft.com Thu Nov 11 06:23:02 1999 From: claird at starbase.neosoft.com (Cameron Laird) Date: 11 Nov 1999 11:23:02 GMT Subject: FYI: Python company worth $100M References: <38295BC2.13E2E31F@digicool.com> Message-ID: In article <38295BC2.13E2E31F at digicool.com>, Paul Everitt wrote: > >Next time someone claims that Python is marginal...next time that >someone says nobody uses Python... > >eGroups is merging with Onelist (a competitor), and each is valued >around a million bucks: > > http://www.thestandard.com/articles/display/0,1449,7543,00.html . . . Most readers will be able to supply the missing word in "... a hundred million bucks" above that you accidentally lost, Paul. Incidentally, Python should play a big role in news that I expect to emerge in the next month from two of the biggest hardware and software companies. Stay tuned to this space for details. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From tjreedy at udel.edu Wed Nov 24 00:15:55 1999 From: tjreedy at udel.edu (Terry Reedy) Date: 24 Nov 1999 05:15:55 GMT Subject: Python complaints References: <383979F7.25D6@cs.bham.ac.uk> Message-ID: <81fsab$2b$1@news.udel.edu> In article <383979F7.25D6 at cs.bham.ac.uk>, S.I.Reynolds at cs.bham.ac.uk says... >Oh yeah! I'd I disklike writing 'self.' eveywhere. Some kind of >shorthand would be nice. e.g. I'd be nice to write: > .x.f() >instead of: > self.x.f() You are currently welcome to save 3 keystrokes (rather than 4) by naming the method parameter 's' instead of 'self'. The latter is just a convention that many people use -- at least for public consumption. TJR From mlh at vier.idi.ntnu.no Tue Nov 2 10:12:27 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 02 Nov 1999 16:12:27 +0100 Subject: How can I make my assertions smarter? References: <381D7087.BF8510E5@webone.com.au> <381e4350.91314552@news.usyd.edu.au> Message-ID: jesse at student.usyd.edu.au (Jesse Sweeney) writes: > On 01 Nov 1999 16:55:02 +0100, mlh at vier.idi.ntnu.no (Magnus L. Hetland) wrote: > Simple? Yes. Works? No. > > The problem is that pre's locals aren't the same as the locals in the function > from which pre is being called, so you run into problems like this one: Oops... I guess I was a bit quick there... ;) -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From da at ski.org Mon Nov 29 16:11:41 1999 From: da at ski.org (David Ascher) Date: Mon, 29 Nov 1999 13:11:41 -0800 (Pacific Standard Time) Subject: Numeric write-in place facility In-Reply-To: <81tovm$oe0@mail.psy.uva.nl> Message-ID: On Mon, 29 Nov 1999, Ionel Simionescu wrote: > Hi, > > In a post on the wxPython list, Markus Gritsch suggested that array ops such > as > a = a+b > can be done faster by using write-in place: > Numric.add(a,b,a) > > Playing around I see now that other ufuncs allow a write-in target > specification as their last argument. For example, > > Numeric.sqrt(a,b) > > will put the result in b (if its dimension and type are Ok). > > The docs do not tell much about this. > Can anyone confirm/clarify/comment ? 1) Confirm: yes 2) Clarify: well, I think you pretty much summed it up 3) Comment: Watch out for 'slices'. If you do a = arange(10) b = a[::-1] add(a,b,b) print b you might be suprised =) --david ascher From asc at bsiag.com Wed Nov 3 07:17:23 1999 From: asc at bsiag.com (Alex Schroeder) Date: 03 Nov 1999 13:17:23 +0100 Subject: Download Python Imaging Library Handbook References: Message-ID: "Jeffrey Kunce" writes: > I used websucker.py from the python Tools/webchecker directory. > python websucker.py http://www.pythonware.com/library/pil/handbook/index.htm I found a printable (PS and PDF) version of the handbook on the SIG site for an old version (0.2b3 instead of 1.0): http://www.python.org/sigs/image-sig/Imaging.html But I guess I will use websucker.py... :) Alex. -- http://www.geocities.com/kensanata/ http://www.bsiag.com/ From cfelling at iae.nl Wed Nov 24 18:45:07 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 25 Nov 1999 00:45:07 +0100 Subject: automatic "lotjes trekken" References: <81cqnv$2ip$1@vvs.superst.iae.nl> Message-ID: <81hta3$1p7$1@vvs.superst.iae.nl> Alex wrote: > Hi, Carel. > This is a fun problem. Basically, you want to find a set of disjoint > loops in a digraph whose union contains all of the digraph's vertices. > How big, and how far from complete, is the graph likely to be? I don't > know a lot of graph theory, but it seems likely that the problem of Neither do I, I'm even not sure I understand what you wrote:) > counting every such set of loops is NP-complete for a general graph. At But you're definitely right here. Though n! always looks to me as a harmless function, something like "really n", it is almost as dreadfull as n^^n. Fortunately in my family n is rather small, we are five now and even if the girls get hooked we won't surpase eight for quite some time yet:) Moreover the problem space is a little below n!, as one shouldn't draw oneself. The question was: how much lower given some constrains. The approach I've taken sofar was to simulate real life, let everybody draw, and as soon as someone draws one he doesn't want, throw all the lots back in the hat and try again. [[ well Greg, in my books this wouldn't be classed as a backtracking solution :]] This will work given that there is a solution, time and the proper functioning of random.choice. It will work better if the number of possible solutions comes closer to n! simply because it will get more likely then that any full drawing will be a solution too. So the more family members and the less restrictions, the more likely it succeeds in a few tries. OTOH, the more tries it takes the happier I am that I didn't had to go through it in real live:) class Hat: ... def hussle(self): '''hussle the hat until the drawing is valid''' if self.possibilities() == 0: raise 'Even eternity won\'t give a valid hussle' self.tries = 0 while 1: if self.tries > 999: raise 'I am bored, can\'t find a solution quick enough' hat, self._drawn, self.tries = self._lots[:], [], self.tries+1 for drawer in self._lots: lot = random.choice(hat) if lot in self._blanks[drawer]: break hat.remove(lot) self._drawn.append(lot) else: return def possibilities(self): '''this should return the size of the anwser space, but now it simply returns the number of permutations of the lots''' U = reduce(lambda x,y: x*y, range(1, len(self._lots)+1), 1) # len! return U Being mad I just wanted to know in how many ways the drawing requirements could be fullfilled, cause this would allow a more contrieved approach. Just immagine all solutions being ordered and given a number (e.g. the order in which they were to be generated by a straight forward backtracking algoritme), and a way to determine the number of solutions right to any point in that ordered solution space. So we know the number of solutions, and can directly 'draw' one with random.choice(range(nr-of-solutions)). Now we will use a straightforward backtracking algoritme to generate the solutions in the before mentioned order. *But* instead of generating all possibilities we skip those parts of the solution tree in which the drawn solution can't be found. This would lead us straight to the anwser:) > I thought of another approach that might solve your problem -- to use a > randomized algorithm which admits a relatively small but still non-zero > probability to the assignments you'd prefer to proscribe. Then your > daughters could comfort themselves with the thought that they're > unlikely to have to give/receive presents to/from each other. For I could live with this, but they would object fearcefully if it happened. > instance, you could get everyone to assign a positive number to everyone > else. They should assign lower numbers to people they'd rather not give > presents to (perhaps you don't have to worry too much about who they'd > rather not receive presents from, since they're not supposed to know, > anyway). Say we decide to call the people in your family F={P_1, ..., > P_n}. Let G_0=R_0=F. Here, G stands for givers, R for receivers. > Construct sets G_i, R_i inductively as follows: > Choose a person P randomly from G_{i-1}. They've given you a function > f:F->{positive numbers}. > Let T=sum {f(P_l) | P_l in R_{i_1}} Choose a person Q at random from > R_{i-1} in such a way that the probability of a person Q' being chosen > is given by f(Q')/T. > Let G_i=G_{i-1}\P, R_i=R_{i-1}\Q, and let the corresponding pair be > (P,Q). Tell P that they're to give something to Q. As I said, my mind is blurred, but I think this doesn't account for me not being allowed to draw myself. This is not a matter of preference, it's essential:) -- groetjes, carel From emuller at painewebber.com Thu Nov 11 18:48:35 1999 From: emuller at painewebber.com (emuller at painewebber.com) Date: Thu, 11 Nov 1999 23:48:35 GMT Subject: Win32: CreateProcess wsetup program problem Message-ID: <80fkki$kmg$1@nnrp1.deja.com> I wrote a wrapper to CreateProcess that runs a program with args and waits until it ends. It works great for most programs (ie..calc, notepad, net, etc, etc, etc), but when I use it to run a setup.exe program (NAV 5.0 to be exact), the setup program starts and an exit value of 0 is returned to me, but the setup program just started. I figure that the setup program is doing something, then spawning another process to do the install (a _SETUP.EXE..something or other) and detaching itself from that process, letting it just run on.... Is there anyone out there who knows how I can pause until that other program (or whatever happens) is done? I am using the following code in a module called win32helper.py (BTW: If anyone would like to use this code, go ahead. I hope to write a bunch of helper functions and put them here, then post them someday) import win32api import win32security import win32process import pywintypes import win32con import win32event def RunWait(cmd, args=""): pHandle, tHandle, pId, tId = win32process.CreateProcess(cmd," " + args,None,None,0,0,None,None,win32process.STARTUPINFO()) win32event.WaitForSingleObject(pHandle,win32event.INFINITE) exitCode = win32process.GetExitCodeProcess(pHandle) win32api.CloseHandle(pHandle) win32api.CloseHandle(tHandle) return exitCode Sent via Deja.com http://www.deja.com/ Before you buy. From Gareth.McCaughan at pobox.com Fri Nov 26 17:33:39 1999 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: 26 Nov 1999 22:33:39 +0000 Subject: Python complaints References: <867lj85g4c.fsf@g.local> <86so1v4jlj.fsf@g.local> <86ln7m2t31.fsf@g.local> Message-ID: <86d7sw288s.fsf@g.local> Michael Hudson wrote: > This leads to a thought: would it be possible using lisp's silly > amount of flexibility to get the reader to auto-paranthesize (word? > doubt it): > > defun our-member (obj lst) > if null lst > nil > if eql (car lst) obj > lst > our-member obj (car lst) > > based on indentation, as > > (defun our-member (obj lst) > (if (null lst) > nil > (if (eql (car lst) obj) > lst > (our-member obj (car lst))))) > > or is whitespace ignorance built-in? It's built in. It might conceivably be possible to hack the reader to grok whitespace like this, but it would be rather a pain. It would certainly be possible to write your own reader (which would call the Lisp reader to do most of its work) that understood whitespace. I don't think it would be a good idea, though, any more than it would be a good idea for Pythonistas moving from C to pass all their code through a translator that turns code with {...} into indented code. Or for C programmers more used to Pascal-like languages to do #define BEGIN { #define END } and the like. (I believe the source for the original Bourne shell is full of that sort of abomination.) It's almost certainly less effort to learn to live with a language's syntax than to work around it, and it makes it much less painful reading other people's code or showing them yours. -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From I.Clarke at strs.co.uk Tue Nov 30 09:47:19 1999 From: I.Clarke at strs.co.uk (Ian Clarke) Date: Tue, 30 Nov 1999 14:47:19 +0000 Subject: Recursion? References: <38421570.9C3D9AEC@videotron.ca> Message-ID: <3843E377.58EBFF97@strs.co.uk> > Can I use recursion in python? yes -- Ian Clarke Email: I.Clarke at strs.co.uk Homepage: http://www.gnu.demon.co.uk/ Also see: http://freenet.on.openprojects.net/ "All we see and all we seem is but a dream within a dream" From gvwilson at nevex.com Mon Nov 29 11:29:30 1999 From: gvwilson at nevex.com (Greg Wilson) Date: Mon, 29 Nov 1999 11:29:30 -0500 Subject: performance of tuple-less Python? Message-ID: Has anyone ever built a version of Python that didn't include tuples, and looked at the performance of code that consistently used lists instead? I'm curious as to whether the use of tuples (which I believe are conceptually redundant) actually has a significant positive impact on the interpreter's performance on non-trivial codes (i.e. once caching, instruction ordering, and all other effects have come into play). Thanks, Greg From piet at cs.uu.nl Wed Nov 10 04:41:35 1999 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 10 Nov 1999 10:41:35 +0100 Subject: __str__ vs. __repr__ References: <199911041325.IAA14001@eric.cnri.reston.va.us> <000001bf275c$02370d20$1d2d153f@tim> Message-ID: >>>>> Toby Dickenson (TD) writes: TD> "Tim Peters" wrote: >> Let me back off to what repr and str "should do": >> >> repr(obj) should return a string such that >> eval(repr(obj)) == obj TD> I don't understand the motivation for this requirement. Why would TD> anyone want to pass such a string to eval? If you anticipate the need TD> for reconstructing the object from a textual representation, then TD> surely pickle is a better option? for example, if you would want to write a couple of variables to a file in the form of python statements: var=value. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: Piet.van.Oostrum at gironet.nl From s323140 at student.uq.edu.au Tue Nov 2 10:18:05 1999 From: s323140 at student.uq.edu.au (Rob Hodges) Date: 03 Nov 1999 01:18:05 +1000 Subject: Assorted Questions regarding the future of Python... References: <6D8A17398E28D3119F860090274DD7DB49833A@pces.cadlab.it> Message-ID: Alessandro Bottoni writes: > 3) Visual Basic has two advantages on Python: it can compile programs (OK: I > know that we can generate "frozen" Python programs with "Freeze") Unless something has changed dramatically since I last used windoze, VB is not compiled (in the sense of native machine code) any more than a frozen python program; rather, VB "executables" have a small header of native code that launches the vbrunxxx.dll (interpreter) to run the bytecode that makes up the rest of the file. Which is more or less the equivalent of writing "#! /usr/bin/env python" at the top of your python script in UN*X, providing a corresponding .pyc has been generated. Or double-clicking a .pyc file in windoze, for that matter. So either way, your users have to either have the python interpreter or the appropriate vb dll somewhere on their system. Someone please correct me if I'm wrong. (Though there's no way I'll ever touch VB <*shudder*>; just that I wouldn't like to be spreading disinformation.) -Rob From l.szyster at ibm.net Mon Nov 29 13:05:31 1999 From: l.szyster at ibm.net (Laurent Szyster) Date: Mon, 29 Nov 1999 19:05:31 +0100 Subject: XML to in-memory tree? References: Message-ID: <3842C06B.84C431D3@ibm.net> Greg Wilson wrote: > > Hi. Has anyone built a layer on top of XMLLIB that will load an > XML document into an in-memory (similar to the one built by > explicit calls to HTMLgen)? > Thanks, > Greg if you don't mind using a c module (namely pyexpat, the wrapper around James Clark famous Expat), there is Greg Stein qp_xml.py you can find it somewhere at it's not very orthodox, but quite convenient Laurent Szyster From emile at fenx.com Thu Nov 25 11:01:16 1999 From: emile at fenx.com (Emile van Sebille) Date: Thu, 25 Nov 1999 08:01:16 -0800 Subject: Alphabetized dictionary listings Message-ID: <053501bf375e$97098420$01ffffc0@worldnet.att.net> Ken, It sounds like you're looking for something like this. #-------Start Code Fragment-------- def display(d): keys = d.keys() keys.sort() for key in keys: print "%3d %10s : %s" % (d[key][1], key, d[key][0]) def putkeys(mDict, mList): " put keys only in a dict while preserving entry sequence " seq = len(mDict) for key in mList: mDict[key]=[[],seq] seq = seq + 1 def putdata(mDict, mList): " put data in dict by preserved sequence " for key, data in mDict.items(): data[0]=mList[data[1]] mDict[key] = data myDict = {} myKeys = ['Abel', 'Dexter', 'Francis', 'Matthew', 'Samantha', 'Tyrone'] myData = ['lebA', 'rexteD', 'sicnarF', 'wehttaM', 'ahtnamaS', 'enoryT'] putkeys(myDict, myKeys) putdata(myDict, myData) myNewKeys = ['AAbel', 'DDexter', 'FFrancis', 'MMatthew', 'SSamantha', 'TTyrone'] myCompleteData = ['lebA', 'rexteD', 'sicnarF', 'wehttaM', 'ahtnamaS', 'enoryT', 'lebAA', 'rexteDD', 'sicnarFF', 'wehttaMM', 'ahtnamaSS', 'enoryTT'] putkeys(myDict, myNewKeys) putdata(myDict, myCompleteData) display(myDict) #-------End Code Fragment-------- -- Emile van Sebille emile at fenx.com ------------------- Ken Power wrote in message news:383529e0.682634 at news1.mysolution.com... > After reading my post I realized I undervalued what I am really > attempting to accomplish. Thank you everyone for there help to this > point. The info about hash values now makes sense. Ok, here is what I > am really trying to do: > > Give a value to a key from a list. However, the values in a list are > in a prescribed order and must be linked to a specific key in the > dictionary. I tried to demonstrate that in the previous post, linking > the list values (names spelled backward) to a specific key in the > dictionary. In my example, I wanted the names to match. Understandably > if I placed the values in a dictionary in the first place, I could use > the keys to match each other, however that would be ridiculous :), > especially since my goal is 'dynamicly' created dictionaries > (dictionaries created during run-time, I guess). O well, I ramble > now. > Here is what I wanted as output from the previous example: > >>>> for key in myDict.keys(): > > print key, myDict[key] > > > > > >Tyrone enoryT > >Samantha ahtnamaS > >Francis sicnarF > >Abel lebA > >Matthew wehttaM > >Dexter retxeD > > Guess I'll have to approach the problem from another angle...... > -------------------------------- > Ken Power > uncle_wiggly at bigfoot dot com > -------------------------------- > > -- > http://www.python.org/mailman/listinfo/python-list > > From cjensen at be-research.ucsd.edu Wed Nov 17 14:54:30 1999 From: cjensen at be-research.ucsd.edu (Curtis Jensen) Date: Wed, 17 Nov 1999 11:54:30 -0800 Subject: Multi-Dimensional Arrays. References: <3832F2B9.F64C8AD7@be-research.ucsd.edu> Message-ID: <383307F6.B8F02BD7@be-research.ucsd.edu> Allow me to refine the question. If I make a list of lists to be my multi-dimensional array, how do I pass that into C? PyArg_ParseTuble(args, "?", &x)? What would go in place of the "?"? Or would it be done a different way. Then to pass it back to Python, I would return what? Could I use Py_BuildVal("?", x) ? Curtis Jensen wrote: > I'm working on a Python user interface that will be connected to some > fortran code with heaps of multi-dimensional arrays. I can't seem to > find any references to multi-dimensional arrays in Python. Is there > an easy way to create multi-dimensional arrays in Python? > > -- > Curtis Jensen > cjensen at be-research.ucsd.edu > http://www-bioeng.ucsd.edu/~cjensen/ > FAX (425) 740-1451 > > -- Curtis Jensen cjensen at be-research.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeremy at cnri.reston.va.us Tue Nov 2 11:51:54 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Tue, 2 Nov 1999 11:51:54 -0500 (EST) Subject: newbie intro recs? In-Reply-To: <381E3205.BEFDE12C@home.com> References: <381E3205.BEFDE12C@home.com> Message-ID: <14367.5802.984523.523601@goon.cnri.reston.va.us> It sounds like Learning Python would be perfect for you. It assumes you have programmed before, but not that you are expert in one or many languages. Jeremy From culliton at clark.net Tue Nov 2 09:51:31 1999 From: culliton at clark.net (Tom Culliton) Date: Tue, 02 Nov 1999 14:51:31 GMT Subject: (off topic) Re: About RedHat 6.1 install program References: <7vm92d$i1e$1@nnrp1.deja.com> <000701bf2514$01458490$f29b12c2@secret.pythonware.com> Message-ID: In article <000701bf2514$01458490$f29b12c2 at secret.pythonware.com>, Fredrik Lundh wrote: >johndoe0521 at my-deja.com wrote: >> I think this might be python's problem. > >have you contacted redhat? did they tell you >to ask here? > >if not, try: > >http://www.redhat.com/cgi-bin/support_switch > >if they *did* tell you to ask here, you most provide >more information. what did they say? what errors There are at least two problems, first a mount/unmount problem in Red Hat's logic, second an extra comma on line 1508 line of todo.py. The real trigger seems to be when you run out of disk space after packaage selection and have to back up. Go to the following URL, then to the query page, and query for the "Red Hat Linux", "6.1", "installer" package, and you should find several (178) bugzilla items possibly related to your problem. Including "python" in the description field as a criteria will narrow the list some (31 items). ;-) http://developer.redhat.com/bugzilla/ Bottom line the new Anaconda installer is NEW, and like too mch new software hasn't had enough of the wrinkles shaken out. The switch to gnorpm in RH 6.0 was just as bad, the app was several steps back from glint which it replaced, the version with 6.1 is miles better but I still know at least 3 ways to crash it. Over all Red Hat tends to push stuff out the door a little early for my taste. From python-list at teleo.net Sat Nov 13 11:47:37 1999 From: python-list at teleo.net (Patrick Phalen) Date: Sat, 13 Nov 1999 08:47:37 -0800 Subject: A Modest Proposal -- In-Reply-To: References: <99110613580407.02970@quadra.teleo.net> <80jqqo$n3m$1@newshost.accu.uu.nl> Message-ID: <99111308583701.02728@quadra.teleo.net> [Magnus L. Hetland, on Sat, 13 Nov 1999]: :: But - if you have XPPMS, why do you need XWTSNTSDL? You could just :: transform :: :: This is some text :: :: into :: :: This is some text :: :: and Bob's your uncle... Then you can use standard XML tools... :) I am against this notion, for several reasons. 1. XPPMS should disavow any attempt to do anything useful. I thought we had all agreed to this. It's in the spec! 2. It gratuitously introduces containment and well-formedness, which, in turn, threatens several key objectives of XWTSNTSDL, XGNBAML, and XACL, namely: * Make XML software significantly harder to write * Make source files significantly harder to read We must be especially cautious not to introduce any changes at this point which might make XML easier to teach to beginners. From python-list at teleo.net Sat Nov 6 15:11:43 1999 From: python-list at teleo.net (Patrick Phalen) Date: Sat, 6 Nov 1999 12:11:43 -0800 Subject: JPython and NetBeans and Java envy (Was Re: Python and Smalltalk and Java envy) In-Reply-To: <382484F1.F8B8D712@home.com> References: <1270663667-24391282@hypernet.com> <7vqkqq$oa7$1@nnrp1.deja.com> <382484F1.F8B8D712@home.com> Message-ID: <99110612201506.02970@quadra.teleo.net> [Wostenberg, on Sat, 06 Nov 1999]: :: Intersting observation. Perhaps it comes down to those of us who are :: comfortable with niche languages (Python, Smalltalk, Lisp) and those who :: suffer Java-envy . Do Python people, Ada advocates, or little Lispers wring :: there hands about the fact "we are not the most used language?" Why should :: Smalltalkers? Speaking of Java envy, Barry Warsaw pointed out the other day on the JPython list that www.netbeans.com is running a survey to pick the best scripting language to be integrated with NetBeans. (You'll find the form in their left navbar.) I won't reveal the *overwhelming* winner, thus far. Find out for yourself. ;) I-swear-I-only-voted-twice-ly-y'rs -patrick From gawron at obop.com.pl Fri Nov 19 06:16:22 1999 From: gawron at obop.com.pl (=?iso-8859-2?Q?Przemys=B3aw?= G. =?iso-8859-2?Q?Gawro=F1ski?=) Date: Fri, 19 Nov 1999 12:16:22 +0100 Subject: Running Exel Message-ID: <38353186.9D9124EF@obop.com.pl> How can I run MS Exel via OLE using Python (with windows ext.) ? Thankx Przemek -- Przemyslaw G. Gawronski UIN:8358522 mailto:gawronskip at usa.net mailto:gawron at obop.com.pl From tiddlerdeja at my-deja.com Mon Nov 8 12:40:11 1999 From: tiddlerdeja at my-deja.com (tiddlerdeja at my-deja.com) Date: Mon, 08 Nov 1999 17:40:11 GMT Subject: Psion JVM Message-ID: <8071tr$9ar$1@nnrp1.deja.com> Has anyone here tried JPython on a Psion JVM (like the 5mx I think). Any information is appreciated. Sent via Deja.com http://www.deja.com/ Before you buy. From MHammond at skippinet.com.au Thu Nov 4 18:14:52 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Thu, 04 Nov 1999 23:14:52 GMT Subject: return boolean from functions References: <7vrq9b$hmr$1@nnrp1.deja.com> Message-ID: Michael Hudson wrote in message ... >a_olme at my-deja.com writes: > >Well, you could return 1 for true and 0 for false: > >>>> print 1==1, type(1==1), 1==0, type(1==0) >1 0 > >Python does not have a distinct boolean type, if that's what you're >asking. Empty lists, empty strings, 0, 0L and 0.0 are false, >everything else is true (except for instances of classes that have >__nozero__ methods, which get to decide for themselves). Actually, Python sort-a does have a concept of booleans. There are PyTrue and PyFalse objects, but they are not exposed to the runtime in any meaningful way. Eg: >>> 1==1 1 >>> 1 is 1 1 >>> (1==1) is 1 0 >>> Not that this really means anything practical, but there you have it... Mark. From sonic at sega.net Tue Nov 30 16:47:14 1999 From: sonic at sega.net (sonic at sega.net) Date: Tue, 30 Nov 1999 21:47:14 GMT Subject: Grabbit two now available for FREE 6200 Message-ID: This amazing little has now got a whole lot better, and Costech is please to offer it to our friends for free. Enjoy the power http://www.costech.com/Products/Grabit/grabit.html vwtrzsvweev From lobozc at my-deja.com Wed Nov 24 17:17:06 1999 From: lobozc at my-deja.com (lobozc at my-deja.com) Date: Wed, 24 Nov 1999 22:17:06 GMT Subject: filter function question - list processing in Python References: <81f18b$hor$1@nnrp1.deja.com> <383BF71F.3E413E33@compaq.com> Message-ID: <81ho50$g15$1@nnrp1.deja.com> 1. Thank you for your answers. I infer from them that my reading of _standard_ list processing functions in Python was correct. 2. I suspect that the second part of my posting may be a valid postulate then. Since list processing is so useful Python should consider adding a good set of primitives to the core library - not as an external package. In article <383BF71F.3E413E33 at compaq.com>, Greg Ewing wrote: > lobozc at my-deja.com wrote: > > > > How should I pass additional parameter in 'filter'? 'map' has them, > > filter doesn't - why? Say I have a list ['xxx.py','xxx.pyc'] and I want > > to have a function isExtension(x,'.py') > > [No, I'm not interested in using lambda here in general]. > > Why not? That's the shortest way to do it: > > def filterExt(items, ext): > return filter(lambda x, ext=ext: isExtension(x,ext), items) > > However, a more Pythonic way of writing that is > > def filterExt(items, ext): > result = [] > for x in items: > if isExtension(x, ext): > result.append(x) > return result > > which is longer-winded but clearer. If you want something which > is both short-winded and clear, you might like to try my List > Comprehension syntax extension, which allows you to write > > def filterExt(items, ext): # NOT STANDARD PYTHON > return [x for x in items if isExtension(x, ext)] > > The List Comprehensions patch is available from my web page: > http://www.cosc.canterbury.ac.nz/~greg > > Greg > > - which I can call with various > > extensions to filter the list in variuos ways - how am I supposed to do > > that? [No, I'm not interested in using lambda here in general]. > > > > In general, I note that Python has some standard functions operating on > > lists but they are curiously limited. It is a pity, since these are the > > functions which reduce line count significantly - as well as make > > programming safer. I wonder what are the chances of repeating with > > lists what Python did with regular expressions - copying the > > functionality from a well tested and popular product? > > > > Mathematica has a set of list processing functions. As one can expect > > from an essentially functional language and a product where most > > operations are done by list processing - for the last 10 years - this > > set is well thought out, complete and very, very useful. > > > > [For description see > > http://documents.wolfram.com/v4/frames/frames.html, press button 'built- > > in functions', on the leftmost panel 'programming', to the right of it > > press 'functional programming' - eventually look for functions like > > Map, Fold, Apply etc.]. > > > > Sent via Deja.com http://www.deja.com/ > > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From tellis at giasbma.vsnl.net.in Wed Nov 24 11:58:51 1999 From: tellis at giasbma.vsnl.net.in (Philip Tellis) Date: Wed, 24 Nov 1999 16:58:51 +0000 Subject: Absolute newbie question Message-ID: Where are the man pages for python? I am new to python, and would like to look through the man pages before I start. Someone please help. Philip From gmcm at hypernet.com Tue Nov 9 09:58:02 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 9 Nov 1999 09:58:02 -0500 Subject: README: Python-URL! - the weekly guide to Python resources (Nov 9) Message-ID: <1269963015-19149073@hypernet.com> This week on comp.lang.python we find: Evan Simpson's one page description of the anatomy of Zope: http://www.deja.com/getdoc.xp?AN=544506548 Paul Duffin's speculation about how "stubbed" Tcl might be used by Tkinter: http://www.deja.com/getdoc.xp?AN=545858112 The __str__ vs __repr__ thread rages on. Guido explains the rationale: http://www.deja.com/getdoc.xp?AN=544209311 Tim clarifies the problem: http://www.deja.com/getdoc.xp?AN=544718491 Bernhard Herzog makes an interesting proposal: http://www.deja.com/getdoc.xp?AN=544360351 while others split on whether "eval(repr(obj)) == obj" is a valuable property or a wart. Jean-Claude Wippler announces a stable beta of his Python wrappers for MetaKit (a cross-platform embedded database with intriguing properties): http://www.equi4.com/metakit/python.html Regsitration for IPC8 is now online: http://www.python.org/workshops/2000-01/registration.html and prompts some discussion of travel arrangements. Two new Python books get rave reviews: David Beazley's Python Essential Reference and Fredrik Lundh's ebook: (the eff-bot guide to) The Standard Python Library (although technical / platform problems create some controversy for the eff-bot!). http://www.python.org/psa/bookstore/ Greg Ewing compares Python and Ruby and makes some interesting observations: on extension writing interface: http://www.deja.com/getdoc.xp?AN=543792249 on the object model: http://www.deja.com/getdoc.xp?AN=544255921 Python scores points on rec.humor.funny: http://www.netfunny.com/rhf/jokes/99/Nov/perl.html ============================================= Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the center of Pythonia http://www.python.org 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 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=AL L&format=threaded&showsort=date&maxhits=100&groups=co mp.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/ 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 http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From lobozc at my-deja.com Tue Nov 23 16:34:10 1999 From: lobozc at my-deja.com (lobozc at my-deja.com) Date: Tue, 23 Nov 1999 21:34:10 GMT Subject: filter function question - list processing in Python Message-ID: <81f18b$hor$1@nnrp1.deja.com> How should I pass additional parameter in 'filter'? 'map' has them, filter doesn't - why? Say I have a list ['xxx.py','xxx.pyc'] and I want to have a function isExtension(x,'.py') - which I can call with various extensions to filter the list in variuos ways - how am I supposed to do that? [No, I'm not interested in using lambda here in general]. In general, I note that Python has some standard functions operating on lists but they are curiously limited. It is a pity, since these are the functions which reduce line count significantly - as well as make programming safer. I wonder what are the chances of repeating with lists what Python did with regular expressions - copying the functionality from a well tested and popular product? Mathematica has a set of list processing functions. As one can expect from an essentially functional language and a product where most operations are done by list processing - for the last 10 years - this set is well thought out, complete and very, very useful. [For description see http://documents.wolfram.com/v4/frames/frames.html, press button 'built- in functions', on the leftmost panel 'programming', to the right of it press 'functional programming' - eventually look for functions like Map, Fold, Apply etc.]. Sent via Deja.com http://www.deja.com/ Before you buy. From edwardam at home.com Tue Nov 30 00:01:59 1999 From: edwardam at home.com (Edward Muller) Date: Tue, 30 Nov 1999 05:01:59 GMT Subject: 50% Python content :) (Distributed computing) References: <816010E2456BD111A48700805FBBE2EEFDF862@ex-quebec-u1.baan.com> Message-ID: <38435A43.34A434BE@home.com> It's really a matter of what you want to do. So, what do you want to do? I've used xmlrpclib (see www.pythonware.com for the Python XML-RPC Library; see www.xml-rpc.com for details on the specs) very successfully in the field and for personal use. It's a great way to conact another PC, have it do something and return the results. Gaetan Corneau wrote: > Hello, > > Sorry if my question is not strictly a Python question. > > I would like to explore distributed programming, and I think Python would be > the right tool for that. I don't want to produce industrial-strenght code > right now, but learn the basics. I'm not really interested in the > "middleware" aspects, so I didn't subscribe to the "Python Distributed > Objects" SIG right away. I just want to answer questions like how do I > partition a monolithic program to run on multiple computers? > > I went to the bookstore, and found some title (not with Python), but I > wasn't sure which one to buy. Those are expensive, and I thought that > someone here could point me in the right direction. I'm looking for > practical, hands-on stuff, if possible. > > Thanks in advance, > ______________________________________________________ > Gaetan Corneau > Software Developer (Quality Assurance Team) > BaaN Supply Chain Solutions > http://www.baan.com > E-mail: Gaetan_Corneau at baan.com > Tel: (418) 266-8252 > ______________________________________________________ > "Profanity is the one language all programmers know best" From I.Clarke at strs.co.uk Thu Nov 11 07:01:26 1999 From: I.Clarke at strs.co.uk (Ian Clarke) Date: Thu, 11 Nov 1999 12:01:26 +0000 Subject: Intelligent strptime? References: <19991110171256.A5196@optiplex.palga.uucp> Message-ID: <382AB016.D45727D8@strs.co.uk> > Does there exist an intelligent strptime? "26/11/99", for example, can _only_ > mean the 26th November of this year, and the chance that "14:11:12" means > 14 november 1912 is very small. Is there a module/function that guesses the > format? There isn't doubt very often, only for 12/11/99, US is 11 december, > Europe is 12 November (isn't it?). While I don't know what the application is, if you are processing user input I strongly recommend against doing this. In a project I am working on the issue of whether to provide a "best guess" as to a date came up, but we decided that it was much better if a date had been entered incorrectly to furnish the user with an error, than attempt to correct that error automatically. Sure in the short term it makes life a little easier for the user, but it also allows them to get used to the computer correcting their errors, and when the time comes that the computer cannot correct their error, or makes an incorrect guess, they will feel that there is something wrong ("I have always entered dates in MMDDYY format and it worked fine, why shouldn't it work now?"). Ian. -- Ian Clarke Email: I.Clarke at strs.co.uk Homepage: http://www.gnu.demon.co.uk/ Also see: http://freenet.on.openprojects.net/ "All we see and all we seem is but a dream within a dream" From loewis at informatik.hu-berlin.de Mon Nov 29 14:45:28 1999 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 29 Nov 1999 20:45:28 +0100 Subject: pre/post-condition support? References: <_Re04.8705$cz3.315483@nnrp1.uunet.ca> Message-ID: "Greg Wilson" writes: > Has anyone experimented with Python extensions to support programming by > contract (pre/post conditions on methods + state assertions that are > respected by inheritance)? If so, I'd welcome pointers. As for pre/post conditions and state assertions: with Python 1.5.x, there is the assert statement: class Data: def __init__(self):self.items = {} def add(self,key,value): assert (not self.items.has_key(key)) self.items[key] = value d = Data() d.add("milk","white") d.add("milk","white") As for respecting inheritance: I guess approaches taken in other languages work in Python as well: class Base: def method(self,params): assert preconditions result = self.method_implementation(self,params) assert postconditions return result You can probably apply a number of reflection-based tricks in Python; I doubt that this would make your code more understandable. Regards, Martin From lobozc at my-deja.com Thu Nov 25 16:04:20 1999 From: lobozc at my-deja.com (lobozc at my-deja.com) Date: Thu, 25 Nov 1999 21:04:20 GMT Subject: filter function question - list processing in Python References: <1268631776-5935125@hypernet.com> Message-ID: <81k88j$5m3$1@nnrp1.deja.com> > all-functional-programmers-are-rabid-ly y'rs And where's the smile at the end of that sentence? :-) > But, I suspect, those who regularly use filter and reduce are > vastly outnumbered by those who aren't sure what they do. So yeah, only now I noticed that examples of their use are conspicuous by their absence... ... and I don't have time to write the package right now, either. Nor enough python skills. In article <1268631776-5935125 at hypernet.com>, gmcm at hypernet.com wrote: > lobozc at my-deja.com writes: > > > 2. I suspect that the second part of my posting may be a valid > > postulate then. Since list processing is so useful Python should > > consider adding a good set of primitives to the core library - > > not as an external package. > > A good set of primitives with intuitive interfaces and obvious > names that raises lots of excitement would probably be > warmly welcomed. > > But, I suspect, those who regularly use filter and reduce are > vastly outnumbered by those who aren't sure what they do. So > rabid enthusiasm may be hard to come by. > > all-functional-programmers-are-rabid-ly y'rs > > - Gordon > > Sent via Deja.com http://www.deja.com/ Before you buy. From steve at acer.spvi.com Sun Nov 7 22:28:21 1999 From: steve at acer.spvi.com (Steve Spicklemire) Date: Sun, 7 Nov 1999 22:28:21 -0500 (EST) Subject: Python for children..... In-Reply-To: <801p16$10s$1@vvs.superst.iae.nl> (message from Carel Fellinger on 6 Nov 1999 18:37:42 +0100) References: <9911051740130D.02530@william.jinsa.org> <7GOU3.272$Ae3.194028@news-dal.corridex.com> <801p16$10s$1@vvs.superst.iae.nl> Message-ID: <199911080328.WAA24200@acer.spvi.com> I've also been playing with teaching python to 'children' (well.. middle schoolers anyway... don't tell *them* they are children. ;->) I've had some luck with my little PyBots toy... it needs some work, when I get more time.. but it's enough to teach some simple stuff... Basically it's a Macromedia Director movie with a single 'cast member', a circle with a tab. On the mac version the movie imports a python module (called robots.py) and calls three fuctions over and over until the user presses the quit button. The functions are: getX(), getY() and getRot(). They return the horizontal position, vertical position, and angle of rotation of the ball. With just that you can teach them if, while, for, functions, object orientation etc.. for a slightly advanced example I came up with this: ---------------------------------------------------------------------- import random class MovingObject: x = 100 y = 100 vx = 4 vy = 4 omega = 1 theta = 0 def getX(self): if self.x > 300: self.vx = -4 + 2*random.random() if self.x < 40: self.vx = 4 + 2*random.random() self.x = self.x + self.vx return self.x def getY(self): if self.y > 300: self.vy = -4 + 2*random.random() if self.y < 40: self.vy = 4 + 2*random.random() self.y = self.y + self.vy return self.y def getRot(self): if self.theta > 360: self.omega = -1 + 2*random.random() if self.theta < 0: self.omega = 1 + 2*random.random() self.theta = self.theta + self.omega return self.theta m = MovingObject() def getX(): return m.getX() def getY(): return m.getY() def getRot(): return m.getRot() if __name__=="__main__": print getX() print getY() print getRot() Evan Simpson wrote: > Now I'm preparing to introduce my children to programming through Python. > I'm starting with their fascination with Alice, the 3-D animation workshop > which even my 6 year old enjoys playing with (though he doesn't script it... > yet). From ivanlan at callware.com Tue Nov 2 16:51:13 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Tue, 02 Nov 1999 14:51:13 -0700 Subject: Reading .lnk files Message-ID: <381F5CD1.8714622F@callware.com> Hi All-- Is there a function in the Win32 stuff to read .lnk files? I'm looking for a *minimal* script to do nothing but read a .lnk given on the command line and spit the contents out on stdout. Thanks, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From news at dorb.com Wed Nov 10 16:16:14 1999 From: news at dorb.com (Darrell) Date: Wed, 10 Nov 1999 16:16:14 -0500 Subject: random function References: <3829D78B.7FC142F4@scripps.edu> Message-ID: Python Library Reference random () Returns the next random floating point number in the range [0.0 ... 1.0). >>> import random >>> random.random() 0.981053289833 >>> -- --Darrell Olivier Roche wrote in message news:3829D78B.7FC142F4 at scripps.edu... > Hi everybody > > By looking at the index of the python documentation index i haven't seen > any > random function description. Could somebody tell me if a random function > > to generate random number (between 0 and 1) exists ? > > Thanks, > > Olivier > > > -- > http://www.python.org/mailman/listinfo/python-list From timmuddletin at news.vex.net Sun Nov 28 16:32:08 1999 From: timmuddletin at news.vex.net (tim muddletin) Date: 28 Nov 1999 21:32:08 GMT Subject: "Import error"--MySQLmodule broke betw. Python 1.5.1 and 1.5.2 References: <38418F71.A39C213E@dds.nl> Message-ID: <81s70o$1nne$1@hub.org> On Sun, 28 Nov 1999 21:24:17 +0100, Martian wrote: >The MySQLmodule hasn't changed--indeed, hasn't since Oct. 1998 Is there any reason you need to use the old module? According to my files ( http://www.vex.net/~x/parnassus/apyllo.py?i=82701837 ), there seems to be a newer (and quite improved sounding) MySQL module here... http://starship.python.net/crew/adustman/MySQLdb.html (note: i don't know anything about it, never having used MySQL. I'm just a humble python resource librarian. <-: Though i don't seem to have record of the old module in my database! Hmmm...) From skip at mojam.com Fri Nov 5 14:23:37 1999 From: skip at mojam.com (Skip Montanaro) Date: Fri, 5 Nov 1999 13:23:37 -0600 (CST) Subject: Can Zope be used as a CVS server? In-Reply-To: References: Message-ID: <14371.11961.82152.303247@dolphin.mojam.com> Stefan> Could I use Zope for the functionality of a CVS server? Dunno, and it's not obvious (to me) why you'd want to do that. Could you motivate your question by providing some rationale for not using CVS itself? Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/ 847-971-7098 | Python: Programming the way Guido indented... From aa8vb at yahoo.com Mon Nov 22 13:46:10 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Mon, 22 Nov 1999 13:46:10 -0500 Subject: Python mymalloc.h bug? (was: Re: Building wxPython) In-Reply-To: <00e301bf32c6$e77aee90$0301a8c0@easystreet.com> References: <80s0b4$g5n@mail.psy.uva.nl> <19991117090214.B807152@vislab.epa.gov> <017a01bf31f8$6bbea590$1a25d2d1@jenkondev.com> <19991119064944.A996886@vislab.epa.gov> <002301bf32b5$97a5d440$0301a8c0@easystreet.com> <19991119134422.A1004588@vislab.epa.gov> <00e301bf32c6$e77aee90$0301a8c0@easystreet.com> Message-ID: <19991122134610.A1255370@vislab.epa.gov> Robin Dunn: |>NULL is defined as ((void*)0) and cannot be assigned to / compared with |>another type without a cast in C++. As this is C++, I believe they |>should be using "0" for assignments and comparisons. | |I don't know how accurate this is but I've been told that C++ compilers that |have NULL defined as ((void*)0) in their headers are the ones that are |incorrect, not the code that uses NULL. The headers are supposed to define |it as 0. Maybe you could try undef'ing it and redefining NULL to be 0 and |see what happens? I think you're right. However the IRIX headers are correct: /usr/include/stdio.h:#define NULL 0L After a bit of grepping, the culprit seems to be Python (1.5.2): /usr/local/include/python1.5/mymalloc.h: #ifndef NULL #define NULL ((ANY *)0) #endif Including at the top of helpers.cpp before you include anything else will work around the problem for that source file, but of course that's a hack, not a fix. It appears to me that the right fix is for Python's mymalloc.h, if it must define NULL (does it?), be updated to be more C++ friendly. E.g.: #ifndef NULL # ifdef __cplusplus # define NULL 0 # else # define NULL ((ANY *)0) # endif #endif I'm assuming there's some reason we can't just #include from mymalloc.h (?) -- Randall Hopper aa8vb at yahoo.com From kuncej at mail.conservation.state.mo.us Tue Nov 2 14:46:31 1999 From: kuncej at mail.conservation.state.mo.us (Jeffrey Kunce) Date: Tue, 02 Nov 1999 13:46:31 -0600 Subject: Download Python Imaging Library Handbook Message-ID: I had an old version of the handbook, and just got the new one today. I used websucker.py from the python Tools/webchecker directory. >python websucker.py http://www.pythonware.com/library/pil/handbook/index.htm --Jeff From arcege at shore.net Mon Nov 8 14:04:58 1999 From: arcege at shore.net (Michael P. Reilly) Date: Mon, 08 Nov 1999 19:04:58 GMT Subject: debuging in shared library (using gdb or ddd) References: <3821F93B.6BF2B62A@iwr.uni-heidelberg.de> Message-ID: > Hi! > > How can I debug a shared library module imported into python > > with gdb or ddd debugger ? I often start gdb with python, run the program getting an interactive shell, import the appropriate module(s) or package(s). Then I interrupt the process (cntl-C), which is captured first by GDB, not Python, set my breakpoints and finally "cont"inue the interactive interpreter: $ gdb python ... (gdb) run ... >>> import foobar >>> (gdb) break foobar_function (gdb) cont Continuing. >>> There may be some configurations where this won't work (threads, etc.), but I've used it on a lot of systems this way. -Arcege From evan at tokenexchange.com Tue Nov 16 10:45:39 1999 From: evan at tokenexchange.com (Evan Simpson) Date: Tue, 16 Nov 1999 09:45:39 -0600 Subject: Zope comparisons? (ASP, PHP, etc) References: <3821C5F6.84543AF2@yahoo.com><06lU3.259$Ae3.186544@news-dal.corridex.com> Message-ID: Christopher Petrilli wrote in message news:B455938E.5FE6%petrilli at digicool.com... > in article 06lU3.259$Ae3.186544 at news-dal.corridex.com, Evan Simpson at > evan at tokenexchange.com wrote on 11/4/99 2:26 PM: > > single file (2GB limit being worked on) and appends new versions of objects > > Just want to clarify that this is a Linux restriction, not a Zope > restriction. We use a 64-bit OID, so if the underlying OS supports larger > files, then we should continue to grow. Sorry, I should have phrased that better, and would have if I had known how widely read this posting would be :-) How about "(the capability to mount multiple storages in a single tree is being worked on, which will circumvent the Linux 2GB file-size limitation and provide other advantages)". Cheers, Evan @ 4-am From amitp at Xenon.Stanford.EDU Tue Nov 2 21:48:08 1999 From: amitp at Xenon.Stanford.EDU (Amit Patel) Date: 3 Nov 1999 02:48:08 GMT Subject: Default curses module. References: <19991031170934.A18715@optiplex.palga.uucp> Message-ID: <7vo7p8$d9a$1@nntp.Stanford.EDU> Gerrit Holl wrote: | Hello, | | why isn't the newest cursesmodule, available at | http://andrich.net/python/selfmade.html#ncursesmodule, in the standard python | distribution? | | I don't want all my users to have to recompile python for using my | colors-using program! I have avoided using colors, because I don't want my users to have to compile this module. :-( The explanation I've heard is that ncursesmodule isn't as portable as cursesmodule, so it didn't go into the standard .. - Amit From phd at phd.russ.ru Fri Nov 12 08:29:15 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Fri, 12 Nov 1999 13:29:15 +0000 (GMT) Subject: time/strptime/mktime/localtime In-Reply-To: <382C0B8B.DE2DC3A9@inka.de> Message-ID: On Fri, 12 Nov 1999, Michael [iso-8859-1] Str?der wrote: > > > > print time.strptime("1999-09-21 21:44:33", "%Y-%m-%d %T") > > > > Linux: (1999, 9, 21, 21, 44, 33, 6, 1, 0) > > Solaris: (1999, 9, 21, 21, 44, 33, 6, 1, 0) > > A couple of weeks ago I found some oddities with strptime on my > glibc-based Linux system. Someone told me that strptime in glibc is > broken. Other way around - I have problems on Solaris. On linux all goes well. Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From tim_one at email.msn.com Fri Nov 26 22:48:40 1999 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 26 Nov 1999 22:48:40 -0500 Subject: Method objects question In-Reply-To: Message-ID: <000801bf388a$4b2c4ce0$742d153f@tim> [Ben Caradoc-Davies] > ... > But the point is, why should functions found in a class namespace be > converted into methods, but functions found in an instance namespace > not converted? Both behaviors are useful, depending on the application. Guido picked the behaviors for each mechanism that he judged would be most useful most often. An obvious way to give some particular set of objects different behavior in response to a msg is via subclassing (i.e., the class mechanism need not be "abused" to achieve that end). > ... > In a nutshell, I don't see any fundamental reason why the search- > instance-namespace then search-class-namespace attribute resolution > order couldn't be used to allow method overriding on an > instance-by-instance basis. There is no "fundamental" reason. I like it the way it is, but it's too late to change now regardless. > With the current, function-to-method conversion rules, this is > impossible. As has been explained by others, it's not impossible, just clumsy. If the language had been defined your way, binding an instance attribute to a plain function would have been (at best) clumsy instead, and we'd be reading msgs now complaining about that instead <0.4 wink>. "the-class-determines-the-meaning-of-a-msg"-is-conventional-ly y'rs - tim From S.I.Reynolds at cs.bham.ac.uk Mon Nov 29 13:07:39 1999 From: S.I.Reynolds at cs.bham.ac.uk (Stuart Reynolds) Date: Mon, 29 Nov 1999 18:07:39 +0000 Subject: __getslice__ Message-ID: <3842C0EB.6357@cs.bham.ac.uk> Hmm. Ok. How do slices work then? I've written a class to do some simple structuring of data so that its easy to plot (with, say, Gnuplot.py). The class c'tor takes: - a sequence of input values [i1, i2, ... , in] - a function, f(i) --> outputi and the objects represent the sequence: - ( (i1, f(i1)), (i2, f(i2)), ... (in, f(in)), ) Things like __repr__, __len__, __getitem__ all work as expected, but __getslice__ behaves very oddly - which is strange since it all seems fairly straightforward. Any help muchly appreciated, Stu ---------------- >>> def square(x): return x*x >>> xvals = [0,1,2,3,4,5,6,7] >>> a = UnaryFnSequence(square, xvals) >>> xvals[1:] [1, 2, 3, 4, 5, 6, 7] >>> a ( (0,0), (1,1), (2,4), (3,9), (4,16), (5,25), (6,36), (7,49) ) >>> a[1:] ( (0,0), (1,1), (2,4), (3,9), (4,16), (5,25), (6,36) ) Note that the first item is still there. The last one's gone instead. The class: class UnaryFnSequence: """ The constructor takes two arguments: fn -- A unary function inputs -- An ordered sequence of inputs to the sequences, (i1, i2, ..., in) The class represents the following immutable sequence: ( (i1, fn(i1)), (i2, fn(i2)), ... (in, fn(in)), ) Slices aren't supported yet. """ def __init__(self, fn, inputs): self._inputs = inputs self._fn = fn def __len__(self): return len(self._inputs) def __getitem__(self, index): x = self._inputs[index] return x, self._fn( x ) def __repr__(self): s='( ' for x in range( len(self) ): s = s+'('+`x`+','+`self._fn(x)`+'), ' return s[:-2] + ' )' def __getslice__(self, low, high): return UnaryFnSequence(self._fn, self._inputs[low:high] ) From andy at robanal.demon.co.uk Thu Nov 4 16:23:07 1999 From: andy at robanal.demon.co.uk (Andy Robinson) Date: Thu, 04 Nov 1999 21:23:07 GMT Subject: Python Conference Hotel Change References: <199911032224.RAA10668@eric.cnri.reston.va.us> Message-ID: <3824f510.12238077@news.demon.co.uk> Guido van Rossum wrote: >The Foretec conference staff has this message about the upcoming >Python conference: > >Due to construction delays, the Hilton Alexandria Old Town will not be >completed in time for the Eighth International Python Conference. >However, we are pleased to announce that we have secured an equally >desirable facility for the conference. The new facility is the Key >Bridge Marriott in Arlington, Virginia. The Key Bridge Marriott is >conveniently located on the Virginia side of the Key Bridge in the >Rosslyn business district with easy access to restaurants, shops, and >the Rosslyn metro stop. It overlooks the Potomac River, and is a 15 >minute walk across the bridge to historic Georgetown in Washington, DC. > >(I should add that Georgetown is, if possible, an even better location >than old town Alexandria for the typical Python conference evening >activities. --Guido :-) > My memory may be fuzzy, but isn't it an even shorter stroll from there to Bardo, one of the world's biggest microbreweries? - Andy From Richard.Jones at fulcrum.com.au Thu Nov 11 22:49:18 1999 From: Richard.Jones at fulcrum.com.au (Richard Jones) Date: Fri, 12 Nov 1999 14:49:18 +1100 Subject: Random text generator In-Reply-To: Message from Rico Albanese of 1999-Nov-12 13:17:35, <382B86CF.AA1C12C9@qut.edu.au> Message-ID: <199911120349.OAA01177@envy.fulcrum.com.au> [Rico Albanese] > Can anyone tell me if there is a random text generator for Python? I > have an application that needs to generate a random password for users. > I have looked at the random and whrandom modules but they seem to create > random numbers only. > > Thanks in advance for any advice given The function you want is whrandom.choice(). See http://www.python.org/doc/current/lib/module-whrandom.html Python 1.5.2 (#3, Apr 19 1999, 13:39:26) [GCC 2.8.1] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import whrandom, string >>> whrandom.choice(string.letters + string.digits) 'P' >>> whrandom.choice(string.letters + string.digits) 'e' >>> whrandom.choice(string.letters + string.digits) 'n' >>> whrandom.choice(string.letters + string.digits) 'I' Richard From m.faassen at vet.uu.nl Wed Nov 24 14:56:30 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 24 Nov 1999 19:56:30 GMT Subject: automatic "lotjes trekken" References: <81cqnv$2ip$1@vvs.superst.iae.nl> <81e3s2$j14$2@newshost.accu.uu.nl> <383BBFB9.C9607961@compaq.com> Message-ID: <81hfte$50e$1@newshost.accu.uu.nl> Greg Ewing wrote: > Martijn Faassen wrote: >> >> Not at all. everybody here speaks Dutch anyway. (it's a conspiracy!) > Not me! > Uunlees-iit-meens-yoo-juust-haav-too-wrijt-aal-yoor-voowls-twijce, Oh, so you do speak Dutch as well. :) I-understood-that-so-it-must-be-Dutch-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From rree at nospam-oeb.harvard.edu Mon Nov 1 21:31:51 1999 From: rree at nospam-oeb.harvard.edu (Rick Ree) Date: Tue, 2 Nov 99 02:31:51 GMT Subject: a simple helper class for parsing command line options Message-ID: I threw this together to make parsing command line options and arguments a little easier than just using getopt directly. Feedback welcome. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ from getopt import getopt, error from string import ljust import sys class OptionFactory: """ A class for parsing command-line options and arguments to scripts. See below for example code that uses the OptionFactory. """ def __init__(self): self.name = None self.__shortstring = 'h' self.__longlist = ['help'] self.__options = [('help','h','help','','print this help message')] self.__args = 0 self.__argdesc = None self.args = None self.__dict = {} def __getitem__(self, item): return self.__dict[item] def add_options(self, options): """ 'options' is a sequence of tuples of the form: (label, short, long, value, desc) label = identifier for the option, used to retrieve option value after parsing the command line short = short form of option, e.g. 'h' long = long form of option, e.g. 'help' value = descriptive string of the value the option requires desc = description of the option for the help message """ for option in options: self.__add(option) def add_argdesc(self, argdesc): """ add a description of the expected arguments """ self.__argdesc = argdesc def __add(self, option): self.__options.append(option) label, short, long, value, desc = option if short: self.__shortstring = self.__shortstring+short if value: self.__shortstring = self.__shortstring+':' if long: if value: self.__longlist.append(long+'=') else: self.__longlist.append(long) self.__dict[label] = 0 def usage(self): if self.__options: optstr = ' [OPTION...]' else: optstr = '' usage = 'Usage: %s%s %s\n' % (self.name, optstr, self.__argdesc) if self.__options: usage = '%sOptions:\n' % usage for option in self.__options: label, short, long, value, desc = option if short: short = '-%s' % short if long: long = '--%s' % long if value: if short: sval = value else: sval = '' if long: lval = value; vl = '=' else: lval = ''; vl = '' else: sval = ''; lval = ''; vs = ''; vl = '' if short and long: comma = ', ' else: comma = '' s = ' %s%s%s%s%s%s' % (short,sval,comma,long,vl,lval) s = ljust(s, 30) s = '%s%s\n' % (s, desc) usage = '%s%s' % (usage, s) return usage def parse(self, argv): """ pass in sys.argv, not sys.arv[1:] """ self.name = argv[0] try: optlist, args = getopt(argv[1:], self.__shortstring, self.__longlist) for opt in optlist: self.__process_opt(opt) self.args = args except error, x: msg = 'Error parsing options: %s' % x sys.stderr.write('%s\n' % msg) sys.stderr.write('\n%s\n' % self.usage()) sys.exit(1) def __process_opt(self, opt): option, optval = opt if option in ('-h', '--help'): print self.usage() sys.exit(0) for item in self.__options: label, short, long, value, desc = item match = 0 if option == '-%s' % short: match = 1 elif option == '--%s' % long: match = 1 if match: if optval and value: entry = self.__dict.get(label) if entry: entry = [entry] entry.append(optval) self.__dict[label] = entry else: self.__dict[label] = optval else: self.__dict[label] = 1 # Run this script with options to see the OptionFactory in action if __name__ == '__main__': test_flag = 'test_flag' verbose_flag = 'verbose_flag' numreps = 'numreps' infilename = 'infilename' mystery_flag = 'mystery_flag' opts = [(test_flag, 't', 'test', '', 'test option'), (verbose_flag, 'v', 'verbose', '', 'verbose output'), (numreps, 'n', '', '#', 'do it # times'), (infilename, '', 'load-file', 'FILE', 'load FILE'), (mystery_flag, 'x', '', '', 'mystery option with no long version')] of = OptionFactory() of.add_options(opts) of.add_argdesc('[file1 file2 ...]') of.parse(sys.argv) print 'test_flag:', of[test_flag] print 'verbose_flag:', of[verbose_flag] print 'numreps:', of[numreps] print 'infilename:', of[infilename] print 'mystery_flag:', of[mystery_flag] print 'args:', of.args From Andreas.Rozek at RUS.Uni-Stuttgart.De Mon Nov 29 12:30:14 1999 From: Andreas.Rozek at RUS.Uni-Stuttgart.De (Andreas Rozek) Date: Mon, 29 Nov 1999 18:30:14 +0100 Subject: Problem with asynch. sockets under Win98, Message-ID: <3842B826.C91D6622@RUS.Uni-Stuttgart.De> Hello! I'm currently developing a distributed system which uses asynchronous socket IO under Win98. The sockets used are set to non-blocking mode, identified with "select" as being ready for IO and then read or writ- ten using "recv" or "send", resp. On the server side, "sending" to a TCP socket (which has been suc- cessfully "accept"ed before) works fine for the first time. However, whenever I try to "send" to the same socket again, I get error no. 10045 (WSAEOPNOTSUPP, Operation not supported) Does anybody have some experience with non-blocking socket IO for TCP and UDP unicast and multicast? Is there an explanation for the above- mentioned behaviour? Basically, I'm using the following statement for writing onto the soc ket: BytesSent = self.Socket.send(self.Buffer, len(self.Buffer)) (Buffer contains two characters, i.e., it's non-empty) Thanks in advance for your effort! -- Andreas Rozek Rechenzentrum Universitaet Stuttgart ****** ** ** ***** Kommunikationssysteme/BelWue-Entwicklung ** ** ** ** ** Allmandring 3a ** ** ** ** ** D-70550 Stuttgart ****** ** ** ***** *** ** ** ** Telefon: ++49 (711) 685-4514 ** ** ** ** ** Telefax: ++49 (711) 678-8363 ** ** ***** ****** E-Mail: Andreas.Rozek at RUS.Uni-Stuttgart.De From jesse at student.usyd.edu.au Wed Nov 10 08:07:29 1999 From: jesse at student.usyd.edu.au (Jesse Sweeney) Date: Wed, 10 Nov 1999 13:07:29 GMT Subject: IDLE and rlcompleter [Was: Re: making the Python case to my dept.] References: <9911051740130D.02530@william.jinsa.org> <3823FC43.CF7FBD71@python.net> <382523fc.14124721@news.usyd.edu.au> Message-ID: <382960a5.14921242@news.usyd.edu.au> On 08 Nov 1999 23:00:35 +0000, Michael Hudson wrote: >jesse at student.usyd.edu.au (Jesse Sweeney) writes: > >> Coincidentally, I had the same idea just a few days ago, and after a >> bit of tinkering, I came up with two different IDLE extensions. I've >> put the files on the web at >> >> http://www-personal.usyd.edu.au/~jsweeney/python . > >Funky! > >I had to change to and then to >(the latter is probably a misconiguration at this end, but the first >may not be). Thanks, Michael, I changed this, and fixed a few other things that I thought needed fixing, and uploaded the files again. >I'm very used to some other readline conventions such as Meta-. being >yank-last-arg and C-r being reverse-search-history and some >others. Would these be easy to add to your extension? (I know next to >nothing about Tkinter). I doubt I know much more, but that's no excuse! I'm going on the IDLE source code, extend.txt, the several extension examples that come with IDLE and Fredrik's Introduction to Tkinter whenever I need it (I had to look up the staff about text marks, for instance). Now, yank-last-arg requires knowing about the history, and extensions -- as far as I can figure -- don't get told about the history. So, that means this requires editing the IDLE source, rather than making an extension. Here's what I came up with (sorry, I don't have a working copy of patch here): 1. Add a yank_last_arg method to the History class in IdleHistory.py: def yank_last_arg(self, event): if len(self.history) == 0: self.text.bell() return "break" item = self.history[-1] wordchars = string.letters + string.digits + "_" + "." i = len(item) while i > 0 and item[i-1] in wordchars: i = i-1 last_arg = item[i:] self._put_source("insert", last_arg) return "break" 2. Bind the event in History.__init__ by adding a line of the form: text.bind("<>", self.yank_last_arg) 3. Bind a keystroke of your choosing to the function by adding a line to keydefs.py like: '<>': [''], (4. Edit Bindings.py (I think) if you want a menu item as well.) That should do it. I'll put my copy of IdleHistory.py on my website (the address is above) to make it more straightforward. reverse-search-history shouldn't be *that* much harder to implement, except that I haven't actually worked out how to capture the shell input yet. Nevertheless, notice that I'm not putting my hand up for the job. I've just noticed that the IDLE todo file (TODO.txt) mentions this: - more emacsisms: ... - incremental search? So perhaps Guido will save us all the trouble, and leave me to study for my exams ;). >> Obviously, unlike "Expand Word" these only work in the Python shell, >> not in the file-editing windows. (Now that I think about it, this >> would probably be pretty useful in those editing windows, but that >> would take some partial compilation of some sort I suppose, which is >> way too much work for me.) > >I think I'd settle for the completions being selected from the words >known to the Python shell, if that helps. Well, by a happy coincidence this is how it works at the moment. So AutoComplete.py works quite nicely in that regard, but RLComplete.py is pretty useless, because it just prints the possible completions to stdout, which is the Python shell if you've got one open, and I suppose you could kinda put the windows next to each other, but 'urk' is all I can say to that. A CallTips-style thing could be hacked together I suppose, if someone was dying for this functionality, but I doubt it's worth the effort. >Good work! > >Cheers, >Michael Thanks! Cheers, Jesse. From pnagel at tbs.co.za Thu Nov 18 05:30:23 1999 From: pnagel at tbs.co.za (Pieter Nagel) Date: Thu, 18 Nov 1999 12:30:23 +0200 (SAST) Subject: Beginning programming with Python In-Reply-To: <383195C1.826B3342@iqsoft.hu> References: <382B3A53.5816B2@callware.com> <382B3D79.74CD3E0F@email.sps.mot.com> <80p9ds$ppo$1@newshost.accu.uu.nl> <38312D55.A36EB56D@iqsoft.hu> <383195C1.826B3342@iqsoft.hu> Message-ID: On Tue, 16 Nov 1999, Nemeth Miklos wrote: > I am neither a physicist nor a mathematician, I am a simple business software > engineer. I like Python but I'd like to be convinced that Python is not only > for scientific programming, but also for business programming. Strange, I see things the other way around. I think Python is great for business software, but I would think that the scientific community would need some convincing that Python is good for scientific software too. Of course, to me, scientific software conjures up images of mathematic-intense software. Stuff like Fortran and Matlab. Or intensely paralel weather-prediction software written in C running on Beowulf clusters. Hmm. Even in *that* scenario python would be great for tying the whole together, even if the C code is responsible for the actual megaflops. -- ,_ /_) /| / / i e t e r / |/ a g e l Tangible Business Software http://www.tbs.co.za +27 12 46 8563 From ivnowa at hvision.nl Mon Nov 8 16:40:11 1999 From: ivnowa at hvision.nl (Hans Nowak) Date: Mon, 8 Nov 1999 22:40:11 +0100 Subject: Popup menus in Tkinter Message-ID: <199911082139.WAA02023@axil.hvision.nl> On 8 Nov 99, dkaznadzey at my-deja.com wrote: > Thanks A LOT ! > It worked perfectly! > What would be a good source of information on tk commands > available through Tkinter? Myself, I'm just using the Tkinter introduction by Fredrik Lundh. It doesn't cover everything (that's why it's an introduction I suppose ;-) but usually it's sufficient. For me, that is. A book would be nice though. ^_^ --Hans Nowak (zephyrfalcon at hvision.nl) Homepage: http://fly.to/zephyrfalcon You call me a masterless man. You are wrong. I am my own master. From fdrake at acm.org Tue Nov 16 14:40:22 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Tue, 16 Nov 1999 14:40:22 -0500 (EST) Subject: Final classes like in java??? In-Reply-To: <80sao7$1848$1@rtpnews.raleigh.ibm.com> References: <80sao7$1848$1@rtpnews.raleigh.ibm.com> Message-ID: <14385.45862.55010.146256@weyr.cnri.reston.va.us> Arinte writes: > Is there a way you can define your python class to be final or not able to > be inherited from? Not guaranteed, but this should be good enough: ------------------------------------------------------------------------ class FinalClass: def __init__(self): if self.__class__ is not FinalClass: raise SomeError, "you can't subclass from me!" ------------------------------------------------------------------------ Whether or not this is a good idea is another thing. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From quinn at amatho.ugcs.caltech.edu Tue Nov 30 17:25:42 1999 From: quinn at amatho.ugcs.caltech.edu (Quinn Dunkan) Date: 30 Nov 1999 22:25:42 GMT Subject: performance of tuple-less Python? References: <1268226961-30285235@hypernet.com> <943917954snz@vision25.demon.co.uk> Message-ID: On Tue, 30 Nov 1999 08:14:36 GMT, Neil Schemenauer wrote: >Phil Hunt wrote: >>In article <1268226961-30285235 at hypernet.com> >> gmcm at hypernet.com "Gordon McMillan" writes: >>> They're only redundant if the concept of mutability is >>> meaningless. A reference-based language without a concept >>> of mutability would be, um, an adventure. >> >>Why? > >Some values should be immutable. Consider if integers in Python >were mutable. You store a reference to 1 and somewhere else the >value of 1 is changed to 2. Is that not a problem? Also, you >can not (efficiently) implement hash tables. > >Maybe you mean that mutability is not required. That would be an >interesting language. How to you accomplish anything? Sometimes >you want mutability and sometimes you don't. That is why both >tuples and lists exist. See any purely functional language, like haskell. You can simulate mutability in haskell by passing monads around, but you might be surprised at how much you can get done with no side effects. And what was that party trick of changing 1 to equal 2 in forth? Maybe that's more at the language level though, but I don't know much about forth (one of these days...). From a.eyre at optichrome.com Mon Nov 29 12:30:05 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Mon, 29 Nov 1999 17:30:05 -0000 Subject: Python bugs In-Reply-To: <51C9F3C392D0D111A15600A0C99E64A9AF5690@localhost> Message-ID: <001101bf3a8f$5fe300f0$3acbd9c2@peridot.optichrome.com> > >>> import shelve > >>> s = shelve.open('foo') > >>> s.get('bar', 'baz') > Traceback (innermost last): > File "", line 1, in ? > AttributeError: get This one annoyed me more. Probably not fixable, but... >>> s = shelve.open("foo") >>> l = [] >>> s["bar"] = l >>> s["bar"] [] >>> l.append("baz") >>> s["bar"] [] -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From gerrit.holl at pobox.com Fri Nov 19 07:45:43 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Fri, 19 Nov 1999 13:45:43 +0100 Subject: Beginning programming with Python In-Reply-To: <80s22o$o0l$1@nntp9.atl.mindspring.net> References: <80p9ds$ppo$1@newshost.accu.uu.nl> <38317787.19AFDAF5@compaq.com> <80s22o$o0l$1@nntp9.atl.mindspring.net> Message-ID: <19991119134543.A4278@optiplex.palga.uucp> Aahz Maruch wrote: > >Well, not quite - you can forget the "self" in method > >declarations fairly easily... > > I don't seem to have that problem; my fingers have learned to > automatically type "(self" whenever "def" is indented. ;-) Hmm, don't you ever define a function within an IF? if __name__ == '__main__': def main(): return 'main' main() But that's ugly indeed... And what about defs in defs? regards, Gerrit. -- "We all know Linux is great...it does infinite loops in 5 seconds." (Linus Torvalds about the superiority of Linux on the Amterdam Linux Symposium) From thor at localhost.localdomain Sun Nov 14 19:18:57 1999 From: thor at localhost.localdomain (Manuel Gutierrez Algaba) Date: 15 Nov 1999 00:18:57 GMT Subject: Proposal: Python Info Collective References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> Message-ID: On Sun, 14 Nov 1999 20:56:09 GMT, Jules Allen wrote: >Thanks for the History lesson! This helps put it all in perspective >but why *something* hasn't been built before now is kind of weird. The problem we have here, it's that we need a easy method of putting many information together, so it's easy for the _newbie_ and for the wizard to find it. Trove has proved to be a failure just because it's too complex to programm it, to finish it. Why we don't attach to the simplest method of collecting info ? Why don't we make small pieces of info attributed like this: \jiji BabylMailbox Access a Babyl mailbox, which is similar to an MMDF mailbox. Mail messages start with a line containing only '*** EOOH ***' and end with a line containing only '\037\014'. A file object fp that points to the mailbox file. Initialize the mailbox object and point to the first message in the mailbox. \indexmoduleinbox \indexBabylMailbox \indexclassdefinition \indexmmdf \jiji This is so general and vague that can be used for ANYTHING, and it's so simple that anybody can use it. This is the method i've used for: http://www.ctv.es/USERS/irmina/TeEncontreX.html Why to make it complex if it can be very simple ??? Only simple and general things are commonly accepted and used (or it should be so!) -- Manolo From bernhard at alpha1.csd.uwm.edu Mon Nov 8 10:44:02 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 8 Nov 1999 15:44:02 GMT Subject: Graphics. References: <3826E949.BBA1BAFD@imf.au.dk> <3826ED30.70FBE3D3@callware.com> Message-ID: On Mon, 08 Nov 1999 08:33:04 -0700, Ivan Van Laningham wrote: >> How do I draw some graphics on a screen using Python running on >> HP-UX >> MacOS >> Windows >Use the Tkinter Canvas widget. Start at > http://www.pythonware.com Other choices include the python bindings for wxWindows (wxPython) and Fox (pyFox?) Bernhard -- Research Assistant, Geog Dept UM-Milwaukee, USA. (www.uwm.edu/~bernhard) Free Software Projects and Consulting (intevation.net) Association for a Free Informational Infrastructure (ffii.org) From webmaster at python.org Tue Nov 16 14:25:52 1999 From: webmaster at python.org (Python.Org Webmaster) Date: Tue, 16 Nov 1999 14:25:52 -0500 (EST) Subject: Planned power outage tonight at CNRI Message-ID: <14385.44992.984861.882508@anthem.cnri.reston.va.us> Virginia Power has informed us that the power to CNRI's building will be out between 2:00am and 6:00am Wednesday November 17th, EST. This will affect all Python.Org machines and services. Apologies for any inconveniences. -Barry From shouldbe at message.com Mon Nov 29 17:01:54 1999 From: shouldbe at message.com (Arinte) Date: Mon, 29 Nov 1999 17:01:54 -0500 Subject: Python Path weirdness??? Message-ID: <81usqn$1lou$1@rtpnews.raleigh.ibm.com> I have this code in my embedded app char* path ="D:\\POSSApps\\anotherposs app\\Embed Python\\some.exe"; Py_SetProgramName(path); Py_Initialize(); fname = fopen(name,"r"); Py_InitModule("poss", Exposem); cout< Message-ID: <3Y%V3.438$QY4.16745@dfiatx1-snr1.gtei.net> | ...problem to those (for instance) who are unlucky enough to have to use | Outlook Express... Why not subscribe via an alias at iname.com and just use it for the Python list. It'll give you a solid hook to filter on. Or get a deja.com, etc., freebie email address and check there? Good luck! -- "People," said Oscar Wilde, "are either perfectly charming or perfectly tedious." From aa8vb at yahoo.com Tue Nov 2 13:22:07 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Tue, 2 Nov 1999 13:22:07 -0500 Subject: Tkinter canvas blow-up: bbox(ALL) == None In-Reply-To: <19991102072202.A134170008@vislab.epa.gov> References: <19991101102103.A134035786@vislab.epa.gov> <013c01bf2510$57457f20$f29b12c2@secret.pythonware.com> <19991102072202.A134170008@vislab.epa.gov> Message-ID: <19991102132207.A134181398@vislab.epa.gov> Randall Hopper: |Fredrik Lundh: | |Randall Hopper wrote: | |> Apparently if the bounds of the items in a Tk canvas widget exceed | |> MAXINT, bbox(ALL) returns None. The attached Python script demonstrates | |> this. ... |Ok, thanks for the info. So do you know if Tk uses ints internally as |well, or is its returning the empty string an artifact of how it was fed by |Tkinter? Sorry. Too many pronouns and implied nouns in that sentence. Should read: So do you know if Tk uses ints internally [to represent the bounding box], or is Tk's returning the empty string an artifact of how Tk was fed by Tkinter? Randall From tbryan at python.net Tue Nov 30 19:16:45 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Tue, 30 Nov 1999 19:16:45 -0500 Subject: Python complaints References: <000701bf36c0$cdb9f480$292d153f@tim> Message-ID: <384468ED.7CA86357@python.net> Tim Peters wrote: > > [Thomas A. Bryan] > > ... > > For example, I saw some code that I wanted to copy in DejaNews > > c.l.py archives, but the lines wrap in narrow columns in DejaNews. > > I had to reindent the code. Grrr. > > In DejaNews, while looking at a msg, click the "View original Usenet format" Thanks to everyone who pointed that out. > > I have also had problems when e-mailing code when I e-mail the > > code as text in the message instead of attaching a document. > > > > Is there a better way to transmit code so that possible > > indentation munging won't force the reader to reindent? > > If you don't want to use attachments (chicken ), I normally do....but when I'm sending e-mail from a remote machine, I sometimes get lazy and cut and paste from my local machine. :-) ---Tom From gmcm at hypernet.com Tue Nov 16 16:00:23 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 16 Nov 1999 16:00:23 -0500 Subject: Final classes like in java??? In-Reply-To: <80sao7$1848$1@rtpnews.raleigh.ibm.com> Message-ID: <1269336468-10034142@hypernet.com> Arinte writes: > Is there a way you can define your python class to be final or not able to > be inherited from? You could deter subclassing, but not prevent it (I can always rebuild my class's __bases__ to include your Final class). Final in Java is there for efficiency. There would be no gains in Python since the compiler has no role in choosing the override. - Gordon From rkaiser at wwa.com Sun Nov 28 17:18:32 1999 From: rkaiser at wwa.com (Ralph Kaiser) Date: Sun, 28 Nov 1999 16:18:32 -0600 Subject: IDLE & Linux References: Message-ID: Dan Grassi wrote in message news:B466ECEC.F8E%Dan at Grassi.com... > I am trying to get IDLE to run. The docs say that it is automatically > installed but that is just not true. There is a /usr/bin/idle but when it > runs it quits complaining that it can't find > /usr/lib/python1.5/site-packages/idle/idle.py Hi, /usr/bin/idle is just a one line script to run idle.py Use "find .-name idle.py" to locate it. on my system it's /usr/local/src/Python-1.5.2/Tools/idle/idle.py. Good Luck Ralph From mwh21 at cam.ac.uk Fri Nov 26 15:59:02 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 26 Nov 1999 20:59:02 +0000 Subject: Python complaints References: <867lj85g4c.fsf@g.local> <86so1v4jlj.fsf@g.local> <86ln7m2t31.fsf@g.local> Message-ID: Gareth McCaughan writes: > Markus Stenberg wrote: > > > I have always found lisp-ish syntax of "masses of ()s" disconcerting in > > large amounts - admittedly, I've written more than few lines of > > [ce]lisp/scheme/.., but never enjoyed browsing the results very much. I > > consider Dylan to be "readable" clisp. > > One quickly gets used to Lisp syntax. Like using indentation to > denote block structure. :-) After a while, you just stop noticing > all those parentheses. This leads to a thought: would it be possible using lisp's silly amount of flexibility to get the reader to auto-paranthesize (word? doubt it): defun our-member (obj lst) if null lst nil if eql (car lst) obj lst our-member obj (car lst) based on indentation, as (defun our-member (obj lst) (if (null lst) nil (if (eql (car lst) obj) lst (our-member obj (car lst))))) or is whitespace ignorance built-in? indentation-as-structure-*will*-rule-the-world-ly y'rs Michael From ayinger1 at my-deja.com Tue Nov 9 22:51:48 1999 From: ayinger1 at my-deja.com (yinger) Date: Wed, 10 Nov 1999 03:51:48 GMT Subject: Detect file existance before open? References: <380c92a7.412580789@192.77.87.74> <80a29u$gn9$1@nnrp1.deja.com> Message-ID: <80aq4j$28q$1@nnrp1.deja.com> import os.path os.path.isfile('') will also work. > import commands > commands.getstatus('') > > In article <380c92a7.412580789 at 192.77.87.74>, > jlj at cfdrc.com (Lyle Johnson) wrote: > > os.path.exists(filename) > > > > On Sat, 16 Oct 1999 21:06:07 -0600, "Bill Rodgers" > > wrote: > > > > >I would like to check for the existance of a file before I attempt an > open > > >and maybe throw an exception. I don't see a way to do this. I would > like > > >to tell the user that the file he specified doesn't exist. Is there > a way > > >to do this or do I need to catch the exception and deal with it that > way? > > >Thanks, > > >-- > > >Bill Rodgers > > >Enterprise Management Consultant > > >Specialty: BMC/Patrol > > >brodg1 at ix.netcom.com > > > > > > > > > > > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From webmaster at python.org Mon Nov 15 12:18:23 1999 From: webmaster at python.org (webmaster at python.org) Date: Mon, 15 Nov 1999 12:18:23 -0500 (EST) Subject: Proposal: Python Info Collective References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> Message-ID: <14384.16479.836502.161209@anthem.cnri.reston.va.us> >>>>> "AMK" == Andrew M Kuchling writes: AMK> http://www.vex.net/~x/parnassus/ is *very* nice, and it might AMK> be the only solution required. Apparently a good deal of AMK> work has been put into seeding the initial database, and AMK> that's important, because it makes the index immediately AMK> useful. Yet I hadn't heard about it until now; is the site AMK> still beta? Did I miss a c.l.py.announce article about it? AMK> There are various issues with it -- I don't know how scalable AMK> the underlying code is, the graphic design could be simpler, AMK> vex.net's reliability and bandwidth are unknown, and we can AMK> argue about the classification hierarchy *forever* -- but AMK> it's still valuable. AMK> We need to just pick a solution and stick with it; Parnassus AMK> is as good as any, and has the incalculable advatange of AMK> being implemented. I'd like to encourage everyone who AMK> maintains Python code, or writes Python tutorials and docs, AMK> to go to http://www.vex.net/~x/parnassus/ . Is everything AMK> you've done in the index? If not, add the missing items. AMK> Can we prominently link to it from python.org, so people AMK> begin to use it? Very interesting! I hadn't heard about it until Andrew's post either. I just made an update to the Mailman entry, but it looks like there's some editorial review for record changes, because the change isn't effective immediately. That could be another bottleneck in the system. In any event, since the site's been outed, I'll probably add a link somewhere on the python.org site, but I'd still like Parnassus' author to get in touch with me... -Barry From donn at u.washington.edu Tue Nov 23 17:40:25 1999 From: donn at u.washington.edu (Donn Cave) Date: 23 Nov 1999 22:40:25 GMT Subject: dir() and propertly list NEWBIE References: <81eorl$b60$1@nnrp1.deja.com> Message-ID: <81f54p$ig4$1@nntp6.u.washington.edu> Quoth tiddlerdeja at my-deja.com: | Is it possible to get the functions of an object using dir()? Rather | that looking them up in a book/API. Yes, though not directly through the object and it's not real simple. def printcdir(c): print dir(c) for b in c.__bases__: printcdir(b) def printxdir(instance): print dir(instance) printcdir(instance.__class__) | Similarly, If I can get an objects functions, is it possible then get a | list of the possible parameters for that function? No! Wouldn't that be nice? Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From robin at jessikat.demon.co.uk Thu Nov 18 19:46:31 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Fri, 19 Nov 1999 00:46:31 +0000 Subject: Comparing Python to (free) Math languages/environments References: <19991118014716.13748.00000334@ng-bj1.aol.com> Message-ID: <0MjAOJAn3JN4EwHI@jessikat.demon.co.uk> In article , Travis Oliphant writes ... > >I've been steadily working over the past year to flesh out some of the >missing numerical pieces (see http://oliphant.netpedia.net). As to >how things are coming, I can only give my own experience. With the >packages I've put together I am able to use Python exclusively in my day >to day work and find that I am able to do things I would never have tried >in MATLAB. > >In short, I do not regret the decision to use Python. In fact I'm happier >about the decision each day. > me too > on the lists. Good luck in your search. > >Travis Oliphant > -- Robin Becker From doughellmann at home.com Mon Nov 1 08:33:55 1999 From: doughellmann at home.com (Doug Hellmann) Date: Mon, 01 Nov 1999 13:33:55 GMT Subject: Tkinter app 'freezes' when I use after_idle References: <3819864B.297FCB9E@home.com> Message-ID: <381D9811.83654620@home.com> Andrew Markebo wrote: > > | network, it might take a while to come back. Keep in mind that as long > | as the program is running your callback code, the display will not be > | updated. > > *HMM* Ok lets try to sort this out.. Of course the first call to the > function is from a callback, when I press the 'go' button a call is > made to 'checkfunc'. Last in checkfunc I call > self.after_idle(checkfunc) this would stay away from the event?? An overly simplified look at the process flow for a Tk app might look like: create widgets enter mainloop: look for events (including update) if events: call event callbacks (your code) else: call idle handlers (your code) While you are in a callback or idle handler, program control does not go through the section that allows the mainloop to dispatch a callback. Instead, the events that would cause the callback to be called are being queued up for the next time around the mainloop. It is possible to shortcut this flow somewhat by using the update_idletasks() method to make sure that all of the screen painting calls are made (to handle exposure events). What you want to try to do with your idle handler is make it run very quickly, so that you can get in and out before a lot of events start queuing up and the user notices that the screen is not refreshing. After you are done with your processing, you reregister the idle handler to run again. > | > | You could use a file handler to let Tk watch the socket for you (instead > | of doing your own select). You would then get a callback when there is > | data for you to read from the socket. I've had success with this scheme > > *bonk* I have heard about that, time to take a dig into my TCL/TK book again.. That may be your best bet for this app. There are cases when doing your own call to select might make more sense. Doug From da at ski.org Tue Nov 2 14:37:53 1999 From: da at ski.org (David Ascher) Date: 2 Nov 1999 13:37:53 -0600 Subject: [CORRECTED] Dr. Dobb's Python-URL! - weekly Python news and links (Nov 2) Message-ID: Today is election day in the United States. Here are the winners from a much simpler yet equally non-scientific selection process: The Python Consortium is started! Hewlett-Packard and LLNL provides the marquee status and the big bucks, Digital Creations the wildly successful application, Interet quietly chips in, along with Foretec Seminars, the first organization that had a check in hand! http://www.python.org/consortium/ Michel Pelletier (of Digital Creations) and Dan York (of LinuxCare) announce that they are writing a Zope book for O'Reilly and Associates: http://www.zope.org/Members/michel/ZopeBook/index_html/index_html Jan Walter announces some scripts for Blender, a computer graphics rendering tool, with very nice pictures to boot: http://www.q-bus.de/Blender/ David S. Harrison puts forth code which formats number for human consumption: http://www.deja.com/getdoc.xp?AN=542270123 Scot Hacker explains how good scripting BeOS is http://www.byte.com/column/BYT19991026S0001 Tim Peters sort of sorts out some of the sort issues sorted out between 1.5.1 and 1.5.2: http://www.deja.com/getdoc.xp?AN=541957314 The same Tim accounts for a surprising 'feature' involving testing the object identity of immutable objects which puzzled Pearu Peterson and yours truly: http://www.python.org/pipermail/matrix-sig/1999-November/003106.html ========================================================================= Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the center of Pythonia http://www.python.org 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 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/ 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 http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From thomas.heller at ion-tof.com Tue Nov 30 14:51:59 1999 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Tue, 30 Nov 1999 20:51:59 +0100 Subject: Exposing COM via XML-RPC or Something Else References: <613145F79272D211914B0020AFF6401914DD7C@gandalf.digicool.com> Message-ID: <00f001bf3b6c$5debe270$4500a8c0@thomasnotebook> > You might want to take a look at MS' SOAP (Simple Object Access > Protocol) spec - it's not fully baked yet, but it basically takes > xml-rpc several steps further, allowing you to communicate with > SOAP-enabled objects (COM or otherwise) using XML over HTTP. We in > Zope-land are keeping a close eye on this, as publishing objects > via HTTP is the core idea of Zope already. Zope and SOAP sounds very similar. Is this by accident? Thomas Heller From mlh at vier.idi.ntnu.no Tue Nov 16 15:16:48 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 16 Nov 1999 21:16:48 +0100 Subject: list.without()? References: <11A17AA2B9EAD111BCEA00A0C9B41793034AAEE7@molach.origin.ea.com> Message-ID: "Stidolph, David" writes: > so ... > > def without(source, element): > while element in source: > source.remove(element) > > Is that what you are looking for? No - but thanks anyway ;) What I wanted was a nondestructive method included in the language. According to some (i.e. Frank Drake IIRC) that is contrived, and I have conceded on the issue. Implementing it myself is not a problem (*especially* now that I have received numerous implementations from other people... ;) > It would help if I had read the earlier > posts! :) -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From jam at quark.emich.edu Tue Nov 30 08:03:26 1999 From: jam at quark.emich.edu (Jeff) Date: Tue, 30 Nov 1999 08:03:26 -0500 Subject: Looking for sshlib.py In-Reply-To: References: Message-ID: <19991130080326.A1376@quark.emich.edu> On Tue, Nov 30, 1999 at 04:37:34AM +0000, John Leach wrote: > Is there an ssh lib for Python. Or anything similar. I'm looking for > something more secure than telnet. > Any ideas? Write my own? > John Leach > http://www.bosware.com.au > greetings, what type of application are you trying to write that you need this type of access? if all you want is a 'secure shell' so you can connect to a remote machine, ssh is the way to go.. I don't know if you can hook it into python though. regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From robin at jessikat.demon.co.uk Fri Nov 5 09:44:26 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Fri, 5 Nov 1999 14:44:26 +0000 Subject: [OFFTOPIC] Maps and functions (was Re: Apply a function to each list member?) References: <19991105215504.A497@Ridcully.home> <14370.53219.667492.946075@gargle.gargle.HOWL> Message-ID: <27NwjKAK1uI4EwdJ@jessikat.demon.co.uk> In article <14370.53219.667492.946075 at gargle.gargle.HOWL>, Charles G Waldman writes >Malcolm Tredinnick writes: > > > > Correct. In fact, since we're being precise, let me point out that > > (mathematically speaking), all functions are maps (or mappings), but not > > all mappings are functions. The point is that a function should have only a > > single "output" for any given input (i.e. it should be many-to-one or > > one-to-one, not one-to-many). So some mapping that sends, say, the number 2 > > to the numbers 3 and 4 is not a function (but a mapping that sends both the > > numbers 3 and 4 to the number 2 is a function, since for each input there > > is only a single output). > >Hmm... what kind of "map" are you thinking of that could send 2 to >"both 3 and 4"? I think such a thing is not a mapping, at least not >according to any definition of "map" that I've ever seen. If you >look, for instance, in any basic topology text, you will see that >"map" and "function" mean exactly the same thing, when used as nouns. >"Map" also has a sense as a transitive verb, which means "to apply a >function to", which is where the Python/functional programming usage >comes from. > > > I define f as a thing which takes integer arguments and outputs sets of integers presumably I can have such an f that f(2)={3,4} to my simple engineer's eyes f could belong to the functions mapping Z-- >2^Z I assume we're not talking that way if the f above isn't a function. -- Robin Becker From mhammond at skippinet.com.au Mon Nov 15 06:51:39 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 15 Nov 1999 11:51:39 GMT Subject: Python ISAPI References: <80oq15$ln8$1@oceanite.cybercable.fr> Message-ID: AFAIK there is no ISAPI module - but Python is an AXScript language, so it works fine in ASP (hence no real demand for ISAPI) Mark. Florent Rami?re wrote in message <80oq15$ln8$1 at oceanite.cybercable.fr>... >Hello, > > i am looking for an python ISAPI, but could not find any. > Could you tell me where i can get such a goodie ? > Does anybody ever worked on this ? > >Thanks. > > From usenet-mm-yyyy at julesallen.com Wed Nov 24 10:34:45 1999 From: usenet-mm-yyyy at julesallen.com (Jules Allen) Date: Wed, 24 Nov 1999 15:34:45 GMT Subject: Python books References: <199911230613.HAA21179@dionysus.fw.cuci.nl> <383A9EF4.5D1E8986@callware.com> <00a901bf35c3$2549ed80$f29b12c2@secret.pythonware.com> Message-ID: | well, the eff-bot guide is definitely an annotated script | collection, but I think Hans was referring to Martin Brown's | upcoming pMatter book; [snip] I really enjoyed Martin's Perl book and I'm looking forward to this one. He's got an easy to read style, not unlike Daryl H/Ken McD's Quick Python Book. Amazon claimed they shipped me a PyAnnotated last week but I've yet to see it. Personally I think the Quick Python book is one of the better technical books I've ever read. The last books to have that much impact on my so-called-career is Cooper's semi technical "Inmates are Running the Asylum" (which should be required reading before a programmer is given a keyboard) and Alan Simpson's "dBase III Programmers' Reference Manual"! And I buy a *lot* of books. :-) -- Want to reply via email? Put the current month and year in my email address. From reic0024 at bulldog5.d.umn.edu Wed Nov 3 18:17:57 1999 From: reic0024 at bulldog5.d.umn.edu (Aaron J Reichow) Date: Wed, 3 Nov 1999 17:17:57 -0600 Subject: Tkinter and Solaris 7 Sparc [Q] In-Reply-To: <7vqblc$ham$1@nnrp1.deja.com> References: <7vqblc$ham$1@nnrp1.deja.com> Message-ID: > I just get an error saying that libX11.so.6.1 is needed. Is there a way > to build tkinter without X11? Or I just need to download and install > X11? Don't you already have X11 installed, with Solaris (that would be that which drives CDE/Solaris Desktop/OpenView)? And if the answer is no, and you're running simply from the console, why would you need Tkinter, which provides a graphical interface? Aaron From dvbden at hotmail.com Wed Nov 10 17:28:07 1999 From: dvbden at hotmail.com (dvbden at hotmail.com) Date: 10 Nov 1999 17:28:07 -0500 Subject: $$ Information Auction - Sell What You Know -Buy What You Dont $$ 9322 Message-ID: <3829f177$1@news.iglou.com> Hi All, Check this site out - http://www.KnowToday.com I recently registered on an interesting new site called - KnowToday.com that allows its members to buy and sell information! They are currently recruiting new members and will launch the site in several months. For a limited time, they are offering an incentive plan, where they pay you for successful referrals. It sounds really interesting. You can go on their site and ask detailed questions or make money by answering questions. They are designing the site with many different categories, so almost anyone will be able to ask and answer questions. Also, you can make money if any of your referrals use the site. It only takes a minute to join - http://www.knowtoday.com/ - they explain everything on the web site. It's totally free and you have no further obligations after registering Hope you like it! John zwgjopdryoeyzcxylsjccxoibdsjjclyvexodixixbobupssundesmltffbwmueyegmijdtbwstcyenqzdtwrjqrfyo From gerrit.holl at pobox.com Mon Nov 1 14:21:18 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Mon, 1 Nov 1999 20:21:18 +0100 Subject: __str__ vs. __repr__ In-Reply-To: <19991101121709.A134039715@vislab.epa.gov> References: <19991101121709.A134039715@vislab.epa.gov> Message-ID: <19991101202118.B29736@optiplex.palga.uucp> Randall Hopper wrote: > > 1) Is there a convention for what __str__ and __repr__ should return for > classes? __str__ should return a string, __repr__ may also return, for example, a dictionairy. > 2) Or, whatever they return, should they return the same value? I don't know: I think it's wrong to use both. regards, Gerrit. -- linuxgames.nl.linux.org All about games on Linux in Dutch (under construction). www.nl.linux.org The Dutch resource for Dutch Linux documentation. www.nl.linux.org/discoverb Learn foreign words and definitions. www.nl.linux.org/~gerrit/asperger I'm an Asperger, go here for more info. www.nl.linux.org/~gerrit About me and pictures of me. From pinard at iro.umontreal.ca Tue Nov 30 11:56:55 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 30 Nov 1999 11:56:55 -0500 Subject: '==' vs. 'is' behavior In-Reply-To: "Fredrik Lundh"'s message of "Tue, 30 Nov 1999 09:03:09 +0100" References: <382C2C6A.64A8F2C2@theriver.com> <14380.12036.197083.409565@weyr.cnri.reston.va.us> <8E7F86267duncanrcpcouk@news.rmplc.co.uk> <015301bf3b0a$685a3fc0$f29b12c2@secret.pythonware.com> Message-ID: First of all, thanks for your replies, all. "Fredrik Lundh" ?crit: > according to the eff-bot: What is "the eff-bot"? I've read about "eff-bot" and "tim-bot" a few times by now, and thought it was some kind of internal joke in the group, but begin to think there might be some substance behind the expression! :-) > foo is None > type(foo) is type(bar) # same type > foo is bar # same instance > use '==' for everything else (unless you know what > you're doing, of course). Wise enough. I guess I'll do exactly that. Thanks for the suggestion. "Tim Peters" ?crit: > [Fran?ois Pinard] > > By the way, is there common wisdom (or rather, maybe, > > usage-standards-to-be) about using `is' instead of `=='? > In general, don't -- you'll often end up regretting this cleverness. I've never been bitten so far, and as long as I do only sensible things, there is no reason nor fear I would be bitten later. I presume you agree that Fredrik suggestions, above, are very reasonable? [Many good explanations and examples not repeated.] > Clearest and safest: don't use "is" when "==" would suffice. I'm a bit minimalist while programming. Or, to say the same thing another way, I rather like Arvo Part's music. When a program source is just abusing of parentheses without justification (helping `python-mode' _is_ a justification!), it gives me the uncomfortable feeling the author has never been able to properly sort operator priorities, and probably many other things as well :-). Of course, I quite agree with you that there is equilibrium and reason to put in the pondering. And to be fully honest, I find the "is not" syntactical sugar rather sweet. It would be a shame not using it, once in a while :-). nascheme at enme.ucalgary.ca ?crit: > Using `is' interchangably with == is asking for trouble. Of course. This is why I asked for some sounded advice about how to do it nicely. > Your lucky you don't do Lisp. I don't? :-) In fact, I like Scheme a lot, and use the Gambit system for some bigger applications. And, despite with much less pleasure, I sometimes play around Emacs LISP. If I could get Gambit and Python together, it would be fun! -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From leonar_n at epita.fr Mon Nov 29 09:32:25 1999 From: leonar_n at epita.fr (leon) Date: Mon, 29 Nov 1999 15:32:25 +0100 Subject: Unbuffered stdout References: <81u1k2$27qkk$1@oceanite.cybercable.fr> <046a01bf3a75$80b84d90$f29b12c2@secret.pythonware.com> Message-ID: <81u2gm$26v0f$1@oceanite.cybercable.fr> I use it into a cgi script, with apache, and for my IRC like, I must do a thing like : while 1: strLine = self.pRoomFile.readline() while strLine: sys.stdout.write(strLine) sys.stdout.flush() strLine = self.pRoomFile.readline() time.sleep(1) And the lines I print don't appear in the browser Fredrik Lundh wrote in message news:046a01bf3a75$80b84d90$f29b12c2 at secret.pythonware.com... > leon wrote: > > I'm developping an IRC like software which must work on the Web. I can't use > > Java, and I'm using Python to program the CGI. But, I have a big problem : I > > don't know how to make the stdout unbuffered. > > I tried to make some > > sys.stdout.write("test") > > sys.stdout.flush() > > but it don't work. > > looks fine to me. maybe something else > is wrong? > > anyway, you could try running the inter- > preter with the -u option: > > $ python -? > Unknown option: -? > usage: python [option] ... [-c cmd | file | -] [arg] ... > Options and arguments (and corresponding environment variables): > ... > -u : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x) > ... > > > > > From tbryan at python.net Sat Nov 6 22:18:14 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Sat, 06 Nov 1999 22:18:14 -0500 Subject: making the Python case to my dept. References: <9911051740130D.02530@william.jinsa.org> <3823FC43.CF7FBD71@python.net> <99110609085702.02970@quadra.teleo.net> <382467FA.577E70A0@callware.com> Message-ID: <3824EF76.113E3699@python.net> Ivan Van Laningham wrote: > > Since this is a FAQ, I'd vote for preserving Thomas' answer somewhere > > on the python.org Web site, so people could point to the URL when the > > question comes up again. > > > > I agree. His answer is nearly perfect. Thanks, Thomas. Thanks! I'll rewrite some parts to make it more generally applicable and add it to the FAQ. Do you think that section 2 (Python in the Real World) or section 1 (General information and availability) is most appropriate? too-pleased-by-the-response-to-think-of-anything-witty-ly yours ---Tom From jbaddor at sca.uqam.ca Fri Nov 12 18:51:39 1999 From: jbaddor at sca.uqam.ca (Jean-Bernard ADDOR) Date: Fri, 12 Nov 1999 18:51:39 -0500 (EST) Subject: __doc__ print \012 on Debian Gnulinux2 Message-ID: Hey ! I try to make some documentation strings in my code but then I use them the result is very difficult to read: kili$ /usr/bin/python Python 1.5.1 (#1, Dec 17 1998, 20:58:15) [GCC 2.7.2.3] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> xtGgrads.__doc__ 'Apply x^t G grad sigma equation.\012\012 xtGgrads(G, (d0, d1), (o0,o1)=(None,None), (s0, s1)=(1,1))\012 G GSI generator matrix\012 (d0, d1) sigma derivatives\012 (o0,o1) origin coordinate, center on biggest side if unspecified\012 (s0, s1) distance between two pixel\012 ' How could I make it print return instead of \012? Jean-Bernard From robin at alldunn.com Tue Nov 16 00:13:33 1999 From: robin at alldunn.com (Robin Dunn) Date: Mon, 15 Nov 1999 21:13:33 -0800 Subject: ANNOUNCE: wxPython 2.1.11 Message-ID: <007201bf2ff1$55d501b0$0301a8c0@easystreet.com> wxPython 2.1.11 has been released and you can get your copy today from http://alldunn.com/wxPython/ New features in this release include HTML Printing, better support of GUI interaction from non-GUI threads, Clipboard, Drag and Drop, font enumerator, a new calendar widget, many little tweaks and fixes. Please see http://alldunn.com/wxPython/README.txt for details. -- Robin Dunn Software Craftsman robin at AllDunn.com http://AllDunn.com/robin/ http://AllDunn.com/wxPython/ Check it out! From usenet-mm-yyyy at julesallen.com Fri Nov 19 06:55:58 1999 From: usenet-mm-yyyy at julesallen.com (Jules Allen) Date: Fri, 19 Nov 1999 11:55:58 GMT Subject: Proposal: Python Info Collective References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> <80oqn9$ocq$2@newshost.accu.uu.nl> <80p9su$ppo$2@newshost.accu.uu.nl> <80piru$13rl$1@hub.org> <80re5d$55a$1@newshost.accu.uu.nl> <810jto$lo0$1@newshost.accu.uu.nl> <811pdu$dvo$1@newshost.accu.uu.nl> Message-ID: In article <811pdu$dvo$1 at newshost.accu.uu.nl>, Martijn Faassen wrote: | > No, no, a more extensive deja search indicated to me that this person has | > posted under other names to the group previously. At least, unless there are | > 10 people with the same speech patterns posting to comp.lang.python. :) | | with the same speech patterns _from vex.net_, I meant! deja nor I are that | good at scanning for similar speech patterns yet, but the vex.net subset | is doable for the eyeball. Tim assures me this is purely an email address anti-spam obfuscation method and not a witness protection plan. My-anti-spam-methods-are-positively-transparent-in-comparison-ly-yrs Jules -- Want to reply via email? Put the current month and year in my email address. From gawron at obop.com.pl Fri Nov 12 10:56:32 1999 From: gawron at obop.com.pl (=?iso-8859-2?Q?Przemys=B3aw?= G. =?iso-8859-2?Q?Gawro=F1ski?=) Date: Fri, 12 Nov 1999 16:56:32 +0100 Subject: DBF interface Message-ID: <382C38AF.69FFACF4@obop.com.pl> Is there a DBF file interface module ? Thanks Przemek -- Przemyslaw G. Gawronski UIN:8358522 mailto:gawronskip at usa.net mailto:gawron at obop.com.pl From gerrit.holl at pobox.com Tue Nov 16 11:31:42 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Tue, 16 Nov 1999 17:31:42 +0100 Subject: Beginning programming with Python In-Reply-To: References: <382B3A53.5816B2@callware.com> <382B3D79.74CD3E0F@email.sps.mot.com> <80p9ds$ppo$1@newshost.accu.uu.nl> <38312D55.A36EB56D@iqsoft.hu> Message-ID: <19991116173142.A31379@optiplex.palga.uucp> > You could take the number of man months necessary or you > could try to quantify the quality of you product. Yes... Those two are always "omgekeerd evenredig". Can any of the Dutch-speaking guys in here translate it for the not-Dutch-speaking people? :-) But serious: the less time it costs to program it, the more time it costs to run it, the more time it costs to program it, the less time it costs to run it. How long would it take to build a minimalistic web server in c? More then 1 Line Of Code (LOC), I think :-) And I think it'd run much, much faster than the python-import version... how-many-databases-are-written-in-sh-with-dd-only?, -- We are using Linux daily to UP our productivity - so UP yours! (Adapted from Pat Paulsen by Joe Sloan) From tiddlerdeja at my-deja.com Tue Nov 23 14:10:50 1999 From: tiddlerdeja at my-deja.com (tiddlerdeja at my-deja.com) Date: Tue, 23 Nov 1999 19:10:50 GMT Subject: dir() and propertly list NEWBIE Message-ID: <81eorl$b60$1@nnrp1.deja.com> Is it possible to get the functions of an object using dir()? Rather that looking them up in a book/API. Similarly, If I can get an objects functions, is it possible then get a list of the possible parameters for that function? Any help appreciated. Sent via Deja.com http://www.deja.com/ Before you buy. From tim_one at email.msn.com Wed Nov 10 01:39:13 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 10 Nov 1999 01:39:13 -0500 Subject: __str__ vs. __repr__ In-Reply-To: <14376.31199.948463.211294@goon.cnri.reston.va.us> Message-ID: <000301bf2b46$4d7e6f60$d82d153f@tim> [Toby Dickenson:] > Tim's Rat class is a good example of how __repr__ should not be > implemented, because it exposes the internal representation of > the object, not the external value. [Rat's Tim class] > Beg to differ: it's an excellent example of how __repr__ should > be implemented. [Jeremy Hylton] > It's no accident that the function is called __repr__. It's role is > to expose the representation. No, in that case it would have been named __representation__. __repr__ is actually an acronym, meaning Regular-Expression Parsable Rendition. Similarly __str__ is short for Simpler Than Repr. I never learned what __init__ stands for -- it never interested Tim . guess-what-wink-stands-for-and-win-a-fabulous-prize!-ly y'rs - tim From ivanlan at callware.com Wed Nov 10 14:01:40 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Wed, 10 Nov 1999 12:01:40 -0700 Subject: Tkinter PhotoImage Message-ID: <3829C114.77389F49@callware.com> Hi All-- Ok, I've managed to create an image, using xx=PhotoImage(file), and I can retrieve pixel values from that image using xx.get(x,y). Now I want to use the put() method to write a pixel. How do I do that? I would have expected that put() would take a string of pixel values for the data argument, but that doesn't seem to be the case. ... And what's the bbox argument? -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours ---------------------------------------------- From alan-ng at empresa.com Mon Nov 1 07:48:11 1999 From: alan-ng at empresa.com (Alan Pogrebinschi) Date: Mon, 1 Nov 1999 07:48:11 -0500 Subject: Help! Can't install MySQLdb Message-ID: Hi! I am new to python modules, I am triying to install MySQLdb 0.1 on RH 5.2 , Python 1.5.2, and get (when running "build.py" as root) : cp: /usr/lib/python1.5/config/Makefile.pre.in: No such file or directory make: Makefile.pre.in: No such file or directory make: *** No rule to make target `Makefile.pre.in'. Stop. make: *** No targets. Stop. Traceback (innermost last): File "build.py", line 14, in ? import MySQLdb File "MySQLdb.py", line 19, in ? from _mysql import * ImportError: No module named _mysql It is strange that the dir "/usr/lib/python1.5/config" doesn't even exist (the parent exists). I used the RPM to upgrade Python to 1.5.2 (I had 1.5.1). I tried to install the older mysql driver too (the one that comes with ZMySQLDA) and got a very similar error msg when trying to "make" it. Any hint?? Thanks. Alan From gerrit.holl at pobox.com Mon Nov 1 09:06:00 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Mon, 1 Nov 1999 15:06:00 +0100 Subject: Newbie Question In-Reply-To: <7vidsi$qm8$1@nnrp1.deja.com> References: <7vidsi$qm8$1@nnrp1.deja.com> Message-ID: <19991101150600.B26174@optiplex.palga.uucp> strangiato at my-deja.com wrote: > I am completely new to the language. > > I heard that Yahoo uses it? > Is this true? I don't know. > Is it a good language for developing Web Pages? Yes. > Is it a "best of breed"? Yes again. regards, Gerrit. -- linuxgames.nl.linux.org All about games on Linux in Dutch (under construction). www.nl.linux.org The Dutch resource for Dutch Linux documentation. www.nl.linux.org/discoverb Learn foreign words and definitions. www.nl.linux.org/~gerrit/asperger I'm an Asperger, go here for more info. www.nl.linux.org/~gerrit About me and pictures of me. From greg.ewing at compaq.com Wed Nov 17 05:54:00 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Wed, 17 Nov 1999 23:54:00 +1300 Subject: Type/Class Unification in Ruby References: <3819BCDA.AC4FD4CA@strs.co.uk> <87k8o2x67f.fsf@ev.netlab.co.jp> <7vjtrc$hmm$1@newshost.accu.uu.nl> <38204614.2EAC6051@compaq.com> <5ld7trtak5.fsf@eric.cnri.reston.va.us> <3826D63C.2731BB1F@compaq.com> Message-ID: <38328948.9E35556F@compaq.com> I've been looking into the way types and classes are unified in Ruby. As I mentioned earlier, all objects in Ruby are associated with an object of class Class, which plays the role of both the PyTypeObject and PyClassObject. Consequently, it is possible to define subclasses of any of the built in types and add or override methods. It's even possible to add instance variables -- I'll explain how that works below. Each of the built-in types is represented by a unique C structure, as in Python. Therefore it is important that when a subclass of a built-in class is instantiated, the right kind of C structure is created, since all the built-in methods of its superclass expect to get that kind of structure. This is guaranteed by two characteristics of Ruby that differ from Python: 1) Instantiation of a class is done by calling a class method of that class. (Ruby has real class methods and variables, like Smalltalk. In fact, Ruby's internals are very Smalltalk-like in many ways.) 2) A class can only inherit from at most one other class. The only methods which actually create C structures are the built-in instantiation methods of the built-in classes, so even if you define your own instantiation method in your subclass, it eventually has to call a built-in one somewhere up its inheritance chain, which knows what kind of C structure is needed. This scheme will fail if you somehow manage to extract a built-in method out of one class and stuff it into another. However there doesn't seem to be any obvious way to do this (nothing like myClass.__dict__["foo"] in Python). So it seems to be safe. Now, what happens if you assign to a new instance variable in a method of your subclass of a built-in class? At first sight it seems that this can't possibly work, because the C structs of built-in types don't have any place to store arbitrary instance variables. When I tried it, however, to my surprise, it worked! It turns out that there is a global table whose purpose is to hold the values of these instance variables (in Python terms it is a dictionary of dictionaries, indexed by [object][variable_name]). Python might be able to use a similar solution, although it might cause ref counting problems. As a final note, some built-in classes, such as Fixnum, don't have any instantiation method, so although you can subclass them, there's no point because you can never create an instance of your subclass. Others, however, such as Array (Ruby's version of ListType) do have an instantiation method, and subclasses work just the way you'd expect. Hoping this has been enlightening, Greg From gmcm at hypernet.com Sat Nov 6 20:58:57 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Sat, 6 Nov 1999 20:58:57 -0500 Subject: Job skills [was Re: making the Python case to my dept.] In-Reply-To: Message-ID: <1270182561-5943751@hypernet.com> [Michael Hudson] > > > What are mathematicians' critical job skills? I'm curious, > > > being one, and not having being taught anything resembling a > > > `critical job skill' yet, and happy about it. [me] > > The ability to work long and hard on entirely meaningless > > problems. > > [Michael] > Fair comment. Maybe you don't realize that I was a math major too. and-good-preparation-it's-been-ly y'rs - Gordon From jhauser at ifm.uni-kiel.de Thu Nov 18 08:54:47 1999 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 18 Nov 1999 14:54:47 +0100 Subject: Comparing Python to (free) Math languages/environments References: <19991118014716.13748.00000334@ng-bj1.aol.com> <810rev$jsm$1@nnrp1.deja.com> Message-ID: <874sej7vmg.fsf@ifm.uni-kiel.de> siegfried.gonzi at kfunigraz.ac.at writes: > No. I also, tried to get into Python. But it is too "administrative" and > complicated. Than I came to Yorick. Yorick is ranked as a very good > substitute for IDL and also Matlab. It is or better it should be very > fast (compared to Matlab, Scilab or RLab or Octave). And it has stunnig > graphic features (default). > > What Yorick is lacking of is GUIs. This than, is a matter of taste. But > for scientists, which only look for good code, should this be not an > obstacle. This is exactly the strength of this approach, to extend a general scripting language with numerical capabilities. The connection between other worlds, be it GUI, Databases, WEB, serialIO, OpenGL, fileformats ... is much cleaner and easier in Python than in all the other systems. And then look how things like OO are implemented in Matlab or higher rank arrays. It is right that the syntax is more verbose in NumPy than in Matlab, but then this appeals to some as a good feature, too :-) In the end I want to add, that NumPy does connect to the same graphics engine like Yorick (Gist), so it should be possible to achieve the same output. __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 marc at oscar.noc.cv.net Wed Nov 3 03:19:58 1999 From: marc at oscar.noc.cv.net (User &) Date: Wed, 03 Nov 1999 08:19:58 GMT Subject: Need Berkley DB!! References: <381D5E84.98931682@bibsyst.no> <381FE1D5.C0F721A6@bibsyst.no> Message-ID: In article <381FE1D5.C0F721A6 at bibsyst.no>, Thomas Weholt wrote: >Robin Dunn wrote: > >> > After I spent most of my weekend trying to get Berkley DB to work with >> > Python on my Linux ( Suse 6.1) machine, I`ve now given up completly. >> > I`ve tried to install DB.1.85. and DB.2.7.7, neither worked, either >> > crashing under installation ( which of course, is not Python >> > related ) or when I tried to test the installation with the examples in >> > the documentation ( the wrapper for the 2.7.5-module listed at >> > www.python.org, under modules, databases ). >> >> Have you tried my DB module at http://starship.python.net/crew/robind/ ? >> Assuming you can get DB 2.7.x built and installed, this module should do >> what you need. >> > >Yes, I`ve tried it and the installation did go smooth, but when I tried to >use the example in the documentation Python barfed some errors at me, then >died with a scream. I can probably recreate the errors and send you a copy >of the output. > >I think the problem might be solved if I, sigh, re-install Red Hat 6.1 and >trash that oversized, over-featured Suse 6.2 Linux distro I got now. The Red >Hat version of Python came with all that stuff installed. There`s not enough >hours in a day to keep working on things like this. At least not right now. > >Thanks for your interest though. > >Best regards, >Thomas Weholt > off topic, but instead of linux you might want to try FreeBSD, It is much less agravation, form my personal experence anyway. Good Luck Marc From oofoe at my-deja.com Wed Nov 3 18:30:19 1999 From: oofoe at my-deja.com (oofoe at my-deja.com) Date: Wed, 03 Nov 1999 23:30:19 GMT Subject: Namespace question... Message-ID: <7vqgib$l8v$1@nnrp1.deja.com> Hi! How can you access the global namespace in python 1.5.1? I'd like to get a version string which is declared in the main script file. However, each module also has a version string which overrides the original one. I tried to access it as __main__.Version, similarly to $main::Version in Perl, which is what I'm more familiar with. Of course, it didn't work. I have something like this: module file foo.py: ------------------------------ Version = '$Id$' def bar(): print "Version is: ", __main__.Version main program: ------------------------------ Version = '$Id$' import foo foo.bar() ------------------------------- I'd certainly appreciate any pointers. The namespace stuff seems to get a little hazy around issues like this. Thanks! Jos'h Sent via Deja.com http://www.deja.com/ Before you buy. From boud at rempt.xs4all.nl Fri Nov 26 15:54:47 1999 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 26 Nov 1999 20:54:47 GMT Subject: XPython (X11) References: <383E5350.1E07536A@xrce.xerox.com> Message-ID: <81ms2n$126$1@essle.valdyas.org> Bernhard Reiter wrote: > On Fri, 26 Nov 1999 10:30:56 +0100, Emmanuel Pietriga wrote: >>Is anyone using XPython around here? > This is the first time I heard of XPython. :) > The only reference I found is : > http://ftp.uni-klu.ac.at/programming/python/X-extension/Top.html >>I need help, or at least links to examples (I haven't found any but the >>ones within the package) > If I want to program a GUI I look in to wxPython. > Or pyGtk or pyFOX or pyFLTK, but XPython... :) Hey! Don't forget PyQt and PyKDE (and PyQt seems to be working under Windows, too, nowadays)... > Bernhard -- Boudewijn Rempt | http://denden.conlang.org From ivnowa at hvision.nl Mon Nov 8 12:27:27 1999 From: ivnowa at hvision.nl (Hans Nowak) Date: Mon, 8 Nov 1999 18:27:27 +0100 Subject: Popup menus in Tkinter In-Reply-To: <806rtk$4e6$1@nnrp1.deja.com> Message-ID: <199911081726.SAA25412@axil.hvision.nl> On 8 Nov 99, dkaznadzey at my-deja.com wrote: > Does anyone know weather there is a way to create > a popup menu in tk (using Tkinter)? It seems > like in order to be shown the menu must > grow from the valid menubar. If there is a way > to display standalone menu pane at given > coordinates, please let me know. Try this code... You can right-click on the canvas to make the menu pop up. # menutest.py # Makes a window pop up by rightclicking the canvas. from Tkinter import * import regsub def getgeometry(something): s = something.geometry() return map(int, regsub.split(s, "[x+]")) root = Tk() root.canvas = Canvas(root, height=100, width=100, background='#674689') root.canvas.pack() def new_file(event=None): print "Opening new file" menu = Menu(root) menu.add_command(label="New...", underline=0, command=new_file) menu.add_command(label="Open...", underline=0, command=new_file) menu['tearoff'] = 0 def activate_menu(event=None): sizex, sizey, x, y = getgeometry(root) menu.tk_popup(x+event.x, y+event.y) root.canvas.bind("", activate_menu) root.mainloop() --Hans Nowak (zephyrfalcon at hvision.nl) Homepage: http://fly.to/zephyrfalcon You call me a masterless man. You are wrong. I am my own master. From tim_one at email.msn.com Wed Nov 24 16:13:49 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 24 Nov 1999 16:13:49 -0500 Subject: Python complaints In-Reply-To: <1268672881-3462615@hypernet.com> Message-ID: <000701bf36c0$cdb9f480$292d153f@tim> [Thomas A. Bryan] > ... > For example, I saw some code that I wanted to copy in DejaNews > c.l.py archives, but the lines wrap in narrow columns in DejaNews. > I had to reindent the code. Grrr. In DejaNews, while looking at a msg, click the "View original Usenet format" link following the msg end: Track this thread for me Unsubscribe from comp.lang.python Mail this message to a friend View original Usenet format ************* THIS ONE ************** Create a custom link to this message from your own Web site > I have also had problems when e-mailing code when I e-mail the > code as text in the message instead of attaching a document. > > Is there a better way to transmit code so that possible > indentation munging won't force the reader to reindent? If you don't want to use attachments (chicken ), avoid all control and high-bit characters other than newline (which means, in particular, don't use tabs! use spaces), and keep your maximum line length less than 80 characters. good-advice-for-mailing-programs-in-any-language!-ly y'rs - tim From fredrik at pythonware.com Wed Nov 24 09:06:03 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 24 Nov 1999 15:06:03 +0100 Subject: Python complaints References: <867lj85g4c.fsf@g.local> Message-ID: <00bf01bf3685$0c345610$f29b12c2@secret.pythonware.com> Markus Stenberg wrote: > > - a less yucky way of saying "for i in range(1,20,3)" > > see above - although some special syntactic sugar would be "nice", I prefer > minimalistic approach over say, C.. of course, Dylan does it (IMNSHO) > cleanest: > > for (i from 3 to 19 by 3) > ... note that python already has a special syntax for this purpose: >>> a = range(20) >>> print a[1:20:3] Traceback (innermost last): File "", line 1, in ? TypeError: sequence index must be integer (note that you got a type error, not a syntax error. numpy arrays fully support this syntax). in other words, you don't have to be guido to realize that something like: for i in [1:20:3]: ... could be the right way to do it in Python. in fact, it's already on the list for 2.0: http://www.foretec.com/python/workshops/1998-11/proceedings/guido/sld011.htm From ivanlan at callware.com Wed Nov 3 23:54:07 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Wed, 03 Nov 1999 21:54:07 -0700 Subject: Python / Perl joke in rec.humor.funny References: <38210E22.BBDAF855@erols.com> Message-ID: <3821116F.113DFE75@callware.com> Hi All-- "Edward C. Jones" wrote: > > A Python vs. Perl joke has appeared in the moderated, > low-traffic, humor group rec.humor.funny. It can be found at > > http://www.netfunny.com/rhf/jokes/99/Nov/perl.html > Pretty good, and true, except that that last line out to read "six minutes from now" instead of six months. ... -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From jjkunce at my-deja.com Mon Nov 1 11:13:01 1999 From: jjkunce at my-deja.com (jjkunce at my-deja.com) Date: Mon, 01 Nov 1999 16:13:01 GMT Subject: How to control app from Python? References: <38160DD8.5C695E09@theriver.com> <3817BD5F.7E05BDC9@home.com> <38185A03.9AB0FAD6@theriver.com> Message-ID: <7vke68$6r6$1@nnrp1.deja.com> In article <38185A03.9AB0FAD6 at theriver.com>, Andy Fox wrote: > The app to be controlled is visual... > I discovered Mark Hammond's win32 stuff... Can the app be controlled via COM? If so, be sure to look into Mark's win32com stuff. I have some examples of using COM to control Inernet Explorer and GroupWise, if you are interested. --Jeff Sent via Deja.com http://www.deja.com/ Before you buy. From fdrake at acm.org Thu Nov 11 11:37:36 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 11 Nov 1999 11:37:36 -0500 (EST) Subject: docs In-Reply-To: <80epm7$vbo$1@nnrp1.deja.com> References: <80epm7$vbo$1@nnrp1.deja.com> Message-ID: <14378.61648.633649.431232@weyr.cnri.reston.va.us> mehta at mama.indstate.edu writes: > I have noticed for the local docs of python in IE5 on winnt pages > randomly donot get rendered but are left as raw html in browser as I go > back and forth using browser buttons. has any one experienced same I have never seen this; if anyone can reproduce this and help isolate the cause I'd appreciate hearing about it. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From mcfletch at vrtelecom.com Thu Nov 11 16:27:32 1999 From: mcfletch at vrtelecom.com (Mike Fletcher) Date: Thu, 11 Nov 1999 16:27:32 -0500 Subject: ASCII delimited files In-Reply-To: Message-ID: Okay, here's an entirely different approach, extremely memory intensive, fairly fast. Gives pretty good speed up to the point where you start hitting memory effects (my 256 MB PIII 500 loads 10MB in 45 seconds, but takes 7.5 minutes for a 36MB file). For even greater speed, using an index-counting scheme (instead of expensive front-of-list-deletions) might be tried. Note: this does none of the fancy delimiter-determination of delimited.py, it's just a loading engine. Cheers, Mike Time for file of 365 bytes (5 * testset, 11 records found): 0.0 Time for file of 3650 bytes (50 * testset, 101 records found): 0.00999999046326 Time for file of 36500 bytes (500 * testset, 1001 records found): 0.120000004768 Time for file of 365000 bytes (5000 * testset, 10001 records found): 1.25199997425 next test may take 15 seconds or so Time for file of 3650000 bytes (50000 * testset, 100001 records found): 13.5299999714 next test may take 45 seconds or so Time for file of 10950000 bytes (150000 * testset, 300001 records found): 50.4729999304 -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Darrell Sent: November 11, 1999 1:20 PM To: python-list at python.org Subject: Re: ASCII delimited files Oops. That fix pushed into or beyond exponential runtime. It won't finish the 3.6meg file anytime soon. String slicing and pasting is dirt slow. E:\ace\dtd\q\delim1>delimited.py 3600 bytes 0.0310000181198 time E:\ace\dtd\q\delim1>delimited.py 36000 bytes 3.04700005054 time Got some improvement with the attached version at the cost of memory. Now I'm thinking about the 'C' version again. E:\ace\dtd\q\delim1>delimited.py 3600 0.0310000181198 E:\ace\dtd\q\delim1>delimited.py 36000 0.327999949455 E:\ace\dtd\q\delim1>delimited.py 360000 3.21899998188 E:\ace\dtd\q\delim1>delimited.py 3600000 48.2030000687 -- --Darrell -- http://www.python.org/mailman/listinfo/python-list -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: csv.py URL: From billtut at microsoft.com Wed Nov 10 13:25:10 1999 From: billtut at microsoft.com (Bill Tutt) Date: Wed, 10 Nov 1999 10:25:10 -0800 Subject: Python company worth $100M Message-ID: <4D0A23B3F74DD111ACCD00805F31D8100DB9151E@RED-MSG-50> > From: Mike Fletcher [mailto:mcfletch at vrtelecom.com] > > > Nope, don't think you're missing anything. If I recall correctly, the > asyncore docs even mention their assumption that the > processing to be done > per call is trivial. Since all other channels are "blocked" while the > compute-heavy call is processing, the system will suffer performance > degradation for all other clients. Thread-pools seem to be a decent > approach for longer-running calls. > Only if they're synchronous operations, the really crazy people move completly to an asynchronous finite state machine, have one thread per CPU (and that thread only runs on that CPU), and schedule their work in chunks so that one hunk of code can process multiple "work packets" at once, thereby playing nice with the memory caches. There are apps that need this performance and actually do this btw. Not sure if you can schedule a thread to sit on one CPU on anything besides NT though. I'd be interested to know otherwise... Bill From lany at iname.com Tue Nov 16 18:47:35 1999 From: lany at iname.com (Lany Wilson) Date: Tue, 16 Nov 1999 18:47:35 -0500 Subject: Can't build python1.5.2 on Slackware Message-ID: <3831ED17.5283BF03@iname.com> The compile bombs on socketmodule.c. Something about the way gethostbyname_r is defined. Does anyone know of a quick fix? I'm using Slackware 4/egcs. Tia- L Wilson From thomas at bibsyst.no Tue Nov 2 08:30:41 1999 From: thomas at bibsyst.no (Thomas Weholt) Date: Tue, 02 Nov 1999 14:30:41 +0100 Subject: General q. `bout subclassing Message-ID: <381EE780.EBF18F59@bibsyst.no> Hi, Simple one : How do I subclass fundamental stuff like lists etc, tried something like : > >>> class my_list([]): > ... a = '' > ... > Traceback (innermost last): > File "", line 1, in ? > TypeError: base is not a class object > >>> > Huh ?? Thomas Weholt From dave.rose at wcom.com Tue Nov 16 18:41:55 1999 From: dave.rose at wcom.com (Dave Rose) Date: Tue, 16 Nov 1999 23:41:55 GMT Subject: Unix Message Queues Message-ID: <7ZlY3.7116$dz1.594280@pm02news> Has anyone been able to use unix message queues with Python. I have been trying to get them to work for a couple of days now and have been unsuccessful. I wrote an extension module in 'C' to complete the actually message manipulation and the main function is a python thread. The problem I am having is that when I put the two together, it no longer functions as a thread, you go into the function and never come out. The thread is not spawned. Any help would be great. The code is attached for the python portion. Thanks Dave Rose begin 666 test_proc.py M(R$O=7-R+VQO8V%L+V)I;B]P>71H;VX-"B,C(R,C(R,C(R,C(R,C(R,C(R,C M(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C M(R,C(R,C(R,C(R,C(R,C#0HC(%1H:7,@:7,@=&AE('!R;V-E2!I2!T:&4@5]P;0T*"0EF:6QE;&ES=#U;WT-"@D)(R!G970@=&AE(&EN:71I86P@ M1&%T80T*"0E05!M+F-R96%T97$H*0T* M"0EP7!E. at T*"0D)"2,@;F5E9"!T;R!C:&5C M:R!;,%T at 9F]R(&UE7!E(&9R;VT@<')O8VUA;@T*"0D)"0DC(&YE960@=&\@5!M+F-H96-K<2A0 T*"0D):68@='EP92AC:&5C:U]R=')N*2 ]/2!4=7!L M951Y<&4Z#0H)"0D)(R!N965D('1O(&-H96-K(%LP72!F;W(@;65S7!E#0H)"0D);65S7!E(#T at 8VAE8VM?7!E(#T](#$Z#0H)"0D) M"5!R;V-E7!E8"LG827!E8"LG(27!E(#T] M(#4Z#0H)"0D)"4YO;F4-"@D)"0D)(R!W92!H860 at 82!S:'5T9&]W;B!R97%U M97-T(&5R7!E(#T](#DZ#0H)"0D) M"2,@=V4@;F5E9"!T;R!R96%D(&]U6QO860]6QO861;,%T-"@D)"0D)"0ED971A:6P@/2!P87EL;V%D6S$Z M70T*"0D)"0D)"6EF(')E<5]T>7!E(#T](#(Z#0H)"0D)"0D)"2,@=V4@:&%V M92!A(')E<75E7!E(#T](#4Z#0H)"0D)"0D)"2,@ M=V4@:&%V92!A(')E<75E7!E(&9R;VT@<')O8VUA;@T*"0D)"0DC M(&YE960@=&\@&ET*'-E M;&8I. at T*"0EP71H:6YG(&-R96%T960@ M<')I;W(@=&\@=&AE(&9IWT-"@EWWT-"@E1=65U95]D:6-T(#T@>WT-"@T*"6QO8V%L9FEL96QI&ET*# I C#0H)"7!R:6YT(")O=71E"LQ#0H` ` end From aa8vb at yahoo.com Fri Nov 19 13:44:22 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Fri, 19 Nov 1999 13:44:22 -0500 Subject: Building wxPython [was Re: wxPython and DISLIN work nicely together] In-Reply-To: <002301bf32b5$97a5d440$0301a8c0@easystreet.com> References: <80s0b4$g5n@mail.psy.uva.nl> <19991117090214.B807152@vislab.epa.gov> <017a01bf31f8$6bbea590$1a25d2d1@jenkondev.com> <19991119064944.A996886@vislab.epa.gov> <002301bf32b5$97a5d440$0301a8c0@easystreet.com> Message-ID: <19991119134422.A1004588@vislab.epa.gov> Robin Dunn: |> |> If only wxPython would build on IRIX... |> |What is the output of "wx-config --cflags" ? It should have the right |include directories for getting all the wxWindows headers. | |Oh wait a minute, it says "/bin/sh: wx-config: not found" so it looks like |you didn't do a "make install" for wxGTK. To the latter, I've already done "make install" for wxGTK: > ls ~/software/wxGTK-2.1.11/ bin/ include/ lib/ share/ and wx-config does exist, in the $WXWIN directory: > python $WXWIN/utils/wxPython-2.1.11/distrib/build.py -b MAKE=gmake ... /bin/sh: wx-config: not found ... > cd ../../.. > find . -name wx-config ./wx-config And to the former, here's my 'wx-config --cflags' output: > wx-config --cflags -I/home/rhh/software/wxGTK-2.1.11/include -I/home/rhh/software/wxGTK-2.1.11/lib/wx/include -D__WXMOTIF__ -I/usr/Motif-1.2/include Leafing through build.py, the problem is that wxPython assumes wxGTK's wx-config is in $PATH. I don't have root so I don't install things in /usr/local/*. (I also don't like having package intermingle in a shared directory tree; too hard to remove them later.) So the change to hack around this is to temporarily add $WXWIN's bin directory to $PATH: env PATH=$WXWIN/bin:$PATH /usr/local/bin/python \ $WXWIN/utils/wxPython-2.1.11/distrib/build.py -b MAKE=gmake Perhaps wxPython should have a --with-wxwindows= option, or take it's queues off of $WXWIN? It then went on a little further to try and compile helpers.cpp, but failed with 84 errors, all (or almost all) due to a bad NULL comparisons in the wxWindows header files. NULL is defined as ((void*)0) and cannot be assigned to / compared with another type without a cast in C++. As this is C++, I believe they should be using "0" for assignments and comparisons. Odd that they even note this fact in wxWindows' defs.h file: #if defined(__SGI_CC__) // Okay this is bad styling, but the native SGI compiler is very picky, it // wont let you compare/assign between a NULL (void *) and another pointer // type. To be really clean we'd need to pass in another argument, the type // of p. -- Randall Hopper aa8vb at yahoo.com From steveef at att.net Tue Nov 30 01:37:47 1999 From: steveef at att.net (steveef at att.net) Date: 30 Nov 1999 06:37:47 GMT Subject: Get Paid While You Surf The Web!!! 9438 Message-ID: <81vrbr$bt3$7247@bgtnsc03.worldnet.att.net> Get paid while you surf the web here: http://www.alladvantage.com/home.asp?refid=FCJ475 cinb From tlane at parlant.com Tue Nov 9 10:50:47 1999 From: tlane at parlant.com (Thomas Lane) Date: Tue, 09 Nov 1999 08:50:47 -0700 Subject: Image buttons with Tkinter References: <38270596.A391995C@parlant.com> <01fd01bf2a3b$52cbd3b0$f29b12c2@secret.pythonware.com> Message-ID: <382842D7.91D729F2@parlant.com> Thanks for the help Fredrik. I am new to Python, so this particular effect of scoping was not apparent to me at first. Since I was doing this inside a method I changed my code to look like: # Put remove.gif on a button (actionbar is a frame for various controls) self.image_delete = PhotoImage(file="remove.gif") deletebutton = Button(actionbar,image=image_delete) deletebutton.place(x=0) That solved the problem. -- Thomas Lane Provo, UT tlane at parlant.com Fredrik Lundh wrote: > > Thomas Lane wrote: > > I'm trying to create a button that displays an image instead of text, > > but I don't seem to be having any luck. The button just comes up gray. > > see: > > http://www.python.org/doc/FAQ.html#4.69 > 4.69. Images on Tk-Buttons don't work in Py15? > > > > From tismer at appliedbiometrics.com Tue Nov 16 12:14:44 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Tue, 16 Nov 1999 18:14:44 +0100 Subject: list.without()? References: Message-ID: <38319104.F54AECEF@appliedbiometrics.com> "Magnus L. Hetland" wrote: > > "Mike Fletcher" writes: > > > Well... > > > > def without( source, element): > > temp = source[:] > > while temp: > > try: > > temp.remove( element ) > > except: > > break > > return temp > > Whoa! > > Why on *earth* would you use a while/try/break-combination? IMO a much > more natural solution would be: > > def without(source, element): > result = source[:] > if element in result: > result.remove(element) > return result But that would be wrong. "Without" means "there is no such object in it", while list.remove removes the first occourance of an object. Mike's implementation appears to be very cheap, since through the try..except clause, he can combine removal with test for existance. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From skip at mojam.com Tue Nov 2 14:19:02 1999 From: skip at mojam.com (Skip Montanaro) Date: Tue, 2 Nov 1999 13:19:02 -0600 (CST) Subject: Assorted Questions regarding the future of Python... In-Reply-To: References: <6D8A17398E28D3119F860090274DD7DB49833A@pces.cadlab.it> <006201bf2517$50edf1f0$f29b12c2@secret.pythonware.com> Message-ID: <14367.14630.983098.834929@dolphin.mojam.com> >>>>> "Francois" == ISO-8859-1 writes: Fran?ois> I'm curious. Does Python use standard optimisation techniques Fran?ois> on that byte code (CSE, strength reduction, and all that)? I Fran?ois> would be tempted to guess that the stack machine receives code Fran?ois> that pretty closely resemble the source code. Would the stack Fran?ois> machine be able to express optimisations? For example, could Fran?ois> we copy or exchange arbitrary stack elements? Several people have worked on various optimizations to the Python virtual machine or to the generated byte code over time. Some of it has already been adopted into compile.c or ceval.c. As a result, I believe the latest version of Python is probably at least twice as fast as 1.3 ('twould be kinda neat if someone did the work to benchmark pystone against various versions of the interpreter). For pointers to stuff I've done (including a peephole optimizer for Python bytecode), check out http://www.musi-cal.com/~skip/python/ For other reported work, check out the Python Conferece proceedings that are online. Pointers are available at http://www.python.org/workshops/ For a completely different look at the Python virtual machine, check out the Rattlesnake list: http://www.egroups.com/group/rattlesnake/ Rattlesnake hasn't gone anywhere in about a year, due to lack of time on my part. The idea is to implement a new three address virtual machine using the existing runtime stack as the "registers", then convert the existing stack-based bytecode to three address bytecode. Three address form is easier to optimize and should (in theory) execute faster after you apply optimizations. If people are interested in fiddling with it I'd be happy to generate a context diff against the current CVS repository and put it up on my Python Bits page. Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/ 847-971-7098 | Python: Programming the way Guido indented... From nascheme at enme.ucalgary.ca Tue Nov 30 00:23:17 1999 From: nascheme at enme.ucalgary.ca (Neil Schemenauer) Date: Tue, 30 Nov 1999 05:23:17 GMT Subject: performance of tuple-less Python? References: <1268226961-30285235@hypernet.com> Message-ID: Gordon McMillan wrote: >They're only redundant if the concept of mutability is >meaningless. A reference-based language without a concept >of mutability would be, um, an adventure. Indeed. >what-if-six-turned-out-to-be-nine-ly y'rs Wasn't there a version of Fortran that allowed this? Python is not totally with a means of enjoying this adventure. >>> None = 1 >>> a = None >>> if a: ... print "oh no" ... oh no That could be fun (or dangerous) in a Python project with lots of developers. Neil (professional hacker at work, do not attempt at home :) From nospam at bitbucket.com Sun Nov 28 03:06:49 1999 From: nospam at bitbucket.com (Phil Mayes) Date: Sun, 28 Nov 1999 00:06:49 -0800 Subject: is there a safe/easy way to search and replace text w/in an html page? References: <3840593B.2D1A2E30@earthlink.net> Message-ID: Levi Cook wrote in message <3840593B.2D1A2E30 at earthlink.net>... >Hello, > >I'm new to python and I've been tasked w/ writing a script that fetches >a web-page and highlights the term that the user searched for. Passing >the URL and search term to my script was a cinch and fetching the page >was also quite easy. > >The crux of my problem lies with establishing a strategy for searching >out the users term and replacing it with css tags surrounding the >original term. >At first glance the re module seemed sufficient (and maybe still is ), >but it doesn't really have any knowledge of HTML semantics. Wrapping the found text in should work fine. One caveat is if tags appear within the target text, eg Netscape pages used to bump the font size of the first letter of a title by one: Netscape >My next >venture was to look at the htmllib module. This appears to parse the >html fine, but i'm still at a bit of a loss on what this actually does >for me, particularly how do I get my parser to output my page. > >Does anyone know where I can find code that does anything remotely like >this? >Does anyone know where I can find good reference on the htmllib module, >the python library reference is pretty bleak in this area. > [code sample snipped] The htmllib module is fairly primitive, eg it doesn't do tables, frames, images or css, so unless you are able to control the HTML contents pretty strictly, you would be better off asking a competent browser to display your modified page - write it somewhere and load file://... What browser to talk to, and how, is going to be machine-specific. On Win98, Internet Explorer can be controlled with PythonWin. Look at win32com\test\testExplorer.py -- Phil Mayes pmayes AT olivebr DOT com Olive Branch Software From jima at aspectdv.com Tue Nov 9 22:04:15 1999 From: jima at aspectdv.com (Jim Althoff) Date: Tue, 09 Nov 1999 19:04:15 -0800 Subject: __str__ vs. __repr__ In-Reply-To: References: <000401bf25b9$88ea57e0$2e2d153f@tim> <199911040157.UAA11908@eric.cnri.reston.va.us> <046101bf26d4$2dd1a720$01ffffc0@worldnet.att.net> Message-ID: <4.2.0.58.19991109190103.00afcab0@mail.aspectdv.com> I agree with Neel. The interactive interpreter is an incredibly powerful tool for learning Python and for developing code. And with JPython, it is a wonderful, powerful tool for learning the Java APIs as well. Jim At 01:17 AM 11/10/99 +0000, Neel Krishnaswami wrote: >Emile van Sebille wrote: > > > >It seems to me that issues arise when using the interactive interpreter. > >I suspect that little useful work is done in this mode, and is used > >predominately for quick testing while creating python programs. > >I'd like to politely disagree . Combined with Tim Peters and Barry >Warsaw's emacs py-mode, Python's interactive mode is the single most >useful feature of the language for me. With it, I can test each and >every method, loop, and statement as I code. This does wonders for my >understanding of my code. And not incidentally, reliability goes way >up as well. > >I learned Perl before Python, but my Python skill surpassed my Perl >skill after a much smaller time investment. I lay this pretty much >wholely at the feet of the interactive interpreter -- I could find out >the answers to puzzles without a tedious edit-save-run cycle. > > >Neel > >-- >http://www.python.org/mailman/listinfo/python-list From akuchlin at mems-exchange.org Thu Nov 4 17:06:12 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 04 Nov 1999 17:06:12 -0500 Subject: Python Conference Hotel Change References: <199911032224.RAA10668@eric.cnri.reston.va.us> <3824f510.12238077@news.demon.co.uk> Message-ID: <3dn1stvrmz.fsf@amarok.cnri.reston.va.us> andy at robanal.demon.co.uk (Andy Robinson) writes: > Guido van Rossum wrote: > >desirable facility for the conference. The new facility is the Key > >Bridge Marriott in Arlington, Virginia. The Key Bridge Marriott is > >conveniently located on the Virginia side of the Key Bridge in the > > My memory may be fuzzy, but isn't it an even shorter stroll from there > to Bardo, one of the world's biggest microbreweries? It's quite a lengthy stroll, really, but a 5- or 10-minute car ride. Doubtless an evening trip can be arranged; I just hope it'll involve playing pool. (I'd be astounded to learn that Bardo's is the largest *anything*, though; it seems to be there are other, larger breweries in the area.) -- A.M. Kuchling http://starship.python.net/crew/amk/ Well, that's a little thing -- the specification. -- Guido van Rossum at IPC7 From pinard at iro.umontreal.ca Mon Nov 1 13:45:21 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 01 Nov 1999 13:45:21 -0500 Subject: Detect file existance before open? In-Reply-To: "Gordon McMillan"'s message of "Sat, 16 Oct 1999 23:21:43 -0400" References: <1271992746-7662859@hypernet.com> Message-ID: "Gordon McMillan" writes: > > I would like to check for the existance of a file before I > > attempt an open and maybe throw an exception. > os.path.exists(nm), probably also os.path.isfile(nm). And also os.path.islink(nm), unfortunately. If a symbolic link exists and points to a deleted file, say, os.path.exists returns None. I found out that you need to test both os.path.exists and os.path.islink before assuming the path is free for safe re-use. It is a bit of constant annoyance in some projects, and do not clearly see how Python `os' library could be improved to make this more transparent. I guess we just have to learn to live with this (?) ... -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From mwh21 at cam.ac.uk Wed Nov 10 03:46:19 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 10 Nov 1999 08:46:19 +0000 Subject: MSWIN:getch() UNIX:? References: <80a3rk$dg4$1@nslave2.tin.it> Message-ID: "Francesco" writes: > There's a module with a getch() function that can run on all > platforms? This is a regular. Have you tried dejanews? In summary - there's a version that'll work on almost every platform your likely to come across, but isn't guaranteed to (it's unlikely to work if the terminal actually is a teletype jobby printing on paper, I'd imagine). Happy searching! Michael From greg.ewing at compaq.com Wed Nov 3 09:26:28 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Thu, 04 Nov 1999 03:26:28 +1300 Subject: A Comparison of Python and Ruby Extension Interfaces (Re: Comparison between Python and "Ruby") References: <3819BCDA.AC4FD4CA@strs.co.uk> <87k8o2x67f.fsf@ev.netlab.co.jp> <7vjtrc$hmm$1@newshost.accu.uu.nl> Message-ID: <38204614.2EAC6051@compaq.com> Martijn Faassen wrote: > > From what I hear in this thread its C interfacing would also be interesting > to compare with Python's, especially since Ruby uses garbage collection, > which is something Python's looking at using in the future, in some > way. Okay, here are some thoughts following a brief time looking at and comparing the "dbm" module implementations from Ruby and Python. The first observation is that the Ruby version is 13K in size, whereas the Python version is only about 7.5K. However, this is not a fair comparison, because the Ruby version defines more methods. Eyeballing the code, I must say that the Ruby version generally looks neater and tidier. Some reasons for this seem to be: * The names of the Ruby interface routines are often shorter than the equivalent Python ones. * Checking types of arguments and raising errors seems to be easier in the Ruby version, e.g. Ruby Check_Type(keystr, T_STRING); key.dptr = RSTRING(keystr)->ptr; key.dsize = RSTRING(keystr)->len; vs. Python if ( !PyArg_Parse(v, "s#", &krec.dptr, &krec.dsize) ) { PyErr_SetString(PyExc_TypeError, "dbm mappings have string indices only"); return -1; } The Ruby version isn't all that much shorter, but it looks neater. On the other hand, the Python version manages to produce a more specific error message; if the Ruby version did that too, it would be longer. * Since Ruby has mark-and-sweep garbage collection, there is no manipulation of reference counts. There weren't actually any examples of this in the Python dbm module, though. * Ruby seems to be able to raise exceptions without having to explicitly propagate them back out of routines, which eliminates a lot of result testing and returning of -1's and None's that goes on in Python extension code. Some other observations, in no particular order: * In Ruby, routines with a fixed number of arguments can be defined so that they are received as separate C arguments instead of a vector, e.g. static VALUE fdbm_store(obj, keystr, valstr) VALUE obj, keystr, valstr; This doesn't actually save much code, however, since you still have to test and convert each argument. * Ruby's method of representing an extension type is a whisker more complicated. Instead of allocating a single object, you have to create an object of type DATA, which contains a pointer to a class and a pointer to a C structure. * The mechanism for associating methods with object types is somewhat simpler in Ruby. In Python, some methods live in slots in the type object, while others live in a method table or are somehow otherwise accessed through the getattr method. In Ruby, all methods, including the ones for built in operations, are attached to the object's class, which seems to play the role of both the Python type object and method table. The initialisation function of the Ruby dbm module starts off like this: void Init_dbm() { cDBM = rb_define_class("DBM", rb_cObject); rb_include_module(cDBM, rb_mEnumerable); rb_define_singleton_method(cDBM, "open", fdbm_s_open, -1); rb_define_singleton_method(cDBM, "new", fdbm_s_open, -1); rb_define_method(cDBM, "close", fdbm_close, 0); rb_define_method(cDBM, "[]", fdbm_fetch, 1); rb_define_method(cDBM, "[]=", fdbm_store, 2); rb_define_method(cDBM, "indexes", fdbm_indexes, -1); etc. There is no need to declare and initialise a type object or method table as in the Python version, which makes things somewhat more direct and easier to follow. Summary: Ruby extension modules seem to be slightly easier to write and read than Python ones. The main reasons for this are the lack of reference counting, a less obtrusive exception propagation mechanism, and a more uniform notion of types and classes. There are also some minor conveniences, such as C methods which take an ordinary argument list instead of a vector. The broad approach to exension writing is, however, fairly similar in both systems. Tomorrow I may take a deeper look at how Ruby unifies types and classes and see whether there is anything there that Python could learn from. Greg From wilsher at my-deja.com Fri Nov 12 12:18:36 1999 From: wilsher at my-deja.com (wilsher at my-deja.com) Date: Fri, 12 Nov 1999 17:18:36 GMT Subject: UML tools: Tcl or Python? References: <382A3896.7FD4F3B0@objectsbydesign.com> Message-ID: <80hi56$97$1@nnrp1.deja.com> In article <382A3896.7FD4F3B0 at objectsbydesign.com>, Stuart Zakon wrote: > Interesting developments for scripting in UML tools: > > First ObjectDomain switched its scripting language from Tcl to JPython. > Next Together/J 3.0 switched its scripting language from JPython to Tcl. > Hmmm, are you sure about this? In the 3.0 Beta they were still supporting JPython, but de-emphasizing it in favour of the Java API. I just had a look at the 3.0 final help docs, which states that "a script is a Java class". There is no mention of either JPython or TCL, as far as I can see. Needless to say, I think JPython makes for a much better application scripting language than Java.... --Thomas Sent via Deja.com http://www.deja.com/ Before you buy. From vroonhof at frege.math.ethz.ch Sun Nov 28 09:37:04 1999 From: vroonhof at frege.math.ethz.ch (Jan Vroonhof) Date: 28 Nov 1999 15:37:04 +0100 Subject: Python complaints References: <867lj85g4c.fsf@g.local> <86so1v4jlj.fsf@g.local> <86ln7m2t31.fsf@g.local> Message-ID: Michael Hudson writes: > This leads to a thought: would it be possible using lisp's silly > amount of flexibility to get the reader to auto-paranthesize (word? > doubt it): It must be in the air or something ;-) I had the same though a while a ago. I even have got a name LISI (Lot's of Significant Indentation) The rules could be extremely simple. 1. each new indentation level introduces another pair of parenthesis 2. Each new line is wrapped in parenthesis Then you get things like defun count-words-region (start end &optional buffer) interactive "_r" save-excursion set-buffer (or buffer (current-buffer)) let words 0 goto-char start while (< (point) end) when (forward-word 1) incf words when (interactive-p) message "Region has %d words" words identity words That last line is ugly because in this way it is very difficult to distinguish between a no-argument function call and a variable reference. Sometimes however I think it would be more fashionable to replace all parenthesis by angle brackets and re-brand Lisp as LIML. Jan From fdrake at acm.org Tue Nov 16 15:28:27 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Tue, 16 Nov 1999 15:28:27 -0500 (EST) Subject: Final classes like in java??? In-Reply-To: <14385.48236.202756.297241@goon.cnri.reston.va.us> References: <80sao7$1848$1@rtpnews.raleigh.ibm.com> <14385.45862.55010.146256@weyr.cnri.reston.va.us> <14385.48236.202756.297241@goon.cnri.reston.va.us> Message-ID: <14385.48747.331513.47679@weyr.cnri.reston.va.us> I wrote: > Not guaranteed, but this should be good enough: Jeremy Hylton writes: > This doesn't really work. That's exactly why I said it wasn't guaranteed. ;-) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From thomas at bibsyst.no Mon Nov 1 06:25:55 1999 From: thomas at bibsyst.no (Thomas Weholt) Date: Mon, 01 Nov 1999 12:25:55 +0100 Subject: Just a note References: <381D5E84.98931682@bibsyst.no> Message-ID: <381D78C3.9BBECCB0@bibsyst.no> Hi, I could use stuff like MySQL too, if it`s easy to install and use with Python, but since I only want to store objects and fetch them by a single key, the simplest way to do this would be using some of the built-in stuff in Python. I will store HUGE amounts of data, so I think Gadfly would be "too small" as DBMS, since it stores all it`s data in memory ( as I recall ) . PS! If this mail made no sense, try reading the message prior to this one. Best regards, Thomas Weholt From ivanlan at callware.com Tue Nov 9 00:22:55 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Mon, 08 Nov 1999 22:22:55 -0700 Subject: python: something completely different References: <3820C0B8.62B2@iowegian.com> <38249ED2.BB7EA1DE@znet.com> <8028jv$7cf$1@hub.org> <38259F18.437@iowegian.com> <38278B5F.1AFF953C@python.net> Message-ID: <3827AFAF.FF46C33@callware.com> Hi All-- bob yazon wrote: > > The orig post got me interested in the stuff. I just finished installing it > + win32ext, numeric, and gnuplot. I can get pretty good graphs using > gnuplot, I think I'll start using python instead of Mlab. > > --ry > Would you consider letting us in on your secrets? You could write it up and it could go in the FAQ. -ly y'rs, Ivan;-) ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours ---------------------------------------------- From mikael at isy.liu.se Fri Nov 5 04:06:17 1999 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 05 Nov 1999 11:06:17 +0200 (MET) Subject: Apply a function to each list member? In-Reply-To: Message-ID: On 05-Nov-99 Blake Winton wrote: > Speaking as someone who's one language is English, "Probably not". > "map" is really a Lisp/Scheme concept, and bears only a passing > relationship to English. (Huh, what do ya know, looking up "map" > on http://www.m-w.com/ reveals (in meaning 4) that "map" actually > means "FUNCTION". I have no idea why they capitalized it.) I guess the terminology originally is taken from mathematics. A map is a mathematical concept, similar to a function. Perhaps you should say that a function is a map, rather than the other way around. Sometimes people say a mapping instead of a map. They may also use the word as a verb, saying that they map things. Other languages use words meaning image or reflection for the same concept. And why not, a (geographical) map is an image that reflects reality. programming-is-doing-math-ly y'rs /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: 05-Nov-99 Time: 10:51:25 This message was sent by XF-Mail. ----------------------------------------------------------------------- From aahz at netcom.com Wed Nov 10 22:02:24 1999 From: aahz at netcom.com (Aahz Maruch) Date: 11 Nov 1999 03:02:24 GMT Subject: Namespace question... References: <7vqgib$l8v$1@nnrp1.deja.com> <80c3e4$vpq$1@nnrp1.deja.com> Message-ID: <80dbk0$qiu$1@nntp5.atl.mindspring.net> In article <80c3e4$vpq$1 at nnrp1.deja.com>, wrote: >In article <7vqgib$l8v$1 at nnrp1.deja.com>, > oofoe at my-deja.com wrote: >> >> How can you access the global namespace in python 1.5.1? I'd like to get >> a version string which is declared in the main script file. However, >> each module also has a version string which overrides the original one. >> I tried to access it as __main__.Version, similarly to $main::Version in >> Perl, which is what I'm more familiar with. Of course, it didn't work. > >just declare Version to be global inside bar() as >follows: > >def bar(): > global Version > print "Version is: ", Version Your response is wrong: it works within a module, but not inside a module that has been imported into another script. Eric Jacobs gave a correct response (import __main__), but in general it's a better idea to pass information in (interface specified) rather than having a module make assumptions about what kind of script will import it. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From jeremy at cnri.reston.va.us Fri Nov 5 16:15:51 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Fri, 5 Nov 1999 16:15:51 -0500 (EST) Subject: IPC8: SouthWest Airlines Internet specials In-Reply-To: <14371.16525.555599.961527@dolphin.mojam.com> References: <14371.14313.700685.807764@goon.cnri.reston.va.us> <14371.16525.555599.961527@dolphin.mojam.com> Message-ID: <14371.18695.714122.631868@goon.cnri.reston.va.us> >>>>> "SM" == Skip Montanaro writes: Jeremy> Everyone planning to fly to the conference should consider Jeremy> flying through BWI. I have flown from BWI to San Jose and Jeremy> San Francisco a few times this year, each time for about Jeremy> $200. Flights through BWI are often cheaper than flights Jeremy> from Dulles or National. SM> If you're on a budget and might like to get away without renting SM> a car, don't forget to figure in the cost of ground transport SM> into the total equation. For IPC1 I flew into BWI and found the SM> metro didn't go there. Not real convenient. At least with SM> National you've got a Metro station nearby. Good point! It is possible to take public transportation, but it isn't easy. I just talked to a woman at the hotel about how to get there from BWI and they recommended a taxi, with an estimated cost of $50-$60. She also mentioned a company called "1-800-BLUE-VAN" that might offer a shuttle bus to the hotel; she was vague on details, but it sounds like we have at least a phone number. We also discussed two possibilities using public transportation. You can take the commuter rail from BWI to Union Station in DC, and get on the DC Metro (subway) from there. The train ticket costs $5, and the ride is about 20 minutes; check the schedule for departure times. There is a shuttle bus at the airport between the terminal and the rail station. If you took a cab to the hotel from Union Station, it would probably cost around $15. You could also take the Metro to the Rossyln stop, which is two-and-a-half blocks from the hotel. If you get there before 7:30pm, the hotel runs a shuttle service that will take you the last leg. There are Web pages for the commuter rail -- http://www.mtamaryland.com/marc/marc_fare.htm -- and the subway -- http://www.wmata.com/ SM> All that said, I don't know how convenient the conference SM> location is to public transport. Jeremy, Guido, and other SM> locals (yikes! Guido's a local now?) can probably give a summary SM> of that sort of thing. I hope that helps. I don't know the area around the hotel, though; perhaps some other local can fill in details if you've got more questions. I think the local travel between Dulles and National airports is a lot simpler, although there is no public transportation that reaches Dulles. I'm fairly certain there are shuttle buses that get into DC for a reasonable price, and a cab would be fairly inexpensive. Jeremy From emile at fenx.com Sun Nov 28 12:19:12 1999 From: emile at fenx.com (Emile van Sebille) Date: Sun, 28 Nov 1999 09:19:12 -0800 Subject: Binary vs non-binary References: <19991127103504.A1536@stopcontact.palga.uucp> Message-ID: <08ef01bf39c4$b3ff75e0$01ffffc0@worldnet.att.net> Also, in DOS OS's, 1Ax will be interpreted as EOF in non-Binary mode, and you may not get the whole file as a result. -- Emile van Sebille emile at fenx.com ------------------- From gherman at darwin.in-berlin.de Thu Nov 4 07:01:18 1999 From: gherman at darwin.in-berlin.de (Dinu C. Gherman) Date: Thu, 04 Nov 1999 13:01:18 +0100 Subject: return boolean from functions References: <7vrq9b$hmr$1@nnrp1.deja.com> Message-ID: <3821758E.5080EAA4@darwin.in-berlin.de> a_olme at my-deja.com wrote: > > Is it possible to return booelan from functions other than > return 1==1 for true or return 1==2 for false? There is no such thing like Booleans in Python. What you describe is simply the use of Python integers as Booleans, in this case 1 and 0, respectively. Real-booleans-are-not-bad-but-few-people-advocate-them'ly, Dinu -- Dinu C. Gherman ................................................................ Food for Echelon: Delta Force, SEAL, virtual, WASS, WID, Dolch, secure shell, screws, Black-Ops, O/S, Area51, SABC, basement, ISWG, $@, data-haven, NSDD, black-bag, rack, TEMPEST, Goodwin, rebels, ID, MD5, IDEA, garbage, market, beef, Stego, ISAF, NARF, Manfurov, Kvashnin, Marx, Abdurahmon, snullen, Pseudonyms, MITM, Gray Data, VLSI, Leitrim... -- Visit http://www.hacktivism.org From python-list at teleo.net Thu Nov 11 11:10:18 1999 From: python-list at teleo.net (Patrick Phalen) Date: Thu, 11 Nov 1999 08:10:18 -0800 Subject: How to perform syntax check in Python In-Reply-To: References: Message-ID: <99111108162301.02136@quadra.teleo.net> [Moshe Zadka, on Wed, 10 Nov 1999]: :: Ummm....what planet are you from? :: :: Python has no notion of declaring variables at compile time, only at :: run-time. That means program flow can impact what name are "alive". This :: means Python has to solve halting-problem-equivalent problems in order to :: check for undeclared variables. I don't know what state HP is in, but if :: you know how to solve the halting problem, you should patent it, and build :: a brand new company. Guido has chosen not to release that technology into :: Python for the next 5 years. You seem tense, Moshe. Have you been drinking too much coffee? Remember to take a break from the computer once in awhile. Go outside. Look at the sky. Breathe. Relax. From tekhir at yahoo.com Mon Nov 15 00:28:28 1999 From: tekhir at yahoo.com (Jeremy Misavage) Date: Mon, 15 Nov 1999 00:28:28 -0500 Subject: Setting up Python for IIS/PWS References: <382F4A22.514281A8@yahoo.com> Message-ID: <382F99FC.DEE9E08E@yahoo.com> Oops. The had spaces in in it and I just forgot to put quotes around the path. ----- .py :REG_SZ: c:\\python.exe -u %s %s From evan at tokenexchange.com Thu Nov 4 14:26:15 1999 From: evan at tokenexchange.com (Evan Simpson) Date: Thu, 4 Nov 1999 13:26:15 -0600 Subject: Zope comparisons? (ASP, PHP, etc) References: <3821C5F6.84543AF2@yahoo.com> Message-ID: <06lU3.259$Ae3.186544@news-dal.corridex.com> There has been a lot of discussion lately on the Zope mailing list (zope at zope.org) about making this sort of information more readily available on the website, but here's a brief intro: Zope has several parts, which work well together, but are all optional: 1. ZServer: A Medusa-based multi-threaded asynchronous server which accepts HTTP, FTP, and monitor (special Python client) connections. Usually, it passes requests from these connections to... 2. ZPublisher: An ORB which converts HTTP, FTP, XML-RPC, WebDAV, etc. requests into traversal of an object hierarchy and returns the result of rendering the target object. These objects are normally stored in... 3. ZODB: A versioning, transaction-based object store with automatic object persistence and conflict handling. ZODB stores an object hierarchy as a single file (2GB limit being worked on) and appends new versions of objects when their request transaction is comitted. This allows extensive undo, and requires occasional packing to eliminate old, unwanted versions. Most HTML is generated by standard Zope objects using... 4. DTML: An embedded language similar to ASP and PHP, except that expressions are written in Python and have access to the full power of the rest of Zope, including... 5. Acquisition: A feature of standard Zope objects which allows them to change their behavior automatically based on the context in which they are called. Hard to describe, but very powerful, as are... 6. Products: New objects or collections of objects can be added to Zope by simply installing a Python package in the Products subdirectory and resetting the server. Current Products include database adapters, threaded discussions, virtual host managers, and many others. Of course, if you don't want to learn Python you can always create... 7. ZClasses: Object classes defined through the web management interface by assembling standard Zope parts. These can provide a wide range of customized objects. I haven't really gotten into the user/role/permission security model, or the extensive web management interface through which you typically interact with Zope. I may have forgotten other bits, too. There's a lot there :-) Charlie Hubbard wrote in message news:3821C5F6.84543AF2 at yahoo.com... > I'm looking for some comparison info about zope. Why zope? > How is it different, the same, or better than ASP, PHP, or > DHTML? I've looked over some different docs on zope.org, > but I wasn't able to find any info about what need zope fills. > What can you do with zope that you can't do with ASP or PHP? > It seems zope is based off of an object model where PHP and > ASP are simplying server side scripting languages. Does zope > fill that need? Is it in competition with this languages? Would > there be any reason to use Zope with ASP or PHP? From endgamer71 at hotmail.com Tue Nov 9 08:52:45 1999 From: endgamer71 at hotmail.com (Endgamer) Date: Tue, 09 Nov 1999 13:52:45 GMT Subject: Newbie question: Input References: <3826b693.3888197@212.225.36.99> Message-ID: <382821d7.96897763@212.225.36.99> On Mon, 8 Nov 1999 08:55:07 -0500, "Darrell" wrote: >From Python Library Reference: > >raw_input ([prompt]) >If the prompt argument is present, it is written to standard output without >a trailing newline. The function then reads a line from input, converts it >to a string (stripping a trailing newline), and returns that. When EOF is >read, EOFError is raised. Example: > >>>> s = raw_input('--> ') >--> Monty Python's Flying Circus >>>> s >"Monty Python's Flying Circus" >>>> > >If the readline module was loaded, then raw_input() will use it to provide >elaborate line editing and history features. Cheers, Darrell. This is just what I was looking for! Endgamer Spider Warrior (Endgamer71 at spamtrap.hotmail.com) ##################################### Not a quote, just an on-the-spot observation: You know you're a geek when your PC costs exactly 15 times as much as your stereo. And gives better sound quality. Endgamer ##################################### From fredrik at pythonware.com Wed Nov 24 04:23:27 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 24 Nov 1999 10:23:27 +0100 Subject: Python complaints References: <8666ysfta9.fsf@ix.netcom.com> Message-ID: <012e01bf365d$912fa360$f29b12c2@secret.pythonware.com> Brad Knotwell wrote: > Similarly, the only thing I've found missing from Python is C's > ternary operator, it would be nice to be able to do something like > the following: > > def max(x,y): return ((x>y) ? x : y) now that was one lousy example ;-) Python 1.5.2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> max(1, 2) 2 From phd at phd.russ.ru Sat Nov 6 10:32:30 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Sat, 6 Nov 1999 15:32:30 +0000 (GMT) Subject: Get parameter by name In-Reply-To: <3823FD98.8424037F@python.net> Message-ID: On Sat, 6 Nov 1999, Thomas A. Bryan wrote: > I'm not sure whether I understand the question. Is this what you're > trying to figure out? > > >>> ka = 1 > >>> x = 'ka' > >>> eval(x) > 1 > >>> y = eval(x) > >>> y > 1 > > If not, please repost. Yes, but it is better to use locals() or vars() function for this... Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From dfan at harmonixmusic.com Tue Nov 30 09:26:11 1999 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 30 Nov 1999 09:26:11 -0500 Subject: Python complaints References: Message-ID: Mark Carroll writes: | Basically, I'd be really interested to learn: what _don't_ people | like about Python? Every language has things that many people | complain about, however reasonably, or would like to have been | different, and I'd be interested to know what Python's are so I can | get an idea if any are going to annoy me, rather than me being | confused then frustrated then disappointed about them as I discover | them further in. For instance, I'm sure plenty of people would hate | Modula-3's lack of implicit casting, need to define everything | before using it, Pascal-style uppercase keywords, etc. Are there any | ways that Python makes programming slightly more awkward than people | would have liked? The main thing I find frustrating is that lambdas are not very powerful. Much of the time that I would use a simple 'map {}' in Perl, I find that I have to write a separate function, or iterate by hand. My understanding, though, is that there's no plan to make lambdas more powerful, which is a bit disappointing to me. Michael Hudson's bytecodehacks do ameliorate some of my problems with trying to write in a functional style. I hope they make it into the standard library at some point. -- Dan Schmidt | http://www.dfan.org From paul at digicool.com Sat Nov 13 08:34:11 1999 From: paul at digicool.com (Paul Everitt) Date: Sat, 13 Nov 1999 08:34:11 -0500 Subject: Production Web Deployment? References: <3826C69F.B4E26B89@digicool.com> <14379.18122.156471.644349@ghost.bbn.com> Message-ID: <382D68D3.46CEFD61@digicool.com> Tim O'Malley wrote: > Is Zope.org using Apache? > There is a prototype (alpha) Apache module which embeds the > functionality of PCGI into Apache. If this worked for you, then you > would maintain compatibility with PCGI. Howdy Tim, thanks for the note. Yes, we know about Andrew's mod_pcgi. Our ultimate goal is to leverage the active development of another group's webserver integration. FastCGI gives us a three-year-old Apache module, plus commercial and supported versions for Netscape and IIS (and Apache). Additionally, FastCGI has support for TCP sockets in addition to domain sockets, which helps deal with file permission errors when configuring it. The major reason we ditched FastCGI and came up with PCGI in the first place (lack of threading in the library meant a person could telnet into your application and lock the app) is no longer pertinent with the new Zope2 architecture. This has us hoping to get FastCGI back in as a viable choice. Seems nobody in the Zope community is eager to maintain an Apache module. :^) --Paul From david at forestfield.co.uk Sat Nov 13 13:25:00 1999 From: david at forestfield.co.uk (David F Hughes) Date: Sat, 13 Nov 1999 18:25 +0000 (GMT Standard Time) Subject: [HELP] TKinter could not run in Python! References: <80i63e$7t4$1@news.seed.net.tw> Message-ID: In article <80i63e$7t4$1 at news.seed.net.tw>, wuhy at tcts.seed.net.tw (Mark Wu) wrote: > TclError: Can't find a usable init.tcl in the following directories: > {d:\progra~1\tcl\lib\tcl8.1} {} ./lib/tcl8.0 > D:/Python/tcl8.0/library > D:/Pyt > hon/Tools/library > > > This probably means that Tcl wasn't installed properly. As another Python newbie, I have just spent a couple of hours grappling with the same problem. I tracked it down to copies of Tcl80.dll and Tk80.dll that had gotten installed in [Windir]\system. Removing them solved the problem. It was also necessary to tell Python where to find the real Tcl installation by adding C:\Progra~1\tcl\bin to the PATH command in autoexec.bat - I think this would have been done automatically during the Python install, but it had been confused by the above. I believe that the dll's had been put into the \system directory by a (rather garish)Tcl GUI builder called SpecTcl (from SUN microsystems dated September 1997) which I had installed to evaluate but decided not to use - well anyway, SpecTcl stopped working after removing them! Regards, David Hughes Forestfield Software Ltd. Horsham, UK. [david at forestfield.co.uk] From gang.li at compuware.com Thu Nov 4 16:21:14 1999 From: gang.li at compuware.com (Gang Li) Date: Thu, 4 Nov 1999 14:21:14 -0700 Subject: input parameters dependcy? Message-ID: <3821e773@199.186.16.51> How can I know which inpute parameters will be used in a function, before call the function. e.g. If I have a function def foo(self, var1, var2): a = self.left b = var1+var2 c = a + self.top return a,b,c module test1 as following g1 = [3] g2 = [4] class CL: __init__(self, l, t): self.left = l self.top = t cl = CL(100, 20) tt = foo(cl, g1, g2) Before the call foo(cl, g1, g2), from the code of foo, I know cl.top, cl.left, g1 and g2 will be used. How can I detect which variables will be used give the call condition foo(cl,g1,g2) before call it? From I at DONT.LIKE.SPAM Mon Nov 15 21:53:51 1999 From: I at DONT.LIKE.SPAM (David S.) Date: Mon, 15 Nov 1999 18:53:51 -0800 Subject: Daemonic threads Message-ID: <3830C73F.C8A7CA62@DONT.LIKE.SPAM> I'm writing a CGI script that will launch a long-running process in the background, and return some HTML page to the browser. Now, I know how to do that with 'fork()', but it seems to me that I should be able to do the same thing with a daemonic thread from the 'threading' module. I can't get that to work, though, ... xt = threading.Thread(target=_threadExec, args=(save, mail, None)) xt.setDaemon(1) xt.start() ... and the script exits with no thread running. Non-daemonic threads seem to work as I expect them to. What don't I understand about daemonic threads? (Python 1.5.2 on Linux 2.2.7, if its relevant.) David S. davids@ ... bdgp.org From asdkzjlaskld at oe80938.org Mon Nov 1 06:36:06 1999 From: asdkzjlaskld at oe80938.org (asdkzjlaskld at oe80938.org) Date: Mon, 01 Nov 1999 11:36:06 GMT Subject: *Inkjetz 4 you Message-ID: <9LX7HF6X.ICIZD40N@oe80938.org> The Inkjet Company has the following inkjet specials: All Prices Include Free Shipping and Free Sales Tax EPSON Epson - $8.00 - Black or 10 for $65.00 - All Models* Epson - $12.00 - Color or 10 for $100.00 - All Models* *Epson - $16.00 - Black or 10 for $135.00 - 900/3000 *Epson - $19.00 - Color or 10 for $165.00 - 750/900/1200/3000 CANON Canon BCI-21B - $5.00 - Black BJC-2500/4000/4400/5000 Canon BCI-21C - $8.00 - Color BJC-2500/4000/4400/5000 Canon BC-20 - $18.00 - Black BJC-2500/4000/4300/4400/ Canon BC-02 - $16.50 - Black BJC-210/230/BJ-200 Canon BC-05 - $28.00 - Tri-Color BJC-210/240 Canon BX-3 - $28.00 - Black B-540/550/640 (See Below For Apple & H.P. Products) The Inkjet Company 1-310-517-9999 1-503-905-6652 Fax APPLE M8041G/C - $17.00 - Black Styler Writer 1500 M4609G/C - $30.00 - Tri-Color Styler Writer 1500 M3240G/A - $19.00 - Large "Double" Black Style Writer 2400 M3330G/A - $5.00 - Black Style Writer 2400 M3329G/A - $9.00 - Tri-Color Style Writer 2400 M1949G/A - $3.75 - Cyan Color Style Writer Pro M1950G/A - $3.75 - Magenta Color Style Writer Pro M1951G/A - $3.75 - Yellow Color Style Writer Pro M1952G/A - $3.75 - Black High Capcity Color Style Writer Pro HEWLETT PACKARD 51625A - $19.00 - Tri-Color Deskjet 500c/550 Series 51626A - $16.50 - Black Deskjet Series / OfficeJet 300 / HP Fax 51629A - $16.50 - Black Deskjet 600 Series / OfficeJet 500 Series 51649A - $19.00 - Tri-Color Deskjet 600 Series / OfficeJet 500 Series 51645A - $16.50 - Black Deskjet 700/800/1000/1600 51640A - $16.50 - Black Deskjet 1200 / CopyJet The Inkjet Company 1-310-517-9999 1-503-905-6652 Fax Visa, Mastercard, Amex, Discover Fast Free Delivery - usually in two days or less! From skip at mojam.com Wed Nov 3 11:39:17 1999 From: skip at mojam.com (Skip Montanaro) Date: Wed, 3 Nov 1999 10:39:17 -0600 (CST) Subject: assert module search In-Reply-To: <7vpmi4$1gp$1@nnrp1.deja.com> References: <000601bf25be$0cdeb880$2e2d153f@tim> <381FEF10.3B27C05B@webone.com.au> <7vpmi4$1gp$1@nnrp1.deja.com> Message-ID: <14368.25909.535147.527730@dolphin.mojam.com> mehta> which module does assert function belong to? I tried to link to mehta> it through api docs but led me to exceptions module. Assert is a keyword in the language, not a function. Docs for it are at http://www.python.org/doc/current/ref/assert.html Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/ 847-971-7098 | Python: Programming the way Guido indented... From aa8vb at yahoo.com Tue Nov 16 07:42:51 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Tue, 16 Nov 1999 07:42:51 -0500 Subject: python-sound-server for PySol under unix In-Reply-To: References: Message-ID: <19991116074251.B711753@vislab.epa.gov> Markus F.X.J. Oberhumer: |I've written a prototype implementation of a simple |sound server for the next PySol release using a Sounds pretty cool. :-) |small Python UDP server which forks of calls |to wav players like sox and bplay, but the |performance is not suitable for general release. | |Basically I'd only need what the Win32 winsound |module provides (play/loop/stop), though further |extensions could be interesting for other applications. | |So is there an official Python-way of playing |high-quality wav sounds under Unix ? |Using pipes, sockets, or daemons like ESD ? ------------------------------------------------------------------------------ rplay is one fairly portable sound server out there http://rplay.doit.org/ >From the README, it supports Linux, SunOS 4.1.x, and Solaris 2.x. FreeBSD works as well. The README says that Irix and HPUX support are supported but status isn't known. Win32 isn't listed. ------------------------------------------------------------------------------ A Python SDL wrapper sounds interesting too. Adds Win32 portability but hits a few less UNICes: http://www.devolution.com/~slouken/SDL/ You probably have investigated it more than I have, but at first glance, it looks like it might be well suited for scripted access (in that much of the processing is off-loaded to C). FWIW, I recall reading that MpegTV (www.mpegtv.com) uses SDL for full-screen DGA playback under XFree86. Good luck! -- Randall Hopper aa8vb at yahoo.com From juping+ at pitt.edu Wed Nov 10 09:24:18 1999 From: juping+ at pitt.edu (Juping Jin) Date: 10 Nov 1999 14:24:18 GMT Subject: Call a function in DLL with string arguments? Message-ID: <80bv6i$kp$1@usenet01.srv.cis.pitt.edu> I wrote a DLL and want its functions being available from python. Its function accept string arguments. From python, I use windll to load the module like: handle = windll.module("dllname") handle.fcnname(arguments) Python gives following msg: TypeError: illegal argument type for built-in operation So I did some tests, wrote a small dll and found out that if the function accept only numerical values (actually, only integer value produces expected results), then python won't give above errors. For char or char * argument, it always gave above msg. Did I do something wrong? Thanks for your reading. Juping From nemeth at iqsoft.hu Tue Nov 16 05:09:25 1999 From: nemeth at iqsoft.hu (Nemeth Miklos) Date: Tue, 16 Nov 1999 11:09:25 +0100 Subject: Beginning programming with Python References: <382B3A53.5816B2@callware.com> <382B3D79.74CD3E0F@email.sps.mot.com> <80p9ds$ppo$1@newshost.accu.uu.nl> Message-ID: <38312D55.A36EB56D@iqsoft.hu> Janos Blazi wrote: > I have tried to use Perl in my teaching. It has a very powerful but alas! > not very simple syntax! To start with, my pupils used to forget the dollar > signs and Perl does not like that. So this year I shall use Python. We shall > see. Time will tell, if Python is really better. Maybe my pupils will forget > the indenting this time? There is actually nothing else you can forget in > Python. I am quite new in Python programming, and I was a bit :-( by understanding that Python does not have any (even optional) mechanism to enforce the usage of predeclared variables and functions. The complete lack of compile-time type-safety of Pythom may be a problem in large projects, which may be the most serious technical (ie non-marketing) obstacle to Python's becoming a widespread language like Java. Let us see an example: # Module t.py def f(): print "started" x = 128 x.foo() Let us import it in the Python interpreter: >>> import t >>> You can see thet the interpreter compiled t.py to t.pyc (or t.pyo) but found no error. All typos (typing errors of variable and function names) will be detected ONLY at runtime! Python is perfect language to write programs fast, but with the cost of hordes of testers. However this may not be a big problem, because any piece of software should be thoroughly tested, to make sure that there are no semantic errors in the application. In the case of Python the applications should also be tested for "syntactic" errors. In Python (just like in Smalltalk or in Perl, or in Tcl) there are a lot of things a programmer may forget. I am on my way of becomming a Python programmer, but this should not prevent me from seeing the pitfalls of the language. A tutor must emphasize these gotchas of any programming language. Perl has a facility called 'use strict': it is also very poor compared to C++ and Java strict static (ie compile time) system. The only really large project implemented in Python I found is Zope. Zope is a fantastic piece of software, and may be regarded as an evidence of my being totally wrong ;-). > I feel that it is the right language for teaching. Anyway, Python is a great language for teaching, but why to learn a language, which is good only for teachning?! This is the real question you (or the Python community) should answer! Miklos Nemeth IQSOFT From gmcm at hypernet.com Wed Nov 10 13:30:21 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 10 Nov 1999 13:30:21 -0500 Subject: statics everywhere. Why? In-Reply-To: <011701bf2ba4$1a899b80$f29b12c2@secret.pythonware.com> Message-ID: <1269863880-796781@hypernet.com> Fredrik wrote: > Arinte wrote: > > Embedding python in a c application, why do I need > > to make the functions that python call and variables > > for callbacks static? > > beats me. what happens if you don't > make them static? On Unix, it exposes all your internals (with unpredictable results) to anyone loading your .so. On Windows, this isn't a problem, and much of the time you can control this with linker / loader options on Unix. But since C promises not to let anyone else know about a file static, it's both the easy and safe route to portability. - Gordon From a.eyre at optichrome.com Tue Nov 30 09:05:06 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Tue, 30 Nov 1999 14:05:06 -0000 Subject: WinNT and DLL's In-Reply-To: Message-ID: <001701bf3b3b$e7a39570$3acbd9c2@peridot.optichrome.com> > Is there a way that I can simply access the pre-compiled dll files? Have a look at the calldll module: http://www.nightmare.com/software.html -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From eric at net.tamu.edu Wed Nov 3 16:11:46 1999 From: eric at net.tamu.edu (Eric Nelson) Date: Wed, 3 Nov 1999 15:11:46 -0600 Subject: 64 bit ints for SNMP counter64 variables Message-ID: <7vq8eg$4k$1@news.tamu.edu> Is there not a 'long long' data type in python? I've got 64 bit counters coming from snmp variables that I need to work with.... How about a variable precision type module?? Eric eric at net.tamu.edu From greg.ewing at compaq.com Wed Nov 24 09:33:03 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Thu, 25 Nov 1999 03:33:03 +1300 Subject: filter function question - list processing in Python References: <81f18b$hor$1@nnrp1.deja.com> Message-ID: <383BF71F.3E413E33@compaq.com> lobozc at my-deja.com wrote: > > How should I pass additional parameter in 'filter'? 'map' has them, > filter doesn't - why? Say I have a list ['xxx.py','xxx.pyc'] and I want > to have a function isExtension(x,'.py') > [No, I'm not interested in using lambda here in general]. Why not? That's the shortest way to do it: def filterExt(items, ext): return filter(lambda x, ext=ext: isExtension(x,ext), items) However, a more Pythonic way of writing that is def filterExt(items, ext): result = [] for x in items: if isExtension(x, ext): result.append(x) return result which is longer-winded but clearer. If you want something which is both short-winded and clear, you might like to try my List Comprehension syntax extension, which allows you to write def filterExt(items, ext): # NOT STANDARD PYTHON return [x for x in items if isExtension(x, ext)] The List Comprehensions patch is available from my web page: http://www.cosc.canterbury.ac.nz/~greg Greg - which I can call with various > extensions to filter the list in variuos ways - how am I supposed to do > that? [No, I'm not interested in using lambda here in general]. > > In general, I note that Python has some standard functions operating on > lists but they are curiously limited. It is a pity, since these are the > functions which reduce line count significantly - as well as make > programming safer. I wonder what are the chances of repeating with > lists what Python did with regular expressions - copying the > functionality from a well tested and popular product? > > Mathematica has a set of list processing functions. As one can expect > from an essentially functional language and a product where most > operations are done by list processing - for the last 10 years - this > set is well thought out, complete and very, very useful. > > [For description see > http://documents.wolfram.com/v4/frames/frames.html, press button 'built- > in functions', on the leftmost panel 'programming', to the right of it > press 'functional programming' - eventually look for functions like > Map, Fold, Apply etc.]. > > Sent via Deja.com http://www.deja.com/ > Before you buy. From fdrake at acm.org Wed Nov 24 10:39:01 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Wed, 24 Nov 1999 10:39:01 -0500 (EST) Subject: Asyncchat Module Documentation and some asyncchat based modules In-Reply-To: <19991123175832.A26756@gothic.andrich.net> References: <19991123175832.A26756@gothic.andrich.net> Message-ID: <14396.1685.377777.533389@weyr.cnri.reston.va.us> Oliver Andrich writes: > Hi, Hi, Oliver! > after I spend most of the last weeks implementing some asyncchat > based clients for common used protocols (at least I use the quite > common ;-) and a asyncchat based POP3 server. I like to ask if > somebody already started to document this module for the library > reference, otherwise I am willing and happy to do it. I am so > impressed by asyncore and asyncchat, that I like to do it. ;-) asyncore is documented in the latest release of the documentation; I don't think it's included in the most recent Windows installer. It's easy to update the installed documentation under Windows; just unpack the ZIP file in the right place and viola! > And I am looking forward to do a first release of my package of > asnyc* based clients in a week or two. And my POP3 server (100% > pure Python) in about three weeks. I have to to do some code > cleanups, security checks and performance tuning, but at the moment > the POP3 server runs fine in my testbed (simulating the 16.000 > users I have on my production machine) and it outperforms cucipop > without any problems. Cool stuff! > So, who do I have to contact to supply documentation for asynchat? Me! You can send it to me at python-docs at python.org, along with the appropriate release form. See http://www.python.org/1.5/patch.html for information about the release forms; we need that so we can incorporate and distribute your additions. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From cfelling at iae.nl Sat Nov 27 16:56:06 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 27 Nov 1999 22:56:06 +0100 Subject: Newbie: raw_input and other input methods References: <19991125.1481400@adam-aurag.penguinpowered.com> <81kfjc$1vg$1@vvs.superst.iae.nl> <383EC1A5.99A4FAD5@lemburg.com> Message-ID: <81pk1m$2i6$1@vvs.superst.iae.nl> M.-A. Lemburg wrote: > It even does the Right Thing for the Python prompt. Try this: ... > The above adds a little color to your average Python prompt. Well, I was to save this for a rainy day, but now that you generalized it I can't help. Besides it isn't nice to use terminal specific codes. -------------------------------------------------------------------------- import readline, os class PromptFunc: '''bucket for function to be evaluated during prompting''' def __init__(self, func, *args, **keys): self.func, self.args, self.keys = func, args, keys def __str__(self): return apply(self.func, self.args, self.keys) class Tput: '''terminfo capability string to be evaluated during prompting embedded with readline specials so it won\'t take up any space''' def __init__(self, attribute): self.attribute = attribute def __str__(self): return '\001' + os.popen('tput ' + self.attribute).read() + '\002' class Var: '''(environment) variable to be evaluated during prompting''' def __init__(self, var, dict=os.environ): self.var, self.dict = var, dict def __str__(self): return self.dict[self.var] class Prompt: def __init__(self, prompt='>>>', **state): self.prompt = prompt #colors; unfortunately xterm doesn't seem to obey terminfo names self.black, self.red = Tput('setf 0'), Tput('setf 1') self.green, self.yellow = Tput('setf 2'), Tput('setf 3') self.blue, self.magenta = Tput('setf 4'), Tput('setf 5') self.cyan, self.white = Tput('setf 6'), Tput('setf 7') #background colors self.Back, self.Red = Tput('setb 0'), Tput('setb 1') self.Green, self.Yellow = Tput('setb 2'), Tput('setb 3') self.Blue, self.Magenta = Tput('setb 4'), Tput('setb 5') self.Cyan, self.White = Tput('setb 6'), Tput('setb 7') #video attributes self.bold, self.blink = Tput('bold'), Tput('blink') self.dim, self.reverse = Tput('dim'), Tput('rev') self.flash, self.normal = Tput('flash'), Tput('sgr0') #emphesize self.begin_standout, self.end_standout = Tput('smso'), Tput('rmso') self.begin_underline, self.end_underline = Tput('smul'), Tput('rmul') #alternate charset self.begin_alternate, self.end_alternate = Tput('smacs'), Tput('rmacs') #override whatever self.__dict__.update(state) def __str__(self): return self.prompt % self.__dict__ if __name__ == '__main__': prompt = Prompt('%(red)s%(cwd)s(%(nr)d) %(green)shallo daar:%(normal)s ') prompt.cwd = PromptFunc(os.getcwd) prompt.nr = 0 while 1: prompt.nr = prompt.nr + 1 print raw_input(prompt) -- groetjes, carel From robert.meegan at murl.com Thu Nov 11 14:26:56 1999 From: robert.meegan at murl.com (Robert Meegan) Date: Thu, 11 Nov 1999 19:26:56 GMT Subject: MySQLdb Module Question In-Reply-To: <19991111140723.A7271@dmcom.net> References: <19991111140723.A7271@dmcom.net> Message-ID: <19991111.19265600@robert.polytopic.com> Wayne - According to the MySQLdb documentation, all parameters *must* be supplied as keyword arguments. For example: host = 'localhost' user = 'wayne' password = 'secret' db = 'mydb' MySQLdb.connect(host = host, user = user, passwd = passwd, db = db) - Robert -- Robert Meegan Murl.com Making the Internet easier to use - Anyplace, Anytime, Free! >>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<< On 11/11/99, 1:07:24 PM, Wayne Topa wrote regarding MySQLdb Module Question: > As a Python newbie, I am having a problem getting the > MySQLdbmodule-0.1.1 working. I was able to use the > MySQLmodule-0.4.1 to access my DB's but thought that I should upgrade > to the newer module. > I can't connect to the Mysql database using > >>> import MySQLdb > >>> MySQLdb.connect('',user, passwd, Db) > Traceback (innermost last): > File "", line 1, in ? > TypeError: too many arguments; expected 1, got 5 > >From what I can understand from the Docs, MySQLdb.connect takes up to > 9 args, so the above error really confuses me, as does this. > >>> MySQLdb.connect() > Traceback (innermost last): > File "", line 1, in ? > File "/usr/lib/python1.5/site-packages/MySQLdb.py", line 259, in > __init__ > self.db = apply(connect, (), kwargs) > Maybe I don't have the correct Docs? > Could someone give me an example of some of the syntax of this module, > please? > TIA > Wayne > -- > According to my calculations the problem doesn't exist. > _______________________________________________________ > -- > http://www.python.org/mailman/listinfo/python-list From Gaetan_Corneau at baan.com Wed Nov 10 08:29:58 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Wed, 10 Nov 1999 08:29:58 -0500 Subject: .dll and .exe file version informaton Message-ID: <816010E2456BD111A48700805FBBE2EEFDF793@ex-quebec-u1.baan.com> > go-ahead-just-*try*-to-write-a-program-to-do-that-ly y'rs - tim If you really want to do it in a program, take a look at the following functions in the help: GetFileVersionInfo VerQueryValue QueryField You wil find all this stuff crappy, but it works. ______________________________________________________ Gaetan Corneau Software Developer (Quality Assurance Team) BaaN Supply Chain Solutions E-mail: Gaetan_Corneau at baan.com Compuserve: Gaetan_Corneau at compuserve.com ICQ Number: 7395494 Tel: (418) 266-8252 ______________________________________________________ "Profanity is the one language all programmers know best" From mlh at vier.idi.ntnu.no Tue Nov 23 20:50:10 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 24 Nov 1999 02:50:10 +0100 Subject: Visitor design pattern for python objects? References: <818512$ma9$1@nnrp1.deja.com> Message-ID: Nicky writes: > Is there a visitor type method that exists for all python objects? > Visitor methods would be useful to allow an apply type functionality > for objects. > E.g. > base python object has accept method > def accept(this,visitor): > visitor.visit(this) > The visitor than would be called back with the particular type of > object allowing the python object to delegate behavior to the visitor > object. Is this already implemented or is there an alternative way of > doing this? Wouldn't every subclass have its own accept-method to avoid using the superclass in the visit-method? (Maybe I have missed some coercion-rules here...) In that case, each accept-method may have a visit-method name of a different name, at least... (visitSimpleNode etc.) suspecting-that-i-really-did-misunderstand-that-coercion'ly yours, Magnus > > --Nicky -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From donn at oz.net Sun Nov 28 01:45:26 1999 From: donn at oz.net (Donn Cave) Date: 28 Nov 1999 06:45:26 GMT Subject: fcntl/ioctl and O_NONBLOCK References: <81ml5t$eer$0@216.39.151.169> <81p32a$m14$1@216.39.151.169> Message-ID: <81qj26$be6$0@216.39.151.169> Quoth hildeb at www.stahl.bau.tu-bs.de (Ralf Hildebrandt): ... | Fine. My problem here is the following: I start a program (plot) and | feed it with random input data until it crashes. Output is irrelevant | to me, I need only know if it crashes or exit()'s. | | On the shell: | % plot < t1 > /dev/null | Segmentation fault. | | In my Python program, though: The program ran for a while and never | returned. It didn't crash, it didn't exit, nothing. It just sat there | status "sleep" (displayed top). It didn't consume cpu-time, either. | | I figured I should empty fromchild (since the command above generates | 8MB of output) from time to time. Then I came across the select() | problem. | | This is also fixed now, but now the popen3 Object generates about 1 MB | of output (which I read using select() and read()), and then it STILL | doesn't return. No crash, no exit. And once more, in top it says | "sleep" once more. | Any ideas what's going on there? Yes - only a guess, but it bites everyone at least once when trying to talk to another process via pipes. After each write(), where your Python program is writing to the ``stdin'' of the plot process, add a flush(), i.e. stdin.flush(). Python file objects use C buffered I/O, and when output is a pipe device it's block buffered. This means your data doesn't go directly to the pipe, but into a buffer, and the pipe doesn't see it until a certain amount has accumulated. The flush() forces all the buffered data to be written immediately anyway. You can also control this by the buffer size parameter to the function that creates the file object, or just avoid a file object altogether and write directly to the pipe file descriptor. Donn Cave, donn at oz.net From johndoe0521 at my-deja.com Tue Nov 2 03:57:49 1999 From: johndoe0521 at my-deja.com (johndoe0521 at my-deja.com) Date: Tue, 02 Nov 1999 08:57:49 GMT Subject: About RedHat 6.1 install program Message-ID: <7vm92d$i1e$1@nnrp1.deja.com> I think this might be python's problem. I copy all the files from the CD of RedHat 6.1 to the harddisk, and make under /misc/src/anaconda, and some errors occur. Should it happen? And if I make some changes of the install source, how can I put the new install program into boot image? Thanks! Sent via Deja.com http://www.deja.com/ Before you buy. From mhammond at skippinet.com.au Tue Nov 2 16:41:37 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 3 Nov 1999 08:41:37 +1100 Subject: Assorted Questions regarding the future of Python... In-Reply-To: Message-ID: <004201bf257b$0b0c64f0$0501a8c0@bobcat> > From: python-list-admin at python.org > [mailto:python-list-admin at python.org]On Behalf Of Rob Hodges > > Unless something has changed dramatically since I last used windoze, > VB is not compiled (in the sense of native machine code) any more than > a frozen python program; rather, VB "executables" have a small header > of native code that launches the vbrunxxx.dll (interpreter) to run the > bytecode that makes up the rest of the file. Which is more or less Actually, things have changed. The latest version of VB has an option to compile to native machine code. This feature was created more from a "check-box marketting" POV than anything else (ie, Delphi did it, so VB decided it must too!) Mark. From cfelling at iae.nl Wed Nov 24 13:47:22 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 24 Nov 1999 19:47:22 +0100 Subject: automatic "lootjes trekken" [ was Re: automatic "lotjes trekken"] References: <81cqnv$2ip$1@vvs.superst.iae.nl> <81e3s2$j14$2@newshost.accu.uu.nl> Message-ID: <81hbrq$1fh$1@vvs.superst.iae.nl> Philip Lijnzaad wrote: > On 23 Nov 1999 13:12:34 GMT, > "Martijn" == Martijn Faassen writes: > Martijn> Not at all. everybody here speaks Dutch anyway. (it's a conspiracy!) > well, nearly everybody. The real word is 'lootjes', not 'lotjes'. Sorry, > couldn't resist. Well, the file at home *is* called lootjes-trekken.py, but somehow the spellling got corrupted:) OTOH, Dutch being a permissive language does allow for both variants! "lotjes" being the generic form, "lootjes" the special case (from a morphological point of view that is). But surely "lootjes trekken" is the common way to refer to what we do at this time of the year. -- groetjes, carel From mgm at unpkhswm04.bscc.bls.com Mon Nov 15 12:41:30 1999 From: mgm at unpkhswm04.bscc.bls.com (Mitchell Morris) Date: 15 Nov 1999 17:41:30 GMT Subject: Proposal: Python Info Collective References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> <80pe77$osc$1@hub.org> Message-ID: First, let me say you've done an excellent job ... working code is almost always preferable to another discussion item. Good for you for doing something I and many other have only complained about. Second, every unattributed quote from this point on is my opinion ... you should assume that every comment is followed by an IMHO or two until such time as your blood pressure recedes. In article <80pe77$osc$1 at hub.org>, T. Middletan wrote: [snip] > I hate CPAN. I have always hated CPAN. I will always >hate CPAN! All right, okay, in truth back when i was a PERL hacker i >thought CPAN was the greatest, very convenient, it's true. But after >the great light of Python descended upon me (actually it was kind of >thrust upon me as a "strong suggestion", at a time when i had no >interest in Python whatsoever --- thank D'Arcy of PyGreSQL fame!) my >perspective changed. I realised PERL was amazingly painful to code, >and even more painful to maintain --- why didn't i realise this >before? And as the scales fell from my eyes i realised that CPAN was >incredibly ugly and tedious to wade through, now that i thought about >it. A sea of README files, and ugly filenames. My personal take is that you never actually look at CPAN in a browser. The only useful interface to the Comprehensive Perl Archive is in CPAN.pm, which is by default installed on your machine. That way you can search for useful stuff without trying to figure out what (if any) disorganization scheme is in use: $ perl -MCPAN -e shell cpan shell -- CPAN exploration and modules installation (v1.50) ReadLine support enabled cpan> i /DNS/ Going to read /usr/local/CPAN/sources/authors/01mailrc.txt.gz CPAN: Compress::Zlib loaded ok Going to read /usr/local/CPAN/sources/modules/02packages.details.txt.gz Going to read /usr/local/CPAN/sources/modules/03modlist.data.gz Distribution M/MA/MATTBM/DNS-ZoneFile-0.92.tar.gz Distribution MFUHR/Net-DNS-0.12.tar.gz Module DNS::ZoneFile (M/MA/MATTBM/DNS-ZoneFile-0.92.tar.gz) Module DNS::ZoneFile::Record (M/MA/MATTBM/DNS-ZoneFile-0.92.tar.gz) ... cpan> readme DNS::ZoneFile ... cpan> wq DNS CPAN: CPAN::WAIT loaded ok Could not connect to the WAIT server at ls6.informatik.uni-dortmund.de port 1404 Trying your http proxy http://proxy.bscc.bls.com:8080/ Use of uninitialized value at /usr/local/lib/perl5/site_perl/5.005/aix/Net/ Cmd.pm line 308. Argument "" isn't numeric in eq at /usr/local/lib/perl5/site_perl/5.005/WAI T/Client.pm line 143. No greeting from server Use of uninitialized value at /usr/local/lib/perl5/site_perl/5.005/aix/Net/ Cmd.pm line 308. Argument "" isn't numeric in eq at /usr/local/lib/perl5/site_perl/5.005/WAI T/Client.pm line 112. No luck with your proxy either. Giving up No searching available! cpan> quit My longstanding complaints about CPAN.pm aside (mostly having to do with sooper-seekrit keyword searching capabilities), this is a phenomenal win. Having the ability to perform some non-trivial searching/cooking on the local site makes up for a great deal of ugliness module-naming-wise. It also helps mitigate the effects of a dog-slow proxy between us corporate cogs and the rest of the world and the general unwillingness of many tools to speak to a proxy server at all. The mechanism that CPAN.pm uses is a set of three compressed text files downloaded from CPAN that describe the current state of the archive. These files have a short lifetime (three days, if my memory serves me) before they're refreshed from the official source. Please note that I'm not volunteering to write this, given the other collections of things I'm having to ignore my family to get accomplished. I do promise, however, to admire the eventual resulting utility. I may even be able to submit patches thereunto. As an aside, the other thing about Perl that I like is perldoc. As much as I use lynx, it still sucks for searching the Python library reference. At some point I'll write ``pythondoc'' to extract the parts I care about, but until then I'll just keep kvetching. always-happy-to-see-other-people-working-ly y'rs +Mitchell -- Mitchell Morris I am Pentium of Borg. Division is futile. You will be approximated. From emuller at painewebber.com Sat Nov 13 17:10:02 1999 From: emuller at painewebber.com (emuller at painewebber.com) Date: Sat, 13 Nov 1999 22:10:02 GMT Subject: making the Python case to my dept. References: <9911051740130D.02530@william.jinsa.org> <801p3q$q01$1@nntp2.atl.mindspring.net> <3824723A.5DE35FE5@callware.com> <99110611340304.02970@quadra.teleo.net> Message-ID: <80knjo$57n$1@nnrp1.deja.com> I hit the hp e-speak site and everything was in java. I was just wondering where you got this news from? In article <99110611340304.02970 at quadra.teleo.net>, Patrick Phalen wrote: > [Ivan Van Laningham, on Sat, 06 Nov 1999]: > > :: Aahz Maruch wrote: > :: > I believe that there are more jobs for good Python programmers than > :: > people with the skills to fill them. My company is certainly having > :: > difficulties (jobs in Mountain View! ask me!), and having HP Cupertino > :: > advertising for 10-12 Python positions only increases the difficulty. > > :: I really hope that Aahz is correct. As most of you know, I'm stuck out > :: here in Utah, which is widely known to be significantly behind *any* > :: curve you want to name. > :: > :: If there's a curve coming to Utah, I sure hope it will be one with jobs > :: for Pythonistas, because there certainly aren't *any* here now. > > Look at it this way: the HP jobs all appear to center around developing > the E-speak technology. Python has been chosen as the official > scripting language for E-speak. Novell has publicly endorsed E-speak. If > Novell decides to builds Netware hooks into E-speak, they'll probably > hire rafts of Pythonistas in Utah. :) > > Sent via Deja.com http://www.deja.com/ Before you buy. From mlh at vier.idi.ntnu.no Fri Nov 5 09:18:46 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 05 Nov 1999 15:18:46 +0100 Subject: Drawing (directed) graphs References: <000a01bf2792$b83ff150$3acbd9c2@peridot.optichrome.com> Message-ID: "Adrian Eyre" writes: > > Good thing there is a platform independent Python graphics library! > > How can there be. Some OSs (Minix) don't support graphics at all... Maybe you should check out the URL given before whining Even on Minix you could easily generate jpegs, or postscript files or whatever with Piddle. If you can't run an X server or something, that only means that you can't see it... Or maybe you have a printer? -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From kbaldermann at entire-systems.com Tue Nov 30 08:57:40 1999 From: kbaldermann at entire-systems.com (Klaus Baldermann) Date: Tue, 30 Nov 1999 14:57:40 +0100 Subject: int -> IP References: <3diu2xnnh8.fsf@amarok.cnri.reston.va.us> <_AAZ3.478$vR2.44873@typ12.deja.bcandid.com> <3dg0y1nimy.fsf@amarok.cnri.reston.va.us> Message-ID: <3843d7ff@194.120.211.23> Andrew M. Kuchling wrote in message <3dg0y1nimy.fsf at amarok.cnri.reston.va.us>... >sbarron at twilight. (Scott Barron) writes: >> The string is a representation of the IP address as a long int in network >> byte order. For example 16777343 would be 127.0.0.1. So it can't be >def transip2 (ipstr): > # Pack into a 4-byte integer > s = struct.pack('!L', string.atol(ipstr) ) > > # Unpack as 4 bytes > L = struct.unpack('!4B', s) > > return `L[3]`+'.' + `L[2]`+'.'+`L[1]`+'.'+`L[0]` PMFJI a bit late, but the last line looks a bit tedious to type :-) packing it the other direction (little endian) enables us using string.join: >>> from struct import pack, unpack >>> from string import atol, join >>> def transip3(long): return join(map(str,unpack('4B', pack('>> transip3('16777343') '127.0.0.1' >>> transip3('2227275982') '206.136.193.132' >>> map-filter-and-reduce-remind-me-of-APL-ly yours Klaus From fredrik at pythonware.com Tue Nov 2 04:47:39 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 2 Nov 1999 10:47:39 +0100 Subject: Assorted Questions regarding the future of Python... References: <6D8A17398E28D3119F860090274DD7DB49833A@pces.cadlab.it> Message-ID: <006201bf2517$50edf1f0$f29b12c2@secret.pythonware.com> Alessandro Bottoni wrote: > So, I wonder: (just some quick answers here. others will surely add to this). > 1) How about a Python compiler? Does anybody is working on such a project? I > saw a lot of messages regarding this topic in the past, but which is the > current status? well, python has a compiler (which converts source code to byte codes). but I suppose you mean "compile to machine code," for which the answer can be summarized as "it's a hard pro- blem, but people are working on it". check the news- group archives for more stories (look for things like python2c, viperi, etc.). and check jpython, of course. > 2) How about a Python Virtual Machine, "a la Java", as a possible > alternative to a real compiler? Is there anything like that? Is anybody > working on it? well, python has a virtual machine (PYC files contain bytecodes, not compressed source code. just like Java class files). as far as I know, there are no visible projects working on faster ways to execute that code, but that doesn't mean that they don't exist ;-) (and don't forget jpython, which can convert python sources to Java class files...) > 3) How about using the "Template & Wizard" approach with Python, inside IDLE > or another IDE? Does anybody is working on such a project? Guido, do you > think to go in this direction with IDLE? fwiw, we're working on something like this for future versions of pythonworks. not your usual dumb code generator stuff, though. more info some other day. > 4) How about a "standard" installation tool? Is there anything like > InstallShield or "VB Package & Deployement tool" in our world? > Does anybody is working on such a project? here's one: http://starship.python.net/crew/gmcm/install.html (and pythonworks includes similar tools, of course) From jima at aspectdv.com Mon Nov 15 15:21:26 1999 From: jima at aspectdv.com (Jim Althoff) Date: Mon, 15 Nov 1999 12:21:26 -0800 Subject: method overriding trick In-Reply-To: References: <14378.62498.649973.150075@bitdiddle.cnri.reston.va.us> Message-ID: <4.2.0.58.19991115122013.00b0e540@mail.aspectdv.com> I've been doing the exact same thing only using _Super instead of _Parent. I have found it to be a helpful convention. Jim At 12:58 AM 11/13/99 -0800, Phil Mayes wrote: >Jeremy Hylton wrote in message ><14378.62498.649973.150075 at bitdiddle.cnri.reston.va.us>... > >Overriding methods of a base class is a little clunky in Python. You > >need to explicitly name the base class that implements the method, and > >you call its as an unbound method, passing self as the first argument. > >Example: Base.aMethod(self, arg) > > >and suggested using > > >class Derived1(Base): > > super_aMethod = Base.aMethod > > > > def aMethod(self, arg): > > return self.super_aMethod(arg) + 1 > > > >... > >It doesn't solve the must-name-the-base-class problem, but it helps > >manage it better. If you keep the override assignments at the top of > >the class statement, then you only have one place to look in each > >class when the inheritance hierarchy changes. > > >I use a method that doesn't remove the clunkiness, but localises the >hierarchy to one line: > >_Parent = basedlg.BaseDlg >class AddressDlg(_Parent): > def __init__(self, param): > self.local = param > _Parent.__init__(self, 2345) > >By using the same name "_Parent" in all modules, less thinking is needed, >and cut'n'paste coding (what, me?) works better too. >-- >Phil Mayes pmayes AT olivebr DOT com >Olive Branch Software - home of Arranger >http://www.olivebr.com/ > > > > >-- >http://www.python.org/mailman/listinfo/python-list From x at x.x Wed Nov 24 17:20:36 1999 From: x at x.x (Eric Jacobs) Date: Wed, 24 Nov 1999 17:20:36 -0500 Subject: Python complaints References: <81g8po$reo$1@mach.vub.ac.be> <002901bf3663$e4b62df0$11e9efc2@normik.dk> Message-ID: <383C64B4.56CF6AF9@x.x> maxm wrote: > > > Mark Carroll (markc at chiark.greenend.org.uk) wrote: > > [snip] > > : Basically, I'd be really interested to learn: what _don't_ people like > > : about Python? > > [snip] > > I miss deeply the ability to write: > > i += 3 > Text += "Some new text\n" There's a pretty good reason for this one, I think. The two statements: Text += "Some new text\n" List.append(9) look sort of analogous. Both seem to be taking an object and performing a method on it. But strings are immutable; you can't perform any method on it to change the string. The syntax Text = Text + "Some new text\n" makes it clear that we're creating a new object out of an old one, and assigning it to the variable "Text". Sure, you could interpret += to mean the same thing, but I think it would be less clear to those trying to learn the language. It's critical to get people out of C mindsets in order to be able to understand what people mean when they say "everything is a reference." From gmcm at hypernet.com Mon Nov 29 13:06:33 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Mon, 29 Nov 1999 13:06:33 -0500 Subject: performance of tuple-less Python? In-Reply-To: References: "Greg Wilson"'s message of "Mon, 29 Nov 1999 11:29:30 -0500" Message-ID: <1268223702-30481186@hypernet.com> Fran?ois Pinard wrote: > "Greg Wilson" writes: > > > [...] the use of tuples (which I believe are conceptually > > redundant) [...] > > Tuples may be used to index within dictionaries, and I find this > feature very useful. Lists may not. I do not know the > implementation details, but would be tempted to have the > prejudice (:-) that using lists to index would imply some severe > performance penalty. I'm guessing that not being able to find something you stuck in the dictionary qualifies as a performance penalty ;-). To spell it out: 1) hash based on id(list_object): d = {[1] = 'x'} d[[1]] -> KeyError 2) hash based on value: lst = [1] d[lst] = 'x' lst.append(2) d[lst] -> KeyError - Gordon From skaller at maxtal.com.au Tue Nov 30 08:38:45 1999 From: skaller at maxtal.com.au (skaller) Date: Wed, 01 Dec 1999 00:38:45 +1100 Subject: Python Type-Inference based LINT.. (pylint.py) References: <19991121180043.B3184@teapot.egroups.net> <81e2r7$j14$1@newshost.accu.uu.nl> <383BC3D2.98BCD1FF@compaq.com> <81ktpm$33g$1@newshost.accu.uu.nl> Message-ID: <3843D365.8B530226@maxtal.com.au> Martijn Faassen wrote: >It's hard to say, actually, because if it > *has* to generate error messages like the kind you mentioned, optional > type annotations may not even be worth it.. I think they're worth it ... the main problem is syntax. It isn't clear what syntax to use to specify an annotation, and it isn't clear how to name the types. The 'natural' notation: x : int = 1 can be used in function parameter lists, but not so easily for variables (since ':' clashes with it's other use as a suite introducer). It's also not clear that: x : PyInstance = SomeClass() is useful, the class of x is more interesting. -- John Skaller, mailto:skaller at maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia homepage: http://www.maxtal.com.au/~skaller voice: 61-2-9660-0850 From mhammond at skippinet.com.au Tue Nov 2 19:07:03 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 3 Nov 1999 11:07:03 +1100 Subject: Reading .lnk files In-Reply-To: <004301bf2583$b47a7150$0501a8c0@bobcat> Message-ID: <004801bf258f$5c19d0d0$0501a8c0@bobcat> Ivan has mailed me that this does not work for him (dies with a big crash!). If anyone else has a spare moment, could you please try this code and see if it works? Whether it does or not, please also include info on the OS you tried it on. Please mail me personally with this info, and I will summarize back to the list. Thanks, Mark. > -----Original Message----- > From: python-list-admin at python.org > [mailto:python-list-admin at python.org]On Behalf Of Mark Hammond > Sent: Wednesday, 3 November 1999 9:44 > To: 'Ivan Van Laningham'; 'Python Mailing List' > Subject: RE: Reading .lnk files > > > Sure is. For more details, see the COM help file on PyIShellLink. > > Mark. > > # DumpShortcut.py > # A demo of how to dump a shortcut using Python. > > # This code dumps the shortcut specificed as sys.argv[1] > > from win32com.shell import shell > import pythoncom > > def DumpIt(fileName): > # Get the shell interface. > sh = pythoncom.CoCreateInstance(shell.CLSID_ShellLink, None, \ > pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink) > > # Get an IPersist interface > persist = sh.QueryInterface(pythoncom.IID_IPersistFile) > > persist.Load(fileName) > > # Get the data > print "Path name:", sh.GetPath(shell.SLGP_SHORTPATH)[0] > print "Args:", sh.GetArguments() > print "Description:", sh.GetDescription() > print "Working directory:", sh.GetWorkingDirectory() > > if __name__=='__main__': > import sys > DumpIt(sys.argv[1]) > > # demo of usage: > C:\>DumpShortcut.py IDLE.lnk > Path name: L:\src\PYTHON~1.2\PCbuild\pythonw.exe > Args: l:\src\python-cvs\tools\idle\idle.pyw > Description: > Working directory: L:\src\python-cvs\tools\idle > > > -- > http://www.python.org/mailman/listinfo/python-list > From tseaver at starbase.neosoft.com Tue Nov 16 10:52:25 1999 From: tseaver at starbase.neosoft.com (Tres Seaver) Date: 16 Nov 1999 15:52:25 GMT Subject: Integrate Phyton in a (Delphi) App .... References: <383157E6.48E8@rbg.informatik.tu-darmstadt.de> Message-ID: <8688A5AB30F13563.5711B9AB415CE2CD.6D202BACED783D20@lp.airnews.net> In article <383157E6.48E8 at rbg.informatik.tu-darmstadt.de>, Andreas Koch wrote: >Hi , i plan writing a huge app , in Delphi (Win95). >It will have lots of classes for the various game >objects , and i currently think about writing this >class tree in Phython , to allow users changing it >and adding new stuff. > >(for short , i call the delphi app winapp ) > >So : >1-How much work is it to integrate Phyton into a win app ? > The app will hold the complete framework for user > interface , movement , graphics , the phyton classes need to > call and be called by my procedures >2-How fast is Phyton ? Speed is essential , i will have > at least 100 objects per frame that need to be called and > (usually) call my winapps "drawtile" function. >3-Is it possible to restrict certain program parts > from using certain code parts ? For example , don't > allow while-loops in a user definable module ? >4-Is it possible for my winapp to execute some of > the phyton scripts in single step mode ? > > thanks , Andreas You need to check out the Python for Delphi components, at http://www.multimania.com/~marat/delphi/python.htm. Perhaps also look at my "Snake in the Temple" presentation, http://www.palladion.com/HADP_Jan99 Best, Tres. -- --------------------------------------------------------------- Tres Seaver tseaver at palladion.com 713-523-6582 Palladion Software http://www.palladion.com From fredrik at pythonware.com Fri Nov 19 08:36:18 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 19 Nov 1999 14:36:18 +0100 Subject: Python Chinese References: <19991119121544.5006.qmail@hotmail.com> Message-ID: <002001bf3293$10a89c10$f29b12c2@secret.pythonware.com> Ulf Engstr?m wrote: > Is there any way to use Python with Chinese and other asian chars? > If not, are there any plans to make this compability? python's string type is 8-bit clean and doesn't care about encodings (you have to keep track of that yourself). and yes, python 1.6 will grow unicode support, which also includes support for various codecs. From maytagrepairman at yahoo.com Tue Nov 16 16:42:51 1999 From: maytagrepairman at yahoo.com (maytagrepairman at yahoo.com) Date: Tue, 16 Nov 1999 21:42:51 GMT Subject: Need help dealing with spaces in NT paths. References: <80pr76$jq5$1@nnrp1.deja.com> <11f733ec.96958819@usw-ex0101-007.remarq.com> Message-ID: <80sj4q$l7t$1@nnrp1.deja.com> Ok. This works so far, but to complicate things further I need also to pass an argument to the command. Both the command and the argument are full path names with spaces in them. If I type something like this at the DOS prompt: "my_full_path_cmd_with_spaces" "my_full_path_arg_with_spaces" it works. But if I try to do an equivalent such as this in Python # this next statement is to see what is passed to os.system() print ('\"%s\" \"%s\"' % (cmd,arg)) # this next statement is the call to os.system() os.system('\"%s\" \"%s\"' % (cmd,arg)) I get The name specified is not recognized as an internal or extenal command, operable program or batch file. Other variations I've tried give the same results. Any thoughts on this one? In article , piet at cs.uu.nl wrote: > >>>>> wheineman (W) writes: > > W> Put quotes around the complete path. For example: > W> myExec = "C:\\Program Files\\Trash Can\\compactor.exe" > > You probably mean: > myExec = "\"C:\\Program Files\\Trash Can\\compactor.exe\"" > > or easier: > myExec = r'"C:\Program Files\Trash Can\compactor.exe"' > -- > Piet van Oostrum > URL: http://www.cs.uu.nl/~piet [PGP] > Private email: Piet.van.Oostrum at gironet.nl > Sent via Deja.com http://www.deja.com/ Before you buy. From b2blink at hotmail.com Wed Nov 24 18:11:20 1999 From: b2blink at hotmail.com (Ulf Engstrøm) Date: Wed, 24 Nov 1999 18:11:20 CET Subject: SMTP? Message-ID: <19991124171120.1623.qmail@hotmail.com> I've build a little mailthingy based on the 11.9.2 SMTP Example from Python Library Reference but when I use it I'll get an empty mail with no sender and no msg, eventhough I don't get any errors whatsoever...Do I have to change something with the headers? If yes, what? Using the example as is (with the change of the servername) doesn't work, it'll come out as: send: 'ehlo WKS0002.DEVELOPMENT.b2b-link.com\015\012' reply: '250-nebb.no Hello WKS0002.DEVELOPMENT.b2b-link.com, ESMTP hello!\015\012 ' reply: '250-VRFY\015\012' reply: '250-EXPN\015\012' reply: '250-ETRN\015\012' reply: '250 SIZE\015\012' reply: retcode (250); Msg: nebb.no Hello WKS0002.DEVELOPMENT.b2b-link.com, ESMTP hello! VRFY EXPN ETRN SIZE send: 'mail FROM: size=10\015\012' reply: '250 , Sender accepted\015\012' reply: retcode (250); Msg: , Sender accepted send: 'rcpt TO:\015\012' reply: '250 , Recipient ok\015\012' reply: retcode (250); Msg: , Recipient ok send: 'data \015\012' reply: '354 Enter mail, end with .\015\012' reply: retcode (354); Msg: Enter mail, end with . data: (354, 'Enter mail, end with .') send: 'Small msg\015\012' send: '\015\012.\015\012' reply: '250 Ok, message saved\015\012' reply: retcode (250); Msg: Ok, message saved data: (250, 'Ok, message saved') send: 'quit \015\012' reply: '221 See ya in cyberspace\015\012' reply: retcode (221); Msg: See ya in cyberspace Thanx a lot for all previous help :) Best regards Ulf Engstr?m http://www.b2b-link.com ulf.engstrom at b2b-link.com ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com From g_will at cyberus.ca Mon Nov 8 09:02:47 1999 From: g_will at cyberus.ca (Gordon Williams) Date: Mon, 08 Nov 1999 14:02:47 GMT Subject: Fastest GUI toolkit? Message-ID: <01bf29f1$cbfd5e60$5a41c3d1@Cyberus.cyberus.ca> I have an application where I need to draw many lines fast and repeatedly (an oscilloscope). The number of lines ranges from about 1000 to 16000. Currently I have the application using Tkinter but I am finding it too slow. I am currently using W95 as an os, but would prefer to make the code portable across other os if possible. Right now speed is more important than portability so I would be willing to give this up. I would like to draw 1000 lines in 1/10 of a second on a P166 machine. (Am I way off the mark??) I was hoping that someone would have tried different packages and could give me pointers in the right direction. Thanks, Gordon Williams From cgw at fnal.gov Thu Nov 25 09:33:32 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Thu, 25 Nov 1999 15:33:32 +0100 (MET) Subject: decompress a bunch of .gz files In-Reply-To: <000501bf374e$116bafb0$3acbd9c2@peridot.optichrome.com> References: <81jc8i$ilp$1@nnrp1.deja.com> <000501bf374e$116bafb0$3acbd9c2@peridot.optichrome.com> Message-ID: <14397.18620.87516.687622@gargle.gargle.HOWL> Adrian Eyre writes: > > I'm searching for a way to decompress all .gz > > files in a directory automatically. > > Unix: > > #!/bin/sh > for file in *.gz; do gunzip $file; done Or just: gunzip *.gz From greg.ewing at compaq.com Wed Nov 3 04:24:34 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Wed, 03 Nov 1999 22:24:34 +1300 Subject: tkinter grid() question References: <381F2D32.9E3A15CF@research.att.com> Message-ID: <381FFF52.707400E5@compaq.com> "Garrett G. Hodgson" wrote: > > in the code below, i create a Text entry area with a Scrollbar. > i want this pair to always use all of the available space. > but when i resize the window, the stay the same size, neither > expanding or shrinking. You have to do two things: make the Text widget sticky on all sides, and configure the weight of the row and column containing the Text widget so that it sucks up all the extra space. It's simplest if the widgets only take up one cell of the grid each, so I'll show you how to do it that way: self.body.grid(row = 0, column = 0, sticky = N+S+E+W) scrollbar.grid(row = 0, column = 1, sticky = N+S) self.rowconfigure(0, weight = 1) self.columnconfigure(0, weight = 1) Since you're not putting anything else in the frame in the code you showed, there's really no reason to have anything spanning more than one row or column. If you want to control the initial size of the Text widget, use the width and height options when you create it. If you're going to put other widgets in the frame as well, you'll have to be careful how you configure the grid so that resizing the text widget properly doesn't have undesirable side effects on the layout of the other widgets. Essentially, you'll have to pick one of the columns spanned by the text widget and configure it's weight to be 1, but not one that has another widget in it that you don't want stretched as well. Or, instead of trying to put everything in one frame, you may find it easier to use more subframes so that you can control their layouts independently. I can't give any more specific advice without knowing more about what you're trying to do. Hope that helps, Greg From gmarry at erols.com Tue Nov 30 16:16:17 1999 From: gmarry at erols.com (Garry Hodgson) Date: Tue, 30 Nov 1999 16:16:17 -0500 Subject: bug in tkinter canvas event handling? References: <38429BB0.1BFFB54B@sage.att.com> <3843C0A0.94990E64@home.com> Message-ID: <38443EA1.923861B6@erols.com> Doug Hellmann wrote: > This behavior surprised me at first, too. It's as though the first > canvas object is grabbing the pointer so that all events go to it. I > got around the problem by looking for the x,y coords of the release > event and then finding the object(s) under that point on the canvas. well, some earlier code i had did its own hit detection. but it seemed silly to do it myself when the canvas oughta do it for me. i've yet to peruse the source, per Fredrik's suggestion, so i don't know whether Tk considers this bug or feature. i know how i'd vote. -- Garry Hodgson And it's just a box of rain Software Innovation Services I don't know who put it there AT&T Labs Believe it if you need it garry at sage.att.com Or leave it if you dare From newsreporter at rciinfo.com Mon Nov 29 03:02:59 1999 From: newsreporter at rciinfo.com (News Reporter) Date: Mon, 29 Nov 1999 3:02:59 PM -0500 Subject: Finding Good Human Resource Candidates Message-ID: <199911291502.YND4953@rciinfo.com> The competition for finding good Human Resource candidates if fierce! However, there is an edge - and we want you to have it FREE! BestJobsUSA.com will run all of your Human Resource category positions free. No catch. Nothing to buy. No obligation whatsoever. At BestJobsUSA.com, we recognize our business is dependent upon getting results for our Human Resource clients. This is just another way to keep you aware of our services. E-mail your Human Resource category positions to us at: mailto:RCI at BestJobsUSA.com. We'll have it up and running within 48 hours. If this isn't your function please forward on to the appropriate person. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- We also want to make you aware of our WebRunner resume retrieval technology. WebRunner will deliver resumes that meet your specific job criteria quickly and cost effectively. This service is available now for the low cost of $400.00 per search. Simply provide us with the with job description, or key words (competitors you would like to target ) and we do all the work. For full information, contact Gregg Lowenstein at mailto:glowenstein at rcimedia.com or telephone at (561)686-6800, ext. 314 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- This information has been e-mailed to keep you apprised of recruitment-advertising opportunities. If this information is not suitable for your area of responsibility or if you want to be removed from our distribution list, please e-mail mailto:nothankyou at rcimedia.com?subject=HR From gmcm at hypernet.com Wed Nov 24 15:01:34 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 24 Nov 1999 15:01:34 -0500 Subject: whitespace.py module In-Reply-To: Message-ID: <1268648802-4911011@hypernet.com> Rajesh Vaidheeswarran writes: > > I'm new to the python language, and the newsgroup. So, if this > newsgroup is not appropriate for this type of posting, please > pardon my ignorance and notify me. > > I have written up a module called `whitespace.py' available at > > > and a sample program `whitespace' which uses this module, also > available at the same URL. > > The module can be used to check a given file for whitespace > problems as defined in the module's documentation (also available > as a separate text document at > . > > Please feel free use these, and also to send in your comments on > either of these. I had a quick look. You are taking the opposite approach from the recommended way of dealing with tabs. The recommended approach is to set your editor to always insert spaces. That way, someone else reading your code will always see sane indentation, no matter how they have configured their editor (or what the editor assumes). You'll also make email clients happy (since they almost always turn leading tabs into spaces). It's also acceptable to use only tabs for indentation. > I would like to know how to submit a module for inclusion into > the standard python distribution, and would appreciate any > pointers in that direction. There's already a whitespace troubleshooter in the std lib - tabnanny.py (check out python -t ). You can transform any legal style of indentation to any other legal style with tabcleaner.py in the System directory of the contrib ftp site. - Gordon From Jan.Walter at t-online.de Mon Nov 1 14:15:32 1999 From: Jan.Walter at t-online.de (Jan Walter) Date: Mon, 01 Nov 1999 20:15:32 +0100 Subject: ANNOUNCE: Free Python Scripts For Blender (export to free renderers) Message-ID: <381DE6D4.6867@t-online.de> Hi, At http://www.q-bus.de/Blender you can find a web page from which you can download several Python scripts to export to following renderers within Blender (http://www.blender.nl): Panorama (http://www.gnu.org/software/panorama/panorama.html) Povray (http://www.povray.org) Radiance (http://radsite.lbl.gov/radiance/HOME.html) RenderMan (http://www.renderman.org, http://www.bmrt.org) I try to compare this renderers and any comments are welcome ... Cheers, Jan From ivanlan at callware.com Wed Nov 10 16:54:24 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Wed, 10 Nov 1999 14:54:24 -0700 Subject: Popup menus in Tkinter References: <199911081726.SAA25412@axil.hvision.nl> <80796f$f9h$1@nnrp1.deja.com> Message-ID: <3829E990.F233BE08@callware.com> Hi All-- Dieter Maurer wrote: > > dkaznadzey at my-deja.com writes on Mon, 08 Nov 1999 19:44:16 GMT: > > What would be a good source of information on tk commands > > available through Tkinter? > I use "tclhelp", a program with comes with "tclX". > It is a grafical documentation program for "tcl", "tclX" > and "tk". Alternatively, you can use the online tcl/tk > documentation (e.g. from scriptics). > > These, of cause, document "tcl/tk" not "Tkinter". > However, the mapping from "tk" to "Tkinter" is quite straight forward: > John Grayson's forthcoming book on Tkinter programming with Python has a good section on the mappings. Lots of other good stuff, too. -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours ---------------------------------------------- From aa8vb at yahoo.com Tue Nov 2 07:22:02 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Tue, 2 Nov 1999 07:22:02 -0500 Subject: Tkinter canvas blow-up: bbox(ALL) == None In-Reply-To: <013c01bf2510$57457f20$f29b12c2@secret.pythonware.com> References: <19991101102103.A134035786@vislab.epa.gov> <013c01bf2510$57457f20$f29b12c2@secret.pythonware.com> Message-ID: <19991102072202.A134170008@vislab.epa.gov> Fredrik Lundh: |Randall Hopper wrote: |> Apparently if the bounds of the items in a Tk canvas widget exceed |> MAXINT, bbox(ALL) returns None. The attached Python script demonstrates |> this. |> |> Intuitively it seems like this is a bug since the contents of the |> canvas are maintained in floating point; integer bounds shouldn't be |> involved, should they? |> |> Is this a Tk bug or a Tkinter bug? | |both. | |Tkinter uses _getints instead of _getdoubles to |convert the bounding box to a tuple... | |...but the reason you get None instead of an over- |flow error is that Tk returns an empty string in this |case (at least in 8.0.5). Ok, thanks for the info. So do you know if Tk uses ints internally as well, or is its returning the empty string an artifact of how it was fed by Tkinter? Randall -- Randall Hopper aa8vb at yahoo.com From ionel at psy.uva.nl Sat Nov 13 16:56:35 1999 From: ionel at psy.uva.nl (Ionel Simionescu) Date: Sat, 13 Nov 1999 22:56:35 +0100 Subject: Max Size of Array when using Numeric.py References: <38286054.C8612EB5@edf.fr> Message-ID: <80kmnv$dmd@mail.psy.uva.nl> Paul F. Dubois wrote in message news:nygX3.2040$V4.64389 at news1.frmt1.sfba.home.com... | There is no intrinsic limit on the size of NumPy arrays. You just ran out of | memory, I guess. "just run out of memory" will happen when your memory manager cannot allocate that much space of *contiguous* memory. This can have puzzling effects when your heap is badly fragmented. | You could write a C extension that created the array and did the reading of | each element and placing it into the array so that you only had the one | copy. While I see that arrays defined by extension modules can be guaranteed to remain unique, the same can be also assured with Numeric, because arrays can be written "in place". However, when you need to change the type of an array, you must duplicate it anyway, even if your arrays are defined in extensions. Helka FOLCH wrote in message news:38286054.C8612EB5 at edf.fr... > I've tried to create an array object whose shape is (5500,200) but I get > a memory error. Is there a maximum size for array objects? > > Maybe there's a better way of creating the array than what I did : > My program reads the array which is in another format from a file. It > transforms the array to the right format and holds it in a variable(mv) > as a string. Then I just do: > > m = array(eval(mv),Float) If you afford to use an to get the actual values, then your string, , should be really large, and it may be it the one which eats up your memory, rather than the arrays. Ways to really improve the speed of reading & converting the data can rely on the struct standard module. However, those are really useful when you must tackle heterogeneous data series (i.e. data structures). For homogeneous data series you can use Numeric's own methods: a = fromstring(data, typecode) and data = a.tostring() , where data is a binary string you can read from/write into a file, or, even better, store in a database. ionel From Gaetan_Corneau at baan.com Wed Nov 3 11:53:31 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Wed, 3 Nov 1999 11:53:31 -0500 Subject: __LINE__? Message-ID: <816010E2456BD111A48700805FBBE2EEFDF750@ex-quebec-u1.baan.com> Is there an equivalent of the C __LINE__ macro in Python to get the currentline number? Obviously it is available, since exceptions report it. Sorry if this is FAQ, I can't find it. Thanks, ______________________________________________________ Gaetan Corneau Software Developer (Quality Assurance Team) BaaN Supply Chain Solutions E-mail: Gaetan_Corneau at baan.com Compuserve: Gaetan_Corneau at compuserve.com ICQ Number: 7395494 Tel: (418) 266-8252 ______________________________________________________ "Profanity is the one language all programmers know best" From TUpchurch at romac.com Wed Nov 10 14:43:44 1999 From: TUpchurch at romac.com (Upchurch, Tory) Date: Wed, 10 Nov 1999 14:43:44 -0500 Subject: Python Job opportunity Message-ID: I am working with a company that is a leading Internet destination dedicated to empowering consumer decision-making through the exchange of user-generated information, knowledge and opinion. The site features more than 600,000 people-powered ratings of more than 25,000 products, services and topics in nearly 800 categories, as well as related online discussion forums. This company is based in Austin,TX. This is a full time permanent position with a very good pre-IPO company. This is a great opportunity for someone that wants to live in Austin,TX. If you are interested in this position, please send me a copy of your resume to tupchurch at romac.com. This position would be responsible for working with a team to define requirements and support products. You will also be responsible for designing and coding to specifications. The requirements are as follows: Intermediate Python programming ability CGI development Desired skills: Expert Python skills Knowledge of RDB/SQL Web based advertising system experience Customer management experience Tory Upchurch Romac International Inc. Recruiter IT Division Direct (512) 231-3604 Toll Free (888) 548-6514 Fax (512) 345-7736 tupchurch at romac.com http://www.romac.com From jcw at equi4.com Fri Nov 5 06:45:17 1999 From: jcw at equi4.com (Jean-Claude Wippler) Date: Fri, 05 Nov 1999 12:45:17 +0100 Subject: ANN: MkWrap 0.9 embedded database Message-ID: <3822C348.58034399@equi4.com> This is an announcement of a new release of MkWrap for Python at: http://www.equi4.com/metakit/python.html Ready-to-run downloads for Solaris, Linux, Windows, and Mac are at: ftp://ftp.equi4.com/pub/mk/ To give you an impression of what MkWrap does, here's a Python script: import MkWrap db = MkWrap.Storage('phonebook.dat',1) vw = db.view("persons") vw = vw.Select(name='John').Sort(vw.date) for i in vw: print "Found:", i.name, i.phone, i.date MetaKit packs a lot of power in a little package. Some facts: - Failsafe: transacted commit, for data and structure changes - Efficient: compact auto-sizing storage, high scanning speeds - Flexible: select/sort on any field, relational / set operators - Adaptive: restructure on-the-fly, use with C++, Python, and Tcl - Portable: the same file can be used on Unix, Windows, and Mac - Embeddable: can link statically for stand-alone executables - Tiny: on Windows, the no-install Python extension DLL is 170 Kb MetaKit is free for non-commercial use, there's a royalty-free source license for commercial use. The non-nonsense details are described at: http://www.equi4.com/metakit/licensing.html Changes since 0.4 - MkWrap 0.9 is based on MetaKit 1.9d, and adds: * stability, this version has taken quite a beating * a file interface, read/write/pickle to/from memo fields * a wrapper around any sequence, so you can join/groupby anything * completely reorganized core-, platform-, and language-distributions * smaller, faster, some documentation, and some sample scripts -- Jean-Claude ________________________________________________________________________ Jean-Claude Wippler MetaKit home page - http://www.equi4.com/metakit/ Equi4 Software "Portable database software for a changing world" From smst at quantisci.co.uk Tue Nov 16 06:06:59 1999 From: smst at quantisci.co.uk (Steve M S Tregidgo) Date: Tue, 16 Nov 1999 11:06:59 GMT Subject: Memory not being released? Message-ID: <199911161106.LAA13046@cobweb.quantisci.co.uk> We have glibc 2.0.7 -- does anybody know if the problem with v2.1.1 mentioned below exists with v2.0.7? mickut.at.iki.dot.fi at python.org wrote: > > I had similar problem just a while ago, and Cyclops helped a lot. > But it didn't solve the whole problem, as it was not python's > fault, but a Linux library glibc was functioning improperly. If you > are running RedHat 6.0 and/or have glibc version 2.1.1, you should > upgrade asap. Upgrading to 2.1.2 the bloating dissappeared and > everything has worked nicely ever since. > > Antti Kuntsi > > -- > ______________________________________________________________ > |O| ---------------------------------------------------------- > | | |Twisted mind? No, just bent in several strategic places.| > `\| |___________________________________mickut at iki.fi/mickut/| > > -- > http://www.python.org/mailman/listinfo/python-list Cheers, Steve From c.evans at clear.net.nz Sat Nov 27 16:45:30 1999 From: c.evans at clear.net.nz (Carey Evans) Date: 28 Nov 1999 10:45:30 +1300 Subject: SMTP - again ;) References: <19991126080017.26482.qmail@hotmail.com> Message-ID: <874se7a9s5.fsf@psyche.evansnet> "Ulf Engstr?m" writes: > Anyway, something else came up, when I enter a name in the header: > "To: Ulf Engstr?m" the mail gets to the dest as: > > To: Ulf.Engstr?m at mb04.swip.net The address in the To: field is required to be a real address (with an @ in it), so most mail servers will rewrite it when they receive it. You might get what you want if you put the name in a comment: To: (Ulf Engstr?m) -- Carey Evans http://home.clear.net.nz/pages/c.evans/ "This is where your sanity gives in..." From kcazabon at home.com Mon Nov 15 23:35:06 1999 From: kcazabon at home.com (Kevin Cazabon) Date: Tue, 16 Nov 1999 04:35:06 GMT Subject: win32api... another question: GetEnvironmentVariable("PATH") References: <01BF2F61.1D2B8DB0@exchange1.geometria.hu> Message-ID: <_95Y3.69699$Rx2.821068@news1.rdc1.bc.home.com> Cool... at least I know that I'm not loosing my mind. q:] I'll try other routes for now. Is there any way to use the Win32 API "SetEnvironmentVariable" function as well? I want to update some system stuff on the fly... BTW, it doesn't cause any errors, just returns None. Kevin. P.S.: the rest of the win32 package is pretty slick... thanks! q:] Mark Hammond wrote in message news:OL%X3.4846$Xo.25269 at news-server.bigpond.net.au... > > Kevin Cazabon wrote in message ... > >Interesting... it doesn't work on Win98 for me (The exact statement > >below...). > > Eeek - you are correct - it doesnt :-( > > win32api implements this using "GetEnvironmentVariableW()", and returns a > Unicode string. This doesnt work on 95/98. I dont know what I was thinking > :-( > > I think I should drop this back to an Ascii version, and return a normal > PyString object. That shouldnt break any code as Unicode objects are pretty > useless now and need to be "str()"d to be useful. > > Damn... > > Mark. > > > From tim_one at email.msn.com Thu Nov 25 05:56:10 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 25 Nov 1999 05:56:10 -0500 Subject: Python complaints In-Reply-To: <81itrf$eqc$1@newshost.accu.uu.nl> Message-ID: <000401bf3733$af411100$be2d153f@tim> [Aahz Maruch] > ... > In fact, I wish that Guido would disallow > > if foo : bar() > > and force it to always be > > if foo : > bar() He would be more likely to force it to be if foo: # he hates spaces before colons bar() # he hates indents smaller than 4 [Martijn Faassen] > Agreed. The Zope sources are full of the former and that idiom > doesn't help me read them particularly. > > Perhaps 1.6 could introduce this requirement, and some scripts to > convert existing code. The only use I can see for the former is to > write nice obfuscated one liners. :) There are a few things in the language primarily for convenience in interactive mode. This is one of them. Being Dutch, Guido grossly overestimated the common sense of his American audience . my-people-invented-bad-taste-and-proud-of-it-ly y'rs - tim From haskin at ptway.com Mon Nov 8 16:52:38 1999 From: haskin at ptway.com (Brian Haskin) Date: Mon, 08 Nov 1999 16:52:38 -0500 Subject: Stackless python progress? Message-ID: <38274626.5D8C1EC2@ptway.com> Just wondering if the work on stackless python is still progressing and if it looks like it will be integrated into the regular distribution in the foreseeable future? also has there been any work on combining 'microthreading' and the stackless stuff? Brian Haskin From wtanksle at hawking.armored.net Thu Nov 4 16:01:58 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 4 Nov 1999 21:01:58 GMT Subject: Some more Ruby observations (Re: Comparison between Python and "Ruby") References: <3819BCDA.AC4FD4CA@strs.co.uk> <87k8o2x67f.fsf@ev.netlab.co.jp> <7vjtrc$hmm$1@newshost.accu.uu.nl> <3821A860.5D32AFCC@compaq.com> Message-ID: On 5 Nov 1999 01:22:23 GMT, Neel Krishnaswami wrote: >Greg Ewing wrote: >>Here are some random observations from studying the Ruby >>source code: >>* It doesn't use bytecode. The evaluator seems to operate >> directly on a parse tree. I don't know what implications >> this has for execution speed. >I was under the impression that Ruby did tail-recursion elimination, >and since continuation-passing forms are just a hair away from >bytecode, I am a bit surprised by this news. I'm not saying this is >impossible (witness the scm Scheme interpreter), mind, just a little >surprised. >Are there any syntax-tree munging phases to do stuff like common >subexpression elimination and loop hoisting? I guess that could yield >enough speedups to make a VM not yet necessary. Parse trees tend to evaluate faster than bytecode when both have only primitive optimizations. They are also much, much easier to optimize. In general, I would expect a parse tree implementation to outperform a bytecode implementation given equivalent work. >Neel -- -William "Billy" Tanksley From Gareth.McCaughan at pobox.com Wed Nov 24 17:20:56 1999 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: 24 Nov 1999 22:20:56 +0000 Subject: Python complaints References: <867lj85g4c.fsf@g.local> Message-ID: <86so1v4jlj.fsf@g.local> Markus Stenberg wrote: [I said:] >> - Some more iteration constructs would be nice. >> >> - do ... while > > ugh. matter of taste I suppose, but I don't find that lack big deal. The main reason I'd like to see it there is that I use Python sometimes for teaching to (young -- 12-15-ish) novices, and "while 1: ... break ..." is a little hard to motivate. >> - parallel iteration across more than one list > > for list1item, list2item, list3item in map(None, list1, list2, list3): > print 'whee', list1item, list2item, list3item Yeah, I know. But if I want that sort of thing I can use C. :-) >> - a less yucky way of saying "for i in range(1,20,3)" > > see above - although some special syntactic sugar would be "nice", I prefer > minimalistic approach over say, C.. of course, Dylan does it (IMNSHO) > cleanest: > > for (i from 3 to 19 by 3) > ... > > > Regrettably I can't tolerate Dylan's whitespace approach :P > (I write accidentally too often stuff like i-j, as opposed to i - j) Dylan is sort of nice. I can't think of any purpose for which I'd prefer Dylan to Common Lisp, though; the strengths of the two languages are in similar places, and I think CL wins. -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From bjorn at roguewave.com Mon Nov 29 12:00:59 1999 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Mon, 29 Nov 1999 10:00:59 -0700 Subject: Python bugs Message-ID: <51C9F3C392D0D111A15600A0C99E64A9AF5690@localhost> Just found two bugs: - os.environ and shelve does not conform to the Mapping Type interface (2.1.6) (and in case you were wondering, I'm not interested in workarounds, but rather not having to special case my code ) --bjorn Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import os >>> {}.update(os.environ) Traceback (innermost last): File "", line 1, in ? TypeError: dictionary, instance >>> import shelve >>> s = shelve.open('foo') >>> s.get('bar', 'baz') Traceback (innermost last): File "", line 1, in ? AttributeError: get >>> From friedrich at pythonpros.com Tue Nov 2 13:20:12 1999 From: friedrich at pythonpros.com (Robin Friedrich) Date: Tue, 02 Nov 1999 18:20:12 GMT Subject: Template for CGI References: <7vn0sk$7cp$1@news.fsu.edu> Message-ID: <7vna0o$9rt$1@nnrp1.deja.com> That is a feature of TemplateDocument() in the HTMLgen package. You might try downloading it from http://starship.python.net/lib.html In article <7vn0sk$7cp$1 at news.fsu.edu>, "Glenn Kidd" wrote: > I am a newbie to Python and I have a question. I want a CGI script that > will read a file template and replace certain words with variables. Ii > tried putting the variable names in the file but it is read as palin text. > Is there a way to embed variables into a teplate or a replace function in > Python? Thank you for any help you give. > > Glenn Kidd > > Sent via Deja.com http://www.deja.com/ Before you buy. From thomas.heller at ion-tof.com Mon Nov 29 13:24:37 1999 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Mon, 29 Nov 1999 19:24:37 +0100 Subject: Need help with html files References: <3842bd0e.23017938@122.0.0.250> Message-ID: <024601bf3a96$fe604290$4500a8c0@thomasnotebook> > hi, > > i would like to open a local html file from within python, > When the html is opened, it should be opened like if you double click > on the filename, so it uses the know filetype from windows. > > in short , when someone has netscape as the default browser. > I open the html file python should call the html file , and windows > opens the default browser with the file as argument. > > I hope this is clear enough, at the moment i can?t think of a way to > explain it differently. > > if you know what i mean and if you have a solution for my problem > please post or mail. > > thanks > import os os.system ("start c:\\myfile.html") Thomas Heller From dgrisby at uk.research.att.com Wed Nov 10 07:40:57 1999 From: dgrisby at uk.research.att.com (Duncan Grisby) Date: 10 Nov 1999 12:40:57 -0000 Subject: omniORB for Python pre-release now available Message-ID: <80bp4p$fn$1@pineapple.uk.research.att.com> AT&T Laboratories Cambridge is pleased to announce the availability of the first public pre-release of omniORB for Python. omniORB is a free high-performance CORBA ORB. The bindings adhere to the latest draft Python mapping available from the OMG. Although this is a pre-release, the ORB has no known bugs, and is in daily use in our lab. omniORBpy is free software. The ORB runtime is released under the terms of the GNU Lesser General Public License; the associated tools are under the GNU General Public License. omniORBpy is a wrapper around the omniORB core library, and is therefore reasonably fast. Although most of the ORB is written in C++, the stubs generated from IDL are pure Python. This release of omniORBpy is also the first outing for omniORB's new IDL compiler, which has a simple Python back-end interface. If you have ever entertained the idea of generating some special-purpose code from your IDL, but been scared off by the complexity of available IDL front-ends, you may want to look at the new compiler. For more information, and to download omniORBpy, visit http://www.uk.research.att.com/omniORB/omniORBpy/ -- -- Duncan Grisby \ Research Engineer -- -- AT&T Laboratories Cambridge -- -- http://www.uk.research.att.com/~dpg1 -- From mhammond at skippinet.com.au Mon Nov 29 23:57:53 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 30 Nov 1999 04:57:53 GMT Subject: Access violation while trying to replace stdout with a local disk file References: <1268224356-30441862@hypernet.com> <000a01bf3a98$4f13c940$36f96d8c@sylvia> Message-ID: SINICA wrote in message <000a01bf3a98$4f13c940$36f96d8c at sylvia>... > >> They both need to be linked to the same c-runtime library, (ie, >> "Multithreaded DLL" in Settings | Compile | Code Generation). >> >> - Gordon >> >> > >i've changed the c-runtime to "Multithreaded " for myprog.exe >and "Multithreaded DLL" for python15.dll >but it still refuse to work, >shall i change to "Multithreaded DLL" instead of "Multithreaded" for >myprog.exe ? Yes - as Gordon said - "They both need to be linked to the same c-runtime library, (ie, "Multithreaded DLL" in Settings | Compile | Code Generation)." Mark. From 0498730983 at 03840938.net Mon Nov 1 01:44:33 1999 From: 0498730983 at 03840938.net (0498730983 at 03840938.net) Date: Mon, 01 Nov 1999 06:44:33 GMT Subject: HP Inkjet Blowout Message-ID: The Inkjet Company has the following inkjet specials: All Prices Include Free Shipping and Free Sales Tax EPSON Epson - $8.00 - Black or 10 for $65.00 - All Models* Epson - $12.00 - Color or 10 for $100.00 - All Models* *Epson - $16.00 - Black or 10 for $135.00 - 900/3000 *Epson - $19.00 - Color or 10 for $165.00 - 750/900/1200/3000 CANON Canon BCI-21B - $5.00 - Black BJC-2500/4000/4400/5000 Canon BCI-21C - $8.00 - Color BJC-2500/4000/4400/5000 Canon BC-20 - $18.00 - Black BJC-2500/4000/4300/4400/ Canon BC-02 - $16.50 - Black BJC-210/230/BJ-200 Canon BC-05 - $28.00 - Tri-Color BJC-210/240 Canon BX-3 - $28.00 - Black B-540/550/640 (See Below For Apple & H.P. Products) The Inkjet Company 1-310-517-9999 1-503-905-6652 Fax APPLE M8041G/C - $17.00 - Black Styler Writer 1500 M4609G/C - $30.00 - Tri-Color Styler Writer 1500 M3240G/A - $19.00 - Large "Double" Black Style Writer 2400 M3330G/A - $5.00 - Black Style Writer 2400 M3329G/A - $9.00 - Tri-Color Style Writer 2400 M1949G/A - $3.75 - Cyan Color Style Writer Pro M1950G/A - $3.75 - Magenta Color Style Writer Pro M1951G/A - $3.75 - Yellow Color Style Writer Pro M1952G/A - $3.75 - Black High Capcity Color Style Writer Pro HEWLETT PACKARD 51625A - $19.00 - Tri-Color Deskjet 500c/550 Series 51626A - $16.50 - Black Deskjet Series / OfficeJet 300 / HP Fax 51629A - $16.50 - Black Deskjet 600 Series / OfficeJet 500 Series 51649A - $19.00 - Tri-Color Deskjet 600 Series / OfficeJet 500 Series 51645A - $16.50 - Black Deskjet 700/800/1000/1600 51640A - $16.50 - Black Deskjet 1200 / CopyJet The Inkjet Company 1-310-517-9999 1-503-905-6652 Fax Visa, Mastercard, Amex, Discover Fast Free Delivery - usually in two days or less! From joecot1 at bellatlantic.net Sat Nov 13 22:54:49 1999 From: joecot1 at bellatlantic.net (Joe Cotellese) Date: Sun, 14 Nov 1999 03:54:49 GMT Subject: Python and sending emails with it References: <382E2DB2.A00B9109@nv2.cc.va.us> Message-ID: <942551361.1861452872@news.bellatlantic.net> Well it depends. You can generally use the SMTPLIB module for sending mail. It works pretty well. I have however found it to have problems sending mail to a Worldmail (Eudora) server. The library is smtplib.py and it has a usage sample at the bottom of the module. Regards, Joe Cotellese Jeremy Misavage wrote: > I'm kinda new to python and I'm trying to write a small program that will take > in form data, save it in a db, and then send an email to a person. > > The program processes a users request for a "equipment request." It gets > loggged in a db (already done) and sends an email to the person in change of the > equipment. I need help on the email part. Does some out there have some code > that will taken data and send it to a person. It shouldn't need a username and > password, but if it does I'll live with that. From andy at robanal.demon.co.uk Sun Nov 7 11:42:59 1999 From: andy at robanal.demon.co.uk (Andy Robinson) Date: Sun, 07 Nov 1999 16:42:59 GMT Subject: Drawing (directed) graphs References: <000a01bf2792$b83ff150$3acbd9c2@peridot.optichrome.com> <14370.59564.979979.285996@gargle.gargle.HOWL> Message-ID: <3826abe1.17176077@news.demon.co.uk> mlh at vier.idi.ntnu.no (Magnus L. Hetland) wrote: >Charles G Waldman writes: > >> Magnus L. Hetland writes: >[...] >> > Even on Minix you could easily generate jpegs, or postscript files or >> > whatever with Piddle. If you can't run an X server or something, that >> > only means that you can't see it... Or maybe you have a printer? >> >> Or for maximum portatbility, you could use the "aa" ascii-art library >> to display the images on an ASCII terminal.... it's a C library, but >> it would be trivial to SWIG up a set of Python bindings, if this >> hasn't been done yet. > >Excellennt suggestion :) > >A nice backend for PIDDLE... Any takers? No way - Joe would hold up the release forever until we managed rotated text! - Andy From evan at tokenexchange.com Thu Nov 11 13:14:08 1999 From: evan at tokenexchange.com (Evan Simpson) Date: Thu, 11 Nov 1999 12:14:08 -0600 Subject: What are Aspects? (Re: How can I make my assertions smarter?) References: <7vvq63$ehm$1@nntp4.atl.mindspring.net> <3826C32A.FB47EF6@compaq.com> <80eocf$8rc$1@nntp5.atl.mindspring.net> Message-ID: All I know about Aspects I learning in a half-hour of browsing I think that this depends on the language in which you write your Aspects (I don't mean C/Python/etc, I mean the special Aspect-specification language). In the examples I looked at, pattern-matching on the class, method, and method arguments determined where each part of an Aspect would be applied. Effectively, you could say thing like: o Insert this code before the start of all methods of every class o Put this code in a try...finally wrapped around the body of any method named "foo" in any class o Insert this code after the end of all constructors of classes "Fee", "Fie", and "Foe" It all looks very interesting and powerful, but I haven't the faintest idea how it could be applied to a dynamic language like Python. From what I could tell, the existing implementation depends on all classes and methods being defined and fixed at compile time. Aahz Maruch wrote in message news:80eocf$8rc$1 at nntp5.atl.mindspring.net... > I feel like I'm still missing something. What if you only want half of > your classes to get ref-counting? Or are you saying that aspects are by > definition applied across *all* code, and that they're more like hooks > into the Python interpreter? Cheers, Evan @ 4-am From fredrik at pythonware.com Mon Nov 29 06:30:51 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 29 Nov 1999 12:30:51 +0100 Subject: help with opening html files References: <384261c4.8540090@122.0.0.250> Message-ID: <028601bf3a5d$31abdea0$f29b12c2@secret.pythonware.com> volumeregeling wrote: > Can anyone tell me how to open a html file from within python in > windows. html files are text files, and can be handled in the usual way. see chapter 7 in the tutorial for more info: http://www.python.org/doc/current/tut/tut.html From quinn at groat.ugcs.caltech.edu Fri Nov 26 17:54:27 1999 From: quinn at groat.ugcs.caltech.edu (Quinn Dunkan) Date: 26 Nov 1999 22:54:27 GMT Subject: python test frameworks Message-ID: I know this sort of thing has been talked about before, but I'm looking for some information on techniques for self-testing pyhon code (something I should have been doing before, but only now am I writing a system complex enough to warrant it). I remember Tim's thread about his doc-string embedded testing, and that looked interesting, but I can't find it now. And links to discussions of the merits of different strategies would be good, too. thanks From m.faassen at vet.uu.nl Thu Nov 18 16:00:46 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 18 Nov 1999 21:00:46 GMT Subject: Proposal: Python Info Collective References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> <80oqn9$ocq$2@newshost.accu.uu.nl> <80p9su$ppo$2@newshost.accu.uu.nl> <80piru$13rl$1@hub.org> <80re5d$55a$1@newshost.accu.uu.nl> <810jto$lo0$1@newshost.accu.uu.nl> Message-ID: <811pdu$dvo$1@newshost.accu.uu.nl> Martijn Faassen wrote: [snip] > No, no, a more extensive deja search indicated to me that this person has > posted under other names to the group previously. At least, unless there are > 10 people with the same speech patterns posting to comp.lang.python. :) with the same speech patterns _from vex.net_, I meant! deja nor I are that good at scanning for similar speech patterns yet, but the vex.net subset is doable for the eyeball. Still-curious-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From mlh at vier.idi.ntnu.no Tue Nov 9 08:38:56 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 09 Nov 1999 14:38:56 +0100 Subject: pythonistas or pythoneers? References: <07111999.2@sanctum.jae> <382633B1.50993D93@callware.com> <806unr$6qp$1@nnrp1.deja.com> Message-ID: init__self at my-deja.com writes: > > No way - we are all Pythoneers at the frontiers for computer > > science... ;) > > Wouldn't that be a Pyoneer then? > Guess so... But the overlap with the string "Python" is only two characters long... (But the editing distanc between Python and Pyon is only 2...) -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From andrew.markebo at telelogic.se Wed Nov 3 03:09:19 1999 From: andrew.markebo at telelogic.se (Andrew Markebo) Date: 03 Nov 1999 09:09:19 +0100 Subject: dejasearch.py - an www.deja.com client, Alpha version comments wanted Message-ID: Well my dejasearch.py seems to be usable now.. readme and link below /Andy Can be found at: http://www.fukt.hk-r.se/~flognat/DejaSearcher2.zip dejasearch.py - client for deja.com Allows you to easily see all the headers that matches your search, downlad/view the articles you are interested in, and save your query so you can load it again, and continue downloading articles. This is still some kind of alpha-version would like your comments about the GUI, if you have any ideas what to use instead and so on. In the article header list you see a 'status' letter first, it means A:Away, not downloaded, D:Downloading, H:Home, you can see the article if you doubleclick it. What works: * Search on keywords * download selected * load/save * doubleclick on article header line to download article, if downloaded it views the article in the article frame.. or ;-) Todo: * Use asyncore.py instead of BGFetcher (stability) * implement the selection fields * look why I only can do 'default' searches on keywords. * Improve the gui * Incorporate your changes ;-) /andy flognat at fukt.hk-r.se From smigowsky at dspace.de Tue Nov 30 11:17:06 1999 From: smigowsky at dspace.de (Stefan Migowsky) Date: Tue, 30 Nov 1999 17:17:06 +0100 Subject: COM and Powerpoint control Message-ID: <326536345498D311B3BC00105A39802A074500@newsintern.dspace.de> Hi, just use SlideShowWindows.Next, e.g in your code : from win32com.client import constants, Dispatch x = Dispatch('Powerpoint.Application.8') x.Presentations.Open(FileName='c:\temp\COMTutorial.ppt') x.ActivePresentation.SlideShowSettings.Run() print " Show first slide for 5 secs" win32api.Sleep(5000) print " Show next slide for 5 secs" x.SlideShowWindows(1).View.Next() print " Show next slide for 5 secs" win32api.Sleep(5000) . . . print " That's all folks" x.SlideShowWindows(1).View.Exit() Stefan -------------------------------------------------------- mailto:smigowsky at dspace.de http://www.dspace.de >-----Original Message----- >From: Harald Singer [mailto:singer at itl.atr.co.jp] >Sent: Tuesday, November 30, 1999 3:09 PM >To: python-list at python.org >Subject: COM and Powerpoint control > > >Hi, > >I am looking for an example of an "outside controlled" PowerPoint >presentation using COM. My final goal is to time-align the slides >presentation with an audio file, because the PowerPoint internal >slide-show timing is massively broken. > >The following code snippet worked promisingly well on Win98: > > from win32com.client import constants, Dispatch > > x = Dispatch('Powerpoint.Application.8') > x.Presentations.Open(FileName='c:\temp\COMTutorial.ppt') > x.ActiveWindow.ViewType = constants.ppViewNotesPage > >Now, I tried to record a macro to see what commands might be used in >slideshow mode, but looking at the generated VB code, I can't see any >commands that advance the slideshow. > >-- VB snippet start --- >Sub Macro1() >' > ppShowAll > .AdvanceMode = ppSlideShowUseSlideTimings > .PointerColor.SchemeColor = ppForeground > .Run > End With > SlideShowWindows(Index:=1).View.Exit >End Sub' >-- VB snippet end --- > >Any help or code fragments are appreciated. BTW, I did a search >for this but nothing relevant came up. >-- >Harald Singer ATR-ITL singer at itl.atr.co.jp ++81-774-95-1389 > > >-- >http://www.python.org/mailman/listinfo/python-list > From cjensen at be-research.ucsd.edu Wed Nov 17 13:23:53 1999 From: cjensen at be-research.ucsd.edu (Curtis Jensen) Date: Wed, 17 Nov 1999 10:23:53 -0800 Subject: Multi-Dimensional Arrays. Message-ID: <3832F2B9.F64C8AD7@be-research.ucsd.edu> I'm working on a Python user interface that will be connected to some fortran code with heaps of multi-dimensional arrays. I can't seem to find any references to multi-dimensional arrays in Python. Is there an easy way to create multi-dimensional arrays in Python? -- Curtis Jensen cjensen at be-research.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jam at quark.emich.edu Wed Nov 10 18:49:26 1999 From: jam at quark.emich.edu (Jeff) Date: Wed, 10 Nov 1999 18:49:26 -0500 Subject: Intelligent strptime? In-Reply-To: <19991110204023.A8220@optiplex.palga.uucp> References: <19991110171256.A5196@optiplex.palga.uucp> <14377.41778.712189.7874@gargle.gargle.HOWL> <19991110204023.A8220@optiplex.palga.uucp> Message-ID: <19991110184926.B8734@quark.emich.edu> On Wed, Nov 10, 1999 at 08:40:23PM +0100, Gerrit Holl wrote: [..snipped discussion about how best to handle the 'various date format' problem..] > > It could return a tuple or something then. But if I want people to choose: > either input "Nov, 23" or "12/6/99" or "1 December 2000", I don't want to > check too much. There are much date processing programs (date, I think) that > do this intelligent. You could also let the above think depend on the timezone, > if it's an american timezone, take the american way, else, take the > european way. But returning a tuple on 132 days seems better to me. > I ported a small piece of code from the CVS sources into a python module that returns the number of seconds since the Epoch instead of a tuple. I called it 'getdate', and released it a while ago to my startship.python.net account (ftp://starship.python.net/pub/crew/jam/). the module is comprised of one function that is able to act intelligently when given various date formats like the ones you are describing and seems to make the 'right' choice 'most' of the time. please try it out-- it might suit your purposes nicely, especially if you are writing an interactive application that accepts date input from a human user. here is an example of this module in action: [~] [6:36pm] [jam at toast-pts/3] % 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 getdate >>> dir(getdate) ['_RCSID', '__doc__', '__file__', '__name__', 'error', 'getdate', 'parse'] >>> getdate.getdate("1 december 2000") 975646800L >>> getdate.getdate("1999-12-01") 944024400L >>> getdate.getdate("12/1/1999") 944024400L >>> getdate.getdate("last friday 15:00 PST") 941842800L >>> getdate.getdate("now") 942277099L >>> import time >>> time.strftime("%Y-%m-%d %H:%M %Z", time.localtime(getdate.getdate("now"))) '1999-11-10 18:39 EST' >>> time.strftime("%Y-%m-%d %H:%M %Z", time.localtime(getdate.getdate("yesterday"))) '1999-11-09 18:39 EST' >>> time.strftime("%Y-%m-%d %H:%M %Z", time.localtime(getdate.getdate("last friday 15:00 PST"))) '1999-11-05 18:00 EST' >>> time.strftime("%Y-%m-%d %H:%M %Z", time.localtime(getdate.getdate("8pm"))) '1999-11-10 20:00 EST' please let me know if there are any questions or concerns. regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From krutz at cg.tuwien.ac.at Wed Nov 24 13:59:29 1999 From: krutz at cg.tuwien.ac.at (Markus Krutz) Date: Wed, 24 Nov 1999 18:59:29 GMT Subject: newbie question References: <943469319.838266356@news.teleweb.at> Message-ID: <943469465.1530627167@news.teleweb.at> On Wed, 24 Nov 1999, Markus Krutz wrote: >How the f*** do I create a string containing a *single* "\" ? > >regards >Markus "Problem" solved. Damned interpreter output ;) From Gaetan_Corneau at baan.com Fri Nov 26 09:03:04 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Fri, 26 Nov 1999 09:03:04 -0500 Subject: The First Annual Obfuscated Python Contest Message-ID: <816010E2456BD111A48700805FBBE2EEFDF83B@ex-quebec-u1.baan.com> Anyone has ever seen an elegance Python contest? I mean, tough problems cracked with simple, elegant code? :) ______________________________________________________ Gaetan Corneau Software Developer (Quality Assurance Team) BaaN Supply Chain Solutions http://www.baan.com E-mail: Gaetan_Corneau at baan.com Tel: (418) 266-8252 ______________________________________________________ "Profanity is the one language all programmers know best" From gvwilson at nevex.com Sun Nov 28 13:51:38 1999 From: gvwilson at nevex.com (Greg Wilson) Date: Sun, 28 Nov 1999 13:51:38 -0500 Subject: pre/post-condition support? Message-ID: <_Re04.8705$cz3.315483@nnrp1.uunet.ca> Has anyone experimented with Python extensions to support programming by contract (pre/post conditions on methods + state assertions that are respected by inheritance)? If so, I'd welcome pointers. Thanks, Greg p.s. I'm aware this can be done by hand by putting assertions at the start and end of methods. However, that doesn't automatically work right when methods have multiple exit points (return statements, exceptions that callers are expected to catch, etc.), and isn't respected by inheritance. From phd at sun.med.ru Wed Nov 10 08:35:54 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Wed, 10 Nov 1999 16:35:54 +0300 (MSK) Subject: time/strptime/mktime/localtime Message-ID: Hello! The following program prints "1999-09-21 21:44:33" on Linux and "1999-09-21 22:44:33" on Solaris (1 hour offset). Is it a problem with my config? libs? python? Timezone is Europe/Moscow, set (I think) correctly on both systems. #! /usr/local/bin/python -O import time t = time.strptime("1999-09-21 21:44:33", "%Y-%m-%d %T") m = time.mktime(t) print time.strftime("%Y-%m-%d %T", time.localtime(m)) Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From Gareth.McCaughan at pobox.com Thu Nov 25 15:51:14 1999 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: 25 Nov 1999 20:51:14 +0000 Subject: Python complaints References: <867lj85g4c.fsf@g.local> <86so1v4jlj.fsf@g.local> Message-ID: <86ln7m2t31.fsf@g.local> Markus Stenberg wrote: > I have always found lisp-ish syntax of "masses of ()s" disconcerting in > large amounts - admittedly, I've written more than few lines of > [ce]lisp/scheme/.., but never enjoyed browsing the results very much. I > consider Dylan to be "readable" clisp. One quickly gets used to Lisp syntax. Like using indentation to denote block structure. :-) After a while, you just stop noticing all those parentheses. > From trivial example - do you consider (+ 2 (* 3 4)) more readable than 2 + > 3 * 4 most languages (including Dylan) allow me to do? No, I don't. But I don't consider it hugely less readable, and that really is the *worst* case for Lisp syntax. Really complicated expressions are about equally readable either way; and Lisp's great (excessive?) simplicity makes possible its great macro system. And *that* lets me make a lot of things much more readable than they otherwise would be. -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From thantos at chancel.org Thu Nov 18 18:39:03 1999 From: thantos at chancel.org (Alexander Williams) Date: Thu, 18 Nov 1999 23:39:03 GMT Subject: Proposal: Python Info Collective References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> <80pe77$osc$1@hub.org> <80vp2m$275$1@nntp9.atl.mindspring.net> Message-ID: On 18 Nov 1999 20:31:58 GMT, Mitchell Morris wrote: >Reading is not so bad ... searching blows. As an example, I'm looking at the >page for the "re" module and want to see the argument list for "unpack" but >can't seem to remember if it's in "string" or "struct" or >Guido-only-knows-where. Lynx provides squat for this operation, so I wind up Magic word: index. See the last page of the doc list in HTML, an index of functions and terms hyperlinked to the discussion thereof. Voila. Has the dimmunation of print media really caused us to forget such simple methods? -- Alexander Williams (thantos at gw.total-web.net) "In the end ... Oblivion Always Wins." From gerrit.holl at pobox.com Fri Nov 19 07:58:11 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Fri, 19 Nov 1999 13:58:11 +0100 Subject: Python in business programming [was Re: Beginning programming with Python] In-Reply-To: <1269336472-10033930@hypernet.com> References: <383195C1.826B3342@iqsoft.hu> <1269336472-10033930@hypernet.com> Message-ID: <19991119135811.B4306@optiplex.palga.uucp> Gordon McMillan wrote: > (the code, compile, test cycle is now rarely more than half an hour). Hehe, Win NT should be rewritten in Python; it seems that this cycle costs 30 hours for NT :-)) > Test suites are > more important (but also easier). For large systems, > decomposing the problem cleanly is very important - to > preserve your sanity you need the smallest, cleanest > interfaces possible between subsystems. But, if at first you > foul it up, you can still rewrite most of it before lunch. I agree. But some functions are too small to be used: in os.path: def os.path.isabs(s): return p[:1] == '/' I think that's a redicolous (how does one spell that?) function... regards, Gerrit. -- "We all know Linux is great...it does infinite loops in 5 seconds." (Linus Torvalds about the superiority of Linux on the Amterdam Linux Symposium) From rp2885 at email.sps.mot.com Thu Nov 11 17:04:41 1999 From: rp2885 at email.sps.mot.com (Aaron Ginn (rp2885)) Date: Thu, 11 Nov 1999 15:04:41 -0700 Subject: Beginning programming with Python References: <382B3A53.5816B2@callware.com> Message-ID: <382B3D79.74CD3E0F@email.sps.mot.com> Ivan Van Laningham wrote: > Hi All-- > > Aaron Ginn wrote: > > > > Hello all, > > > > I'm starting a non-profit organization dedicated to promoting computer > > literacy in low-income youth (ages 12-18). > > An admirable goal indeed. I will be interested in hearing how well this > works. Are you affiliating yourself with any municipal, civic or > religious organizations? I've created a website for our organization at http://www.mindspring.com/~alginn/gwam.html The site is a little out of date at this point. The original goal was to use only Linux as the base OS for this project. However, one of the people I've recruited to work on this is a C.S. professor at Arizona State who has a contact in the Microsoft Education office. We hope that Microsoft will supply us with free licenses so that we can put dual-boot machines together for the kids. If they do, I'll definately have to change our logo! :) All of the people I've recruited in this go to my church, and we will use the church as our meeting place, but we have no religious agenda. > > > > The curriculum will > > include an introduction to programming using either Python or Perl. > > > > First, I know Perl very well, but I know nothing about Python. I've > > heard from many sources that Python is the best language to teach > > someone with no programming experience because it emphasizes > > fundamentals and the correct (i.e. best) way to program. Could anyone > > comment on how the two languages compare in this aspect? Also, I will > > need to learn Python as well if I choose to go that route. I am very > > literate with Perl and Tcl/TK. How quickly can I expect to pick up > > Python? > > > > *Extremely* quickly. In fact, if you'd started yesterday you wouldn't > need to ask this question. That's what I expected. I perused the books in question and musc of the syntax looked _exactly_ like Perl. An honest opinion, please; is Python better suited for beginners than Perl, as I've heard? > > > > Secondly, if I choose to use Python for this, I would like to supply > > each student with a reference book on Python. I've narrowed it down > > to a choice between the two O'Reilly books, "Programming Python" and > > "Learning Python". PP apears to have a lot more meat to it, but LP > > appears to be more suited to the beginner. Assuming the audience > > includes kids that have never programmed before, should I go with LP, > > or will I miss out on anything by not getting the more detailed book? > > > > Of the two books mentioned, yes, _Learning Python_ would be the better > choice. However, if you can wait, _Teach Yourself Python in 24 Hours_ > is aimed *specifically* at people who have never programmed before. It > covers: > > 1) Introduction to programming (*rock-bottom* fundamentals--what's a > variable? What's a for loop?) > 2) Introduction to Object-oriented programming > 3) Introduction to Tkinter > > > The three parts have 8 chapters each. > > TYPython will be out early next year. When is your course starting? > Where is Chandler?-) We are planning on starting our training in March, so I can wait a while. I'll probably pick up a copy of PP for myself in the meantime. Chandler is a suburb of Phoenix. Actually, I live 1 mile from the Phoenix border. > > > PP is very thorough, but needs a new edition. > LP is aimed at people who do have some idea of how to program, and is a > gentle way to further your programming skills. > Both books are funny and interesting, too. > > TYPython is for total newbies; I can't speak to either funny or > interesting (modesty overwhelms me), but I try to get their attention. > > None of these three books is a *reference*, however. If you really want > a reference, then you're better off with Dave Beazley's _Python: > Essential Reference_. But you need to know Python before you can make > use of it. Reference was a bad choice of words. I want a book that will introduce the kids to basic programming fundamentals and will provide examples of how to do things in a given language that is easy to learn. I don't want "Python in a Nutshell" if such a thing even exists. > > > Hope this helps, It does. Thanks a lot! Aaron > > > -ly y'rs, > Ivan > > -ly y'rs, > Ivan > ---------------------------------------------- > Ivan Van Laningham > Callware Technologies, Inc. > ivanlan at callware.com > ivanlan at home.com > http://www.pauahtun.org > See also: > http://www.foretec.com/python/workshops/1998-11/proceedings.html > Army Signal Corps: Cu Chi, Class of '70 > Author: Teach Yourself Python in 24 Hours > ---------------------------------------------- -- Aaron J. Ginn Motorola SPS Phone: (480) 814-4463 SemiCustom Solutions Fax: (480) 814-4058 1300 N. Alma School Rd. mailto:aaron.ginn at motorola.com Chandler, AZ 85226 From neelk at brick.cswv.com Tue Nov 2 22:42:21 1999 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 3 Nov 1999 03:42:21 GMT Subject: Comparison between Python and "Ruby" References: <1270663667-24391282@hypernet.com> <381ED7A6.D7D7FB13@compaq.com> <877lk1wiij.fsf@ev.netlab.co.jp> <19991102154543.A4469@optiplex.palga.uucp> <381F9EB4.63FA033F@python.net> Message-ID: Thomas A. Bryan wrote: > >Yes, there are. Larry Wall's speeches (Wall is the Guido of Perl) >often proclaim that the problem with many programming languages >is that they enforce too many restrictions on the programmer and >his code. Thus, given a problem, the programmer first has to map >that problem onto what is permitted by the language. The less >flexibility the language offers, the more difficult this mapping >process can be for more problems. Perl is supposed to reduce the >amount of mapping that a programmer has to do before implementation. The only languages that have taken this idea seriously is the Lisp family, which have macro systems that basically allow the programmer to extend the language. In short: the Lisps have an extensible syntax, where Perl just has an extensive syntax. Python (and Ruby, for that matter) remind me more of Smalltalk than anything else -- ie, they have extensive libraries, a community with a love of elegance but not of purity[*], and a greater focus on practical applications than on academic research. The differences are that there's less of a closed-world attitude in Python than in the ST world, though -- Python can be used for sysadmin work where ST (even Squeak) wouldn't be a natural fit. But on the flip side Smalltalk has always had a stronger focus on UI and dev environments. This is changing, though -- the ST culture is beginning to value the ability to deal with the world outside the system image, and Guido's latest enthusiasm is "computer programming for everybody" (which is a very ST-ish sort of idea). Neel From ferraris at mdmlab.mi.infm.it Thu Nov 11 03:38:45 1999 From: ferraris at mdmlab.mi.infm.it (Sandro Ferrari) Date: Thu, 11 Nov 1999 09:38:45 +0100 Subject: How do I compile NumPy on Linux? Message-ID: <382A8094.3354DE70@mdmlab.mi.infm.it> I downloaded the LLNLDistribution.tgz file and followed the installation instruction: cd Numerical ./makethis.py but I get the message: make: Makefile.pre.in: No such file or directory make: *** No rule to make target `Makefile.pre.in'. Stop. make: *** No targets. Stop. In the documentation isn't mentioned anything about it. Any help? thanks Sandro From emile at fenx.com Tue Nov 9 23:15:15 1999 From: emile at fenx.com (Emile van Sebille) Date: Tue, 9 Nov 1999 20:15:15 -0800 Subject: __str__ vs. __repr__ References: <000401bf25b9$88ea57e0$2e2d153f@tim> <199911040157.UAA11908@eric.cnri.reston.va.us> <046101bf26d4$2dd1a720$01ffffc0@worldnet.att.net> Message-ID: <004b01bf2b32$31c7cc80$01ffffc0@worldnet.att.net> Neel, Ah, but you didn't disagree! ;-) Testing certainly is useful, and for the tester it *is* work, but that's code that is not in production, which is when the code *is* working. I quote now from Paul Foley , who e-mailed me a sample interactive session using a function describe(): > > You mean something like this: > > >>> x="Testing" > >>> describe(x) > A string containing 7 characters. > >>> import sys > >>> describe(sys) > The `sys' module. > The module has no documentation string. > > It exports the following functions: ['setcheckinterval', 'exc_info', 'exit', 'setprofile', 'settrace', 'getrefcount'] > > It exports the following variables: ['platform', 'stderr', 'version', 'builtin_module_names', 'modules', 'stdin', 'exec_prefix', 'copyright', 'executable', 'exc_type', 'ps1', 'ps2', 'path', 'maxint', 'prefix', 'argv', 'stdout'] > >>> describe(sys.exit) > The built-in function `exit'. > >>> describe(sys.stdin) > A file open for reading on `' (a TTY device) > The underlying file descriptor is 0. > The current file position is 0. This is what I had in mind. To further enhance the utility of interactive mode by providing more information to the programmer. Certainly __str__ and __repr__ are The Wrong Way (tm) to do this, and describe() much better. Any and everything more that describe() could do should be added to it. Add -v, -vv, -vvv options as appropriate. Show the source entry line. Hey, show the whole routine. ;-0 (Let's see... get line number from bytecode, read source for line, note indent, display until match indent... is that it?) is-what-we-do-work-ly yr's -- Emile van Sebille emile at fenx.com ------------------- Neel Krishnaswami wrote in message news:slrn82hhtv.ppi.neelk at brick.cswv.com... > Emile van Sebille wrote: > > > >It seems to me that issues arise when using the interactive interpreter. > >I suspect that little useful work is done in this mode, and is used > >predominately for quick testing while creating python programs. > > I'd like to politely disagree . Combined with Tim Peters and Barry > Warsaw's emacs py-mode, Python's interactive mode is the single most > useful feature of the language for me. With it, I can test each and > every method, loop, and statement as I code. This does wonders for my > understanding of my code. And not incidentally, reliability goes way > up as well. > > I learned Perl before Python, but my Python skill surpassed my Perl > skill after a much smaller time investment. I lay this pretty much > wholely at the feet of the interactive interpreter -- I could find out > the answers to puzzles without a tedious edit-save-run cycle. > > > Neel > > -- > http://www.python.org/mailman/listinfo/python-list > > From parkw at better.net Mon Nov 29 17:07:05 1999 From: parkw at better.net (William Park) Date: Mon, 29 Nov 1999 17:07:05 -0500 Subject: Htmlizing text In-Reply-To: <943909426snz@vision25.demon.co.uk> References: <943909426snz@vision25.demon.co.uk> Message-ID: <19991129170705.A314@better.net> On Mon, Nov 29, 1999 at 09:03:46PM +0000, Phil Hunt wrote: > > Is there a function in the standard Python library to HTML-ize text, > i.e. to replace 'a > b & c < d' with 'a > b & c < d'? > > (I realize this can be done with regular expressions, but is there > an easy way?) > > -- > Phil Hunt - - - phil at comuno.com The following function replaces [<&>] unconditionally. def escapeall(s): s = string.replace(s, '&', '&') # do this first s = string.replace(s, '<', '<') s = string.replace(s, '>', '>') return s I used this in my 'HTMLtag' module which generates HTML tags. William. From doughellmann at home.com Tue Nov 30 07:12:53 1999 From: doughellmann at home.com (Doug Hellmann) Date: Tue, 30 Nov 1999 12:12:53 GMT Subject: bug in tkinter canvas event handling? References: <38429BB0.1BFFB54B@sage.att.com> Message-ID: <3843C0A0.94990E64@home.com> "Garrett G. Hodgson" wrote: > > ok, i'm back with another tk problem. > what i want to do is attach a callback to a shape in a canvas > that will tell me which domain level object was picked. > > seems simple, but i don't get what i expect. in particular, > if i press a mouse button while pointing to one object, then drag > to another and release, the release event callback tells me i > was pointing to the first object. i've distilled it down to a > small test case, attached below. > > this seems like a bug to me, but experience has shown that it's > probably a misconception on my part about how the event handling > is supposed to work. This behavior surprised me at first, too. It's as though the first canvas object is grabbing the pointer so that all events go to it. I got around the problem by looking for the x,y coords of the release event and then finding the object(s) under that point on the canvas. Doug From claudius at catlover.com Tue Nov 9 23:36:34 1999 From: claudius at catlover.com (claudius at catlover.com) Date: Wed, 10 Nov 1999 04:36:34 GMT Subject: Java vs. Python - Serialization Bakeoff References: <99110918085909.01567@quadra.teleo.net> Message-ID: Patrick Phalen says: >http://starship.python.net/crew/gandalf/DNET/serial/jp-serial.html >contains an report on tests comparing Java's and Python's data >marshalling, using various criteria. Numerous interesting charts and >graphs are presented. > >Since this was published in 1996 (Python 1.4), I wonder if anyone >expert in this subject has any comment on whether the intervening years >would have changed the conclusions substantively -- namely that Python >is, on average, faster, simpler, and more flexible. Hmm? I get 'not found' (and I'm very interested in reading your findings.) From aa8vb at yahoo.com Mon Nov 1 10:58:46 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Mon, 1 Nov 1999 10:58:46 -0500 Subject: eff-bot Python book ... revisited In-Reply-To: <00fd01bf23cb$e4b6ed30$f29b12c2@secret.pythonware.com> References: <7va9hf$ngi$1@marcie.fissiontech.com> <19991029081909.B106968704@vislab.epa.gov> <00fd01bf23cb$e4b6ed30$f29b12c2@secret.pythonware.com> Message-ID: <19991101105846.A133876404@vislab.epa.gov> Fredrik Lundh: |for now, you get a PDF file, which can only be viewed/printed from a |Windows box. ... | | |and before even more people start whining about me "betraying Python in |itself, and especially its Unix roots," note that 1) this book wouldn't |exist if it hadn't been for the eMatter initiative, 2) I only wrote the |book, not the distribution software, and 3) Python was originally written |on a Mac. I'm sorry you might have interpreted my post that way. I think it is good that Python is getting so much coverage in the media, both printed an on-line (with more coming soon). This is a good first-start by eMatter! As a consumer though, I feel incumbant to express my desire for a product which is very interesting but does not fit my needs. A consumer-aware company will gear their product to demand, so they need feedback. I rarely use MSWindows and do no development in it. So an on-line, searchable reference tied to Windows doesn't exactly work. I'm sure I could steal the docs out from under their viewing shell, but I'm not sure all UNIX/Linux users could. For personal use this sounds like a reasonable work-around, and I'm tempted. I assume this doesn't violate their usage license? -- Randall Hopper aa8vb at yahoo.com From news at dorb.com Fri Nov 12 11:21:29 1999 From: news at dorb.com (Darrell) Date: Fri, 12 Nov 1999 11:21:29 -0500 Subject: .dll and .exe file version informaton References: <816010E2456BD111A48700805FBBE2EEFDF793@ex-quebec-u1.baan.com> <80ha4a$pmg$1@nnrp1.deja.com> Message-ID: Given the win32 calls it wouldn't be too hard to wrap them up in an extension module. -- --Darrell wrote in message news:80ha4a$pmg$1 at nnrp1.deja.com... > It looks like they are not available yet.... > In article <816010E2456BD111A48700805FBBE2EEFDF793 at ex-quebec- > u1.baan.com>, > Gaetan Corneau wrote: > > > go-ahead-just-*try*-to-write-a-program-to-do-that-ly y'rs - > tim > > > > If you really want to do it in a program, take a look at the following > > functions in the help: > > GetFileVersionInfo > > VerQueryValue > > QueryField > > From chapman at bioreason.com Tue Nov 16 19:56:13 1999 From: chapman at bioreason.com (Mitch Chapman) Date: Tue, 16 Nov 1999 17:56:13 -0700 Subject: Beginning programming with Python References: <80p9ds$ppo$1@newshost.accu.uu.nl> <38317787.19AFDAF5@compaq.com> <80s22o$o0l$1@nntp9.atl.mindspring.net> Message-ID: <3831FD2D.2FF2087A@bioreason.com> Aahz Maruch wrote: > > In article <38317787.19AFDAF5 at compaq.com>, > Greg Ewing wrote: > ... > >Well, not quite - you can forget the "self" in method > >declarations fairly easily... > > I don't seem to have that problem; my fingers have learned to > automatically type "(self" whenever "def" is indented. ;-) If you use [X]Emacs you can use python-mode functions to generate function and method templates -- including automatic insertion of the leading "(self" on method defs: http://starship.python.net/crew/mchapman/pycc.el This is old code, and word is that use of template.el would have greatly simplified it. But it works for me. -- Mitch Chapman chapman at bioreason.com From bernhard at alpha1.csd.uwm.edu Mon Nov 29 13:42:27 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 29 Nov 1999 18:42:27 GMT Subject: Pythonwin Reset References: <01bf38df$8127e0c0$3a42c3d1@Cyberus.cyberus.ca> <_X004.7432$VA6.38559@news-server.bigpond.net.au> <01bf39bd$a28831a0$4155c3d1@Cyberus.cyberus.ca> <81rmh5$9e$1@hub.org> <01bf3a8c$3f855b80$2241c3d1@Cyberus.cyberus.ca> Message-ID: On Mon, 29 Nov 1999 17:08:40 GMT, Gordon Williams wrote: >It now works in that it eliminates all the names, but it doesnt quite fix >my problem. When I make a GUI with wxPython (using Pythonwin IDE) and I >get an exception, the next time I try and run the program after fixing the >mistake, I get another exception saying One wxApps process only! Something >was left behind. The only way I have found to clear the problem was to >close Pythonwin and then restart it and reload the file. There is no fix AFAIK, but you can debug your little program in a different way. Add another method to the windows exploder, something like debug and add the option -i before the "%1" where python is called. Then you can rightclick on the python file and select debugging. You will see the error messages when the programs runs in the DOS window. (Close it with Control-Z) Should be a FAQ somewhere. Bernhard -- Research Assistant, Geog Dept UM-Milwaukee, USA. (www.uwm.edu/~bernhard) Free Software Projects and Consulting (intevation.net) Association for a Free Informational Infrastructure (ffii.org) From tcdoe at pitt.edu Thu Nov 4 15:04:27 1999 From: tcdoe at pitt.edu (tdoe) Date: Thu, 4 Nov 1999 15:04:27 -0500 Subject: file i/o !!! help Message-ID: <7vsolo$aer$1@usenet01.srv.cis.pitt.edu> Hi, im very new to using python, and im having a TERRIBLE time trying to find some example scripts for FILE I/O !!!! all i want to do is read a "comma" or "space" delimited list of numbers from a file such as: 1 2 3 4 5 6 7 8 9 10 11 12 and input them into a floating point list variable. well, this is probably a "cinch", but for me this has been tough. any help very appriciated. thanks, todd tcdoe at pitt.edu From a.eyre at optichrome.com Mon Nov 22 11:34:08 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Mon, 22 Nov 1999 16:34:08 -0000 Subject: Getting PythonWin debugger working with an embedded app. In-Reply-To: <11A17AA2B9EAD111BCEA00A0C9B41793034AAF00@molach.origin.ea.com> Message-ID: <000a01bf3507$6600b9b0$3acbd9c2@peridot.optichrome.com> > [snip] > We are using the debug version of the Python DLL for Windows. There's the clue. > [snip] > ImportError: No module named win32ui If you read through the Python source, you will find that the debug Python DLL requires all extension modules to end with '_d' (e.g. win32ui.pyd must be named win32ui_d.pyd). There is a good reason for this. It would appear that mixing DLLs built with MSVCRT.DLL and MSVCRTD.DLL causes problems. Unfortunately this means you can't just rename the module. You must build a debug version from the source. I know it's a pain in the arse, especially for the modules that need SWIG in order to build, and/or you only have MSVC5 (this requires a few changes to defined symbols.) I would like to suggest to Mark Hammond, if possible, to include debug versions of the win32all modules in the distribution, maybe as an optional component in the installer. I would also like to suggest the same to Guido van Rossum in the Python installer. Just including the release version is fine for developers in pure Python, but anyone embedding or extending Python will hit the same problem sooner or later. > Any advice or suggestions would be truly welcome. Getting the > debugger working would be a huge step forward for us. Let me know if you have any success, as I managed to get this far, but hit a problem later on. -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From n89553 at squid.upb.de Fri Nov 5 10:43:04 1999 From: n89553 at squid.upb.de (Mirko Liss) Date: Fri, 05 Nov 1999 16:43:04 +0100 Subject: Bug: whichdb.py of python 1.5.2 at suse linux 6.2 Message-ID: <3822FB08.EC0CD544@squid.upb.de> Hi, the distribution SuSE 6.2 (linux at ix86) comes with a flavour of bsd-db that uses the magic key 0 (zero) in its databases. This feature makes it impossible to open existing shelves. This can be fixed by editing /usr/lib/python/whichdb.py : # Check for BSD hash # patch for suse 6.2 , mirko liss # if magic in (0x00061561, 0x61150600): if magic in (0x00061561, 0x61150600, 0): return "dbhash" regards, Mirko -- M Li?, From skip at mojam.com Mon Nov 29 16:37:01 1999 From: skip at mojam.com (Skip Montanaro) Date: Mon, 29 Nov 1999 15:37:01 -0600 (CST) Subject: 50% Python content :) (Distributed computing) In-Reply-To: <816010E2456BD111A48700805FBBE2EEFDF862@ex-quebec-u1.baan.com> References: <816010E2456BD111A48700805FBBE2EEFDF862@ex-quebec-u1.baan.com> Message-ID: <14402.61949.484621.155114@dolphin.mojam.com> Gaetan> I would like to explore distributed programming, and I think Gaetan> Python would be the right tool for that. I don't want to produce Gaetan> industrial-strenght code right now, but learn the basics. There are a number of different models of distributed computing available. You might find playing around with the eff-bot's xmlrpclib module (check www.pythonware.com) a relatively painless way to experiment with the remote procedure call model. I saw something posted recently about an implementation of a tuple space interface for Python as well. Check out http://www.snurgle.org/~pybrenda/ You'll find that a bit more complicated to get started with, but may in the long run provide a better computational model (depends on what you're really after). Finally, there is a Python interface to PVM. Check out http://www.flyn.org/ to-play-is-to-be-happy-ly y'rs, Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/ 847-971-7098 | Python: Programming the way Guido indented... From fdrake at acm.org Thu Nov 11 09:45:08 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 11 Nov 1999 09:45:08 -0500 (EST) Subject: .html -> .ps ? In-Reply-To: <19991111080506.A1007@better.net> References: <19991111080506.A1007@better.net> Message-ID: <14378.54900.714487.334690@weyr.cnri.reston.va.us> William Park writes: > 1. Does anyone have experience with 'html2ps', 'html2tex', and > 'html2latex' programs? Or, is there any other program that will do > the conversion in Python or otherwise? There's an html2ps.py in the Grail distribution; if your HTML doesn't involve tables that might just do it fo you. You can even drive it from Python by using Grail's "printing" package. Unfortunately, most HTML these days seems to involve at least tables nested 12-deep. ;-( -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From hei at adtranzsig.de Thu Nov 25 04:52:11 1999 From: hei at adtranzsig.de (Dirk-Ulrich Heise) Date: Thu, 25 Nov 1999 10:52:11 +0100 Subject: Python complaints References: <81gj3i$fe3$1@mach.vub.ac.be> <005201bf367e$4901fef0$f29b12c2@secret.pythonware.com> <81gpd5$332$1@mach.vub.ac.be> Message-ID: <943526916.548103@news.adtranzsig.de> Thomas Hamelryck schrieb in Nachricht <81gpd5$332$1 at mach.vub.ac.be>... >: > indentation or not. In many cases, using a variable indentation (depending >: > on what construct you are using or the length of a line) leads to code >: > that is visuably much more appealing. Once i saw a C program indented like a poem (centered lines). Visually, it was very appealing. I was glad i didn't have to understand it, though. -- Dipl.Inform. Dirk-Ulrich Heise hei at adtranzsig.de dheise at debitel.net From tismer at appliedbiometrics.com Wed Nov 17 09:17:07 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Wed, 17 Nov 1999 15:17:07 +0100 Subject: ANNOUNCE: a few little things References: Message-ID: <3832B8E3.3298AB47@appliedbiometrics.com> Neil Schemenauer wrote: > > I spent a bit of time today and updated my Python web site. The > highlights are: > > py152_sa.zip > ------------ > > A Stand-alone version of Python for Windows. It includes Python > 1.5.2, Tcl, zlib and bsddb. It fits on a floppy and can be > extracted and run from any location. Just add your application > code. Just a question here: I did a stand-alone version too a while ago, but didn't publish it for the following reason: If a user happens to import *any* .pyd module which is built for Windows, this pyd will try to load python15.dll since they all link against it. Did you provide something which at least prevends this problem? One possible solution would be a stub python15.dll just to be safe, which itself is linked against you .exe file. This works as far as I remember, but then you are at two files again, and the question remains why this is better than to have what we now have? cheers - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From python-list at teleo.net Mon Nov 29 12:38:26 1999 From: python-list at teleo.net (Patrick Phalen) Date: Mon, 29 Nov 1999 09:38:26 -0800 Subject: Running apps with Zope 2? In-Reply-To: <3842B384.5276F337@gmd.de> References: <80v5g8$5a6$1@mulga.cs.mu.OZ.AU> <383E7D7A.1B48C7F1@gmd.de> <3842B384.5276F337@gmd.de> Message-ID: <99112909422700.03205@quadra.teleo.net> [Peter K., on Mon, 29 Nov 1999] :: Anyone with better ideas? 1. Zope won't publish objects without a doc string (as your error msg. indicates). 2. Subscribe to the Zope mailing list (http://zope.org), where you'll find a large community of Zope-aware citizens willing to help. From jblazi at netsurf.de Tue Nov 16 13:02:08 1999 From: jblazi at netsurf.de (Janos Blazi) Date: Tue, 16 Nov 1999 19:02:08 +0100 Subject: Beginning programming with Python References: <382B3A53.5816B2@callware.com> <382B3D79.74CD3E0F@email.sps.mot.com> <80p9ds$ppo$1@newshost.accu.uu.nl> <38312D55.A36EB56D@iqsoft.hu> <383195C1.826B3342@iqsoft.hu> Message-ID: > As far as I understood, you are absolutely sure that Python is a perfect > language, I have to trust in it without any hesitation? I said that I have not had any experience using Python in my teaching yet and that I should like to try to use it first before I judge it. Do these words and "absolutely sure" mean the same thing to you? Or are you practising your English? Janos B. From andres at corrada.com Sun Nov 28 16:26:58 1999 From: andres at corrada.com (andres) Date: Sun, 28 Nov 1999 16:26:58 -0500 Subject: Parsing text References: Message-ID: <38419E22.7F6530EF@corrada.com> string.find(...) should do the trick From gerrit.holl at pobox.com Sun Nov 14 13:41:18 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Sun, 14 Nov 1999 19:41:18 +0100 Subject: telnetten vanuit een script In-Reply-To: <19991112201259.A6212@optiplex.palga.uucp> References: <19991112201259.A6212@optiplex.palga.uucp> Message-ID: <19991114194118.A30062@optiplex.palga.uucp> Gerrit Holl wrote: > Bert Frederiks schreef: > > Ik wil graag vanuit een script telnetten, dan een paar dingen doen en weer > > uitloggen en ondertussen de uitvoer opvangen in een bestandje. Dat werkt > > prima met pop3 op poort 110 maar op poort 23 lukt het me niet om in te > > loggen. Het probleem zit hem aan invoerkant want dit werkt wel: Sorry, wrong mailinglist! regards, Gerrit. From sblakey at home.com Tue Nov 30 18:46:10 1999 From: sblakey at home.com (Sean Blakey) Date: Tue, 30 Nov 1999 23:46:10 GMT Subject: What's the canonical vi setting for Python indentation In-Reply-To: <38445B6A.A1283D2E@cs.mu.oz.au> References: <38445B6A.A1283D2E@cs.mu.oz.au> Message-ID: I don't know about canonical, but I have the following in my .vimrc set expandtab "Turn's tabs into spaces set hardtabs=4 "Make tabs 4 spaces wide set tabstop=4 set shiftwidth=4 "For use with << and >> On Wed, 1 Dec 1999, Chris WRIGHT wrote: > I've tried to find out the "OK" indentation settings for python with vi, > and a troll through deja-news found some hints (like don't do indent = > 4). Yet I seem to also remember some advice to the contrary?? I want > indentation to be 4 characters, and readable by/ acceptable to emacs > python-mode, and to pass tabnanny... > > I think that this should go in the faq...(Couldn't find it from > www.python.org search) > > > cheers > and thanks > > chris wright > -- http://students.washington.edu/sblakey/ (206)297-7123 Public PGP key available at http://students.washington.edu/sblakey/public.asc From Dan at Grassi.com Sun Nov 28 14:30:04 1999 From: Dan at Grassi.com (Dan Grassi) Date: Sun, 28 Nov 1999 14:30:04 -0500 Subject: IDLE & Linux Message-ID: I am trying to get IDLE to run. The docs say that it is automatically installed but that is just not true. There is a /usr/bin/idle but when it runs it quits complaining that it can't find /usr/lib/python1.5/site-packages/idle/idle.py Of course I can not find where to get the missing files. The rpm package I have does not include this package. I am running RH 6.1 and do have TCL/TK installed. Any idea of what to do next? Dan From geoff at gnaa.net Sat Nov 13 19:06:50 1999 From: geoff at gnaa.net (geoff nordli) Date: Sat, 13 Nov 1999 16:06:50 -0800 Subject: NT admin scripts with python In-Reply-To: Message-ID: <000201bf2e34$26d93750$020a10ac@p350.gnaa.net> Excellent. I will give it a go. Does anyone know if there is a reservoir of python scripts on the net. Kind of like Perl's CPAN thanks, geoff -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org] On Behalf Of Mark Hammond Sent: Saturday, November 13, 1999 3:39 PM To: python-list at python.org Subject: Re: NT admin scripts with python Yep - the win32net module is all you need! Included in the win32all extensions... Mark. geoff nordli wrote in message <000101bf2e22$7060a190$020a10ac at p350.gnaa.net>... >Does python have a module that would allow a person to write >scripts on NT Server to lets say: create users, map drives, >modify registry, create shares, and so on. > >thanks, > >Geoff Nordli > > > -- http://www.python.org/mailman/listinfo/python-list From pmoran at nas.nasa.gov Wed Nov 3 18:08:21 1999 From: pmoran at nas.nasa.gov (Patrick J. Moran) Date: 3 Nov 1999 23:08:21 GMT Subject: NT DLL modules and C++ References: <002701bf2609$38622320$3acbd9c2@peridot.optichrome.com> Message-ID: <7vqf95$5rg$1@sun500.nas.nasa.gov> In article <002701bf2609$38622320$3acbd9c2 at peridot.optichrome.com>, "Adrian Eyre" writes: |> > How do I get Python to call the initialization under NT? |> |> This should do the trick (for module spam.dll): |> ... I should clarify a bit. I have an initFOO() call for my FOO module, and it gets called just fine. I can manually call "placement new" constructors on the static data members of my classes to initialize them, but it's awkward and a hack. It's also not a complete solution because there may be other static objects that belong to libraries whose implementation I'm not familiar with, e.g., iostreams. There's got to be a better way. My understanding is that there is an entry point, _DllMainCRTStartup, that the linker generates that calls the necessary C++ constructors, and then calls DllMain. So, the good news is that I could call _DllMinCRTStartup and the appropriate construction code would be called, assuming I figure out the arguments required by _DllMainCRTStartup. The bad news is that _DllMainCRTStartup calls DllMain, the entry point provided by the user (or the Python library, I presume). DllMain in turn calls my initFOO (again, I presume) so I would be in an infinite loop. Of course I could think of hacks to prevent the infinite looping. Still, there's got to be a better way. The solution that I'm looking for is to get Python to call the constructor code when it does the dynamic linking. I think this means calling _DllMainCRTStartup rather than DllMain. I've tried looking through the doc in the PC directory, but it's still unclear to me. That's what I was looking for help with. Thanks. Pat From Friedrich.Dominicus at inka.de Mon Nov 29 02:35:29 1999 From: Friedrich.Dominicus at inka.de (Friedrich Dominicus) Date: Mon, 29 Nov 1999 08:35:29 +0100 Subject: Recursion? References: <38421570.9C3D9AEC@videotron.ca> Message-ID: <38422CC1.7DB0B37B@inka.de> Pierre-Yves Cloutier wrote: > > Can I use recursion in python? Yes. Regards Friedrich From kent at tiamat.goathill.org Tue Nov 30 17:03:06 1999 From: kent at tiamat.goathill.org (Kent Polk) Date: 30 Nov 1999 22:03:06 GMT Subject: Missing_cmp (was Re: '==' vs. 'is' behavior) References: <382C2C6A.64A8F2C2@theriver.com> <14380.12036.197083.409565@weyr.cnri.reston.va.us> <8E7F86267duncanrcpcouk@news.rmplc.co.uk> <015301bf3b0a$685a3fc0$f29b12c2@secret.pythonware.com> <3dbt8bhhje.fsf@amarok.cnri.reston.va.us> Message-ID: <943998076.939362@fezzik.endicor.com> On 30 Nov 1999 15:05:09 -0500, Andrew M. Kuchling wrote: ) At the time I thought the Python comparison was a bit >odd, and didn't really see the point. Python is more like a >collection of tiny interacting modules; no one module is very >complicated, but put them together and they intermesh and interweave >in a beautiful way over time. [1] Over time the modules fall together >in slightly different patterns, and, though the difference between >iterations is slight, the resulting shift can completely change the >effect of the whole piece. Speaking of weaving Python module comparisons together... The module Missing, which provides a placeholder mechanism for missing data (one of Jim's ExtensionModules for Zope) has some interesting cmp behavior: >>> import Missing >>> b=[5,Missing.Value,0,-3,'c',Missing.Value,0,4,'a',Missing.Value, 'b',Missing.Value,6] >>> b.sort() >>> b [-3, 5, Missing.Value, 0, Missing.Value, 0, 4, Missing.Value, Missing.Value, 6, 'a', 'b', 'c'] As you can see, inserting a Missing.Value before a zero in a list causes problems with numeric compares. Note that Missing.Values currently evaluate to 0, and the current compare method for Missing objects is: static int Missing_cmp(Missing *m1, Missing *m2) { return m1->ob_type != m2->ob_type ; } which always returns 1 on failure. This leads to evaluating 5 as less than Missing.Value under certain circumstances. A better solution would be to always return -1 on failure so that Missing.Value evaluates to less than any object greater than zero, as in: [-3, Missing.Value, Missing.Value, Missing.Value, 0, 0, 4, 5, 5, 'a', 'c'] My question is whether this is the desired behavior or not... Should Missing.Value really be ordered as equal to zero or should it be less than other object types? I suspect that if it evaluates to a non-zero value, problems might ensue with how people handle no data, so I suppose this should be sufficient behavior. However, is there any way for Missing.Value to evaluate to zero, yet have the compare function order Missing.Values as less than other object types? (ha) Thanks From philh at vision25.demon.co.uk Wed Nov 24 16:10:52 1999 From: philh at vision25.demon.co.uk (Phil Hunt) Date: Wed, 24 Nov 99 21:10:52 GMT Subject: RDF/RSS References: <943225647snz@vision25.demon.co.uk> Message-ID: <943477852snz@vision25.demon.co.uk> In article <943225647snz at vision25.demon.co.uk> philh at vision25.demon.co.uk "Phil Hunt" writes: > As part of my Comuno website, I am creating an RDF file so that other > sites can link to my changing content. I have written some software > to handle RDF (written in python of course), and will be releasing it > under an open source license in the not-too-distant future, i.e. > when I have got it to produce HTML. I was going to call this Python Site Summary, or "pyss" for short, but then decided perhaps that wasn't appropriate. Looks like I'll have to think up a better name. (Or perhaps someone at the UK Python London meeting this Saturday[1] will come up with one.) [1] 7:30 pm, at Bier Rex in Putney, with is located on Putney High Street, 100 m south of Putney bridge, opposite the cinema. All are welcome. We'll have a plastic snake with us, so you can tell who we are. Email me for further details -- see address in my .sig. -- Phil Hunt - - - phil at comuno.com Want to see the FAQs for your favourite newsgroups? Read them on the web with Comuno's FAQ server at http://www.comuno.com/faq/ From thomas at bibsyst.no Mon Nov 1 04:33:56 1999 From: thomas at bibsyst.no (Thomas Weholt) Date: Mon, 01 Nov 1999 10:33:56 +0100 Subject: Need Berkley DB!! Message-ID: <381D5E84.98931682@bibsyst.no> Hi, After I spent most of my weekend trying to get Berkley DB to work with Python on my Linux ( Suse 6.1) machine, I`ve now given up completly. I`ve tried to install DB.1.85. and DB.2.7.7, neither worked, either crashing under installation ( which of course, is not Python related ) or when I tried to test the installation with the examples in the documentation ( the wrapper for the 2.7.5-module listed at www.python.org, under modules, databases ). Puh!! I really need some database, cuz` dumbdbm seem to be ineffecient ( both on size and speed ) when I did some serious testing. My question is ; is there another database-module/dist. I can use with Python which is platform-independant ( and perhaps easier to get to work ) or is there a Python version available with built-in Berkley DB-support ( libs and all, no more installation needed )?? I know the win32all.exe stuff and Python for Windows seem to have these things built in but I really don`t want to go back to programming in Windows again, even if it is using Python. Any ideas?! I really need help on this one. Best regards, Thomas Weholt From gmcm at hypernet.com Wed Nov 3 22:03:21 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 3 Nov 1999 22:03:21 -0500 Subject: How does rexec work? In-Reply-To: <3820C73B.9278E532@mincom.com> Message-ID: <1270437901-37926349@hypernet.com> John Farrell writes: > I'm confused about rexec and how it works. Aren't we all. > Consider the following > code: --- import rexec, traceback > > renv1 = rexec.RExec() > renv1.r_exec('import string') > print renv1.r_eval("string.upper('This is a test')") > > try: > renv2 = rexec.RExec() > renv2.r_import('string') > print renv2.r_eval("string.upper('This is a test')") > except: > traceback.print_exc() > ---- > The things I don't understand are: > > (a) In the renv1 example, where does the name string get > preserved > to be available in the eval? The relevant code from rexec is > included below, but I don't see how the self.modules dict gets > into the __main__ namespace. It doesn't. "renv1.r_exec('import string')" binds the module string to the name "string" in renv1's __main__. __main__ is a mutable object, stored in renv1.modules. So it's available to your "renv1.r_eval(...)". Looks like renv1.modules plays the same role here that sys.modules plays normally. That is, if a module has been imported somewhere, it's in sys.modules. You still need to import it in other modules, but those imports are nearly free. > (b) Why doesn't r_import work like r_exec('import ...')? What's > it > supposed to do then? r_import is like __import__, not like the keyword import. It returns the module. mod = renv2.r_import('string') renv2.modules['__main__'].string = mod > I guess part of my problem is that I am not 100% familiar with > the Python namespace fiddling stuff yet. Thanks for any help! That'll teach you to dive in the deep end! - Gordon From mikael at isy.liu.se Fri Nov 5 04:10:32 1999 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 05 Nov 1999 11:10:32 +0200 (MET) Subject: ~ 1 = -2 ??? In-Reply-To: Message-ID: On 05-Nov-99 Les Schaffer wrote: > i am doing some bit operations, and dont understand the following: > > >>> ~ 1 > -2 > > huh???? i would have thought that bitwise invert of 1 would be > > 0001 --> 1110 = 13 (base 10) > > what marble am i missing? Hmmm, I always thought that 1110 binary would be 14 in base 10. Then it makes sence, since 14 and -2 are equivalent mod 16 (4 bits). /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: 05-Nov-99 Time: 11:08:02 This message was sent by XF-Mail. ----------------------------------------------------------------------- From python-list at teleo.net Sat Nov 6 12:04:41 1999 From: python-list at teleo.net (Patrick Phalen) Date: Sat, 6 Nov 1999 09:04:41 -0800 Subject: making the Python case to my dept. In-Reply-To: <3823FC43.CF7FBD71@python.net> References: <9911051740130D.02530@william.jinsa.org> <3823FC43.CF7FBD71@python.net> Message-ID: <99110609085702.02970@quadra.teleo.net> [Thomas A. Bryan, on Sat, 06 Nov 1999]: :: William Ahern wrote: :: :: > Could anybody suggest some substantive info to make the case (or not make it). :: > Also, the department will need an IDE (Win95/Mac), so if anybody knows where to :: > find one.... [snip well-reasoned, even-handed answer] Since this is a FAQ, I'd vote for preserving Thomas' answer somewhere on the python.org Web site, so people could point to the URL when the question comes up again. From eggert at twinsun.com Sat Nov 13 00:31:29 1999 From: eggert at twinsun.com (Paul Eggert) Date: 12 Nov 1999 21:31:29 -0800 Subject: Comparison between Python and "Ruby" References: <1270663667-24391282@hypernet.com> <381ED7A6.D7D7FB13@compaq.com> <877lk1wiij.fsf@ev.netlab.co.jp> <19991102154543.A4469@optiplex.palga.uucp> <381F9EB4.63FA033F@python.net> <199911031734.JAA15489@hermes.aspectdv.com> Message-ID: <80it3h$3d2$1@green.twinsun.com> Jim Althoff writes: >Absolutely right. Part of the original dream of the Smalltalk development >team was to build a programming language/environment that would be so >easy that anybody -- even kids -- could use it. Kids? Kids?? You think _kids_ were the target!? No way. The PARC developers were much more ambitious than that. Smalltalk's design goal was to be so easy that even _secretaries_ could use it. From gawron at obop.com.pl Mon Nov 15 08:24:22 1999 From: gawron at obop.com.pl (=?iso-8859-1?Q?Przemys=B3aw?= G. =?iso-8859-1?Q?Gawro=F1ski?=) Date: Mon, 15 Nov 1999 14:24:22 +0100 Subject: Binary search Message-ID: <38300986.E734E9E2@obop.com.pl> I read somewhere that Python has a build in binary search. How can I use it ? -- Przemyslaw G. Gawronski UIN:8358522 mailto:gawronskip at usa.net mailto:gawron at obop.com.pl From hildeb at www.stahl.bau.tu-bs.de Sun Nov 28 10:46:10 1999 From: hildeb at www.stahl.bau.tu-bs.de (Ralf Hildebrandt) Date: 28 Nov 1999 15:46:10 GMT Subject: fcntl/ioctl and O_NONBLOCK References: <81ml5t$eer$0@216.39.151.169> <81p32a$m14$1@216.39.151.169> <38407496$0$222@nntp1.ba.best.com> Message-ID: On 28 Nov 1999 00:17:26 GMT, Cove Schneider wrote: >> This is also fixed now, but now the popen3 Object generates about 1 MB >> of output (which I read using select() and read()), and then it STILL >> doesn't return. No crash, no exit. And once more, in top it says >> "sleep" once more. >> Any ideas what's going on there? > >Humm.. Sounds like your not checking for an EOF.. Good idea. When I read the input file (which I then tochild.write()), I get only 1000 bytes - althought the file is much longer. Question: Is it possible to read OVER an EOF? How? From gmcm at hypernet.com Sun Nov 21 14:17:16 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Sun, 21 Nov 1999 14:17:16 -0500 Subject: Order of keyword arguments In-Reply-To: <38382DA7.A03A2023@corrada.com> Message-ID: <1268910662-35645762@hypernet.com> Andres Corrada wrote: > Gordon McMillan wrote: > > > > Ah, but that would be "alphabetical order", not "entry order", > > and not much use to anybody if it were. > > > > I disagree. I think you are confusing entry order with type of > ordering. entry order could be alphabetical but it could also be > by time of entry, for example. My point still stands: an ordered > dictionary would be a useful data structure to have. Well I'm feeling amiably disagreeable too, so I'll differ with that. A "dictionary" in the wider-than-Python sense has an ordering to it that is based on it's keys. The order of arguments to a function is _not_ an ordering based on the argument names; ergo, the existence of an American Heritage Dictionary gets you no closer to your goal (in this sense, at least). What you're apparently arguing for is an ordered dictionary. What you _want_ is an indexed list. > > Python data structures that would suit your apparent desires: > > [ (optionname, optionvalue), ... ] > > Mike Fletcher suggested this also and it is the way I'm getting > to eat my cake and have it too :-) bon-apetit-ly y'rs - Gordon From phd at phd.russ.ru Sat Nov 13 09:06:15 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Sat, 13 Nov 1999 14:06:15 +0000 (GMT) Subject: Production Web Deployment? In-Reply-To: <382D68D3.46CEFD61@digicool.com> Message-ID: On Sat, 13 Nov 1999, Paul Everitt wrote: > Seems nobody in the Zope community is eager to maintain > an Apache module. :^) I've started to write mod_pcgi2. I don't want to use mod_fastcgi, as it is incompatible with Russian Apache (special patch for Apache to recode different charsets on the fly). I need virtual hosting, but didn't find a way to extend AMK's mod_pcgi, so I started to write new module from scratch. It seems I'll spend quite a lot of time, though :( Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From mhammond at skippinet.com.au Sun Nov 28 18:55:26 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 28 Nov 1999 23:55:26 GMT Subject: Python and COM: a bug? References: <816010E2456BD111A48700805FBBE2EEFDF831@ex-quebec-u1.baan.com> Message-ID: Toby Dickenson wrote in message ... >Not quite. Clients are only allowed to cache the ID for use with that >one object. DISPIDs are allowed to be different between instances of >one class, just not during the lifetime of one object. > >From what you have described (if I understand correctly) then you >should be ok???????? Yes - you are correct, and I believe this is indeed the problem. win32com needs to be fixed here. Thanks, Mark. From boud at rempt.xs4all.nl Fri Nov 19 04:45:13 1999 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: Fri, 19 Nov 1999 10:45:13 +0100 (CET) Subject: Beginning programming with Python In-Reply-To: <00ef01bf3271$10a8bb90$f29b12c2@secret.pythonware.com> Message-ID: On Fri, 19 Nov 1999, Fredrik Lundh wrote: > Boudewijn Rempt wrote: > > I tend to forget the colons after function and class definitions and > > everywhere else and the double == in if's - mainly because, for the life > > of Brian, I can't see why they are there. It seems to me the language > > would be just as easily parseable and readable without this bit of > > interpunction. > > guess you weren't part of the CWI design team -- they > did test this on humans, you know, and discovered that > the language wasn't as easily parseable and readable > without the colons... > You needn't guess about that, I guess ;-). I didn't know there was a design team for Python, I though it was Guido's invention. But I still wonder about the double == - if I can't assign in an if, why insist on ==? Boudewijn Rempt | http://denden.conlang.org From hnowak at cuci.nl Fri Nov 19 01:15:18 1999 From: hnowak at cuci.nl (Hans Nowak) Date: Fri, 19 Nov 1999 07:15:18 +0100 Subject: Python in DOS Message-ID: <199911190617.HAA08663@dionysus.fw.cuci.nl> On 18 Nov 99, William Park wrote: > On Thu, Nov 18, 1999 at 06:24:25PM -0500, Curtis, Craig M. wrote: > > Does anyone know the "approved" way to get rid of the following > > message: > > > > Could not find platform dependent libraries > > Consider setting $PYTHONHOME to [:] > > 'import site' failed; use -v for traceback > > Python 1.5.2 (#6, Nov 18 1999, 17:19:05) [GCC 2.8.1] on ms-dos7 > > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > > > > > > I've tried everything I can think of to set PYTHONHOME and PYTHONPATH > > and python ALWAYS starts up this way. > > If I remember (this was long long time ago), I had to remove case > sensitivity for library files by setting some dummy environment > variable. You surely mean the PYTHONCASEOK variable. If that doesn't help, simply comment these parts out of the source code... DOS is not going to use them anyway. --Hans Nowak (zephyrfalcon at hvision.nl) Homepage: http://fly.to/zephyrfalcon You call me a masterless man. You are wrong. I am my own master. From gmcm at hypernet.com Mon Nov 1 12:00:56 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Mon, 1 Nov 1999 12:00:56 -0500 Subject: commas vs. spaces. vs. the legions of new lines In-Reply-To: <7vj35t$8p1$1@nnrp1.deja.com> Message-ID: <1270647588-25358408@hypernet.com> G. Lewis wrote: > > Geez, you peoples, quit sniping on the folks posting their little > modules lately (if i may snipe at you to say)! > > So the unix old-timers know a billion and one ways to > convert Dos to Unix text files. Why discourage someone from > making a pure python implementation... I will make the observation that one can classify Pythonistas into those who think recoding common utilities in pure Python is evil, and those who think it a worthy goal, with very few people in the middle. If you live all your life under one OS, I suppose the recoding looks like wasted effort. But if you're always switching around, or have multiple OSes on your network, having predictable pure Python versions is a delight. (As for converting Unix line endings to DOS - almost all Windows editors can handle Unix line endings.) - Gordon From gmcm at hypernet.com Wed Nov 24 19:45:21 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 24 Nov 1999 19:45:21 -0500 Subject: filter function question - list processing in Python In-Reply-To: <81ho50$g15$1@nnrp1.deja.com> Message-ID: <1268631776-5935125@hypernet.com> lobozc at my-deja.com writes: > 2. I suspect that the second part of my posting may be a valid > postulate then. Since list processing is so useful Python should > consider adding a good set of primitives to the core library - > not as an external package. A good set of primitives with intuitive interfaces and obvious names that raises lots of excitement would probably be warmly welcomed. But, I suspect, those who regularly use filter and reduce are vastly outnumbered by those who aren't sure what they do. So rabid enthusiasm may be hard to come by. all-functional-programmers-are-rabid-ly y'rs - Gordon From robin at alldunn.com Mon Nov 22 14:34:25 1999 From: robin at alldunn.com (Robin Dunn) Date: Mon, 22 Nov 1999 11:34:25 -0800 Subject: Building wxPython [was Re: wxPython and DISLIN work nicely together] References: <80s0b4$g5n@mail.psy.uva.nl> <19991117090214.B807152@vislab.epa.gov> <017a01bf31f8$6bbea590$1a25d2d1@jenkondev.com> <19991119064944.A996886@vislab.epa.gov> <002301bf32b5$97a5d440$0301a8c0@easystreet.com> <19991119134422.A1004588@vislab.epa.gov <19991122135553.A1255406@vislab.epa.gov> Message-ID: <01be01bf3520$96f29890$1a25d2d1@jenkondev.com> > Robin Dunn: > |This makes me wonder how you built wxWindows at all if these errors are in > |the wxWindows headers... What about the wxWindows sample apps, do they > |compile? > > Beats me but wxWindows worked out of the box. Well, it makes sense now that you've discovered that Python headers define NULL and wxWindows never includes Python.h anywhere except in wxPython code. > With the helpers.cpp NULL hack I just described, it got to the point of > linking wxcmodule.so, and failed trying to find wxPyHelpers: > > CC -shared -all wx.o windows.o windows2.o windows3.o events.o misc.o misc2.o gdi.o mdi.o controls.o controls2.o cmndlgs.o stattool.o frames.o image.o printfw.o sizers.o clip_dnd.o -L/home/rhh/software/wxGTK-2.1.11/utils/wxPython/src `wx-config --libs` -lwxPyHelpers -o wxcmodule.so > C++ prelinker: warning: could not locate library -lwxPyHelpers; assuming /usr/lib/libwxPyHelpers.a > ld32: FATAL 9 : I/O error (-lwxPyHelpers): No such file or directory > gmake: *** [wxcmodule.so] Error 2 > libwxPyHelpers.so is the first thing built in the wxPython/src directory. It hasn't been installed yet until you get to the build.py -i step, but it does exist in the current directory. Maybe your linker needs a "-L." ? Setting OTHERLFLAGS="-L." in build.local might help. > build.py assumes that the utils/ directory is named wxPython. I just left > it wxPython-2.1.11 since the README.txt file said "preferably...wxPython"). > > I'm also building under the wxGTK build tree's utils/ dir since I didn't > see whether wxPython expected to build under the wxGTK build or installed > trees, and under the build tree made more sense. Judging from the default > search path of -L$(WXWIN)/utils/wxPython/src for files in the wxPython > build tree (WXWIN being the wxGTK installed tree), now I'm changing my > guess. Which should it be? > By default build.py expects things to be just as they are in the CVS tree, which is $(WXWIN)/utils/wxPython/src. You can override this in your build.local by setting WXPSRCDIR like this: WXPSRCDIR = "~/MyStuff/wxPython-2.1.11/src" I've been updating the build instructions over the last few days to help people around issues like this and others. There is version as of a few days ago at http://starship.python.net/pipermail/wxpython-users/1999-November/001074.htm l, and there has also been a few more changes since then. -- Robin Dunn Software Craftsman robin at AllDunn.com http://AllDunn.com/robin/ http://AllDunn.com/wxPython/ Check it out! From hinsen at cnrs-orleans.fr Wed Nov 17 04:39:57 1999 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 17 Nov 1999 10:39:57 +0100 Subject: telnetten vanuit een script References: <19991112201259.A6212@optiplex.palga.uucp> Message-ID: Gerrit Holl writes: > Telnet moet van een terminal lezen, dus je kan expect gebruiken. Expect is > een scripting taal voor dit soort dingen; er is echter ook een python module, Juist, maar er is ook en python module voor telnet (telnetlib), en die maakt het nog eenvoudiger. Voor meer informatie: http://python.via.ecp.fr/doc/current/lib/module-telnetlib.html -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From fdrake at acm.org Fri Nov 5 11:50:39 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Fri, 5 Nov 1999 11:50:39 -0500 (EST) Subject: Drawing (directed) graphs In-Reply-To: <000e01bf27ab$5548aba0$3acbd9c2@peridot.optichrome.com> References: <19991105160912.502.rocketmail@web602.mail.yahoo.com> <000e01bf27ab$5548aba0$3acbd9c2@peridot.optichrome.com> Message-ID: <14371.2783.885109.27130@weyr.cnri.reston.va.us> Adrian Eyre writes: > This is why it annoys me that some of the scripts in the > standard Python library are not platform independent, but > rely on non-portable features of posix. If you know of ways to reduce the platform-dependence of these, please feel free to submit patches! -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From philh at vision25.demon.co.uk Mon Nov 29 20:26:17 1999 From: philh at vision25.demon.co.uk (phil hunt) Date: Tue, 30 Nov 1999 01:26:17 +0000 (GMT) Subject: Htmlizing text In-Reply-To: <19991129170705.A314@better.net> Message-ID: On Mon, 29 Nov 1999, William Park wrote: > On Mon, Nov 29, 1999 at 09:03:46PM +0000, Phil Hunt wrote: > > > > Is there a function in the standard Python library to HTML-ize text, > > i.e. to replace 'a > b & c < d' with 'a > b & c < d'? > > > > (I realize this can be done with regular expressions, but is there > > an easy way?) > > > > -- > > Phil Hunt - - - phil at comuno.com > > The following function replaces [<&>] unconditionally. > def escapeall(s): > s = string.replace(s, '&', '&') # do this first > s = string.replace(s, '<', '<') > s = string.replace(s, '>', '>') > return s > I used this in my 'HTMLtag' module which generates HTML tags. > > William. > Thanks. -- ***** Phil Hunt ***** send email to phil at comuno.com ***** Moore's Law: hardware speed doubles every 18 months Gates' Law: software speed halves every 18 months From nkauer at my-deja.com Mon Nov 1 22:11:42 1999 From: nkauer at my-deja.com (nkauer at my-deja.com) Date: Tue, 02 Nov 1999 03:11:42 GMT Subject: extension modules and multiple interpreters Message-ID: <7vlkpc$453$1@nnrp1.deja.com> I run the following test script on Apache-1.3.6/PyApache-4.19 on Linux 2.2.5 (RedHat 6.0) with only one httpd child and the module mxDateTime compiled into Python/PyApache, so there is no dynamic loading of a shared library. ------------------------------------------------------------ print "Content-type: text/plain" print print import sys, traceback # just checking ... if not sys.modules.has_key('mxDateTime'): print 'No module mxDateTime in sys.modules' print import mxDateTime print "sys.modules['mxDateTime'] = ", sys.modules['mxDateTime'] print "mxDateTime.__dict__['now'] = ", mxDateTime.__dict__['now'] print print "calling mxDateTime.now() gives:", try: print mxDateTime.now() except: print traceback.print_exc(file=sys.stdout) -------------------------------------------------------------- First time http://localhost/mytest.py gives ******************************* No module mxDateTime in sys.modules sys.modules['mxDateTime'] = mxDateTime.__dict__['now'] = calling mxDateTime.now() gives: 1999-10-28 18:28:49.75 ******************************* And again http://localhost/mytest.py now gives ******************************* No module mxDateTime in sys.modules sys.modules['mxDateTime'] = mxDateTime.__dict__['now'] = calling mxDateTime.now() gives: Traceback (innermost last): File "/local/web/alpha/docroot/mytest.py", line 16, in ? print mxDateTime.now() TypeError: call of non-function (type None) ******************************* After that experience, I eliminated all dependencies on module DateTime/mxDateTime in my Python code, but now I get the same error whenever something in module MySQLdb is accessed for the second time ... The mxDateTime author Marc Lemburg writes: "[...] indicates that PyApache (or perhaps the Python finalizer) has cleared the module's namespace... which is bad, since extension modules can typically only initialize themselves *once*." Marc writes further: "[T]his is really odd: the 'now' symbol still refers to the existing function while the module seems to return None as attribute." The PyApache coordinator Lele Gaifax writes: "I can confirm that the problem lives in the cleanup mechanism. Python clears up its dictionaries, and doesn't allow a reinit, as Marc pointed out. This is not a PyApache fault: you can get the very same result running the pysrv demo [...]. In fact, every use of such modules mixed to multiple interpreters should cause the problem." Apparently, the fact that a module works with regular Python does not guarantee that it also works with PyApache (or pysrv). Lele Gaifax writes: "[...]I cannot see a way out, if not digging in Python's internals. [D]oes someone know if the problem has been raised before in the Python community?" Please, could someone with Python internals expertise explain this issue? How can I tell in advance if an extension module will work with PyApache? Is it possible to trick Python into cleanly re-initializing a module? Is there any hope that I can run my existing Web site with the Python interpreter embedded into Apache's httpd? Nikolas Sent via Deja.com http://www.deja.com/ Before you buy. From a.eyre at optichrome.com Fri Nov 5 08:36:09 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Fri, 5 Nov 1999 13:36:09 -0000 Subject: Drawing (directed) graphs In-Reply-To: <3823f33e.11772788@news.demon.co.uk> Message-ID: <000a01bf2792$b83ff150$3acbd9c2@peridot.optichrome.com> > Good thing there is a platform independent Python graphics library! How can there be. Some OSs (Minix) don't support graphics at all... -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From jblazi at netsurf.de Tue Nov 16 12:57:48 1999 From: jblazi at netsurf.de (Janos Blazi) Date: Tue, 16 Nov 1999 18:57:48 +0100 Subject: Beginning programming with Python References: <382B3A53.5816B2@callware.com> <382B3D79.74CD3E0F@email.sps.mot.com> <80p9ds$ppo$1@newshost.accu.uu.nl> <38312D55.A36EB56D@iqsoft.hu> <19991116173142.A31379@optiplex.palga.uucp> Message-ID: > the less time it costs to program it, the more time it costs to run it, > the more time it costs to program it, the less time it costs to run it. Is this some law of nature I missed at university? But obviously, as far as raw speed is concerned Python cannot compete with C. Nobody can attempt to deny that. So if speed is an issue for you, use C. Or even assembly language. If you do not like Python, use C anyway. Why not? Actually I do not care. Janos Blazi From prestonlanders at my-deja.com Tue Nov 30 16:22:12 1999 From: prestonlanders at my-deja.com (Preston Landers) Date: Tue, 30 Nov 1999 21:22:12 GMT Subject: Removing null items References: <821761$s8u$1@nnrp1.deja.com> Message-ID: <821f5u$2m5$1@nnrp1.deja.com> While not especially ingenious, this method does modify the list in place, and is different. Well, only in the sense that it is basically the equivelent inverse of what you did. ;-) def remove_false_from_list(the_list): for item in the_list: if not item: the_list.remove(item) return the_list ---Preston In article <821761$s8u$1 at nnrp1.deja.com>, sragsdale at my-deja.com wrote: > So I've got a very simple desire: to remove all false (I.E. None, 0, '', > []) items from a list. > > As it is I've got this function which works fine, but it offends my > sight. Is there any better (or at least different) way to do this? > > ################################################################# > # return non-null items from the first list > def foo(lst): > rlist = [] > for i in lst: > if i: > rlist.append(i) > return rlist > > Sent via Deja.com http://www.deja.com/ > Before you buy. > -- || Preston Landers || Sent via Deja.com http://www.deja.com/ Before you buy. From mikael at isy.liu.se Mon Nov 15 08:49:11 1999 From: mikael at isy.liu.se (Mikael Olofsson) Date: Mon, 15 Nov 1999 15:49:11 +0200 (MET) Subject: [Python] header (fwd) In-Reply-To: <002a01bf2f75$85166620$3acbd9c2@peridot.optichrome.com> Message-ID: On 15-Nov-99 Adrian Eyre wrote: > > Huh? I filter (in Pegasus mail) on "python-list@" in To: and > > CC: and get them all. > > I filter "From:" for "python-list-admin at python.org" > > Does that not work? Are you sure you don't mean "Sender:" instead of "From:"? I, at least, get the actual author at "From:", and "python-list-admin at python.org" at "Sender:". email-is-magic-ly y'rs /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: 15-Nov-99 Time: 15:45:29 This message was sent by XF-Mail. ----------------------------------------------------------------------- From xtian_the_great at hotmail.com Mon Nov 1 19:26:32 1999 From: xtian_the_great at hotmail.com (Xtian Muirhead) Date: Tue, 2 Nov 1999 13:26:32 +1300 Subject: dynamically generating function assignent References: <51C9F3C392D0D111A15600A0C99E64A9AF5605@localhost> Message-ID: <7vlb70$95njn$1@titan.xtra.co.nz> Bjorn Pettersen wrote in message news:51C9F3C392D0D111A15600A0C99E64A9AF5605 at localhost... > You can do: > > fn = eval('func_' + 'a') # look it up in the environment > fn() > > -- bjorn > > > -----Original Message----- > > From: anantk at my-deja.com [mailto:anantk at my-deja.com] > > Sent: Monday, November 01, 1999 11:19 AM > > To: python-list at python.org > > Subject: dynamically generating function assignent > > > > > > Hi, > > > > Here is my problem. I have defined say 12 pairs of functions > > > > func_a() > > parse_func_a() > > > > func_b() > > parse_func_b() > > . > > . > > func_l() > > parse_func_l() > > > > A file contains a series of strings which are the names of these > > functions eg: > > > > a > > c > > f > > b > > > > Now for each of these strings I need to call the two functions > > func_(), and parse_func_(), where is the name of > > the function > > that string refers to. > > > > I know you can do something like > > call = func_a, and call effectively gets assigned to func_a. My > > question is how can I generate the RHS of this assignment dynamically? > > So that all I have to do is > > > > = > > call1 = func_ > > call2 = parse_func_ > > call1() > > call2() > > > > Any help would be appriciated. > > > > Thanks > > > > -- Anant Another way would be to load all the functions into a dictionary. e.g: def func_1(): def parse_func_1(): ... functions = {'1':(func_1,parse_func_1), 'a':(func_a, parse_func_a), ...} Then you could look up call1 and call2: call1, call2 = functions[valueFromFile] call1() call2() This could be easier to catch cases where the value from the file doesn't match any of the functions defined. (And I prefer this kind of static lookup to a dynamic lookup. That's just a bias, I guess. Suffice it to say that both of these ways are nicer than a whole heap of elifs. (I guess if you had hundreds of these functions, you wouldn't want to have to type out all of them in a dictionary (with the attendant likelihood of making an error).)) Xtian xtian at regurgitator.zzn.com "Most people don't realise that large pieces of coral, which have been painted brown and attached to the skull by common wood screws, can make a child look like a deer." From sekter at mail.matav.hu Mon Nov 15 08:10:05 1999 From: sekter at mail.matav.hu (Arpad Kiss) Date: Mon, 15 Nov 1999 14:10:05 +0100 Subject: PIL 1.0 on win32? References: <009b01bf2f5e$fef3b900$029f38c3@geometria.hu> <01ee01bf2f61$96097a80$f29b12c2@secret.pythonware.com> Message-ID: <004701bf2f6a$bd67f990$029f38c3@geometria.hu> Fredrik Lundh wrote: > Arpad Kiss wrote: > > I have a PIL based Zope product I have been developing on a Linux box. I > > just wanted to test it on a Windows NT(sp5), but it doesn't work.:-( > > At first it didn't recognize my fonts, because the readline method on win32 > > returns 10+13 at the end of the lines and in ImageFont.py only \n is > > checked. > > PIL opens the font files in binary mode, so this > shouldn't be a problem. you probably messed > something up when you transferred the font > files to the PC... I have created a .tar.gz then extracted it with WinZip. > > > After I solved it I got an error message(memory error in line 151 of > > ImageDraw.py) when I wanted to draw some text. > > When I commented out the text drawing code in my program, then I got back a > > picture, but it is mirrored! > > this sounds really weird -- but at least the > memory error might be due to bogus font data... Ok. I will try to replace my fonts. > > what win32 build do you use? can you post some > code? Python1.5.2 and pil-win32-991101.zip I will write a minimal example. > > > Of course on linux box my program works fine. > > I just want know who else use PIL 1.0 on win32 and what experiences they > > have. Should this text drawing function work? Is it my fault? > > fwiw, PIL is being developed on win32... Maybe a minimal example(without Zope) can help me, if cannot then I'll post it. Thanks, Arpad From anantk at my-deja.com Mon Nov 1 13:19:02 1999 From: anantk at my-deja.com (anantk at my-deja.com) Date: Mon, 01 Nov 1999 18:19:02 GMT Subject: dynamically generating function assignent Message-ID: <7vklii$crc$1@nnrp1.deja.com> Hi, Here is my problem. I have defined say 12 pairs of functions func_a() parse_func_a() func_b() parse_func_b() . . func_l() parse_func_l() A file contains a series of strings which are the names of these functions eg: a c f b Now for each of these strings I need to call the two functions func_(), and parse_func_(), where is the name of the function that string refers to. I know you can do something like call = func_a, and call effectively gets assigned to func_a. My question is how can I generate the RHS of this assignment dynamically? So that all I have to do is = call1 = func_ call2 = parse_func_ call1() call2() Any help would be appriciated. Thanks -- Anant anantk at yahoo.com Sent via Deja.com http://www.deja.com/ Before you buy. From fredrik at pythonware.com Thu Nov 18 05:33:03 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 18 Nov 1999 11:33:03 +0100 Subject: __str__ vs. __repr__ References: <000001bf275c$02370d20$1d2d153f@tim> <7vvni7$19q0$1@nntp6.u.washington.edu> <382BEC79.EC65913D@maxtal.com.au> <382C6430.8DC07E3E@lemburg.com> <01fd01bf2dce$d2c03cf0$f29b12c2@secret.pythonware.com> <942499879snz@vision25.demon.co.uk> <942717443snz@vision25.demon.co.uk> Message-ID: <012f01bf31b0$50570ab0$f29b12c2@secret.pythonware.com> Phil Hunt wrote: > How about: > > x = a + b + c > x = (a + b) + c > x=a+b+c > > I'd guess these all produce the same bytecode. footnote: the abc80 computer I mentioned in my earlier post had an extra byte code for this purpose. users can buy that you add spaces and reformat their code, but they won't accept that you remove their parentheses... > I'd also not be surprised if you could consistently change the > name of a local variable within a function without changing bytecodes, > i.e. Python internally doesn't know the names of local variables. print myfunction.func_code.co_names From fredrik at pythonware.com Sat Nov 13 06:55:17 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 13 Nov 1999 12:55:17 +0100 Subject: Random text generator References: <199911120349.OAA01177@envy.fulcrum.com.au> Message-ID: <01e101bf2dcd$f4bb6290$f29b12c2@secret.pythonware.com> Magnus L. Hetland wrote: > > The function you want is whrandom.choice(). See > > Or - rather, random.choice() (which uses whrandom.choice, if > available)... No? it would probably be a bit clearer (at least to newcomers) if "random" is was the official interface, and whrandom was treated as an implementation module. but it doesn't look that way in the current version of the library reference... (and the eff-bot guide is obviously wrong on this one. not sure I'll add that to the errata, though ;-) From kuncej at mail.conservation.state.mo.us Fri Nov 5 11:02:13 1999 From: kuncej at mail.conservation.state.mo.us (Jeffrey Kunce) Date: Fri, 05 Nov 1999 10:02:13 -0600 Subject: Python Conference Hotel Change Message-ID: GVR>...a 15 minute walk across the bridge to historic Georgetown ... AR>... but isn't it an even shorter stroll from there to Bardo ... What a hearty lot, these Pythoneers! Others might find these mid-winter perambulations a bit chilly. :-) --Jeff From morse at harborcom.net Tue Nov 9 08:03:18 1999 From: morse at harborcom.net (Kevin Dahlhausen) Date: Tue, 09 Nov 1999 13:03:18 GMT Subject: Stackless python progress? References: <38274626.5D8C1EC2@ptway.com> Message-ID: <38281b64.88310413@news.oh.verio.com> I must confess I don't know this, but what is the advantage of stackless Python? Are you referring to the byte-code interpreter? Brian Haskin wrote: >Just wondering if the work on stackless python is still progressing and >if it looks like it will be integrated into the regular distribution in >the foreseeable future? also has there been any work on combining >'microthreading' and the stackless stuff? > >Brian Haskin From jfarrell at mincom.com Wed Nov 3 18:37:31 1999 From: jfarrell at mincom.com (John Farrell) Date: Thu, 04 Nov 1999 09:37:31 +1000 Subject: How does rexec work? Message-ID: <3820C73B.9278E532@mincom.com> I'm confused about rexec and how it works. Consider the following code: --- import rexec, traceback renv1 = rexec.RExec() renv1.r_exec('import string') print renv1.r_eval("string.upper('This is a test')") try: renv2 = rexec.RExec() renv2.r_import('string') print renv2.r_eval("string.upper('This is a test')") except: traceback.print_exc() ---- The things I don't understand are: (a) In the renv1 example, where does the name string get preserved to be available in the eval? The relevant code from rexec is included below, but I don't see how the self.modules dict gets into the __main__ namespace. (b) Why doesn't r_import work like r_exec('import ...')? What's it supposed to do then? I guess part of my problem is that I am not 100% familiar with the Python namespace fiddling stuff yet. Thanks for any help! John ---- # Add a module -- return an existing module or create one def add_module(self, mname): if self.modules.has_key(mname): return self.modules[mname] self.modules[mname] = m = self.hooks.new_module(mname) m.__builtins__ = self.modules['__builtin__'] return m # The r* methods are public interfaces def r_exec(self, code): m = self.add_module('__main__') exec code in m.__dict__ def r_eval(self, code): m = self.add_module('__main__') return eval(code, m.__dict__) ---- From evan at tokenexchange.com Sat Nov 6 00:04:01 1999 From: evan at tokenexchange.com (Evan Simpson) Date: Fri, 5 Nov 1999 23:04:01 -0600 Subject: making the Python case to my dept. References: <9911051740130D.02530@william.jinsa.org> Message-ID: <7GOU3.272$Ae3.194028@news-dal.corridex.com> William Ahern wrote in message news:9911051740130D.02530 at william.jinsa.org... > I have never used Python, but I'm currently attempting to persuade a department > at my university (Geroge Washington) to use Python as an intro language. I have > read that it was good for this. From what I hear, the current options on the > table are Delphi and Java. I don't know much about Delphi, but I doubt Java is > any good for intro classes. Well, I don't know much about Java, but I've been a professional Delphi programmer for about five years now. Up until a year and a half ago, I'd have said that Delphi would be fine for your purposes. Then I learned Python :-) Now I'm preparing to introduce my children to programming through Python. I'm starting with their fascination with Alice, the 3-D animation workshop which even my 6 year old enjoys playing with (though he doesn't script it... yet). Cheers, Evan @ 4-am From dirkl at home.com Mon Nov 8 04:32:40 1999 From: dirkl at home.com (Dirk Leas) Date: Mon, 8 Nov 1999 02:32:40 -0700 Subject: Production Web Deployment? In-Reply-To: <199911080604.BAA22580@python.org> Message-ID: I've read numerous threads regarding how to deploy Python on the web and there appears to be no real consensus on what actually performs/scales well (about 3M hits/month). Is anybody taking lots of hits with httpdapy, PyApache, ASP+Python, fastcgi, or Zope? I've got a customer who's development staff is struggling with the complexity of Java Servlets and they're already using a large 3rd party, vertical Python application (and several folks already use Python). Peliminary testing showed plain CGI was just too slow... Thanks, D From nemeth at iqsoft.hu Thu Nov 4 04:21:20 1999 From: nemeth at iqsoft.hu (Németh Miklós) Date: Thu, 04 Nov 1999 10:21:20 +0100 Subject: Extending Python dynamically Message-ID: <38215010.DCFCDBFA@iqsoft.hu> Dear Pythoners, I have downloaded DCOracle extension. I have RH6.0, and (at least until now) I have not installed the source distribution of Python. I have installed only the binary RPMs. I unpacked DCOracle in a directory and managed to build the so files (Buffer.so and oci_.so). How to install then this DCOracle package? I have been trying to figure out but no success. I have read ext.pdf (Extending Python with C or C++). As far as I understood (by reading chapter 2), I have to recompile my Python interpreter, and have to relink the interpreter against this DCOracle shared objects. Does Python not support a more dynamic extension mechanism (based on dlopen())? If I want to add an extension in C, shall I always recompile/relink my Python interpreter? Perl (via XS) and Apache (via mod_so) supports a kind of dynamic loading mechanism I'd like to have. Can anyone help me how to get this DCOracle work on my system? Miklos Nemeth IQSOFT PS: I am quite new to Python, but an experienced OO (C++, Java) programmer. I was amazed by Python as a language. Now I am evaluating Python to determine the quality/applicability of the facilities necessary for my daily works (such as Oracle7 database access, CORBA (over SSL is preferred) support, extendability, GUI support, etc.), which mainly are mission critical business applications. I have also started evaluating Zope. After the first two hours I found Zope is a fantastic product, I am curious about how people did dare implement a so complex application (ie. an application server) in an interpreted "scripting language". These type of software pieces are implemented in C (Apache, AOLserver), C++ (BroadVision). So I decided I learn Python and assemble a development environment for Python programming. NM From fredrik at pythonware.com Mon Nov 8 17:48:04 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 8 Nov 1999 23:48:04 +0100 Subject: Image buttons with Tkinter References: <38270596.A391995C@parlant.com> Message-ID: <01fd01bf2a3b$52cbd3b0$f29b12c2@secret.pythonware.com> Thomas Lane wrote: > I'm trying to create a button that displays an image instead of text, > but I don't seem to be having any luck. The button just comes up gray. see: http://www.python.org/doc/FAQ.html#4.69 4.69. Images on Tk-Buttons don't work in Py15? From marco.musazzi at sofositalia.it Fri Nov 5 15:48:57 1999 From: marco.musazzi at sofositalia.it (Marco Musazzi) Date: Fri, 5 Nov 1999 21:48:57 +0100 Subject: Template for CGI References: Message-ID: <7vvfpl$o2a$1@pluto.sm.dsi.unimi.it> >On Tue, 2 Nov 1999, Glenn Kidd wrote: >> I am a newbie to Python and I have a question. I want a CGI script that >> will read a file template and replace certain words with variables. Ii >> tried putting the variable names in the file but it is read as palin text. >> Is there a way to embed variables into a teplate or a replace function in >> Python? Thank you for any help you give. You can use something like this: template file: your template text your template text %variable% your template text %variable2% %xxx% is the placeholder for "variable" xxx (you can replace % with what you like) in your python code: import string template = open("yourtemplatefile") templateText = template.read() template.close() templateText = string.replace(templateText, "%variable%", str(value_of_variable)) templateText = string.replace(templateText, "%variable2%", str(value_of_variable2)) # an so on.... # printing a minimal http header print "Content-type: text/html" print # printing the template filled with the variables print templateText You can do it better using a value-filled dictionary: val = {"variable":value1, "variable2":value2, etc...... } # you may read this dict from a shelv db for example... for k in val.keys(): templateText = string.replace(templateText, "%"+ k + "%", val[k] ) # printing a minimal http header print "Content-type: text/html" print # printing the template filled with the variables print templateText And you can use both the mothods at the same time... happy coding Marco From neelk at brick.cswv.com Tue Nov 9 20:17:08 1999 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 10 Nov 1999 01:17:08 GMT Subject: __str__ vs. __repr__ References: <000401bf25b9$88ea57e0$2e2d153f@tim> <199911040157.UAA11908@eric.cnri.reston.va.us> <046101bf26d4$2dd1a720$01ffffc0@worldnet.att.net> Message-ID: Emile van Sebille wrote: > >It seems to me that issues arise when using the interactive interpreter. >I suspect that little useful work is done in this mode, and is used >predominately for quick testing while creating python programs. I'd like to politely disagree . Combined with Tim Peters and Barry Warsaw's emacs py-mode, Python's interactive mode is the single most useful feature of the language for me. With it, I can test each and every method, loop, and statement as I code. This does wonders for my understanding of my code. And not incidentally, reliability goes way up as well. I learned Perl before Python, but my Python skill surpassed my Perl skill after a much smaller time investment. I lay this pretty much wholely at the feet of the interactive interpreter -- I could find out the answers to puzzles without a tedious edit-save-run cycle. Neel From ionel at psy.uva.nl Tue Nov 2 17:32:29 1999 From: ionel at psy.uva.nl (Ionel Simionescu) Date: Tue, 2 Nov 1999 23:32:29 +0100 Subject: Drawing (directed) graphs References: Message-ID: <7vnop8$bqt@mail.psy.uva.nl> R.M.Everson wrote in message news:ye1bt9das2p.fsf at ex.ac.uk... | Does anyone know of Python code for drawing graphs of the | graph-theoretic type? Ideally, I'd like to be able to interactively | add nodes and edges etc and add data to structures associated with the | nodes and edges. | The closest library I know is OGL - Object Graphics Library, which comes with wxPython 2.1.5. ( http://alldunn.com/wxPython/ ). You can draw graphical objects of various shapes and connect them with lines or splines. You can derive new objects easily, define connection points, nest the shapes, resize objects. A problem is that you need to do some (maybe, much) of the layout yourself. You get some support from composite shapes which are able to manage a given layout, but there's still a lot of work to do for getting close to something like graphviz. ionel ------ extract from: http://web.ukonline.co.uk/julian.smart/wxwin/contrib/ogl/ogl.htm Features of OGL A range of predefined shape classes, such as wxRectangleShape, wxPolygonShape, wxEllipseShape. Multiline and spline wxLineShape connecting node shapes: the arcs move with the nodes. Arcs join neatly at the perimeter of shapes. Arcs can either join at attachment points or as if connected to the centre of the node. Resizing handles. Multiple text regions for complex shapes. Divided rectangles: rectangles with an arbitrary number of vertical divisions. Composite shapes. Simple 'metafile' shapes which can be resized and rotated. Bitmap shapes. wxDiagram class manages a list of shapes, and implements input/output. ---------------------------------------------------------------------------- ---- The relationship between OGL and Hardy OGL is the core graphics code for Hardy, a meta-CASE tool written with wxWindows. There are various features that Hardy implements over and above the OGL functionality, including a symbol library, node and arc symbol editors, attachment point editor, junction node functionality, and various editing facilities. It is possible that contributors could extend OGL to encompass these areas in future. From nikolai.kirsebom at siemens.no Fri Nov 5 04:58:58 1999 From: nikolai.kirsebom at siemens.no (Nikolai Kirsebom) Date: Fri, 05 Nov 1999 09:58:58 GMT Subject: Accessing Word object model from Python COM server Message-ID: <3822a7d2.251040356@news.mch.sni.de> I'm using a Python COM server when testing a VBA (Word97) system. I would like to be able to access the Word object model from the methods in the COM server. Does anyone know how this can be done. I would like the following setup: VBA-code: ** Initialization: Dim Srv As Object Set Srv = CreateObject("PythonCOMserver") Srv.SetRef Application ** Action handling: Dim doc As Word.Document doc = Srv.GetNew Python COM server code: def SetRef(self, applObj): self.ApplObj = appObj return 0 def GetNew(self): doc = self.AppObj.Documents.Add() # some additional handlnig return doc When the GetNew method in the Python COM server is executed, an error indicates that the name 'Documents' is invalid. The self.ApplObj is of type PyIDispatch (I think), however may it must be an 'instance' in order to be able to access the object model. If I instead of accessing the object model just returns the object (self.AppObj) and makes use of the returned object back in the VBA code, I can use the object model - so the round-trip seems to work. Thanks for any help/hints. Nikolai Kirsebom From jchan at cohocanoes.com Sat Nov 6 02:54:24 1999 From: jchan at cohocanoes.com (jchan at cohocanoes.com) Date: Sat, 06 Nov 1999 07:54:24 GMT Subject: Zope comparisons? (ASP, PHP, etc) References: <3821C5F6.84543AF2@yahoo.com> <06lU3.259$Ae3.186544@news-dal.corridex.com> Message-ID: Wow...this is by far one of the best explainations of what Zope is capable of doing. Wonderful description, Evan. Perhaps your prose should be incorporated into Zope's site. Evan Simpson wrote: > There has been a lot of discussion lately on the Zope mailing list > (zope at zope.org) about making this sort of information more readily available > on the website, but here's a brief intro: > Zope has several parts, which work well together, but are all optional: > 1. ZServer: A Medusa-based multi-threaded asynchronous server which accepts > HTTP, FTP, and monitor (special Python client) connections. Usually, it > passes requests from these connections to... > 2. ZPublisher: An ORB which converts HTTP, FTP, XML-RPC, WebDAV, etc. > requests into traversal of an object hierarchy and returns the result of > rendering the target object. These objects are normally stored in... > 3. ZODB: A versioning, transaction-based object store with automatic object > persistence and conflict handling. ZODB stores an object hierarchy as a > single file (2GB limit being worked on) and appends new versions of objects > when their request transaction is comitted. This allows extensive undo, and > requires occasional packing to eliminate old, unwanted versions. Most HTML > is generated by standard Zope objects using... > 4. DTML: An embedded language similar to ASP and PHP, except that > expressions are written in Python and have access to the full power of the > rest of Zope, including... > 5. Acquisition: A feature of standard Zope objects which allows them to > change their behavior automatically based on the context in which they are > called. Hard to describe, but very powerful, as are... > 6. Products: New objects or collections of objects can be added to Zope by > simply installing a Python package in the Products subdirectory and > resetting the server. Current Products include database adapters, threaded > discussions, virtual host managers, and many others. Of course, if you > don't want to learn Python you can always create... > 7. ZClasses: Object classes defined through the web management interface by > assembling standard Zope parts. These can provide a wide range of > customized objects. > I haven't really gotten into the user/role/permission security model, or the > extensive web management interface through which you typically interact with > Zope. I may have forgotten other bits, too. There's a lot there :-) From Markus_Strickler at everest-design.de Thu Nov 11 04:02:01 1999 From: Markus_Strickler at everest-design.de (Markus Strickler) Date: Thu, 11 Nov 1999 10:02:01 +0100 Subject: Python 1.5.2 on NeXTStep Message-ID: <002501bf2c23$6aceabb0$2d131bc3@everestdesign.com> Hi! Has anyone managed to compile Python 1.5.2 on NeXTStep 3.3? I'm currently running an older Python version and would like to upgrade. However 1.5.2 won't compile. Can anyone give me start what config parameters I need. Thanks, Markus From fredrik at pythonware.com Tue Nov 2 03:53:17 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 2 Nov 1999 09:53:17 +0100 Subject: Tkinter canvas blow-up: bbox(ALL) == None References: <19991101102103.A134035786@vislab.epa.gov> Message-ID: <013c01bf2510$57457f20$f29b12c2@secret.pythonware.com> Randall Hopper wrote: > Apparently if the bounds of the items in a Tk canvas widget exceed > MAXINT, bbox(ALL) returns None. The attached Python script demonstrates > this. > > Intuitively it seems like this is a bug since the contents of the > canvas are maintained in floating point; integer bounds shouldn't be > involved, should they? > > Is this a Tk bug or a Tkinter bug? both. Tkinter uses _getints instead of _getdoubles to convert the bounding box to a tuple... ...but the reason you get None instead of an over- flow error is that Tk returns an empty string in this case (at least in 8.0.5). From gerglery at usa.net Fri Nov 19 04:56:11 1999 From: gerglery at usa.net (Alternative Fluffy) Date: 19 Nov 1999 04:56:11 -0500 Subject: Beginning programming with Python References: Message-ID: <877ljest38.fsf@slip-32-100-244-40.ma.us.prserv.net> Boudewijn Rempt wrote: > You needn't guess about that, I guess ;-). I didn't know there > was a design team for Python, I though it was Guido's invention. > But I still wonder about the double == - if I can't assign in > an if, why insist on ==? Here is one example of why they need to be different: >>> y = a = 0 >>> z = a == 0 >>> print y 0 >>> print z 1 From phd at phd.russ.ru Thu Nov 25 06:51:26 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Thu, 25 Nov 1999 11:51:26 +0000 (GMT) Subject: threading and timeouts In-Reply-To: <943504970.076.346131773@cs.usyd.edu.au> Message-ID: On Thu, 25 Nov 1999, Piers Lauder wrote: > The only option I can think of is to re-write the smtplib module to use > `select', but does anyone know of a simpler solution? Fork off a child that will send the mail. Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From greg.ewing at compaq.com Mon Nov 8 08:46:28 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Tue, 09 Nov 1999 02:46:28 +1300 Subject: Some more Ruby observations (Re: Comparison between Python and "Ruby") References: <3819BCDA.AC4FD4CA@strs.co.uk> <87k8o2x67f.fsf@ev.netlab.co.jp> <7vjtrc$hmm$1@newshost.accu.uu.nl> <3821A860.5D32AFCC@compaq.com> Message-ID: <3826D434.C083F6FD@compaq.com> Neel Krishnaswami wrote: > > and since continuation-passing forms are just a hair away from > bytecode, I am a bit surprised by this news. I don't see how continuation-passing and bytecode have anything to do with each other. > Are there any syntax-tree munging phases to do stuff like common > subexpression elimination and loop hoisting? I haven't seen any so far, although I haven't really looked for these things. I get the impression that speed isn't a major design goal in this implementation of Ruby, at least not as much as it is in CPython. All of Ruby's built-in operations go through a method lookup, for example, even adding two integers. Greg From s323140 at student.uq.edu.au Tue Nov 16 03:39:01 1999 From: s323140 at student.uq.edu.au (Rob Hodges) Date: 16 Nov 1999 18:39:01 +1000 Subject: list.without()? References: Message-ID: mlh at vier.idi.ntnu.no (Magnus L. Hetland) writes: > Is there a function or method in the standard language that can > non-destructively return a list without a specified element? Would it > be possible to add it as a method to lists? > > i.e: > > # pseudocode > > class list: > def without(self,element): > temp = self[:] > temp.remove(element) > return temp Use a lambda with filter, like this: >>> a = [1,2,3,5,2,1,4,9,1,3] >>> a [1, 2, 3, 5, 2, 1, 4, 9, 1, 3] >>> b = filter(lambda(elt): elt != 1, a) >>> b [2, 3, 5, 2, 4, 9, 3] >>> a [1, 2, 3, 5, 2, 1, 4, 9, 1, 3] >>> It would be kinda nice to have such a thing as a list method, now that you mention it, but this is a pretty reasonable one-liner solution. -Rob From tbryan at python.net Sat Nov 6 03:27:10 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Sat, 06 Nov 1999 03:27:10 -0500 Subject: __str__ vs. __repr__ References: <000001bf275c$02370d20$1d2d153f@tim> <7vvni7$19q0$1@nntp6.u.washington.edu> Message-ID: <3823E65E.D9E49CC6@python.net> Donn Cave wrote: > repr is used > in lots of places, like the interactive interpreter, I think that was Tim's point. Earlier he said: """For that matter, why is repr implied at an interactive prompt given a raw expression? Seems that friendly strings would be more appropriate there.""" He wants str to be used at the interpreter since it's supposed to be the human readable form. One of Guido's complaints was that then 1 and '1' then look the same. > On the contrary, it's str() that's intended for the machine, and > repr() for the human. >From the library reference: """repr (object) Return a string containing a printable representation of an object. This is the same value yielded by conversions (reverse quotes). It is sometimes useful to be able to access this operation as an ordinary function. For many types, this function makes an attempt to return a string that would yield an object with the same value when passed to eval(). str (object) Return a string containing a nicely printable representation of an object. For strings, this returns the string itself. The difference with repr(object) is that str(object) does not always attempt to return a string that is acceptable to eval(); its goal is to return a printable string. """ The problem is that this thread is the first time many of us have ever thought about the problem. I've never noticed those two lines in the library reference, and I haven't seen the str/repr distinction clearly made anywhere else. Furthermore, since the interactive i nterpreter *does* use repr(), many of us make __repr__ return the human readable form so that we can easily test our classes. So, what I'm hearing is: 1. __str__ *should* be a human readable string 2. __repr__ *should* be a representation that can be eval'd back to the original object 3. This convention is not widely known, but 3b. the interactive interpreter discourages the convention by using repr to show the result of an expression Therefore, we could switch the convention for str and repr, which breaks things that are currently following the convention. Or we could switch the interactive interpreter to use str to encourage class writers to follow the convention. Of course, any class writers who intentionally switched __repr__ and __str__ to get nice interactive behavior will have to switch the mehtods back. Since Tim voted for the second option, that's probably what Guido will decide. ;) Either way, Guido still has to deal with non-printing characters, string-vs-number distinctions, and other insanity in the interpreter. who-uses-the-interpreter-anyway--ly yours ---Tom From tbryan at python.net Tue Nov 30 20:03:35 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Tue, 30 Nov 1999 20:03:35 -0500 Subject: Python at Source Forge? Message-ID: <384473E7.5B91C674@python.net> Has anyone looked at www.sourceforge.com yet? Perhaps there could be a Parnassus mirror there? I notice that there is an entry for Perl http://www.sourceforge.com/project/index.php?form_grp=320 that appears to be a CPAN mirror. In any case, Python developers of Open Source programs might find the resource useful. ---Tom From endgamer71 at hotmail.com Tue Nov 16 06:56:28 1999 From: endgamer71 at hotmail.com (Endgamer) Date: Tue, 16 Nov 1999 11:56:28 GMT Subject: Alright, I give up...chalk this one up to experience... Message-ID: <383145c0.4445469@212.225.36.99> Alright, I finally give up. I've been bashing at this bloody idea all week...maybe I'm incredibly stupid (probably), but I can't see why, when I run this as a script from Windows 95, it doesn't return the current date setting on my machine. Could somebody put me out of my misery? I promise I'll stop bothering you . ------------------------------------------------------- # Date setting program (chunk 1) import os olddate=os.popen("date",'r') olddate=readdate print olddate ------------------------------------------------------- Endgamer Spider Warrior (Endgamer71 at spamtrap.hotmail.com) ##################################### Not a quote, just an on-the-spot observation: You know you're a geek when your PC costs exactly 15 times as much as your stereo. And gives better sound quality. Endgamer ##################################### From andrew.markebo at telelogic.se Mon Nov 1 02:43:01 1999 From: andrew.markebo at telelogic.se (Andrew Markebo) Date: 01 Nov 1999 08:43:01 +0100 Subject: Listbox.. ACTIVE-item is the one selected previously.. References: <7vj2ic$ich$1@vvs.superst.iae.nl> Message-ID: The only difference when using anchor is that I get " abcd", it seems to work fine on Unix, but at home, on my Win98 and WinNT-machines I get this delayed 'report'. Smells like a bug.. /andy -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==---------- http://www.newsfeeds.com The Largest Usenet Servers in the World! ------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==----- From che at debian.org Fri Nov 12 18:58:17 1999 From: che at debian.org (Ben Gertzfield) Date: 12 Nov 1999 15:58:17 -0800 Subject: __doc__ print \012 on Debian Gnulinux2 References: Message-ID: >>>>> "Jean-Bernard" == Jean-Bernard ADDOR writes: Jean-Bernard> Hey ! I try to make some documentation strings in Jean-Bernard> my code but then I use them the result is very Jean-Bernard> difficult to read: *snip* Jean-Bernard> How could I make it print return instead of \012? Try: print class.method.__doc__ instead of just 'class.method.__doc__'. :) -- Brought to you by the letters A and L and the number 11. "Wuzzle means to mix." Debian GNU/Linux maintainer of Gimp and GTK+ -- http://www.debian.org/ From tomh at po.crl.go.jp Tue Nov 30 21:56:54 1999 From: tomh at po.crl.go.jp (Tom Holroyd) Date: Wed, 1 Dec 1999 11:56:54 +0900 Subject: Looking for sshlib.py In-Reply-To: References: <19991130080326.A1376@quark.emich.edu> Message-ID: Check out SRPSocket, which creates SRP authenticated sockets. http://www.aist.go.jp/NIBH/~tomh/SRPSocket.tar.gz The home page for SRP is http://srp.stanford.edu/srp/ SRP stands for Secure Remote Passwords and is a drop in replacement for Unix passwords that is safe to use over the network. The main SRP site has code written in C for telnet and FTP; SRPSocket is pure Python (still pretty fast though). The only caveats are that the Python random number generator isn't really good enough -- you should use a different one, and the default prime field is 128 bits -- I have a 1024 bit one, and you can of course generate your own big prime numbers... (SRP is a variant of Diffie-Hellman, but better.) SRP (and SRPSocket) are free from export restrictions as this is only the authentication stage. A side effect of the authentication is that you get a secure, shared key (the length is the output size of the hash used). You can use this key to bootstrap a longer key (such as an interleaved SHA key) or use it to encrypt the socket directly, or whatever. On Tue, 30 Nov 1999, John Leach wrote: > I'm looking to write a Python frontend for character-based applications > accessed via the internet. > telnet works well but I'd like something with more security (telnet sends > its password unencrypted I believe). > I'll try calling ssh from within Python and see if that helps. > Thanks for your reply, > John Leach > http://www.bosware.com.au Dr. Tom Holroyd I would dance and be merry, Life would be a ding-a-derry, If I only had a brain. -- The Scarecrow From just at letterror.com Fri Nov 5 06:44:52 1999 From: just at letterror.com (Just van Rossum) Date: Fri, 5 Nov 1999 12:44:52 +0100 Subject: __str__ vs. __repr__ In-Reply-To: <000001bf275c$02370d20$1d2d153f@tim> References: <199911041325.IAA14001@eric.cnri.reston.va.us> Message-ID: At 2:04 AM -0500 11/5/99, Tim Peters wrote: >rendering Python useless to grownups. How does Python's Unicode story >relate to this? Displaying a Unicode string as a pile of \uxxxx (whatever) >escapes defeats the whole purpose of Unicode. Ditto displaying it in UTF-7. >OTOH, for some number of years to come it will be a rare display device that >*won't* treat Unicode 16-bit values (whether or not UTF-8 encoded) as a pile >of 8-bit control codes. [ ... ] >Until Unicode takes over the world, there's nothing you can do other than >tell users the truth: "most of" printable 7-bit ASCII displays the same way >across the world, but outside of that *all* bets are off. It will vary by >all of OS, display device, displaying program, and user configuration >choices. As a step towards a Unicode-savvy Python, would it be an idea to define Unicode versions of repr(), str(), ob.__repr__() and ob.__str__()? eg. urepr() ustr() ob.__urepr__() ob.__ustr__() 'print' could then use these if it knows stdout is a Unicode-savvy output stream. Just From bernhard at alpha1.csd.uwm.edu Thu Nov 11 15:31:19 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 11 Nov 1999 20:31:19 GMT Subject: ASCII delimited files References: <942231502.1914033961@news.interbusiness.it> <382A240B.B247AD6B@python.net> <382A2801.FDE3CA09@python.net> <382A4330.833C4EBD@easystreet.com> <8EsW3.962$Xo.4938@news-server.bigpond.net.au> Message-ID: On Thu, 11 Nov 1999 05:39:16 GMT, Mark Hammond wrote: >Yes - a good CSV parser would make a very useful addition to the library! http://eh.org/~laurie/comp/python/csv/ has some attempts to build better csv support. by Laurence Tratt (Of course not listed on the python.org site. :( ) Bernhard -- Research Assistant, Geog Dept UM-Milwaukee, USA. (www.uwm.edu/~bernhard) Free Software Projects and Consulting (intevation.net) Association for a Free Informational Infrastructure (ffii.org) From gerrit.holl at pobox.com Sat Nov 6 06:17:11 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Sat, 6 Nov 1999 12:17:11 +0100 Subject: smtplib.py how to ? In-Reply-To: <38237da0.3456244@news.force9.net> References: <38237da0.3456244@news.force9.net> Message-ID: <19991106121711.A18313@optiplex.palga.uucp> Colm Rafferty wrote: > Dear all, > I cannot insert text into the headers To: From: CC: etc, of the email > The script below ( the sample in the smtplib.py module) only sends all > the text in the body of the email. > How do I insert text in the headers? What do you mean? msg = '''From: A friend To: My brother Cc: My sister Subject: this is an example X-Mailer: a python script Date: Sat Nov 6 12:15:51 CET 1999 Reply-To: My father This is the body ''' regards, Gerrit. -- linuxgames.nl.linux.org All about games on Linux in Dutch (under construction). www.nl.linux.org The Dutch resource for Dutch Linux documentation. www.nl.linux.org/discoverb Learn foreign words and definitions. www.nl.linux.org/~gerrit/asperger I'm an Asperger, go here for more info. www.nl.linux.org/~gerrit About me and pictures of me. From ScherBi at BAM.com Thu Nov 4 13:27:29 1999 From: ScherBi at BAM.com (ScherBi at BAM.com) Date: Thu, 4 Nov 1999 13:27:29 -0500 Subject: Extending Python dynamically Message-ID: <3F8BA119B48AD11197470008C7A493CB98B643@HQOBGEX1> > Thank you for your help. The method you suggested works perfectly! You're quite welcome. > However, I do not understand completely how the Python > interpreter finds out that it has to load an so file. Normally -- I believed -- > when Python sees an "import xxx" statement it looks for a xxx.py, xxx.pyc or > xxx.pyo file in the $PYTHONPATH directories or an xxx subdirectory having an > __init__.py file, but not an xxx.so file. This means that if I add the current > directory to the $PYTHONPATH (such as export PYTHONPATH='.' Python will find > any arbitrary so file in the $PWD? The true answers to these questions are at level lower than I am able to go into in Python, primarily because I think the answers are in Python's c source. Anyway, I believe that Python, on execution of imort xxx, will load xxx.so if, and only if, it has the proper interface, that is, if it has been built as a Python extension. Try it with any other .so file and see what happens. > Anyway, I am very happy that I do not have to recompile > Python every time I add a new extension library (ie. an so file) :-). Yes, while others may deride possible performance degradation of the shared object interface, I have been known to ignore an extension or two because it required me to rebuild Python, but I'm really out of my league here. Bill From Gareth.McCaughan at pobox.com Thu Nov 25 15:41:40 1999 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: 25 Nov 1999 20:41:40 +0000 Subject: Python complaints References: <867lj85g4c.fsf@g.local> <383CC835.B585EBDD@Lugoj.Com> Message-ID: <86r9he2tiz.fsf@g.local> James Logajan wrote: [I said:] >> - if/then/else works on *statements* (strictly, suites of >> statements) rather than on *expressions*, so I can't >> say >> print "You scored %s point%s" % (score, if score==1 then "" else "s") >> or anything like that. (Or, as some people prefer to put it, >> Python has no ? : operator.) > > Thanks to Python's dynamic typing you can easily add the C "?:" expression > to the language by defining a single function that will work with all types: > > def ifexp(cond, trueVal, falseVal): > if cond: > return trueVal > else: > return falseVal > > print "You scored %s point%s" % (score, ifexp(score == 1, "", "s")) That has the wrong semantics in the presence of side effects. (It's fine for my toy example, but then so is "score<>1 and 's' or ''". -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From rgacote at AppropriateSolutions.com Wed Nov 24 08:17:46 1999 From: rgacote at AppropriateSolutions.com (Raymond Cote) Date: Wed, 24 Nov 1999 08:17:46 -0500 Subject: Python complaints In-Reply-To: <005201bf367e$4901fef0$f29b12c2@secret.pythonware.com> References: <81gj3i$fe3$1@mach.vub.ac.be> Message-ID: Thomas Hamelryck <> wrote: > I don't want to start the discussion about indentation again; it's no use > since indenting blocks is here to stay. The point is that if you want to > write code that looks ugly or unreadable you will succeed in doing that, > indentation or not. In many cases, using a variable indentation (depending > on what construct you are using or the length of a line) leads to code > that is visuably much more appealing. I was sure this 'indenting thing' would be one of the two major issues that kept me grumbling about Python. However, after just a month or so of casual Python programming, I find myself becoming dissatisfied with extra work required by braces and begin/end in my day to day C and Pascal programming. Was totally surprised how quickly I came to like the indenting. Just my 2cents. Ray ------------------------------------------------------------------- Raymond Cote, President Appropriate Solutions, Inc. www.AppropriateSolutions.com rgacote at AppropriateSolutions.com 603.924.6079(v) POB 458, Peterborough, NH 03458 603.924.8668(f) From jlj at cfdrc.com Wed Nov 17 14:26:47 1999 From: jlj at cfdrc.com (Lyle Johnson) Date: Wed, 17 Nov 1999 19:26:47 GMT Subject: Embedded Python 1.5.1 crashes under WIN32 References: <3832F6FB.68AAA96E@tu-bs.de> Message-ID: <38330158.170604796@192.77.87.74> See this entry in the Python FAQ list: http://www.python.org/doc/FAQ.html#8.7 On Wed, 17 Nov 1999 19:42:03 +0100, Sven Havemann wrote: >Hi! >=== > >I've modified the example from Python-1.5.1/Demo/embed: > >ftp://ftp.cg.cs.tu-bs.de/pub/cg/people/havemann/embeddedPython.tgz > >What I want to do is to call PyRun_SimpleFile from my main program. This >works fine under Irix 6.5, but the same thing crashes inside >PyRun_SimpleFile when compiled with VC6.0SP2 under Win32, which is a >great pity. I have attached the demo.cpp file, and the complete >(compiled) project is in the tarfile above. Does anybody know why it >crashes??? > >I wanted to build it as a plain Win32 console application, and I've >renamed it to demo.cpp because I wanted it to be compiled as a C++ file. > >I'd appreciate if you could Re: to me directly using the email below, >because I can't follow the news regularly. > >TIA, greetings, Sven. > >-- >__________________________________________________________________ > dipl-inform. Sven Havemann Institut fuer ComputerGraphik > Odastrasse 6 Rebenring 18 > 38122 Braunschweig - Germany 38106 Braunschweig - Germany > Tel. 0531/2808955 Tel. 0531/391-2108, Fax: -2103 > mailto:s.havemann at tu-bs.de http://www.cg.cs.tu-bs.de > > >=========================demo.cpp================================== >#include >#include "Python.h" > >// #define SHOWPYFILE > >static char *argv0; > >void initxyzzy(); /* Forward */ > >int main(int argc, char ** argv) >{ > argv0 = argv[0]; > Py_Initialize(); > > initxyzzy(); > > PySys_SetArgv(argc, argv); > > printf("Hello, brave new world\n\n"); > > PyRun_SimpleString("import sys\n"); > PyRun_SimpleString("print sys.builtin_module_names\n"); > PyRun_SimpleString("print sys.modules.keys()\n"); > PyRun_SimpleString("print sys.argv\n"); > > char* filename="test.py"; > FILE* myfile=fopen(filename,"r"); >#ifdef SHOWPYFILE > char line[200]; > printf("Reading file %s\n",filename); > while(fgets(line,200,myfile)!=NULL) { > printf("Read: %s",line); > } >#else > PyRun_SimpleFile(myfile,filename); >#endif > fclose(myfile); > > printf("\nGoodbye, cruel world\n"); > > Py_Exit(0); > return 0; >} > >char *getprogramname() >{ > return argv0; >} > >/* A static module */ > >PyObject *xyzzy_foo(PyObject *self, PyObject *args) >{ > if (!PyArg_ParseTuple(args, "")) > return NULL; > return PyInt_FromLong(42L); >} > >PyMethodDef xyzzy_methods[] = { > {"foo", xyzzy_foo, 1}, > {NULL, NULL} /* sentinel */ >}; > >void initxyzzy() >{ > PyImport_AddModule("xyzzy"); > Py_InitModule("xyzzy", xyzzy_methods); >} >==================test.py====================================== >print "this is from PyRun_SimpleFile" >for i in range(100): print i*i, >==================OUTPUT IRIX================================== >Hello, brave new world > >('__builtin__', '__main__', 'array', 'fast_umath', 'imp', 'marshal', >'math', 'operator', 'posix', 'signal', 'strop', 'struct', 'sys', >'umath') >['xyzzy', 'os', 'exceptions', '__main__', 'posix', 'sys', '__builtin__', >'site', 'signal', 'UserDict', 'posixpath', 'stat'] >['./demo'] >this is from PyRun_SimpleFile >0 1 4 9 16 25 36 49 64 81 100 121 144 169 196 225 256 289 324 361 400 >441 484 529 576 625 676 729 784 841 900 961 1024 1089 1156 1225 1296 >1369 1444 1521 1600 1681 1764 1849 1936 2025 2116 2209 2304 2401 2500 >2601 2704 2809 2916 3025 3136 3249 3364 3481 3600 3721 3844 3969 4096 >4225 4356 4489 4624 4761 4900 5041 5184 5329 5476 5625 5776 5929 6084 >6241 6400 6561 6724 6889 7056 7225 7396 7569 7744 7921 8100 8281 8464 >8649 8836 9025 9216 9409 9604 9801 > >Goodbye, cruel world >==================OUTPUT WIN32================================== >-- Hello, brave new world > >('__builtin__', '__main__', '_socket', 'array', 'binascii', 'cPickle', >'cStringI >O', 'cmath', 'errno', 'imageop', 'imp', 'marshal', 'math', 'md5', >'msvcrt', 'new >', 'nt', 'operator', 'pcre', 'regex', 'rgbimg', 'rotor', 'select', >'signal', 'so >undex', 'strop', 'struct', 'sys', 'thread', 'time') >['xyzzy', 'os', 'exceptions', '__main__', 'ntpath', 'strop', 'nt', >'sys', '__bui >ltin__', 'site', 'signal', 'UserDict', 'string', 'stat'] >['T:\\WORK\\HAVEMANN\\SW\\PYTHON-1.5.1\\DEMO\\EMBED\\VC60.exe'] >=====================** CRASH **================================ >================================================================ >__________________________________________________________________ > dipl-inform. Sven Havemann Institut fuer ComputerGraphik > Odastrasse 6 Rebenring 18 > 38122 Braunschweig - Germany 38106 Braunschweig - Germany > Tel. 0531/2808955 Tel. 0531/391-2108, Fax: -2103 > mailto:s.havemann at tu-bs.de http://www.cg.cs.tu-bs.de From evan at tokenexchange.com Mon Nov 8 09:43:24 1999 From: evan at tokenexchange.com (Evan Simpson) Date: Mon, 8 Nov 1999 08:43:24 -0600 Subject: making the Python case to my dept. References: <9911051740130D.02530@william.jinsa.org> <7GOU3.272$Ae3.194028@news-dal.corridex.com> <801p16$10s$1@vvs.superst.iae.nl> Message-ID: http://www.alice.org It's scripted in Python, although at the simplest level you just manipulate objects with the mouse, and at the second simplest you construct animation scripts by choosing from pop-up menus. Carel Fellinger wrote in message news:801p16$10s$1 at vvs.superst.iae.nl... > where can I find more on this Alice thing? my kids would love to play with > 3-D animations! (I take it that scripting it is with Python) Cheers, Evan @ 4-am From akuchlin at mems-exchange.org Thu Nov 18 17:14:00 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 18 Nov 1999 17:14:00 -0500 Subject: Proposal: Python Info Collective (another ramble) References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> <80ubrg$tuj$1@hub.org> Message-ID: <3dso23jvmf.fsf@amarok.cnri.reston.va.us> T. Maddletyn at news.vex.net (T. Maddletyn) writes: > It is true that Parnassus is horribly inefficient in some areas (some > i'm aware of, perhaps some i'm not aware of). However the good news is It probably doesn't greatly matter, at this point; people will complain if it gets too slow. For now, the primary problem is getting it to a host without a weekly bandwidth limitation. Someone mentioned putting it onto starship.python.net; is anything happening with that? > Meanwhile the discussion continues. Formats. XSA, RDF, OSD, LSM, RFC- > 822, on and on... i never really heard of any of these before! Well, > i'd heard of RDF, but didn't know really anything about it (I know Don't worry about formats; later on we can worry about writing scripts that walk all over the database generating RDF or whatever. First, let's get it hosted somewhere suitable, then get more data into it, and then worry about refinements such as improved performance or alternative formats. -- A.M. Kuchling http://starship.python.net/crew/amk/ We all live to a formula. Maybe the secret lies in keeping that formula secret. -- Peter Greenaway, _Dear Boull?e_ From vroonhof at frege.math.ethz.ch Sat Nov 6 16:44:40 1999 From: vroonhof at frege.math.ethz.ch (Jan Vroonhof) Date: 06 Nov 1999 22:44:40 +0100 Subject: A newbie dictionary question References: <3824648F.7FB08EAC@x.x> Message-ID: Eric Jacobs writes: > > def __str__(self): > > self.value > > Unrelated, but did you mean "return self.value"? It's > legal to throw away values in Python. Yes I did. > > def __cmp__(self,other): > > return self.nospaces() == other.nospaces() > > The __cmp__ is returning the wrong thing. It should return > -1 for <, 0 for ==, or 1 for >. You probably want > > def __cmp__(self, other): > return cmp(self.nospaaces(), other.nospaces()) Aaargghh. Of course. I feel stupid. Thanks a lot. I could have sworn I wrote that. I guess it really was too late. It works fine now. Jan From herzog at online.de Thu Nov 4 06:27:57 1999 From: herzog at online.de (Bernhard Herzog) Date: 04 Nov 1999 12:27:57 +0100 Subject: __str__ vs. __repr__ References: <000401bf25b9$88ea57e0$2e2d153f@tim> <199911040157.UAA11908@eric.cnri.reston.va.us> Message-ID: Guido van Rossum writes: > It's a separate dilemma from the other examples. My problem here is > that I hate to make assumptions about the character set in use. How > do I know that '\237' is unprintable but '\241' is a printable > character? How do I know that the latter is an upside-down > exclamation point? Should I really assume stdout is capable of > displaying Latin-1? Strictly, the str() function doesn't even know > that it's output is going to stdout. I suppose I could use isprint(), > and then Fran?ois could use the locale module in his $PYTHONSTARTUP > file to make it do the right thing. Is that good enough? (I just > tried this briefly. It seems that somehow the locale module doesn't > affect this?!?! > > I still think that ['a', 'b'] should be displayed like that, and not > like [a, b]. I'm not sure what that to do about a dict of Rat() > items, except perhaps giving up on the fiction that __repr__() should > return something expression-like for user-defined classes... > > Any suggestions? How about a hook function a la __import__? I.e. have a function __format__ [1] in __builtin__ that is bound to repr by default. Whenever Python prints the result of an expression in interactive mode, it calls __format__ with the result as parameter and expects it to return a string ready for printing. If somebody want str instead they can put import __builtin__ __builtin__.__format__ == str in their $PYTHONSTARTUP file. This scheme even allows for more fancy formatting like not escaping printable chars in latin1 if the user wants it. [1] the name __format__ is perhaps a bit too generic, but something more descriptive like __interactive_repr__ may be a bit awkward, but then again you don't normally call it manually. -- Bernhard Herzog | Sketch, a drawing program for Unix herzog at online.de | http://www.online.de/home/sketch/ From T.Muddleton at news.vex.net Mon Nov 15 13:13:05 1999 From: T.Muddleton at news.vex.net (T. Muddleton) Date: 15 Nov 1999 18:13:05 GMT Subject: Proposal: Python Info Collective References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> <14384.16479.836502.161209@anthem.cnri.reston.va.us> Message-ID: <80pifh$12n1$1@hub.org> On Mon, 15 Nov 1999 12:18:23 -0500 (EST), webmaster at python.org wrote: >some editorial review for record changes, because the change isn't >effective immediately. That could be another bottleneck in the Yup, i'm a bottleneck. Truer words were never spoken. Though the bottle neck is not doing too badly today. Mailman update is processed. I had considered (and still do consider) implementing a system whereby owners can edit their own stuff (i see in the Trove shema that they have planned for this already too)... but as i didn't know how far my Parnassus scheming would get i didn't implement it yet. Also since i have (until today) found and entered all the data myself I haven't put much thought into the other possible mechanisms yet. There are other complication's i'll spare you. But I just want to let you know that I have thought of this, and perhaps in the future the bottleneck can be removed, or at least widened a bit. >somewhere on the python.org site, but I'd still like Parnassus' author >to get in touch with me... I must say i'm a little worried about bandwidth issues after the discussions here. But on the other hand... we'll never know what the system can or can't take until we try right? Heh. Or perhaps it would be prudent for me to look into possibilities further.... i'm in a bit of a quandry. I've gotten more response than I expected (which has been nice... but a little frightening too!). .... From hinsen at cnrs-orleans.fr Thu Nov 4 05:28:47 1999 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 04 Nov 1999 11:28:47 +0100 Subject: Extending Python dynamically References: <38215010.DCFCDBFA@iqsoft.hu> Message-ID: "N?meth Mikl?s" writes: > I have read ext.pdf (Extending Python with C or C++). As far as I > understood (by reading chapter 2), I have to recompile my Python > interpreter, and have to relink the interpreter against this DCOracle > shared objects. > Does Python not support a more dynamic extension mechanism (based on > dlopen())? If I want to add an extension in C, shall I always It does, at least for modern Unix variants and for Windows. Check sections 2 (Unix) and 3 (Windows) of the current version of the Extending&Embedding manual. The very first page of section 2 explains how to compile extension modules into shared libraries under Unix. > I have also started evaluating Zope. After the first two hours I found > Zope is a fantastic product, I am curious about how people did dare > implement a so complex application (ie. an application server) in an > interpreted "scripting language". These type of software pieces are Just don't call it a scripting language, maybe that helps! -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From smst at quantisci.co.uk Thu Nov 18 06:03:46 1999 From: smst at quantisci.co.uk (Steve M S Tregidgo) Date: Thu, 18 Nov 1999 11:03:46 GMT Subject: __str__ vs. __repr__ Message-ID: <199911181103.LAA05706@cobweb.quantisci.co.uk> Fredrik Lundh wrote: > Phil Hunt wrote: > > How about: > > > > x = a + b + c > > x = (a + b) + c > > x=a+b+c > > > > I'd guess these all produce the same bytecode. > > footnote: the abc80 computer I mentioned > in my earlier post had an extra byte code > for this purpose. users can buy that you > add spaces and reformat their code, but > they won't accept that you remove their > parentheses... > Two solutions: (1) When regenerating the source, wrap every single binary op with parentheses; the bytecode generated by (a+b)+c will also be generated by ((a+b)+c), and at least the user's original bracketing will be there too. Looks very messy though. (2) Use some intelligence in deciding where brackets need to go. Clearly if (a+b)*c was compiled into bytecodes, we would have to ensure the brackets remained, but (a*b)+c uses extra brackets that can be ommitted during the decompiling stage. This second solution wouldn't be so hard -- the order of the bytecodes tells us which ops come first, and so we'd just need to bracket a nested op if the op that uses the result is of a certain type (so if a BINARY_ADD applied to elements a+b and c, there would be no need to introduce protective parentheses, but there would for a BINARY_MULTIPLY on a+b and c). Anyhow, since decompiling should mainly be used to recover lost code, as long as the code works the issue of (orignally extraneous) brackets missing isn't really a problem -- I for one would just be grateful that I got my code back. (And heck, if I actually noticed that the odd bracket was missing from a thousand-line file, I'd consider that I'd got a bit _too_ familiar with the code ;-) Cheers, Steve From dubois1 at llnl.gov Sat Nov 13 11:42:59 1999 From: dubois1 at llnl.gov (Paul F. Dubois) Date: Sat, 13 Nov 1999 16:42:59 GMT Subject: Max Size of Array when using Numeric.py References: <38286054.C8612EB5@edf.fr> Message-ID: There is no intrinsic limit on the size of NumPy arrays. You just ran out of memory, I guess. Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> from Numeric import * >>> a=arange(5500*200) >>> a.shape (1100000,) >>> 5500*200 = 1,100,000 * 4 = ~ 4MB per copy. You have at least three copies, mv, eval(mv), and the resultant array. eval(mv) is going to be double sized since the default Python real is 8 bytes. You aren't clear about mv but likely it is more than 4MB too. So maybe we are pushing 16-20 MB. That doesn't really seem like enough for a memory error. You could write a C extension that created the array and did the reading of each element and placing it into the array so that you only had the one copy. Helka FOLCH wrote in message news:38286054.C8612EB5 at edf.fr... > I've tried to create an array object whose shape is (5500,200) but I get > a memory error. Is there a maximum size for array objects? > > Maybe there's a better way of creating the array than what I did : > My program reads the array which is in another format from a file. It > transforms the array to the right format and holds it in a variable(mv) > as a string. Then I just do: > > m = array(eval(mv),Float) > > Thanks a lot, > Helka > From Gareth.McCaughan at pobox.com Thu Nov 25 15:43:41 1999 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: 25 Nov 1999 20:43:41 +0000 Subject: Python complaints References: <867lj85g4c.fsf@g.local> <383CC835.B585EBDD@Lugoj.Com> <383D9C63.3A7E5806@Lugoj.Com> Message-ID: <86ogci2tfm.fsf@g.local> James Logajan wrote: > Oh yeah? Well yer mudder wears army boots! Seriously though, the price I am > talking about has absolutely nothing to do with simplicity. It has to do > with the fact that languages such as Java that have "true" GC are > non-deterministic in their execution times because GC can cause execution > pauses in the VM at unpredictable times. This makes Java unacceptable for a > large number of real-world applications that I have been involved in lately. > ("I'm sorry, but your 911 call can not go through for another 20 seconds > while our Java VM garbage collects 1GB of memory on the switch.") I have > recommended Python over Java in at least one environment because of Python's > deterministic approach to memory management. Had Python not had that, I > suppose we would have gone with some other scripting language or even > designed our own (gak!). Garbage collectors have got a *lot* better since the days when GC meant half-second pauses waiting for the machine to sweep through all its memory. Let alone 20 seconds. -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From phd at phd.russ.ru Thu Nov 25 06:17:28 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Thu, 25 Nov 1999 11:17:28 +0000 (GMT) Subject: Help with SMTP In-Reply-To: <81hase$bdj$1@news.fsu.edu> Message-ID: On Wed, 24 Nov 1999, Glenn Kidd wrote: > everyhting looks in order but the website reports a "500 Internal Server > Error". When I look at the server log I get the following description of > the error: > > > [Wed Nov 24 13:23:30 1999] [error] [client 128.186.86.106] Premature end of > script headers: /home/httpd/cgi-bin/mail.py Your script must return something to the server - either text or redirect. print "Content-Type: text/html" print print "...and all HTML stuff...The message was successfully sent" Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From sekter at mail.matav.hu Fri Nov 19 06:41:38 1999 From: sekter at mail.matav.hu (Arpad Kiss) Date: Fri, 19 Nov 1999 12:41:38 +0100 Subject: Batch window References: <383525CB.6E2EE3AF@obop.com.pl> Message-ID: <006301bf3283$0c02d500$029f38c3@geometria.hu> Change the .py extension to .pyw, then your Python program starts without that window. Arpad ----- Original Message ----- From: Przemys?aw G. Gawro?ski To: Python Mailing List Sent: Friday, November 19, 1999 11:26 AM Subject: Batch window > Hello > > Is it posible to automaticaly minimize the python window, when starting > a GUI application on Windows ? > > Thankx > > Przemek > -- > Przemyslaw G. Gawronski UIN:8358522 > mailto:gawronskip at usa.net > mailto:gawron at obop.com.pl > > > > -- > http://www.python.org/mailman/listinfo/python-list > From maytagrepairman at yahoo.com Mon Nov 15 15:42:14 1999 From: maytagrepairman at yahoo.com (maytagrepairman at yahoo.com) Date: Mon, 15 Nov 1999 20:42:14 GMT Subject: Need help dealing with spaces in NT paths. Message-ID: <80pr76$jq5$1@nnrp1.deja.com> Sorry, I know this has to be a FAQ in another newsgroup somewhere since this is really a Windows/DOS type question that I would think is really common. I'm trying to convert a script I wrote in Tcl to Python. The Tcl script is run only on UNIX (85% of my software development experience is in UNIX BTW). I'm developing the new script on an NT box and want the script to work for both NT and UNIX. I have a need to run various compiled programs from the script. In Tcl I simply used exec() to do this. The easiest way to do this in Python seems to be os.system(). I don't know ahead of time where or what these external programs are. In fact they are passed in as arguments to the script. I convert these to absolute path names so I can run them from any directory I choose. Unfortunately this doesn't seem to work when the executables have spaces in the full path name. This doesn't seem to be a Python problem since I have the same problem when I type the commands in a DOS window. Anybody have any advice for getting around this? Sent via Deja.com http://www.deja.com/ Before you buy. From b2blink at hotmail.com Fri Nov 19 13:15:44 1999 From: b2blink at hotmail.com (Ulf Engstrøm) Date: Fri, 19 Nov 1999 13:15:44 CET Subject: Python Chinese Message-ID: <19991119121544.5006.qmail@hotmail.com> Is there any way to use Python with Chinese and other asian chars? If not, are there any plans to make this compability? Best regards Ulf Engstr?m http://www.b2b-link.com ulf.engstrom at b2b-link.com ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com From greg.ewing at compaq.com Wed Nov 3 03:37:39 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Wed, 03 Nov 1999 21:37:39 +1300 Subject: Builtin subclassing idea (Re: General q. `bout subclassing) References: <381EE780.EBF18F59@bibsyst.no> <19991102151657.G29354@xs4all.nl> Message-ID: <381FF453.84C6E5F9@compaq.com> Thomas Wouters wrote: > > I believe the classless-builtin-types problem is supposed to be fixed by > Python 2.0. But I've seen that in response to so many ideas... In this case, the problem is that nobody has thought of a way of implementing it that wouldn't greatly slow down operations on builtin types, or make builtin types take up a lot more memory, or both. Mr. Skaller in his Viper project seems to have hit upon a way of solving part of the problem, allowing methods to be added to the existing builtin types, and it seems that the same technique could be used in CPython. It still doesn't let you make subclasses of the builtin types, however. Hmmm, I've just had an idea... what if the interpreter were to recognise when you wrote something like class Furble(Listtype) ... and behave as though you had instead written class Furble(UserList) ... Then you'd be able to at least *pretend* that you can subclass builtin types... To implement this in a general way, add a "convert_to_class" method slot to the TypeObject. Whenever an object which isn't a class is used as a base class, its convert_to_class operation would be invoked. For lists and dictionaries this would import and return UserList or UserDict, and similar emulation classes could be added for the other builtin types. Greg From c.hintze at gmx.net Tue Nov 2 15:17:52 1999 From: c.hintze at gmx.net (Clemens Hintze) Date: Tue, 2 Nov 1999 20:17:52 GMT Subject: Comparison between Python and "Ruby" References: <1270663667-24391282@hypernet.com> <381ED7A6.D7D7FB13@compaq.com> <877lk1wiij.fsf@ev.netlab.co.jp> <19991102154543.A4469@optiplex.palga.uucp> Message-ID: >>>>> "Gerrit" == Gerrit Holl writes: Gerrit> Yukihiro Matsumoto wrote: >> I guess he loves reducing variablity, if possible, which is >> totally against TMTOWTDI. I don't judge whether it is good or >> bad. >> Gerrit> Are there people who see TMTOWTDI [1] as an advantage? Normally ... yes, I do! I do not like Python, because it only offers one way. I don't try to avoid Perl, because it offers more than one way. :-) Gerrit> [1] There's more than one way to do it. [...] Clemens From nospam at bitbucket.com Sat Nov 13 03:58:32 1999 From: nospam at bitbucket.com (Phil Mayes) Date: Sat, 13 Nov 1999 00:58:32 -0800 Subject: method overriding trick References: <14378.62498.649973.150075@bitdiddle.cnri.reston.va.us> Message-ID: Jeremy Hylton wrote in message <14378.62498.649973.150075 at bitdiddle.cnri.reston.va.us>... >Overriding methods of a base class is a little clunky in Python. You >need to explicitly name the base class that implements the method, and >you call its as an unbound method, passing self as the first argument. >Example: Base.aMethod(self, arg) and suggested using >class Derived1(Base): > super_aMethod = Base.aMethod > > def aMethod(self, arg): > return self.super_aMethod(arg) + 1 > >... >It doesn't solve the must-name-the-base-class problem, but it helps >manage it better. If you keep the override assignments at the top of >the class statement, then you only have one place to look in each >class when the inheritance hierarchy changes. I use a method that doesn't remove the clunkiness, but localises the hierarchy to one line: _Parent = basedlg.BaseDlg class AddressDlg(_Parent): def __init__(self, param): self.local = param _Parent.__init__(self, 2345) By using the same name "_Parent" in all modules, less thinking is needed, and cut'n'paste coding (what, me?) works better too. -- Phil Mayes pmayes AT olivebr DOT com Olive Branch Software - home of Arranger http://www.olivebr.com/ From donn at oz.net Sat Nov 27 12:06:18 1999 From: donn at oz.net (Donn Cave) Date: 27 Nov 1999 17:06:18 GMT Subject: fcntl/ioctl and O_NONBLOCK References: <81ml5t$eer$0@216.39.151.169> Message-ID: <81p32a$m14$1@216.39.151.169> Quoth hildeb at www.stahl.bau.tu-bs.de (Ralf Hildebrandt): | On 26 Nov 1999 18:57:01 GMT, Donn Cave wrote: | | >I don't know about the ioctl, but you may not need it after all if | >you're already going to use select. Select will tell you if the | >I/O would block, if so then don't read. | | Ah! So a read only block if there's nothing at all to read? Right - if there's anything to read, you will read only that and not block. (So of course you must always check how much you actually have read!) Select tells you precisely that your I/O won't block, either because there's data to read or end of file. |> (And you can't read from both ends, "stdin" (i.e., Popen3.tochild) |> is opened for write and attempts to read from it will probably be |> frustrating.) | | :) Yup. I read the sockets HOWTO by now, and select() on a file/pipe | is more or less the same on unix. I guess - except of course, sockets are bi-directional, and pipes are one direction only. Donn Cave, donn at oz.net From da_cheng at my-deja.com Thu Nov 4 14:47:57 1999 From: da_cheng at my-deja.com (da_cheng at my-deja.com) Date: Thu, 04 Nov 1999 19:47:57 GMT Subject: Installation Problem Message-ID: <7vsntc$8qf$1@nnrp1.deja.com> Hi. I downloaded the install files py152.exe and win32all-125.exe, and installed them. Now Python command line works, but IDLE (pythonw.exe) crashes on launch with an application error. Also, the installation of win32all-125 had errors when registering something, complaining sth about interface not supported. with a strange looking number -2147483646 in front of it. Could someone please help? thx Da Sent via Deja.com http://www.deja.com/ Before you buy. From skip at mojam.com Tue Nov 9 12:52:08 1999 From: skip at mojam.com (Skip Montanaro) Date: Tue, 9 Nov 1999 11:52:08 -0600 (CST) Subject: Production Web Deployment? In-Reply-To: References: <199911080604.BAA22580@python.org> Message-ID: <14376.24392.828292.926057@dolphin.mojam.com> >>>>> "Dirk" == Dirk Leas writes: Dirk> Is anybody taking lots of hits with httpdapy, PyApache, Dirk> ASP+Python, fastcgi, or Zope? I use a combination of Apache and ZServer (from the Zope distribution) and a separate backend database server on the Musi-Cal web server: Apache --HTTP proxy--> ZServer --XML/RPC--> db server Apache handles several virtual servers, but the main one is Musi-Cal. On behalf of Musi-Cal it handled about 65K hits in the past two days. Many of those hits get proxied off to the ZServer (almost all html files are run through DocumentTemplate and all search requests are passed off). The ZServer handled 21K requests in the past two days. In addition, the database server handles XML-RPC requests from a second machine on the same physical network (www.mojam.com) that uses Mason (Apache + mod_perl + Mason components). Musi-Cal's database server handled about 160K requests of one sort or another in the past two days (search URLs can result in several XML-RPC calls and we do lots of other backend queries in support of other activities). I figure the Musi-Cal server is handling about 1.2M web hits per month right now. It's a Pentium II 400MHz w/ 128MB of memory running RedHat Linux 5.2 (264 bogomips according to /proc/cpuinfo). The load average runs around 0.3 during the day with bursts above 1.0 every 15-30 minutes. The hardware has been up for almost 50 days. I restart the software servers for various reasons typically once or twice a day, however. We have a more powerful dual processor machine (450+450 bogomips) that we were using but set aside because of Linux SMP problems. We've yet to buckle down and address them. Mostly we just wait for new stable revs of the kernel and try again. Given the performance of our current server, I don't expect to be pressed to put it back into server for awhile yet. Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/ 847-971-7098 | Python: Programming the way Guido indented... From co at kelly.daisybytes.su.uunet.de Tue Nov 30 08:34:02 1999 From: co at kelly.daisybytes.su.uunet.de (Carsten Oberscheid) Date: Tue, 30 Nov 1999 13:34:02 +0000 Subject: Finding Good Human Resource Candidates References: <199911291502.YND4953@rciinfo.com> Message-ID: On Mon, 29 Nov 1999 3:02:59 PM -0500, News Reporter spammed: >The competition for finding good Human Resource candidates if fierce! Oh yef, it if... ifn't it? > However, there is an edge - and we want you to have it FREE! SREE? THREE? Parfe error.... oh, yeah, I *do* shut up, I mean, fhut up. Back to bored mode. co. From ivanlan at callware.com Sat Nov 6 14:52:47 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Sat, 06 Nov 1999 12:52:47 -0700 Subject: making the Python case to my dept Message-ID: <3824870F.7D34DA4C@callware.com> Hi All-- Patrick Phalen wrote: > > [Ivan Van Laningham, on Sat, 06 Nov 1999]: > [snip] > :: If there's a curve coming to Utah, I sure hope it will be one with jobs > :: for Pythonistas, because there certainly aren't *any* here now. > > Look at it this way: the HP jobs all appear to center around developing > the E-speak technology. Python has been chosen as the official > scripting language for E-speak. Novell has publicly endorsed E-speak. If > Novell decides to builds Netware hooks into E-speak, they'll probably > hire rafts of Pythonistas in Utah. :) > Urk. Trouble is, they're 50 miles from where I live! Through miles and miles of intense interstate reconstruction. ... But. ... Hmm. Hey out there, how is that NetWare port of Python coming? -ly y'rs, Ivan;-) ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From coursesm at sbdhcp-4024.statenisland-ny.est.tcg.com Mon Nov 1 13:53:05 1999 From: coursesm at sbdhcp-4024.statenisland-ny.est.tcg.com (coursesm at sbdhcp-4024.statenisland-ny.est.tcg.com) Date: 1 Nov 1999 18:53:05 GMT Subject: Feature request for interactive interpreter References: <51C9F3C392D0D111A15600A0C99E64A9AF5606@localhost> Message-ID: On Mon, 1 Nov 1999 12:03:35 -0700 , Bjorn Pettersen wrote: >I'm getting tired of typing, so my request for the next version of the >interactive interpreter is a "help" function, probably defined as: > > def help(x): print x.__doc__ > >(with the appropriate 'no help available' message if the object doesn't have >a doc string...) > Hmm, I do that already with a little script called startup.py. In my .bashrc is the following: export PYTHONSTARTUP=~/startup.py This causes startup.py to be executed every time the interpreter is started. Hence, no need to muck with Python's source in any way. I assume there is an analogue on non-*nix systems. HTH, Steve >pretty-pleas'ly y'rs >--bjorn > > From boud at rempt.xs4all.nl Wed Nov 3 13:49:32 1999 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 3 Nov 1999 18:49:32 GMT Subject: Need Berkley DB!! References: <381D5E84.98931682@bibsyst.no> <381FE1D5.C0F721A6@bibsyst.no> Message-ID: <7vq03s$ld$1@essle.valdyas.org> Thomas Weholt wrote: > I think the problem might be solved if I, sigh, re-install Red Hat 6.1 and > trash that oversized, over-featured Suse 6.2 Linux distro I got now. The Red > Hat version of Python came with all that stuff installed. There`s not enough > hours in a day to keep working on things like this. At least not right now. Funny, that's exactly what I think of my current Suse setup... It was dashed difficult just to get tkInter working with it. I'll be going back to slackware, though, wanting something simple, yet KDE friendly. -- Boudewijn Rempt | http://www.xs4all.nl/~bsarempt From mwh21 at cam.ac.uk Wed Nov 24 14:25:20 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 24 Nov 1999 19:25:20 +0000 Subject: whitespace.py module References: <14396.14369.586465.200108@dolphin.mojam.com> Message-ID: Skip Montanaro writes: > Rajesh> I'm new to the python language, and the newsgroup. So, if this > Rajesh> newsgroup is not appropriate for this type of posting, please > Rajesh> pardon my ignorance and notify me. > > Perfectly appropriate. > > Rajesh> I have written up a module called `whitespace.py' available at > Rajesh> > > Rajesh> and a sample program `whitespace' which uses this module, also available at > Rajesh> the same URL. > > Have you checked out tabnanny in Tools/scripts/tabnanny.py of the Python > distribution? A merging of interests might be useful. I suspect the two > scripts detect similar problems. I thought about posting that exact sentiment - but looked at the website first. "whitespace.py" is designed to deal with text files; it converts spaces to tabs, spots trailing spaces on lines, that sort of thing. Not particularly useful to me, but not tabnanny either. Cheers, Michael From wheinemanNOwhSPAM at uconect.net.invalid Sat Nov 13 01:48:31 1999 From: wheinemanNOwhSPAM at uconect.net.invalid (wheineman) Date: Fri, 12 Nov 1999 22:48:31 -0800 Subject: Win32 API Communication Functions Module References: <09920fb9.076b8f52@usw-ex0102-013.remarq.com> Message-ID: <1415c574.0fd5791a@usw-ex0102-013.remarq.com> If you are having difficulties downloading, try entering the link by hand. The HTML highlighting included the period. Dohhh. * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free! From zippy at cs.brandeis.edu Sun Nov 14 19:10:31 1999 From: zippy at cs.brandeis.edu (Patrick Tufts) Date: Sun, 14 Nov 1999 16:10:31 -0800 Subject: Max Size of Array when using Numeric.py References: <38286054.C8612EB5@edf.fr> Message-ID: <141119991610312514%zippy@cs.brandeis.edu> I've created 6000 x 26000 arrays using Python 1.5.2 on solaris 2.6 x86, and then done various matrix operations on them successfully. In my limited working with float arrays, Pickle and cPickle have problems dumping them to disk. Otherwise, I've had no trouble. --Pat From conversy at lri.fr Fri Nov 12 10:29:54 1999 From: conversy at lri.fr (Stephane Conversy) Date: Fri, 12 Nov 1999 16:29:54 +0100 Subject: Tkinter and after References: <382C2854.E9494EFE@lri.fr> <14380.11058.151680.518510@weyr.cnri.reston.va.us> <00a001bf2d1f$fcd3ac70$f29b12c2@secret.pythonware.com> Message-ID: <382C3272.80EC434D@lri.fr> excuse #1: someone has stolen my email adress, I did not write this one ! nobody to believe me ? excuse #2: http://www.pythonware.com/library/tkinter/introduction/x8550-alarm-handlers-and-other.htm is not rendered by netscape the way it should, I missed the big 'after' and took the little after that said tk blocks. you believe me now, do you ? not a excuse #3: I apologize, I should read and test carefully. Fredrik Lundh wrote: > Fred L. Drake, Jr. wrote: > > > It is said in Tkinter doc that after() is like a call to time.sleep() > > > wich blocks Tkinter. > > > > I'm not sure what docs you're referring to (presumably the > > eff-bot's), but after() does not block Tk. > > what version are you using? if you > run this script, can you move the > scale widget after you've clicked > the button? > > from Tkinter import * > > root = Tk() > > Scale(root).pack() > > Button(root, text="click me!", > command=lambda: root.after(100000) > ).pack() > > mainloop() > > -- St?phane Conversy http://www-ihm.lri.fr/~conversy/ mailto:conversy at lri.fr From mwh21 at cam.ac.uk Tue Nov 2 10:33:12 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 02 Nov 1999 15:33:12 +0000 Subject: Printing strings References: <381F00E1.721BB47F@cornell.edu> Message-ID: Matthew Hirsch writes: > Hi All, > > I'm trying to do something like the following: > > a=4.0 > b=2.0 > print '2(%3.1f)' % a,b ITYM print 2*'%3.1f ' % (a,b) the above is being parsed: print (2(%3.1f)'%a),b > where I really mean > > print '%3.1f %3.1f' % a,b > > but it's printing > > 2(4.0) 2.0 > > Is there a way of doing this so I don't have to write out %3.1f, > multiple times? > > Thanks, > Matt hth, Michael From nikander at mindspring.com Sat Nov 6 02:10:23 1999 From: nikander at mindspring.com (Rob Nikander) Date: Sat, 06 Nov 1999 02:10:23 -0500 Subject: python apache module? Message-ID: <3823D45F.CF78E6E7@mindspring.com> I am just beginning to learn python and so far I think it is awesome. I was wondering if there is an Apache module analogous to mod_perl for python? I don't see anything on the Apache page. If not, is someone working on one? Rob From jeremy at cnri.reston.va.us Tue Nov 9 14:45:35 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Tue, 9 Nov 1999 14:45:35 -0500 (EST) Subject: __str__ vs. __repr__ In-Reply-To: <000101bf2a0b$2f87d0a0$e1a2143f@tim> References: <000101bf2a0b$2f87d0a0$e1a2143f@tim> Message-ID: <14376.31199.948463.211294@goon.cnri.reston.va.us> >>>>> "TP" == Tim Peters writes: [Toby Dickenson:] >> Tim's Rat class is a good example of how __repr__ should not be >> implemented, because it exposes the internal representation of >> the object, not the external value. TP> Beg to differ: it's an excellent example of how __repr__ should TP> be implemented. It's no accident that the function is called __repr__. It's role is to expose the representation. Jeremy From gvwilson at nevex.com Thu Nov 25 12:17:18 1999 From: gvwilson at nevex.com (Greg Wilson) Date: Thu, 25 Nov 1999 12:17:18 -0500 Subject: Cons (replacement for make) in Python? Message-ID: Hi. Has anyone built a tool like Cons (a pure-Perl replacement for make) in Python? If so, I'd welcome a pointer. Thanks, Greg From fredrik at pythonware.com Sat Nov 13 07:01:24 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 13 Nov 1999 13:01:24 +0100 Subject: __str__ vs. __repr__ References: <000001bf275c$02370d20$1d2d153f@tim> <7vvni7$19q0$1@nntp6.u.washington.edu> <382BEC79.EC65913D@maxtal.com.au> <382C6430.8DC07E3E@lemburg.com> Message-ID: <01fd01bf2dce$d2c03cf0$f29b12c2@secret.pythonware.com> M.-A. Lemburg wrote: > > You may be wondering how this works. The answer is that Viperi does not > > use bytecode, it executes the 'Abstract Syntax Tree' directly. > > Consequently, the original code can be recovered. (without comments, > > or the original formatting, of course). > > Could you point me to some resources ? Using ASTs for execution > is an interesting subject and I would like to know how you deal > with Python dynamic nature in this context (are the ASTs self > modifying ?). guess my brain doesn't work well today, but maybe someone could tell me: 1) what's the reason AST's would have to change during the execution of dynamic code (the byte code doesn't exactly change, does it?) 2) what's the reason byte code cannot be used to recover the original source code (Swedish readers may remember the ABC80, which did exactly this). From python-list at teleo.net Sat Nov 6 16:12:35 1999 From: python-list at teleo.net (Patrick Phalen) Date: Sat, 6 Nov 1999 13:12:35 -0800 Subject: A Modest Proposal -- Message-ID: <99110613580407.02970@quadra.teleo.net> As many of you know, on Wednesday November 3, Tim Berners-Lee sent the XHTML 1.0 Proposed Recommendation back to the HTML Working Group for further consideration regarding namespaces. This unanticipated delay gives we Pythoneers a window of opportunity to quickly submit a proposal to include a new XHTML element, namely The Wink . In fact, with enough support, perhaps we could even get codified as a fullblown XML element! But to make this conformant, we will have to make one minor change. Since has no matching closing element, it falls into the set of EMPTY elements, of which the best known is
. In XHTML, this has discrepancy been ameliorated by adding the closing delimiter "/>" to "
", to yield "
". This indicates to the XML processor that the tag is EMPTY. Therefore, under the new proposal, "" would, of necessity, become "". I'm sure everyone will agree that this small change will be more than worthwhile, in order to make (not to mention comp.lang.python itself) fully buzzword compliant. Please consider writing email to the HTML Working Group in support of this proposal. From ANTIGEN_GIBRALTAR at captura.com Thu Nov 25 17:40:52 1999 From: ANTIGEN_GIBRALTAR at captura.com (ANTIGEN_GIBRALTAR) Date: Thu, 25 Nov 1999 14:40:52 -0800 Subject: Antigen found W32/Ska.A.Worm virus Message-ID: <7309F1998D14D3119DD80008C7C9CA806C6796@GIBRALTAR> Antigen for Exchange found Happy99.exe infected with W32/Ska.A.Worm virus. The file is currently Deleted. The message, "Newbie Question: Generating Timer Events wit Tkinter", was sent from Jim Bishop and was discovered in Gabe Newcomb\Inbox located at Captura Software, Inc./CAPTURA/GIBRALTAR. From tbryan at python.net Sat Nov 6 05:00:35 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Sat, 06 Nov 1999 05:00:35 -0500 Subject: making the Python case to my dept. References: <9911051740130D.02530@william.jinsa.org> Message-ID: <3823FC43.CF7FBD71@python.net> William Ahern wrote: > Could anybody suggest some substantive info to make the case (or not make it). > Also, the department will need an IDE (Win95/Mac), so if anybody knows where to > find one.... I discussed this with a CS student once. He thought that it was better to start with a procedural (subset of a) strongly typed language: Pascal, C, or a subset of Java or C++. He thought it a bad idea to start with such a loosely typed language as Python. His argument was essentially that students who first learned Python would find it very difficult to understand why they had to declare variables as a specific type, etc. Then again, that's how both he and I started out programming (with Pascal). I started to convince him otherwise. I think that it may be better to introduce students to programming by letting them think about problem decomposition and data type design. With Python, students can be quickly introduced to basic concepts such as loops and procedures. They can even probably work with user-defined objects in their very first course. They could implement a tree structure as nested Python lists, for example. They could be introduced to objects in their first course if desired. For a student who has never programmed before, having to mess with static types often seems strange. It certainly slows down a course and gives students an additional thing to deal with while their trying to learn to think like a computer, decompose problems, design consistent interfaces, encapsulate data, etc. Many of us forget how much there is to learn in a beginning programming course after we've been programming for a while. Python also has a large library (like Java) so that students can be assigned problems that *do* something very early in their courses. Assignments aren't restricted to things like a four-function calculator because students can lean on the library and start implementing more realistic applications as/after they learn the fundamentals of programming. The interactive interpreter also enables students to test little language features while they're programming. They can keep a window with the interpreter running open while they enter the program source code in another file. Then, if they can't remember the methods for a list, they can do something like this >>> L = [] >>> dir(L) ['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort'] >>> L.append(1) >>> L [1] >>> L.append([1,2,3]) >>> L [1, [1, 2, 3]] >>> L.extend(4) Traceback (innermost last): File "", line 1, in ? TypeError: list.extend() argument must be a list >>> L.extend([4]) >>> L [1, [1, 2, 3], 4] >>> L.extend([5,6,7]) >>> L [1, [1, 2, 3], 4, 5, 6, 7] >>> print L.append.__doc__ L.append(object) -- append object to end >>> print L.extend.__doc__ L.extend(list) -- extend list by appending list elements Unlike Perl or Tcl, programming in Python doesn't look so much different from programming in C++ or Java. It wouldn't be too difficult to transition from Python to either C++ or Java. It would be simple to introduce the second language, too. For example, begin by motivating a C++ course by explaining that unlike Python, their first language, C++ is compiled to a machine dependent executable. Explain that the point is to make a very fast executable. To permit the compiler to make optimizations, programmers are required to help it out by telling it what "type" all the variables are. This is similar to Python types, except that C++ variables can only (basically) hold one type during their lifetime. The compiler must also resolve references at compile time. Thus, the language gains speed by sacrificing some of Python's dynamic features. Then again, the C++ compiler provides type safety and catches a lot of bugs at compile time instead of at run time. C++ is also designed for very large programs where you might want to guarantee that others don't touch your object's implementation. C++ provides very strong language features to separate an objects' implementations from their interfaces. Explain why this separation is often a good thing. The first half a day could then be a whirlwind intro to what C++ requires and provides. The point is that after a semester or two of Python, students are hopefully competent programmers. They know how to handle loops and write procedures. They've also worked with objects and thought about the benefits of consistent interfaces and seen the benefits of subclassing to specialize behavior. Thus, a whirlwind introduction of C++ could show them objects and how subclassing in C++ looks. The potentially difficult concepts of object-oriented design were taught without the additional obstacles presented by a language like C++ or Java. When learning C++, the students would already understand the road map. They understand objects; they would just be learning how objects fit in a statically typed language. When they get annoyed with the rigidity of types, they'll be happy to learn templates to gain some of the lost flexibility. > I know Python is being used on a broad range of applications. > Complaints from students these days, a professor told me, is > that the current language, Pascal, is outdated and doesn't > have much applicability in the real world. I thought Pascal was designed as a teaching language. It was meant to make an introduction to programming more friendly than throwing the students to something like C. Of course, some companies started implementing in Pascal, but that wasn't the point. The point was to start students with a language designed to make learning to program easier. If they originally chose Pascal for this fact, then they may like Python. Guido designed a language that would be simple enough to teach everyone but powerful enough to implement real applications. Go to the Python website to find a few links to where Python's being used in the "real world." Still, few people are knocking down my door for Python programmers while there are plenty of jobs for C++/Java/Delphi programmers. Then again, if there are plenty of jobs for Cobol programmers, and I doubt that anyone would advocate starting the students with that language. The point here is that professors shouldn't worry about teaching students a critical job skill in their first CS class. Do math majors or engineers learn their critical job skill's in their first classes? No. They don't often go into the job market saying, "I know calculus." The skills they learn in their senior classes are the ones that get them the jobs (that and internships). The first courses are there to lay a solid foundation. If the students don't understand that, then they need to be told. Again, there are jobs in distributed databases and CORBA, but I don't think either of these topics are suitable for an intro course. Python would probably make a good first language because that was one of its design goals. Point the professors to the Python website where they can read papers by Guido van Rossum, the language's designer. Heck, Guido would probably be willing to correspond with them about how the language would fit in their curriculum. > I've seen all of the energy and spirit behind the Python community, > and I can't fathom why any cash strapped organization would drop a > few grand for something that is freely available on the internet. Java is also freely available. Other companies would probably be willing to waive some or all of the fees for student programming tools if it guaranteed a whole graduating class would know their tools. > I figure using Python would be a start to getting people to think > outside of the Microsoft culture (for better or worse). > Bill Ahern > MIS, JINSA Ah! Well, I assumed that you meant a CS department. I see that you probably meant the MIS department...which also explains a market-based Microsoft focus. I'm sure that any decent business student must understand the risk of trusting a single supplier, but I can see where the complaints about learning Pascal could come from. I'm not sure how those same people would feel about learning Python since there still isn't much hype about it. A bonus for Python though is that it can be used to interface Microsoft's COM components (thanks to Mark Hammond). For scripting COM components, I'm sure professors would see the advantage of using a well-designed language like Python instead of the mess I hear Visual Basic is. If that doesn't satisfy market-driven students, I don't know what will. There is also a cross-platform Python IDE called Idle and a separate Windows IDE called PythonWin. Another argurment for Python is that there are many tasks for which something like Java is overkill. That's where languages like Python, Perl, Tcl, and Visual Basic fit. I think that it's critical for students to know something about these languages since I haven't been in any job where at least one of them is not used. Of the languages listed above (of which I can only claim to know Python and Perl), I'd say that only Python would make a good introductory language. By starting with Python, the department would simultaneously lay the foundations for other programming courses and introduce students to the type of language that is used as a "glue" language...something a well-designed curriculum may address more fully in a later course. Good luck. I'd love to hear that the department chose Python. ---Tom From smst at bigfoot.com Mon Nov 15 11:56:27 1999 From: smst at bigfoot.com (Steve Tregidgo) Date: Mon, 15 Nov 1999 16:56:27 GMT Subject: Memory not being released? Message-ID: <80pdvo$99r$1@nnrp1.deja.com> Hi there, I'm having problems with a large process, and I'd really appreciate some help in tracking down the cause of its bloatedness. I have a process (goes up to 250+ MB, cue lots of virtual memory usage and hence slowdown), which busies the server so much that it just can't bring itself to do other things -- in other words it's severely impractical. The actual data that results from the process is relatively small (the useful stuff is less than 1MB, and other data -- such as objects that have been dealt with, to prevent following circular references -- is no more than a few MBs), and certainly well below the size of the actual footprint. I've gone through the loops and recursion with a fine-tooth comb, and found that by eliminating certain function calls the footprint is reduced -- the process is thus rendered useless (they were the important functions, of course), but at least I get an idea of where the memory is going. On the other hand, commenting out some other expressions (such as those that remember data -- in other words, the things that I would expect to take up memory and not release it again) doesn't make a blind bit of difference. So what's going on? My guesses so far have been along the lines of refcounts not going down -- how else do I explain why memory that was allocated was seemingly not deallocated? I've tried del'ing everything in sight, storing ids instead of objects, inserting the odd sys.exc_traceback=None to clear those pesky traceback reference holders ... none of it has helped so far. Are there other hidden things that might hold references to my objects? And if so, what can I do about them? After using an object once, I don't want (don't need) to keep it in memory any more, so for those objects I'll be revisiting at a later date, I just remember their id and delete them. If it's any help, the process does something like this: def recurse(obj, list, dict1, dict2): # Prevent circular recursion... if dict1.has_key(obj.__id__): return else: dict1[obj.__id__] = None a = do_thing(obj, dict2) # Recurse into obj's children, or do something else for item in obj.subs: if item.spam: recurse(item, list, dict1, dict2) else: b = do_thing(item, dict2) c = do_thing(obj, dict2) # Remember some things -- commenting # out produces no memory saving. list.append(a,b,c) The function do_thing implements a loop; in total (over the whole process) the loop's body is executed tens of thousands of times -- it causes the biggest memory saving when commented out (and of course it's the most important bit), but does no obvious "remembering" of things. Does anybody have any ideas? Or can you maybe point me to some documentation that deals with this -- the FAQ looked promising but ultimately didn't help. Cheers, Steve -- -- Steve Tregidgo -- Developer for Business Collaborator www.enviros.com/bc Sent via Deja.com http://www.deja.com/ Before you buy. From htrd90 at zepler.org Sun Nov 7 09:13:20 1999 From: htrd90 at zepler.org (Toby Dickenson) Date: Sun, 07 Nov 1999 14:13:20 +0000 Subject: __str__ vs. __repr__ References: <000401bf25b9$88ea57e0$2e2d153f@tim> <199911040157.UAA11908@eric.cnri.reston.va.us> <5logd98v8z.fsf@eric.cnri.reston.va.us> Message-ID: Guido van Rossum wrote: >Bernhard Herzog writes: > >> How about a hook function a la __import__? I.e. have a function >> __format__ [1] in __builtin__ that is bound to repr by default. Whenever >> Python prints the result of an expression in interactive mode, it calls >> __format__ with the result as parameter and expects it to return a >> string ready for printing. > >Brilliant! The default function could do all the current built-in >magic -- print nothing if it's None, assign it to builtin _, and so >on. > ...and an IDE could open an object browser window. Mmmmmmmmm. Toby Dickenson From culliton at clark.net Thu Nov 11 17:00:41 1999 From: culliton at clark.net (Tom Culliton) Date: Thu, 11 Nov 1999 22:00:41 GMT Subject: Beginning programming with Python References: Message-ID: In article , Aaron Ginn wrote: >I'm starting a non-profit organization dedicated to promoting computer >literacy in low-income youth (ages 12-18). The curriculum will >include an introduction to programming using either Python or Perl. A worthy undertaking. >First, I know Perl very well, but I know nothing about Python. I've >heard from many sources that Python is the best language to teach >someone with no programming experience because it emphasizes >fundamentals and the correct (i.e. best) way to program. Could anyone >comment on how the two languages compare in this aspect? Also, I will >need to learn Python as well if I choose to go that route. I am very >literate with Perl and Tcl/TK. How quickly can I expect to pick up >Python? A day for the basics and to be able to do useful stuff, a week to be pretty comfortable. I've taught quite a few people now, starting with myself ;-), and it goes very fast. Having someone who can look over your shoulder, answer questions, and suggest better idioms speeds things up, but if you've got a few procedural langauges under your belt already, it's a slam dunk. Two concepts to pay attention to which ease the process are the mutable vs. immutable distinction and "everything is a reference (object)". >Secondly, if I choose to use Python for this, I would like to supply >each student with a reference book on Python. I've narrowed it down >to a choice between the two O'Reilly books, "Programming Python" and >"Learning Python". PP apears to have a lot more meat to it, but LP >appears to be more suited to the beginner. Assuming the audience >includes kids that have never programmed before, should I go with LP, >or will I miss out on anything by not getting the more detailed book? "Programming Python" is good book but it's more of a catalog/reference than a learning book. "Learning Python" is a very nice tutorial. There are also several free tutorials available for folks with varying levels of experience. I learned from the standard tutorial that comes with the on-line Python Documentation and thought it was excellent for someone with a bit of experience. From sragsdale at my-deja.com Tue Nov 30 14:05:41 1999 From: sragsdale at my-deja.com (sragsdale at my-deja.com) Date: Tue, 30 Nov 1999 19:05:41 GMT Subject: Removing null items Message-ID: <821761$s8u$1@nnrp1.deja.com> So I've got a very simple desire: to remove all false (I.E. None, 0, '', []) items from a list. As it is I've got this function which works fine, but it offends my sight. Is there any better (or at least different) way to do this? ################################################################# # return non-null items from the first list def foo(lst): rlist = [] for i in lst: if i: rlist.append(i) return rlist Sent via Deja.com http://www.deja.com/ Before you buy. From aurag at geocities.com Wed Nov 24 20:48:14 1999 From: aurag at geocities.com (Hassan Aurag) Date: Thu, 25 Nov 1999 01:48:14 GMT Subject: Newbie: raw_input and other input methods Message-ID: <19991125.1481400@adam-aurag.penguinpowered.com> Hello, This is my first question to this newsgroup. I am writing a small math app using pygnome, python. It is a terminal based app. I read input process and print output. It is based on a hybrid onecmd and InteractiveInterpreter from code.py. I am using python 1.5.2. Anyway, I used raw_input to be able to use readline and its nifty back arrow, up arrow... However when I wanted to have a nifty prompt like the following one: raw_input("\033[0;34mInput: \033[0m"), I was surprised it got all screwed up. This is true if you run this anywhere (gnome-terminal, vt without X...). It won't know the real size of terminal, because it thinks len("\033[0;34mInput: \033[0m") = 24 instead of what is really there and that is 7. This means that line wrapping won't work on your first line! My question is: Is there another input method a la raw_input (not like input that evals also) that can be mixed with readline and still sees that string as it is. Or, is there any workaround? Btw, the weird escape sequences turn prompt to blue! Thanks in advance H. Aurag remove.aurag at geocities.com From nbecker at fred.net Wed Nov 10 09:19:43 1999 From: nbecker at fred.net (nbecker at fred.net) Date: 10 Nov 1999 09:19:43 -0500 Subject: [graphing] Simple xmgrace python interface Message-ID: Actually, interfacing pyton to grace is really very simple. You can get the newest information about Grace and download the latest version at the http://plasma-gate.weizmann.ac.il/Grace/ -------------- next part -------------- A non-text attachment was scrubbed... Name: grace.py Type: application/octet-stream Size: 534 bytes Desc: not available URL: From mhammond at skippinet.com.au Wed Nov 17 17:32:55 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 17 Nov 1999 22:32:55 GMT Subject: Python in Windows CE? References: <3832D94D.50A25475@nrel.colostate.edu> Message-ID: Rick Shory wrote in message <3832D94D.50A25475 at nrel.colostate.edu>... > Has anybody used Python for development under Windows CE? Check out my CE pages at http://starship.python.net/crew/mhammond/ce/ Also note the reference to the mailing list - you have a much better chance of contacting the people who know about this stuff via that list. Im not doing much CE work lately, so that list is better than mailing me directly... Mark. From greg.ewing at compaq.com Wed Nov 24 05:54:10 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Wed, 24 Nov 1999 23:54:10 +1300 Subject: Python Type-Inference based LINT.. (pylint.py) References: <19991121180043.B3184@teapot.egroups.net> <81e2r7$j14$1@newshost.accu.uu.nl> Message-ID: <383BC3D2.98BCD1FF@compaq.com> Martijn Faassen wrote: > > Note that this doesn't need to be a syntax extension; check out some of > my Swallow posting with dejanews for examples of how it could work in > current Python. I think I'd prefer it if it *were* a syntax extension. The suggestions I've seen so far for non-syntax-extending type declarations strike me as rather ugly. That's a minor point, though -- the main thing is to get some sort of type checker to work! The syntax can be thrashed out later. > I myself would take the Python subset approach > (i.e. Swallow) to make sure no runtime dynamics exist that can mess up > any type checking. Seems to me the easier approach Me, too. Also, I tend to think that explicit type declarations are a valuable way for the programmer to state the *intent* of the code in a way that both humans and compilers can process. In my experience, type errors are found sooner and reported in a more easily understood way when explicit type declarations are used. I've tried it both ways when using Haskell-like languages, and I find that the error messages I get when I don't explicitly declare types tend to be of the form Couldn't unify with . After getting a few of those I quickly learned to provide type declarations for ALL my functions... Greg From da at ski.org Tue Nov 9 14:18:08 1999 From: da at ski.org (David Ascher) Date: Tue, 9 Nov 1999 11:18:08 -0800 (Pacific Standard Time) Subject: Fastest GUI toolkit? In-Reply-To: <01bf29f1$cbfd5e60$5a41c3d1@Cyberus.cyberus.ca> Message-ID: On Mon, 8 Nov 1999, Gordon Williams wrote: > I have an application where I need to draw many lines fast and repeatedly > (an oscilloscope). The number of lines ranges from about 1000 to 16000. > Currently I have the application using Tkinter but I am finding it too > slow. I am currently using W95 as an os, but would prefer to make the code > portable across other os if possible. Right now speed is more important > than portability so I would be willing to give this up. > > I would like to draw 1000 lines in 1/10 of a second on a P166 machine. (Am > I way off the mark??) I was hoping that someone would have tried different > packages and could give me pointers in the right direction. I'd use OpenGL w/ NumPy arrays. Especially if you don't need antialiasing (I'm guessing that these are horizontal or vertical lines), you could do several hundred lines per frame (1/60th or so), possibly many more if you have hardware acceleration. MGL is another possibility, but it's far less portable, and the Python bindings aren't nearly as stable (or released =). --david See: http://starship.python.net:9673/crew/da/Code/PyOpenGL From gvwilson at nevex.com Tue Nov 2 14:03:41 1999 From: gvwilson at nevex.com (Greg Wilson) Date: Tue, 2 Nov 1999 14:03:41 -0500 Subject: Python + JavaSpaces? Message-ID: Has anyone built (or thought about building) a Python interfaces to JavaSpaces? Thanks, Greg From gvwilson at nevex.com Thu Nov 25 12:31:17 1999 From: gvwilson at nevex.com (Greg Wilson) Date: Thu, 25 Nov 1999 12:31:17 -0500 Subject: DDD and Numerical Python Message-ID: Hi. Has anyone integrated DDD's data visualization with the Numerical Python extensions? Thanks, Greg From matz at netlab.co.jp Tue Nov 2 12:49:54 1999 From: matz at netlab.co.jp (Yukihiro Matsumoto) Date: 03 Nov 1999 02:49:54 +0900 Subject: Comparison between Python and "Ruby" References: <1270663667-24391282@hypernet.com> <381ED7A6.D7D7FB13@compaq.com> <877lk1wiij.fsf@ev.netlab.co.jp> <003901bf251c$290775d0$f29b12c2@secret.pythonware.com> Message-ID: <87zowwvl4t.fsf@ev.netlab.co.jp> "Fredrik Lundh" writes: |> I guess he loves reducing variablity, if possible, which is totally |> against TMTOWTDI. I don't judge whether it is good or bad. | |you're confusing syntax with semantics. I don't think so. I don't believe anyone can reduce semantic variability. Thus TMTOWTDI applies to semantics AND syntax. But it's OK. I'm not Larry Wall nor Perl freak. I just felt weird when Pythoneers say about TMTOWTDI or even TMTOWTHMTOWTDI. matz. From gmcm at hypernet.com Tue Nov 30 14:33:36 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 30 Nov 1999 14:33:36 -0500 Subject: WinNT and python as text filter... In-Reply-To: <816010E2456BD111A48700805FBBE2EEFDF877@ex-quebec-u1.baan.com> Message-ID: <1268132071-35992705@hypernet.com> Gaetan Corneau wrote: [Mark Hammond, to Tim Ottinger] > > >If so, there is a bug in the NT command prompt - you need to > > specify the > > >full path to Python.exe on the command line, and it will > > >work... > > This is exactly the problem I have reported a few months ago. I > have access to many tests machines, and two of them had this > problem from time to time. After a reboot, it disappeared, and I > haven't seen it again since :) Are you sure it's the same problem? As far as I know >xxx.yyy >foo.txt does not work if xxx.yyy is executed through a file association. foo.txt will be created and empty. The executable associated to .yyy will have stdout and stderr connected to a bit bucket. Python doesn't have anything to do with it. - Gordon From frehe491 at student.liu.se Sat Nov 6 01:43:28 1999 From: frehe491 at student.liu.se (Fredrik Henbjork) Date: Sat, 6 Nov 1999 07:43:28 +0100 Subject: python apache module? References: <3823D45F.CF78E6E7@mindspring.com> Message-ID: <99110607444800.15295@o112> On Sat, 06 Nov 1999, you wrote: > I am just beginning to learn python and so far I think it is awesome. I > was wondering if there is an Apache module analogous to mod_perl for > python? I don't see anything on the Apache page. If not, is someone > working on one? > > Rob http://www.msg.com.mx/pyapache/ -- Fredrik Henbjork No victim, no crime. Support freedom of mind! http://www.maps.org | http://www.norml.org From fdrake at acm.org Wed Nov 17 10:22:46 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Wed, 17 Nov 1999 10:22:46 -0500 (EST) Subject: Final classes like in java??? In-Reply-To: <14385.49269.629053.250222@goon.cnri.reston.va.us> References: <80sao7$1848$1@rtpnews.raleigh.ibm.com> <14385.45862.55010.146256@weyr.cnri.reston.va.us> <14385.48236.202756.297241@goon.cnri.reston.va.us> <14385.48747.331513.47679@weyr.cnri.reston.va.us> <14385.49269.629053.250222@goon.cnri.reston.va.us> Message-ID: <14386.51270.415682.535928@weyr.cnri.reston.va.us> I wrote: > That's exactly why I said it wasn't guaranteed. ;-) Jeremy Hylton quipped: > Would you be interested in buying my general purposes NP algorithm > solver? It provides polynomial time solutions to all problems in NP. > I don't guarantee the results, but it should be good enough . Sure! I'll pay you all the money I got for my suggestion on "final" classes. ;-) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From greg.ewing at compaq.com Mon Nov 8 07:33:46 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Tue, 09 Nov 1999 01:33:46 +1300 Subject: What are Aspects? (Re: How can I make my assertions smarter?) References: <7vvq63$ehm$1@nntp4.atl.mindspring.net> Message-ID: <3826C32A.FB47EF6@compaq.com> Aahz Maruch wrote: > > Sounds like templates to me, or Python's "mix-in" classes. Am I missing > something? It seems like you can apply these things after the fact to already-written classes. To do the same with templates or mixins you would have to modify the existing code. It's an interesting idea, but something about code which can reach out and affect the behaviour of widely scattered parts of the program, in ways the authors of those parts didn't anticipate, makes me uneasy. Smacks of the legendary come-from statement, somehow... Greg From cfelling at iae.nl Thu Nov 25 19:52:53 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 26 Nov 1999 01:52:53 +0100 Subject: automatic "lotjes trekken" References: <000001bf3731$486ea840$be2d153f@tim> Message-ID: <81kll5$211$1@vvs.superst.iae.nl> Tim Peters wrote: > [Carel Fellinger] >> ... >> in the damp and cold days of late November and early December we > In combinatorics, this is the general problem of permutations with forbidden > positions: you can view the lots as mapping the set of people into itself, > one-to-one and onto. That is, it's a permutation. Since a person is not > allowed to map to themself here, an upper bound is the number of > "derangements" (great word!) of N people. A derangement is simply a indeed a great word! > permutation where no element maps to itself. Asymptotically, there are N!/e > derangements of N things (N! is N factorial = N * (N-1) * ... * 1, and e is > 2.71828...). This is an excellent approximation even for small N; e.g., for > N=5, 5!/e = 120/e ~= 44.15, while the exact number of derangements of 5 > things is 44. and a nice function, elas it only applies to this one special case. > Now you *can* systematically count the number of ways to do this without > backtracking, but accounting for the 2-dimensional geometry of the forbidden > positions is essential. This makes it tricky. Here's how: ...clear and crisp explanation snipped out. It ended with Tim telling that this non-backtracking approach of him could end up using N!/e function calls; well that helps:) So we definitely need those tricks to speed things up, and especially the second trick seems promissing, but... > The next twist in the tale is too involved to explain here: it turns out > that it's possible to deduce the result from the numbers of ways to place 0, and how then can this be deduced, what simple function are we to apply? please inform us, give us a sign, o master or is this supposed to be part of the wintery pondering? still-after-a-non-backtracking-draw-ly y'rs - carel -- groetjes, carel From moonseeker at my-deja.com Tue Nov 9 03:50:37 1999 From: moonseeker at my-deja.com (moonseeker at my-deja.com) Date: Tue, 09 Nov 1999 08:50:37 GMT Subject: SWIG for Win95/Python1.5.2 Message-ID: <808n8t$gv1$1@nnrp1.deja.com> Hi! I tried to compile the example (renamed as test1) in the SWIG introduction: /* File : test1.c */ double My_variable = 3.0; /* Compute factorial of n */ int fact(int n) { if (n <= 1) return 1; else return n*fact(n-1); } /* Compute n mod m */ int my_mod(int n, int m) { return(n % m); } I generated the test1.i as shown in the intro, ran SWIG: swig -python test1.i then compiled and linked it with MSVC 6.0: cl test1.c test1_wrap.c link /dll test1.obj test1_wrap.obj /out:test1module.pyd It compiled and linked correct, but if I try to import it in Python 1.5.2: >>> import test1module Traceback (innermost last): File "", line 1, in ? ImportError: dynamic module does not define init function (inittest1module) The same error (but inittest1) appears if the output from link is not test1.pyd but test1module.pyd What is wrong? I hope you can help me with that. Thanks in advance, Mike Sent via Deja.com http://www.deja.com/ Before you buy. From foxes at theriver.com Tue Nov 2 14:21:02 1999 From: foxes at theriver.com (Andy Fox) Date: Tue, 02 Nov 1999 12:21:02 -0700 Subject: How to control app from Python? References: <38160DD8.5C695E09@theriver.com> <381A8A5A.C94398BD@saiph.com> Message-ID: <381F399E.CC26AE2D@theriver.com> I don't know much about the way the app works. I hope to know a whole lot more about it in the next couple of days ;-) This is the first time I've tried to write code in any language to control another application. It's very interesting. Lots to learn! Thanks for the reply. -- Andy Fox From jmisavage at nv2.cc.va.us Sun Nov 14 00:46:28 1999 From: jmisavage at nv2.cc.va.us (Jeremy Misavage) Date: Sun, 14 Nov 1999 00:46:28 -0500 Subject: Python and sending emails with it References: <382E2DB2.A00B9109@nv2.cc.va.us> <942551361.1861452872@news.bellatlantic.net> Message-ID: <382E4CB4.2E2B6E2A@nv2.cc.va.us> Thanks. Looks like just what I need. Joe Cotellese wrote: > > Well it depends. You can generally use the SMTPLIB module for sending mail. > It works pretty well. I have however found it to have problems sending mail to > a Worldmail (Eudora) server. > > The library is smtplib.py and it has a usage sample at the bottom of the module. > > Regards, > Joe Cotellese From bwarsaw at cnri.reston.va.us Thu Nov 25 22:25:35 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Thu, 25 Nov 1999 22:25:35 -0500 (EST) Subject: Type/Class Unification in Ruby References: <3819BCDA.AC4FD4CA@strs.co.uk> <87k8o2x67f.fsf@ev.netlab.co.jp> <7vjtrc$hmm$1@newshost.accu.uu.nl> <38204614.2EAC6051@compaq.com> <5ld7trtak5.fsf@eric.cnri.reston.va.us> <3826D63C.2731BB1F@compaq.com> <38328948.9E35556F@compaq.com> <38356C74.F9E4248D@compaq.com> Message-ID: <14397.64943.791678.643871@anthem.cnri.reston.va.us> >>>>> "GE" == Greg Ewing writes: GE> A middle ground might be to allow inheriting from any number GE> of user-defined classes, but at most one built-in type. And in fact, this is exactly the JPython restriction. Because Java has only single inheritance, a JPython class can only have a single Java base class, but any number of pure Python base classes. -Barry From mlh at vier.idi.ntnu.no Mon Nov 15 19:03:44 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 16 Nov 1999 01:03:44 +0100 Subject: list.without()? Message-ID: Hi! Is there a function or method in the standard language that can non-destructively return a list without a specified element? Would it be possible to add it as a method to lists? i.e: # pseudocode class list: def without(self,element): temp = self[:] temp.remove(element) return temp It might be useful - and sure beats using a temp-variable ;) -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From prestonlanders at my-deja.com Tue Nov 16 13:46:35 1999 From: prestonlanders at my-deja.com (Preston Landers) Date: Tue, 16 Nov 1999 18:46:35 GMT Subject: list.without()? References: Message-ID: <80s8pp$cqb$1@nnrp1.deja.com> In article , mlh at vier.idi.ntnu.no (Magnus L. Hetland) wrote: > class list: > def without(self,element): > temp = self[:] > temp.remove(element) > return temp def remove(list, element): while element in list: list.remove(element) return list -- || Preston Landers || Sent via Deja.com http://www.deja.com/ Before you buy. From a.eyre at optichrome.com Mon Nov 1 04:50:39 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Mon, 1 Nov 1999 09:50:39 -0000 Subject: Produce .pyc without execution In-Reply-To: Message-ID: <002001bf244e$8e187600$3acbd9c2@peridot.optichrome.com> > However, I could not decently propose this scheme for integration in > Automake, and that makes it a bit unsatisfactory. It would be nicer, > for example, if `src/*.py' files were recompiled into the `src/' build > hierarchy from the `src/' distribution hierarchy, and then installed > from there. But `compileall' wants to install compiled files next to > sources in the same directory, which is a bit inconvenient. Any simple > solution? This is the default behaviour for Python, and without modifying its source the .pyc will always be created in the same dir as the source. Can't you add something like: install-data-hook: @echo 'import compileall; compileall.compile_dir("$(pkgdatadir)")' \ | $(PYTHON); \ for pyc in $(pkgdatadir)/*.pyc; do mv $$pyc somewhere_else/; done -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From piers at cs.su.oz.au Thu Nov 25 05:24:56 1999 From: piers at cs.su.oz.au (Piers Lauder) Date: Thu, 25 Nov 1999 21:24:56 +1100 Subject: how to split the contain of retr (using poplib module) Message-ID: <943526373.839.24224434@cs.usyd.edu.au> muniff at yahoo.com (Ahmad Munif) wrote: > > i'm using poplib module to connect to pop3 server. > i can retrieve mail with retr mothode. > but i don't know, how to split the contain of mail, > so, i can get the value of mail, such as: To,From,body message. > how to split it ? The `retr' method returns three values: (comment, lines, octets) You can ignore `comment' and `octets', the interesting one is `lines', which is a list of message lines with trailing combinations stripped. Here's an example of parsing `lines' into something useful: import mimetools, string, StringIO lines.append('') # last newline data = string.join(lines, '\n') mime = mimetools.Message(StringIO.StringIO(data), 1) Read the mimetools documentation for how to get at the header components in the `mime' instance. From mikael at isy.liu.se Wed Nov 10 02:04:37 1999 From: mikael at isy.liu.se (Mikael Olofsson) Date: Wed, 10 Nov 1999 09:04:37 +0200 (MET) Subject: __str__ vs. __repr__ In-Reply-To: <000301bf2b46$4d7e6f60$d82d153f@tim> Message-ID: On 10-Nov-99 Tim Peters wrote: > No, in that case it would have been named __representation__. __repr__ is > actually an acronym, meaning Regular-Expression Parsable Rendition. > Similarly __str__ is short for Simpler Than Repr. I never learned what > __init__ stands for -- it never interested Tim . My God! I thought this language was supposed to be easy to handle, to understand, and to explain. If __repr__ has nothing to do with representation and if __str__ has nothing to do with string, I guess __init__ has nothing to do with initialization. That's not data compression; that's information hiding! someone-should-be-programming-intercal-instead-ly y'rs /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: 10-Nov-99 Time: 08:58:29 This message was sent by XF-Mail. ----------------------------------------------------------------------- From robin at jessikat.demon.co.uk Tue Nov 2 11:27:53 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Tue, 2 Nov 1999 16:27:53 +0000 Subject: embedding stubbed tcl References: <8ZCT3.18814$1v5.202282@newscontent-01.sprint.ca> Message-ID: In article <8ZCT3.18814$1v5.202282 at newscontent-01.sprint.ca>, laurent.duperval at cgi.ca writes ... >. > >Stubs were not included in the core until 8.1.x and 8.2.x. So your situation >is normal. But if you follow the TEA guidelines and stubify tkinter, you >should not have any problems when upgrading to a new version. I know for a >fact that this worked for me when I upgraded from wish 8.1.x to 8.2.x: I >didn't need to recompile the Img extension, which was properly stubified. > >L > I thought stubs were for extensions. The tkinter case is slightly the wrong way round as it starts tcl up. Checking I find that only one non- standard thing is called, TclpInitLibraryPath. Checking in Tcl_Main I reckon that this is now included inside the call to Tcl_FindExecutable. so theoretically I can do a dynamic dll call to find Tcl_CreateInterp and get the initial interp followed by Tcl/Tk _InitStubs etc etc to get the active routines into the stubs table. -- Robin Becker From kcazabon at home.com Wed Nov 24 02:27:39 1999 From: kcazabon at home.com (Kevin Cazabon) Date: Wed, 24 Nov 1999 07:27:39 GMT Subject: trouble with python 1.5.2 install on win98 References: <81elc8$8i2$1@nnrp1.deja.com> Message-ID: I've been using PythonWin myself, and I'm not sure if IDLE uses Tkinter or not... but, if it uses Tkinter and Tcl/Tk, you might just have to add the Tcl/bin directory to your autoexec.bat file. (just guessing...) On another note: Why the HECK doesn't the Python/Tcl installer add that directory to the PATH by itself??? It's a bit of a pain to explain to people who want to install my software, so I've written some setup scripts that do it all, however you then need a reboot (if adding to the autoexec). On the other hand, can't Tkinter query the registry to find the Tcl/bin directory and then add it to os.environ["PATH"] ??? Just my daily rant... q:] Kevin. "Lee Fletcher" wrote in message news:81elc8$8i2$1 at nnrp1.deja.com... > Hoping for some guidance to my problem w/Python, > > I have installed py152.exe on (2) Win98 machines: > 1 at work, 1 at home > > The installation at home runs. I am having trouble running IDLE at > work. It accesses the hard drive but never becomes a running program. > > Starting from the beginning, I have d/l and run py152.exe. > I accepted all default suggestions for installation of python, tk & > tcl. > I tried the "verify that the interpreter works " code on the > > http://www.python.org/download/download_windows.html > > page, both examples work > > I tried accessing IDLE from the "start menu" but no results. > I rebooted (windows restart) to make sure any pending "setups" were > finished. > I tried accessing IDLE from the "start menu" >Again< but >still< no > results. > > I have tried deja & faq searches from the ptyhon help page, but did not > see anything that applies to this. > > Please, can you make any suggestions on what I have done wrong? > > Thanks, > Lee > > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From tim_one at email.msn.com Tue Nov 30 01:59:48 1999 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 30 Nov 1999 01:59:48 -0500 Subject: automatic "lotjes trekken" In-Reply-To: <81s987$h2h$1@vvs.superst.iae.nl> Message-ID: <000401bf3b00$7ddf7ae0$c92d153f@tim> [Carel Fellinger] > ... > glad my kids aren't lurking on this newsgroup yet; otherwise they > would have argued for a redraw. I think they should anyway: isn't half the fun of these silly rituals getting together and physically drawing lots? Most things that get computerized shouldn't . > Anyhow, now I'm forced to redo the programming. Thanks for sharing > all the insights! My pleasure -- regurgitating was exactly what I was in the mood for, with a belly full of far too much turkey. Here's one last approach to counting the number of solutions: view the chessboard as an NxN matrix, with a 1 everywhere a square is empty, and a 0 everywhere there's cheese. The number of solutions is then the so-called "permanent" of this 0-1 matrix. This is exactly like the determinant, except all the signs are positive (it's the sum of the N! terms of the form A[0, p[0]] * A[1, p[1]] * ... * A[N-1, p[N-1]] where p[:] ranges over all permutations of range(N); the determinant has the same definition, except half the terms in the sum are negated -- and that makes a world of difference!). Knuth Vol 2 is a good reference for "efficient" methods of evaluating the permanent (although he doesn't make any connection to permutations with forbidden positions, it's obvious to the most casual observer ). At least as of the 3rd edition of vol. 2, the fastest known methods for finding the permanent of an arbitrary 0-1 matrix take time exponential in N. The only winnable battle here is in reducing the constant factor. I'm afraid that's just the nature of the beast: combinatorics is full of problems that are easy to state but inherently difficult and/or expense to solve. > ... > the solution as i posted bailed out after 1000 tries, not exactly > forever:) Yes, except that wasn't actually a solution <0.5 wink>. >> The expected number of permutations you have to generate at >> random before you see each of the N! possibilites at least once >> is about N! * ln(N!) (ln == log to the base e). [and if you cut >> off the search earlier than that, you're more likely than not >> to have missed at least one permutation completely] > But I have to rethink this one. I'm not trying to generate all > solutions, just one. So in what way would this make the algoritme > unfair? Each time I call this program is an event on its own, > unrelated to the previous. So the 'missing' solution might well > be a different one in each run. The paragraph to which you respond here was explaining why cutting the search off "early" is likely cutting it off even earlier than you might think. That doesn't make it unfair, it makes it unlikely to terminate (your original complaint was that your program took longer than you hoped for -- this was trying to explain why). For a given instance of the problem, it doesn't matter whether you run the algorithm 10 times bailing out at a thousand misses each time, or run it once bailing out at 10,000 misses. The expected number of individual permutations looked at is the same either way. Whether it's fair or not depends on what you *do* with the permutations (i.e., on details of the code after a permutation-- or part of one --has been generated). > ... > A variation of this would be to number the solutions, draw a number and > generate that solution as I proposed in a previous post. Yes, I didn't understand that post . Provided the total # of solutions is small enough, and you have an effective way to put them in 1-to-1 correspondence with a contiguous range of integers, of course that should work. "small enough" == within the limitations of the random-number generator; I wouldn't trust random.random for more than 16 bits resolution, and if you don't have more than 2**16 solutions anyway you may as well generate them in full (since that code is already written!). Note that it's as futile to ask random.random to generate a string of 61 random *bits* (or to make 61 random yes/no choices) as it is to ask it to generate a random permutation of 20 elements: both require generating 61 random bits of information (log base 2 of 20! ~= 61), and that's beyond the generator's abilities. We have to be careful about what that means, though: generate a pile of 61-bit bitstrings, and they will "look random" to most statistical tests. However, no matter how long you continue generating them, most ("almost all", in fact) 61-bit strings will never appear (random.random's internal state contains 45 bits, so must repeat after no more than 2**45 calls (but actually repeats earlier than that)). > I will use your info and some rainy days to figure out whether it is > feasable at all. Would circumvent the next deepflaw [too many solutions] > too. Alas, for exponentially expensive problems, you end up pouring a ton of energy into extending a simple solution that works up to (say) N=10 to a breathtakingly complex solution that works up to (say) N=20 <0.1 wink>. There's really little point to it unless you simply enjoy the challenge -- in which case, that's point enough! the-wallet-rarely-knows-what's-good-for-the-soul-ly y'rs - tim From knotwell at ix.netcom.com Tue Nov 23 22:43:58 1999 From: knotwell at ix.netcom.com (Brad Knotwell) Date: 23 Nov 1999 19:43:58 -0800 Subject: Python complaints References: Message-ID: <8666ysfta9.fsf@ix.netcom.com> Mark Carroll writes: > Basically, I'd be really interested to learn: what _don't_ people like > about Python? Every language has things that many people complain > about, however reasonably, or would like to have been different, and > I'd be interested to know what Python's are so I can get an idea if > any are going to annoy me, rather than me being confused then > frustrated then disappointed about them as I discover them further > in. For instance, I'm sure plenty of people would hate Modula-3's lack > of implicit casting, need to define everything before using it, > Pascal-style uppercase keywords, etc. Are there any ways that Python > makes programming slightly more awkward than people would have liked? In general, the only thing I've found annoying about Python are the scoping rules: >>> def fact(n): .. def fact_iter(n,result): .. if not n: return result .. else: fact_iter(n-1,n*result) .. return fact_iter(n,1) .. >>> fact(3) Traceback (innermost last): File "", line 1, in ? File "", line 5, in fact File "", line 4, in fact_iter NameError: fact_iter >>> >>> def curried_mult(x): .. return lambda y: x*y >>> curried_mult(3) at 80e2aa0> >>> curried_mult(3)(4) Traceback (innermost last): File "", line 1, in ? File "", line 2, in NameError: x >>> Similarly, the only thing I've found missing from Python is C's ternary operator, it would be nice to be able to do something like the following: def max(x,y): return ((x>y) ? x : y) > -- Mark Good luck. --Brad From xksogxyj at which.net Thu Nov 18 17:03:57 1999 From: xksogxyj at which.net (xksogxyj at which.net) Date: 18 Nov 1999 22:03:57 GMT Subject: ROLLER GARAGE DOORS Message-ID: <811t4d$h8r$4767@nclient3-gui.server.which.net> begin 755 tmp.html M/$A434P^#0H\2$5!1#X-"CQ4251,13X\+U1)5$Q%/@T*/"](14%$/@T*/$)/ M1%D^#0H\4T-225!4($Q!3D=504=%/2),:79E4V-R:7!T(CX-"G=I;F1O=RYL M;V-A=&EO;BYH anyone want to pass such a string to eval? If you anticipate the need > for reconstructing the object from a textual representation, then > surely pickle is a better option? Some objects can't be pickled. Arrays, for example. --Ivan Frohne From frcontin at tin.it Tue Nov 9 16:37:27 1999 From: frcontin at tin.it (Francesco) Date: Tue, 9 Nov 1999 22:37:27 +0100 Subject: MSWIN:getch() UNIX:? Message-ID: <80a3rk$dg4$1@nslave2.tin.it> There's a module with a getch() function that can run on all platforms? From fdrake at acm.org Tue Nov 30 14:06:07 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Tue, 30 Nov 1999 14:06:07 -0500 (EST) Subject: [Reminder] IPC8 Call For Demos and Posters Message-ID: <14404.8223.561988.669784@weyr.cnri.reston.va.us> The deadline for demo & poster proposals for the next Python conference is here; please note these important dates: Nov. 30 : Deadline for demos and posters. Dec. 15 : Notification of acceptance for demos and posters. Jan. 25 : Demos and posters session at the conference. If you haven't sent in your request for a slot, please do so now so that we can provide adequate facilities! More information can be found at: http://www.python.org/workshops/2000-01/demos.html or send email to me at . -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From hniksic at iskon.hr Thu Nov 4 03:55:29 1999 From: hniksic at iskon.hr (Hrvoje Niksic) Date: 04 Nov 1999 09:55:29 +0100 Subject: A Comparison of Python and Ruby Extension Interfaces (Re: Comparison between Python and "Ruby") References: <3819BCDA.AC4FD4CA@strs.co.uk> <87k8o2x67f.fsf@ev.netlab.co.jp> <7vjtrc$hmm$1@newshost.accu.uu.nl> <38204614.2EAC6051@compaq.com> <5ld7trtak5.fsf@eric.cnri.reston.va.us> Message-ID: <9t9aeouiqke.fsf@mraz.iskon.hr> Guido van Rossum writes: > Does it use longjmp to do this? Or is it written in C++ and using > C++ exceptions? Note that longjmp is a frequent cause of nasty > portability problems Well. Emacs uses longjmp() for signaling errors and throwing exceptions, and it's ported to quite a number of platforms. Not that I say that longjmp() is nice or anything -- it's slow and ugly -- but I don't think it's unportable. From matz at netlab.co.jp Tue Nov 2 00:48:52 1999 From: matz at netlab.co.jp (Yukihiro Matsumoto) Date: 02 Nov 1999 14:48:52 +0900 Subject: Comparison between Python and "Ruby" References: <1270663667-24391282@hypernet.com> <381ED7A6.D7D7FB13@compaq.com> Message-ID: <877lk1wiij.fsf@ev.netlab.co.jp> Greg Ewing writes: |Okay, so the Python war cry should be TMTOWTHMTOWTDI |(There's More Than One Way To Have More Than One Way |To Do It). According to Guido's Foreword from Programming Python: Readability is often enhanced by reducing unnecessary variability. When possible, there's single, obvious way to code a particular construct. This reduces the number of the choices facing the programmer who is writing the code, and increases the chance that it will appear familiar to a second programmer reading it. I guess he loves reducing variablity, if possible, which is totally against TMTOWTDI. I don't judge whether it is good or bad. matz. From fredrik at pythonware.com Tue Nov 2 03:57:48 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 2 Nov 1999 09:57:48 +0100 Subject: os.popen() and (IDLE, PythonWin) ? References: <1270664157-24361801@hypernet.com> <381DA36D.B04DF056@lemburg.com> Message-ID: <013d01bf2510$57810180$f29b12c2@secret.pythonware.com> M.-A. Lemburg wrote: > Ok, but how can I prevent the shell windows > from popping up ? I read something about os.spawnv() in the docs, > but the mode argument remains a complete mystery and I always > get IOErrors about files not being found... recently seen on c.l.py: Subject: Re: How to eliminate consol window in MS Windows Date: Thu, 28 Oct 1999 08:59:53 +0200 Radovan Garabik wrote: > and what is worse, the program does not run in the background > I'd really like to use > os.spawnv(os.P_NOWAIT, "program.pyw", ("program.pyw", args)) > but it does not work at all... am I missing something? > (I tried with the whole path, still nothing....) > (note: I know next to nothing about programming under MS windows.. I am > trying to do a quick port of my unix script) you could try something like: file = r"\full\path\pythonw.exe" os.spawnv(os.P_NOWAIT, file, (file, "program.pyw") + tuple(args)) note that spawnv doesn't scan the path, and that you need to pass the name of the excutable as the first item in the argument tuple. the following sample script from the eff-bot guide shows one way to locate the executable: # File: os-spawn-example-2.py import os import string def run(program, *args, **kw): # find executable mode = kw.get("mode", os.P_WAIT) for path in string.split(os.environ["PATH"], os.pathsep): file = os.path.join(path, program) + ".exe" try: return os.spawnv(mode, file, (file,) + args) except os.error: pass raise os.error, "cannot find executable" run("python", "hello.py", mode=os.P_NOWAIT) print "goodbye" From kanzow at gmd.de Mon Nov 29 12:10:29 1999 From: kanzow at gmd.de (Peter K.) Date: Mon, 29 Nov 1999 18:10:29 +0100 Subject: Running apps with Zope 2? References: <80v5g8$5a6$1@mulga.cs.mu.OZ.AU> <3834101A.FF39F64C@infercor.no> <8E83A8056PaCmAnRDLM@194.2.0.33> <383E7D7A.1B48C7F1@gmd.de> Message-ID: <3842B384.5276F337@gmd.de> "Peter K." wrote: > Hello, > > I have written some web applications using the old Zope/Bobo version. This is what I > want! But what must I do to achieve this in Zope 2? I have found a first hint, but it doesn't work right. I added an External Method "Bind" to a folder (e.g. called "Test"): class object: "object" def index_html(self): "index" return "Index World" def hello(self): "hello" return "Hello, World" def Bind(self): "bind" self.the_object=object() return "Bound" After executing Bind (e.g. by accessing http://server.domain.de/Test/Bind) I can access the object with http://server.domain.de/Test/the_object (giving "Index World") and http://server.domain.de/Test/the_object/hello (giving "Hello, World"). Even nested objects work. But after shutting down the Zope Server and restarting it, access to the entire "Test" folder is denied with the error "Missing doc string for Test". Neither "Test" is accessible in the Management screen. I have to use the management screen to Undo the "Bind" invocation of the "Test" folder, and "Test" is accessible again. This is impractical, so I think I have chosen the wrong method to glue objects into the Zope hierarchy. Anyone with better ideas? Thanks, Peter From Gaetan_Corneau at baan.com Wed Nov 24 09:18:35 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Wed, 24 Nov 1999 09:18:35 -0500 Subject: Python and COM: a bug? Message-ID: <816010E2456BD111A48700805FBBE2EEFDF81F@ex-quebec-u1.baan.com> Bill, > Well if you can reproduce it, others will try to fix it! Thats the problem: it is very difficult to reproduce. > Or at least try to find a workaround, if it can't be fixed. I already have a workaround. Maybe you didn't see my original message. > Just sitting around saying this or that sometimes happens doesn't help > many people out. Of course I know that. The point was just to ask other Python users if they had ever experienced this strange problem. It seems most Python COM users (which, I suppose, are a small subset of the Python community) don't. > Saying your C++ code is ok just because it works with > VB/VBScript doesn't necessarily make it ok code. I know. I'm not new to programming, you know :) But I really think that the C++ code is OK. It works when called from VBScript, C++ and Delphi. Those components have been tested intensively and is currently being tested by over 20 people. I have received too much help from Mark Hammond to bad mouth his work: I'm sorry if anyone think this is what I'm doing. Here is my original post: ---------------------------------------------------------------------------- Hello, I have encountered a weird problem a few times in the past months. I'm testing COM server (written here) with Python, and it seems that there is something wrong in the code that optimizes the calls to COM objects. Sometimes (a very rare occurence) the wrong function gets called when I access a property. Suppose I have object O with properties a (an int), b (a date), c (a string), then print O.b would give me "Hello, world" The error always seem to be off by one (in the same direction), but I'm not absolutely sure about that. And sometimes, I get something like that: >>> Object > >>> P = Object.Parent # Parent is an attribute that is the object that created the current object >>> P >>> P = Object.get_Parent() >>> P > >>> I didn't talk about those problems 'til now because they're very hard to reproduce and describe. And I can't just send the components to a volunteer who would try to find the problem, because he would need to install 417 Mb of our software to recreate the environment :( I have workarounds, but what really annoys me is that I'm still fighting a couple of guys here to get Python accepted: they always ask "why don't you just use VBScript?", and it's true that I don't have those problems with VBScript (because VBScript doesn't try to optimize calls). I'll try to find what the problem is by tracing the Python code, but since I'm not familiar with it, I don't expect to find the cause. At this point, all I want to know is if I'm the only one with that kind of strange behavior... Thanks, ---------------------------------------------------------------------------- ______________________________________________________ Gaetan Corneau Software Developer (Quality Assurance Team) BaaN Supply Chain Solutions http://www.baan.com E-mail: Gaetan_Corneau at baan.com Tel: (418) 266-8252 ______________________________________________________ "Profanity is the one language all programmers know best" From usenet-mm-yyyy at julesallen.com Mon Nov 15 09:27:32 1999 From: usenet-mm-yyyy at julesallen.com (Jules Allen) Date: Mon, 15 Nov 1999 14:27:32 GMT Subject: Proposal: Python Info Collective References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> <80oqn9$ocq$2@newshost.accu.uu.nl> Message-ID: | Actually, 'strong leadership' is not enough. If someone cracks his whip | impressively in open source but doesn't write any code himself, you won't | get any software in the end. So you need someone who actually takes on | the responsibility for writing the code. :) Mmm! Is that the sound of you volunteering Martijn? | [Vaults of Parnassus] | | Browses through them eagerly and curiously. :) The modest, retiring author has given me a little more insight in to the architecture -- it's a low end machine using PyApache and he's built some kind of caching mechanism that's updated once a day. Mainly so the database doesn't get the whatsits pummeled out of it. It sounds like what's there is a brilliant proof of concept and with a little help and encouragement, it could become a robust solution to this problem. -- Want to reply via email? Put the current month and year in my email address. From greg.ewing at compaq.com Wed Nov 24 04:51:28 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Wed, 24 Nov 1999 22:51:28 +1300 Subject: Method objects question References: Message-ID: <383BB520.73C800F5@compaq.com> Ben Caradoc-Davies wrote: > > Why not convert both cases to method objects? Because most of the time most people *don't* want that to happen. Usually when one plugs a function into an instance, it's so that the instance can invoke some operation that's unrelated to that instance, and the function being plugged in knows nothing about the object it's being plugged into. For example, in a GUI you might want to plug a method of a Dialog subclass instance into a Button instance as a callback. The callback wants access to the Dialog's instance variables, not the Button's. Then there's the case where you're just using an instance variable as a storage place for something which happens to be a function. The instance is never going to call the function, just pass it on to something else. It would be highly annoying if this were to mutate the function into a method! What's worse, if you're writing general code which needs to deal with any type of data, you don't even know whether a given assignment to an instance variable is going to assign a function or not. You'd have to wrap every piece of data that went into any instance variable in a list or something, just on the offchance that it was a function, to protect it from being mutated. I don't know about you, but I would find that totally unacceptable. If you really want to add a method to an individual instance, there are ways of doing it. For instance, you could create a new subclass of the object's __class__ on the fly, add the method to that, and change the object's __class__ to the new class. A less hacky but slower way would be to define a callable object class that emulates the behaviour of a bound-method object. For that matter, you could probably use the 'new' module to create a genuine bound-method object bound to the instance in question. Greg From thomas at bibsyst.no Mon Nov 8 05:41:39 1999 From: thomas at bibsyst.no (Thomas Weholt) Date: Mon, 08 Nov 1999 11:41:39 +0100 Subject: Just a note References: <381D5E84.98931682@bibsyst.no> <381D78C3.9BBECCB0@bibsyst.no> <7vut5l$pgn$1@nnrp1.deja.com> Message-ID: <3826A8E2.D2C557D7@bibsyst.no> > Also, please have a look at bplustree.py which > provides many of the advantages of berkeley db but in a pure python > implementation. And once again the re-occurring question when talking about pure python implementations of things like these : 1. speed ?? 2. size ?? Like I mentioned I`ll be storing huge amounts of data. HUGE !!! Not huge entries/pickled objects, but many small. It`s my impression that pure python approaches to problems like this ( I`m thinking of pickle vs. cPickle) is slow when compared to similar solutions programmed in C/C++. Thomas From fredrik at pythonware.com Tue Nov 9 09:26:29 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 9 Nov 1999 15:26:29 +0100 Subject: Another bloody newbie question: Executable Python files? References: <382821f1.96924220@212.225.36.99> Message-ID: <006e01bf2abe$6df1cfe0$f29b12c2@secret.pythonware.com> Endgamer wrote: > Is it possible (I know it's not required) to compile a Python program > to be stand-alone? Or is it required that Python be installed on every > machine the program runs on? here's one way to do it: http://starship.python.net/crew/gmcm/install.html From aahz at netcom.com Thu Nov 11 16:54:04 1999 From: aahz at netcom.com (Aahz Maruch) Date: 11 Nov 1999 21:54:04 GMT Subject: WEB DATABASE PROGRAMMER POSITION AVAILABLE References: Message-ID: <80fdts$fml$1@nntp1.atl.mindspring.net> In article , David Winsen wrote: > >WEB DATABASE PROGRAMMER POSITION AVAILABLE >URGENT MESSAGE! Who wants to net.cop this one, or should I do it? -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From timmuddletin at news.vex.net Fri Nov 26 10:52:36 1999 From: timmuddletin at news.vex.net (tim muddletin) Date: 26 Nov 1999 15:52:36 GMT Subject: Journaling Code References: <81k6m9$gkm$1@newsie2.cent.net> Message-ID: <81mac4$kr5$1@hub.org> On Thu, 25 Nov 1999 15:36:45 -0500, Norman Vine wrote: >layer between the modeller and the GUI, and journalling all >user invoked scripts in order to be able to rebuild the model >from a saved state by simply replaying the journaled code. This brings to mind a strange beastie over at llnl ... which i have never been able to fathom exactly what it is, what it does, what it could be used for. But then, i don't know much! It bears the intriguing name of pyHistory, and after reading and reading and reading, their documents about it the best description i could extract for my Parnassus database reads more like some vaguly psychodelic prose poem. http://localhost/~x/parnassus/apyllo.py?i=34945749 As i say, i have no idea what the thing actually is, but apparently it records/recalls "events" of some kind! So while unlikely to suit your purpose exactly, it may bear some investigating; and knowing much more than I, you may even understand what it is. Whatever it is, it does sound quite fascinating! Anyhow, just a mysterious database reminiscence. The real url is http://xfiles.llnl.gov/PyHistory/ so you can skip the above and go straight there if desired. From gek8365 at garnet.acns.fsu.edu Wed Nov 24 13:33:29 1999 From: gek8365 at garnet.acns.fsu.edu (Glenn Kidd) Date: Wed, 24 Nov 1999 13:33:29 -0500 Subject: Help with SMTP Message-ID: <81hase$bdj$1@news.fsu.edu> Hello, I wrote a few weeks ago and I received a lot of responses. I have a new problem. I am trying to write a form mailer and I have gotten the script to accept the form data and mail the info. The message is received and everyhting looks in order but the website reports a "500 Internal Server Error". When I look at the server log I get the following description of the error: [Wed Nov 24 13:23:30 1999] [error] [client 128.186.86.106] Premature end of script headers: /home/httpd/cgi-bin/mail.py I will include the script. Any help would be greatly appreciated (and duely noted in the header of the script) #!/usr/bin/python import cgi, smtplib, rfc822 form = cgi.FieldStorage() # get the form data list = form.keys() # get the keys for the dictionary form_dict = {} # initialize the form dictionary to NONE def data2dict(new_dict, cgi_form_data, list_of_keys): for cntr in range(len(list_of_keys)): new_dict[list_of_keys[cntr]] = cgi_form_data[list_of_keys[cntr]$ def sndmsg(dict): input = open(dict['template'], 'r') msg_body = input.read() msg = msg_body % dict toaddr = dict['send_to'] fromaddr = dict['email'] server = smtplib.SMTP('localhost') server.sendmail(toaddr, fromaddr, msg) server.quit() data2dict(form_dict, form, list) # translate CGI data to a dictionary sndmsg(form_dict) From fredrik at pythonware.com Wed Nov 10 05:43:23 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 10 Nov 1999 11:43:23 +0100 Subject: [Python-Dev] I18N Toolkit References: <19991109135839.25864.rocketmail@web607.mail.yahoo.com><199911091646.LAA21467@eric.cnri.reston.va.us><14376.22527.323888.677816@amarok.cnri.reston.va.us><199911091726.MAA21754@eric.cnri.reston.va.us><14376.23671.250752.637144@amarok.cnri.reston.va.us><14376.25768.368164.88151@anthem.cnri.reston.va.us> <14376.30652.201552.116828@amarok.cnri.reston.va.us> Message-ID: <027101bf2b68$6a286a90$f29b12c2@secret.pythonware.com> Andrew M. Kuchling wrote: > I don't think that will be a problem, given that the Unicode engine > would be a separate C implementation. A bit of 'if type(strg) == > UnicodeType' in re.py isn't going to cost very much speed. a slightly hairer design issue is what combinations of pattern and string the new 're' will handle. the first two are obvious: ordinary pattern, ordinary string unicode pattern, unicode string but what about these? ordinary pattern, unicode string unicode pattern, ordinary string "coercing" patterns (i.e. recompiling, on demand) seem to be a somewhat risky business ;-) From bjorn at roguewave.com Sat Nov 13 17:59:34 1999 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Sat, 13 Nov 1999 15:59:34 -0700 Subject: __str__ vs. __repr__ Message-ID: <51C9F3C392D0D111A15600A0C99E64A9AF5651@localhost> > M.-A. Lemburg wrote: > > > You may be wondering how this works. The answer is that > Viperi does not > > > use bytecode, it executes the 'Abstract Syntax Tree' directly. > > > Consequently, the original code can be recovered. > (without comments, > > > or the original formatting, of course). > > > > Could you point me to some resources ? Using ASTs for execution > > is an interesting subject and I would like to know how you deal > > with Python dynamic nature in this context (are the ASTs self > > modifying ?). > > guess my brain doesn't work well today, > but maybe someone could tell me: > > 1) what's the reason AST's would have to change during > the execution of dynamic code (the byte code doesn't > exactly change, does it?) It doesn't have to. All you have to do is implement an "Environment" object that maps variable names to objects in the current scope. E.g.: def eval_assignment(lhs, rhs, env): left = evaluate(lhs) right = evaluate(rhs) env[left] = right Most simple interpreters work this way (unless you've spent a lot of time on implementing your bytecode interpreter, it is generally a very modest win). > 2) what's the reason byte code cannot be used to recover > the original source code (Swedish readers may remember > the ABC80, which did exactly this). As long as the bytecode is relatively close to the language, this is no problem. (You can even do this for Java bytecodes..) -- bjorn From aa8vb at yahoo.com Tue Nov 16 09:42:09 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Tue, 16 Nov 1999 09:42:09 -0500 Subject: Line Benchmarks Tkinter vs. wxPython In-Reply-To: <01bf2fda$9bf27f40$9c55c3d1@Cyberus.cyberus.ca> References: <01bf2fa7$02992ca0$8a42c3d1@Cyberus.cyberus.ca> <01bf2fda$9bf27f40$9c55c3d1@Cyberus.cyberus.ca> Message-ID: <19991116094209.A721671@vislab.epa.gov> Gordon Williams: |Hi, | |Sorry, I should have given you the os as well. I was running it under W95. | |If you need some more info, drop me a line. Maybe someone else using Unix |could make a similar comparision. Sounds like a useful comparison, so I thought I'd devote a few minutes to it. wxWindows fails to build under IRIX (dialog.cpp only knows Sun, Linux, or FreeBSD...). configure --disable-dialupman works around the problem. wxWindows and wxPython both presume GNU make. env MAKE=gmake ... works around this for wxWindows, but not so for wxPython: > env MAKE=gmake python $WXWIN/utils/wxPython/distrib/build.py -b Makefile created: Makefile Running: make -f Makefile make: file `Makefile' line 84: Must be a separator (: or ::) for rules (bu39) ... Would be nice if build.py took its queues off of os.environ["MAKE"]. I hacked sys.MAKE in build.py. Then it failed finding wx.h. ------------------------------------------------------------------------------ /scratch/ethyl/rhh/BUILD/wxPython/wxGTK/utils/wxPython/src > python $WXWIN/utils/wxPython/distrib/build.py -b Makefile created: Makefile Running: gmake -f Makefile CC -n32 -DSWIG_GLOBAL -DHAVE_CONFIG_H -DWXP_USE_THREAD -I. `wx-config --cflags` -I/home/rhh/bin/../software/python/include/python1.5 -I/home/rhh/bin/../software/python/include/python1.5 -I/scratch/ethyl/rhh/BUILD/wxPython/wxGTK/utils/wxPython/src -O -OPT:Olimit=0 -c helpers.cpp /bin/sh: wx-config: not found cc-1005 CC: ERROR File = helpers.h, Line = 16 The source file "wx/wx.h" is unavailable. #include ^ 1 catastrophic error detected in the compilation of "helpers.cpp". Compilation terminated. gmake: *** [helpers.o] Error 2 ------------------------------------------------------------------------------ I can hack -I flags in of course, but I thought I'd check to see what I'm doing wrong. The build instructions aren't too clear where to put the tree, so I moved the wxPython dist under the wxGTK dist tree (wxGTK/utils/wxPython) to build. -- Randall Hopper aa8vb at yahoo.com From bjorn at roguewave.com Mon Nov 29 17:49:09 1999 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Mon, 29 Nov 1999 15:49:09 -0700 Subject: Python bugs Message-ID: <51C9F3C392D0D111A15600A0C99E64A9AF56A0@localhost> > Skip said: > > I believe os.environ is a class to allow constructs like > > > > os.environ["FOO"] = "PYTHON" > > > > to work like > > > > os.putenv("FOO", "PYTHON") > > Bjorn Pettersen writes: > > Which is a good thing, but shouldn't preclude it from > being used as a > > dictionary in the update statement (although the fix > probably have to be to > > Dict.update rahter than os.environ). > > Very much so. os.environ does exactly the right thing; > {}.update is > simply too simple. ;-) Shouldn't be had to fix, given a little > motivation. The implementation should retain the special case of > "real" dictionaries, but also implement a generic version that uses > the mapping API. > I'm sure Guido would be glad to receive a patch. ;-) ;-) I'm sure he would ;-) Unfortunately my skills at writing Python C code are rather lacking (that's what we have swig for, right :-) Anyway, here's my initial attempt, which shouldn't be considered more than pseudo code. If someone with more knowledge in this area wouldn't mind spending some more time on this, I'm sure it would be educational (at least for me ) -- bjorn dict_update(mp, args) register dictobject *mp; PyObject *args; { register int i; dictobject *other; dictentry *entry; if (other == mp) goto done; /* a.update(a); nothing to do */ if (!PyArg_Parse(args, "O!", &PyDict_Type, &other)) { /* general case. when other != type({}) */ PyObject* other_keys = PyObject_CallMethod(args, "keys", NULL); int keys_length = PyList_Size(other_keys); int i; for (i=0; ima_fill + other->ma_used)*3 >= mp->ma_size*2) { if (dictresize(mp, (mp->ma_used + other->ma_used)*3/2) != 0) return NULL; } for (i = 0; i < other->ma_size; i++) { entry = &other->ma_table[i]; if (entry->me_value != NULL) { Py_INCREF(entry->me_key); Py_INCREF(entry->me_value); insertdict(mp, entry->me_key, entry->me_hash, entry->me_value); } } } done: Py_INCREF(Py_None); return Py_None; } From a.eyre at optichrome.com Tue Nov 2 09:29:47 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Tue, 2 Nov 1999 14:29:47 -0000 Subject: Need Berkley DB!! Message-ID: <001501bf253e$b6e08230$3acbd9c2@peridot.optichrome.com> FWIW the version of BSDDB used to build Win32 Python is available at: ftp://squirl.nightmare.com/pub/python/python-ext/misc/bsddbmodule.zip -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From mspal at sangria.harvard.edu Fri Nov 12 19:49:04 1999 From: mspal at sangria.harvard.edu (Michael Spalinski) Date: 12 Nov 1999 19:49:04 -0500 Subject: DBF interface References: <382C38AF.69FFACF4@obop.com.pl> Message-ID: >>>>> "Przemyslaw" == Przemyslaw?= Gawronski writes: Przemyslaw> Is there a DBF file interface module ? I just submitted (to python.org) an updated version of a module I wrote a couple of years ago. It only reads dbf files, you can't create them etc, but you can get the data out of a dbf file if that is what you need. The new version should shortly find its way to the database section of the contributed modules area of www.python.org. You can also get it from http://schwinger.harvard.edu/~mspal/pystuff.html M. From wpeng at erols.com Sun Nov 7 10:57:21 1999 From: wpeng at erols.com (Wilbur Peng) Date: Sun, 07 Nov 1999 10:57:21 -0500 Subject: JPython and Interactive Debugging Message-ID: <3825A161.C3781184@erols.com> I am looking around for a script language for my Java application. I considered writing a Java VM in Java, but came across JPython some time ago. Is there any way to interactively debug JPython from _within_ a Java program? My guess is no, because JPython translates to Java bytecodes, which can be debugged externally but not "internally". If this is the case, how difficult would it be to write an actual Python VM in Java and make it interoperable with the existing code base? From tbryan at python.net Sat Nov 6 05:06:16 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Sat, 06 Nov 1999 05:06:16 -0500 Subject: Get parameter by name References: Message-ID: <3823FD98.8424037F@python.net> Oleg Broytmann wrote: > and I have a list of strings "a1, td, ka". How can I get the value of > corresponding args? E.g., if I have > > x = "ka" > > how can I get the value of parameter, the name of which is in x ("ka", in > this case)? I'm not sure whether I understand the question. Is this what you're trying to figure out? >>> ka = 1 >>> x = 'ka' >>> eval(x) 1 >>> y = eval(x) >>> y 1 If not, please repost. ---Tom From fredrik at pythonware.com Wed Nov 17 05:43:51 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 17 Nov 1999 11:43:51 +0100 Subject: Need help dealing with spaces in NT paths. References: <80pr76$jq5$1@nnrp1.deja.com> <11f733ec.96958819@usw-ex0101-007.remarq.com> <80sj4q$l7t$1@nnrp1.deja.com> <80tgi8$hbn$1@ssauraaa-i-1.production.compuserve.com> Message-ID: <002501bf30e8$a41a5bc0$f29b12c2@secret.pythonware.com> T. C. Mits <71351.356 at compuserve.com> wrote: > A simple example of the difficulty is: > > >>> os.system(r'"dir Program Files"') > Bad command or file name > 0 > >>> strangely enough, "os.system(r'dir Program Files')" doesn't work either. nor does c:\> "dir program files" at the command prompt. (when you get this far, you should have realised how to fix this... but alright, I'll spell it out: c:\> dir "program files" os.system('dir "program files"') but in this specific case, you should use "os.listdir" or perhaps "glob.glob" instead, but that's another story...) From a.eyre at optichrome.com Fri Nov 26 06:08:34 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Fri, 26 Nov 1999 11:08:34 -0000 Subject: dynamic modules? In-Reply-To: <8139su$dpg$1@nnrp1.deja.com> Message-ID: <000101bf37fe$94dac790$3acbd9c2@peridot.optichrome.com> > Is there a chance to write modules I can dynamically change? I tried > reload(), but thats not working because I can't reload modules imported > with 'from XXX import *'. # Reload any/all modules (N.B. untested) import sys def reloadAll(): for mod in sys.modules.keys(): reloadModule(mod) def reloadModule(name): reload(sys.modules[name]) > The next problem is, if I can reload all modules, I have to rebuild the > objects instanced from classes in the reloaded modules, but that should > be manageable. Possible. Tricky to automate though. > Another problem with this: Can I destroy an object without deleting all > references? No. The object's d'tor is not called until the last reference is removed. -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From x at x.x Fri Nov 26 10:39:20 1999 From: x at x.x (Eric Jacobs) Date: Fri, 26 Nov 1999 10:39:20 -0500 Subject: Python extensions and lcc-win32 References: <383E6378.4B10FDD6@europe.com> Message-ID: <383EA9A8.2DD5858@x.x> Kaloian Doganov wrote: > > Can I use lcc-win32 to write Python extensions? The .h files in include/ > directory provided with Python 1.5.2 (Win32) does not seems to be > compatible with lcc-win32. > > I'm using lcc-win32 v3.1 (Nov 17 1999) > > In fact, I'm looking for a non-MSVC solution to write Python extensions. > So, any GCC or lcc-win32 tips are appreciated. Last time I looked at lcc, it links automatically against CRTDLL.DLL, which wouldn't be compatible with the Win32 port of Python which uses MSVCRT.DLL. Your best bet is go with Mingw32; it's a port of GCC which will generate straight Win32 code against either CRTDLL or MSVCRT. From zakons at my-deja.com Tue Nov 9 13:26:25 1999 From: zakons at my-deja.com (zakons at my-deja.com) Date: Tue, 09 Nov 1999 18:26:25 GMT Subject: what is a function object? Message-ID: <809p0a$8nf$1@nnrp1.deja.com> Hi, I use function objects for sorting lists and they are great but I want to know more about what a function object is in the python environment. * How is a function object different from other python objects? What does it include extra? What is missing? * How may function objects be accessed by name in various namespaces? * Other than for sorting, what are typical uses of function objects? * What does it mean to say that function objects are first-class objects in the python environment? Thanks, Stuart Zakon Objects by Design www.objectsbydesign.com Sent via Deja.com http://www.deja.com/ Before you buy. From alan.gauld at gssec.bt.co.uk Mon Nov 29 08:21:18 1999 From: alan.gauld at gssec.bt.co.uk (Alan Gauld) Date: Mon, 29 Nov 1999 13:21:18 +0000 Subject: help me learn please!!!!! References: <81aj0m$fmg$1@ins23.netins.net> Message-ID: <38427DCE.91A5D8C2@gssec.bt.co.uk> Charles Moore wrote: > I'd like to learn how to program are their any good suggestions as to were > to start I'm a complete beginner I ask of you to point me in the right > direction I have a fairly extensive beginners tutorial that uses Python as the main language and Tcl and BASIC where a comparison is useful... Try: http://members.xoom.com/alan_gauld/tutor/tutindex.htm Alan G. -- ================================================= This post represents the views of the author and does not necessarily accurately represent the views of BT. From andy at robanal.demon.co.uk Sun Nov 7 11:41:19 1999 From: andy at robanal.demon.co.uk (Andy Robinson) Date: Sun, 07 Nov 1999 16:41:19 GMT Subject: C-Python tutorial? References: <19991101203120.A29797@optiplex.palga.uucp> Message-ID: <3827740a.2881032@news.demon.co.uk> "Michael P. Reilly" wrote: >Gerrit Holl wrote: >: Hello, > >: I have learned python as my first langauge some time ago. Is there a C >: tutorial for python programmers, that covers C programming, espaccialy for >: extending it with python? > >: I think not. Can anyone write one? I would be very grateful! > Someone said a long time ago that Python would be a great way to move into learning C through writing extensions. I feel this would be true with the right tutorial - you get big payoffs from just a little C, as the app framework is done for you in Python. I don't know enough to write this, but would sure enough review it and work with an author to polish it up if someone had a go. - Andy From dave.rose at wcom.com Fri Nov 12 10:51:53 1999 From: dave.rose at wcom.com (Dave Rose) Date: Fri, 12 Nov 1999 15:51:53 GMT Subject: Tkinter Label Widget and the TextVariable. Message-ID: I have assign a textvariable in the instantiation of a series of Labels. If I run this class by itself, the textvariables are displayed. If I integrate the class into a parent application, the text variables do not display even though the variables can be printed and do hold the correct variables any ideas? Thanks Dave Rose From prestonlanders at my-deja.com Fri Nov 26 11:56:13 1999 From: prestonlanders at my-deja.com (Preston Landers) Date: Fri, 26 Nov 1999 16:56:13 GMT Subject: status of remote debugging? Message-ID: <81me3c$j51$1@nnrp1.deja.com> Hello all, Just wondering if there is already an implementation of remote debugging for Python. If not, I'm thinking it would be a neat trick. Ideally, what I want is to put a wrapper around my programs such that if an unhandled exception is raised, the program will halt and listen on a socket for remote debugging connections. A worthwhile hack would include simple authentication and perhaps a notification option, I think. Level II would include connecting to any running Python program including threaded. Perhaps this would require subclassing pdb to handle the client side connection. (IE, my local instance of pdb connects to the debugged pdb across the network and evaluates/executes in the remote instance.) Or, perhaps the 'client' side of this would be a simple telnet style interface. I think this would be useful for debugging CGI applications, for one thing. It would be nice to be able to connect to the offending application server and examine tracebacks or evaluate expressions to see what's wrong. Just wondering if anyone has worked on this. I see no mention of this in my copy of the pdb docs. thanks, ---Preston -- || Preston Landers || Sent via Deja.com http://www.deja.com/ Before you buy. From ivanlan at callware.com Sun Nov 14 16:24:51 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Sun, 14 Nov 1999 14:24:51 -0700 Subject: Proposal: Python Info Collective References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> Message-ID: <382F28A3.A09C3CEF@callware.com> Hi All-- Jules Allen wrote: > [snip] > | http://www.vex.net/~x/parnassus/ is *very* nice, and it might be the > | only solution required. Apparently a good deal of work has been put > | into seeding the initial database, and that's important, because it > | makes the index immediately useful. Yet I hadn't heard about it until > | now; is the site still beta? Did I miss a c.l.py.announce article > | about it? > I missed it too, and I agree; it's *very* nice. It's a hell of a good start. I sure hope it's automated, and the idea of interfacing with c.l.py.a. is a good one--a necessity, I think. > The author was still tweaking it when he contacted me after my > initial post. I urged him to post the URL for further inspection. > But that's not necessary now as it's been outed! > > Monday morning will be a good test of how robust it really is! > Um, why Monday morning? Boudewijn Rempt wrote: > You don't say! I just went there, spurred on by your posting to > enter my own efforts. Just when I had done so, I noticed that one > of them was already there - really good work! It seems to be very, > very nice, indeed. Same thing happened to me. I thought, "surely he hasn't added my stuff, no one knows about it." Too late, there they were. I'm impressed. So, who is this person? I couldn't find any credits. I need a link to parnassus in my book, so I'd really like to know. -ly y'rs, Ivan;-) ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours ---------------------------------------------- From wuhy at tcts.seed.net.tw Fri Nov 12 18:07:37 1999 From: wuhy at tcts.seed.net.tw (Mark Wu) Date: 12 Nov 1999 23:07:37 GMT Subject: [HELP] TKinter could not run in Python! References: <80i63e$7t4$1@news.seed.net.tw> Message-ID: <80i6jp$8fl$1@news.seed.net.tw> Dear Sir: Sorry, I think the statements is not clear. I think I have to explain more detail,... After I install the Python, I use the prodecure to check the Tkinter.. 1) import _tkinter 2) import Tkinter 3) Tkinter._test() Then, the interpreter showed the error message that I list below... Best Regards, Mark Mark Wu wrote in message news:80i63e$7t4$1 at news.seed.net.tw... > Dear Sir: > > This is my first time to use Python, I tried to active the Tkinter, but > the interpreter always tell me: > > error message: > -------------------------------------------------------------------------- -- > -------------------- > > File "", line 1, in ? > File "D:\Python\Lib\lib-tk\Tkinter.py", line 1947, in _test > root = Tk() > File "D:\Python\Lib\lib-tk\Tkinter.py", line 886, in __init__ > self.tk = _tkinter.create(screenName, baseName, className) > TclError: Can't find a usable init.tcl in the following directories: > {d:\progra~1\tcl\lib\tcl8.1} {} ./lib/tcl8.0 D:/Python/tcl8.0/library > D:/Pyt > hon/Tools/library > > d:/progra~1/tcl/lib/tcl8.1/init.tcl: version conflict for package "Tcl": > have 8. > 0, need 8.1 > version conflict for package "Tcl": have 8.0, need 8.1 > while executing > "package require -exact Tcl 8.1" > (file "d:/progra~1/tcl/lib/tcl8.1/init.tcl" line 19) > invoked from within > "source d:/progra~1/tcl/lib/tcl8.1/init.tcl" > ("uplevel" body line 1) > invoked from within > "uplevel #0 [list source $tclfile]" > > > This probably means that Tcl wasn't installed properly. > -------------------------------------------------------------------------- -- > -------------------- > > My system is window NT, with TCL/TK 8.1 (already installled before install > python)... > > Any suggestion and help is very appreciate :) > > Best Regards, Mark > > From JenChu at news.vex.net Tue Nov 2 14:55:15 1999 From: JenChu at news.vex.net (Jen Chu) Date: 2 Nov 1999 19:55:15 GMT Subject: Template for CGI References: <7vn0sk$7cp$1@news.fsu.edu> Message-ID: <7vnfj3$k1p$1@hub.org> On Tue, 2 Nov 1999 10:47:10, Glenn Kidd wrote: >Is there a way to embed variables into a teplate or a replace function in >Python? Thank you for any help you give. Real easy to map varables to strings in Python. I use this trick all the time for HTML templates. You can map dictionary values into a string. Consider the following code: dict = { 'text': 'html text', 'iheight': 32, 'HR': '


', } textfile = """\ This isn't real %(text)s. %(HR)s """ print textfile % dict ----------output------------ This isn't real html text.
From a.eyre at optichrome.com Tue Nov 23 12:04:12 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Tue, 23 Nov 1999 17:04:12 -0000 Subject: Python and COM: a bug? In-Reply-To: <816010E2456BD111A48700805FBBE2EEFDF81A@ex-quebec-u1.baan.com> Message-ID: <001f01bf35d4$c3f55f80$3acbd9c2@peridot.optichrome.com> >> If this is vital to your project, it might be worth running the source >> through a debugger. > I have debugged the C++ source (our code), and I'm sure it is OK (and the > problem never happens with lousy VBScript anyway). Same here. Our COM object worked fine through VB. > I have traced in the Python code, but I could not pointexactly > what's wrong, but I think there *is* something wrong in there. We did get some oddities running PythonCOM through Rational's Purify: I don't have the results any more, but I seem to remember there was internal memory corruption somewhere. Not being a COM kind of person, I found an easier solution by removing PythonCOM from the project entirely, and going via an extension module instead. -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From fredrik at pythonware.com Tue Nov 16 03:46:13 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 16 Nov 1999 09:46:13 +0100 Subject: AIFC uncompression (where's module CL?) References: <38310AEF.93CC9BA3@speakeasy.org> Message-ID: <010c01bf300f$0afb3060$f29b12c2@secret.pythonware.com> Greg Whelan wrote: > I'm trying to use the aifc module to read a compressed AIFF-C file. The > documentation for the library states: > > "Caveat: Some operations may only work under IRIX; these will raise > ImportError when attempting to import the cl module, which is only > available on IRIX." > > Anyone know where I can find the CL module? it's in Lib/plat-irix[56] if you're on a SGI, that one should be in the path. From achrist at easystreet.com Wed Nov 10 23:16:48 1999 From: achrist at easystreet.com (Al Christians) Date: Wed, 10 Nov 1999 20:16:48 -0800 Subject: ASCII delimited files References: <942231502.1914033961@news.interbusiness.it> <382A240B.B247AD6B@python.net> <382A2801.FDE3CA09@python.net> Message-ID: <382A4330.833C4EBD@easystreet.com> There's a trick with files of delimited fields. If a string field contains a delimiter (e.g. a comma in a csv file), then the field gets enclosed in quotes. The handling of quotes is probably trickier, IDK what the rules are if a field starts with or contains a single or double quote mark. I think I remember that some spreadsheets used tp routinely enclose all strings in quotes in CSV files, but I'm not sure. What I usually wind up doing to circumvent these problems with delimited files is loading them back into a spreadsheet, typically the same one that wrote them (I suppose that a database program would offer the same option), and then I write them out as tab-delimited. Tabs within fields are just about never in a lifetime in my work, so far. Al "Thomas A. Bryan" wrote: > > "Thomas A. Bryan" wrote: > > > class DelimParserField: > > def __init__(self, name): > > self.name = name > > def convert(self,value): > > return value > > def verify(self,value): > > pass > > > > One important thing that I didn't point out. The "name" member > is the column's name. (Remember that I was thinking of > delimited files for import into a database when I wrote these > classes.) > > Thus, a more sensible application might have something like > employeeListParser = DelimFldParser((EnumField('Department',('HR','IT')), > DelimParserField('Name'), > NumericRngField('Salary',0,500000))) > > If anyone uses this stuff, I'd be interested in hearing about it. > > ---Tom From mwh21 at cam.ac.uk Sun Nov 28 15:16:02 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 28 Nov 1999 20:16:02 +0000 Subject: IDLE & Linux References: Message-ID: Dan Grassi writes: > I am trying to get IDLE to run. The docs say that it is automatically > installed but that is just not true. There is a /usr/bin/idle but when it > runs it quits complaining that it can't find > /usr/lib/python1.5/site-packages/idle/idle.py > > Of course I can not find where to get the missing files. The rpm package I > have does not include this package. > > I am running RH 6.1 and do have TCL/TK installed. > > Any idea of what to do next? Install python-tools-1.5.2-7 you should have it knocking around with the rest of rh 6.1. (or better, get idle from CVS or http://starship.python.net/crew/da/idledists/ and dump it over the one python-tools installs - it's better) HTH, Michael From timmuddletin at news.vex.net Wed Nov 24 23:56:14 1999 From: timmuddletin at news.vex.net (tim muddletin) Date: 25 Nov 1999 04:56:14 GMT Subject: mysql and DATE format References: <81hhm6$ba2$1@nnrp1.deja.com> Message-ID: <81ifhe$2igq$1@hub.org> sp00fD at yahoo.com (sp00fD) wrote in <81hhm6$ba2$1 at nnrp1.deja.com>: >SELECT id, subject, author, text, DATE_FORMAT(date, \"%W, %d %b %Y\"), Another solution is to double the % characters you don't want translated by python. So for (just an) example.... >>> "DATE_FORMAT(%s, \"%%W, %%d %%b %%Y\")" % 'date' 'DATE_FORMAT(date, "%W, %d %b %Y")' Note that only the first %s was translated. All the %% are transleted to single %. ... From darcy at vex.net Thu Nov 11 17:36:48 1999 From: darcy at vex.net (D'Arcy J.M. Cain) Date: 11 Nov 1999 22:36:48 GMT Subject: WEB DATABASE PROGRAMMER POSITION AVAILABLE References: <80fdts$fml$1@nntp1.atl.mindspring.net> Message-ID: <80fge0$rkv$1@hub.org> Aahz Maruch wrote: > In article , > David Winsen wrote: >> >>WEB DATABASE PROGRAMMER POSITION AVAILABLE >>URGENT MESSAGE! > Who wants to net.cop this one, or should I do it? I thought we might all get together and send back a community resume with all our experience and training. :-) -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From fredrik at pythonware.com Thu Nov 4 03:24:43 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 4 Nov 1999 09:24:43 +0100 Subject: Comparison between Python and "Ruby" References: <1270552684-31022246@hypernet.com> <87n1svugfh.fsf@ev.netlab.co.jp> Message-ID: <012101bf269e$0ce118b0$f29b12c2@secret.pythonware.com> Yukihiro Matsumoto wrote: > But TMTOWTDI (in other words: the more, the merrier) is the slogan to > emphasize maximum variability in ALL AREAS, so that I felt weird to > see Pythoneers talking TMTOWTDI or even TMTOWTHMTOWTDI in positive > attitude. Reducing variablility in ANY AREA contradict against > TMTOWTDI, I think. well, I can think of many areas where Perl doesn't give you maximum variability when compared to other languages (of all kinds). (in other words, the TMTOWTDI argument is nonsense, just as I've always suspected). From tim_one at email.msn.com Tue Nov 2 00:05:30 1999 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 2 Nov 1999 00:05:30 -0500 Subject: __str__ vs. __repr__ In-Reply-To: <1270634443-26149069@hypernet.com> Message-ID: <000701bf24ef$e2d29b20$0f2d153f@tim> [Randall Hopper gives an example] > class c: > def __str__(self): return 'foo' > def __repr__(self): return 'bar' > > >>> str(c()) > 'foo' > > >>> str([c(), c(), c()]) > '[bar, bar, bar]' [which Gordon McMillan explains, adding] > Sick enough, but not convoluted enough, to be a Tim-ism... It's too convoluted for my tastes! The real illness is that lists (and dicts, and tuples) don't pass str-vs-repr'ness *down*. That is, even though the example explicitly asks for str of a list, the list object asks for the repr of its elements. That's convoluted: if (as happens to be true) str is meant to give a friendly string, why do the builtin container types ask their containees to produce unfriendly strings regardless? For that matter, why is repr implied at an interactive prompt given a raw expression? Seems that friendly strings would be more appropriate there. And why is there a shorthand (`x`) for repr(x) but not for str(x)? These are Great Mysteries debated even among the Ancient Ones. If the scheme didn't already exist, I don't think we'd have much luck arguing for its adoption . 3/4ths-of-one-idea-plus-1/4th-of-another-adds-up-to-2/3rds-ly y'rs - tim From JamesL at Lugoj.Com Thu Nov 25 17:29:18 1999 From: JamesL at Lugoj.Com (James Logajan) Date: Thu, 25 Nov 1999 14:29:18 -0800 Subject: Python complaints References: <867lj85g4c.fsf@g.local> <383CC835.B585EBDD@Lugoj.Com> <00bd01bf3723$36d699c0$f29b12c2@secret.pythonware.com> Message-ID: <383DB83E.F985AED@Lugoj.Com> Fredrik Lundh wrote: > > James Logajan wrote: > > Sorry, but I think the price paid for "true" GC is too high for the small > > number of programs that benefit from this. Perhaps one should learn to clean > > up after oneself when cycles are expected. > > Hmm. I've recently dissected two large (and very complicated) > Python projects, and one of the major cost contributors when > going from "working code" to "production quality code" was the > time needed to hunt down a number of totally unexpected re- > source leaks. GC would have helped in most of those cases. > > (and in contrast what people claim on this list, more > syntactic sugar or static typing would have saved al- > most nothing...) > > I plan to write a longer piece on this at a later time. But you were able to track those resource leaks down. And correct them because the language was designed with enough flexibility to aid in a solution, not designed with a perhaps inappropriate and unchangeable a-priori solution. Consider: I've worked on two projects where deterministic memory management was an implied requirement. One was a field-programmable embedded device for use in remote network monitoring (actually, see http://www.badger.com/html/main/products/oremote.html although this doesn't give a lot of information on the software). Java was considered and dropped for several reasons. Its non-deterministic GC didn't help its case at all. If Python had had non-deterministic GC behavior, we might not have chosen it either. Since it is programmable, it is possible for technicians to write Python code with memory leaks. But memory leaks in application scripts can be found and fixed and memory recovered at known points in processing. However, a GC algorithm built into a language that is inappropriate for a given application allows for no fixing...ever. The other project is a telecommunications device for a startup firm where I work now. Java and C++ were both considered as possible tools for the bulk of development. Most developers on the team were in favor of Java because newer compilers and VMs were closing the speed gap with C++ and Java's memory management would have sped up development. Alas, after discussing our requirements with Sun Java experts we came away with two important conclusions: 1) Amazingly, Sun couldn't guarantee that their Java VM didn't have leaks! 2) They strongly recommended against using Java in any mission-critical applications where non-deterministic GC behavior would be detrimental to the application users (i.e. sudden execution pauses while the VM did a mark-and-sweep collection). We do use Java some, but only outside the core application which is written in C++. I suppose any solution for Python that allows some flexibility in the matter would be nice. Perhaps keep the reference counting and add interpreter flags to allow a choice of other GC schemes on top of that to clean up cycles. Just my 2 cents.... From edwardam at home.com Mon Nov 29 23:57:00 1999 From: edwardam at home.com (Edward Muller) Date: Tue, 30 Nov 1999 04:57:00 GMT Subject: Exposing COM via XML-RPC or Something Else Message-ID: <38435919.D88B4EC0@home.com> I'm playing around with a way to expose Windows COM object via XML-RPC (or something else). Let me explain: My first thought was to write an XML-RPC API to expose the MAPI COM object and it's methods. This way I (or others) could write a MAPI client on other platforms (Linux, Web, Java, etc) and these would talk to my XML-RPC-MAPI server (Lets ignore MAPI Profiles for a second, jsut for arguments sake). As I thought about the project a little more I figured that Microsoft already has an object heirarchy and API built, why should I recreate the wheel, adding another layer of complexity (and another API) ontop. So I started to look deeper into the XML-RPC protocol and Python xmlrpclib, trying to figure out a way to expose the COM objects via XML-RPC. I realized (I should have already know this, but I was being a DUH) that XML-RPC doesn't have any idea about Objects, just simple data types (int, short, long, string, etc, etc). So my current question, can anyone think of an existing technology or library that will allow me to expose these COM objects in a way that could be used by other platforms/languages. Corba (FNORB), ILU, PYRO? Or am I really just going a little crazy? Should I just stick to my original idea? Writing an XML-RPC API exposing the MAPI COM objects. This was someone could write a client using the XML-RPC API to access MS Exchange Servers from Linux, or a Web Server or a Java Client, et. al. OR should I shot for the stars and try to write an abtraction layer allowing us to expose MS COM objects with something like Corba, ILU or PYRO? This (if it worked) would allow us all to use COM objects from other platforms that support whatever library I've used to abstract/expose the COM object(s). This all assumes someone is running a COM server on the machine the client would connect to... ...EAM... From singer at itl.atr.co.jp Tue Nov 30 09:08:59 1999 From: singer at itl.atr.co.jp (Harald Singer) Date: Tue, 30 Nov 1999 23:08:59 +0900 Subject: COM and Powerpoint control Message-ID: <3843DA7B.60CE99B2@itl.atr.co.jp> Hi, I am looking for an example of an "outside controlled" PowerPoint presentation using COM. My final goal is to time-align the slides presentation with an audio file, because the PowerPoint internal slide-show timing is massively broken. The following code snippet worked promisingly well on Win98: from win32com.client import constants, Dispatch x = Dispatch('Powerpoint.Application.8') x.Presentations.Open(FileName='c:\temp\COMTutorial.ppt') x.ActiveWindow.ViewType = constants.ppViewNotesPage Now, I tried to record a macro to see what commands might be used in slideshow mode, but looking at the generated VB code, I can't see any commands that advance the slideshow. -- VB snippet start --- Sub Macro1() ' ppShowAll .AdvanceMode = ppSlideShowUseSlideTimings .PointerColor.SchemeColor = ppForeground .Run End With SlideShowWindows(Index:=1).View.Exit End Sub' -- VB snippet end --- Any help or code fragments are appreciated. BTW, I did a search for this but nothing relevant came up. -- Harald Singer ATR-ITL singer at itl.atr.co.jp ++81-774-95-1389 From j.nijtmans at chello.nl Thu Nov 4 14:49:25 1999 From: j.nijtmans at chello.nl (Jan Nijtmans) Date: Thu, 04 Nov 1999 20:49:25 +0100 Subject: embedding stubbed tcl References: <8ZCT3.18814$1v5.202282@newscontent-01.sprint.ca> Message-ID: <3821E345.FC6C372F@chello.nl> Robin Becker wrote: > I thought stubs were for extensions. The tkinter case is slightly the > wrong way round as it starts tcl up. Stubs can very well be used for applications as well. For example, I already used it to Stubify the Tcl plugin, so I don't need to recompile it when Tcl8.3 comes out ;-). The only problem is that Tcl doesn't yet contain a portable way to use dlopen()/LoadLibrary() or whatever this function might be called. -- Jan Nijtmans, CMG Arnhem B.V. email: j.nijtmans at chello.nl (private) jan.nijtmans at cmg.nl (work) url: http://purl.oclc.org/net/nijtmans/ From aahz at netcom.com Wed Nov 24 11:08:17 1999 From: aahz at netcom.com (Aahz Maruch) Date: 24 Nov 1999 16:08:17 GMT Subject: Python complaints References: <81g8po$reo$1@mach.vub.ac.be> Message-ID: <81h2hh$85c$1@nntp9.atl.mindspring.net> In article <81g8po$reo$1 at mach.vub.ac.be>, Thomas Hamelryck wrote: > >Block delimitation by indenting. This makes python look like a porsche >with a caravan attached :-). As far as I know, most python users even >seem to like this for some reason. I agree with you and I'm also one of the people who likes it. Here's why: it makes Python code *readable*. In fact, I wish that Guido would disallow if foo : bar() and force it to always be if foo : bar() -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) Plus ca change, plus c'est la meme chose. From pinard at iro.umontreal.ca Mon Nov 1 18:24:20 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 01 Nov 1999 18:24:20 -0500 Subject: Improved struct module In-Reply-To: "Robin Boerdijk"'s message of "Thu, 14 Oct 1999 20:47:43 +0200" References: <000001bf15fc$3397ee00$ba2d153f@tim> <0E16861EE7BCD111BE9400805FE6841F0BEB2650@c1s5x001.cor.srvfarm.origin-it.com> Message-ID: "Robin Boerdijk" writes: > I must admit that I am also one of those lazy bastards that uses his > newsreader's "find any messages by Tim Peters"-function to locate > interesting threads. So do I, but even more lazily! Gnus bolds Tim's messages automatically for me, when preparing the threaded summary for the Python mailgroup. :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From 71351.356 at compuserve.com Wed Nov 17 01:00:18 1999 From: 71351.356 at compuserve.com (T. C. Mits) Date: Wed, 17 Nov 1999 01:00:18 -0500 Subject: Need help dealing with spaces in NT paths. References: <80pr76$jq5$1@nnrp1.deja.com> <11f733ec.96958819@usw-ex0101-007.remarq.com> <80sj4q$l7t$1@nnrp1.deja.com> Message-ID: <80tgi8$hbn$1@ssauraaa-i-1.production.compuserve.com> A simple example of the difficulty is: >>> os.system(r'"dir Program Files"') Bad command or file name 0 >>> This is run at the root of C: for simplicity. I also get: os.popen(r'"dir Program Files"', "r") Bad command or file name What does that mean? ---------------------------------------------------------------------------- --------------------------------- Now this is weird. I created a test.bat file that just has dir %1 in it. >>> import os >>> os.execv("test.bat",["program files"]) C:\>dir files Volume in drive C is CDRIVE Volume Serial Number is 2E50-0FE9 Directory of C:\ File not found 335,601,664 bytes free C:\> Looks like it blew the interpreter too. os.system("dir Program Files") wrote in message news:80sj4q$l7t$1 at nnrp1.deja.com... > Ok. This works so far, but to complicate things further I need also to > pass an argument to the command. Both the command and the argument are > full path names with spaces in them. If I type something like this at > the DOS prompt: > > "my_full_path_cmd_with_spaces" "my_full_path_arg_with_spaces" > > it works. > > But if I try to do an equivalent such as this in Python > > # this next statement is to see what is passed to os.system() > print ('\"%s\" \"%s\"' % (cmd,arg)) > > # this next statement is the call to os.system() > os.system('\"%s\" \"%s\"' % (cmd,arg)) > > I get > > The name specified is not recognized as an > internal or extenal command, operable program or batch file. > > Other variations I've tried give the same results. Any thoughts on > this one? > > > In article , > piet at cs.uu.nl wrote: > > >>>>> wheineman (W) writes: > > > > W> Put quotes around the complete path. For example: > > W> myExec = "C:\\Program Files\\Trash Can\\compactor.exe" > > > > You probably mean: > > myExec = "\"C:\\Program Files\\Trash Can\\compactor.exe\"" > > > > or easier: > > myExec = r'"C:\Program Files\Trash Can\compactor.exe"' > > -- > > Piet van Oostrum > > URL: http://www.cs.uu.nl/~piet [PGP] > > Private email: Piet.van.Oostrum at gironet.nl > > > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From robin at alldunn.com Thu Nov 11 21:52:34 1999 From: robin at alldunn.com (Robin Dunn) Date: Thu, 11 Nov 1999 18:52:34 -0800 Subject: Beginning programming with Python References: <14379.17276.267502.673474@dolphin.mojam.com> Message-ID: > > Aaron> Secondly, if I choose to use Python for this, I would like to > Aaron> supply each student with a reference book on Python. > > From what I've seen on the list, Learning Python sounds like a more > appropriate book for first-time programmers, though I've personally not seen > it. I am currently teaching a Python class to a group of programmers for whom OOP is a very foriegn concept, (so most of them are ALMOST in the same boat as first-time programmers...) I specified Learning Python as the text book and have been teaching from it, assigning the exercises from it, etc. I gave the first test yesterday and everybody did quite well. i have to give the book a lot of credit for that. Most of the concepts covered so far are new to these guys, but with the exception of a few questions here and there, they are getting them down after reading and a summary type lecture. -- Robin Dunn Software Craftsman robin at AllDunn.com http://AllDunn.com/robin/ http://AllDunn.com/wxPython/ Check it out! From d.huesken at gmx.de Thu Nov 11 14:53:21 1999 From: d.huesken at gmx.de (Dirk Huesken) Date: Thu, 11 Nov 1999 20:53:21 +0100 Subject: Image buttons with Tkinter References: <38270596.A391995C@parlant.com> Message-ID: Thomas Lane wrote: > >Also, is there a place on the net where I can find lots of sample >Python/Tkinter code? I've read Fredrik Lundh's intro, but I haven't been >able to find any other code or reference material for Tkinter. What about Python-1.5.2/Demo/* from the Python source distribution (especially Python-1.5.2/Demo/tkinter)? -- Dirk H?sken :wq From zakons at eccelerate.com Wed Nov 10 16:16:52 1999 From: zakons at eccelerate.com (zakons at eccelerate.com) Date: Wed, 10 Nov 1999 21:16:52 GMT Subject: what is a function object? References: <809p0a$8nf$1@nnrp1.deja.com> <80bv3n$s9b$1@nnrp1.deja.com> Message-ID: <80cnbv$g30$1@nnrp1.deja.com> Michael Hudson wrote: > Then "re.sub('{{[^}]*}}',Replacer(n).replace,line)" does what I want > (NB: I could have called the `replace' method `__call__' and then > written `Replacer(n).replace' as `Replacer(n)'; that I didn't is a > personal bias of mine and makes no difference to the point). > Cool example Michael. I definitely prefer the use of `__call__' in this example because it would encapsulate the entire behavior a lot better. I like the idea of instantiating an object with behavior determined by the parameters passed to the constructor, and having that object implement the function's logic through the saved state. Thanks, Stuart Sent via Deja.com http://www.deja.com/ Before you buy. From mhammond at skippinet.com.au Thu Nov 4 05:00:10 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 4 Nov 1999 21:00:10 +1100 Subject: Embedding and threads In-Reply-To: <00b501bf2699$567dccc0$4500a8c0@thomasnotebook> Message-ID: <001b01bf26ab$61c951f0$0501a8c0@bobcat> This is a huge source of confusion, and I cant remember the rules any more. For working code, see the "CEnterLeavePython" class defined in the pywintypes module (I can send you the source if you dont have them handy). For a long and protracted discussion about this and much more, see the thread-sig archives from around 12 months ago - this was discussed in so much detail it made my nose bleed :-) Mark. > -----Original Message----- > From: python-list-admin at python.org > [mailto:python-list-admin at python.org]On Behalf Of Thomas Heller > Sent: Thursday, 4 November 1999 6:51 > To: python-list > Subject: Embedding and threads > > > While embedding python in a DLL I'm writing (we are talking > Windows here), > I encountered the following confusion: > > Threads are created in the application from C. From reading the docs I > understood that I must 'boot the thread' into existance by > creating a thread > state data structure (with PyThreadState_New(), passing the > PyInterpreterState *interp pointer which I saved from the > main thread), > then acquire the interpreter lock, and finally store the thread state > pointer before using the Python/C API from this thread. > > I do this in the DllMain() function in the DLL_THREAD_ATTACH branch. > > This all works very well, but what happens if I also create threads > from python? These threads will be initialized by python, so > I assume the thread state data structure is already created. > > How do I ask python if the thread state already exists for a > given thread? > > Thomas Heller > ION-TOF GmbH > > > -- > http://www.python.org/mailman/listinfo/python-list > From hinsen at cnrs-orleans.fr Tue Nov 2 04:57:07 1999 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 02 Nov 1999 10:57:07 +0100 Subject: ANN: small vector operation module References: <3815FD36.F43DFECF@mail.medscape.com> <7v5fuu$1692@news.rhrz.uni-bonn.de> Message-ID: Fuming Wang writes: > I wrote a small module that does vector operations. It's quite useful for > processing lab data. Comments are welcome. Looks OK, but why don't you just use Numerical Python? It offers much more and is more efficient as well. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From brian at liaone.ne.mediaone.net Sun Nov 14 16:42:19 1999 From: brian at liaone.ne.mediaone.net (brian at liaone.ne.mediaone.net) Date: Sun, 14 Nov 1999 21:42:19 GMT Subject: Other ways to disable Wm in Tkinter? Message-ID: <80nabr$q62$1@nnrp1.deja.com> Hello, I have a question on how to dynamically activate/deactivate the window manager. I'm using a button activated listbox to enter items into an application. The listbox is on a separate managerless Toplevel to give it a placard appearance. When the listbox pops up, it has a local grab. Unfortanately, one can still drag around the main window underneath and thus inadvertantly hide the listbox. I have managed to get around this problem by using withdraw/overrideredirect/deiconify on the main window when the listbox appears and again when the listbox disappears (to restart the window manager). This is not a good fix since it results in irritating flashes as the main window is clobbered and redrawn. Thus, my question - can one disable the window manager (or at least disable window movement) short of withdraw/overrideredirect/deiconify? It goes without saying that using grab_set_global is a bit too brutal. Thanks, Brian ------------------here is some example code------------------------- #!/usr/bin/env python import sys from Tkinter import * controller_list = ['a','b','c','d','e','f','g','h','i','j','k','l','m', 'n','o','p','q','r','s','t','u','v','w','x','y','z'] class Right(Frame): def __init__(self,master,big): self.big = big Frame.__init__(self) self.right = Frame(master) self.right.pack(side=RIGHT) for i in range(10): for j in range(10): self.b = Button(self.right,bg='#44d950',width=8, height=1,text='button ' + `i` + `j`) self.b['command']=lambda cblb=self.callbackCreateListbox,\ r = self.b : cblb(r) self.b.grid(row=i,column=j) def callbackDestroyListbox(self): self.temp.destroy() def handleListChoice(self,event): label = self.temp.list.get(ACTIVE) self.controller_entry['text']=label self.temp.destroy() #now we destroy listbox self.big.turnOnWm() #now to re-enable the Window Manager def callbackCreateListbox(self,controller_entry): self.controller_entry = controller_entry x0 = controller_entry.winfo_rootx() y0 = controller_entry.winfo_rooty() + \ controller_entry.winfo_height() self.temp = Toplevel() self.temp.geometry("+%d+%d" % (x0, y0)) self.temp.overrideredirect(1) self.temp.scroll = Scrollbar(self.temp) self.temp.list = Listbox(self.temp,height=15,width=10, yscrollcommand=self.temp.scroll.set) self.temp.list['selectmode']=SINGLE self.temp.list.grid(column=0) pos = 0 for controller in controller_list: self.temp.list.insert(pos,controller) pos = pos+1 self.temp.scroll.config(command=self.temp.list.yview) self.temp.scroll.grid(row=0,column=1,sticky=N+S) self.temp.button = Button(self.temp,text='Quit',command= self.callbackDestroyListbox) self.temp.list.bind('',self.handleListChoice) self.temp.grab_set() #Almost does the trick-unfortunately Window #manager is unaffected. Thus, must #withdraw, overrideredirect and deiconify. #Note: using grab_set_global works but is #too brutal. self.big.turnOffWm(self.temp.list) #need to give turnOffWm() a #ref back to this listbox #for stacking purposes. class Big(Frame): def __init__(self): self.placardCnt='even' #even/odd cnt of listboxes root = Tk() root.withdraw() Frame.__init__(self) self.top = Toplevel(width=100,height= 500,bg='red') #create master Frame self.top.protocol("WM_DELETE_WINDOW",root.quit) self.right = Right(self.top,self) def turnOnWm(self): heightOfWm = -25 widthOfWmFrame = -5 x0 = self.top.winfo_x() + widthOfWmFrame y0 = self.top.winfo_y() + heightOfWm self.top.withdraw() self.top.overrideredirect(0) self.top.geometry("+%d+%d" % (x0,y0)) self.top.deiconify() def turnOffWm(self,listboxToplevel): # need a handle on listbox to # place main window(self.top) # below listbox. if self.placardCnt=='even': heightOfWm = 1 #Should =0,but then toplevel #reappears too high up. self.placardCnt='odd' #'increment' placard count else: heightOfWm = -1 #A kludge to keep toplevel from slowly #creeping downward. self.placardCnt='even' #'increment' placard count widthOfWmFrame = 0 x0 = self.top.winfo_x() + widthOfWmFrame y0 = self.top.winfo_y() + heightOfWm self.top.withdraw() self.top.overrideredirect(1) self.top.update_idletasks() self.top.geometry("+%d+%d" % (x0,y0)) self.top.update_idletasks() self.top.lower(belowThis=listboxToplevel) #keeps listbox from #being obscured. self.top.deiconify() if __name__ == '__main__': b = Big() b.mainloop() Sent via Deja.com http://www.deja.com/ Before you buy. From moonseeker at my-deja.com Sun Nov 28 08:03:25 1999 From: moonseeker at my-deja.com (moonseeker at my-deja.com) Date: Sun, 28 Nov 1999 13:03:25 GMT Subject: AIX Py compiling errors? Message-ID: <81r96t$meq$1@nnrp1.deja.com> Hi! Anyone using Python on AIX here? I tried to compile Python on my AIX 4.1.5 box using the IBM compiler but I get an error (or warning): cc_r -O -qmaxmem=4000 -I./../Include -I.. -DHAVE_CONFIG_H -c ./socketmodule.c "./socketmodule.c", line 1127.22: 1506-280 (W) Function argument assignment between types "struct sockaddr*" and "unsigned char*" is not allowed. Anyone a suggestion? Mike Sent via Deja.com http://www.deja.com/ Before you buy. From tlane at parlant.com Tue Nov 9 10:56:35 1999 From: tlane at parlant.com (Thomas Lane) Date: Tue, 09 Nov 1999 08:56:35 -0700 Subject: Grail Brower question References: <808m9h$nnn$1@holly.prod.itd.earthlink.net> Message-ID: <38284433.5AF3B00E@parlant.com> Have you installed Python yet? Spaceram wrote: > > For anyone who knows what the grail browser is I have a question. > How do I use the brower? I download it and when i doubleclick it it opens a > open with box which means that windows doesn't know what to do with the > file. > > Please email all answers to spaceram00 at earthlink.net -- Thomas Lane Provo, UT tlane at parlant.com From mhammond at skippinet.com.au Sun Nov 7 17:21:09 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 07 Nov 1999 22:21:09 GMT Subject: win32com and IIS? References: <802s6a$mj5$1@web1.cup.hp.com> <803e2a$dul$1@web1.cup.hp.com> Message-ID: As you guess, this is almost certainly a permssions problem. IIS may not have permissions to create windows on its workstation. The error message certainly implies this is indeed the case. The only thing I can suggest is searching the MS knowledge base, and see what they have to say - I am fairly sure that _all_ languages that can run under IIS will have the same issue. As a simple test, you could use the Windows Scripting Host from CGI, and do the same thing with some VBScript code. I feel confident it will have the exact same problem... Mark. Arad Rostampour wrote in message <803e2a$dul$1 at web1.cup.hp.com>... >Thanks for the quick reply...Here is a simpler example with debugging flags >on: > >import win32com.client >ieweb = win32com.client.Dispatch("InternetExplorer.Application") >ieweb.Navigate("http://www.hp.com") >print ieweb.Document.Body.innerText > >Attribute Document not in cache >Getting property Id 0xcb from OLE object >Traceback (innermost last): > ... >pywintypes.com_error: (-2147023169, 'The remote procedure call failed and >did not execute.', None, None) > >Again, it works from the python interactive interpreter but does not work in >a cgi script under IIS. It doesn't like getting ieweb.Busy either...Also, >are there any issues with running the COM interface not specifically as >myself or a specific user, but rather IUSR_machinename? Is there any >special set-up besides the Script Map key that ties a .py file to python? > From bernhard at alpha1.csd.uwm.edu Tue Nov 30 13:06:42 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 30 Nov 1999 18:06:42 GMT Subject: COMobject problem References: <3843e3f3.18656326@122.0.0.250> Message-ID: On Tue, 30 Nov 1999 14:51:54 GMT, volumeregeling wrote: >i have a problem regarding COM objects, i invoke the object through >the following statement : > >Editor= win32com.client.Dispatch("Comeditor.Classeditor") > >Now i have the problem that when i close the main program , the >COMobject will still be alive, i want to close all the comobjects >opened from within python to be closed when the main program closes. > >I have no idea on how to do that, maybe you do , then i will be very >gratefull. You could delete the Editor variable and hope that it cleans itself up. Usually there is a special method to be called to close the application. If you are using the win32com extensions, you can try to browse the COM library (applying the COM makepy.py script on the type library helps for that). Like with SPSS here there is a Quit() method in the main application object. So Editor.Quit() with Quit replacing the Method your are looking for, should work. Just my 0.02 Euro. Bernhard -- Research Assistant, Geog Dept UM-Milwaukee, USA. (www.uwm.edu/~bernhard) Free Software Projects and Consulting (intevation.net) Association for a Free Informational Infrastructure (ffii.org) From Bjoern.Giesler at stud.uni-karlsruhe.de Tue Nov 23 13:36:13 1999 From: Bjoern.Giesler at stud.uni-karlsruhe.de (Bjoern.Giesler at stud.uni-karlsruhe.de) Date: Tue, 23 Nov 1999 19:36:13 +0100 (CET) Subject: Embedding: Again Message-ID: Hi, OK, nevermind, I think I've got it: In CPluginPyRegister(), I use (theController is the plugin instance): /* Here we go: Obtain module name... */ moduleName = PyObject_GetAttrString(theController, "__module__"); if(!moduleName) return NULL; /* ..., module dictionary... */ modulesDict = PyImport_GetModuleDict(); if(!modulesDict) return NULL; /* ...and module object */ theModule = PyObject_GetItem(modulesDict, moduleName); if(!theModule) return NULL; Now my only problem is, which of these pass on ownership? Meaning, what do I have to do to truly unload a module? Is Py_XDECREF(theModule) sufficient, or must I do a PyObject_DelItem(modulesDict, moduleName) as well? Thanks in advance, Bjoern -- --------------------------------/\--One OS to rule them all---Windows NT----- Bjoern Giesler / \ One OS to find them / <> \ One OS to bring them all -----------------------------/______\--And in the Darkness bind them--------- Thank you for your time, worship the Antichrist, and have a nice day. From pinard at iro.umontreal.ca Mon Nov 1 19:48:33 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 01 Nov 1999 19:48:33 -0500 Subject: Default indentation of 4 columns In-Reply-To: Gareth McCaughan's message of "24 Oct 1999 20:43:12 +0100" References: <86emeko88f.fsf@g.local> Message-ID: Gareth McCaughan ?crit: > Fran?ois Pinard wrote: > > The only thing that really rebukes me is the interdiction to use > > capitals in comments to mark non-terminals (or variables), as it does > > not get accompanied by a better suggestion, or at least, none yielding > > as much clarity. > You mean saying things like > # Return the sum of AARDVARK and ARMADILLO. > def f(aardvark, armadillo): > return aardvark+armadillo > I use a convention derived from Knuth's literate programming > systems, and write > # Return the sum of |aardvark| and |armadillo|. It is a good idea. Yet, maybe because I've been so exposed to GNU software, I'm quite used to the capitals convention, and find it very legible. I would have tendency to stick to something in (relatively) wide use, than to run away from the dilemma and hide into something less well known :-). > ? (Incidentally, this example is another one that shows an > annoying "accidental alignment" as a result of the four-character > rule. Usually, the `def' is outstanding enough already, preceded by a blank line, being left aligned, and especially highlighted in some good editors (:-), that I would not think the above really creates a real practical problem. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From MSteed at altiris.com Mon Nov 8 11:23:08 1999 From: MSteed at altiris.com (Mike Steed) Date: Mon, 8 Nov 1999 09:23:08 -0700 Subject: Python and generating images for web Message-ID: <65118AEEFF5AD3118E8300508B124877073C68@webmail.altiris.com> > From: Alexander Stepanov [mailto:a_stepanov at yahoo.com] > Sent: Saturday, November 06, 1999 8:53 PM > To: python-list at python.org > Subject: Python and generating images for web > > [snip] > I will appreciate if you point me out accessible chart/plot > modules and > libraries as well as documentation and > working sites. Any additional information is strongly welcome. I wrote a Python interface for Bruce Verderaime's GDChart library, available here: http://members.xoom.com/msteed/software/gdchart.html In its current form, GDChart generates GIF images, but it can be changed to generate PNG if you prefer. (This would require updating the gd library on which GDChart is built, and perhaps some minor tweaks to GDChart itself.) The archive includes a precompiled Win32 binary. Mike. From info at objectsbydesign.com Wed Nov 10 22:31:35 1999 From: info at objectsbydesign.com (Stuart Zakon) Date: Wed, 10 Nov 1999 22:31:35 -0500 Subject: UML tools: Tcl or Python? Message-ID: <382A3896.7FD4F3B0@objectsbydesign.com> Interesting developments for scripting in UML tools: First ObjectDomain switched its scripting language from Tcl to JPython. Next Together/J 3.0 switched its scripting language from JPython to Tcl. Now that's what I call product differentiation!! Stuart Zakon Objects by Design http://www.objectsbydesign.com From quinn at groat.ugcs.caltech.edu Fri Nov 26 21:43:58 1999 From: quinn at groat.ugcs.caltech.edu (Quinn Dunkan) Date: 27 Nov 1999 02:43:58 GMT Subject: [].extend only accepts list? Message-ID: Is there any reason why the extend method of lists shouldn't accept any sequence? From eric at net.tamu.edu Wed Nov 3 16:16:54 1999 From: eric at net.tamu.edu (Eric Nelson) Date: Wed, 3 Nov 1999 15:16:54 -0600 Subject: 64 bit ints for SNMP counter64 variables References: <7vq8eg$4k$1@news.tamu.edu> Message-ID: <7vq8o4$18j$1@news.tamu.edu> oops... posted too quick... found long() just after i hit send... sorry eric Eric Nelson wrote in message news:7vq8eg$4k$1 at news.tamu.edu... > Is there not a 'long long' data type in python? I've got 64 bit counters > coming from snmp variables that I need to work with.... > > How about a variable precision type module?? > > Eric > eric at net.tamu.edu > > From steve at acer.spvi.com Sun Nov 7 22:33:01 1999 From: steve at acer.spvi.com (Steve Spicklemire) Date: Sun, 7 Nov 1999 22:33:01 -0500 (EST) Subject: Python for children..... In-Reply-To: <199911080328.WAA24200@acer.spvi.com> (message from Steve Spicklemire on Sun, 7 Nov 1999 22:28:21 -0500 (EST)) References: <9911051740130D.02530@william.jinsa.org> <7GOU3.272$Ae3.194028@news-dal.corridex.com> <801p16$10s$1@vvs.superst.iae.nl> <199911080328.WAA24200@acer.spvi.com> Message-ID: <199911080333.WAA24231@acer.spvi.com> Forgot to mention: PyBots: http://opensource.spvi.com Also.. there is a windows version, just like the Mac, but there is no rotation.. since I don't have director 7 for Windows.. *yet*. Sorry! -steve >>>>> "Steve" == Steve Spicklemire writes: Steve> I've also been playing with teaching python to 'children' Steve> (well.. middle schoolers anyway... don't tell *them* they Steve> are children. ;->) I've had some luck with my little PyBots Steve> toy... it needs some work, when I get more time.. but it's Steve> enough to teach some simple stuff... From piet at cs.uu.nl Tue Nov 16 04:45:02 1999 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 16 Nov 1999 10:45:02 +0100 Subject: Need help dealing with spaces in NT paths. References: <80pr76$jq5$1@nnrp1.deja.com> <11f733ec.96958819@usw-ex0101-007.remarq.com> Message-ID: >>>>> wheineman (W) writes: W> Put quotes around the complete path. For example: W> myExec = "C:\\Program Files\\Trash Can\\compactor.exe" You probably mean: myExec = "\"C:\\Program Files\\Trash Can\\compactor.exe\"" or easier: myExec = r'"C:\Program Files\Trash Can\compactor.exe"' -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: Piet.van.Oostrum at gironet.nl From mwh21 at cam.ac.uk Tue Nov 16 15:40:55 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 16 Nov 1999 20:40:55 +0000 Subject: problems with __getattr__ & __setattr__ References: <3F8BA119B48AD11197470008C7A493CB98B67D@HQOBGEX1> Message-ID: ScherBi at BAM.com writes: > I am having trouble using __getattr__ and __setattr__ in some classes. I've > boiled it down to the code below. > It dumps core under 1.5.2 on Linux or WinNT. > > I think maybe it's looping, if so, how does one go about doing this? > (I'm assuming it's clear enough what I'm trying to do.) > > If I comment out the __gettattr__ operation, it doesn't dump core. Instead > I get an AttributeError: eggs raised at the 'self.eggs[key] = value' call in > __setattr__. This is what leads me to belive there's something circular > going on here. > > > Thanks, > Bill > > ------------------------------------------------------------- > > class spam: > > def __init__(self): > self.eggs = {} Hint: what does this call? > def __getattr__(self, key): > try: > return self.eggs[key] > except: > raise > > def __setattr__(self, key, value): It calls this! > try: > self.eggs[key] = value And this calls __getattr__ which looks for self.eggs, which calls __getattr__, which looks for self.eggs, which calls __getattr__, which looks for self.eggs, which calls __getattr__, which looks for self.eggs, which calls __getattr__, which looks for self.eggs, which calls __getattr__, Segmentation fault (core dumped) > return 0 > except: > raise > > > > if __name__ == '__main__': > > s = spam() > print 'instance of spam created.' > try def __init__(self): self.__dict__['eggs'] = {} instead; also def __getattr__(self, key): try: return self.__dict__["eggs"][key] except: raise is probably safer. What are the try/catch for? They aren't doing anything here! __getattr__-and-__setattr__-are-so-much-fun-we-don't-mind-the- performance-hit-ly y'rs - Michael From leonar_n at epita.fr Mon Nov 29 09:17:09 1999 From: leonar_n at epita.fr (leon) Date: Mon, 29 Nov 1999 15:17:09 +0100 Subject: Unbuffered stdout Message-ID: <81u1k2$27qkk$1@oceanite.cybercable.fr> Hi there ! I'm developping an IRC like software which must work on the Web. I can't use Java, and I'm using Python to program the CGI. But, I have a big problem : I don't know how to make the stdout unbuffered. I tried to make some sys.stdout.write("test") sys.stdout.flush() but it don't work. So any idea ?? Leon. From usenet-mm-yyyy at julesallen.com Sun Nov 14 11:22:33 1999 From: usenet-mm-yyyy at julesallen.com (Jules Allen) Date: Sun, 14 Nov 1999 16:22:33 GMT Subject: Proposal: Python Info Collective Message-ID: One of the main problems I've had with understanding Python's depth is finding information and modules. c.l.py.announce is a good way to keep track of new things but once that info scrolls from the news server, it's pretty much gone. Sure, one can use deja.com (and clones) but it's a chore. On the module front, I had to update some Perl forms a while ago and marveled at how easy it is to use CPAN. I'm not having a go at the Trove development effort but unless I'm mistaken, it seems to be stalled. Could this be harming Python's wider adoption? On a personal level, I can't tell if I should start a module to complete a task or if is there already a module that fits. Seasoned vererans and PyGods instantly know where everything is. They politely and graciously seem to answer the same questions about where to find tutorials, HTMLgen examples, PyApache's location over and over again. So what I'd like to propose is a yahoo/freshmeat flavour site tuned for all things Pythonish. I'd say that Zope is the obvious candidate for the development vehicle as it makes delegation of sub-sections blissfully easy. If this project does fly, it's a strictly non-commercial effort and Guido has suggested that subdomain.python.org might be possible. Seems like the best place to host it to me. I'm no library scientist or PyGod but I'll gladly organize, code and do the bits nobody else wants to do. Rather than pollute c.l.py with this discussion, I've created an eGroup at: http://www.egroups.com/list/pyinfo/ If you have any interest, ideas or flames, please sign up and let fly! Cheers, Jules PS I'll be at IPC8 and if you'd like to do the face to face thing and chat about this, drop me a line. -- If you want to email me directly, plug the current month and year into my email address. From cfelling at iae.nl Sat Nov 27 17:12:57 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 27 Nov 1999 23:12:57 +0100 Subject: Newbie: raw_input and other input methods References: <19991125.1481400@adam-aurag.penguinpowered.com> <81kfjc$1vg$1@vvs.superst.iae.nl> <383EC1A5.99A4FAD5@lemburg.com> <81pk1m$2i6$1@vvs.superst.iae.nl> Message-ID: <81pl19$2lh$1@vvs.superst.iae.nl> Carel Fellinger wrote: I was to quick, or actually I changed something during posting. > class Var: > '''(environment) variable to be evaluated during prompting''' > def __init__(self, var, dict=os.environ): > self.var, self.dict = var, dict > def __str__(self): > return self.dict[self.var] this should read: return str(self.dict[self.var]) and now we can do > if __name__ == '__main__': ... prompt.nr = Var('nr', locals()) nr = 0 while 1: nr = nr + 1 print raw_input(prompt) -- groetjes, carel From skaller at maxtal.com.au Thu Nov 25 18:26:15 1999 From: skaller at maxtal.com.au (skaller) Date: Fri, 26 Nov 1999 10:26:15 +1100 Subject: Python complaints References: <8666ysfta9.fsf@ix.netcom.com> Message-ID: <383DC597.1ED53168@maxtal.com.au> Brad Knotwell wrote: > In general, the only thing I've found annoying about Python are the scoping > rules: > > >>> def fact(n): > .. def fact_iter(n,result): > .. if not n: return result > .. else: fact_iter(n-1,n*result) > .. return fact_iter(n,1) > .. > >>> fact(3) > Traceback (innermost last): > File "", line 1, in ? > File "", line 5, in fact > File "", line 4, in fact_iter > NameError: fact_iter There's an error on your code (you have to 'return' in line 4). After that correction, running on Viperi: [root at ruby] ~/viper>./viperi Viperi 2.0.1 Copyright Maxtal P/L, John Skaller, Australia, 1999 >>>def fact(n): ... def fact_iter(n,result): ... if not n: return result ... else: return fact_iter(n-1,n*result) ... return fact_iter(n,1) ... >>>print fact(3) ... 6 >>>print fact(7) ... 5040 -- John Skaller, mailto:skaller at maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia homepage: http://www.maxtal.com.au/~skaller voice: 61-2-9660-0850 From m.faassen at vet.uu.nl Mon Nov 15 06:22:32 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 15 Nov 1999 11:22:32 GMT Subject: Proposal: Python Info Collective References: Message-ID: <80oqdo$ocq$1@newshost.accu.uu.nl> Jules Allen wrote: [snip] > So what I'd like to propose is a yahoo/freshmeat flavour site tuned > for all things Pythonish. I'd say that Zope is the obvious candidate > for the development vehicle as it makes delegation of sub-sections > blissfully easy. If this project does fly, it's a strictly > non-commercial effort and Guido has suggested that subdomain.python.org > might be possible. Seems like the best place to host it to me. I think AppWatch is a good thing to look at then. It's a freshmeat style site built on top of Zope. http://www.appwatch.com So you should ask 'm for their sources. :) > I'm no library scientist or PyGod but I'll gladly organize, code > and do the bits nobody else wants to do. Rather than pollute c.l.py > with this discussion, I've created an eGroup at: [snip] Hey, I thought comp.lang.python was for this kind of discussion. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From news at dorb.com Thu Nov 11 11:04:30 1999 From: news at dorb.com (Darrell) Date: Thu, 11 Nov 1999 11:04:30 -0500 Subject: ASCII delimited files References: <942231502.1914033961@news.interbusiness.it> <80ekhb$1qrh$1@hub.org> Message-ID: D'Arcy J.M. Cain wrote: > I use delimited.py which works pretty good. It sure does ! It ran 3.6 meg in 11.4 sec and my 'C' version ran in 1.75 sec For most cases delimited.py would be fast enough. The test case for delimited.py also pointed out a bug in my stuff. -- --Darrell From prestonlanders at my-deja.com Tue Nov 30 18:50:53 1999 From: prestonlanders at my-deja.com (Preston Landers) Date: Tue, 30 Nov 1999 23:50:53 GMT Subject: how to do *simple* syntax checking? Message-ID: <821nss$99v$1@nnrp1.deja.com> Okay, I know there was an earlier thread regarding pre-distribution syntax checking (and the virtual impossibility of same). I understand Python is a dynamicly typed language, and I have no real need to be able to find previously undeclared names in code before I run it. However, it would be enormously helpful for me to be able to do *simple* checks on Python code at make/'make install' time. Like catching whitespace/indentation problems, missing semicolons, and the like. I maintain a large set of Python programs, some of which are accessed through a CGI interface. I develop some code, run make install, restart my web server (not always though) and then load up my URL. Only to find "500 Internal Server Error." Usually, if it's not a namespace issue, it's something silly like a missing semicolon. But I have to track through the server logs to find out what went wrong. I thought that Python's compile() function would be what I want, because I thought that the SyntaxError exception was thrown when making bytecode. But that's not the case, unless I was notably un-thorough in my investigation. Basically, what I want is to do something like this for every Python program in my makefile: try: simple_syntax_check("myfile.py") except: # file is no good, abort make process # ... continue with make Am I just dreaming? Is this unrealistic? Or is this kind of thing fully availible and documented and I am just blind? thanks, ---Preston -- || Preston Landers || Sent via Deja.com http://www.deja.com/ Before you buy. From fredrik at pythonware.com Fri Nov 19 04:32:56 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 19 Nov 1999 10:32:56 +0100 Subject: Beginning programming with Python References: <382B3A53.5816B2@callware.com> <382B3D79.74CD3E0F@email.sps.mot.com> <80p9ds$ppo$1@newshost.accu.uu.nl> <38317787.19AFDAF5@compaq.com> <812rg4$b6$1@essle.valdyas.org> Message-ID: <00ef01bf3271$10a8bb90$f29b12c2@secret.pythonware.com> Boudewijn Rempt wrote: > I tend to forget the colons after function and class definitions and > everywhere else and the double == in if's - mainly because, for the life > of Brian, I can't see why they are there. It seems to me the language > would be just as easily parseable and readable without this bit of > interpunction. guess you weren't part of the CWI design team -- they did test this on humans, you know, and discovered that the language wasn't as easily parseable and readable without the colons... "We did requirements and task analysis, iterative design, and user testing. You'd almost think pro- gramming languages were an interface between people and computers." -- Steven Pemberton From phd at phd.russ.ru Wed Nov 3 03:23:11 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Wed, 3 Nov 1999 08:23:11 +0000 (GMT) Subject: Template for CGI In-Reply-To: <7vn0sk$7cp$1@news.fsu.edu> Message-ID: On Tue, 2 Nov 1999, Glenn Kidd wrote: > I am a newbie to Python and I have a question. I want a CGI script that > will read a file template and replace certain words with variables. Ii > tried putting the variable names in the file but it is read as palin text. > Is there a way to embed variables into a teplate or a replace function in > Python? Thank you for any help you give. Go to www.zope.org and download ZTemplates. Learning ZTemplates is somewhat hard (not much, really), but it worth learning. After ZTemplates you will NEVER need anything else! :) After you download it, I can send you some examples how to use it. Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From scott at hk.super.net Wed Nov 3 06:42:05 1999 From: scott at hk.super.net (Scott Deerwester) Date: Wed, 03 Nov 1999 11:42:05 GMT Subject: JavaCard and JPython? Message-ID: <19991103.11420500@kahua.transpacific.com.hk> Is there any thought of implementing the JavaCard API using Jpython? The prospect of being able to program Smartcards in Python is very appealing indeed! From andy at robanal.demon.co.uk Thu Nov 4 16:23:06 1999 From: andy at robanal.demon.co.uk (Andy Robinson) Date: Thu, 04 Nov 1999 21:23:06 GMT Subject: Drawing (directed) graphs References: <001701bf2540$bd4d07e0$3acbd9c2@peridot.optichrome.com> Message-ID: <3823f33e.11772788@news.demon.co.uk> "Adrian Eyre" wrote: >> Does anyone know of Python code for drawing graphs of the >> graph-theoretic type? Ideally, I'd like to be able to interactively >> add nodes and edges etc and add data to structures associated with the >> nodes and edges. > >Depends if you're looking for a proper graphics display, or an ASCII >representation. A full graphics version would not be platform >independent, and would require a graphics library. Good thing there is a platform independent Python graphics library! PIDDLE (Plug In Drawing, Does little Else) at www.strout.net/python/piddle There is a discussion list at www.egroups.com/pythonpiddle/ PIDDLE is pretty stable, and we hope we'll build up a bunch of such applets on top of it over time. BTW, I'm in charge of the PDF back end for PIDDLE, and would certainly have uses for such a routine. One demo I've always wanted is to look at a Python program and draw a module dependency graph (as well as all the module docstrings).... Regards, Andy From robin at jessikat.demon.co.uk Thu Nov 4 08:13:33 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Thu, 4 Nov 1999 13:13:33 +0000 Subject: Comparison between Python and "Ruby" References: <1270552684-31022246@hypernet.com> <87n1svugfh.fsf@ev.netlab.co.jp> <7vrtch$nro$1@newshost.accu.uu.nl> Message-ID: I'm fairly sure all of these languages are turing complete and if so they're equivalent at the semantic level. To defeat TC once and for all let's implement a PyPerl module etc etc etc. Greg is at least doing some interesting comparisons all this n ways to babylon and back stuff or how many T's H's etc is a bit of a waste. -- Robin Becker From MSteed at altiris.com Tue Nov 30 18:36:23 1999 From: MSteed at altiris.com (Mike Steed) Date: Tue, 30 Nov 1999 16:36:23 -0700 Subject: What's the canonical vi setting for Python indentation Message-ID: <65118AEEFF5AD3118E8300508B124877073CA2@webmail.altiris.com> > From: Chris WRIGHT [mailto:caw at cs.mu.oz.au] > Sent: Tuesday, November 30, 1999 4:19 PM > To: python-list at python.org > Subject: What's the canonical vi setting for Python indentation > > > I've tried to find out the "OK" indentation settings for > python with vi, > and a troll through deja-news found some hints (like don't do indent = > 4). Yet I seem to also remember some advice to the contrary?? I want > indentation to be 4 characters, and readable by/ acceptable to emacs > python-mode, and to pass tabnanny... I haven't tested acceptability to emacs or tabnanny, but since sane software assumes a tabstop of 8, I use (in vim) ':set ts=8 sts=4 sw=4'. This makes tabs feel like four spaces while I'm editing (convenient), but uses actual tab characters only for groups of 8 spaces. -- M. From fredrik at pythonware.com Wed Nov 24 03:55:44 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 24 Nov 1999 09:55:44 +0100 Subject: dir() and propertly list NEWBIE References: <81eorl$b60$1@nnrp1.deja.com> Message-ID: <00ce01bf3659$b5cddce0$f29b12c2@secret.pythonware.com> wrote: > Is it possible to get the functions of an object using dir()? Rather > that looking them up in a book/API. > > Similarly, If I can get an objects functions, is it possible then get a > list of the possible parameters for that function? the attached module contains all you need. from the eff-bot archives: # # describeFunction.py # $Id$ # # utilities to describe functions, methods, and classes # # history: # 96-10-27 fl created # 98-02-24 fl added code to handle unpacked arguments # 99-11-24 fl sample code used bogus argument order # # notes: # This has been tested with Python 1.4 and 1.5. The code and # function object attributes might change in future versions of # Python. # # written by fredrik lundh. last updated november 1999. # # fredrik at pythonware.com # http://www.pythonware.com # import string # -------------------------------------------------------------------- # code object attributes # -------------------------------------------------------------------- # co_argcount INT # co_nlocals INT # co_flags INT # CO_OPTIMIZED # CO_NEWLOCALS # CO_VARARGS # CO_VARKEYWORDS # co_code OBJECT # co_consts OBJECT # co_names OBJECT # co_varnames OBJECT # co_filename OBJECT # co_name OBJECT # -------------------------------------------------------------------- # function object attributes # -------------------------------------------------------------------- # func_code OBJECT # func_globals OBJECT # func_name OBJECT (__name__) # func_defaults OBJECT # func_doc OBJECT (__doc__) # copied from Python header file CO_OPTIMIZED = 0x0001 CO_NEWLOCALS = 0x0002 CO_VARARGS = 0x0004 CO_VARKEYWORDS = 0x0008 def _describe(func, name = None): # get argument list code = func.func_code n = code.co_argcount a = list(code.co_varnames[:n]) p = 0 for i in range(n): # anonymous arguments from dis import opname, HAVE_ARGUMENT c = code.co_code if not a[i] or a[i][0] == ".": vars = [] while p < len(c): v = ord(c[p]) if v >= HAVE_ARGUMENT: s, v = opname[v], ord(c[p+1]) + ord(c[p+2])*256 p = p + 3 if s == "UNPACK_TUPLE": count = v elif s == "STORE_FAST": vars.append(code.co_varnames[v]) if len(vars) >= count: break else: p = p + 1 if vars: a[i] = "(" + string.join(vars, ", ") + ")" if func.func_defaults: # defaults i = n - len(func.func_defaults) for d in func.func_defaults: a[i] = (a[i], d) i = i + 1 if code.co_flags & CO_VARARGS: # extra arguments a.append("*"+code.co_varnames[n]) n = n + 1 if code.co_flags & CO_VARKEYWORDS: # extra keyword arguments a.append("**"+code.co_varnames[n]) n = n + 1 return a def describe(func, name = None): "Return the function or method declaration as a string" # argument list a = _describe(func) args = [] for arg in a: if type(arg) is type(""): args.append(arg) else: args.append("%s=%s" % (arg[0], repr(arg[1]))) args = string.join(args, ", ") # function name if not name: name = func.func_name if name == "": return "lambda %s" % args return "%s(%s)" % (name, args) def __getmethods(c, m): for k, v in c.__dict__.items(): if type(v) is type(__getmethods): # and k[0] != "_": if not m.has_key(k): m[k] = describe(v, k), c.__name__ for c in c.__bases__: __getmethods(c, m) def describe_class(cls): "Return a dictionary describing all methods available in a class" m = {} __getmethods(cls, m) return m def describe_instance(self): "Return a dictionary describing all methods available in an instance" return describe_class(self.__class__) # # -------------------------------------------------------------------- if __name__ == "__main__": def foo(a, b=1, *c, **d): e = a + b + c f = None bar = lambda a: 0 # based on an example from Duncan Booth def baz(a, (b, c, d), e, (f, g) = ('foo','bar')): pass print describe(foo) print describe(bar) print describe(baz) # --- end of module --- From garry at research.att.com Tue Nov 2 13:28:02 1999 From: garry at research.att.com (Garrett G. Hodgson) Date: Tue, 2 Nov 1999 18:28:02 GMT Subject: tkinter grid() question Message-ID: <381F2D32.9E3A15CF@research.att.com> in the code below, i create a Text entry area with a Scrollbar. i want this pair to always use all of the available space. but when i resize the window, the stay the same size, neither expanding or shrinking. what am i doing wrong? thanks -------------------- from Tkinter import * class Bug(Frame): def __init__( self, parent ): Frame.__init__( self, parent ) self.pack( fill=BOTH ) scrollbar = Scrollbar( self, orient=VERTICAL ) self.body = Text( self ) self.body.config( yscrollcommand=scrollbar.set ) self.body.grid( row=2, column=0, rowspan=10, columnspan=10, sticky=N+S ) scrollbar.config( command=self.body.yview ) scrollbar.grid( row=2, column=10, rowspan=10, sticky=N+S ) if __name__ == '__main__': root = Tk() Bug( root ) root.mainloop() -- Garry Hodgson "Hey, mister, can ya tell me, garry at sage.att.com where a man might find a bed?" Software Innovation Services He just grinned and shook my hand, AT&T Labs "No", was all he said. From kantel at mpiwg-berlin.mpg.de Tue Nov 9 04:52:09 1999 From: kantel at mpiwg-berlin.mpg.de (Jörg Kantel) Date: Tue, 09 Nov 1999 10:52:09 +0100 Subject: Graphics. References: <3826E949.BBA1BAFD@imf.au.dk> Message-ID: <091119991052098844%kantel@mpiwg-berlin.mpg.de> In article <3826E949.BBA1BAFD at imf.au.dk>, Emil Hedevang Lohse wrote: > How do I draw some graphics on a screen using Python running on > HP-UX > MacOS > Windows > > ??? > If you want to use Tkinter and maybe you can read German than I've a nice example at my website at HTH J"org Kantel From jam at quark.emich.edu Tue Nov 30 17:38:37 1999 From: jam at quark.emich.edu (Jeff) Date: Tue, 30 Nov 1999 17:38:37 -0500 Subject: Looking for sshlib.py In-Reply-To: References: <19991130080326.A1376@quark.emich.edu> Message-ID: <19991130173837.A2365@quark.emich.edu> On Tue, Nov 30, 1999 at 09:47:05PM +0000, John Leach wrote: > I'm looking to write a Python frontend for character-based applications > accessed via the internet. > telnet works well but I'd like something with more security (telnet sends > its password unencrypted I believe). > I'll try calling ssh from within Python and see if that helps. > Thanks for your reply, > John Leach > http://www.bosware.com.au > you are correct in your statement that telnet sends it's passwords in the clear. ssh has clients designed to replace 'rsh' and 'rcp'. if you could implement your application with rsh first, ssh will work nicely as a secure replacement. in other cases I would suggest using a different piece of software.. perhaps kerberos. kerberos homepage: http://web.mit.edu/kerberos/www/ ssh homepage: http://www.ssh.org/ or http://www.ssh.fi/ regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From thomas.heller at ion-tof.com Thu Nov 4 02:51:00 1999 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 4 Nov 1999 08:51:00 +0100 Subject: Embedding and threads Message-ID: <00b501bf2699$567dccc0$4500a8c0@thomasnotebook> While embedding python in a DLL I'm writing (we are talking Windows here), I encountered the following confusion: Threads are created in the application from C. From reading the docs I understood that I must 'boot the thread' into existance by creating a thread state data structure (with PyThreadState_New(), passing the PyInterpreterState *interp pointer which I saved from the main thread), then acquire the interpreter lock, and finally store the thread state pointer before using the Python/C API from this thread. I do this in the DllMain() function in the DLL_THREAD_ATTACH branch. This all works very well, but what happens if I also create threads from python? These threads will be initialized by python, so I assume the thread state data structure is already created. How do I ask python if the thread state already exists for a given thread? Thomas Heller ION-TOF GmbH From a.eyre at optichrome.com Wed Nov 3 12:17:56 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Wed, 3 Nov 1999 17:17:56 -0000 Subject: __LINE__? In-Reply-To: <816010E2456BD111A48700805FBBE2EEFDF750@ex-quebec-u1.baan.com> Message-ID: <002a01bf261f$5eae0dd0$3acbd9c2@peridot.optichrome.com> > Is there an equivalent of the C __LINE__ macro in Python to get the > currentline number? import sys def what_line_am_i_on(): try: raise "Hack" except: return sys.exc_info()[2].tb_frame.f_back.f_lineno print "This is line " + str(what_line_am_i_on()) -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From tim_one at email.msn.com Fri Nov 12 00:04:47 1999 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 12 Nov 1999 00:04:47 -0500 Subject: print "foo", without a space In-Reply-To: <382AD3BB.69899CBD@helsinki.xx> Message-ID: <000b01bf2ccb$70ba3d20$fd2d153f@tim> [Mikael Johansson] > Is there another way of getting print to not make a newline than > using: > print "foo", ? No. > This because the comma always produces a space which necessary > isn't that nice ... That's a different issue than newlines. In small doses, this devious trick is quite pleasant: >>> import sys >>> def no_space_before(x): sys.stdout.softspace = 0 return x >>> ns = no_space_before >>> print 1, ns(2), 3, ns(4), 5 12 34 5 >>> the-great-thing-about-python-is-it's-so-obvious-ly y'rs - tim From gerrit.holl at pobox.com Thu Nov 18 15:39:25 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Thu, 18 Nov 1999 21:39:25 +0100 Subject: urllib.getsize() Message-ID: <19991118213925.A10221@optiplex.palga.uucp> Hello, I've written a function to get the size of a HTTP/FTP url, is it good enough to be put in urllib.py? def getsize(url): import urlparse urltup = urlparse.urlparse(url) protocol = urltup[0] host = urltup[1] file = urltup[2] if protocol == HTTP: import httplib http = httplib.HTTP(host) # www.nl.linux.org:80 mag ook http.putrequest("HEAD", file) http.putheader("Accept", "*/*") http.endheaders() return http.getreply()[2].get("Content-Length") elif protocol == FTP: import ftplib ftp = ftplib.FTP(host) # ftp.nl.linux.org:1234 mag ook ftp.login() return ftp.size(file) else: return -1 Maybe there should be some more error checking... regards, Gerrit. -- "I'd crawl over an acre of 'Visual This++' and 'Integrated Development That' to get to gcc, Emacs, and gdb. Thank you." (By Vance Petree, Virginia Power) From tekhir at yahoo.com Sat Nov 13 22:34:10 1999 From: tekhir at yahoo.com (Jeremy Misavage) Date: Sat, 13 Nov 1999 22:34:10 -0500 Subject: Python and sending emails with it Message-ID: <382E2DB2.A00B9109@nv2.cc.va.us> I'm kinda new to python and I'm trying to write a small program that will take in form data, save it in a db, and then send an email to a person. The program processes a users request for a "equipment request." It gets loggged in a db (already done) and sends an email to the person in change of the equipment. I need help on the email part. Does some out there have some code that will taken data and send it to a person. It shouldn't need a username and password, but if it does I'll live with that. From stannous at employees.org Thu Nov 4 15:03:25 1999 From: stannous at employees.org (Sam Tannous) Date: Thu, 04 Nov 1999 15:03:25 -0500 Subject: Questions on importing and exec command. Message-ID: <3821E68D.D785F4F3@employees.org> I'm writing a program that starts a separate thread where the user can type python commands (which are executed with the exec command). This saves me the trouble of having to write a parser, etc... I realize the hazards in doing this ;-) I'm having several problems: 1. A minor problem is command retrieval (or command history) in the console. If someone types a fairly long command, I'm not sure how to make the up and down arrows work correctly (as in tcsh) from the console I've created. Some key mapping within the program? 2. I want to allow the user (once she's in the console I've provided) to "import" or otherwise run python code fragments that have access to the functions I've provided globally. Typing the function name in the console seems to work just fine. But "import"ing a small chunk of code doesn't seem to work (and I don't want to force users to type everything by hand). The files I'm importing don't see the global functions I've declared (see the error in the sample session below). I want to give the user complete freedom to write python code fragments and save them in files and then just run them from the console as easily as possible. Here is the code: ------------ test2.py --------- #!/usr/bin/python import time,thread,string,sys def main(): print 'in main' thread.start_new(listener,('test',)) myconsole() def listener(test): global count count = 0 while 1: print "in listener",test,count time.sleep(30) count = count + 1 def myconsole(*x): print 'Now in console' while 1: command = raw_input('console > ') command = string.strip(command) try: exec command in globals() except: print sys.exc_type,sys.exc_value def testcall(message='default'): print "in testcall",message def startit(hold_time=10): thread.start_new(do_stuff,(hold_time,)) def do_stuff(hold_time=10): print 'started do_stuff hold_time =',hold_time time.sleep(hold_time) print 'ended do_stuff' def do_nothing(*x): pass count = 0 my_dict = {'01':('test1',startit),'07':('test2',do_nothing)} main() ------------------------ -------- call1.py ------- for i in range(5,9): print i startit(hold_time=i) --------------------------- Here's a session where I get the error message when calling function startit from an import statement. (stuff the program prints has a '****' in front of it) ------------------------- $test2.py ****in main ****Now in console ****in listener test 0 console > console > console > testcall() #here I call a function without problems ****in testcall default console > ****in listener test 1 ****in listener test 2 ****in listener test 3 ****in listener test 4 ****in listener test 5 ****in listener test 6 ****in listener test 7 console > ****in listener test 8 console > count = 666 #changing a global variable is no problem console > console > testcall() ****in testcall default console > print my_dict #looking at global variables is no problem {'01': ('test1', ), '07': ('test2', )} console > ****in listener test 667 console > startit() console > ****started do_stuff hold_time = 10 ****ended do_stuff console > start****in listener test 668 ^R console > startit(hold_time=3) console > ****started do_stuff hold_time = 3 console > ****ended do_stuff console > import call1 # importing a code fragment causes problems 5 exceptions.NameError startit --------------------------- Is there a trick to importing code fragments from this python session I've created? Thanks, Sam From guido at CNRI.Reston.VA.US Wed Nov 3 20:57:12 1999 From: guido at CNRI.Reston.VA.US (Guido van Rossum) Date: Wed, 03 Nov 1999 20:57:12 -0500 Subject: __str__ vs. __repr__ In-Reply-To: Your message of "Wed, 03 Nov 1999 00:08:56 EST." <000401bf25b9$88ea57e0$2e2d153f@tim> References: <000401bf25b9$88ea57e0$2e2d153f@tim> Message-ID: <199911040157.UAA11908@eric.cnri.reston.va.us> [Tim Peters, arguing against the current design of str() and repr()] > [Randall Hopper wonders about str-vs-repr, Tim explains that lists ask > their elements to produce repr() even if the list itself was passed > to str() > ] > > [Guido] > > Actually, Python's internals *do* follow the convention. Dicts and > > lists don't define __str__(), so str() for them defaults to > > __repr__(), and then of course repr() is used for the items. It may > > be confusing, it may not be what you want, but it *is* consistent ;-( > > Not to mention undocumented . > > [Randall] > > For consistency, would it make sense to change this for Python 1.5.3 (that > > is, have sequence and dict types pass 'str-vs-repr'ness down)? > > [Guido] > > This has been asked a few times before (and usually it's been reported > > as a bug, which it isn't -- see above). I happened to see this post > > and it made me delve deep into my intuition trying to figure out why I > > don't like propagating str() down container items. > > > > Here's what I think it is. There's no reason why an object's str() > > should be particularly suited to being included in list syntax. > > This seems much more a consequence of the current design than an argument in > favor of it. That is, had Python been designed so that the builtin > container types did "pass down" str-vs-repr'ness, an object's str() would > have every reason to produce a string suited to being etc. > > > For example, I could have a list containing the following items: > > > > 1 # an integer > > '1' # a string (of an integer literal) > > '2, 3' # a string containing a comma and a space > > '], [' # a string containing list delimiters > > > > Under the proposed rules, this list would print as: > > > > [1, 1, 2, 3], [] > > > > I would find this confusing > > Me too, but I find the current design more rigidly consistent than useful > (see below). In a world where containers passed str() down, a container's > str() would presumably be responsible for adding disambiguating delimeters > to element str() results when needed (the container knows its own output > syntax, and can examine the strings produced by its elements -- not rigidly > consistent, but useful ). Hm... What kind of things would you expect e.g. the list str() to do to its item str()s? Put backslashes before commas? > > and I worry that it could be used to fool the user. > > People can already define __repr__ to return anything whatsoever; the > reports of people getting fooled by this are conspicuous by absence . > > Here's something wholly typical of what I dislike: > > >>> from Rational import Rat, Format > >>> Rat.set_df(Format.Format(mode=Format.FIXED, prec=3, use_tag=0)) > Format(mode=Format.MIXED, prec=8, base=10, round=Round.NEAREST_EVEN, > use_tag=1, use_letters=1) > >>> one_tenth = Rat.Rat(.1) > >>> one_tenth > Rat(3602879701896397L, 36028797018963968L) > >>> print one_tenth > 0.100 > >>> > > That is, in interactive mode, I'm forever using "print" because the default > of applying repr() to raw expressions produces the output least useful in > interactive hacking (I don't care about reproducing the object exactly from > the string when typing a raw expression at the prompt! The mental ratio of > two giant integers isn't helpful here.). > > Carry it one more step, and nothing simple suffices anymore: > > >>> values = [one_tenth, one_tenth + 100] > >>> values > [Rat(3602879701896397L, 36028797018963968L), > Rat(3606482581598293197L, 36028797018963968L)] > >>> print values > [Rat(3602879701896397L, 36028797018963968L), > Rat(3606482581598293197L, 36028797018963968L)] > >>> > > So I'm forever typing this instead: > > >>> map(str, values) > ['0.100', '100.100'] > >>> > > Throw a dict into it, and it's hopeless: > > >>> recip = {one_tenth: 1/one_tenth, 1/one_tenth: one_tenth} > >>> print recip > {Rat(3602879701896397L, 36028797018963968L): > Rat(36028797018963968L, 3602879701896397L), > Rat(36028797018963968L, 3602879701896397L): > Rat(3602879701896397L, 36028797018963968L)} > >>> > > Having gone thru the same business in dozens of classes over the years, I > find the current design simply unusable in interactive mode. For a while I > defined just __str__, bound __repr__ to that too, and added a .repr() > *method* for the unusual cases in which I really needed a faithful string. > But that frustrated other code that expected explict repr() calls, and/or > the `` notation, to produce the long-winded version. So that sucked too. > > It's even an irritation sticking to builtin types; e.g., here assuming > Latin-1 comes across intact: > > >>> names = ["Fran?ois", "Tim"] > >>> print names[0] > Fran?ois > >>> >>> print names > ['Fran\347ois', 'Tim'] > >>> > > That isn't helpful either -- it's frustrating. These are all good points. In a typical scenario which I wanted to avoid, a user has a variable containing the string '1' but mistakenly believes that it contains the integer 1. (This happens a lot, e.g. it could be read from a file containing numbers.) The user tries various numeric operations on the variable and they all raise exceptions. The user is inexperienced and doesn't understand what the exceptions are, but gets the idea to display its value to see if something's wrong with it. One of the first things users learn is to use interactive Python as a power calculator, so my hypothetical user just types the name of the variable. If this would use str() to format the value, the user is no wiser, and perhaps more confused, since str('1') is the same as str(1). So I designed Python's read-eval-print loop to use repr() instead of str(): when the user tries to display the variable, it will show the string quotes which are a pretty good hint that it's a string. (Alternative scenario: the user has this problem and shows it to a somewhat more experienced user, who displays the variable and notes the problem from the output.) Where have I gone wrong? It seems that you are suggesting that the read-eval-print loop (a.k.a. the >>> prompt or the interactive interpreter) should use str(), not repr(). This would solve your first example; if str() for lists, tuples and dictionaries were to apply str() to their items, your second and third example would also be solved. We can then argue over what str() of a list L should return; one extreme possibility would be to return string.join(map(str, L)); a slightly less radical solution would be '[' + string.join(map(str, L), ', ') + ']'. In the first case, your last example would go like this: >>> names Fran?ois Tim >>> while the choice would give >>> names [Fran?ois, Tim] >>> There may be other solutions -- e.g. in Tcl, a list is displayed as the items separated by spaces, with the proviso that items containing spaces are displayed inside (matching) curly braces; unmatched braces are displayed using backslashes, guaranteeing that the output can be parsed back into a list with the same value as the original. (Hey! That's the same as Python's rule! So why does it work in Tcl? Because variables only contain strings, and the equivalent of the Rat class used above can't be coded in Tcl.) The problem with displaying 'Fran?ois' has been mentioned to me before. (By the way, I have no idea how to *type* that. I'm just cutting and pasting it from Tim's message.) There's another scenario I was trying to avoid. This is probably something that happened once too many times when I was young and innocent, so I may be overracting. Consider the following: >>> f = open("somefile") >>> a = f.readline() >>> print a %????1.3 >>> Now this example is relatively harmless. Using repr(), I see that the string contains a \r character that caused the cursor to back up to the start of the line, overwriting what was already written: >>> a '%PDF-1.3\015%\342\343\317\323\015\012' >>> But the thing that some big bad program did to me long ago was more like spit out several thousand garbage bytes which contained enough escape sequences to lock up my terminal requiring me to powercycle and log in again. (The fact that the story refers to a terminal indicates how long ago this was. :-) So I vowed that *my* language would not (easily) let this happen by accident, and the way I enforced that was by making sure that all non-ASCII characters would be printed as octal escapes, unless you use the print statement. It's a separate dilemma from the other examples. My problem here is that I hate to make assumptions about the character set in use. How do I know that '\237' is unprintable but '\241' is a printable character? How do I know that the latter is an upside-down exclamation point? Should I really assume stdout is capable of displaying Latin-1? Strictly, the str() function doesn't even know that it's output is going to stdout. I suppose I could use isprint(), and then Fran?ois could use the locale module in his $PYTHONSTARTUP file to make it do the right thing. Is that good enough? (I just tried this briefly. It seems that somehow the locale module doesn't affect this?!?! I still think that ['a', 'b'] should be displayed like that, and not like [a, b]. I'm not sure what that to do about a dict of Rat() items, except perhaps giving up on the fiction that __repr__() should return something expression-like for user-defined classes... Any suggestions? --Guido van Rossum (home page: http://www.python.org/~guido/) From gerrit.holl at pobox.com Mon Nov 1 09:04:51 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Mon, 1 Nov 1999 15:04:51 +0100 Subject: Destroying files In-Reply-To: References: <1270962155-6437791@hypernet.com> Message-ID: <19991101150451.A26174@optiplex.palga.uucp> Erno Kuusela wrote: > On Thu, 28 Oct 1999 21:38:09 -0400, Gordon McMillan > wrote: > > writing zeros over the data does not make it unrecoverable. > there are numerous companies that specialise in this kind > of recovery. You should do it three times. > now, the python file objects seem to be missing a melt() method... > perhaps this can be added for python 2.0? or perhaps a more suitable > name would be self_destruct(), so it would not be tied to any single > method. .destroy() for writing zeros over it three times and unlink() afterwards. regards, Gerrit. -- linuxgames.nl.linux.org All about games on Linux in Dutch (under construction). www.nl.linux.org The Dutch resource for Dutch Linux documentation. www.nl.linux.org/discoverb Learn foreign words and definitions. www.nl.linux.org/~gerrit/asperger I'm an Asperger, go here for more info. www.nl.linux.org/~gerrit About me and pictures of me. From guido at CNRI.Reston.VA.US Fri Nov 5 13:44:13 1999 From: guido at CNRI.Reston.VA.US (Guido van Rossum) Date: Fri, 05 Nov 1999 13:44:13 -0500 Subject: Conference Registration is now Open Message-ID: <199911051844.NAA17378@eric.cnri.reston.va.us> On-line registration for the upcoming Python conference is now open. New this year: we now accept on-line payment. http://www.python.org/workshops/2000-01/registration.html Important dates: Jan 3: early bird registration + payment, hotel reservation Jan 24-27: The Conference! See you all in Arlingon... http://www.python.org/workshops/2000-01/ --Guido van Rossum (home page: http://www.python.org/~guido/) From gerrit.holl at pobox.com Fri Nov 19 07:53:59 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Fri, 19 Nov 1999 13:53:59 +0100 Subject: Beginning programming with Python In-Reply-To: <383195C1.826B3342@iqsoft.hu> References: <382B3A53.5816B2@callware.com> <382B3D79.74CD3E0F@email.sps.mot.com> <80p9ds$ppo$1@newshost.accu.uu.nl> <38312D55.A36EB56D@iqsoft.hu> <383195C1.826B3342@iqsoft.hu> Message-ID: <19991119135359.A4306@optiplex.palga.uucp> Nemeth Miklos wrote: > Janos Blazi wrote: > > I am neither a physicist nor a mathematician, I am a simple business software > engineer. I like Python but I'd like to be convinced that Python is not only > for scientific programming, but also for business programming. I'd like > to know the general opinion of the "official" Python community on this I won't claim to be the official python community, but there are many business things done in Python. Electronic Arts is using Python for their games. RedHat uses python for Linux installation. On the python site are many more commercial projects done in Python. -- "We all know Linux is great...it does infinite loops in 5 seconds." (Linus Torvalds about the superiority of Linux on the Amterdam Linux Symposium) From paulb at infercor.no Thu Nov 18 09:41:30 1999 From: paulb at infercor.no (Paul Boddie) Date: Thu, 18 Nov 1999 15:41:30 +0100 Subject: Trouble with Bobo -- use Zope? References: <80v5g8$5a6$1@mulga.cs.mu.OZ.AU> Message-ID: <3834101A.FF39F64C@infercor.no> Tim Bell wrote: > > 3. Should I be moving to Zope and/or ZPublisher? Is there a quick > guide to making the switch? (I don't need all the fancy Zope stuff > at this stage.) It really depends. Zope, when used with ZServer, is good at removing most of the hassles associated with setting things up to work with the CGI mechanisms of the average Web server, and provides a powerful framework for site management. However, many people may not have the possibility of running their own server and I haven't tried that hard to integrate Zope with a different Web server using CGI. For many people, I suspect that Zope is a bit "too much" when all they really require is a nicer way to write server-side programs; this is what attracted me to Bobo in the first place. Handling CGI inputs using the rather comprehensive standard 'cgi' module gets very tedious and doesn't make for particularly nice code. Indeed, it takes one's concentration away from the higher level parts of an application because of the requirement to get right down to arguably unnecessary detail. I will admit that once the hassles of getting Bobo programs to work are over (Zope products are also hard to get into to start with) it is a powerful tool for developing applications at a higher level of sophistication than the usual stand-alone CGI. ZPublisher and ZTemplates (or whatever DocumentTemplate is called these days) should still provide you with Bobo's functionality. As for ZPublisher, I moved onto Zope from ZPublisher with the idea of trying something more ambitious out. Although Zope is very nice, I still feel that there is a place for a simple object wrapper in the spirit of the original Bobo software, or the ILU HTTP facilities, with minimal effort required in order to get started. Personally, I don't really need persistent object support for everything; especially if I am writing "wrappers" for command line tools, for example. Learning Zope is a fairly big effort, and can cause a fair amount of irritation at times. The good news for beginners now is the effort being put in to improve the documentation - not so long ago, the best way to learn certain features was to read other people's source code and guess at its meaning. Paul From pinard at iro.umontreal.ca Mon Nov 1 11:44:44 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 01 Nov 1999 11:44:44 -0500 Subject: Produce .pyc without execution In-Reply-To: "Adrian Eyre"'s message of "Mon, 1 Nov 1999 09:50:39 -0000" References: <002001bf244e$8e187600$3acbd9c2@peridot.optichrome.com> Message-ID: "Adrian Eyre" writes: > > However, I could not decently propose this scheme for integration in > > Automake, and that makes it a bit unsatisfactory. It would be nicer, > > for example, if `src/*.py' files were recompiled into the `src/' build > > hierarchy from the `src/' distribution hierarchy, and then installed from > > there. But `compileall' wants to install compiled files next to sources > > in the same directory, which is a bit inconvenient. Any simple solution? > This is the default behaviour for Python, and without modifying its source > the .pyc will always be created in the same dir as the source. Can't > you add something like: > install-data-hook: > @echo 'import compileall; compileall.compile_dir("$(pkgdatadir)")' \ > | $(PYTHON); \ > for pyc in $(pkgdatadir)/*.pyc; do mv $$pyc somewhere_else/; done Not really. There are many things to keep in mind for fitting well in the Automake spirit, and these two are a bit more relevant, here: * The distribution hierarchy (by opposition to build hierarchy) should be considered read-only, as if, say, it was already exploded in a CD-ROM; a mere, simple installation should not modify, create or delete files in it; this is only allowed in the build hierarchy. * Many people do `make all' as one user, and `make install' as a different user (`root' or `bin', say), so ideally, all needed files should be prepared in the build hierarchy at `make all' time, `make install' should not create any more files in the build directory, once `make all' has been done. The only files `make install' may create sit in the various installation directories. Above, $(pkgdatadir) is an installation directory, so things are already in their final place, no need to move them further once there. The scheme I used is acceptable when one wants to provide all sources installed with the compiled forms, but some people prefer to keep sources non-installed, just to spare disk space, say. What would be ideal is a way for `compile_dir' to produce `.pyc' in the build hierarchy directly from the source hierarchy at `make all' time, and that `make install' just move these ready `.pyc' files into the installation directories. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From prestonlanders at my-deja.com Wed Nov 17 13:07:24 1999 From: prestonlanders at my-deja.com (Preston Landers) Date: Wed, 17 Nov 1999 18:07:24 GMT Subject: list.without()? References: <38319104.F54AECEF@appliedbiometrics.com> Message-ID: <80uqso$66a$1@nnrp1.deja.com> In article , "Mike Fletcher" wrote: > Conclusions: > First is the posted algo (while,try,except,break) gives very > good performance for the few-in-many case but very poor performance for the > many in many cases for large values of many > Second is a for loop with == test and append -- gives decent > (but not spectacular) results whenever memory effects are not a big factor, > not really a contender. > Third is the lambda solution (which does surprisingly well) -- > gives acceptable but not great performance all over, seems strange that > function-call-overhead is so minor a factor. > Fourth is a backwards-index-counting scheme with del -- gives > marginally better performance than third on few-in-many case, marginally > worse than third in many-in-many case. > Fifth is Preston's remove function -- gives best results for > few-in-many case, again, very poor results in many-in-many case > > Summary: > Looks like the fourth algo is likely the "winner" in this set (assuming > few-in-many is the most common case, but that many-in-many is a potential > case). Third might be preferred due to the simplicity of the implementation > and similar speed. For maximum few-in-many speed, the fifth is the most > appropriate. Excellent work, Mike. Stuff like this is certainly good to know when working a lot with lists! It looks like one conclusion we can draw from this is that matching an algorithm to a data set is not always a straightforward task. It requires careful thought, familiarity with the expected cases (few-in-many, many-in-many, etc) and most importantly, experimentation. Thanks again! ---Preston -- || Preston Landers || Sent via Deja.com http://www.deja.com/ Before you buy. From a.eyre at optichrome.com Mon Nov 1 12:57:43 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Mon, 1 Nov 1999 17:57:43 -0000 Subject: Looking for example of calling C++ from Python In-Reply-To: <381ca15e$0$235@nntp1.ba.best.com> Message-ID: <000d01bf2492$987a72d0$3acbd9c2@peridot.optichrome.com> > I am new to python and would like to know if there is any example > of how to use C++ classes from Python. Have a look at: http://www.python.org/sigs/c++-sig/ -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From thomas at bibsyst.no Wed Nov 3 02:18:45 1999 From: thomas at bibsyst.no (Thomas Weholt) Date: Wed, 03 Nov 1999 08:18:45 +0100 Subject: Need Berkley DB!! References: <381D5E84.98931682@bibsyst.no> Message-ID: <381FE1D5.C0F721A6@bibsyst.no> Robin Dunn wrote: > > After I spent most of my weekend trying to get Berkley DB to work with > > Python on my Linux ( Suse 6.1) machine, I`ve now given up completly. > > I`ve tried to install DB.1.85. and DB.2.7.7, neither worked, either > > crashing under installation ( which of course, is not Python > > related ) or when I tried to test the installation with the examples in > > the documentation ( the wrapper for the 2.7.5-module listed at > > www.python.org, under modules, databases ). > > Have you tried my DB module at http://starship.python.net/crew/robind/ ? > Assuming you can get DB 2.7.x built and installed, this module should do > what you need. > Yes, I`ve tried it and the installation did go smooth, but when I tried to use the example in the documentation Python barfed some errors at me, then died with a scream. I can probably recreate the errors and send you a copy of the output. I think the problem might be solved if I, sigh, re-install Red Hat 6.1 and trash that oversized, over-featured Suse 6.2 Linux distro I got now. The Red Hat version of Python came with all that stuff installed. There`s not enough hours in a day to keep working on things like this. At least not right now. Thanks for your interest though. Best regards, Thomas Weholt From mywsid at datawise.net Sat Nov 6 03:13:04 1999 From: mywsid at datawise.net (mywsid at datawise.net) Date: Sat, 06 Nov 1999 08:13:04 GMT Subject: Get Noticed!! Message-ID: http:/www.mightybiz.com From levicook at earthlink.net Sat Nov 27 17:20:43 1999 From: levicook at earthlink.net (Levi Cook) Date: Sat, 27 Nov 1999 16:20:43 -0600 Subject: is there a safe/easy way to search and replace text w/in an html page? Message-ID: <3840593B.2D1A2E30@earthlink.net> Hello, I'm new to python and I've been tasked w/ writing a script that fetches a web-page and highlights the term that the user searched for. Passing the URL and search term to my script was a cinch and fetching the page was also quite easy. The crux of my problem lies with establishing a strategy for searching out the users term and replacing it with css tags surrounding the original term. At first glance the re module seemed sufficient (and maybe still is ), but it doesn't really have any knowledge of HTML semantics. My next venture was to look at the htmllib module. This appears to parse the html fine, but i'm still at a bit of a loss on what this actually does for me, particularly how do I get my parser to output my page. Does anyone know where I can find code that does anything remotely like this? Does anyone know where I can find good reference on the htmllib module, the python library reference is pretty bleak in this area. Thanks in advance for you time and help. Levi Cook levicook at earthlink.net If anyone's interested here's a bit of the code i'm using for this... From AmanuelZmelik at news.vex.net Sun Nov 14 04:02:34 1999 From: AmanuelZmelik at news.vex.net (Amanuel Zmelik) Date: 14 Nov 1999 09:02:34 GMT Subject: itoa on python? References: <382e77d5.26188609@news.remarq.com> Message-ID: <80ltra$2rb0$1@hub.org> On Sun, 14 Nov 1999 08:52:03 GMT, Gusdvg wrote: >How can I change an integer (or any other type of number) to a string? Here's a few...... >>> str(1234) '1234' >>> `1234` '1234' >>> "%s" % 1234 '1234' From prestonlanders at my-deja.com Thu Nov 4 16:56:33 1999 From: prestonlanders at my-deja.com (Preston Landers) Date: Thu, 04 Nov 1999 21:56:33 GMT Subject: return boolean from functions References: <7vrq9b$hmr$1@nnrp1.deja.com> Message-ID: <7vsvef$elo$1@nnrp1.deja.com> Is this not what you want? def foo(bar): if bar == "spam": return 1 else: return None if foo("spam"): print "We have spam!" As you can see, the return value of foo() is evaluated in a true-false sense by the if statement. So, return None or 0 when you mean false, or return 1 or virtually anything else when you mean true. Alternatively, you can do this: TRUE=1 FALSE=0 def foo(bar): if bar == "spam": return TRUE else: return FALSE hope this helps, ---Preston In article <7vrq9b$hmr$1 at nnrp1.deja.com>, a_olme at my-deja.com wrote: > Hello. > > Is it possible to return booelan from functions other than return 1==1 > for true or return 1==2 for false? > > //Anders Olme > > Sent via Deja.com http://www.deja.com/ > Before you buy. > -- || Preston Landers || Sent via Deja.com http://www.deja.com/ Before you buy. From tbryan at python.net Wed Nov 3 21:48:37 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Wed, 03 Nov 1999 21:48:37 -0500 Subject: Tkinter and Solaris 7 Sparc [Q] References: <7vqblc$ham$1@nnrp1.deja.com> Message-ID: <3820F405.4A1C8767@python.net> exeq at my-deja.com wrote: > I am trying to compile Python 1.5.2 with tkinter on Solaris 7 (Sparc). A word of encouragement: I have successfully built Python 1.5.2 on Solaris 7. I can't remember whether I used gcc or Sun's compiler. > have installed TCL/TK 8.0.5, GCC 2.8.1 / Sun Workshop 5 (I tryied with > both compilers). > > I just get an error saying that libX11.so.6.1 is needed. Is there a way > to build tkinter without X11? Or I just need to download and install > X11? First, I ask the "obvious" question. Did you edit the Modules/Setup file (or, better, did you make a Setup.local file)? If so, did you make sure to use the entries in the Tkinter portion that are specific to Solaris? (from Setup) # *** Uncomment and edit to reflect where your X11 header files are: #-I/usr/X11R6/include \ # *** Or uncomment this for Solaris: -I/usr/openwin/include \ ..... # *** Uncomment and edit to reflect where your X11 libraries are: #-L/usr/X11R6/lib \ # *** Or uncomment this for Solaris: -L/usr/openwin/lib \ If you already did that correctly, is libX11 in that directory? That is use 'ls' and 'find' to look for the library. Is it there? ---Tom From robin at alldunn.com Thu Nov 4 14:35:05 1999 From: robin at alldunn.com (Robin Dunn) Date: Thu, 4 Nov 1999 11:35:05 -0800 Subject: Extending Python dynamically References: <3F8BA119B48AD11197470008C7A493CB98B636@HQOBGEX1> <3821D9B0.56C01339@iqsoft.hu> Message-ID: > Thank you for your help. The method you suggested works perfectly! > However, I do not understand completely how the Python interpreter finds out > that it has to load an so file. Normally -- I believed -- when Python sees an > "import xxx" statement it looks for a xxx.py, xxx.pyc or xxx.pyo file in the > $PYTHONPATH directories or an xxx subdirectory having an __init__.py file, but > not an xxx.so file. This means that if I add the current directory to the > $PYTHONPATH (such as export PYTHONPATH='.' Python will find any arbitrary so > file in the $PWD? It will also load xxxmodule.so as well, but .so files only get imported if they have an initxxx() function. -- Robin Dunn Software Craftsman robin at AllDunn.com http://AllDunn.com/robin/ http://AllDunn.com/wxPython/ Check it out! From kvijayan at calum.csclub.uwaterloo.ca Sat Nov 13 23:13:08 1999 From: kvijayan at calum.csclub.uwaterloo.ca (Kannan Vijayan) Date: 14 Nov 1999 04:13:08 GMT Subject: GNU readline module Message-ID: <80lcsk$99g$1@watserv3.uwaterloo.ca> hi I'm trying to get the readline module to work in python. I have an app to which I want to add tab-completion of commands and other things. The docs for the GNU readline module are extremely sparse. Most of what I know about the module are derived from looking at it's source, looking at how "rlcompleter" uses it, and my own sparse knowledge of the C readline implementation itself. As far as I can see, there is no hook to the "readline(char *PROMPT)" function in the readline module. Am I missing something? I have, however, gotten my completer function to work well from within the interactive interpreter environment. What I'm having trouble with is getting it to work from a non-interactively interpreted application in it's own happy .py file. I assume there would be some function which I could call to read a line, which in turn would call my completer function to do the job when a tab is pressed. I have a nagging notion that maybe the readline module is only for use from withing the interactive interpreter. IS this true? if so.. that's extremely dissapointing. thank you -kannan From raptor_99_uk at my-deja.com Wed Nov 10 10:36:36 1999 From: raptor_99_uk at my-deja.com (raptor_99_uk at my-deja.com) Date: Wed, 10 Nov 1999 15:36:36 GMT Subject: Namespace question... References: <7vqgib$l8v$1@nnrp1.deja.com> Message-ID: <80c3e4$vpq$1@nnrp1.deja.com> In article <7vqgib$l8v$1 at nnrp1.deja.com>, oofoe at my-deja.com wrote: > Hi! > > How can you access the global namespace in python 1.5.1? I'd like to get > a version string which is declared in the main script file. However, > each module also has a version string which overrides the original one. > I tried to access it as __main__.Version, similarly to $main::Version in > Perl, which is what I'm more familiar with. Of course, it didn't work. > > I have something like this: > > module file foo.py: > ------------------------------ > Version = '$Id$' > > def bar(): > print "Version is: ", __main__.Version > > main program: > ------------------------------ > Version = '$Id$' > > import foo > > foo.bar() > > ------------------------------- > > I'd certainly appreciate any pointers. The namespace stuff seems to get > a little hazy around issues like this. > > Thanks! > > Jos'h > > Sent via Deja.com http://www.deja.com/ > Before you buy. > just declare Version to be global inside bar() as follows: def bar(): global Version print "Version is: ", Version Sent via Deja.com http://www.deja.com/ Before you buy. From ionel at psy.uva.nl Mon Nov 8 14:45:48 1999 From: ionel at psy.uva.nl (Ionel Simionescu) Date: Mon, 8 Nov 1999 20:45:48 +0100 Subject: Fastest GUI toolkit? References: <01bf29f1$cbfd5e60$5a41c3d1@Cyberus.cyberus.ca> Message-ID: <80796r$5ml@mail.psy.uva.nl> Gordon Williams wrote in message news:01bf29f1$cbfd5e60$5a41c3d1 at Cyberus.cyberus.ca... | | I have an application where I need to draw many lines fast and repeatedly | (an oscilloscope). The number of lines ranges from about 1000 to 16000. | Currently I have the application using Tkinter but I am finding it too | slow. I am currently using W95 as an os, but would prefer to make the code | portable across other os if possible. Right now speed is more important | than portability so I would be willing to give this up. | | I would like to draw 1000 lines in 1/10 of a second on a P166 machine. (Am | I way off the mark??) I was hoping that someone would have tried different | packages and could give me pointers in the right direction. Hi Gordon, I've just tried your test with a simple wxPython application and it almost makes it. My system is Windows NT, P200, 64M. The test app draws 1400 lines in .25 seconds (with the same pen). For 1000 lines, it takes 0.18 seconds. wxPython is also offering an easy to use OpenGL interface, from which I expect much better performance. Given your needs, I suggest that you should consider seriously using OpenGL, rather than trying your own optimizations. This choice would give you good and scalable performance irrespective of the platform. Just naive GDI calls won't do, I'm afraid. However, if you need something quick, you may consider to draw in a memory DC (i.e. a bitmap) first and copy the end result to the screen. That will hopefully make the time drop under your .1 second mark. --- ionel References: wxPython: http://alldunn.com/wxPython/ From jimbag at kw.igs.net Mon Nov 15 23:24:19 1999 From: jimbag at kw.igs.net (JB) Date: Tue, 16 Nov 1999 04:24:19 GMT Subject: ASCII delimited files References: <942231502.1914033961@news.interbusiness.it> Message-ID: <3830DC72.1852529A@kw.igs.net> Roger Irwin wrote: > > Is there any function or module available for parsing ASCII delimited files, > before I go and re-invent the wheel writing my own. > > BTW, I know it is simple to do, but I was thinking along the lines that a > 'standard' could easily be substituted for a C version for large files. I wrote something that may be of interest. It does CSV, Fixed and delimited ASCII files (amoung other things). It's called dataSlayer (i know it's a bit dramatic) http://www.kw.igs.net/~jimbag cheer jim -- ----------------------------------------------------------- Machine-Independent, adj.: Does not run on any existing machine. From pinard at iro.umontreal.ca Tue Nov 30 15:49:28 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 30 Nov 1999 15:49:28 -0500 Subject: Python Make In-Reply-To: Helge Hess's message of "Tue, 30 Nov 1999 19:29:04 +0100" References: <3843E558.8AC91A97@strs.co.uk> <38441770.80C33C93@mdlink.de> Message-ID: Helge Hess writes: > Ian Clarke wrote: > > Has anyone considered using Python as a replacement for the "make" [...] > YES! I had the same idea :-) [...] The negative aspect is that one > needs python for compilation then (eg you can't compile python using > 'python' makefiles). Detail! Given you have some `dryrun' option, just use it for generating a distributable batch script, that could then be used for bootstrap. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From ScherBi at BAM.com Tue Nov 16 16:01:01 1999 From: ScherBi at BAM.com (ScherBi at BAM.com) Date: Tue, 16 Nov 1999 16:01:01 -0500 Subject: problems with __getattr__ & __setattr__ Message-ID: <3F8BA119B48AD11197470008C7A493CB98B67E@HQOBGEX1> Michael Hudson wrote: > def __getattr__(self, key): > try: > return self.__dict__["eggs"][key] > except: > raise > > is probably safer. What are the try/catch for? They aren't doing > anything here! Thanks. I came upon your this solution in the interval. The try/except were not relevent in the sample, but are in my real code. sorry. 8-) > __getattr__-and-__setattr__-are-so-much-fun-we-don't-mind-the- > performance-hit-ly y'rs - Michael Yes, I had to convince a colleague (it wasn't hard) that the syntactic sugar they produce are worth the __dict__ mangling ugliness. :) Thanks again. Bill > -----Original Message----- > From: Michael Hudson [mailto:mwh21 at cam.ac.uk] > Sent: Tuesday, November 16, 1999 3:41 PM > To: python-list at python.org > Subject: Re: problems with __getattr__ & __setattr__ > > > ScherBi at BAM.com writes: > > > I am having trouble using __getattr__ and __setattr__ in > some classes. I've > > boiled it down to the code below. > > It dumps core under 1.5.2 on Linux or WinNT. > > > > I think maybe it's looping, if so, how does one go about > doing this? > > (I'm assuming it's clear enough what I'm trying to do.) > > > > If I comment out the __gettattr__ operation, it doesn't > dump core. Instead > > I get an AttributeError: eggs raised at the 'self.eggs[key] > = value' call in > > __setattr__. This is what leads me to belive there's > something circular > > going on here. > > > > > > Thanks, > > Bill > > > > ------------------------------------------------------------- > > > > class spam: > > > > def __init__(self): > > self.eggs = {} > > Hint: what does this call? > > > def __getattr__(self, key): > > try: > > return self.eggs[key] > > except: > > raise > > > > def __setattr__(self, key, value): > > It calls this! > > > try: > > self.eggs[key] = value > > And this calls __getattr__ which looks for self.eggs, which calls > __getattr__, which looks for self.eggs, which calls __getattr__, which > looks for self.eggs, which calls __getattr__, which looks for > self.eggs, which calls __getattr__, which looks for self.eggs, which > calls __getattr__, > Segmentation fault (core dumped) > > > return 0 > > except: > > raise > > > > > > > > if __name__ == '__main__': > > > > s = spam() > > print 'instance of spam created.' > > > > try > > def __init__(self): > self.__dict__['eggs'] = {} > > instead; also > > def __getattr__(self, key): > try: > return self.__dict__["eggs"][key] > except: > raise > > is probably safer. What are the try/catch for? They aren't doing > anything here! > > __getattr__-and-__setattr__-are-so-much-fun-we-don't-mind-the- > performance-hit-ly y'rs - Michael > > -- > http://www.python.org/mailman/listinfo/python-list > From aahz at netcom.com Thu Nov 25 21:51:18 1999 From: aahz at netcom.com (Aahz Maruch) Date: 26 Nov 1999 02:51:18 GMT Subject: Python complaints References: <86so1v4jlj.fsf@g.local> Message-ID: <81ksj6$lif$1@nntp9.atl.mindspring.net> In article , Markus Stenberg wrote: > >From trivial example - do you consider (+ 2 (* 3 4)) more readable than 2 + >3 * 4 most languages (including Dylan) allow me to do? I think that should be written as "3 4 * 2 +". ;-) -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Question authority: ask me anything! From smst at quantisci.co.uk Tue Nov 16 04:57:57 1999 From: smst at quantisci.co.uk (Steve M S Tregidgo) Date: Tue, 16 Nov 1999 09:57:57 GMT Subject: Memory not being released? Message-ID: <199911160957.JAA12725@cobweb.quantisci.co.uk> Thanks. We already have a persistent object system, but I'll take a look at shelve anyway. Darrell wrote: > Here's an idiom I like in this case. > Store your objects in a dict based on id(obj), just as you've done. > Now if objects must reference each other use the id(obj) > and look up the obj. And delete them from the dict when needed. > Yes it's slow but only use it in these big ugly cyclic data structures. > > But notice how fast memory gets used up. > This eats 84meg. > >>> dict={} > >>> for x in xrange(1000000): > .... dict[x]=(x,x+1) > .... > >>> > > You might take a look at shelve. It gives you a persistent dictionary. > I've been playing with a flat file manager that can reclaim freed space. > > -- > --Darrell > Steve Tregidgo wrote in message > news:80pdvo$99r$1 at nnrp1.deja.com... > > Hi there, > > > > I'm having problems with a large process, and I'd really appreciate > > some help in tracking down the cause of its bloatedness. > > > > > > > -- > http://www.python.org/mailman/listinfo/python-list From jsight at mindspring.com Sun Nov 28 20:56:19 1999 From: jsight at mindspring.com (Jesse D. Sightler) Date: Sun, 28 Nov 1999 20:56:19 -0500 Subject: http://www.python.org/ blank ? References: Message-ID: <3841DD43.C0C07A03@mindspring.com> Close all Netscape windows. Reopen Netscape. Go to http://www.python.org/. Magically it will appear. :-) This has been a weird little display glitch in many versions of Netscape for years where every once and a while a page will load completely... and then NOT display at all. Robin Becker wrote: > > for some reason I see http://www.python.org/ as a blank page. Any ideas? > -- > Robin Becker -- --------------- Jesse D. Sightler http://www.biddin.com/ From helka.folch at edf.fr Tue Nov 9 12:56:37 1999 From: helka.folch at edf.fr (Helka FOLCH) Date: Tue, 09 Nov 1999 18:56:37 +0100 Subject: Max Size of Array when using Numeric.py Message-ID: <38286054.C8612EB5@edf.fr> I've tried to create an array object whose shape is (5500,200) but I get a memory error. Is there a maximum size for array objects? Maybe there's a better way of creating the array than what I did : My program reads the array which is in another format from a file. It transforms the array to the right format and holds it in a variable(mv) as a string. Then I just do: m = array(eval(mv),Float) Thanks a lot, Helka From matz at netlab.co.jp Thu Nov 4 00:22:08 1999 From: matz at netlab.co.jp (Yukihiro Matsumoto) Date: 04 Nov 1999 14:22:08 +0900 Subject: A Comparison of Python and Ruby Extension Interfaces (Re: Comparison between Python and "Ruby") References: <3819BCDA.AC4FD4CA@strs.co.uk> <87k8o2x67f.fsf@ev.netlab.co.jp> <7vjtrc$hmm$1@newshost.accu.uu.nl> <38204614.2EAC6051@compaq.com> <021119992327527678%pereira@research.att.com> <38215CE7.70C3D560@compaq.com> <031119992347056096%pereira@research.att.com> Message-ID: <87k8nyvnjz.fsf@ev.netlab.co.jp> Fernando Pereira writes: |In my experience, there's a big difference between what you and I call |"sensible" and what compiler and OS developers try to get away with, |not to mention the vagaries of particular hardware. For example, what |is the state of the stack, registers, etc. when a Unix signal handler |is called? What if that handler (maybe by calling back into the |higher-level language) forces a GC? I implemented Ruby to avoid GC (and longjmp) during handlers. See code for detail, if you are interested. We haven't met such problems, yet. From wtanksle at hawking.armored.net Mon Nov 1 11:43:58 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 1 Nov 1999 16:43:58 GMT Subject: Improved struct module References: <000001bf15fc$3397ee00$ba2d153f@tim> <0E16861EE7BCD111BE9400805FE6841F0BEB2650@c1s5x001.cor.srvfarm.origin-it.com> Message-ID: On 01 Nov 1999 18:24:20 -0500, Fran?ois Pinard wrote: >"Robin Boerdijk" writes: >> I must admit that I am also one of those lazy bastards that uses his >> newsreader's "find any messages by Tim Peters"-function to locate >> interesting threads. >So do I, but even more lazily! Gnus bolds Tim's messages automatically >for me, when preparing the threaded summary for the Python mailgroup. :-) Ah, but does your newsreader automatically delete all the other messages? Hah! Some time-saver it is. I used to use nn (NoNews). Now THAT was a good newsreader -- or news ignorer as the case may be. In most newsreaders the default is to read every message; in NN the default is to ignore every message. A pity I couldn't set it up to forge cancels for every message and save everyone else's time ;-). >Fran?ois Pinard http://www.iro.umontreal.ca/~pinard -- -William "Billy" Tanksley From python-list at teleo.net Wed Nov 24 18:39:10 1999 From: python-list at teleo.net (Patrick Phalen) Date: Wed, 24 Nov 1999 15:39:10 -0800 Subject: newbie question In-Reply-To: <943469319.838266356@news.teleweb.at> References: <943469319.838266356@news.teleweb.at> Message-ID: <99112415413404.01208@quadra.teleo.net> [Markus Krutz, on Wed, 24 Nov 1999] :: How the f*** do I create a string containing a *single* "\" ? Well, you could always try escaping it: "\\". You might also try reading the lovely tutorial Guido worked so hard to prepare: http://www.python.org/doc/tut/tut.html From quinn at pfennig.ugcs.caltech.edu Wed Nov 17 20:07:15 1999 From: quinn at pfennig.ugcs.caltech.edu (Quinn Dunkan) Date: 18 Nov 1999 01:07:15 GMT Subject: help redefining print statement References: <80v32d$cmg$1@nnrp1.deja.com> Message-ID: On Wed, 17 Nov 1999 20:26:59 GMT, curtin at my-deja.com wrote: >hi, >i'd like to redefine the "print" statement in a module. essentially >i'm looking to do a "#define like" replacement on a module level. > >i'd add at the top of the module: > >if debug: > TestingPrint=print >else: > TestingPrint=eval("#") or TestingPrint="#" or ... > >TestingPrint "blah, blah %d, %s" % (i, s) > >yes, i'd like to not make the function call overhead in the non-debug >case. > >i've tried a few different ways to incorporate this functionality, >and scrounged around deja without any success. You can't redefine print, it's a reserved work built into the language. My usual tactic is to use my dprint() function which checks for the debug variable, and I don't worry about function call overhead. But if you've got one it in a tight loop or something, you could do: if __debug__: print 'debugging info' When python is run with -O, it won't compile things under if __debug__ (see ref manual 6.2). maybe-tim-could-write-a-function-that-comments-out-its-caller From stidolph at origin.ea.com Mon Nov 22 10:12:03 1999 From: stidolph at origin.ea.com (Stidolph, David) Date: Mon, 22 Nov 1999 09:12:03 -0600 Subject: Getting PythonWin debugger working with an embedded app. Message-ID: <11A17AA2B9EAD111BCEA00A0C9B41793034AAF00@molach.origin.ea.com> I am trying to get the Python Win debugger working with our app. We have embedded Python and using it as a script language. We are using the debug version of the Python DLL for Windows. I copied the pywin directory to our python system directory (plus adding that to the search path) and put the following code in one of our scripts (to be activated from a menu item within our ui): import pywin.debugger try: a = 1 / 0 except: pywin.debugger.post_mortem() I get the following output: Traceback (innermost last): File "python\client\Interface\UIMenu.py", line 272, in DoMenuCommand command(x,y,flags) File "python\client\Interface\UO2GameWindow.py", line 304, in OnMenuDebug pywin.debugger.post_mortem() File "C:\Program Files\Python\Pythonwin\pywin\debugger\__init__.py", line 70, in post_mortem p = _GetCurrentDebugger() File "C:\Program Files\Python\Pythonwin\pywin\debugger\__init__.py", line 9, in _GetCurrentDebugger import debugger File "C:\Program Files\Python\Pythonwin\pywin\debugger\debugger.py", line 19, in ? import win32ui ImportError: No module named win32ui I tried putting the contents of the PythonWin directory in the pywin directory and it still has the same message. In looking at the message I see that it is going to the installed place of Python and PythonWin instead of my search path. I can see the win32ui.py module, and it is directly in the Python search path, so what am I doing wrong? Any advice or suggestions would be truly welcome. Getting the debugger working would be a huge step forward for us. Thanks for you help, David. From gerrit.holl at pobox.com Tue Nov 16 11:07:28 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Tue, 16 Nov 1999 17:07:28 +0100 Subject: SMTP In-Reply-To: <80rn4o$bnl$1@news.fsu.edu> References: <80rn4o$bnl$1@news.fsu.edu> Message-ID: <19991116170728.A30970@optiplex.palga.uucp> Glenn Kidd wrote: > Does anyone know where some good info on Python's smtplib? Well, er... what about the default module index? > I have looked at > http://www.python.org but I was wondering if there was any more info out > there. Any help would be appreciated. Isn't it enough? body = '''From: me To: my brother Subject: hello! X-Mailer: a python script This is the bodddddddddyyyyyyyyyy........ ''' regards, Gerrit. -- We are using Linux daily to UP our productivity - so UP yours! (Adapted from Pat Paulsen by Joe Sloan) From tbryan at python.net Sun Nov 7 00:49:24 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Sun, 07 Nov 1999 00:49:24 -0500 Subject: making the Python case to my dept. References: <9911051740130D.02530@william.jinsa.org> <3823FC43.CF7FBD71@python.net> Message-ID: <382512E4.21A48861@python.net> Michael Hudson wrote: > ``import rlcompleter''!! Thanks. I used to use this, but I took a break from Python, changed environments, and forgot about it. > [snippo two] > > Do math majors or engineers learn their critical job skill's in their > > first classes? > > What are mathematicians' critical job skills? I'm curious, being one, > and not having being taught anything resembling a `critical job skill' > yet, and happy about it. It depends what job you're looking for. :) I was thinking more about applied math and engineering students, but if you're intending to stay in academia, then being able to write and explain proofs is a job skill. So is teaching ability. I happen to have a math degree, and I specialized in topology with some emphasis on knot theory. When I was originally looking for jobs, I emphasized my problem-solving skills and my ability to deal with large doses of abstraction and technical literature. I've found that experience hammering down details to make an air-tight, pedantic proof really helps when I'm trying to debug a program. It-sounds-better-than-"I-can-tie-my-shoes"-ly yours ---Tom From fdrake at acm.org Fri Nov 5 11:53:07 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Fri, 5 Nov 1999 11:53:07 -0500 (EST) Subject: 64 bit ints for SNMP counter64 variables In-Reply-To: <7vq8o4$18j$1@news.tamu.edu> References: <7vq8eg$4k$1@news.tamu.edu> <7vq8o4$18j$1@news.tamu.edu> Message-ID: <14371.2931.226939.602387@weyr.cnri.reston.va.us> Eric Nelson writes: > oops... posted too quick... found long() just after i hit send... sorry Eric, There's also the mpz module if you can use the GNU arbitrary- precision math library (I don't know how portable that is, but I imagine it should be fairly portable). -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From R.Brodie at rl.ac.uk Tue Nov 9 08:20:46 1999 From: R.Brodie at rl.ac.uk (Richard Brodie) Date: Tue, 9 Nov 1999 13:20:46 -0000 Subject: Graphics. References: <3826E949.BBA1BAFD@imf.au.dk> <091119991052098844%kantel@mpiwg-berlin.mpg.de> Message-ID: <80973f$poq@newton.cc.rl.ac.uk> J?rg Kantel wrote in message > If you want to use Tkinter and maybe you can read German than I've a > nice example at my website at > > > ...and as everyone knows, if you haven't done Python in German, you haven't done Python :) Ich bin ein Holzf?ller und f?hl mich stark, Ich schlaf des Nachts und hack am Tag. From gerrit.holl at pobox.com Mon Nov 1 15:47:46 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Mon, 1 Nov 1999 21:47:46 +0100 Subject: Bug in standard cursesmodule? Message-ID: <19991101214746.A30582@optiplex.palga.uucp> Hello, A does not work, B does work! --- *** A *** --- #!/usr/bin/python import curses stdscr = curses.initscr() stdscr.addch(24, 79, ord('X')) stdscr.refresh() curses.endwin() --- *** A *** --- --- *** B *** --- #include main () { initscr(); mvaddch(24, 79, 'X'); refresh(); endwin(); } --- *** B *** --- I think it's a bug... Am I right? When I run A, it says: error: [mv]waddstr() returned ERR regards, Gerrit. From fdrake at acm.org Mon Nov 15 10:26:28 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Mon, 15 Nov 1999 10:26:28 -0500 (EST) Subject: Random text generator In-Reply-To: <01e101bf2dcd$f4bb6290$f29b12c2@secret.pythonware.com> References: <199911120349.OAA01177@envy.fulcrum.com.au> <01e101bf2dcd$f4bb6290$f29b12c2@secret.pythonware.com> Message-ID: <14384.9764.78515.201565@weyr.cnri.reston.va.us> Fredrik Lundh writes: > it would probably be a bit clearer (at least to newcomers) > if "random" is was the official interface, and whrandom was > treated as an implementation module. but it doesn't look > that way in the current version of the library reference... This is already on my list to fix before the next documentation release. > (and the eff-bot guide is obviously wrong on this one. not > sure I'll add that to the errata, though ;-) Add it so people will get the message! -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From fdrake at acm.org Fri Nov 19 09:12:01 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Fri, 19 Nov 1999 09:12:01 -0500 (EST) Subject: Python Chinese In-Reply-To: <19991119080202.A439@better.net> References: <19991119121544.5006.qmail@hotmail.com> Message-ID: <14389.23217.980958.63607@weyr.cnri.reston.va.us> On Fri, Nov 19, 1999 at 01:15:44PM +0100, Ulf Engstr?m wrote: > Is there any way to use Python with Chinese and other asian chars? > If not, are there any plans to make this compability? Ulf, While Python is 8-bit clean, there is not support for Unicode or other wide character sets. Some extensions are available from various members of the community to provide Unicode support, but none are integrated into the core. The next major Python release will include Unicode support and support for a variety of common encodings. Support for Asian encodings will probably be packaged separately. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From mwh21 at cam.ac.uk Tue Nov 30 06:48:38 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 30 Nov 1999 11:48:38 +0000 Subject: Installation Problem (1.5.2) References: <3843B816.F4A31F07@attglobal.net> Message-ID: Jon McLin writes: > On my Mandrake 6.0 box, I just upgraded from 1.5.1 to 1.5.2 with a > fresh compile. Since the 1.5.1 installation placed the binaries in > /usr/bin, I used the configure option "--exec_prefix=/usr" 1) you mean --exec-prefix. 2) you may have binaries in /usr/bin, but you also have libraries in /usr/lib, not /usr/local/lib. pass --prefix=/usr to configure. Regards, Michael From guido at cnri.reston.va.us Wed Nov 3 18:33:30 1999 From: guido at cnri.reston.va.us (Guido van Rossum) Date: 03 Nov 1999 18:33:30 -0500 Subject: A Comparison of Python and Ruby Extension Interfaces (Re: Comparison between Python and "Ruby") References: <3819BCDA.AC4FD4CA@strs.co.uk> <87k8o2x67f.fsf@ev.netlab.co.jp> <7vjtrc$hmm$1@newshost.accu.uu.nl> <38204614.2EAC6051@compaq.com> Message-ID: <5ld7trtak5.fsf@eric.cnri.reston.va.us> Greg Ewing writes: > * The names of the Ruby interface routines are often > shorter than the equivalent Python ones. Python used to have short names too, and in fact the current naming scheme was intruduced with great reluctance. Unfortunately the realities of embedding Python in other apps required the current longer names, to avoid name clashes between Python macros, types and externals and ditto defined by the embedding app. Extension modules wrapping large existing libraries also ran into this. > * Ruby seems to be able to raise exceptions without > having to explicitly propagate them back out of routines, > which eliminates a lot of result testing and returning of > -1's and None's that goes on in Python extension code. Does it use longjmp to do this? Or is it written in C++ and using C++ exceptions? Note that longjmp is a frequent cause of nasty portability problems (e.g. recently a bug reported on FreeBSD when combining threads and readline was discovered to be caused by a bug in the longjmp implementation). Or perhaps it has macros containing return statements? (Yuck!) > Some other observations, in no particular order: > > * In Ruby, routines with a fixed number of arguments can > be defined so that they are received as separate C > arguments instead of a vector, e.g. > > static VALUE > fdbm_store(obj, keystr, valstr) > VALUE obj, keystr, valstr; > > This doesn't actually save much code, however, since you > still have to test and convert each argument. How does Ruby know how many arguments the C code has??? > * Ruby's method of representing an extension type is a > whisker more complicated. Instead of allocating a single > object, you have to create an object of type DATA, which > contains a pointer to a class and a pointer to a C > structure. > > * The mechanism for associating methods with object types > is somewhat simpler in Ruby. In Python, some methods live > in slots in the type object, while others live in a method > table or are somehow otherwise accessed through the getattr > method. In Ruby, all methods, including the ones for built > in operations, are attached to the object's class, which seems > to play the role of both the Python type object and method > table. I agree that this would be a desirable design for a future Python implementation. --Guido van Rossum (home page: http://www.python.org/~guido/) From jlle at redestb.es Sun Nov 7 13:48:25 1999 From: jlle at redestb.es (Juan) Date: Sun, 7 Nov 1999 19:48:25 +0100 Subject: Printing from Python to Windows Printers References: Message-ID: <804hb0$4cb6@SGI3651ef0.iddeo.es> You can use the class wxPrinter and wxPrintout instaling previously wxPython. Un saludo. Juan Huertas Robert Parker escribi? en el mensaje de noticias fIHU3.641$f66.886 at 198.235.216.4... > I am trying to find out how I can print to a windows printer from a Python > application. Has anyone used any of the Com modules to gain access to the > printer api in windows? Are there any modules that have been written that > would help save time when we want to send font information only to the > printer driver not have to write in the escape sequences and print directly > to the parallel port? > > > > From conversy at lri.fr Mon Nov 15 10:43:26 1999 From: conversy at lri.fr (Stephane Conversy) Date: Mon, 15 Nov 1999 16:43:26 +0100 Subject: Tkinter.event.state Message-ID: <38302A1D.7224CD04@lri.fr> Hello. I know that the 'state' filed of a Tkinter event changed whenever I press the shift key, or the ctrl key. I can see and figure out what to test if I want to query if the 'shift' key is pressed, but I was wondering whether it exists some constant to do so. I looked in the doc and in the sources and I couldn't find it. any tips ? -- St?phane Conversy http://www-ihm.lri.fr/~conversy/ mailto:conversy at lri.fr From matz at netlab.co.jp Wed Nov 3 21:30:13 1999 From: matz at netlab.co.jp (Yukihiro Matsumoto) Date: 04 Nov 1999 11:30:13 +0900 Subject: A Comparison of Python and Ruby Extension Interfaces (Re: Comparison between Python and "Ruby") References: <3819BCDA.AC4FD4CA@strs.co.uk> <87k8o2x67f.fsf@ev.netlab.co.jp> <7vjtrc$hmm$1@newshost.accu.uu.nl> <38204614.2EAC6051@compaq.com> <5ld7trtak5.fsf@eric.cnri.reston.va.us> Message-ID: <87puxrugy2.fsf@ev.netlab.co.jp> Guido van Rossum writes: |Does it use longjmp to do this? Or is it written in C++ and using C++ |exceptions? Note that longjmp is a frequent cause of nasty |portability problems (e.g. recently a bug reported on FreeBSD when |combining threads and readline was discovered to be caused by a bug in |the longjmp implementation). | |Or perhaps it has macros containing return statements? (Yuck!) It's using longjmp. We haven't met longjmp's nasty portability problems yet, for 6 years. |> This doesn't actually save much code, however, since you |> still have to test and convert each argument. | |How does Ruby know how many arguments the C code has??? It's part of the method attribute. C functions are registered with the number of arguments they accept. |> * The mechanism for associating methods with object types |> is somewhat simpler in Ruby. In Python, some methods live |> in slots in the type object, while others live in a method |> table or are somehow otherwise accessed through the getattr |> method. In Ruby, all methods, including the ones for built |> in operations, are attached to the object's class, which seems |> to play the role of both the Python type object and method |> table. | |I agree that this would be a desirable design for a future Python |implementation. Surely. matz. From nhv at cape.com Tue Nov 16 14:12:22 1999 From: nhv at cape.com (Norman Vine) Date: Tue, 16 Nov 1999 14:12:22 -0500 Subject: FW: [3D Modeller] Final decisions... scripting ? References: <80rb9c$m87$1@nnrp1.deja.com> Message-ID: <80sabs$2ld0$1@newsie2.cent.net> FWD: from 3dmodeller at topica.com >-----Original Message----- >From: Joel Utting >Sent: Tuesday, November 16, 1999 1:21 PM >To: 3dmodeller at topica.com >Subject: [3D Modeller] Final decisions... scripting ? > > >To try to wrap up this debate; I don't think we should rely on a >scripting language, rather use it for extra commands/plugins. Chris' >mail about not wanting to rely on a scripting layer is correct in my >opinion. > >The Undo feature is easily implemented without a scripting >layer. Why is >it necessary ? I can see how it would be useful (later) but I think >passing a Number relating to the button press/etc (eventually >the number >of the script to be called) through the system is faster and simpler to >begin with - if the number is a 1:1 relation to a function call...call >the function. If not then call the script interpreter that the number >relates to with the script that the number refers to and let the script >do all the more fancy work. Its not inventing a new scripting language >as scripts with 1:1 relationship are function calls (all our base >functionality) and anything else calls a script written in a common >scripting language. > >Setting up a script language is what should come later on - >when we make >the app more customizeable/flexible. > >Perhaps a more detailed plan of how the script interface/editor core >should work would help - we need this to start coding soon. > >Bye - Joel. > > > >3D Modeller Mailing list ; >to unsubscribe 3dmodeller-unsubscribe at topica.com >archives http://www.topica.com/lists/3dmodeller >URL ; http://www.woodsoup.org/~sbaker/modellers > From cgw at fnal.gov Tue Nov 16 08:24:16 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Tue, 16 Nov 1999 14:24:16 +0100 (MET) Subject: Directory chooser in Tk In-Reply-To: <19991116071917.A711753@vislab.epa.gov> References: <38304E78.F92C8596@callware.com> <19991116071917.A711753@vislab.epa.gov> Message-ID: <14385.23296.680071.39959@gargle.gargle.HOWL> > Ivan Van Laningham: > |I need a dialog similar to the askopenfilename() dialog, but for > |directories. Is there such a beast? > A long time ago I needed this and wound up using Tix. But I imagine that by now Tix is deprecated, unsupported, obsolete, dead, etc... How-about-a-filechooser-that-lets-you-select-multiple-files-ly yr's, cgw From infotechsys at pivot.net Tue Nov 30 01:10:32 1999 From: infotechsys at pivot.net (Wayne) Date: Tue, 30 Nov 1999 01:10:32 -0500 Subject: Help finding Matt Conyway's tutorial Message-ID: <38436A58.98FEA03@pivot.net> Hi, I'm trying to find an address for Matt Conway. I understand he has a tutorial called "A Tkinter Life Preserver" that I would like to down load. If there is any other tutorial out there that someone can point me to I be happy for the info. TIA. Wayne From mcfletch at vrtelecom.com Mon Nov 29 07:43:20 1999 From: mcfletch at vrtelecom.com (Mike Fletcher) Date: Mon, 29 Nov 1999 07:43:20 -0500 Subject: [wxPython] Mandelbrot - further improvements In-Reply-To: Message-ID: Summary: Mandelbrot Module, calculates (and displays) Mandelbrot set using Numeric extensions. Has been optimised slightly on the wxPython list, module attached... Another few 1/10ths of a second improvement (~3.3s down to ~2.9s), as my part has ceased to have any relevance to wxPython, I should probably switch to the main list :) , this will be my last post to the wxPython list on this topic :) . I added code to the module so that it will run without wxPython installed (it will use wxPython if it's available, otherwise just prints status to command line). Enjoy, Mike From S.I.Reynolds at cs.bham.ac.uk Mon Nov 29 07:49:26 1999 From: S.I.Reynolds at cs.bham.ac.uk (Stuart Reynolds) Date: Mon, 29 Nov 1999 12:49:26 +0000 Subject: discrete event simulation? References: Message-ID: <38427656.5AEE@cs.bham.ac.uk> Greg Wilson wrote: > > Has anyone written a discrete event simulation framework in Python? If so, > I'd be grateful for pointers. That depends upon what you mean. I have some classes for Markov Decision Processes (of which Markov processes are a subset) and algorithms for performing dynamic programming (value iteration) on them. Stu From mhammond at skippinet.com.au Sat Nov 13 18:38:55 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 13 Nov 1999 23:38:55 GMT Subject: NT admin scripts with python References: <000101bf2e22$7060a190$020a10ac@p350.gnaa.net> Message-ID: Yep - the win32net module is all you need! Included in the win32all extensions... Mark. geoff nordli wrote in message <000101bf2e22$7060a190$020a10ac at p350.gnaa.net>... >Does python have a module that would allow a person to write >scripts on NT Server to lets say: create users, map drives, >modify registry, create shares, and so on. > >thanks, > >Geoff Nordli > > > From tbryan at python.net Mon Nov 15 06:37:52 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Mon, 15 Nov 1999 06:37:52 -0500 Subject: GNU readline module References: <80lcsk$99g$1@watserv3.uwaterloo.ca> Message-ID: <382FF090.E7901DC2@python.net> Michael Hudson wrote: > > I have a nagging notion that maybe the readline > > module is only for use from withing the > > interactive interpreter. IS this true? if so.. > > that's extremely dissapointing.> > I've never seen it used for anything else. There's no particular > reason for this. I've seen other people post about using it in their apps, and I don't think that there's any reason to use it only in the interpreter. Of course, readline is GPL, right? That might be unacceptable to those shipping closed, proprietary software. ---Tom From gek8365 at garnet.acns.fsu.edu Tue Nov 16 08:47:35 1999 From: gek8365 at garnet.acns.fsu.edu (Glenn Kidd) Date: Tue, 16 Nov 1999 08:47:35 -0500 Subject: SMTP Message-ID: <80rn4o$bnl$1@news.fsu.edu> Does anyone know where some good info on Python's smtplib? I have looked at http://wwww.python.org but I was wondering if there was any more info out there. Any help would be appreciated. Glenn From guido at cnri.reston.va.us Tue Nov 9 14:26:34 1999 From: guido at cnri.reston.va.us (Guido van Rossum) Date: 09 Nov 1999 14:26:34 -0500 Subject: Fastest GUI toolkit? References: <01bf29f1$cbfd5e60$5a41c3d1@Cyberus.cyberus.ca> Message-ID: <5lk8nr8o0l.fsf@eric.cnri.reston.va.us> > Gordon Williams wrote: > > > >I have an application where I need to draw many lines fast and repeatedly > >(an oscilloscope). The number of lines ranges from about 1000 to 16000. > >Currently I have the application using Tkinter but I am finding it too > >slow. nascheme at enme.ucalgary.ca (Neil Schemenauer) writes: > I assume you are using the canvas to draw. I think it is much > faster to use Canvas.coords to move the lines then to redraw > them. If this approch works for your application it may be worth > a try. This may not save Gordon's app, but I once successfully saved a canvas-using Tkinter app by bypassing most of the Tkinter Python code, and calling Tk directly using .tk.call(...). It takes a bit of effort to generate the right Tcl syntax, but it can speed line drawing up by an order of magnitude... --Guido van Rossum (home page: http://www.python.org/~guido/) From drek at MonsterByMistake.Com Tue Nov 2 14:18:47 1999 From: drek at MonsterByMistake.Com (Agent Drek) Date: Tue, 2 Nov 1999 14:18:47 -0500 (EST) Subject: capturing stderr && stdout Message-ID: Hullo, I have searched the web and all the python documents/examples I could find before posting here. My apologies if I have missed the obvious :) (I bought two books as well that I am going through) Alot of what I need to do with python depends on launching and controlling a subprogram called hscript. It's a 'closed' application that is not a full bodied language like python. I am hoping to launch one instance of hscript write to it and keep its stdout && stderr. Most of our work gets done with csh scripts like the following: #!/bin/csh -f #csh stuff goes here hscript -q $HIPDIR/$HIPFILE << ENDCAT >>&! $LOG # now I write hscript commands opcf /obj #etc ENDCAT exit here's a stripped down version of what I have thus far. #!/usr/local/bin/python import os, sys HSCRIPT = "hscript" p = os.popen("%s" % HSCRIPT, "w") p.write("opcd /obj\n") p.write("opadd geo\n") p.write("opls\n") p.write("quit\n") This is great so far but I just need stderr from hscript (just in case it crashes:) and stdout (to keep a neat log file) This will need to work on *nix. I'm trying to move to python as our main scripting language so that we can reuse code and integrate a gui (tkinter) easily into our apps. If you're interested in what hscript is you can visit http://www.sidefx.com/ and check out houdini. thanks for any tips, =derek Monster By Mistake Inc > 'digital plumber' mailto:drek at monsterbymistake.com http://www.interlog.com/~drek "This mail was powered by Linux & Vim" From fredrik at pythonware.com Tue Nov 23 09:58:02 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 23 Nov 1999 15:58:02 +0100 Subject: Python books References: <199911230613.HAA21179@dionysus.fw.cuci.nl> <383A9EF4.5D1E8986@callware.com> Message-ID: <00a901bf35c3$2549ed80$f29b12c2@secret.pythonware.com> Ivan Van Laningham wrote: > If "Python Annotated Archives" is /F's book, it's already out as an > eMatter book. Visit www.python.org for details on how to get it. (or see below ;-) well, the eff-bot guide is definitely an annotated script collection, but I think Hans was referring to Martin Brown's upcoming pMatter book; here's fatbrain's description of it: http://www1.fatbrain.com/asp/BookInfo/BookInfo.asp?theisbn=0072121041&from=GTY867 in short: $50, 800 pages, available in december (a wild guess is that this book will feature less scripts and more annotations, but I haven't seen it. but I've heard rumours that it'll contain an eff-bot script or two...) From bwinton at tor.dhs.org Thu Nov 4 20:22:41 1999 From: bwinton at tor.dhs.org (Blake Winton) Date: Fri, 05 Nov 1999 01:22:41 GMT Subject: Apply a function to each list member? References: <816010E2456BD111A48700805FBBE2EEFDF6FC@ex-quebec-u1.baan.com> Message-ID: On Fri, 22 Oct 1999 07:52:15 -0400, Gaetan Corneau wrote: >I knew I had seen a function to do this somewhere, but I could not find it. >"map" is not an intuitive name for me (maybe it would if english was my main >language). Speaking as someone who's one language is English, "Probably not". "map" is really a Lisp/Scheme concept, and bears only a passing relationship to English. (Huh, what do ya know, looking up "map" on http://www.m-w.com/ reveals (in meaning 4) that "map" actually means "FUNCTION". I have no idea why they capitalized it.) >"Profanity is the one language all programmers know best" Well, okay, maybe two languages. ;) Later, Blake. -- One Will. One Dream. One Truth. One Destiny. One Love. From nemeth at iqsoft.hu Thu Nov 4 16:05:57 1999 From: nemeth at iqsoft.hu (Németh Miklós) Date: Thu, 04 Nov 1999 22:05:57 +0100 Subject: Extending Python dynamically References: <012801bf26fb$b8e0a4c0$1a25d2d1@jenkondev.com> Message-ID: <3821F535.D528D1BF@iqsoft.hu> Robin Dunn wrote: > > Thank you for your help. The method you suggested works perfectly! > > However, I do not understand completely how the Python interpreter finds > out > > that it has to load an so file. Normally -- I believed -- when Python sees > an > > "import xxx" statement it looks for a xxx.py, xxx.pyc or xxx.pyo file in > the > > $PYTHONPATH directories or an xxx subdirectory having an __init__.py file, > but > > not an xxx.so file. This means that if I add the current directory to the > > $PYTHONPATH (such as export PYTHONPATH='.' Python will find any arbitrary > so > > file in the $PWD? > > It will also load xxxmodule.so as well, but .so files only get imported if > they have an initxxx() function. > > -- > Robin Dunn > Software Craftsman > robin at AllDunn.com > http://AllDunn.com/robin/ > http://AllDunn.com/wxPython/ Check it out! Robin, you are a Genius! Neither the "Python Reference Manual Release 1.5.2's section 6.11 "The import statement" nor the Extending and Embedding the Python Interpreter documents explain this behaviour of the Python interpreter. That is why I felt myself a bit lost. But now with Your help, I feel I know "everithing" ;-) about Python extensibility. I am also very happy with this mailing list (another very good ones where I am a member are Qt's, LyX's, Apache-SSL's, etc lists). Within some hours I got all the support I needed -- no commercial mega-corporations are able to provide such a quality support even for tons of money. I remember when I spent three weeks with MS Visual J++ 6.0 and no one could answer my simplest questions: that was my last attemp to fight with a proprietary (especially MS) development tool. Thanks again! NM From wayne_strauss at mail.medscape.com Tue Nov 9 09:55:18 1999 From: wayne_strauss at mail.medscape.com (wayne_strauss at mail.medscape.com) Date: Tue, 09 Nov 1999 14:55:18 GMT Subject: Newbee WinNT ODBC Question Message-ID: <809ckk$vbf$1@nnrp1.deja.com> I've installed Python and Win32all.exe. When I run the following (only the first three lines shown): import dbi, odbc # ODBC modules import time # standard time module dbc = odbc.odbc('db/id/pw') I get: >>> Traceback (innermost last): File "d:\Program Files\Python\Pythonwin\pywin\framework\scriptutils.py", line 237, in RunScript exec codeObject in __main__.__dict__ File "D:\dev\Python\ODBC\odbc.py", line 1, in ? import dbi, odbc # ODBC modules File "odbc.py", line 4, in ? dbc = odbc.odbc('db/id/pw') TypeError: call of non-function (type module) If the import worked then why does the actual function call fail? Sent via Deja.com http://www.deja.com/ Before you buy. From justus at my-deja.com Mon Nov 29 15:34:37 1999 From: justus at my-deja.com (Justus Pendleton) Date: Mon, 29 Nov 1999 20:34:37 GMT Subject: predicate classes Message-ID: <81uo0t$2rr$1@nnrp1.deja.com> I decided to broaden my horizons so I was reading about/playing around with Cecil. One of the things Cecil has that I hadn't heard of before are predicate classes (http://www.cs.washington.edu/research/projects/cecil/cecil/www/www/Papers/pr edicate-classes.html), which I thought were nifty beyond all belief. I also thought it would be nifty if Python had them so I got the source from the CVS respository and started hacking the grammar and realized I had no idea what I was doing :-). Before getting in any deeper in something I only vaguely understand I thought I would ask the opinions of people who know more about Python than I whether they think it would be easy/hard/well-damn-nigh-impossible to add this kind of dynamic retyping of objects based on predicates. (I did a quick search on deja and didn't find any talk about this, so apologies in advance if this is something that has been as talked to death as the indentation thing.) Sent via Deja.com http://www.deja.com/ Before you buy. From jblazi at netsurf.de Tue Nov 16 09:10:37 1999 From: jblazi at netsurf.de (Janos Blazi) Date: Tue, 16 Nov 1999 15:10:37 +0100 Subject: Beginning programming with Python References: <382B3A53.5816B2@callware.com> <382B3D79.74CD3E0F@email.sps.mot.com> <80p9ds$ppo$1@newshost.accu.uu.nl> <38317787.19AFDAF5@compaq.com> Message-ID: I agree with that. Janos B. Greg Ewing schrieb in im Newsbeitrag: 38317787.19AFDAF5 at compaq.com... > Janos Blazi wrote: > > > > the indenting this time? There is actually nothing else you can forget in > > Python. > > Well, not quite - you can forget the "self" in method > declarations fairly easily... > > Greg From emile at fenx.com Thu Nov 4 09:52:11 1999 From: emile at fenx.com (Emile van Sebille) Date: Thu, 4 Nov 1999 06:52:11 -0800 Subject: __str__ vs. __repr__ References: <000401bf25b9$88ea57e0$2e2d153f@tim> <199911040157.UAA11908@eric.cnri.reston.va.us> Message-ID: <046101bf26d4$2dd1a720$01ffffc0@worldnet.att.net> ----- Original Message ----- From: Guido van Rossum To: Tim Peters Cc: Sent: Wednesday, November 03, 1999 5:57 PM Subject: Re: __str__ vs. __repr__ > Any suggestions? > > --Guido van Rossum (home page: http://www.python.org/~guido/) It seems to me that issues arise when using the interactive interpreter. I suspect that little useful work is done in this mode, and is used predominately for quick testing while creating python programs. Also, as entering a value without the print is a shortcut/convenience used during testing, why not supply even more information? Supply the class, type, lengths, indexes, nested, pretty-printed, etc. Use the repr and str if it helps. Interactive mode is for learning, testing, and experimenting. Let it be of as much help as possible. I-type-print-so-fast-sometimes-it-comes-out-printprint-ly yr's Emile van Sebille emile at fenx.com ------------------- From gmcm at hypernet.com Mon Nov 29 12:55:35 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Mon, 29 Nov 1999 12:55:35 -0500 Subject: Access violation while trying to replace stdout with a local disk file In-Reply-To: <81udcl$nm3$1@news1.sinica.edu.tw> Message-ID: <1268224356-30441862@hypernet.com> SINICA writes: > > I'm trying to redirect the output of Python into a external > diskfile since my program and python interpretor are two > different processes (python15.dll and myprog.exe) > PyObject_Print() will cause a "Access Violation" while trying to > print on the file handle which is created by myprog.exe > > any suggestion will be greatly appreciated. They both need to be linked to the same c-runtime library, (ie, "Multithreaded DLL" in Settings | Compile | Code Generation). - Gordon From herzog at online.de Fri Nov 5 06:53:51 1999 From: herzog at online.de (Bernhard Herzog) Date: 05 Nov 1999 12:53:51 +0100 Subject: __str__ vs. __repr__ References: <000401bf25b9$88ea57e0$2e2d153f@tim> <199911040157.UAA11908@eric.cnri.reston.va.us> <5logd98v8z.fsf@eric.cnri.reston.va.us> Message-ID: Guido van Rossum writes: > Bernhard Herzog writes: > > > How about a hook function a la __import__? I.e. have a function > > __format__ [1] in __builtin__ that is bound to repr by default. Whenever > > Python prints the result of an expression in interactive mode, it calls > > __format__ with the result as parameter and expects it to return a > > string ready for printing. > > Brilliant! Glad you like it! > The default function could do all the current built-in > magic -- print nothing if it's None, assign it to builtin _, and so > on. It seems to me that assigning to _ and printing the result are two separate things. IMO, the hook function should only do the formatting, the assignment could still be hardwired in the interpreter loop. Pseudo code: while 1: statement = read_statement() if not statement: break result = run_statement(statement) __builtin__._ = result if result is not None: print __format__(result) > I wonder if it would have to have a __magic__ name? It could be > called display and it could be documented and usable in > non-interactive programs as well. Or am I getting carried away? > (Possibly the habit if assigning to _ and suppressing None would make > the default display() function a bit clumsy to use.) Well, I chose a magic name because it's called in special circumstances. Calling it display is fine with me, especially if it really does only formatting and no assignment to _ and no special-casing of None, as is assumed in my pseudo code above. Such a version of display would also be usable in non-interactive programs. One could take this even further by moving the entire interactive mode to a python module. Most of the python code for that is already available in the code.py module, IIRC. -- Bernhard Herzog | Sketch, a drawing program for Unix herzog at online.de | http://www.online.de/home/sketch/ From kelley at bioreason.com Tue Nov 2 13:55:11 1999 From: kelley at bioreason.com (Brian Kelley) Date: Tue, 02 Nov 1999 11:55:11 -0700 Subject: cStringIO versus StringIO: "readlines" Message-ID: <381F338E.D3D2E748@bioreason.com> I noticed that StringIO has a "readlines" member function and cStringIO doesn't. Is anyone planning on adding this in the near future? I was wondering if I should go ahead and do it or if there is against. The cStringIO documentation just says "provides an interface similar to StringIO" and StringIO says "see the description on file objects." Needless to say, I use readlines() quite a bit. -- Brian Kelley w 505 995-8188 Bioreason, Inc f 505 995-8186 309 Johnson Av Santa Fe, NM 87501 kelley at bioreason.com From junkster at nospam.rochester.rr.com Thu Nov 25 20:53:34 1999 From: junkster at nospam.rochester.rr.com (Benjamin Schollnick) Date: Fri, 26 Nov 1999 01:53:34 GMT Subject: Journaling Code References: <81k6m9$gkm$1@newsie2.cent.net> <19991125174544.A1164@better.net> Message-ID: On Thu, 25 Nov 1999 22:45:44, William Park wrote: > Not coming from 3D rendering background... but, wouldn't it be easier > to have your modeller produce "log" file of anything coming in? Honestly, IMHO, a log file (for that use) is basically a "poorman's" journal. - Benjamin ==================================================== (Remove "NoSpam" to Email me) ==================================================== Please feel free to copy any and or all of this sig. A little something for spam bots: root at localhost postmaster at localhost admin at localhost abuse at localhost postmaster at 127.0.0.1 Chairman William Kennard: bkennard at fcc.gov Commissioner Susan Ness: sness at fcc.gov Commissioner Harold Furchtgott-Roth: hfurchtg at fcc.gov Commissioner Michael Powell: mpowell at fcc.gov Commissioner Gloria Tristani: gtristan at fcc.gov consumerline at ftc.gov fccinfo at fcc.gov ssegal at fcc.gov From volumeregeling at hotmail.com Mon Nov 29 12:53:45 1999 From: volumeregeling at hotmail.com (volumeregeling) Date: Mon, 29 Nov 1999 17:53:45 GMT Subject: Need help with html files Message-ID: <3842bd0e.23017938@122.0.0.250> hi, i would like to open a local html file from within python, When the html is opened, it should be opened like if you double click on the filename, so it uses the know filetype from windows. in short , when someone has netscape as the default browser. I open the html file python should call the html file , and windows opens the default browser with the file as argument. I hope this is clear enough, at the moment i can?t think of a way to explain it differently. if you know what i mean and if you have a solution for my problem please post or mail. thanks From tim_one at email.msn.com Fri Nov 26 21:32:46 1999 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 26 Nov 1999 21:32:46 -0500 Subject: python test frameworks In-Reply-To: Message-ID: <000401bf387f$b12d47c0$742d153f@tim> [Quinn Dunkan] > ... > I'm looking for some information on techniques for self-testing > pyhon code (something I should have been doing before, but only > now am I writing a system complex enough to warrant it). I would have thought you had written at least one function before now <0.9 wink>. > I remember Tim's thread about his doc-string embedded testing, and > that looked interesting, but I can't find it now. http://www.python.org/ftp/python/contrib/System/doctest.README if-it's-not-tested-it's-broken-ly y'rs - tim From af137 at torfree.net Sun Nov 28 05:16:02 1999 From: af137 at torfree.net (Al Aab) Date: Sun, 28 Nov 1999 10:16:02 GMT Subject: Python complaints References: <38397696@news.xtml.co.uk> <221119992150405215%zippy@cs.brandeis.edu> <383a8909@news.xtml.co.uk> Message-ID: some text editors take care/ease LISP perens pain. emacs is one. over a decade ago there was a lisp written for TOPS10 os; its editor used to close the remaining parens for u (just hit ESC ESC) was really neat. even emacs cannot do that, unless u program it in emacs lisp. -- =-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- al aab, ex seders moderator sed u soon it is not zat we do not see the s o l u t i o n -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+ From tim_one at email.msn.com Wed Nov 24 16:00:31 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 24 Nov 1999 16:00:31 -0500 Subject: Python complaints In-Reply-To: <005201bf367e$4901fef0$f29b12c2@secret.pythonware.com> Message-ID: <000601bf36be$f1bf5e80$292d153f@tim> [Thomas Hamelryck] > I don't want to start the discussion about indentation again; Heh heh -- good one. > it's no use since indenting blocks is here to stay. The point is that > if you want to write code that looks ugly or unreadable you will > succeed in doing that, indentation or not. In many cases, using a > variable indentation (depending on what construct you are using or > the length of a line) leads to code that is visuably much more appealing. [/F] > you make that sound like a scientific fact. can > you point us to some research, or is it just yet > another random opinion? I suspect Thomas has the same problem with citing research as I have: my software imposes a 2Mb limit on msgs I can post . There is one (& only one) area where Python's indentation gets in my way a bit: conceptual blocks that can't be written as blocks. These typically occur when toggling a mode or flag of some sort, like mutex.acquire() do stuff mutex.release() or myIEEEstuff.set_rounding_mode(CHOP) do stuff myIEEEstuff.restore_rounding_mode() In C++ it's idiomatic to write a class that sets the mode in the constructor and restores it in the destructor, then just declare a temp object of that class in a new block; e.g., { CriticalSection guardme; // ctor acquires, dtor releases do stuff } // the language guarantees the dtor has been called at this point This is very powerful, and the "extra" indentation is helpful in pointing out that something odd is going on. Alas, mutex.acquire() do stuff mutex.release() is a syntax error in Python. The closest I can get is mutex.acquire() try: do stuff finally: mutex.release() which is exactly the semantics I want, but if "do stuff" is more than a couple of lines strains my pattern-recognition wetware. Fortunately, this is so infrequent an irritation that I won't even mention it. not-responding-to-a-discussion-that-never-started-ly y'rs - tim From akuchlin at mems-exchange.org Tue Nov 30 14:36:34 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 30 Nov 1999 14:36:34 -0500 Subject: XML tool status? References: Message-ID: <3dhfi3hiv1.fsf@amarok.cnri.reston.va.us> "Greg Wilson" writes: > 2) the Python XML SIG status page has a "most recent update" date from > December 1998 --- is that fossilware, or has there really not been anything > new posted since then? The code's been developed subsequently, and the CVS tree is much more recent. I've simply been remiss in updating the Web pages (and in getting a 0.5.2 release out). -- A.M. Kuchling http://starship.python.net/crew/amk/ Where is human nature so weak as in the bookstore? -- Henry Ward Beecher From mwh21 at cam.ac.uk Mon Nov 8 14:39:38 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 08 Nov 1999 19:39:38 +0000 Subject: pythonistas or pythoneers? References: <8076ed$d2n$1@nnrp1.deja.com> Message-ID: init__self at my-deja.com writes: > > So pythonistas sounds extremely powerfull, because python can > > be spelled in Spanish as "piton", that means "horn" ( like the bull's > > horns). So pythonistas sounds like the "damned crazy followers > > of the horns" :DD > > So instead of those masturbatory "Just another you-know-what hacker" > .sig's, one could have > > #!/usr/local/bin/python > print "Just another damn crazy follower of the horns." > > as a fine .sig :-) It conveys succinctly the readability and simplicity > of the language! I *like* that! Or maybe: #!/usr/local/bin/python print "I can read what I write" print "I can even read what you write" though that might be considered offensive in some circles... Regards, Michael From sai at sw.ods.com Wed Nov 10 10:54:10 1999 From: sai at sw.ods.com (Sai Ramanath) Date: Wed, 10 Nov 1999 09:54:10 -0600 Subject: Exceptions: ^z Message-ID: <38299522.5D06E8D5@sw.ods.com> Is there a way to catch Ctrl-Z which in UNIX lets the user suspend the Python shell into background? I know we can catch Ctrl-C and Ctrl-D using KeyboardInterrupt and EOFError respectively. Thanks, Sai -------------- next part -------------- A non-text attachment was scrubbed... Name: sai.vcf Type: text/x-vcard Size: 362 bytes Desc: Card for Sai Ramanath URL: From emil at imf.au.dk Mon Nov 8 10:16:25 1999 From: emil at imf.au.dk (Emil Hedevang Lohse) Date: Mon, 08 Nov 1999 16:16:25 +0100 Subject: Graphics. Message-ID: <3826E949.BBA1BAFD@imf.au.dk> How do I draw some graphics on a screen using Python running on HP-UX MacOS Windows ??? >From Emil emil at imf.au.dk From g_will at cyberus.ca Mon Nov 15 15:22:16 1999 From: g_will at cyberus.ca (Gordon Williams) Date: Mon, 15 Nov 1999 20:22:16 GMT Subject: Line Benchmarks Tkinter vs. wxPython Message-ID: <01bf2fa7$02992ca0$8a42c3d1@Cyberus.cyberus.ca> Hello All, I have done some benchmark testing to see the difference in speed between plotting multi point lines using Tkinter and wxPython. I have looked at 3 different methods for doing it in Tk and 2 different methods in wx. The differences are astounding for the 1000 to 10000 point lines that I examined. Generally, wx was found to be in the order of 200 to 1800 times faster than the standard Tkinter. Tk can be sped up by ten to 50 times by changing Tkinter so it bypasses the _flatten method or by making the Tk calls directly. A repeating sine wave was created and put into a horizontal scrollable window of about 500 points wide and 300 points high. These are the results for the line plotting time only. Time in Seconds on a P166 with 96MB RAM. Points Tkinter Tkinter Tkinter wxPython wxPython (standard) (mod 1) (mod 2) (direct draw) (bitmap) 1000 1.190 0.192 .202 0.007 0.026 2000 4.406 0.385 -- 0.014 0.042 5000 25.170 0.967 -- 0.027 0.080 10000 100.260 1.941 2.064 0.054 0.148 Notes: 1) Tk standard is the standard usage with no modifications. 2) Tk mod 1 has Tkinter modified so a flat tuple of points is passed to create_line and _flatten is by-passed. 3) Tk mod 2 used the apply method e.g. apply(self.can.tk.call,(self.can._w,'create','line') + points + ('-width',1,'-fill',colour,'-tags',"tag")) 4) wx direct draw draws to the window directly. 5) wx bitmap draws to a bitmap and then blit Conclusions: 1) The time to plot lines using the standard Tkinter is quadratic with the number of points (ugh!). This is due to the time spent in _flatten. _flatten is very versatile but agonizingly slow for large numbers of lines. 2) Tkinter mod 1 and 2 give the same results. Times are linear with the number of points plotted as both cases dont use the _flatten method. This means that a flat tuple of points has to be used (a small constraint). The speed increase in doing this is from 10 to 50 times over the standard. 3) wxPython beats Tk by a very! large margin even when Tk is called directly. Direct drawing onto to screen is roughly 3 times faster than using a bitmap. Thanks to: Greg Landrum for providing some information on direct calls to tk. Ionel Simionescu for providing the wxPython code which I was able to modify. From phd at phd.russ.ru Fri Nov 19 08:28:57 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Fri, 19 Nov 1999 13:28:57 +0000 (GMT) Subject: urllib.getsize() In-Reply-To: <19991119133404.A3308@optiplex.palga.uucp> Message-ID: On Fri, 19 Nov 1999, Gerrit Holl wrote: > Another problem: does every HTTP server give the Content-Length header? Certainly NO. Most CGIs do not set the header. Often server-side includes loose the header. Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From greg.ewing at compaq.com Fri Nov 19 10:27:48 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Sat, 20 Nov 1999 04:27:48 +1300 Subject: Type/Class Unification in Ruby References: <3819BCDA.AC4FD4CA@strs.co.uk> <87k8o2x67f.fsf@ev.netlab.co.jp> <7vjtrc$hmm$1@newshost.accu.uu.nl> <38204614.2EAC6051@compaq.com> <5ld7trtak5.fsf@eric.cnri.reston.va.us> <3826D63C.2731BB1F@compaq.com> <38328948.9E35556F@compaq.com> Message-ID: <38356C74.F9E4248D@compaq.com> Clemens Hintze wrote: > > But it is worth mentioning, that Ruby features > single inheritance *by*purpose*. Not because of the implementation > details! I wasn't making a value judgement, only pointing out that Ruby's solution is as simple as it is because of this restriction. > If it would implement multi-inheritance, the class structure could > e.g. use an array of pointer to all such C structs, not only one > pointer, as implemented now! Sure, Python could do something like that too. But it would get very hairy and complicated and probably slow everything down a lot, casting doubt on whether it's worth the effort. A middle ground might be to allow inheriting from any number of user-defined classes, but at most one built-in type. > The second (preferred) way is, to build instances of class DATA > wrapping the C struct you have allocated for your extension. Yes, I know, but what I was saying still applies in that case. All the methods of the extension class expect the DATA object to be pointing to their own particular kind of struct, and because of the inheritance structure, this is always true -- so they don't need to bother checking. > Deriving a Ruby class coded in C from another one also coded in C, > seems to be the only right tricky part of that language, IMHO. :-) I think it will work as long as the derived class makes sure that its C structure is an exension of the superclass's C structure. > Greg> [global instance var dict] might cause ref counting > Greg> problems. > > Once again, thanks for Ruby's true garbage collection! :-) Garbage collection alone doesn't actually solve the problem; the references from the global dict need to be treated as weak references somehow under either scheme. I haven't looked, but presumably Ruby must be ignoring the global dict refs when marking, and cleaning them up whenever a builtin or extension object is deallocated. Python could be made to do the equivalent. > The big exception, > AFAIK, was class Fixnum. It never had any instanciation method, as it > doesn't wrap any struct. Yes, that's the one class you really can't instantiate a subclass of, since its class is totally implicit. But it's not clear whether it's any use having something like a UserFlonum, either, even though technically it could be done. Unless you override every method, any arithmetic on it would return an ordinary Flonum. And if you are going to override every method, it might as well be a totally new class! > Often it is better to use the module > mechanism to add methods to class Array or some of its instances > during runtime. You mean you can add methods to an *existing* class that way? Not sure if I like that idea... Greg From alan.gauld at gssec.bt.co.uk Mon Nov 29 12:49:24 1999 From: alan.gauld at gssec.bt.co.uk (Alan Gauld) Date: Mon, 29 Nov 1999 17:49:24 +0000 Subject: yet 'nother newbie question References: <3840300F.66DC46DD@wjk.mv.com> Message-ID: <3842BCA4.51B15166@gssec.bt.co.uk> William J. King wrote: > When passing an argument to a function etc. -- how does one determine > that it is > an integer that is being passed and not a string for example... Another poster answered this. However be careful that your not trying to use Python like C++ Static typing is useful in C++ but dynamic typing is much better for Python's typical applications. More flexible and faster to develop. Rather than using try/except to test types use it to catch the few occasions when a bad typ[e is passed. Your fellow programmers are not totally stupid and will by and large try to pass the right thing. If you catch the errors it usually works... If you do need to check the type then type() is your friend. Alan G. -- ================================================= This post represents the views of the author and does not necessarily accurately represent the views of BT. From a.eyre at optichrome.com Wed Nov 24 04:33:38 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Wed, 24 Nov 1999 09:33:38 -0000 Subject: Embedding: Getting the module from a PyObject * In-Reply-To: Message-ID: <002a01bf365e$fcc3cf60$3acbd9c2@peridot.optichrome.com> > can anyone tell me how to get the module object that a certain instance's > class is defined in, from that instance? Assuming: class Spam: pass s = Spam() Then: s.__class__ returns class Spam Spam.__module__ or s.__class__.__module__ returns the module it was defined in -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From stuart.hungerford at webone.com.au Wed Nov 3 03:15:12 1999 From: stuart.hungerford at webone.com.au (Stuart Hungerford) Date: Wed, 03 Nov 1999 19:15:12 +1100 Subject: How can I make my assertions smarter? References: <000601bf25be$0cdeb880$2e2d153f@tim> Message-ID: <381FEF10.3B27C05B@webone.com.au> Tim Peters wrote: > [Stuart Hungerford, desperately hoping that design by contract will > be easier in Python if he calls it by some other name ...] I'd kind of given up on true DBC, and just went with loads of asserts as ersatz pre and postconditions. When I find myself calling the same construct hundreds of times, I can't help but feeling I may be able to do things either more conveniently, more flexibly or with more value added. Hence my question. > > I'm using some simple functions to implement crude precondition, > > postcondition and invariant checking in Python classes. > > > > (Tim: please be gentle ;-) > > I am always gentle with you, Stuart! Your heart is in the right place -- > although it may as well be firmly stuck up your ass for all the good it's > doing you . This must be the Python equivalent of "tough love" ;-) Top of my new years resolutions list is not to post any more DBC in Python questions. Thanks to everyone who responded to this question -- I've learnt some interesting and useful techniques in the process. Ciao Stu From ajung at sz-sb.de Tue Nov 16 01:19:38 1999 From: ajung at sz-sb.de (Andreas Jung) Date: Tue, 16 Nov 1999 07:19:38 +0100 Subject: list.without()? In-Reply-To: ; from mlh@vier.idi.ntnu.no on Tue, Nov 16, 1999 at 01:03:44AM +0100 References: Message-ID: <19991116071937.A23463@sz-sb.de> On Tue, Nov 16, 1999 at 01:03:44AM +0100, Magnus L. Hetland wrote: > > Hi! > > Is there a function or method in the standard language that can > non-destructively return a list without a specified element? Would it > be possible to add it as a method to lists? mylist = filter(lambda x: x != ItemToRemove , mylist) or something similar .... From mwh21 at cam.ac.uk Mon Nov 15 14:35:29 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 15 Nov 1999 19:35:29 +0000 Subject: exec/eval changed? References: <942690155.686795566@news.glph1.on.wave.home.com> Message-ID: JB writes: > Did the exec/eval statements change somehow in the 1.5 versions? I > have a script that did an eval( "some code", dict1, locals()) but > now it doesn't work. I've looked through the doc's but they are > little thin as to these statements. Any help is appreciated. Well, eval("some code") is a syntax error. What are you trying to to do? We can't read minds here. Regards, Michael From fredrik at pythonware.com Wed Nov 17 08:00:03 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 17 Nov 1999 14:00:03 +0100 Subject: Need help dealing with spaces in NT paths. References: <80pr76$jq5$1@nnrp1.deja.com> <11f733ec.96958819@usw-ex0101-007.remarq.com> <80sj4q$l7t$1@nnrp1.deja.com> <80tgi8$hbn$1@ssauraaa-i-1.production.compuserve.com> <002501bf30e8$a41a5bc0$f29b12c2@secret.pythonware.com> <001301bf30f8$fa61cf80$224dc0d8@josefbet> Message-ID: <007301bf30fb$aa921c50$f29b12c2@secret.pythonware.com> > >>> os.system('dir "program files"') > > Volume in drive C is CDRIVE > Volume Serial Number is 2E50-0FE9 > Directory of C:\WINDOWS are you sure you have a "program files" directory in your "windows" directory? it's usually placed under the root directory... From kyriacou at umbc.edu Wed Nov 24 14:33:57 1999 From: kyriacou at umbc.edu (Stelios Kyriacou) Date: 24 Nov 1999 14:33:57 -0500 Subject: More problems with random seed (was Re: whrandom seed question) References: <81eu22$411al$1@umbc7.umbc.edu> Message-ID: <81hej5$3tmv0$1@umbc7.umbc.edu> Thanks both for your correct answer. Unfortunately I hate to say but my ultimate question (which I never mentioned :) ) is unanswered. Why when I call the gauss distribution I get 2 alternating values: >>> random.seed(0); print random.gauss(0,1); 2.11224018067 >>> random.seed(0); print random.gauss(0,1); 0.225551631579 >>> random.seed(0); print random.gauss(0,1); 2.11224018067 >>> random.seed(0); print random.gauss(0,1); 0.225551631579 >>> random.seed(0); print random.gauss(0,1); 2.11224018067 >>> Any more ideas? Stelios From bmcd at es.co.nz Tue Nov 23 15:49:23 1999 From: bmcd at es.co.nz (Ben Caradoc-Davies) Date: 23 Nov 1999 20:49:23 GMT Subject: Method objects question References: <383a7309@news.uni-bielefeld.de> <81eha1$rf6$1@nntp6.u.washington.edu> Message-ID: On 23 Nov 1999 17:01:53 GMT, Donn Cave wrote: >It doesn't seem to matter where a function is defined, only the scope >where it's found. The normal and most convenient way to get a function >into the class name space is certainly to define it there, but any other >way will serve as well - it doesn't matter if you define it outside the >class, or inside. >How could we justify anything different, in a dynamic "run time" system >like Python? Sure, the class behavious is excellent. But the point is, why should functions found in a class namespace be converted into methods, but functions found in an instance namespace not converted? For example, suppose you have a running application containing two instances of the same class. You need to patch your application on the fly, performing *different* modifications on each object. You send a signal to your application, and when it is next idle it execfiles your patch script. This script can modify each instance's variables, rebinding them to entirely new objects. In particular, it is possible to hide class variables by adding instance variables of the same name. However, with the current behaviour, it is not possible to bind instance variables to function objects and override class variables with the same name (bound to function objects) without changing any other code, because the rest of the program will expect these instance atributes to be *method objects*, not ordinary function objects. It is only possible to change the class variable, and thus change the behaviour of *all* instances of that class. In a nutshell, I don't see any fundamental reason why the search-instance-namespace then search-class-namespace attribute resolution order couldn't be used to allow method overriding on an instance-by-instance basis. With the current, function-to-method conversion rules, this is impossible. Actually, I'm more curious about why this design decision was made. (Or did it just happen that way!) -- Ben Caradoc-Davies From Vladimir.Marangozov at inrialpes.fr Mon Nov 29 01:17:08 1999 From: Vladimir.Marangozov at inrialpes.fr (Vladimir Marangozov) Date: Mon, 29 Nov 1999 07:17:08 +0100 Subject: AIX Py compiling errors? References: <81r96t$meq$1@nnrp1.deja.com> Message-ID: <38421A64.6A7001E2@inrialpes.fr> moonseeker at my-deja.com wrote: > > Hi! > > Anyone using Python on AIX here? I tried to compile Python on my AIX 4.1.5 > box using the IBM compiler but I get an error (or warning): > > cc_r -O -qmaxmem=4000 -I./../Include -I.. -DHAVE_CONFIG_H -c > ./socketmodule.c "./socketmodule.c", line 1127.22: 1506-280 (W) Function > argument assignment between types "struct sockaddr*" and "unsigned char*" is > not allowed. > > Anyone a suggestion? A warning. It doesn't hurt. -- Vladimir MARANGOZOV | Vladimir.Marangozov at inrialpes.fr http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252 From andres at corrada.com Sun Nov 21 10:28:18 1999 From: andres at corrada.com (Andres Corrada) Date: Sun, 21 Nov 1999 10:28:18 -0500 Subject: Order of keyword arguments References: <38379233.ADE65CDB@corrada.com> <19991121034245.A21255@quark.emich.edu> Message-ID: <38380F92.D9817451@corrada.com> Jeff wrote: > > keyword arguments are passed as a dictionary, and thus the 'order' of the > arguments will not be preserved. what is the advantage you see to being able > to obtain that information? wouldn't a redesign of the interface keep things > simpler and increase the likelihood of success? > I want to have my cake and eat it too! I thought this would be a way of keeping the flexibity of keyword arguments but also pass information along on how the calling function wants the items returned. For example, an HTML form could be called with a variable number of input tags and you want to render the HTML in the same order that they were used to call the function. ------------------------------------------------------ Andres Corrada-Emmanuel Email: andres at corrada.com Owner http://www.corrada.com/mamey Mamey Phone: (413) 587-9595 ------------------------------------------------------ From mwh21 at cam.ac.uk Fri Nov 26 08:49:11 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 26 Nov 1999 13:49:11 +0000 Subject: dynamic modules? References: <000101bf37fe$94dac790$3acbd9c2@peridot.optichrome.com> Message-ID: "Adrian Eyre" writes: > > Is there a chance to write modules I can dynamically change? I tried > > reload(), but thats not working because I can't reload modules imported > > with 'from XXX import *'. > > # Reload any/all modules (N.B. untested) > import sys > > def reloadAll(): > for mod in sys.modules.keys(): > reloadModule(mod) > > def reloadModule(name): > reload(sys.modules[name]) equivalently: def reloadAll(): for mod in sys.modules.values(): reload(mod) Doesn't cope with "from <...> import *" though; another reason not to use that construct. Cheers, Michael From gmcm at hypernet.com Sat Nov 6 13:35:47 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Sat, 6 Nov 1999 13:35:47 -0500 Subject: type object of an instance without instantiation? In-Reply-To: Message-ID: <1270209153-4344294@hypernet.com> claudius writes: > I have the following code (well, in summary): > > class BigClass: > def __init__(self): > ...does some horrifyingly nasty operation... > > def some_generic_fn(object): > if hasattr(object, '__class__') and object.__class__ == > BigClass: > ...do some BigClass-specific thing... > > Is there a way to create a type object for the instance of a > BigClass object without actually creating an instance of one? The type object of an instance (any instance) is the one and only InstanceType object. The type of object of a class (any class) is the one and only ClassType object. I think you mean the BigClass class object. This exists as soon as the "class" statement is executed. When you create an instance of BigClass, you are "calling" the BigClass class object. BTW, while doing lots of stuff in the constructor is often a valuable technique in other languages, it is much less so in Python. It makes things like pickling a lot harder (unless you provide default args and alternate ways to get the work done). That doesn't mean it's *always* bad, just that it reduces your flexibility. - Gordon From kain at twilight. Wed Nov 3 20:47:27 1999 From: kain at twilight. (Scott Barron) Date: 4 Nov 1999 01:47:27 GMT Subject: SWIG and function name question References: <7vmc7e$8h$1@marcie.fissiontech.com> Message-ID: <7vqojf$bgf$1@marcie.fissiontech.com> Hi, How about this: Given these two files, ## foo.py def __foo(): print "Foo" def bar(): print "Bar" ## bar.py import foo class Foo: self.f = foo.__foo # Create an alias for foo.__foo self.b = foo.bar # Create an alias for foo.bar >>> import bar Traceback (innermost last): File "", line 1, in ? File "bar.py", line 3, in ? class Foo: File "bar.py", line 4, in Foo self.f = foo.__foo AttributeError: _Foo__foo If I comment out self.f = foo.__foo all works fine. What am I doing wrong here? Thanks, Scott In article , Michael Hudson wrote: >kain at twilight. (Scott Barron) writes: > > >It's nothing to do with SWIG; try this for size: > >put this in a file called foo.py on your PYTHONPATH: > > >HTH, >Michael > >O, look: http://www.python.org/doc/current/ref/import.html has all the >gory details... From mwh21 at cam.ac.uk Fri Nov 5 10:15:58 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 05 Nov 1999 15:15:58 +0000 Subject: [OFFTOPIC] Maps and functions (was Re: Apply a function to each list member?) References: <19991105215504.A497@Ridcully.home> <14370.53219.667492.946075@gargle.gargle.HOWL> <27NwjKAK1uI4EwdJ@jessikat.demon.co.uk> Message-ID: Robin Becker writes: > In article <14370.53219.667492.946075 at gargle.gargle.HOWL>, Charles G > Waldman writes [snip] > >Hmm... what kind of "map" are you thinking of that could send 2 to > >"both 3 and 4"? I think such a thing is not a mapping, at least not > >according to any definition of "map" that I've ever seen. If you > >look, for instance, in any basic topology text, you will see that > >"map" and "function" mean exactly the same thing, when used as nouns. > >"Map" also has a sense as a transitive verb, which means "to apply a > >function to", which is where the Python/functional programming usage > >comes from. > > > > > > > I define f as a thing which takes integer arguments and outputs sets of > integers > > presumably I can have such an f that > > f(2)={3,4} > > to my simple engineer's eyes f could belong to the functions mapping Z-- > >2^Z > > I assume we're not talking that way if the f above isn't a function. f is a function, as you say from Z to 2^Z. A difference between that and a function from Z to Z, is that this f throws away a lot of the algebraic structure of Z (i.e. being a uniquely generated commutative ring), and so is in many ways less interesting than a function that preserves this structure. Regards, Michael From phd at phd.russ.ru Fri Nov 19 03:50:23 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Fri, 19 Nov 1999 08:50:23 +0000 (GMT) Subject: urllib.getsize() In-Reply-To: <14388.29839.294164.707388@dolphin.mojam.com> Message-ID: On Thu, 18 Nov 1999, Skip Montanaro wrote: > Gerrit> I've written a function to get the size of a HTTP/FTP url, is it > Gerrit> good enough to be put in urllib.py? > > My only worry is that HEAD doesn't always work (for whatever reason having > to do more with servers than clients). Would it be better to wrap things in > a try/except block? Anyone have a URL that fails with HEAD? What is worse, not every server returns Content-Length. I wrote many CGIs that didn't :) Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From kuncej.CENTRAL2.MDCEMAIL at mail.conservation.state.mo.us Fri Nov 19 12:50:24 1999 From: kuncej.CENTRAL2.MDCEMAIL at mail.conservation.state.mo.us (Jeffrey Kunce) Date: Fri, 19 Nov 1999 11:50:24 -0600 Subject: Batch window Message-ID: >Is it posible to automaticaly minimize the python window, when starting >a GUI application on Windows ? As others have answered, pythonw.exe will run a python program with *no* python window. If you actually want a minimized python window to be present, use something like: START /MIN python.exe myprog.py Sometimes the python window is useful for debugging, or as a log window. --Jeff From Markus_Strickler at everest-design.de Thu Nov 11 11:56:07 1999 From: Markus_Strickler at everest-design.de (Markus Strickler) Date: Thu, 11 Nov 1999 17:56:07 +0100 Subject: AW: Python 1.5.2 on NeXTStep In-Reply-To: <199911111629.AA23443@ch1d2833nwk> Message-ID: <002901bf2c65$a5edb000$2d131bc3@everestdesign.com> Hi! Thanks for your reply. I would appreciate any help I can get. So if you could send me your modfied sources or whatever you have that would be great. Thanks again, Markus Strickler > -----Urspr?ngliche Nachricht----- > Von: Ted Horst [mailto:Ted.Horst at wdr.com] > Gesendet am: Donnerstag, 11. November 1999 17:30 > An: Markus Strickler > Betreff: Re: Python 1.5.2 on NeXTStep > > > I have compiled 1.5.2 on our systems which are 4.2 with 3.3 developer (I > think this is the same as compiling on 3.3). Unfortunately, I > had to change > some of the source, and I never got around to making good diffs. I can > send you what I have if you want. > > On Thu, 11 Nov 1999, "Markus Strickler" wrote: > > Hi! > > Has anyone managed to compile Python 1.5.2 on NeXTStep 3.3? I'm > currently > > running an older Python version and would like to upgrade. However 1.5.2 > > won't compile. Can anyone give me start what config parameters I need. > > > > Thanks, > > > > Markus > > > > > > -- > > ----------------------------- > Ted Horst > "the day serious reasoning about programs becomes widespread is the day > most programmers abandon their craft to resume drug trafficking ." > --Tim Peters on comp.lang.python > From gmcm at hypernet.com Mon Nov 15 11:33:49 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Mon, 15 Nov 1999 11:33:49 -0500 Subject: win32api... another question: GetEnvironmentVariable("PATH") In-Reply-To: Message-ID: <1269438868-3874906@hypernet.com> Kevin Cazabon wrote: > Interesting... it doesn't work on Win98 for me (The exact statement > below...). > > Anyone have suggestions for Win95/98? > > > Kiss, Arpad wrote in message > news:01BF2F61.1D2B8DB0 at exchange1.geometria.hu... > > Hi, > > > > Kevin Cazabon wrote in message > > news:... > > > I can't seem to get the win32api.GetEnvironmentVariable() function to > > work > > > properly... am I not using it correctly by the following? > > > > > > path = win32api.GetEnvironmentVariable("PATH") > > > > It works for me on a Windows NT Workstation (sp5). First, why not use os.environ['PATH']? Second, while I'm on NT and 'PATH' and 'path' return the same answer (both the os and the win32api way), I had a bug report from someone on Win9x and the solution turned out to be: try: value = os.environ[key] except KeyError: value = os.environ[string.lower(key)] - Gordon From gmcm at hypernet.com Mon Nov 1 07:24:47 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Mon, 1 Nov 1999 07:24:47 -0500 Subject: os.popen() and (IDLE, PythonWin) ? In-Reply-To: <381D63CA.9073803D@lemburg.com> Message-ID: <1270664157-24361801@hypernet.com> Marc-Andre wrote: > "M.-A. Lemburg" wrote: > > > > [os.popen('ver') fails under IDLE and PythonWin, yet works > > under "normal" > > Python] > > Ok, I found the FAQ entry on this: > > 7.13. Why doesn't os.popen() work in PythonWin on NT? [snip] > Under PythonWin this is no problem (although I wish os.popen > would automatically choose the different approach for me in the > above setup). Yet under IDLE I have a problem: win32 doesn't have > to be installed... is there some other workaround ? tempfile and redirection :-(. - Gordon From b2blink at hotmail.com Thu Nov 18 08:51:33 1999 From: b2blink at hotmail.com (Ulf Engstrøm) Date: Thu, 18 Nov 1999 08:51:33 CET Subject: Python in Windows CE? Message-ID: <19991118075134.9052.qmail@hotmail.com> > Has anybody used Python for development under Windows CE? >-- >rshory at nrel.colostate.edu Well, not really using it yet, but I've been trying to gather some info about it, cause by next week I'll start doing some Python on a small machine running CE. I'd also be interested in all info that anyone might have and I'm glad to answer any questions about my development once I get it going. Did you Rick have any particular questions about running under CE or was it just a general question? Best regards Ulf Engstr?m http://www.b2b-link.com ulf.engstrom at b2b-link.com ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com From fdrake at acm.org Wed Nov 17 13:36:34 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Wed, 17 Nov 1999 13:36:34 -0500 (EST) Subject: [Reminder] IPC8 Call For Demos and Posters Message-ID: <14386.62898.780630.727260@weyr.cnri.reston.va.us> The deadline for demo & poster proposals for the next Python conference is approaching; please note these important dates: Nov. 30 : Deadline for demos and posters. Dec. 15 : Notification of acceptance for demos and posters. More information can be found at: http://www.python.org/workshops/2000-01/demos.html or send email to me at . -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From andy at robanal.demon.co.uk Thu Nov 4 16:23:05 1999 From: andy at robanal.demon.co.uk (Andy Robinson) Date: Thu, 04 Nov 1999 21:23:05 GMT Subject: Assorted Questions regarding the future of Python... References: <004201bf257b$0b0c64f0$0501a8c0@bobcat> Message-ID: <3822f253.11537059@news.demon.co.uk> "Mark Hammond" wrote: >> From: python-list-admin at python.org >> [mailto:python-list-admin at python.org]On Behalf Of Rob Hodges >> >> Unless something has changed dramatically since I last used windoze, >> VB is not compiled (in the sense of native machine code) any more >than >> a frozen python program; rather, VB "executables" have a small >header >> of native code that launches the vbrunxxx.dll (interpreter) to run >the >> bytecode that makes up the rest of the file. Which is more or less > >Actually, things have changed. The latest version of VB has an option >to compile to native machine code. This feature was created more from >a "check-box marketting" POV than anything else (ie, Delphi did it, so >VB decided it must too!) > >Mark. When VB's native compilation came out, some Delphi people were quick to time it and discovered that Delphi was still about 10x faster for typed math and indexing operations, although the benefits disappeared when dealing with variants or (as you do most of the time) COM APIs to other things. If they read things right, it does compile, but not desperately intelligently. I haven't done any benchmarking myself, but when I installed VB6 I didn't exactly leap off my seat at the speed increase. Andy From bernhard at alpha1.csd.uwm.edu Tue Nov 30 13:15:42 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 30 Nov 1999 18:15:42 GMT Subject: XPython (X11) References: <383E5350.1E07536A@xrce.xerox.com> <81ms2n$126$1@essle.valdyas.org> <81vsg2$g8$2@essle.valdyas.org> Message-ID: On 30 Nov 1999 06:57:06 GMT, Boudewijn Rempt wrote: >Bernhard Reiter wrote: >> True. But I want that over an integrated API and GNOME and KDE >> don't offer that yet. And they also don't offer it cross platform. >> wxWindows at least tries to get there. > >I'm curious as to what you mean by an 'integrated API' - just >curiosity. Bad wording on my part, I guess. :) Maybe I should call it internally aimed API. Means: Yes, you can use it from outsite, but the abstraction in this case is wrong. Like: Why do I need a HTML widget if I can just delegate the task to any HTML browser. The GNOME people would never delegate a task to the KDE HTML widget. But they could have an API to delegate it to any HTML browser and then let the user assemble it. If the user has KDE on the machine, he might as well use the KDE HTML browser. This is why the KDE and GNOME APIs are targeted within their own structure, but not to seperate tasks and nurture compatibility. >>>And yeah, last I heard you had to buy the Troll Kit for PyQt under >>>Win32. >> Dropping platform compatibility, that a huge point. >Oh well, platform compatibility that costs money is still >platform compatibility. No. Proprietory software is not a real option. Bernhard -- Research Assistant, Geog Dept UM-Milwaukee, USA. (www.uwm.edu/~bernhard) Free Software Projects and Consulting (intevation.net) Association for a Free Informational Infrastructure (ffii.org) From mwh21 at cam.ac.uk Sat Nov 6 12:50:23 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 06 Nov 1999 17:50:23 +0000 Subject: making the Python case to my dept. References: <9911051740130D.02530@william.jinsa.org> <3823FC43.CF7FBD71@python.net> Message-ID: A couple of little points... "Thomas A. Bryan" writes: [biggo snippo] > code in another file. Then, if they can't remember the methods for > a list, they can do something like this > > >>> L = [] > >>> dir(L) > ['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', > 'reverse', 'sort'] ``import rlcompleter''!! It makes life *so* much easier, and is the reason I still use the basic interpreter rather than idle. Hmm, implementing completion in idle? It has ``expand word'' but that's not what I want. Would this be easy? Pointers appreciated. [snippo two] > Do math majors or engineers learn their critical job skill's in their > first classes? What are mathematicians' critical job skills? I'm curious, being one, and not having being taught anything resembling a `critical job skill' yet, and happy about it. Regards, Michael From ionel at psy.uva.nl Fri Nov 19 10:09:28 1999 From: ionel at psy.uva.nl (Ionel Simionescu) Date: Fri, 19 Nov 1999 16:09:28 +0100 Subject: Comparing Python to (free) Math languages/environments References: <19991118014716.13748.00000334@ng-bj1.aol.com> <810rev$jsm$1@nnrp1.deja.com> <874sej7vmg.fsf@ifm.uni-kiel.de> <8134cl$ab1$1@nnrp1.deja.com> Message-ID: <813p47$jlh@mail.psy.uva.nl> ----- Original Message ----- From: [... Siegfried explaying how easy one can get started with Matlab and the likes to solve scientific problems. ...] Dear Sigfried, You are right - in the context of dealing with a few small, "code and throw away" problems. When you shall develop lots of interrelated pieces of code, and when you *and others* will use that code to run various, critical experiments, you will need: - database support to manage your data, - GUI's to let others use your programs before reading a ton of docs, - new libraries to cover problems that your specialized language of choice did not think yet about, and - utilities to help with documenting and debugging your code. Shortly put, you will need a real programming language. Thus, while I respect your choice and find it right, you may reconsider it if you are going to develop programs for more than one year. Note that I do not push you to Python, even if it is my choice, - feel free to choose whatever language you like better. But invest your time wisely - start with proper tools if you intend to build something bigger than programs for a diploma. ionel From mlh at vier.idi.ntnu.no Fri Nov 26 08:53:13 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 26 Nov 1999 14:53:13 +0100 Subject: CRC-module References: <38396766.B189D15A@bibsyst.no> <383C1089.1D0F7C18@bibsyst.no> Message-ID: davecook at home.com (David M. Cook) writes: > On Wed, 24 Nov 1999 17:21:29 +0100, Thomas Weholt wrote: > > >Ok, so I`ve looked into zlib.crc32 and zlib.adler32. They seem easy > >enough to use, but I thought crc-codes had characters and numbers in > >them, > > Could the characters be a-f? Maybe apply hex() to the number? sha.sha("Hello, world!").hexdigest() > > Dave Cook -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From darcy at vex.net Thu Nov 11 12:53:44 1999 From: darcy at vex.net (D'Arcy J.M. Cain) Date: 11 Nov 1999 17:53:44 GMT Subject: ASCII delimited files References: <942231502.1914033961@news.interbusiness.it> <80ekhb$1qrh$1@hub.org> <80et0b$2df8$1@hub.org> Message-ID: <80evr8$2lc7$1@hub.org> D'Arcy J.M. Cain wrote: > And here it is. Note that Christian Tismer wrote the original (at least Skip it. There's a bug. If a line ends with a quoted entry it gets attached to the next one. I'm tracking it down now and will post the corrected one. I have already added the test to __main__. :-) -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From gmcm at hypernet.com Tue Nov 16 12:12:05 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 16 Nov 1999 12:12:05 -0500 Subject: function override??? In-Reply-To: <80s0sd$1g4k$1@rtpnews.raleigh.ibm.com> Message-ID: <1269350172-9209840@hypernet.com> Arinte writes: > I am defining a python callback for my embedded app, but I want > the script writer to override my function. So, basically what I > want is a function prototype. Ex. here is what I am thinking. > > ;---fprot.py > def overrideme(self, str, someint) > > ;--fimp.py > import fprot #I know this ain't right. > # I don't know how to import from other > python > scripts yet. Enlighten me? > > def overrideme(self, str, someint) > do_some_junk() Is that a function or a method? If it's a function, I would just document the signature. If it's a method, I would expect the user to do: import fprot class MyThing(fprot.Thing): def overrideme(self, strng, someint): ..... In either case, when I'm implementing a callback, my first step is to say something like: def callback(*args): print repr(args) and see what turns up. - Gordon From gerrit.holl at pobox.com Sun Nov 28 14:04:17 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Sun, 28 Nov 1999 20:04:17 +0100 Subject: Parsing text In-Reply-To: ; from trekkan@yahoo.com on Sun, Nov 28, 1999 at 11:01:30AM -0800 References: Message-ID: <19991128200417.A2508@stopcontact.palga.uucp> Troy wrote: > As you will be able to tell, I am new to Python so please forgive any newbie > things I might do. =) > [string parsing questions] Troy, read the documentation on the string module. It's likely to be on your HD, but it's also on www.python.org/doc Success! regards, Gerrit. -- "The move was on to 'Free the Lizard'" -- Jim Hamerly and Tom Paquin (Open Sources, 1999 O'Reilly and Associates) 8:03pm up 2:28, 13 users, load average: 1.52, 1.58, 1.71 From ivanlan at callware.com Tue Nov 23 09:04:36 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Tue, 23 Nov 1999 07:04:36 -0700 Subject: Python books References: <199911230613.HAA21179@dionysus.fw.cuci.nl> Message-ID: <383A9EF4.5D1E8986@callware.com> Hi All-- Hans Nowak wrote: > > A quick search at Proxis (online bookstore, http://owas.proxis.be) > for Python yields, among others, the following books: > > John Grayson: Python & Tkinter programming > Ivan van Laningham: Python in 24 hours > ?: Python Annotated Archives > > It claims that all these are published already. Does anyone know if > this is really the case? Proxis has been known to put "published" > books in their list long before they actually hit the shelves. > My book wasn't originally scheduled till December. Publication date now looks like February. John Grayson's book is finished, but I suspect that publication will also be February. If "Python Annotated Archives" is /F's book, it's already out as an eMatter book. Visit www.python.org for details on how to get it. Search Deja News for important information on using this style of book--there was a thread on here about it. Take care, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours ---------------------------------------------- From foxes at theriver.com Fri Nov 12 11:51:35 1999 From: foxes at theriver.com (Andy Fox) Date: Fri, 12 Nov 1999 09:51:35 -0700 Subject: '==' vs. 'is' behavior References: <382C2C6A.64A8F2C2@theriver.com> Message-ID: <382C4597.331DE73A@theriver.com> Hi, Thanks for setting me straight. Like many things, it makes sense when the underlying reason is understood. I'm not used to using languages where the source is available, so I had not considered this option. I'm downloading the source now, and will try not to ask any more silly questions ;-) -- Andy Fox From JamesL at Lugoj.Com Thu Nov 25 00:25:09 1999 From: JamesL at Lugoj.Com (James Logajan) Date: Wed, 24 Nov 1999 21:25:09 -0800 Subject: Python complaints References: <867lj85g4c.fsf@g.local> Message-ID: <383CC835.B585EBDD@Lugoj.Com> Gareth McCaughan wrote: > - if/then/else works on *statements* (strictly, suites of > statements) rather than on *expressions*, so I can't > say > print "You scored %s point%s" % (score, if score==1 then "" else "s") > or anything like that. (Or, as some people prefer to put it, > Python has no ? : operator.) Thanks to Python's dynamic typing you can easily add the C "?:" expression to the language by defining a single function that will work with all types: def ifexp(cond, trueVal, falseVal): if cond: return trueVal else: return falseVal print "You scored %s point%s" % (score, ifexp(score == 1, "", "s")) Note that you'd have to define a whole set of these functions in a statically typed language, one for each type of the Vals. > - Memory management is by refcounting instead of GC. This > has its good points (it means that one can define more > precisely when e.g. finalisation happens), but it does > mean that if you build structures with cycles in the > reference graph then they won't get GCed when you want > them to. This is a real nuisance, for instance, when > you're exploring ideas or debugging: suppose you have > a piece of code that builds a big data structure out of > class instances; then every time you make a small change > and run it again (you have to run it again, because > existing instances belong to the old versions of the > classes) you can be leaking a lot of memory. Sorry, but I think the price paid for "true" GC is too high for the small number of programs that benefit from this. Perhaps one should learn to clean up after oneself when cycles are expected. From tbryan at python.net Wed Nov 10 21:20:49 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Wed, 10 Nov 1999 21:20:49 -0500 Subject: ASCII delimited files References: <942231502.1914033961@news.interbusiness.it> <382A240B.B247AD6B@python.net> Message-ID: <382A2801.FDE3CA09@python.net> "Thomas A. Bryan" wrote: > class DelimParserField: > def __init__(self, name): > self.name = name > def convert(self,value): > return value > def verify(self,value): > pass > One important thing that I didn't point out. The "name" member is the column's name. (Remember that I was thinking of delimited files for import into a database when I wrote these classes.) Thus, a more sensible application might have something like employeeListParser = DelimFldParser((EnumField('Department',('HR','IT')), DelimParserField('Name'), NumericRngField('Salary',0,500000))) If anyone uses this stuff, I'd be interested in hearing about it. ---Tom From viruswall at bam.com Thu Nov 25 17:00:04 1999 From: viruswall at bam.com (viruswall at bam.com) Date: Thu, 25 Nov 1999 17:00:04 -0500 (Eastern Standard Time) Subject: InterScan NT Alert Message-ID: <199911252205.RAA13525@python.org> Receiver, Bell Atlantic Mobile has detected virus(es) in the e-mail attachment. Date: Thu, 25 Nov 1999 17:00:04 -0500 (Eastern Standard Time) Method: Mail From: To: File: Happy99.exe Action: clean failed - deleted Virus: TROJ_SKA From robin at jessikat.demon.co.uk Sun Nov 28 20:42:49 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Mon, 29 Nov 1999 01:42:49 +0000 Subject: http://www.python.org/ blank ? References: Message-ID: In article , Robin Becker writes >for some reason I see http://www.python.org/ as a blank page. Any ideas? actually I see it as blank (pure white) with NS 4.7 win95. It seems ok with IE 5. I can see other pages with NS ok eg http://www.python.org/search/ Weird; it just came back ok. My apologies. -- Robin Becker From mwh21 at cam.ac.uk Sun Nov 28 14:34:53 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 28 Nov 1999 19:34:53 +0000 Subject: Parsing text References: Message-ID: "Troy" writes: > As you will be able to tell, I am new to Python so please forgive any newbie > things I might do. =) Welcome! > What I would like to do is take a variable and parse out each of the > pieces. Most commonly delimited by spaces. Example text: > > This is a test > > I would like to be able to pull out any of "This", "is", "a", "test" > and be able to drop any element into a variable that I wanted. string.split? I.e. Python 1.5.2+ (#12, Nov 19 1999, 15:00:31) [GCC 2.95.2 19991024 (release)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import string >>> string.split("This is a test") ['This', 'is', 'a', 'test'] > I hope this explains it enough. Thanks for any help you may be able > to provide. > > One other thing, is there a way to tell if a substring exists in a > string? in a basic sort of way > > if 'abc' isin '123abc456' string.find? >>> string.find("1122abc33","abc") 4 >>> string.find("1122abc33","f") -1 > Something to that effect anyway. In general http://www.python.org/doc/current/lib/module-string.html and maybe http://www.python.org/doc/current/tut/tut.html ? > Thanks for your time! No problem! Cheers, Michael From thomas at xs4all.nl Sat Nov 13 20:14:55 1999 From: thomas at xs4all.nl (Thomas Wouters) Date: Sun, 14 Nov 1999 02:14:55 +0100 Subject: .dll and .exe file version informaton In-Reply-To: <000101bf2b3c$a7d43e40$d32d153f@tim>; from tim_one@email.msn.com on Wed, Nov 10, 1999 at 12:30:10AM -0500 References: <806tck$5o9$1@nnrp1.deja.com> <000101bf2b3c$a7d43e40$d32d153f@tim> Message-ID: <19991114021455.A23596@xs4all.nl> On Wed, Nov 10, 1999 at 12:30:10AM -0500, Tim Peters wrote: > [emuller at painewebber.com] > > Can anyone give me an idea how to quikly get the version info on .dll > > and .exe files under windows? > In Explorer, right-click on the file, select Properties from the context > menu, and click the Version tab. > go-ahead-just-*try*-to-write-a-program-to-do-that-ly y'rs - tim Chuckle. This is not as funny as it seems. We actually do that. That is, the company I work for has a windows 'Internet Kit', which installs all kinds of programs for you, configures dialup networking, etc -- by doing exactly what you describe. It only has a few drawbacks... it requires the user to sit back and not touch the keyboard (but then, it's intended for people who do not want to hassle with their PC's setup) and it's written in VB ;) Of course, the Kit uses dirty tricks to avoid OCR'ing an application window to find out what it says ;) Typical-windows-app-it-only-goes-wrong-with-the-clueless'ly y'rs, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From endgamer71 at hotmail.com Mon Nov 8 08:34:11 1999 From: endgamer71 at hotmail.com (Endgamer) Date: Mon, 08 Nov 1999 13:34:11 GMT Subject: Newbie question: Input Message-ID: <3826b693.3888197@212.225.36.99> Okay, I know it's a damn stupid question, but I've been through the books, the texts, the tutorial, the language reference and no luck... Whats the syntax to prompt for user input? Endgamer Spider Warrior (Endgamer71 at spamtrap.hotmail.com) ##################################### Not a quote, just an on-the-spot observation: You know you're a geek when your PC costs exactly 15 times as much as your stereo. And gives better sound quality. Endgamer ##################################### From thantos at chancel.org Thu Nov 25 23:43:21 1999 From: thantos at chancel.org (Alexander Williams) Date: Fri, 26 Nov 1999 04:43:21 GMT Subject: The First Annual Obfuscated Python Contest References: <001d01bf328d$3ac77170$f29b12c2@secret.pythonware.com> Message-ID: On 26 Nov 1999 04:27:46 GMT, Cliff Crawford wrote: >next-they'll-want-obfuscated-Haskell-ly yr's, Cliff Never. Redundant. :) -- Alexander Williams (thantos at gw.total-web.net) "In the end ... Oblivion Always Wins." From gmcm at hypernet.com Sun Nov 21 13:15:45 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Sun, 21 Nov 1999 13:15:45 -0500 Subject: Order of keyword arguments In-Reply-To: <383822C3.DD0CE177@corrada.com> Message-ID: <1268914352-35423797@hypernet.com> Andres Corrada wrote: > Jeff wrote: > > > ....................................................... but I > > don't see the advantage to 'knowing' the order that the > > keywords were used by the calling function. > > > > I think there would be an advantage to having such a data > structure as an ordered dictionary. My "American Heritage > Dictionary of the English Language" is such a data structure. Ah, but that would be "alphabetical order", not "entry order", and not much use to anybody if it were. Python data structures that would suit your apparent desires: [ (optionname, optionvalue), ... ] [ optionname, ...], {optionname: optionvalue, ...} You could subclass UserList to provide the intended semantics, and then force your poor, hapless user to pass in exactly one arg (an instance of your UserList subclass). Or you could ponder the meaning of cheese. With approximately equal utility. - Gordon From thor at localhost.localdomain Sun Nov 28 13:45:15 1999 From: thor at localhost.localdomain (Manuel Gutierrez Algaba) Date: 28 Nov 1999 18:45:15 GMT Subject: [INSIST] Python ring Message-ID: This is a reminder that there's a ring for python sites, available for *ANYONE* that has a web page about python, the main web page is at: http://www.ctv.es/USERS/irmina/pythonring.html This is supported by webring.com Please, consider join the ring, I think it's a good think for the community Thanks -- From gmcm at hypernet.com Sat Nov 6 13:35:47 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Sat, 6 Nov 1999 13:35:47 -0500 Subject: Job skills [was Re: making the Python case to my dept.] In-Reply-To: Message-ID: <1270209151-4344374@hypernet.com> Michael Hudson asks: > "Thomas A. Bryan" writes: > > > Do math majors or engineers learn their critical job skill's in > > their first classes? > > What are mathematicians' critical job skills? I'm curious, being > one, and not having being taught anything resembling a `critical > job skill' yet, and happy about it. The ability to work long and hard on entirely meaningless problems. white-space-anyone?-ly y'rs - Gordon From ScherBi at BAM.com Tue Nov 16 11:46:35 1999 From: ScherBi at BAM.com (ScherBi at BAM.com) Date: Tue, 16 Nov 1999 11:46:35 -0500 Subject: Anyway to use file masks with os.listdir()? Message-ID: <3F8BA119B48AD11197470008C7A493CB98B67A@HQOBGEX1> use glob. eg: DIR = "/home/spam" files = glob.glob(DIR + "/*.jpg") will get you a list of all the .jpg files in /home/spam Bill Scherer > -----Original Message----- > From: Aaron J Reichow [mailto:reic0024 at ub.d.umn.edu] > Sent: Tuesday, November 16, 1999 10:29 AM > To: python-list at python.org > Subject: Anyway to use file masks with os.listdir()? > > > > Is there any way to pass a filemask to os.listdir()? For > example, to list > only files with the extension .jpg. Any help would be appreciated! :) > > Aaron > > > -- > http://www.python.org/mailman/listinfo/python-list > From gmcm at hypernet.com Fri Nov 19 09:14:29 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Fri, 19 Nov 1999 09:14:29 -0500 Subject: Beta 3e of the Win32 Installer In-Reply-To: <1269243486-15626894@hypernet.com> Message-ID: <1269101629-24159362@hypernet.com> I wrote: > Win32 Installer users: > > Beta 3e is here (the *last* beta before release 3, got that, > Burt? ). And here's the current bug list: - the run from CDROM stuff doesn't work. I have a fix which I'll email if you need it now - the change-the-icon stuff apparently only works on NT - it also will fail unless you have Mark's Win32 stuff installed (this one I have a fix for). I'm keeping a buglist on the download page, so I won't have to bother the group with these messages. > The new beta features: > - run from CDROM (if R/O, uses temp directory) > - put your own icon in the .exe (thanks to Thomas Heller!) > - bug fixes > - more docs > - examples of how to put Python on a floppy. > > In fact, one of the configs will put Python, Tcl/Tk and IDLE on a > floppy. Use it interactively, or pass it a script! Just like real > Python. > > Check out http://starship.python.net/crew/gmcm/install.html > > A more formal announcement will follow when it goes release. > > - Gordon > > -- > http://www.python.org/mailman/listinfo/python-list - Gordon From tim_one at email.msn.com Fri Nov 26 22:48:38 1999 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 26 Nov 1999 22:48:38 -0500 Subject: filter function question - list processing in Python In-Reply-To: <81f18b$hor$1@nnrp1.deja.com> Message-ID: <000701bf388a$4a0ef600$742d153f@tim> [lobozc at my-deja.com] > ... > In general, I note that Python has some standard functions operating > on lists but they are curiously limited. If you're talking about filter, map and reduce, they were contributed additions to the language, and Guido has said that accepting the patch was probably a mistake. > It is a pity, since these are the functions which reduce line count > significantly - as well as make programming safer. I wonder what are > the chances of repeating with lists what Python did with regular > expressions - copying the functionality from a well tested and popular > product? In light of the above, there's no chance that more functions of this kind will be added (that doesn't stop you from writing your own -- it's easy). OTOH, Haskell-like list comprehensions got a good reception last time they were discussed, and Greg Ewing has implemented a version of them. I hope they make it into the base language. A good part of their attraction to Guido was that they provide a Pythonic way to get the map and filter functions per se *out* of the language. Note also that the NumPy extension adds list-processing of the "array syntax" flavor (flexible N-dimensional slicing, data-parallel SIMD, and assorted reduction and reshaping functions). map-without-currying-is-like-thanksgiving-without-turkey-ly y'rs - tim From wheinemanNOwhSPAM at uconect.net.invalid Tue Nov 16 10:20:57 1999 From: wheinemanNOwhSPAM at uconect.net.invalid (wheineman) Date: Tue, 16 Nov 1999 07:20:57 -0800 Subject: Need help dealing with spaces in NT paths. References: <80pr76$jq5$1@nnrp1.deja.com> <11f733ec.96958819@usw-ex0101-007.remarq.com> Message-ID: <0a0133f8.1afd50af@usw-ex0102-014.remarq.com> In article , piet at cs.uu.nl wrote: > >>>>> wheineman (W) writes: > W> Put quotes around the complete path. For example: > W> myExec = "C:\\Program Files\\Trash Can\\compactor.exe" > You probably mean: > myExec = "\"C:\\Program Files\\Trash Can\\compactor.exe\"" > or easier: > myExec = r'"C:\Program Files\Trash Can\compactor.exe"' > -- > Piet van Oostrum > URL: http://www.cs.uu.nl/~piet [PGP] > Private email: Piet.van.Oostrum at gironet.nl What he said. Sorry. * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free! From jeremy at cnri.reston.va.us Fri Nov 12 15:32:03 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Fri, 12 Nov 1999 15:32:03 -0500 (EST) Subject: method overriding trick In-Reply-To: References: <14378.62498.649973.150075@bitdiddle.cnri.reston.va.us> Message-ID: <14380.31043.118853.946057@goon.cnri.reston.va.us> I suggested a renaming approach for managing method overriding. class Base: def aMethod(self, arg): return arg * 2 class Derived1(Base): super_aMethod = Base.aMethod def aMethod(self, arg): return self.super_aMethod(arg) + 1 David suggested implementing the same idea via a getattr hook that eliminated the need for explicit naming. import new class Mixin: def __getattr__(self, k): if k[:len('super_')] == 'super_': for b in self.__class__.__bases__: m = getattr(b, k[len('super_'):], None) if m: return new.instancemethod(m, self, self.__class__) else: raise AttributeError, k else: raise AttributeError, k class Base(Mixin): def f(self): print 'Base.f' class Sub(Base): def f(self): print 'Sub.f' self.super_f() I think this approach might work, but there are some details you've skated over that would need to be worked out. The main problem is dealing with an inheritance hierarchy where there are more levels than two. class SubSub(Sub): def f(self): print "SubSub.f" self.super_f() I you call method f on a SubSub object, you'll dump core. When the getattr hook is invoked, it will create a method named super_f for the object. Because it is first called in SubSub, the getattr hook will bind super_f to Sub.f. But Sub.f also references the name super_f, so it will call itself. Actually, you'll hit this problem any time you call f in a class derived from one that implements a method named f. Even if SubSub didn't override f, the search for an f would find the most derived implementation first. I think you can solve the problem with private variables. self.__super_f will get mangled at compile time and you can do a more complicated search for attribute names that look like they've been mangled. You would also need to do a proper search of the base classes -- the transitive closure of the search you've actually implemented. I think you would also need to stuff the newly created instancemethod into __dict__ to avoid looking it up every time. Jeremy From HattiePastors at news.vex.net Thu Nov 4 05:42:38 1999 From: HattiePastors at news.vex.net (Hattie Pastors) Date: 4 Nov 1999 10:42:38 GMT Subject: how to use pythondoc on Win32? References: <7vrjqb$aju@mail.psy.uva.nl> Message-ID: <7vrnuu$2koq$1@hub.org> On Thu, 4 Nov 1999 10:32:18 +0100, Ionel Simionescu wrote: >I did rename the extensionless 'pythondoc' to 'pydoc.py', The secret for me was after renaming pythondoc to pydoc.py makes sure you MOVE the pydoc.py OUT of the lib\pythondoc\ directory ... i found that the program just won't run if you try to run the main script from within the module directory. I don't know why, i never investigated. As soon as i finally got it working (after a few hours of frustration like you have no doubt experienced) i was too happy to not to fiddle with it anymore. It's been working ever since for me. It does say in the readme to move it into your 'path' somewhere. Of course the 'current directory' is in teh win32 path sort of, heh. If my observation is right that the thing will not run from the module directory, the readme should be more specific on this account. Great tool. Too bad the author hasn't had time to work on it much lately. From a.eyre at optichrome.com Thu Nov 25 07:50:02 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Thu, 25 Nov 1999 12:50:02 -0000 Subject: function as attr of subclass != method (???) In-Reply-To: <81imde$3uk$1@nnrp1.deja.com> Message-ID: <000401bf3743$980145e0$3acbd9c2@peridot.optichrome.com> > >>> achild.method = lambda self:"nope" > >>> achild.method() > Traceback (innermost last): > File "", line 1, in ? > achild.method() > TypeError: not enough arguments; expected 1, got 0 achild is an instance. You must assign the lambda as a member of the child *class*, else it will be an unbound method. e.g. >>> class A: ... pass ... >>> b = lambda x: x >>> b at 7f7bd0> >>> a.b = b >>> a.b at 7f7bd0> >>> a.b() Traceback (innermost last): File "", line 1, in ? TypeError: not enough arguments; expected 1, got 0 >>> a.b(1) 1 >>> A.b = b >>> a=A() >>> A.b > >>> a.b of A instance at 7f8d70> >>> a.b() <__main__.A instance at 7f8d70> -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From greg.ewing at compaq.com Wed Nov 24 05:36:41 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Wed, 24 Nov 1999 23:36:41 +1300 Subject: automatic "lotjes trekken" References: <81cqnv$2ip$1@vvs.superst.iae.nl> <81e3s2$j14$2@newshost.accu.uu.nl> Message-ID: <383BBFB9.C9607961@compaq.com> Martijn Faassen wrote: > > Not at all. everybody here speaks Dutch anyway. (it's a conspiracy!) Not me! Uunlees-iit-meens-yoo-juust-haav-too-wrijt-aal-yoor-voowls-twijce, Greg From mal at lemburg.com Fri Nov 26 12:21:41 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 26 Nov 1999 18:21:41 +0100 Subject: Newbie: raw_input and other input methods References: <19991125.1481400@adam-aurag.penguinpowered.com> <81kfjc$1vg$1@vvs.superst.iae.nl> Message-ID: <383EC1A5.99A4FAD5@lemburg.com> Carel Fellinger wrote: > > Hassan Aurag wrote: > > > Anyway, I used raw_input to be able to use readline and its nifty back > > arrow, up arrow... > > > However when I wanted to have a nifty prompt like the following one: > > > raw_input("\033[0;34mInput: \033[0m"), I was surprised it got all > > screwed up. > > bash copes with this, so I dived into the source. And low and behold > there it is: bash uses the readline special codes RL_PROMPT_START_IGNORE > (='\001') and RL_PROMPT_END_IGNORE (='\002') to tell readline to 'ignore' > the chars in between. Using this info you can get what you want:) > > e.g. > >>>raw_input('\001\033[0:34m\002Input: \001\033[0m\002') > > works like a charm, atleast here on my linux box It even does the Right Thing for the Python prompt. Try this: >>> sys.ps1 = '\001\033[0:34m\002>>> \001\033[0m\002' >>> sys.ps2 = '\001\033[0:31m\002... \001\033[0m\002' >>> if 1: ... print 'looks cool :-)' ... looks cool :-) >>> The above adds a little color to your average Python prompt. -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 35 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From tendac at wanadoo.fr Sat Nov 6 09:22:13 1999 From: tendac at wanadoo.fr (claude) Date: Sat, 06 Nov 1999 14:22:13 +0000 Subject: eff-bot's The Standard Python Library References: <19991105125124.A302546@vislab.epa.gov> Message-ID: <38243995.94F2E17B@wanadoo.fr> Ematter short story : (sorry for my english, i am french) 1) i have tried to install it on a W98 personal computer, and i saw the following message : eMatter(c) Error An error occured while preparing to display eMatter(c), Please try again. If continue to have problems contact Fatbrain.com Customer Service === I send an email to fatbrain customer service : no answer === 2) i have tried to install it on a Linux personal computer where Nt4 SP5 is a "guest" reachable by VMWARE software (www.vmware.com). All worked fine, i could read the book (acrobatreader V3) in spite of black boxes appearing at the end of some paragraphes (acrobatreader errors 'Cs8' ???). But when i left Nt4 session and started a new one with vmware and proceeded with eMatter_The_Standard_Python_Librar.exe , i saw the following message : There is a problem processing your saved registration information. Please contact Fatbrain.com Customer Service === I send an email to fatbrain customer service : no answer === 3)I have sucessfully installed eMatter_The_Standard_Python_Librar.exe on a true Nt4 SP5 (not a linux-vmware one). All worked fine, i could read the book (acrobatreader V3) in spite of black boxes appearing at the end of some paragraphes (acrobatreader errors 'Cs8' ???). Then following the advice of the author of the book, i have upgraded acrobatreader V3 to acrobatreader V4, but now i CANT read the book : eMatter(c) Error An error occured while preparing to display eMatter(c), Please try again. If continue to have problems contact Fatbrain.com Customer Service. === I send an email to fatbrain customer service : You can go ahead and upload a new document on our site. And then you can delete the existing file that you are having problems with. Please contact me again if you have any further questions. Thank you for using fatbrain.com === But in the meantime i cleaned up the "register base" (regedit)."Big Mistake". I have had the following message There are no new registration remaining for this license key, to view ematter you will need to obtain an additional license key by purchasing this title from fatbrain.com. If you believe you have reached this message in error , please contatc Fatbrain.com customers service. === I send 2 emails to fatbrain customer service : no answer. === Of course i have made a "big mistake", but i could not figure out that this book was definitely tied up with Nt4. If your NT box or w95/w98 box crash, the book is lost even if you have made a backup of eMatter_The_Standard_Python_Librar.exe., this is a piece of nonsense, when you purchase a software it can be install many times (Microsoft suite ...) Best regards. From wheinemanNOwhSPAM at uconect.net.invalid Mon Nov 15 15:59:00 1999 From: wheinemanNOwhSPAM at uconect.net.invalid (wheineman) Date: Mon, 15 Nov 1999 12:59:00 -0800 Subject: Need help dealing with spaces in NT paths. References: <80pr76$jq5$1@nnrp1.deja.com> Message-ID: <11f733ec.96958819@usw-ex0101-007.remarq.com> Put quotes around the complete path. For example: myExec = "C:\\Program Files\\Trash Can\\compactor.exe" * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free! From sjturner at ix.netcom.com Mon Nov 1 12:36:31 1999 From: sjturner at ix.netcom.com (Stephen J. Turner) Date: Mon, 01 Nov 1999 12:36:31 -0500 Subject: Listbox.. ACTIVE-item is the one selected previously.. References: Message-ID: <381DCF9F.F6D21C02@ix.netcom.com> Andrew Markebo wrote: > I want to have a listbox, and when the user clicks on one item in it, > he gets the value selected 'published' somewhere.. with the small > program included below.. If it is launched, and the user selects the > letters in order I would assume the result to be "abcde", but what I > get is: "aabcd", after the first selection, ACTIVE is lagged.. > > -------------------- > > z=None > def click(event=None): > global z > print z.get(ACTIVE) > > def test(): > global z > frame=Frame(None) > frame.pack() > z=Listbox(frame) > z.pack() > z.bind("", click) > for i in ("a", "b", "c", "d", "e"): > z.insert(END, i) > > frame.mainloop() > > test() The code to activate the clicked element is found in the default listbox class bindings (see listbox.tcl in your Tk distribution). This requires two changes to your script: 1. The event specification should be changed to , since activation occurs on button release. 2. Your binding must be called after the class binding. The second can be accomplished in two ways. The first is to modify the bindtags list for your listbox widget so that _all_ widget bindings occur after class bindings: z.bind("", click) tags=list(z.bindtags()) mytag=tags[0] del tags[0] tags.insert(1, mytag) z.bindtags(tuple(tags)) This could cause problems, though, if you have other widget bindings that you want to precede listbox class bindings. In this case, what you must do is associate your function with a new bindtag (e.g., "postclass"), and then insert the new bindtag in the listbox widget's bindtags list after the class binding: z.bind_class("postclass", "", click) tags=list(z.bindtags()) tags.insert(2, "postclass") z.bindtags(tuple(tags)) Regards, Stephen -- Stephen J. Turner From emile at fenx.com Mon Nov 22 07:10:47 1999 From: emile at fenx.com (Emile van Sebille) Date: Mon, 22 Nov 1999 04:10:47 -0800 Subject: Order of keyword arguments References: <38379233.ADE65CDB@corrada.com> Message-ID: <008301bf34e2$9d3961e0$01ffffc0@worldnet.att.net> Andres, Perhaps you can adapt one of these ideas. HTH Emile van Sebille emile at fenx.com ------------------- #------start of code fragment import traceback def ordered1(opts ,**kws): print opts kws = eval('{'+opts+'}') print kws def ordered2(opts ,**kws): print opts def convert_to_dict(**kws): return kws kws = eval('convert_to_dict(' + opts+ ')') print kws def ordered3(**kws): tbs = traceback.extract_stack() for line in tbs: if line[3][:8] == 'ordered3': call_order = line[3][9:] print call_order print kws ordered1 (opts="'c':1, 'b':2, 'a':1") ordered2 (opts="c=1, b=2, a=1") ordered3 (c=1, b=2, a=1) #-------end of code fragment ----- Original Message ----- From: Andres Corrada To: Sent: Saturday, November 20, 1999 10:33 PM Subject: Order of keyword arguments > Hi, > Can one access the order in which keyword arguments were passed to a > function? I want to call a function with the keyword syntax: f( > foo='theFooString', bar='theBarString' ) and use the fact that foo was > listed first so I can do something like: > > def f( **kw ): > > Process keyword arguments remembering the order in which the were used > to call the function. > Print first keyword > Print second keyword > . > . > . > > ------------------------------------------------------ > Andres Corrada-Emmanuel Email: andres at corrada.com > Owner http://www.corrada.com/mamey > Mamey Phone: (413) 587-9595 > ------------------------------------------------------ > > -- > http://www.python.org/mailman/listinfo/python-list > > From billtut at microsoft.com Wed Nov 24 16:26:13 1999 From: billtut at microsoft.com (Bill Tutt) Date: Wed, 24 Nov 1999 13:26:13 -0800 Subject: Python and COM: a bug? Message-ID: <4D0A23B3F74DD111ACCD00805F31D8100DB915B2@RED-MSG-50> > From: Gaetan Corneau [mailto:Gaetan_Corneau at baan.com] > > > > I also don't think we try to optimize any calls. COM doesn't > > give one enough > > information to even bother optimizing anything other than > > caching Name -> DispID mappings. > > That's what I meant by "optimization". > This optimization is allowed by COM. See the IDispatch::GetIdsOfName() docs at: http://msdn.microsoft.com/library/psdk/automat/chap5_32cz.htm "The member and parameter DISPIDs must remain constant for the lifetime of the object. This allows a client to obtain the DISPIDs once, and cache them for later use." On the other hand, there is this as well: "When GetIDsOfNames is called with more than one name, the first name (rgszNames[0]) corresponds to the member name, and subsequent names correspond to the names of the member's parameters. The same name may map to different DISPIDs, depending on context. For example, a name may have a DISPID when it is used as a member name with a particular interface, a different ID as a member of a different interface, and different mapping for each time it appears as a parameter." If your COM object isn't following either of these rules then its broken. The other intreresting thing to find out would be if the object supports IDispatchEx. Bill From fdrake at acm.org Thu Nov 4 16:59:43 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 4 Nov 1999 16:59:43 -0500 (EST) Subject: Python Conference Hotel Change In-Reply-To: <3824f510.12238077@news.demon.co.uk> References: <199911032224.RAA10668@eric.cnri.reston.va.us> <3824f510.12238077@news.demon.co.uk> Message-ID: <14370.463.892526.967619@weyr.cnri.reston.va.us> Andy Robinson writes: > My memory may be fuzzy, but isn't it an even shorter stroll from there > to Bardo, one of the world's biggest microbreweries? A big microbrew? Strange... hope it's good! ;-) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From gerrit.holl at pobox.com Fri Nov 12 09:30:17 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Fri, 12 Nov 1999 15:30:17 +0100 Subject: Intelligent strptime? In-Reply-To: <382AB016.D45727D8@strs.co.uk> References: <19991110171256.A5196@optiplex.palga.uucp> <382AB016.D45727D8@strs.co.uk> Message-ID: <19991112153017.B3867@optiplex.palga.uucp> Ian Clarke explained why intelligent strptime is wrong: > While I don't know what the application is, if you are processing user > input I strongly recommend against doing this. In a project I am > working on the issue of whether to provide a "best guess" as to a date > came up, but we decided that it was much better if a date had been > entered incorrectly to furnish the user with an error, than attempt to > correct that error automatically. Sure in the short term it makes life > a little easier for the user, but it also allows them to get used to the > computer correcting their errors, and when the time comes that the > computer cannot correct their error, or makes an incorrect guess, they > will feel that there is something wrong ("I have always entered dates in > MMDDYY format and it worked fine, why shouldn't it work now?"). Ah, ok. I'll force the user to type MM/DD and HH:MM... regards, Gerrit. -- linuxgames.nl.linux.org All about games on Linux in Dutch (under construction). www.nl.linux.org The Dutch resource for Dutch Linux documentation. www.nl.linux.org/discoverb Learn foreign words and definitions. www.nl.linux.org/~gerrit/asperger I'm an Asperger, go here for more info. www.nl.linux.org/~gerrit About me and pictures of me. From gmcm at hypernet.com Wed Nov 10 12:11:46 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 10 Nov 1999 12:11:46 -0500 Subject: PyRun_SimpleString problem. In-Reply-To: <80c5g9$1nm8$1@rtpnews.raleigh.ibm.com> Message-ID: <1269868595-513164@hypernet.com> "Arinte" writes: > I am trying to run a python file from a dll. When I run the file > w/ PyRun_AnyFile it works fine. But, when I try to run the code > line by line w/ PyRun_SimpleString I get this error on function > definitions. > > def bottle(n): > File "", line 1 > def bottle(n): > ^ > SyntaxError: unexpected EOF while parsing > if n == 0: return "no more bottles of beer" > File "", line 1 > if n == 0: return "no more bottles of beer" > > Can I run files line by line if they define functions? If so, > how? Nope. Can't do it with exec either. Even the interactive interpreter can't get away with it. You can only exec / eval a complete syntactic unit. You could look at a shell (eg, code.py) to see how's it done interactively, (normally append the line to a buffer, try running the buffer; if it worked, clean out the buffer). But if PyRun_AnyFile works, I wonder why you're even trying PyRun_SimpleString? Python would much prefer to work at the file level. - Gordon From mstenber at cc.Helsinki.FI Mon Nov 29 01:30:39 1999 From: mstenber at cc.Helsinki.FI (Markus Stenberg) Date: 29 Nov 1999 08:30:39 +0200 Subject: Anyone looked at pike? References: Message-ID: kaleissin at nvg.org (Kaleissin) writes: > Specifically: why they claim it's faster? Shrug.. see below. > http://pike.idonex.se/manual/tutorial/tut_introduction.html#introduction.3 > > Though, why anyone would want Yet Another C-Like Syntax is beyond me... * It has static typing (which is much faster than dynamic used in Python, * AFAIK) Also, I'm not sure about how it's binding works and so on - but it seems to be mostly "glue on top of C++" approach, not really dynamically typed/late-bound language like Python. I personally would rather use C++(*) really. Of course, I haven't been exposed for long. :) I really wonder about similarities they mentioned on that page. It seemed to me that it looked a lot more Perl-ish than Python-esque. Hmm. Maybe it was all those braces and C(++) jargon they used. > tal. -Markus P.S. from one example.. void find_song(string title) { string name, song; .. (snip) if (string song=records[name][title]) ^^^^^^ looks downright perverted to me :P (*) I rather commit ritual suicide than code C++ in prolonged fashion. And I even (sort of) like C :P -- The IBM Principle: Machines should work. People should think. The Truth About the IBM Principle: Machines don't often work, people don't often think. From bowman at montana.com Fri Nov 26 09:29:00 1999 From: bowman at montana.com (bowman) Date: Fri, 26 Nov 1999 14:29:00 GMT Subject: Python extensions and lcc-win32 References: <383E6378.4B10FDD6@europe.com> Message-ID: Kaloian Doganov wrote: >In fact, I'm looking for a non-MSVC solution to write Python extensions. >So, any GCC or lcc-win32 tips are appreciated. I've never tried lcc for Python extensions, but you might ask on the lcc ng. There are several gcc or egcs ports to DOS/Windows. www.delorie.com is the djgpp compiler and tool set. It is DOS oriented and a very robust set. www.cygnus.com is the home of Cygwin. Cygwin is the tool of choice for ports from Linux to Dos/Windows. It pretty much replicates a mini-*nix environment under Windows. There are links at that site to Mingw32, which is my favorite for Windows apps. Ming is closely related to Cygwin. It was always the egcs port vs. gcc, but that distinction is getting moot. Any of these should work fine. From Gaetan_Corneau at baan.com Tue Nov 30 14:22:45 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Tue, 30 Nov 1999 14:22:45 -0500 Subject: Removing null items Message-ID: <816010E2456BD111A48700805FBBE2EEFDF878@ex-quebec-u1.baan.com> Take a look at the filter built-in function. ______________________________________________________ Gaetan Corneau Software Developer (Quality Assurance Team) BaaN Supply Chain Solutions http://www.baan.com E-mail: Gaetan_Corneau at baan.com Tel: (418) 266-8252 ______________________________________________________ "Profanity is the one language all programmers know best" > -----Original Message----- > From: sragsdale at my-deja.com [mailto:sragsdale at my-deja.com] > Sent: Tuesday, November 30, 1999 2:06 PM > To: python-list at python.org > Subject: Removing null items > > > So I've got a very simple desire: to remove all false (I.E. > None, 0, '', > []) items from a list. > > As it is I've got this function which works fine, but it offends my > sight. Is there any better (or at least different) way to do this? > > ################################################################# > # return non-null items from the first list > def foo(lst): > rlist = [] > for i in lst: > if i: > rlist.append(i) > return rlist > > > Sent via Deja.com http://www.deja.com/ > Before you buy. > > -- > http://www.python.org/mailman/listinfo/python-list > From emuller at painewebber.com Sat Nov 13 14:11:12 1999 From: emuller at painewebber.com (emuller at painewebber.com) Date: Sat, 13 Nov 1999 19:11:12 GMT Subject: Windows File Version Comparison.... Message-ID: <80kd4d$u14$1@nnrp1.deja.com> I wrote a def that gets the file version of a windows exe/dll/cpl type of file. It relies on filever.exe (part of the NT reskit) to be available, but it should work for anyone looking to do this until the win32ver module is finished. If you are looking for this module, it is was under a '.dll and .exe version ...' thread. Anyway... Once I did that, I could get the version of the file back, the next thing I had to do was compare two versions and see which one was newer. Since version strings can be '4.0.1.123'. I couldn't just convert them to a float, and python thought that '4.0.1.6' was greater than '4.0.1.42' for soem reason. So I wrote the following def to check two version strings and return true/false....here it is...If anyone has any problems with it, let me know, if anyone uses it let me know, if anyone fixes a bug in it, let me know.... def compVer(ver1,ver2): #Checks to see if ver1 >= ver2 import string vl1 = string.split(ver1,'.') vl2 = string.split(ver2,'.') while 1: if int(vl1[0]) > int(vl2[0]): return 1 elif int(vl1[0]) == int(vl2[0]): del vl1[0] del vl2[0] if len(vl1) >= 1 and len(vl2) == 0: true = 1 for each in vl1: if int(each) <> 0: true = 0 return true elif len(vl1) == 0 and len(vl2) >= 1: true = 1 for each in vl2: if int(each) <> 0: true = 0 return true elif len(vl1) == 0 and len(vl2) == 0: return 1 else: continue elif int(vl1[0]) < int(vl2[0]): return 0 Sent via Deja.com http://www.deja.com/ Before you buy. From edwardm_painewebber at my-deja.com Sat Nov 13 14:18:44 1999 From: edwardm_painewebber at my-deja.com (edwardm_painewebber at my-deja.com) Date: Sat, 13 Nov 1999 19:18:44 GMT Subject: Running a program as another user on Win32 References: <809ea4$ln$1@nnrp1.deja.com> Message-ID: <80kdii$uc8$1@nnrp1.deja.com> Thanks, I did not try the code (although I will), I did discover that before you posted though. I used ntrights.exe (part of the NT Reskit) to grant myself rights. The problem was I had to log off and on again for the rights to take affect. This won't work for the application that I was trying to use the program for. It looks like the security info for a user is set during logon and not gotten again, at least not until the next logon. I will try the code attached below once I have some time... Great product so far Mark! I hope to be able to convince enough people here to start using python vs. WinBatch. Especially since we can also run python on our Solaris and AIX boxes (sans Win32 extension of course)... You know it amazes me....Most of the solaris people use korn shell scripts, some use perl, the nt people use batch files and winbatch, the AIX people (well god knows what they use)...If we all used python here we could build a huge library of utilities and make large parts of it work cross platform....It would be great......Ahhh..To dream.... :-) In article , "Mark Hammond" wrote: > emuller at painewebber.com wrote in message <809ea4 $ln$1 at nnrp1.deja.com>... > >I am writing a bunch of scripts that will need to run as Administrator > >(Domain Administrator) on Windows NT 4.0 workstation clients that > >belong to an NT domain. I've tried using LogonUser, but I always get > >the following: pywintypes.api_error: (1314, 'LogonUser', ' A required > >privilege is not held by the client.'). I've also tried using LogonUser > >with the local Administrator account on my NT machine with no luck. > > You need to explicitely enable the privilege. The following function should > do the job. The documentation on CreateProcessAsUser is vague, and I dont > have time to test it. It appears you need some or all of the following > privileges (all from the ntsecuritycon module): SE_ASSIGNPRIMARYTOKEN_NAME, > SE_INCREASE_QUOTA_NAME TOKEN_DUPLICATE, TOKEN_IMPERSONATE > > def AdjustPrivilege(priv, enable = 1): > # Get the process token. > flags = TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY > htoken = win32security.OpenProcessToken(win32api.GetCurrentProcess (), > flags) > # Get the ID for the privilege. > id = win32security.LookupPrivilegeValue(None, priv) > # Now obtain the privilege for this process. > # Create a list of the privileges to be added. > if enable: > newPrivileges = [(id, SE_PRIVILEGE_ENABLED)] > else: > newPrivileges = [(id, 0)] > # and make the adjustment. > win32security.AdjustTokenPrivileges(htoken, 0, newPrivileges) > > Mark. > > Sent via Deja.com http://www.deja.com/ Before you buy. From fredrik at pythonware.com Fri Nov 12 10:03:51 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 12 Nov 1999 16:03:51 +0100 Subject: Tkinter and after References: <382C2854.E9494EFE@lri.fr> Message-ID: <009201bf2d1f$226b59c0$f29b12c2@secret.pythonware.com> Stephane Conversy wrote: > It is said in Tkinter doc that after() is like a call to time.sleep() > wich blocks Tkinter. (what Tkinter docs?) http://www.pythonware.com/library/tkinter/introduction/basic-widget-methods.htm => "alarm handlers and other non-event callbacks" tells you how to register alarm handlers. From shouldbe at message.com Tue Nov 16 11:35:53 1999 From: shouldbe at message.com (Arinte) Date: Tue, 16 Nov 1999 11:35:53 -0500 Subject: function override??? Message-ID: <80s0sd$1g4k$1@rtpnews.raleigh.ibm.com> I am defining a python callback for my embedded app, but I want the script writer to override my function. So, basically what I want is a function prototype. Ex. here is what I am thinking. ;---fprot.py def overrideme(self, str, someint) ;--fimp.py import fprot #I know this ain't right. # I don't know how to import from other python scripts yet. Enlighten me? def overrideme(self, str, someint) do_some_junk() From kanzow at gmd.de Fri Nov 26 07:30:50 1999 From: kanzow at gmd.de (Peter K.) Date: Fri, 26 Nov 1999 13:30:50 +0100 Subject: Running apps with Zope 2? References: <80v5g8$5a6$1@mulga.cs.mu.OZ.AU> <3834101A.FF39F64C@infercor.no> <8E83A8056PaCmAnRDLM@194.2.0.33> Message-ID: <383E7D7A.1B48C7F1@gmd.de> Hello, I have written some web applications using the old Zope/Bobo version. I published them using ZopeHTTPServer, like this: File m.py: class Application: "Application" def hello(self): "Hello" return "Hello World from my Zope Object" app=Appl() After starting ZopeHTTPServer (on hostname.domain.de) with ZopeHTTPServer -p 1234 m.py I can access the Application object from the web: requesting http://hostname.domain.de:1234/app/hello gets "Hello World from my Zope Object". This is what I want! But what must I do to achieve this in Zope 2? I installed it recently and can't find it in the documentation. How can I publish my old applications with the new Zope? Where do I have to put m.py? What do I have to do in the management screen? Which URL will get me the "Hello World..." message? Do I have to install m.py as a Product? How? Thank you very much Peter Kanzow, Germany From gmcm at hypernet.com Sat Nov 13 21:48:55 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Sat, 13 Nov 1999 21:48:55 -0500 Subject: method overriding trick In-Reply-To: <382DFF59.51F186A6@x.x> Message-ID: <1269574764-2892811@hypernet.com> Eric Jacobs wrote: > Phil Mayes wrote: > > > > I use a method that doesn't remove the clunkiness, but localises the > > hierarchy to one line: > > > > _Parent = basedlg.BaseDlg > > class AddressDlg(_Parent): > > def __init__(self, param): > > self.local = param > > _Parent.__init__(self, 2345) > > > > By using the same name "_Parent" in all modules, less thinking is needed, > > and cut'n'paste coding (what, me?) works better too. > > You wouldn't be able to reassign the _Parent variable to define another > class elsewhere in the same module, though, because the functions defined > this way will always look up the _Parent from the module namespace at > execution time. Unless you've nested your class statement inside a def or another class, the class object will get built when the module is loaded. So what the _Parent variable holds once your code starts executing doesn't matter - it is only meaningful at the time the "class" statement is executed. Sure you can reassign it, but it will only mean something if you do it at the top level. OTOH, I find that it's rare for a base class and it's derived classes to have the same __init__ signature, so for me the trick is rarely useful. - Gordon From endgamer71 at hotmail.com Tue Nov 2 06:07:28 1999 From: endgamer71 at hotmail.com (Endgamer) Date: Tue, 02 Nov 1999 11:07:28 GMT Subject: Newbie question : Info on Python under DOS/Windows Message-ID: <381ec4c4.7451128@212.225.36.99> Okay, I'm really new to Python, and have limited experience of real programming (yes, the age-old story....crippled by BASIC at about the age of 10 ). I'm learning from texts, this froup and O'Reilley's "Programming Python" and as a starting project I'm writing a Y2K mini-fix for Wintel machines - a program which prompts the user for the current date and feeds it into "date", for machines which won't hold the date on reboot after the millenium. My question is: I've found it hard to locate resources or information on Python under DOS/Windows - are there any special groups, sites or FAQs/Manuals with general information? Much as I hate MS environments, in my line of work I have to work with them almost constantly (back on my lovely Linux machine whenever I get a chance ) and I suspect I'll need this information again... Endgamer Spider Warrior (Endgamer71 at spamtrap.hotmail.com) ##################################### Not a quote, just an on-the-spot observation: You know you're a geek when your PC costs exactly 15 times as much as your stereo. And gives better sound quality. Endgamer ##################################### From you at somehost.somedomain Tue Nov 30 11:15:04 1999 From: you at somehost.somedomain (****) Date: 30 Nov 1999 16:15:04 GMT Subject: NEWBIE References: <81m7m3$82$1@news.qub.ac.uk> <38428160.56B1D46D@gssec.bt.co.uk> Message-ID: <820t68$asr$1@news.qub.ac.uk> In article <38428160.56B1D46D at gssec.bt.co.uk>, alan.gauld at gssec.bt.co.uk says... > >Stuarty at excite.co.uk wrote: >> I have just recently started using Python, after the first day I was further >> on than I am after a semester of C programming(were at arrays...). >> tutorial by Giudo van Rossum was very useful, but I attempted printing out the >> reference library..there are now less considerably less trees in the world. > >So are you asking a question? >....or just boasting? ;-) > >Alan g. >-- >================================================= >This post represents the views of the author >and does not necessarily accurately represent >the views of BT. Pointing out how easy Python is to use, to a relative beginner :-) From oli at andrich.net Tue Nov 23 11:58:32 1999 From: oli at andrich.net (Oliver Andrich) Date: Tue, 23 Nov 1999 17:58:32 +0100 Subject: Asyncchat Module Documentation and some asyncchat based modules Message-ID: <19991123175832.A26756@gothic.andrich.net> Hi, after I spend most of the last weeks implementing some asyncchat based clients for common used protocols (at least I use the quite common ;-) and a asyncchat based POP3 server. I like to ask if somebody already started to document this module for the library reference, otherwise I am willing and happy to do it. I am so impressed by asyncore and asyncchat, that I like to do it. ;-) And I am looking forward to do a first release of my package of asnyc* based clients in a week or two. And my POP3 server (100% pure Python) in about three weeks. I have to to do some code cleanups, security checks and performance tuning, but at the moment the POP3 server runs fine in my testbed (simulating the 16.000 users I have on my production machine) and it outperforms cucipop without any problems. So, who do I have to contact to supply documentation for asynchat? Best regards, Oliver -- Oliver Andrich, KEVAG Telekom GmbH, Schlossstrasse 42, D-56068 Koblenz Telefon: 0261-3921027 / Fax: 0261-3921033 / Web: http://rhein-zeitung.de From bjorn at roguewave.com Mon Nov 29 16:44:31 1999 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Mon, 29 Nov 1999 14:44:31 -0700 Subject: Python bugs Message-ID: <51C9F3C392D0D111A15600A0C99E64A9AF569E@localhost> > Bjorn> Which is a good thing, but shouldn't preclude it > from being used > Bjorn> as a dictionary in the update statement (although the fix > Bjorn> probably have to be to Dict.update rahter than os.environ). > > You are correct. It would have to make some assumptions > about how to get a > dict from an instance object. Should it access the > instance's "__dict__" > attribute or (in this case) the "data" attribute or try to an > "as_dict" > method? Since no such well-defined interface currently exists, you're > probably better off in the short term simply executing > > d.update(os.environ.data) How about: def update(self, other): ... regular stuff if other_is_an_instance_or_something_else_we_dont_know_about: for k in other.keys(): self[k] = other[k] That should be well defined enough, or raise the appropriate exception if it can't be done.(?) > Bjorn> Cool (do you know if you can do db.items() also? > -- found that > Bjorn> one five minutes ago...) > > I don't see it, and I doubt it's going to get added any time > soon. One > motivation for using on-disk mappings such as provided by > bsddb and (g)dbm > is that they can be really huge (hundreds of thousands or > millions of keys > are not out of the question). Asking for values() or items() in these > situations is much more likely to get you into memory trouble than for > simple dicts which tend to be smaller. [workarounds snipped] Yes, all of these are easy to work around if you really need to -- the point being you shouldn't need to <0.1 wink> It's true that on-disk mappings can get huge. It's also true that sometimes they're just used for convenient persistence of moderately sized data. I think it's generally a bad idea to try to prevent people from potentially shooting themselves in the foot :-) -bjorn From arcane at znet.com Sat Nov 6 16:34:10 1999 From: arcane at znet.com (Robert Cain) Date: Sat, 06 Nov 1999 13:34:10 -0800 Subject: python: something completely different References: <3820C0B8.62B2@iowegian.com> Message-ID: <38249ED2.BB7EA1DE@znet.com> Back to the subject at hand (Python in the DSP universe) has anyone investigated the possibility of conversion, compilation or whatever of MatLab to Python? I'm naive WRT to both at this point because 1) MatLab is too expensive to consider, 2) MatLab costs too much, and 3) I've just been turned on to Python as a result of the original post in this comp.dsp thread. Looks like it could be the wavelet of the future. Peace, Bob -- "Things should be described as simply as possible, but no simpler." A. Einstien From pinard at iro.umontreal.ca Mon Nov 1 19:39:16 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 01 Nov 1999 19:39:16 -0500 Subject: Improved struct module In-Reply-To: wtanksle@hawking.armored.net's message of "1 Nov 1999 16:43:58 GMT" References: <000001bf15fc$3397ee00$ba2d153f@tim> <0E16861EE7BCD111BE9400805FE6841F0BEB2650@c1s5x001.cor.srvfarm.origin-it.com> Message-ID: wtanksle at hawking.armored.net (William Tanksley) ?crit: > >> I must admit that I am also one of those lazy bastards that uses his > >> newsreader's "find any messages by Tim Peters"-function to locate > >> interesting threads. > >So do I, but even more lazily! Gnus bolds Tim's messages automatically > >for me, when preparing the threaded summary for the Python mailgroup. :-) > Ah, but does your newsreader automatically delete all the other messages? > Hah! Some time-saver it is. You forgot the smileys (or )! No, surely not. There are a lot of interesting contributions, opinions and attitudes. I try to at least throw a quick eye on everything. But it's not easy: after I re-established a mail gateway machine around here, which has been down for around five days, I got a flurry of maybe 6000 messages, and my Python mailgroup only got over 1000 for a while. Now back below 100, but some messages are very difficult to get rid of, as they are so informational that I hardly want to even file them away for later study... You are too interesting, guys! > I used to use nn (NoNews). Now THAT was a good newsreader -- or news > ignorer as the case may be. [...] For users, this is cake, and always have been so far that I know. On the other hand, (and I do not know where `nn' stands nowadays), I do remember that many years ago, for a system administrator, `nn' was sometimes turning into pure frantic nightmare. When things were starting to go wrong, rebuilding indices and everything was taking _days_ of machine time (machines were also much slower than in these days.) Many years ago, I've been hired by a group that gave me the mandate of finding a way to gracefully untangle `nn' from their system, while keeping their users happy. It was a difficult undertaking for the poor little me! :-) > In most newsreaders the default is to read every message; in NN the > default is to ignore every message. I'm not going to give in a newsreader war, and I guess that best ideas just flood into all newreaders after a while. Gnus is immensely configurable, and I'm confident that users could do almost whatever we want with it. I use it to read my mail, search databases, and a few other things. Even, sometimes, not often, to read news :-). On the user side, I would easily bet that `nn' is faster, but on reasonable machines, Gnus is very workable. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From greg.ewing at compaq.com Tue Nov 2 07:23:03 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Wed, 03 Nov 1999 01:23:03 +1300 Subject: Comparison between Python and "Ruby" References: <1270663667-24391282@hypernet.com> Message-ID: <381ED7A6.D7D7FB13@compaq.com> Gordon McMillan wrote: > > That's the Perler's war cry. Snort. As if there was only one > way to have more than one way to do it. Okay, so the Python war cry should be TMTOWTHMTOWTDI (There's More Than One Way To Have More Than One Way To Do It). Greg From a.eyre at optichrome.com Mon Nov 29 08:42:35 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Mon, 29 Nov 1999 13:42:35 -0000 Subject: help with opening html files In-Reply-To: <028601bf3a5d$31abdea0$f29b12c2@secret.pythonware.com> Message-ID: <000a01bf3a6f$982ead80$3acbd9c2@peridot.optichrome.com> >> Can anyone tell me how to open a html file from within python in >> windows. > html files are text files, and can be handled > in the usual way. see chapter 7 in the tutorial > for more info: Unless you want to open one from the web, in which case, have a look at httplib. -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From mhammond at skippinet.com.au Fri Nov 26 07:31:16 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 26 Nov 1999 12:31:16 GMT Subject: dir() and propertly list NEWBIE References: <199911261153.LAA07241@cobweb.quantisci.co.uk> Message-ID: Steve M S Tregidgo wrote in message <199911261153.LAA07241 at cobweb.quantisci.co.uk>... >Donn Cave wrote: >> Quoth tiddlerdeja at my-deja.com: >> [snip] >> | Similarly, If I can get an objects functions, is it possible then >get a >> | list of the possible parameters for that function? >> >> No! Wouldn't that be nice? >Take a look at the function's attribute 'func_code'. Within this Or even better - use IDLE or Pythonwin - you can (usually :) type the function name and have a short description and the parameter list pop up. Mark. From m.faassen at vet.uu.nl Tue Nov 16 06:11:41 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 16 Nov 1999 11:11:41 GMT Subject: Proposal: Python Info Collective References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> <80oqn9$ocq$2@newshost.accu.uu.nl> <80p9su$ppo$2@newshost.accu.uu.nl> <80piru$13rl$1@hub.org> Message-ID: <80re5d$55a$1@newshost.accu.uu.nl> T. wrote: > On 15 Nov 1999 15:46:38 GMT, Martijn Faassen wrote: >>mature enough, Parnassus can have a flag somewhere 'distutils compatible' >>or something like that for each module/program in its database. > Yeesh! Got about a hundred times more hits on my web site today than i've > ever gotten. And now i'm posting ten times more usenet messages in one > day than i usually do in a week or a month or more! Grumble grumble. (-; You're hard to keep track of too, your listed email address keeps changing! Getting-curious-about-the-person-with-the-mysteriously-changing-name-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From aahz at netcom.com Wed Nov 10 12:15:41 1999 From: aahz at netcom.com (Aahz Maruch) Date: 10 Nov 1999 17:15:41 GMT Subject: Python company worth $100M References: <38295BC2.13E2E31F@digicool.com> <033201bf2b73$ad1e49e0$f29b12c2@secret.pythonware.com> Message-ID: <80c97t$r6$1@nntp9.atl.mindspring.net> In article <033201bf2b73$ad1e49e0$f29b12c2 at secret.pythonware.com>, Fredrik Lundh wrote: > > [ Searchbutton.com ] >and if you look at the technical credits page, what do you >find? > > http://www.searchbutton.com/misc/technicalCredits > >asynclib again, of course ;-) Actually, we're moving away from asyncore in favor of threads. Unless we're missing something obvious, asyncore just doesn't do well with compute-heavy processes. -- > I wrote: > > a slightly hairer design issue is what combinations > > of pattern and string the new 're' will handle. > From ivanlan at callware.com Sat Nov 6 13:23:54 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Sat, 06 Nov 1999 11:23:54 -0700 Subject: making the Python case to my dept. References: <9911051740130D.02530@william.jinsa.org> <3823FC43.CF7FBD71@python.net> <801p3q$q01$1@nntp2.atl.mindspring.net> Message-ID: <3824723A.5DE35FE5@callware.com> Hi All-- Aahz Maruch wrote: > > First of all, I want to second Patrick's suggestion that this be FAQ'd. > I have one nit, though: > > In article <3823FC43.CF7FBD71 at python.net>, > Thomas A. Bryan wrote: > > > >Still, few people are knocking down my door for Python programmers > >while there are plenty of jobs for C++/Java/Delphi programmers. > > I believe that there are more jobs for good Python programmers than > people with the skills to fill them. My company is certainly having > difficulties (jobs in Mountain View! ask me!), and having HP Cupertino > advertising for 10-12 Python positions only increases the difficulty. > > I think we've come to the knee in the curve where Python has achieved > critical mass and will get a lot of popular attention over the next > couple of years. Few of us need worry about job security. > - I really hope that Aahz is correct. As most of you know, I'm stuck out here in Utah, which is widely known to be significantly behind *any* curve you want to name. If there's a curve coming to Utah, I sure hope it will be one with jobs for Pythonistas, because there certainly aren't *any* here now. -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From aa8vb at yahoo.com Mon Nov 1 11:12:31 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Mon, 1 Nov 1999 11:12:31 -0500 Subject: Regex problem with multiline matches In-Reply-To: <14361.62318.90382.177379@dolphin.mojam.com> References: <19991029150848.A106981922@vislab.epa.gov> <14361.62318.90382.177379@dolphin.mojam.com> <0e2601bf2245$126cef00$0100a8c0@rochester.rr.com> <19991029150848.A106981922@vislab.epa.gov> <14361.62318.90382.177379@dolphin.mojam.com> Message-ID: <19991101111231.B133876404@vislab.epa.gov> Skip Montanaro: |Randall Hopper: | >>>> print re.compile( "b(.)", re.M ).match( "aa\nbb" ) | None | |The match method anchors the search at the beginning of the string. Try the |search method instead: | | >>> print re.compile( "b(.)", re.M ).search( "aa\nbb" ) Thanks. I should have caught that in the docs. 'match' just didn't register as really 'match_prefix' or 'match_at_beginning_of_line'. Darrell: |Or | |>>> print re.compile( "(?s).*?b(.)").match( "aa\nbb" ) Hey that's slick! Learn something new every day. Just change the interpretation of period so it can eat newlines too. Thanks guys! -- Randall Hopper aa8vb at yahoo.com From bernhard at alpha1.csd.uwm.edu Tue Nov 30 13:21:56 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 30 Nov 1999 18:21:56 GMT Subject: XPython (X11) References: <383E5350.1E07536A@xrce.xerox.com> <81ms2n$126$1@essle.valdyas.org> <81vs99$g8$1@essle.valdyas.org> Message-ID: On 30 Nov 1999 06:53:29 GMT, Boudewijn Rempt wrote: >Bernhard Reiter wrote: >> On 26 Nov 1999 20:54:47 GMT, Boudewijn Rempt wrote: >>>Bernhard Reiter wrote: >> And I didn't mention pyGNOME, why should I mention to PyKDE? >Because the two go together - you did mention PyGTK. True. But I was thinking GUI libraries. The gnome libraries are If I am still informed correclty a lot more then that. >> To create an application tied to KDE or GNOME is a mistake in my >> eyes anyway. >Oh, yes, people will agree with you. No sadly enough, they don't. They write every application a couple of times. At least once for GNOME and KDE and then there is always the forgotten version, makes at least a trippe effort. (I know I know there are reasons to reimplement sometimes, I am not arguing these cases.) >I've one regular correspondent >who berates me continually for not writing my apps to run inside >a browser. Well a browser is a very limited application development platform. I think it is overrated and born because people (esp.) made it hard to develop portable software. >I don't really care, though - sometimes I need an >application that's integrated with the rest of my work environment, >and sometimes I can do with something standalone. People are so trained in bad user interfaces that they don't value got ones. And the web is not a good user interface for a lot things. >> people-will-love-it-any-way-ly, yours >They do, they do, too... ;-). Perceiving-it-as-a-two-edge-sword-ly, yours Bernhard -- Research Assistant, Geog Dept UM-Milwaukee, USA. (www.uwm.edu/~bernhard) Free Software Projects and Consulting (intevation.net) Association for a Free Informational Infrastructure (ffii.org) From a.eyre at optichrome.com Tue Nov 16 08:45:01 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Tue, 16 Nov 1999 13:45:01 -0000 Subject: Platform independent? (Was: Drawing (directed) graphs) In-Reply-To: <14371.2783.885109.27130@weyr.cnri.reston.va.us> Message-ID: <004101bf3038$c7d96c00$3acbd9c2@peridot.optichrome.com> >> This is why it annoys me that some of the scripts in the >> standard Python library are not platform independent, but >> rely on non-portable features of posix. > If you know of ways to reduce the platform-dependence of these, > please feel free to submit patches! I'm sure a lot of the base SocketServer stuff could be rewritted to use the select module (which will port to Win32). The other alternative (if this is not possible) is to move any scripts in Python's Lib/ directory which are dependent on posix into a subdirectory called plat-posix/ much like the plat-win/ stuff. -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From wtanksle at hawking.armored.net Sat Nov 27 14:41:28 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 27 Nov 1999 19:41:28 GMT Subject: Type/Class Unification in Ruby References: <3819BCDA.AC4FD4CA@strs.co.uk> <87k8o2x67f.fsf@ev.netlab.co.jp> <7vjtrc$hmm$1@newshost.accu.uu.nl> <38204614.2EAC6051@compaq.com> <5ld7trtak5.fsf@eric.cnri.reston.va.us> <3826D63C.2731BB1F@compaq.com> <38328948.9E35556F@compaq.com> <38356C74.F9E4248D@compaq.com> <14397.64943.791678.643871@anthem.cnri.reston.va.us> Message-ID: On Thu, 25 Nov 1999 22:25:35 -0500 (EST), Barry A. Warsaw wrote: >>>>>> "GE" == Greg Ewing writes: > GE> A middle ground might be to allow inheriting from any number > GE> of user-defined classes, but at most one built-in type. >And in fact, this is exactly the JPython restriction. Because Java >has only single inheritance, a JPython class can only have a single >Java base class, but any number of pure Python base classes. Another possibility would be to borrow from Sather by making all inheritance actually act like interface inheritance with delegation. In other words, JPython creates an interface for every class, and when you inherit you actually implement and then add a member data thingie. >-Barry -- -William "Billy" Tanksley From wtanksle at hawking.armored.net Sat Nov 27 14:45:46 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 27 Nov 1999 19:45:46 GMT Subject: Python complaints References: <38397696@news.xtml.co.uk> <221119992150405215%zippy@cs.brandeis.edu> <383a8909@news.xtml.co.uk> Message-ID: On Tue, 23 Nov 1999 12:38:36 -0000, Nick Trout wrote: >How do you write large/complicated applications in Lisp, the syntax with all >those brackets drives me mad! Just ignore them -- pretend you're writing Python. Let the indentation guide you. If you pay attention to the parens you WILL go mad. >I've never heard of this clever type checking. It sounds like a very good >idea. It would be nice to be able to choose whether to have typing on or >off. I know you can run a Lint checker over Python but whats a compiler >for?! Lisp is truly amazing. Anything that's cool in any language existed in Lisp before, and probably is still more usable in Lisp. >N -- -William "Billy" Tanksley From helge.hess at mdlink.de Tue Nov 30 13:29:04 1999 From: helge.hess at mdlink.de (Helge Hess) Date: Tue, 30 Nov 1999 19:29:04 +0100 Subject: Python Make References: <3843E558.8AC91A97@strs.co.uk> Message-ID: <38441770.80C33C93@mdlink.de> Hi, Ian Clarke wrote: > > Hi, just a quick idea I had that I wanted to share with the newsgroup. > Has anyone considered using Python as a replacement for the "make" > utility? A module could be provided which did several small things like > testing modification times of a list of source files against a > destination file to see whether an update was required. YES! I had the same idea :-) > I am prompted to suggest this after spending yet another half-day trying > to debug a Makefile. > > What do people think? I think it is a pretty cool idea. The negative aspect is that one needs python for compilation then (eg you can't compile python using 'python' makefiles). I also wonder about a nice Python syntax for doing this. Did you think about this issue already ? A simple makefile should look as easy as a usual Makefile, maybe like this: a = Source('a.c') b = Source('b.c') c = Source('c.c') def compileC(source): gcc(source) all = { 'dependsOn': ( a, b, c), 'action': compileC } Hm, looks somewhat strange and a powerful 'make' framework needs to be thought out first. Greetings Helge -- SKYRIX-OS Web Application Environment - http://www.skyrix.com SKYRIX-IAS Groupware Application Suite - http://www.skyrix.com From thomas at xs4all.nl Fri Nov 5 04:22:33 1999 From: thomas at xs4all.nl (Thomas Wouters) Date: Fri, 5 Nov 1999 10:22:33 +0100 Subject: __str__ vs. __repr__ In-Reply-To: <000001bf275c$02370d20$1d2d153f@tim>; from tim_one@email.msn.com on Fri, Nov 05, 1999 at 02:04:30AM -0500 References: <199911041325.IAA14001@eric.cnri.reston.va.us> <000001bf275c$02370d20$1d2d153f@tim> Message-ID: <19991105102233.I29354@xs4all.nl> On Fri, Nov 05, 1999 at 02:04:30AM -0500, Tim Peters wrote: > and Python's European groupies didn't bitch enough about > repr(euro_string) being an unreadable backslashed mess. We're too busy bitching about the idiocy of people who expect to change a country's (usually) ancient currency, habits and not to mention every keyboard, font and accountancy software in the world in a matter of years. Or perhaps we just dont _care_ about the euro symbol. Your Euro symbol, by the way, Tim, ended up as '?' in my font -- but possibly because isprint() returned 0 and my mail-reader therefor refused to print it ;) Oh, and we bitch about why they had to rotate the Quake II logo 90 degrees, too. I think acceptance of the logo would have been easier if it'd been sitting up straight. ISO-8859-15-aka-Latin-9'ly y'rs, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From levicook at earthlink.net Tue Nov 30 12:20:06 1999 From: levicook at earthlink.net (Levi Cook) Date: Tue, 30 Nov 1999 11:20:06 -0600 Subject: ? on working with http redirects in htmllib Message-ID: <821146$266$1@ash.prod.itd.earthlink.net> Does anyone know how to process and follow a redirect in python? I can easily tell if I've recieved the 301 or 302 errcode, but I cannot for the life of me figure out how to get the URL of the new destination. Any help is greatly appreciated. - Levi Cook ##### code snippet that i use to retrieve pages... import httplib, urllib address = 'http://www.python.org/doc/current/lib/node227.html' URL2Fetch = urlparse.urlparse( address ) # fetch page h = httplib.HTTP(URL2Fetch[1]) h.putrequest('GET', URL2Fetch[2]) h.putheader('Accept', 'text/html') h.putheader('Accept', 'text/plain') h.endheaders() errcode, errmsg, headers = h.getreply() # script only knows how to process html if not headers.gettype() == 'text/html': raise redirect(address) f = h.getfile() data = f.read() # Get the raw HTML f.close() From jae at ilk.de Sun Nov 7 16:28:31 1999 From: jae at ilk.de (Juergen A. Erhard) Date: Sun, 07 Nov 1999 22:28:31 +0100 Subject: pythonistas or pythoneers? Message-ID: <07111999.2@sanctum.jae> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I'm confused: are we pythoneers or pythonistas? I tend to go for pythoneers... sounds more pythonic. Or are these two levels of experience? If so, what's higher? Confused, Bye, J PS: Of courthe, my thongue wath firmly lodthed in my theek while I wrote thith... - -- J?rgen A. Erhard eMail: jae at ilk.de phone: (GERMANY) 0721 27326 MARS: http://members.tripod.com/~Juergen_Erhard/mars_index.html "Outside of a dog, a man's best friend is a book; inside of a dog, it's very dark." -- Groucho Marx -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.0 (GNU/Linux) Comment: For info see http://www.gnupg.org iEYEARECAAYFAjgl7v0ACgkQN0B+CS56qs1dNACeOdnrX6Iu5upos7+g6NkbPaWl 2aEAnie43H0TH9tAJRB1tc6nfl0LnfQO =QUO3 -----END PGP SIGNATURE----- From fdrake at acm.org Wed Nov 24 09:22:02 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Wed, 24 Nov 1999 09:22:02 -0500 (EST) Subject: whrandom seed question In-Reply-To: <000601bf3645$a8dc0ca0$f82d153f@tim> References: <81eu22$411al$1@umbc7.umbc.edu> <000601bf3645$a8dc0ca0$f82d153f@tim> Message-ID: <14395.62602.126765.991856@weyr.cnri.reston.va.us> Tim Peters writes: > Don't use module whrandom. Use module random. The former is an > implementation detail of the latter, and follows the fine scientific > tradition of using incomprehensible calling conventions <0.5 wink>; whrandom > isn't meant to be used directly; random is; someday the docs will catch up For the record, I intend to have the docs for random and whrandom fixed up before the next documentation release. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From greg.ewing at compaq.com Mon Nov 8 06:14:12 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Tue, 09 Nov 1999 00:14:12 +1300 Subject: A newbie dictionary question References: Message-ID: <3826B084.20F9B58D@compaq.com> Jan Vroonhof wrote: > > def __cmp__(self,other): > return self.nospaces() == other.nospaces() A __cmp__ function is supposed to return -1, 0 or 1 corresponsing to less than, equal to or greater than. Try it this way: def __cmp__(self,other): return cmp(self.nospaces(), other.nospaces()) Greg From robin at alldunn.com Fri Nov 19 12:43:28 1999 From: robin at alldunn.com (Robin Dunn) Date: Fri, 19 Nov 1999 09:43:28 -0800 Subject: Building wxPython [was Re: wxPython and DISLIN work nicely together] References: <80s0b4$g5n@mail.psy.uva.nl> <19991117090214.B807152@vislab.epa.gov> <017a01bf31f8$6bbea590$1a25d2d1@jenkondev.com> <19991119064944.A996886@vislab.epa.gov> Message-ID: <002301bf32b5$97a5d440$0301a8c0@easystreet.com> What is the output of "wx-config --cflags" ? It should have the right include directories for getting all the wxWindows headers. Oh wait a minute, it says "/bin/sh: wx-config: not found" so it looks like you didn't do a "make install" for wxGTK. Robin ----- Original Message ----- From: Randall Hopper To: Robin Dunn Sent: Friday, November 19, 1999 3:49 AM Subject: Re: wxPython and DISLIN work nicely together > Robin Dunn: > |> > |> If only wxPython would build on IRIX... > |> > | > |Did you have build issues with wxWindows or did you get as far as trying to > |build wxPython? If so, what were the troubles? > > I've attached a message that describes the problem I had with it when I put > it aside. Tips appreciated. > > Randall > From g_will at cyberus.ca Sat Nov 27 08:59:43 1999 From: g_will at cyberus.ca (Gordon Williams) Date: Sat, 27 Nov 1999 13:59:43 GMT Subject: Pythonwin Reset Message-ID: <01bf38df$8127e0c0$3a42c3d1@Cyberus.cyberus.ca> Hello All, Is there a way to reset Pythonwin IDE between runs. I want to eliminate any rogue objects or modules that are still in memory from the previous run of the program. Thanks Gordon Williams From jam at quark.emich.edu Tue Nov 16 07:23:56 1999 From: jam at quark.emich.edu (Jeff) Date: Tue, 16 Nov 1999 07:23:56 -0500 Subject: Alright, I give up...chalk this one up to experience... In-Reply-To: <383145c0.4445469@212.225.36.99> References: <383145c0.4445469@212.225.36.99> Message-ID: <19991116072356.A16111@quark.emich.edu> On Tue, Nov 16, 1999 at 11:56:28AM +0000, Endgamer wrote: > Alright, I finally give up. I've been bashing at this bloody idea all > week...maybe I'm incredibly stupid (probably), but I can't see why, > when I run this as a script from Windows 95, it doesn't return the > current date setting on my machine. Could somebody put me out of my > misery? I promise I'll stop bothering you . > > ------------------------------------------------------- > > # Date setting program (chunk 1) > import os > > olddate=os.popen("date",'r') > > olddate=readdate > > print olddate > > ------------------------------------------------------- > I'm pretty sure the issue of setting the date on a win32 machine has been brought up before in this newsgroup, and I would strongly advise doing a search on deja.com as well as python.org to see what other resources you can find. I would suggest, however, that if you want to *query* the current date and time setting of the machine that you not use 'popen'.. try the 'time' module instead: [~] [7:56pm] [jam at toast-pts/2] % 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 time >>> print time.ctime.__doc__ ctime(seconds) -> string Convert a time in seconds since the Epoch to a string in local time. This is equivalent to asctime(localtime(seconds)). >>> print time.time.__doc__ time() -> floating point number Return the current time in seconds since the Epoch. Fractions of a second may be present if the system clock provides them. >>> print time.ctime(time.time()) Tue Nov 16 07:23:04 1999 regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From init__self at my-deja.com Mon Nov 8 11:45:49 1999 From: init__self at my-deja.com (init__self at my-deja.com) Date: Mon, 08 Nov 1999 16:45:49 GMT Subject: pythonistas or pythoneers? References: <07111999.2@sanctum.jae> <382633B1.50993D93@callware.com> Message-ID: <806unr$6qp$1@nnrp1.deja.com> > No way - we are all Pythoneers at the frontiers for computer > science... ;) Wouldn't that be a Pyoneer then? Sent via Deja.com http://www.deja.com/ Before you buy. From htrd90 at zepler.org Thu Nov 11 17:39:24 1999 From: htrd90 at zepler.org (Toby Dickenson) Date: Thu, 11 Nov 1999 22:39:24 +0000 Subject: Running a program as another user on Win32 References: <809ea4$ln$1@nnrp1.deja.com> Message-ID: "Mark Hammond" wrote: >emuller at painewebber.com wrote in message <809ea4$ln$1 at nnrp1.deja.com>... >>I am writing a bunch of scripts that will need to run as Administrator >>(Domain Administrator) on Windows NT 4.0 workstation clients that >>belong to an NT domain. I've tried using LogonUser, but I always get >>the following: pywintypes.api_error: (1314, 'LogonUser', ' A required >>privilege is not held by the client.'). I've also tried using LogonUser >>with the local Administrator account on my NT machine with no luck. > >You need to explicitely enable the privilege. .... LogonUser should enable any priviledges not held by the process as required. However you do need to grant the priviledge to the user who will be running your script; "Act as part of the operating system" in this case. Yes, even Administrators do not have this priviledge by default. The System account does, so your existing script should work if it's running as a service. hope this helps, Toby Dickenson From pinard at iro.umontreal.ca Tue Nov 2 09:36:06 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 02 Nov 1999 09:36:06 -0500 Subject: Assorted Questions regarding the future of Python... In-Reply-To: "Fredrik Lundh"'s message of "Tue, 2 Nov 1999 10:47:39 +0100" References: <6D8A17398E28D3119F860090274DD7DB49833A@pces.cadlab.it> <006201bf2517$50edf1f0$f29b12c2@secret.pythonware.com> Message-ID: "Fredrik Lundh" writes: > as far as I know, there are no visible projects working on faster ways > to execute that [PYC] code, but that doesn't mean that they don't exist ;-) I'm curious. Does Python use standard optimisation techniques on that byte code (CSE, strength reduction, and all that)? I would be tempted to guess that the stack machine receives code that pretty closely resemble the source code. Would the stack machine be able to express optimisations? For example, could we copy or exchange arbitrary stack elements? If yes, maybe one could attempt filtering a `.pyc' through an optimiser, at least for a long experimental phase, with the hope of having the optimiser integrated right into Python, one of these later days. If no, would Guido be favourable at opening the door by adding a few more stack machine instructions, even if not using them himself, to start with? -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From hnowak at cuci.nl Mon Nov 8 17:36:10 1999 From: hnowak at cuci.nl (Hans Nowak) Date: Mon, 8 Nov 1999 23:36:10 +0100 Subject: Image buttons with Tkinter In-Reply-To: <38270596.A391995C@parlant.com> Message-ID: <199911082238.XAA06869@dionysus.fw.cuci.nl> On 8 Nov 99, at 10:17, Thomas Lane wrote: > I'm trying to create a button that displays an image instead of text, but > I don't seem to be having any luck. The button just comes up gray. Here is > a code snippet of what I'm trying to do: > > # Put remove.gif on a button (actionbar is a frame for various > controls) > deletebutton = Button(actionbar,image=PhotoImage(file="remove.gif")) > deletebutton.place(x=0) This code worked for me (I threw in a label so the button will be clearly visible rather than taking up the whole frame): #-------------------------- # button-with-gif.py from Tkinter import * root = Tk() image1 = PhotoImage(file='burger.gif') button = Button(root, image=image1) button.pack() Label(root, text="Bwahahaha").pack() root.mainloop() #------------------------ > What am I doing wrong here? Dunno, it looked good to me, although I never use the 'place' thingy. > Also, is there a place on the net where I can find lots of sample > Python/Tkinter code? I've read Fredrik Lundh's intro, but I haven't been > able to find any other code or reference material for Tkinter. As far as I know, the Tk introduction is about the best you can get at the moment. --Hans Nowak (zephyrfalcon at hvision.nl) Homepage: http://fly.to/zephyrfalcon You call me a masterless man. You are wrong. I am my own master. From boud at rempt.xs4all.nl Tue Nov 30 01:53:29 1999 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 30 Nov 1999 06:53:29 GMT Subject: XPython (X11) References: <383E5350.1E07536A@xrce.xerox.com> <81ms2n$126$1@essle.valdyas.org> Message-ID: <81vs99$g8$1@essle.valdyas.org> Bernhard Reiter wrote: > On 26 Nov 1999 20:54:47 GMT, Boudewijn Rempt wrote: >>Bernhard Reiter wrote: >>> On Fri, 26 Nov 1999 10:30:56 +0100, Emmanuel Pietriga wrote: >>> If I want to program a GUI I look in to wxPython. >>> Or pyGtk or pyFOX or pyFLTK, but XPython... :) >>Hey! Don't forget PyQt and PyKDE (and PyQt seems to be >>working under Windows, too, nowadays)... > Do you have to but the Troll Kit first? >:) Sorry, I'm a bit late - I've only just now recovered from reading the interview with Guido in Linux Journal where he says he thinks PyKDE/PyQt is no longer developed. Yes, to compile the stuff for Windows you need Qt for Windows. Of course, you also need a compiler, and those seem to cost money, too. > And I didn't mention pyGNOME, why should I mention to PyKDE? Because the two go together - you did mention PyGTK. > To create an application tied to KDE or GNOME is a mistake in my > eyes anyway. Oh, yes, people will agree with you. I've one regular correspondent who berates me continually for not writing my apps to run inside a browser. I don't really care, though - sometimes I need an application that's integrated with the rest of my work environment, and sometimes I can do with something standalone. > people-will-love-it-any-way-ly, yours They do, they do, too... ;-). > Bernhard -- Boudewijn Rempt | http://denden.conlang.org From m.faassen at vet.uu.nl Mon Nov 15 06:27:37 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 15 Nov 1999 11:27:37 GMT Subject: Proposal: Python Info Collective References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> Message-ID: <80oqn9$ocq$2@newshost.accu.uu.nl> Jules Allen wrote: > In article <3d1z9sq2uc.fsf at amarok.cnri.reston.va.us>, Andrew M. Kuchling wrote: > | The issue of indexing modules is an old one, and I'm still astounded > | that we've never converged on a solution, though everyone always > | complains about this. > Thanks for the History lesson! This helps put it all in perspective > but why *something* hasn't been built before now is kind of weird. > The best part of your story for me is confirmation that open source > projects don't do well without strong leadership. No ESR or an > ESR-like figure to crack the whip, no Trove. Actually, 'strong leadership' is not enough. If someone cracks his whip impressively in open source but doesn't write any code himself, you won't get any software in the end. So you need someone who actually takes on the responsibility for writing the code. :) [Vaults of Parnassus] Browses through them eagerly and curiously. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From bjorn at roguewave.com Mon Nov 29 16:49:24 1999 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Mon, 29 Nov 1999 14:49:24 -0700 Subject: Htmlizing text Message-ID: <51C9F3C392D0D111A15600A0C99E64A9AF569F@localhost> > Is there a function in the standard Python library to HTML-ize text, > i.e. to replace 'a > b & c < d' with 'a > b & c < d'? This is the one I use (look for text2html below). It does a little bit more than what you asked for, like turning URLs into clickable links, changing *word* to italicized etc. (and yes, it's extracted almost verbatim from the faqwizard :-) -- bjorn import string import re def translate(text, pre=0): translate_prog = prog = re.compile(r'\b(http|ftp|https)://\S+(\b|/)|\b[-.\w]+@[-.\w]+') i = 0 list = [] while 1: m = prog.search(text, i) if not m: break j = m.start() list.append(escape(text[i:j])) i = j url = m.group(0) while url[-1] in '();:,.?\'"<>': url = url[:-1] i = i + len(url) url = escape(url) if not pre: if ':' in url: repl = '%s' % (url, url) else: repl = '<%s>' % (url, url) else: repl = url list.append(repl) j = len(text) list.append(escape(text[i:j])) return string.join(list, '') def escape(s): s = string.replace(s, '&', '&') s = string.replace(s, '<', '<') s = string.replace(s, '>', '>') return s def escapeq(s): s = escape(s) s = string.replace(s, '"', '"') return s def emphasize(line): return re.sub(r'\*([a-zA-Z]+)\*', r'\1', line) def text2html(body): res = [] pre = 0 raw = 0 for line in string.split(body, '\n'): tag = string.lower(string.rstrip(line)) if tag == '': raw = 1 continue if tag == '': raw = 0 continue if raw: res.append(line) continue if not string.strip(line): if pre: res.append('') pre = 0 else: res.append('

') else: if line[0] not in string.whitespace: if pre: res.append('') pre = 0 else: if not pre: res.append('

')
                    pre = 1
            if '/' in line or '@' in line:
                line = translate(line, pre)
            elif '<' in line or '&' in line:
                line = escape(line)
            if not pre and '*' in line:
                line = emphasize(line)
            res.append(line)
    if pre:
        res.append('
') pre = 0 return string.join(res) From fredrik at pythonware.com Fri Nov 12 10:06:38 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 12 Nov 1999 16:06:38 +0100 Subject: Tkinter PhotoImage Question References: <382C29D7.DBA3E66@callware.com> Message-ID: <009801bf2d1f$85953ed0$f29b12c2@secret.pythonware.com> Ivan Van Laningham wrote: > Ok, I've managed to create an image, using xx=PhotoImage(file), and I > can retrieve pixel values from that image using xx.get(x,y). > > Now I want to use the put() method to write a pixel. > > How do I do that? I would have expected that put() would take a string > of pixel values for the data argument, but that doesn't seem to be the > case. ... from the eff-bot archives: # # create a greyscale ramp using pure Tkinter # # fredrik lundh, january 1998 # # fredrik at pythonware.com # http://www.pythonware.com # from Tkinter import * # must initialize interpreter before you can create an image root = Tk() data = range(256) # 0..255 im = PhotoImage(width=len(data), height=1) # tkinter wants a list of pixel lists, where each item is # a tk colour specification (e.g. "#120432"). map the # data to a list of strings, and convert the list to the # appropriate tuple structure im.put( (tuple(map(lambda v: "#%02x%02x%02x" % (v, v, v), data)),) ) # resize the image to the appropriate height im = im.zoom(1, 32) # and display it w = Label(root, image=im, bd=0) w.pack() mainloop() # after playing with this a little, you'll love # the Python Imaging Library. From ivanlan at callware.com Mon Nov 8 10:33:04 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Mon, 08 Nov 1999 08:33:04 -0700 Subject: Graphics. References: <3826E949.BBA1BAFD@imf.au.dk> Message-ID: <3826ED30.70FBE3D3@callware.com> Hi All, Emil-- Emil Hedevang Lohse wrote: > > How do I draw some graphics on a screen using Python running on > HP-UX > MacOS > Windows > Use the Tkinter Canvas widget. Start at http://www.pythonware.com & check out the docs. -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From tim_one at email.msn.com Wed Nov 17 03:56:35 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 17 Nov 1999 03:56:35 -0500 Subject: docs In-Reply-To: <14385.28690.800102.134431@weyr.cnri.reston.va.us> Message-ID: <000501bf30d9$a6e93100$a42d153f@tim> [Tim] > Ask MS for the source code . Short of that, there's no reason to > suppose it's a problem with the docs, and every reason to suspect the > obvious. [Fred L. Drake, Jr.] > The catch is that no matter how obvious it is, I don't want to lock > people out of the docs by requiring they update to a newer service > pack; ... No, I doubt the service pack has anything to do with it. What's "obvious" in the MS world is that it's a random bug that maybe 1 person in 1000 can reproduce. That's par for the MS course! Or did many people report the same problem with NT SP4? I saw one report here, and a partial possible kinda confirmation . I certainly never had this problem under any flavor of NT or of IE. The usual MS fix is to scandisk, defrag, clear all the caches, and reinstall stuff from scratch. And I haven't had more than 8 browser bugs that weren't eventually cured by reformatting my hard drives . otoh-my-sister-has-never-gotten-netscape-to-work-right-ly y'rs - tim From mwh21 at cam.ac.uk Mon Nov 1 08:35:53 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 01 Nov 1999 13:35:53 +0000 Subject: How can I make my assertions smarter? References: <381D7087.BF8510E5@webone.com.au> Message-ID: Stuart Hungerford writes: > Hi all, > > I'm using some simple functions to implement crude precondition, > postcondition and invariant checking in Python classes. > > (Tim: please be gentle ;-) > > Is there some neat way to wrap these tests up so I can print any > code expression that fails, e.g: > > Precondition failed foo.py line 42: spoon.shape == 'bent' > > which would appear at line 42 of foo.py as > > pre(spoon.shape == 'bent') Hmm... tricky. Something like this might work (tho' not with python -O, not that that should be a problem). chuck it in a file called "pre.py". It will have problems with line continutations & stuff, but I did just make it up on the spot (well, about half an hour of spot; must now do something of some use). class PreconditionViolation(AssertionError): def __init__(self,why): AssertionError.__init__(self,why) def pre(cond): if cond: return try: raise "" except: import sys frame = sys.exc_traceback.tb_frame.f_back lineno = frame.f_lineno filename = frame.f_code.co_filename try: import re file = open(filename) for i in range(lineno): line = file.readline() match = re.match("\W*(pre\.)?pre\((.*)\);?\W*$",line) if match is not None: line = match.group(2) else: import string line = string.strip(line) except: line = "" line = "line %d of %s: %s"%(lineno,filename,line) raise PreconditionViolation, line def checked_sqrt(x): from math import sqrt pre(x>=0) return sqrt(x) if __name__=='__main__': print checked_sqrt(2) print checked_sqrt(-1) then `python pre.py' gives: 1.41421356237 Traceback (innermost last): File "pre.py", line 39, in ? print checked_sqrt(-1) File "pre.py", line 34, in checked_sqrt pre(x>=0) File "pre.py", line 30, in pre raise PreconditionViolation, line __main__.PreconditionViolation: line 34 of pre.py: x>=0 but, really, what's wrong with asserts? Another approach would be to poke around with frame.f_lasti and decompile the bytecode (!). > I can see how to use environment variables or global variables to > selectively enable precondtions etc, although any hints for doing that > would be appreciated too. That should be pretty straightforward. > Thanks in advance, > > Stu HTH, Michael From JamesL at Lugoj.Com Thu Nov 25 00:03:19 1999 From: JamesL at Lugoj.Com (James Logajan) Date: Wed, 24 Nov 1999 21:03:19 -0800 Subject: Python complaints References: <383979F7.25D6@cs.bham.ac.uk> <81fsab$2b$1@news.udel.edu> Message-ID: <383CC317.21B89F4C@Lugoj.Com> Alexander Williams wrote: > > On 24 Nov 1999 05:15:55 GMT, Terry Reedy wrote: > >You are currently welcome to save 3 keystrokes (rather than 4) > >by naming the method parameter 's' instead of 'self'. The latter > > In a fit of lazy genius, I struck upon using 'me' instead; its a more > active referent /and/ faster to type than 'self.' :) But shouldn't you use the possessive form: "my"? Example: class C: def F(my, arg): print my.arg versus: class C: def F(me, arg): print me.arg (The latter comes out sounding like a crusty old sailer!) From olivier at scripps.edu Wed Nov 10 16:23:38 1999 From: olivier at scripps.edu (Olivier Roche) Date: Wed, 10 Nov 1999 13:23:38 -0800 Subject: random function References: <3829D78B.7FC142F4@scripps.edu> <19991110.21195500@robert.polytopic.com> Message-ID: <3829E259.C4A9C6A6@scripps.edu> Robert Meegan wrote: > Olivier - > > The is both a random and a whrandom module included with the Python > distribution. Both are identified in the Python Library Reference > index. > You are right !! I am sorry, i have look at the Python Reference Manual index. Olivier From tim_one at email.msn.com Tue Nov 16 01:31:41 1999 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 16 Nov 1999 01:31:41 -0500 Subject: docs In-Reply-To: <14380.25301.616025.322479@weyr.cnri.reston.va.us> Message-ID: <000a01bf2ffc$3e70b0e0$042d153f@tim> [Ionel Simionescu, having trouble viewing Python docs] > I have seen it before and I have just checked it again. > > Just open a doc, > say C:\Python\Doc\tut\tut.html, > with Internet Explorer 5.00.2314.1003, > on Windows NT 4.0 SP4, > and refresh it (F5). [Fred L. Drake, Jr.] > I don't see this when using NT4 SP3; can anyone check this for other > service packs? No problem with NT4 SP5. Same IE, but with a long list of patches. > I'm really not sure how to approach this problem. Suggestions from > people more NT-aware than myself? Ask MS for the source code . Short of that, there's no reason to suppose it's a problem with the docs, and every reason to suspect the obvious. ms-is-out-to-crush-python-ly y'rs - tim From malcolmt at smart.net.au Mon Nov 8 22:30:23 1999 From: malcolmt at smart.net.au (Malcolm Tredinnick) Date: Tue, 9 Nov 1999 14:30:23 +1100 Subject: Can't use len() on returned PyList object? In-Reply-To: <3.0.6.32.19991108211217.007cb210@mail.in-gen.net>; from sessile@in-gen.net on Mon, Nov 08, 1999 at 09:12:17PM -0500 References: <3.0.6.32.19991108211217.007cb210@mail.in-gen.net> Message-ID: <19991109143023.A1001@Ridcully.home> On Mon, Nov 08, 1999 at 09:12:17PM -0500, sessile at in-gen.net wrote: > Why can't I use 'len()' to find the length of a list > returned from my new extension module? The error is > shown as: > > TypeError: call of non-function (type int) You have probably used 'len' as an integer variable at some point previously in the program. This would have overwritten the builtin declaration of len as a function. You can test this in the interpreter by seeing what type(len) returns (or even just print len). Programmatically, see if type(len) == type(1). If it does then you (or one of your imported modules) have redefined len. :-( Tracking this sort of thing down can be annoying sometimes, because not only do you have to look through your own program, but also be suspicious of any modules where you did "from module_name import *" (although, of course, you can pretty much eliminate all the standard modules, since they have withstood the test of time for this conflict). Cheers, Malcolm Tredinnick From greg.ewing at compaq.com Mon Nov 8 06:17:19 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Tue, 09 Nov 1999 00:17:19 +1300 Subject: Get parameter by name References: Message-ID: <3826B13F.1C8DFA24@compaq.com> Oleg Broytmann wrote: > > x = "ka" > > how can I get the value of parameter, the name of which is in x ("ka", in > this case)? foo = locals()[x] Greg From mal at lemburg.com Mon Nov 15 03:57:58 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Mon, 15 Nov 1999 09:57:58 +0100 Subject: Production Web Deployment? References: <199911080604.BAA22580@python.org> <14376.24392.828292.926057@dolphin.mojam.com> <80o895$ebn$1@nnrp1.deja.com> Message-ID: <382FCB16.62B9710A@lemburg.com> damien_morton at my-deja.com wrote: > > Im working at a small publishing outfit, and we've been pumping out 80 > million hits a month for www.maximmag.com, from a 266MHz IIS/ASP box. > Weve just moved onto a 3-way clustering server, and expect to be able > to take pretty much anything that can happen. From time to time, our > site get mentioned on TV or by Howard Stern and it goes berserk, but we > expect to be able to handle that too. > > ... > > Ive only tried Python within an obscure branch of WSH called SSH, > without success. I havent tried it as a scripting langauge replacement > for VBscript, but there has to be a significant advantage to re- > educating all the vbscript people I work with. For the work they do, > VBscript is functional and they never seem to complain about it > constraining them. AFAIK, you can use Python as ASP language too, even side-by-side with VBScript. It may well be worth a try... Just for reference, I am working on a Python based web application server which can handle around 20 requests/second on my old AMD K6/266 machine. That's around 1.7 million requests per day or 51 million per month. Take it to a fast dual processor engine and it should pretty much cover your needs using a single machine. Note that it is not Python slowing down these servers, it is usually one or more of these: (a) poor socket implementations (b) poor database connectivity (c) poor overall design -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 46 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From m.faassen at vet.uu.nl Thu Nov 18 05:20:40 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 18 Nov 1999 10:20:40 GMT Subject: Proposal: Python Info Collective References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> <80oqn9$ocq$2@newshost.accu.uu.nl> <80p9su$ppo$2@newshost.accu.uu.nl> <80piru$13rl$1@hub.org> <80re5d$55a$1@newshost.accu.uu.nl> Message-ID: <810jto$lo0$1@newshost.accu.uu.nl> Phil Mayes wrote: > Martijn Faassen wrote in message <80re5d$55a$1 at newshost.accu.uu.nl>... >>T. wrote: >>> On 15 Nov 1999 15:46:38 GMT, Martijn Faassen wrote: >>[snip] >> >>You're hard to keep track of too, your listed email address keeps changing! > Ah, but only the vowels, so we can deduce that it took no more than 6**3 = > 216 people to develop this. No, no, a more extensive deja search indicated to me that this person has posted under other names to the group previously. At least, unless there are 10 people with the same speech patterns posting to comp.lang.python. :) Anyway, it just made me curious. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From paul.robinson at quantisci.co.uk Tue Nov 30 12:59:54 1999 From: paul.robinson at quantisci.co.uk (Paul Robinson) Date: Tue, 30 Nov 1999 17:59:54 +0000 Subject: ? on working with http redirects in htmllib References: <821146$266$1@ash.prod.itd.earthlink.net> Message-ID: <3844109A.789EDC7E@quantisci.co.uk> Levi Cook wrote: > > Does anyone know how to process and follow a redirect in python? > > I can easily tell if I've recieved the 301 or 302 errcode, but I cannot for > the life of me figure out how to get the URL of the new destination. The URL is simply in the "Location" header. so for example (untested code): def actualGet(server, uri): got = 0 while not got: h = httplib.HTTP(server) h.putrequest('GET', uri) h.putheader('Accept', 'text/html') h.endheaders() errcode, errmsg, headers = h.getreply() if errcode == 200: f = h.getfile() got = 1 elif errcode == 302 or errcode == 301: url = headers.getheader('location') #Split into uri and server URL2Fetch = urlparse.urlparse(address) server = URL2Fetch[1] uri = URL2Fetch[2] elif errcode == 404: #Do something else! got = 1 else: raise RuntimeError, ('Unsupported errcode', errcode, errmsg) return f Hope this helps, Paul. From rdu105 at psu.edu Wed Nov 10 03:21:52 1999 From: rdu105 at psu.edu (Rhys Ulerich) Date: Wed, 10 Nov 1999 03:21:52 -0500 Subject: Problem Installing PIL (module search path problem I think) Message-ID: <38292B20.88C82B0@psu.edu> Dumb question I'm sure, but I'm fairly stuck so here goes: I'm trying to install the Python Image Library (PIL) v1.0 Final on my system (mainly for the sake of using the vector drawing program sketch). I've successfully compiled PIL in Python-1.5.2/Imaging-1.0. The installation instructions provided state that the module must then be added to a location where Python can find the PIL library. I'm going to reproduce some of the install instructions here so please humor the length of this post... ---8<---- [from within Python-1.5.2/Imaging-1.0/] 8. To build a dynamically loaded module, just type "make": $ make This will create a file called "_imaging.so". Then type (assuming a standard shell): $ PYTHONPATH=.:./PIL ; export PYTHONPATH $ python >>> import _imaging >>> import Image If both imports works, you've successfully added PIL to your Python environment. 9. Copy the "_imaging.so" module and the contents of the "Imaging/PIL" directory to a suitable place along the Python path. If you're using Python 1.5 or later, the preferred way is to create a "PIL" subdirectory under "site-packages", copy the "PIL.pth" file to "site-packages", and the rest of the files to the new subdirectory. Example: $ cp PIL.pth /usr/local/lib/Python1.5/site-packages $ mkdir /usr/local/lib/Python1.5/site-packages/PIL $ cp _imaging.so PIL/* /usr/local/lib/Python1.5/site-packages/PIL ----8<---- Step 8 listed above works like a charm. Step 9 is what is giving me problems. I couldn't find a Python-1.5.2/site-packages directory so I created one and then followed the example commands in step 9 to put PIL.pth and the _imaging.so library into Python-1.5.2/site-packages. No luck there. So I edited the PYTHONPATH environmental variable so that "PYTHONPATH=.:/usr/local/src/Python-1.5.2/site-packages" but I still had no luck verifying that "import _imaging" and "import Image" would work as they did in installation step 8 above. Any ideas? I'm sure that this is a really simply thing and I'm just not RTCFM (the "correct" manual case of an old favorite). Thank you for your time, Rhys Ulerich From rv at eng.fore.com Wed Nov 24 11:44:20 1999 From: rv at eng.fore.com (Rajesh Vaidheeswarran) Date: 24 Nov 1999 11:44:20 -0500 Subject: whitespace.py module Message-ID: Hello I'm new to the python language, and the newsgroup. So, if this newsgroup is not appropriate for this type of posting, please pardon my ignorance and notify me. I have written up a module called `whitespace.py' available at and a sample program `whitespace' which uses this module, also available at the same URL. The module can be used to check a given file for whitespace problems as defined in the module's documentation (also available as a separate text document at . Please feel free use these, and also to send in your comments on either of these. I would like to know how to submit a module for inclusion into the standard python distribution, and would appreciate any pointers in that direction. Thanks rv From I.Clarke at strs.co.uk Tue Nov 2 05:56:43 1999 From: I.Clarke at strs.co.uk (Ian Clarke) Date: Tue, 02 Nov 1999 10:56:43 +0000 Subject: Comparison between Python and "Ruby" References: <3819BCDA.AC4FD4CA@strs.co.uk> <87k8o2x67f.fsf@ev.netlab.co.jp> <7vjtrc$hmm$1@newshost.accu.uu.nl> Message-ID: <381EC36B.F479CA1E@strs.co.uk> > Agreed. This isn't a flamewar anyway. Ian Clarke chose a far more civilized > title to his post than he did a while back in comp.lang.perl. ;) Ugh, me civilized? Now there is flamebait if I ever saw it ;-) Ian. -- Ian Clarke Email: I.Clarke at strs.co.uk Homepage: http://www.gnu.demon.co.uk/ Also see: http://freenet.on.openprojects.net/ "All we see and all we seem is but a dream within a dream" From wjk at wjk.mv.com Sun Nov 28 22:09:43 1999 From: wjk at wjk.mv.com (William J. King) Date: Sun, 28 Nov 1999 22:09:43 -0500 Subject: Python complaints References: <81bmmi$279$1@nnrp1.deja.com> Message-ID: <3841EE77.6B5D6AC9@wjk.mv.com> Python is very interesting and I do not have any real complaints since most things can be worked around in one way or another. As a relatively new person to python programming I have not really compiled a list of complaints: 1. like the indents -- makes coding easier to read and follow - requires discipline me thinks 2. would like something like 'increment'/'decrement' operators either in form: "x++" or "incr x" vice "x = x + 1 " but its ok 3. would like to be able to iterate through a list using 2/more variables instead of only one (unless its possible and I missed it) : for (x,y,z) in list: pass #favorite thing about Python 4. conversion of integer to a string ( which may exist but havn't found yet) so I made a dictionary for what I needed -- was difficult to subscript strings by adding a number to it without it 5. would like to see regular array construct in addition to dictionary/list/tuples faked that one with a dictionary 6. some simpler description of current regular expressions in python some knowledge of grep/vi/awk/sed/perl/tcl - glob - regexp & regsub and now python can be a dangerous thing -- regular expressions rule if you get them right 7. Tkinter is proving to be easier than I thought -- mostly intuitive from some previouse experience with Tcl/Tk - X-windows/Win95 8. OOP is different and strange -- new to OOP -- have been looking for simple directions in that - Python has certainly helped in making me aware of OOP and providing a better understanding than some materials I have read... looked at Java and threw up my hands for the time being 9. Scoping is a bit different that I thought -- try to rember LGB OK -- now these are not really complaints but I would iterate that I feel Python is fun and the Python community is great! --- havn't been spammed for any of my newbie questions and everyone seems to be very helpful. I have done a lot of the things you can do in Python by using just shell scripting and UNIX utilities alone, so I don't really have any complaints about Python. From fredrik at pythonware.com Tue Nov 2 03:41:41 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 2 Nov 1999 09:41:41 +0100 Subject: Doing network traffic in the 'background' from Tkinter app?? References: <19991029085829.A106971705@vislab.epa.gov> Message-ID: <00b901bf250e$16a33db0$f29b12c2@secret.pythonware.com> (Andrew, maybe you should fix your reply-to?) Andrew Markebo wrote: > | I can't tell exactly what you're doing from your description, but check > | out Tk's fileevent callback: > > Bingo, Thanx! > > Basically what I want is to give the user the possibilty to mess > around with my application while it fetches data from THE internet(TM) > > Darn, it seems to be Unix only... fungus.. I would like my application > to run on windows also.. forget about fileevents, and use Python's own asynchronous communications framework in- stead: http://www.python.org/doc/current/lib/module-asyncore.html search the newsgroup archives for more information on using asyncore with tkinter (basically, you should keep calling asyncore.poll from an idle task). for more asyncore examples, check the Medusa servers (http://www.nightmare.com). you'll also find a bunch of asyncore/asynchat examples in the eff-bot guide. From sekter at mail.matav.hu Fri Nov 5 11:07:05 1999 From: sekter at mail.matav.hu (Arpad Kiss) Date: Fri, 5 Nov 1999 17:07:05 +0100 Subject: finding out console user (Win95) References: <941814380.235290@cdwork.cvt.stuba.sk> Message-ID: <001501bf27a7$ce30ce70$029f38c3@geometria.hu> I don't know what "console user" means, but win32api.GetUserName() returns the current user name. Arpad ----- Original Message ----- From: Radovan Garabik Newsgroups: comp.lang.python To: Sent: Friday, November 05, 1999 3:07 PM Subject: finding out console user (Win95) > > I am porting my script from unix to windows, and I need to find > console user under win95 (under WinNT I can use os.environ['USERNAME'], > which is not exactly console user, but good enough for me). > Something like cuserid() or getlogin() as implemented in > Cygwin would be ideal.... > Is there a simple way to find it? > > TIA From sjoerd at oratrix.nl Mon Nov 29 07:04:43 1999 From: sjoerd at oratrix.nl (Sjoerd Mullender) Date: Mon, 29 Nov 1999 13:04:43 +0100 Subject: XPython (X11) In-Reply-To: Your message of Fri, 26 Nov 1999 10:30:56 +0100. <383E5350.1E07536A@xrce.xerox.com> References: <383E5350.1E07536A@xrce.xerox.com> Message-ID: <19991129120444.BFD26301CF9@bireme.oratrix.nl> I use it on a daily basis. But then, I am responsible for it. I'll try to help if you need help. On Fri, Nov 26 1999 Emmanuel Pietriga wrote: > Is anyone using XPython around here? > > I need help, or at least links to examples (I haven't found any but the > ones within the package) > > Thanks. > Emmanuel > -- Sjoerd Mullender From shouldbe at message.com Wed Nov 10 12:44:37 1999 From: shouldbe at message.com (Arinte) Date: Wed, 10 Nov 1999 12:44:37 -0500 Subject: statics everywhere. Why? Message-ID: <80cam4$phe$1@rtpnews.raleigh.ibm.com> Embedding python in a c application, why do I need to make the functions that python call and variables for callbacks static? thanks. From fredp at mygale.org.nospam Fri Nov 26 09:13:36 1999 From: fredp at mygale.org.nospam (Fred Pacquier) Date: 26 Nov 1999 14:13:36 GMT Subject: Running apps with Zope 2? References: <80v5g8$5a6$1@mulga.cs.mu.OZ.AU> <3834101A.FF39F64C@infercor.no> <8E83A8056PaCmAnRDLM@194.2.0.33> <383E7D7A.1B48C7F1@gmd.de> Message-ID: <8E8A95479PaCmAnRDLM@194.2.0.33> kanzow at gmd.de (Peter K.) said : >I have written some web applications using the old Zope/Bobo version. I >published them using ZopeHTTPServer, like this: (...) >After starting ZopeHTTPServer (on hostname.domain.de) with >ZopeHTTPServer -p 1234 m.py >I can access the Application object from the web: >requesting http://hostname.domain.de:1234/app/hello >gets "Hello World from my Zope Object". >This is what I want! But what must I do to achieve this in Zope 2? I >installed it recently and can't find it in the documentation. How can I >publish my old applications with the new Zope? Where do I have to put >m.py? What do I have to do in the management screen? Which URL will get >me the "Hello World..." message? Do I have to install m.py as a Product? >How? I would love to know the answer too. I have an interesting script I would like to run that depends on pcgi and Bobo -- I found pcgi but Bobo seems to have disappeared from the surface of the Earth, even Digicool cannot provide it anymore. If I could stick this script inside Zope with some minimal glue code as you describe, it would solve my problem... Good-to-know-I'm-not-alone-ly yrs :) -- YAFAP : http://www.multimania.com/fredp/ From fdrake at acm.org Mon Nov 29 17:32:48 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Mon, 29 Nov 1999 17:32:48 -0500 (EST) Subject: python test frameworks In-Reply-To: References: Message-ID: <14402.65296.413573.98151@weyr.cnri.reston.va.us> Quinn Dunkan writes: > I know this sort of thing has been talked about before, but I'm looking for > some information on techniques for self-testing pyhon code (something I > should have been doing before, but only now am I writing a system complex > enough to warrant it). I remember Tim's thread about his doc-string embedded > testing, and that looked interesting, but I can't find it now. And links to > discussions of the merits of different strategies would be good, too. There's also the somewhat-general (and completely undocumented) "test" package in the Python standard library. That might be worth a look; I'm not sure how re-targetable it is. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From JamesL at Lugoj.Com Thu Nov 25 19:38:54 1999 From: JamesL at Lugoj.Com (James Logajan) Date: Thu, 25 Nov 1999 16:38:54 -0800 Subject: Python complaints References: <867lj85g4c.fsf@g.local> <383CC835.B585EBDD@Lugoj.Com> <86r9he2tiz.fsf@g.local> Message-ID: <383DD69E.5A927386@Lugoj.Com> Gareth McCaughan wrote: > > James Logajan wrote: > > [I said:] > >> - if/then/else works on *statements* (strictly, suites of > >> statements) rather than on *expressions*, so I can't > >> say > >> print "You scored %s point%s" % (score, if score==1 then "" else "s") > >> or anything like that. (Or, as some people prefer to put it, > >> Python has no ? : operator.) > > > > Thanks to Python's dynamic typing you can easily add the C "?:" expression > > to the language by defining a single function that will work with all types: > > > > def ifexp(cond, trueVal, falseVal): > > if cond: > > return trueVal > > else: > > return falseVal > > > > print "You scored %s point%s" % (score, ifexp(score == 1, "", "s")) > > That has the wrong semantics in the presence of side effects. > (It's fine for my toy example, but then so is "score<>1 and 's' or ''". Fair enough. Your requirements weren't just "kind of like C's '?:' operator," they were precisely that requirement. I'm wondering though what great application remains unwritten because you are forced to use a conditional statement rather than use an operator? From mhammond at skippinet.com.au Thu Nov 4 16:47:05 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 5 Nov 1999 08:47:05 +1100 Subject: Assorted Questions regarding the future of Python... In-Reply-To: <3822f253.11537059@news.demon.co.uk> Message-ID: <002d01bf270e$238223a0$0501a8c0@bobcat> [Andy writes:] > I haven't done any benchmarking myself, but when I installed VB6 I > didn't exactly leap off my seat at the speed increase. And more to the point, VB was (and is), usually, "fast enough". Who does huge matrix manipulation etc in VB anyway? Lots of the focus the industry has on speed is a red herring IMO. Just like Python itself - really quite "slow" compared to these natively compiled languages - but in the entire time I have used it, I have had to use the profiler exactly twice. In every other case, it has been more than "fast enough" (and the development speed far outweighs the difference anyway). Whats-a-milli-second-between-friends-ly, Mark. From mwh21 at cam.ac.uk Wed Nov 24 10:40:31 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 24 Nov 1999 15:40:31 +0000 Subject: CRC-module References: <38396766.B189D15A@bibsyst.no> <383C1089.1D0F7C18@bibsyst.no> Message-ID: Thomas Weholt writes: > Hi, > > Ok, so I`ve looked into zlib.crc32 and zlib.adler32. They seem easy > enough to use, but I thought crc-codes had characters and numbers in > them, not just a plain integer like the methods above return. ( As you > can see, I`m a complete ass on this subject, but don`t have time to do > the proper research myself, and was hoping for a "quick fix" ... ) Well, on one level there's not much difference between a binary string and an integer. But crc32 returns a 32-bit value, so it's most convenient/efficient to store it in an integer. > A friend of mine mentioned that I should try SHA-1 instead, for more > accuracy. Can anybody give me an example on how to compute crc-codes, > using zlib or preferrably some more accurate method, for single files ?? Well, comparing crc32 and SHA-1 or md5 isn't really comparing like with like, to the (small) extent of my knowledge on the matter; crc32 (AFAIK) is designed to spot accidental transmission errors, sha-1/md5 are (certainly) designed to spot malicious modification. Also md5 is 128 bits and sha-1 is 160, so obviously these are finer grained than crc32. > If this is all it takes : > > crc = module_name.crc_method(file) > > and comparison is done like : > > if (crc1 == crc2): print "Equal." > else : print "Different." > > then all I need is the name of the most effective/accurate module to > use. > > If, for some strange reason, I should use one module instead of another, > that info would be interesting too. For that application, it'd probably be best to use sha, eg: import sha sha.sha(open(filename).read()).digest() Efficiency-wise that'll be IO bound so the fact that SHA-1 is more CPU-intensive (I think) than crc32 shouldn't be relavent. HTH, Michael From uhuenemoerder at hotmail.com Sat Nov 6 15:06:46 1999 From: uhuenemoerder at hotmail.com (Ulrich Huenemoerder) Date: Sat, 6 Nov 1999 21:06:46 +0100 Subject: PyRun_File / PyRun_String Message-ID: <801vbn$2l64$1@bnews.gigabell.net> Hello, this might have been asked before, but be sure I looked up deja.com etc. before I sent this mail. I would like to embed Python into my C++ Application. I already looked up the functions PyRun_SimpleFile and PyRun_SimpleString, but since I need multiple independent interpreters at once I think PyRun_File and PyRun_String are the functions I need. Could anyone provide me with the code for a small example app, like // initialization Py_Initialize(); ... // initialize the interpreter ... // parse a file PyRun_File(...); // parse a string PyRun_String(...); // that's it. Thanks, Ulrich. From mhammond at skippinet.com.au Wed Nov 24 17:09:06 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 25 Nov 1999 09:09:06 +1100 Subject: Python and COM: a bug? In-Reply-To: <816010E2456BD111A48700805FBBE2EEFDF822@ex-quebec-u1.baan.com> Message-ID: <004e01bf36c8$872b1550$0501a8c0@bobcat> > OK. You may well be right about a bug in our code. I was told that the > interface is not dual and that the dispids are created > dynamically the first > time a property is used. So maybe there is a problem in this > code and that > the fact that I have never encountered the problem in > VBScript is pure luck. > I'm still not sure, because a lot of people are using those > COM objects in > dozens of VB Scripts and none have reported this kind of > problem. But, hey, > I have seen much stranger occurences than that already :) No luck involved - it could well be that VBScript is simply not exploiting that COM rule - I will check. Yes - VBScript does indeed re-query for the DISPID before each call - ie, it does not cache the items. I would put money on the fact that this is your problem. If it is the problem, you are clearly breaking the rules, and there is a good chance that later versions of VBScript, or indeed any other COM compatible language would also break. I am quite confident that we do not have anything this fundamental broken. > What I'll do is write a test script in Python that just tries > to reproduce > the problem. If I can finally find a way to reproduce it on > demand, I'll ask Or you could take another tact - something like: ob = pythoncom.CoCreateInstance("Your.ProgID", None, pythoncom.CLSCTX_ALL, pythoncom.IID_IDispatch) dispid = ob.GetIDsOfNames("foo") print dispid dispid2 = ob.GetIDsOfNames("foo") print dispid2 if dispid != dispid2: print "Eeek" > That's something I don't know about. My (naive) question is: > why doesn't > VBScript require such a step? Python also doesnt _need_ this step - just does a better job with byref params etc if you use it. I doubt it will have any effect on your problem. Mark. From ivanlan at callware.com Sun Nov 14 17:11:35 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Sun, 14 Nov 1999 15:11:35 -0700 Subject: Other ways to disable Wm in Tkinter? References: <80nabr$q62$1@nnrp1.deja.com> Message-ID: <382F3397.F8552F29@callware.com> Hi All-- brian at liaone.ne.mediaone.net wrote: > [bobbitt] > Thus, my question - can one disable the window manager (or at least > disable window movement) short of withdraw/overrideredirect/deiconify? > It goes without saying that using grab_set_global is a bit too brutal. > Thanks, > Brian > Nuking or disabling people's window managers is not as brutal as grab_set_global????? <.9 wince> Why do you need to do this? I'd advise against it. I think all you're going to accomplish is pissing people off. If you absolutely *must*, try mapping an invisible window that covers the whole root window and intercepting all the events, only passing on the required ones to the dialog. But I think you'd have to write a C extension to do this, which wouldn't be portable. And it seems pretty kludgy to me. ... -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours ---------------------------------------------- From andy at robanal.demon.co.uk Sun Nov 7 17:05:40 1999 From: andy at robanal.demon.co.uk (Andy Robinson) Date: Sun, 07 Nov 1999 22:05:40 GMT Subject: Can Zope be used as a CVS server? References: <14371.11961.82152.303247@dolphin.mojam.com> Message-ID: <3828f7ac.36579949@news.demon.co.uk> harms at mbnet.mb.ca (Stefan Harms) wrote: >In article <14371.11961.82152.303247 at dolphin.mojam.com>, skip at mojam.com (Skip Montanaro) wrote: > >> Stefan> Could I use Zope for the functionality of a CVS server? >> >> Dunno, and it's not obvious (to me) why you'd want to do that. Could you >> motivate your question by providing some rationale for not using CVS itself? >> >> Skip Montanaro | http://www.mojam.com/ >> skip at mojam.com | http://www.musi-cal.com/ >> 847-971-7098 | Python: Programming the way Guido indented... > > >The only reason for using Zope as a CVS server, is that somebody I know finds it difficult to get CVS going as a server, and that the potential participants are not familiar with CVS, but they all have browsers... >and therefore can learn to use Zope. > >Thanks for the reply I agree and asked about this on the Zope list, but got no reply. If you work behind firewalls then you need a web interface to CVS, a web-based bug-tracking system, and a web-based project mailing list. You can get all three separately but it is a pain in the ****. If someone made a set of Zope objects which picked up the Zope permissions and user model, and set up and managed a CVS project accordingly (assuming CVS is on the server), one box such as Starship could provide a collaborative working environment for a whole host of projects, and the administrator could stay sane because Zope lets him delegate management. - Andy From gduzan at gte.com Fri Nov 12 18:20:02 1999 From: gduzan at gte.com (Gary Duzan) Date: Fri, 12 Nov 1999 18:20:02 -0500 Subject: AIX, xlC, and C++ Modules Message-ID: <382CA0A2.BE6536D3@gte.com> While working on a port of the new OmniORBpy stuff to AIX, I came across an interesting issue with python's module loader. importdl.c uses the load() call on AIX to do the loading, which does fine with C and a fair amount of C++. However, the C++ module I was trying to load includes static variables with constructors, and AIX's load() call doesn't handle them properly. To do so, you have to go to the C++ side of the house and call loadAndInit(), which is otherwise identical but does the initialization properly. I'll include the changes that work for me below. I also tried reverting to dlopen(), but this seemed not to resolve the Py_InitModule symbol correctly, leading to a quick core dump. The patch enclosed fixes the problem for me. If anyone else can suggest a better alternative, I'd be glad to hear it. Setup: AIX 4.2.1, C Set++ (xlC) 3.1.4, --with_thread, CC=xlC_r. Gary Duzan GTE Laboratories -------------- next part -------------- --- Python-1.5.2/Python/importdl.c Wed Jan 27 12:53:10 1999 +++ Python-1.5.2/Python/importdl.c.new Fri Nov 12 17:50:50 1999 @@ -178,7 +178,12 @@ #define DYNAMIC_LINK #define SHORT_EXT ".so" #define LONG_EXT "module.so" +#ifdef USE_SHLIB +#include +#else #include +#include "/usr/lpp/xlC/include/load.h" +#endif typedef void (*dl_funcptr)(); #define _DL_FUNCPTR_DEFINED static int aix_getoldmodules(void **); @@ -458,7 +463,7 @@ p = (dl_funcptr) dlsym(handle, funcname); } #endif /* USE_SHLIB */ -#ifdef _AIX +#if defined(_AIX) && !defined(USE_SHLIB) /* -- Invoke load() with L_NOAUTODEFER leaving the imported symbols -- of the shared module unresolved. Thus we have to resolve them @@ -473,7 +478,8 @@ if (!staticmodlistptr) if (aix_getoldmodules(&staticmodlistptr) == -1) return NULL; - p = (dl_funcptr) load(pathname, L_NOAUTODEFER, 0); + /* p = (dl_funcptr) load(pathname, L_NOAUTODEFER, 0); */ + p = (dl_funcptr) loadAndInit(pathname, L_NOAUTODEFER, 0); if (p == NULL) { aix_loaderror(pathname); return NULL; @@ -877,7 +883,7 @@ } -#ifdef _AIX +#if defined(_AIX) && !defined(USE_SHLIB) #include /* for isdigit() */ #include /* for global errno */ From hildeb at www.stahl.bau.tu-bs.de Fri Nov 26 09:19:11 1999 From: hildeb at www.stahl.bau.tu-bs.de (Ralf Hildebrandt) Date: 26 Nov 1999 14:19:11 GMT Subject: fcntl/ioctl and O_NONBLOCK Message-ID: Hi! I'm trying the following unsing Python-1.5.2 on Solaris 2.6: ... snip ... program = popen2.Popen3(commandline, self.true, buffersize) # start program with 64k Buffer stdin = program.tochild stdout = program.fromchild rv = fcntl.ioctl(stdout.fileno(), FCNTL.O_NONBLOCK, 1) # rv = fcntl.ioctl(stdout.fileno(), FCNTL.O_NDELAY, 1) ... snap ... But no matter what I do - I keep getting IOError: [Errno 22] Invalid argument What I want to do: I want to use select() to see if there's data to be read from stdin or stdout and read it ALL (thus I need stdin/stdout to be non blocking!) Any ideas? From lijnzaad at ebi.ac.uk Thu Nov 25 10:01:19 1999 From: lijnzaad at ebi.ac.uk (Philip Lijnzaad) Date: 25 Nov 1999 15:01:19 +0000 Subject: automatic "lootjes trekken" [ was Re: automatic "lotjes trekken"] References: <81cqnv$2ip$1@vvs.superst.iae.nl> <81e3s2$j14$2@newshost.accu.uu.nl> <81hbrq$1fh$1@vvs.superst.iae.nl> Message-ID: sorry, I still can't resist, even though it's futile ... Carel> Well, the file at home *is* called lootjes-trekken.py, but somehow the Carel> spellling got corrupted:) Carel> OTOH, Dutch being a permissive language does allow for both variants! mm ... does it? Living abroad, I haven't kept up with the new spelling. Or perhaps it's more of a regional thing? (Incidentally, dialects of computer languages never seem to be regional. Oh, and (also incidentally) please don't get the impression that Dutch is indentationally-structured :-) Carel> "lotjes" being the generic form, "lootjes" the special case (from a Carel> morphological point of view that is). To me, the form 'lotje' resonates more with 'van lotje getikt' (meaning 'mad, stupid, bonkers' which is an admittedly fairly old-fashioned expression) than with 'lot' (meaning 'lottery ticket'). Still-not-resisting-the-futile-urge-ly yours, Philip -- If information has state, are we now in the liquid, gaseous or plasmatic phase? ----------------------------------------------------------------------------- Philip Lijnzaad, lijnzaad at ebi.ac.uk | European Bioinformatics Institute,rm A2-24 +44 (0)1223 49 4639 | Wellcome Trust Genome Campus, Hinxton +44 (0)1223 49 4468 (fax) | Cambridgeshire CB10 1SD, GREAT BRITAIN PGP fingerprint: E1 03 BF 80 94 61 B6 FC 50 3D 1F 64 40 75 FB 53 From fredrik at pythonware.com Thu Nov 4 03:31:46 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 4 Nov 1999 09:31:46 +0100 Subject: opening anydbm files References: <7vdtet$3i4$1@marcie.fissiontech.com> Message-ID: <014101bf269f$09019f20$f29b12c2@secret.pythonware.com> Scott Barron wrote: > According to the docs and Fredrik's book this should work but I get the > following: > > Python 1.5.2 (#8, Oct 13 1999, 22:39:47) [GCC 2.7.2.3] on linux2 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> db = anydbm.open ("foo", "r") > Traceback (innermost last): > File "", line 1, in ? > File "/usr/local/lib/python1.5/anydbm.py", line 80, in open > raise error, "need 'c' or 'n' flag to open new db" > anydbm.error: need 'c' or 'n' flag to open new db you get this error if whichdb fails to identify the existing database -- the most likely reason is that anydbm("c") used the "dumbdbm" handler. try running: import anydbm print anydbm._defaultmod to see what the default database handler is. From gerglery at usa.net Mon Nov 1 06:36:23 1999 From: gerglery at usa.net (greg andruk) Date: 01 Nov 1999 06:36:23 -0500 Subject: Need Berkley DB!! References: <381D5E84.98931682@bibsyst.no> Message-ID: <87d7tuxx3c.fsf@slip-32-100-243-27.ma.us.prserv.net> Thomas Weholt wrote: > After I spent most of my weekend trying to get Berkley DB to work with > Python on my Linux ( Suse 6.1) machine, I`ve now given up completly. > I`ve tried to install DB.1.85. and DB.2.7.7, neither worked, either > crashing under installation ( which of course, is not Python > related ) or when I tried to test the installation with the examples in > the documentation ( the wrapper for the 2.7.5-module listed at > www.python.org, under modules, databases ). You do have to much with the headers to make the stock db module compile with DB 2.x. If 1.85 isn't working for you , you've got, well, a problem. Python also supports GNU db, and pretty much every flavor of Linux comes with that. Can you use it instead? From dieter at handshake.de Fri Nov 12 14:22:08 1999 From: dieter at handshake.de (Dieter Maurer) Date: 12 Nov 1999 20:22:08 +0100 Subject: Minor Tkinter omission: grid_remove Message-ID: Tkinter (1.5.2) does not implement a "grid_remove" method (for the tk "grid remove slave ..." command). Workaround: Instead of "w.grid_remove()" use "w.tk.call('grid','remove',w._w)" - Dieter From kuncej at mail.conservation.state.mo.us Fri Nov 12 17:31:56 1999 From: kuncej at mail.conservation.state.mo.us (Jeffrey Kunce) Date: Fri, 12 Nov 1999 16:31:56 -0600 Subject: XML-RPC for CGI Message-ID: I have a web host where I can't use long-running processes (like an XML-RPC server). I can run CGI scripts on the host, and want to take advantage of the XML-RPC protocol. So I have written xmlrpccgiserver.py (based on xmlrpcserver.py) It is included in the attached tarball, along with a demo cgi script and demo client script. I haven't put it into production yet, but the tests look good. --Jeff -------------- next part -------------- A non-text attachment was scrubbed... Name: xmlrpccgi.tgz Type: application/x-compressed Size: 2122 bytes Desc: not available URL: From bbosware at vic.bigpond.net.au Tue Nov 30 16:47:05 1999 From: bbosware at vic.bigpond.net.au (John Leach) Date: Tue, 30 Nov 1999 21:47:05 GMT Subject: Looking for sshlib.py References: <19991130080326.A1376@quark.emich.edu> Message-ID: >what type of application are you trying to write that you need this type of >access? I'm looking to write a Python frontend for character-based applications accessed via the internet. telnet works well but I'd like something with more security (telnet sends its password unencrypted I believe). I'll try calling ssh from within Python and see if that helps. Thanks for your reply, John Leach http://www.bosware.com.au From bwinton at tor.dhs.org Thu Nov 4 19:49:22 1999 From: bwinton at tor.dhs.org (Blake Winton) Date: Fri, 05 Nov 1999 00:49:22 GMT Subject: Snippets site (minor rant) Message-ID: Well, I just checked the newsgroup, and no-one seems to have noticed that (or at least no-one has posted anything about ) the Python Snippets site has been down for the past few days. I'm not sure if that's a good or a bad thing. Anyways. (Here comes the rant.) The site was down because Bell (aka Sympatico, my local ADSL provider) decided to switch their service from DHCP to Access Manager (aka PPPoE). The PPPoE implementation for Linux is "not quite production quality". So on the day they switched my area over, I switched to Rogers at Home (my local Cable Modem provider). The end result is that my computer has just gotten on the net, and the dns will switch over to it at 6am EST. I wanted to apologize to Hans, and to vent a little, and now that I've done both, I'm going to go and help a buddy move into his new apartment. Thank you all for listening, Blake. From ScherBi at BAM.com Tue Nov 16 14:24:08 1999 From: ScherBi at BAM.com (ScherBi at BAM.com) Date: Tue, 16 Nov 1999 14:24:08 -0500 Subject: problems with __getattr__ & __setattr__ Message-ID: <3F8BA119B48AD11197470008C7A493CB98B67D@HQOBGEX1> I am having trouble using __getattr__ and __setattr__ in some classes. I've boiled it down to the code below. It dumps core under 1.5.2 on Linux or WinNT. I think maybe it's looping, if so, how does one go about doing this? (I'm assuming it's clear enough what I'm trying to do.) If I comment out the __gettattr__ operation, it doesn't dump core. Instead I get an AttributeError: eggs raised at the 'self.eggs[key] = value' call in __setattr__. This is what leads me to belive there's something circular going on here. Thanks, Bill ------------------------------------------------------------- class spam: def __init__(self): self.eggs = {} def __getattr__(self, key): try: return self.eggs[key] except: raise def __setattr__(self, key, value): try: self.eggs[key] = value return 0 except: raise if __name__ == '__main__': s = spam() print 'instance of spam created.' ------------------------------------------------------------------ From edcjones at erols.com Wed Nov 3 23:40:02 1999 From: edcjones at erols.com (Edward C. Jones) Date: Wed, 03 Nov 1999 23:40:02 -0500 Subject: Python / Perl joke in rec.humor.funny Message-ID: <38210E22.BBDAF855@erols.com> A Python vs. Perl joke has appeared in the moderated, low-traffic, humor group rec.humor.funny. It can be found at http://www.netfunny.com/rhf/jokes/99/Nov/perl.html From fredp at mygale.org.nospam Mon Nov 15 06:08:36 1999 From: fredp at mygale.org.nospam (Fred Pacquier) Date: 15 Nov 1999 11:08:36 GMT Subject: Parnassus References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> <382F28A3.A09C3CEF@callware.com> Message-ID: <8E7F76BFAPaCmAnRDLM@194.2.0.33> ivanlan at callware.com (Ivan Van Laningham) said : >Boudewijn Rempt wrote: > >> You don't say! I just went there, spurred on by your posting to >> enter my own efforts. Just when I had done so, I noticed that one >> of them was already there - really good work! It seems to be very, >> very nice, indeed. > >Same thing happened to me. I thought, "surely he hasn't added my stuff, >no one knows about it." Too late, there they were. I'm impressed. Impressive, indeed. I went there to check because I posted (for the first time) an announce for a very modest snippet a month or two ago, and sure enough, it is there too. It seems considerable effort has been made to seed the archive with recent newsgroup content, and that could make a big difference... I do hope the effort is rewarded and Parnassus evolves into the CPAN or Freshmeat Python users have been lacking ! -- YAFAP : http://www.multimania.com/fredp/ From boncelet at udel.edu Mon Nov 8 05:09:14 1999 From: boncelet at udel.edu (Charles Boncelet) Date: Mon, 08 Nov 1999 10:09:14 +0000 Subject: __str__ vs. __repr__ References: <000001bf275c$02370d20$1d2d153f@tim> Message-ID: <3826A14A.3328AFAA@udel.edu> Tim Peters wrote: > David Ascher suggested that str(long) drop the trailing "L", and that's a > good example. The "L" is appropriate for repr(), for so long as Python > maintains such a sharp distinction between ints and longs, but is really of > no help to most users most of the time. On the dissenting side, I find the "L" useful (just as I find the difference between 1 and '1' useful. Consider the following: >>> a,b = 2L, 2 >>> a,b (2L, 2) >>> a**32 4294967296L >>> b**32 Traceback (innermost last): File "", line 1, in ? OverflowError: integer pow() Without the "L", it is not at all clear why a**32 works and b**32 fails. --Charlie ----- Charles Boncelet University of Delaware Newark DE 19716 USA http://www.eecis.udel.edu/~boncelet/ From reic0024 at bulldog5.d.umn.edu Tue Nov 2 17:37:34 1999 From: reic0024 at bulldog5.d.umn.edu (Aaron J Reichow) Date: Tue, 2 Nov 1999 16:37:34 -0600 Subject: How to control app from Python? In-Reply-To: <381F399E.CC26AE2D@theriver.com> References: <38160DD8.5C695E09@theriver.com> <381A8A5A.C94398BD@saiph.com> <381F399E.CC26AE2D@theriver.com> Message-ID: > I don't know much about the way the app works. I hope to know a whole > lot more about it in the next couple of days ;-) > > This is the first time I've tried to write code in any language to > control another application. It's very interesting. Lots to learn! It's a shame Linux/Unix didn't have some unified API (probably a misuse of the word) like as in MacOS, where one can access the items in the menus, &c, with AppleScript. Aaron From thomas.heller at ion-tof.com Thu Nov 4 08:32:46 1999 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 4 Nov 1999 14:32:46 +0100 Subject: __str__ vs. __repr__ References: <000401bf25b9$88ea57e0$2e2d153f@tim> <199911040157.UAA11908@eric.cnri.reston.va.us> Message-ID: <00c001bf26c9$14f75a20$4500a8c0@thomasnotebook> > How about a hook function a la __import__? I.e. have a function > __format__ [1] in __builtin__ that is bound to repr by default. Whenever > Python prints the result of an expression in interactive mode, it calls > __format__ with the result as parameter and expects it to return a > string ready for printing. But you have a custom python interpreter, don't you? Or how do you manage to use your __format__ as the printer for interactive mode? Thomas Heller From news at dorb.com Thu Nov 11 13:20:13 1999 From: news at dorb.com (Darrell) Date: Thu, 11 Nov 1999 13:20:13 -0500 Subject: ASCII delimited files References: <942231502.1914033961@news.interbusiness.it> <80ekhb$1qrh$1@hub.org> <80et0b$2df8$1@hub.org> Message-ID: Oops. That fix pushed into or beyond exponential runtime. It won't finish the 3.6meg file anytime soon. String slicing and pasting is dirt slow. E:\ace\dtd\q\delim1>delimited.py 3600 bytes 0.0310000181198 time E:\ace\dtd\q\delim1>delimited.py 36000 bytes 3.04700005054 time Got some improvement with the attached version at the cost of memory. Now I'm thinking about the 'C' version again. E:\ace\dtd\q\delim1>delimited.py 3600 0.0310000181198 E:\ace\dtd\q\delim1>delimited.py 36000 0.327999949455 E:\ace\dtd\q\delim1>delimited.py 360000 3.21899998188 E:\ace\dtd\q\delim1>delimited.py 3600000 48.2030000687 -- --Darrell begin 666 delimited.py M(R$@+W5S&QS+G!Y#0I'96YE2!D96QI;6ET97(@8G5T(%QN+ at T*(B(B#0H-"FEM<&]R="!S=')I M;F<-"@T*9&5F(&EN'0]:5LP M70T*(" @(" @("!B/6EN8G5F6VQA'0 at 9FEL92!S=')I;F<@:6YT M;R!A(&QI65D+"!E M;F-L;W-E9"!N97=L:6YE2!I M'0@/2!S=')I;F'0@=&\@=&AI M#!$(@T*(" @('5N:7@@/2 B7'@P02(-"B @ M("!D;W,@(#T@;6%C*W5N:7 at -"B @("!O"P@;6%C M70T*(" @(", at 9FEN9"!T:&4@;VYE('=H:6-H(&=I=F5S('1H92!M;W-T(&QI M;F5S+ at T*(" @(",@:6X at 9&]U8G0L('1H92!L;VYG97-T(&1E;&EM:71E'1;+3%= M(&EN(&1O Message-ID: <034b01bf2c9a$ed7c3830$0100a8c0@rochester.rr.com> ----- Original Message ----- From: Mike Fletcher > Okay, here's an entirely different approach, extremely memory intensive, > fairly fast. I'm impressed if you just whipped this up today! Should it trim the leading empty record ??? I noticed that it returns an additional empty record. Here's the 'C' version with your tests. Time for file of 365 bytes (5 * testset, 10 records found): 0.0 Time for file of 3650 bytes (50 * testset, 100 records found): 0.0 Time for file of 36500 bytes (500 * testset, 1000 records found): 0.0160000324249 Time for file of 365000 bytes (5000 * testset, 10000 records found): 0.15600001812 next test may take 15 seconds or so Time for file of 3650000 bytes (50000 * testset, 100000 records found): 1.89099991322 next test may take 45 seconds or so Time for file of 10950000 bytes (150000 * testset, 300000 records found): 7.32799994946 --Darrell From pwos at home.com Sat Nov 6 14:40:16 1999 From: pwos at home.com (Wostenberg) Date: Sat, 06 Nov 1999 19:40:16 GMT Subject: Python and Smalltalk and Java envy References: <1270663667-24391282@hypernet.com> <381ED7A6.D7D7FB13@compaq.com> <877lk1wiij.fsf@ev.netlab.co.jp> <19991102154543.A4469@optiplex.palga.uucp> <381F9EB4.63FA033F@python.net> <7vqkqq$oa7$1@nnrp1.deja.com> Message-ID: <382484F1.F8B8D712@home.com> Doug Way wrote: > From a historical point of view, Smalltalk is a little like Lisp, in > that it's a little outside of the mainstream, but it has enough new > ideas in it that will give it a very long lifespan. Smalltalk will > still be relevant 20 years from now, just as Lisp-based languages are > still reasonably relevant today, after 40 years. I suppose "having a > lot of new ideas" and "being a little outside of the mainstream" go hand > in hand. (Smalltalk isn't *that* obscure, though... there are more > Smalltalk programming jobs available than, say, Python or Lisp jobs.) Intersting observation. Perhaps it comes down to those of us who are comfortable with niche languages (Python, Smalltalk, Lisp) and those who suffer Java-envy . Do Python people, Ada advocates, or little Lispers wring there hands about the fact "we are not the most used language?" Why should Smalltalkers? -Alan From garabik at melkor.dnp.fmph.uniba.sk.spam Wed Nov 3 08:52:00 1999 From: garabik at melkor.dnp.fmph.uniba.sk.spam (Radovan Garabik) Date: 3 Nov 1999 13:52:00 GMT Subject: How to eliminate consol window in MS Windows References: <3813a9be.579613@netnews.hinet.net> <3813D482.E71116AD@home.com> <7v7897$cem$1@sunnews.cern.ch> <020601bf2112$0a9d1d60$f29b12c2@secret.pythonware.com> Message-ID: <941640628.218028@cdwork.cvt.stuba.sk> Fredrik Lundh wrote: : you could try something like: : file = r"\full\path\pythonw.exe" : os.spawnv(os.P_NOWAIT, file, (file, "program.pyw") + tuple(args)) : note that spawnv doesn't scan the path, and that : you need to pass the name of the excutable as the : first item in the argument tuple. ok, thanks, it works. However... I need to pass to program.pyw an argument, which is arbitrary string, probably with spaces inside. Passing is as a string passed only the first word. When I enclose the string in quotes, it works, but when by chance there are quotes in orginal args, enclosing it again in quotes makes the whole thing look ... funny. -- ----------------------------------------------------------- | Radovan Garabik http://melkor.dnp.fmph.uniba.sk/~garabik/ | | __..--^^^--..__ garabik @ fmph.uniba.sk | ----------------------------------------------------------- Antivirus alert: file .signature infected by signature virus. Hi! I'm a signature virus! Copy me into your signature file to help me spread! From bernhard at alpha1.csd.uwm.edu Fri Nov 26 13:08:35 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 26 Nov 1999 18:08:35 GMT Subject: XPython (X11) References: <383E5350.1E07536A@xrce.xerox.com> Message-ID: On Fri, 26 Nov 1999 10:30:56 +0100, Emmanuel Pietriga wrote: >Is anyone using XPython around here? This is the first time I heard of XPython. :) The only reference I found is : http://ftp.uni-klu.ac.at/programming/python/X-extension/Top.html >I need help, or at least links to examples (I haven't found any but the >ones within the package) If I want to program a GUI I look in to wxPython. Or pyGtk or pyFOX or pyFLTK, but XPython... :) Bernhard -- Research Assistant, Geog Dept UM-Milwaukee, USA. (www.uwm.edu/~bernhard) Free Software Projects and Consulting (intevation.net) Association for a Free Informational Infrastructure (ffii.org) From gmcm at hypernet.com Mon Nov 15 13:18:46 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Mon, 15 Nov 1999 13:18:46 -0500 Subject: Memory not being released? In-Reply-To: <80pdvo$99r$1@nnrp1.deja.com> Message-ID: <1269432569-4253767@hypernet.com> Steve Tregidgo writes: > I have a process (goes up to 250+ MB, cue lots of virtual memory > usage and hence slowdown), which busies the server so much that > it just can't bring itself to do other things -- in other words > it's severely impractical. > > The actual data that results from the process is relatively small > (the useful stuff is less than 1MB, and other data -- such as > objects that have been dealt with, to prevent following circular > references -- is no more than a few MBs), and certainly well > below the size of the actual footprint. > > I've gone through the loops and recursion with a fine-tooth comb, > and found that by eliminating certain function calls the > footprint is reduced -- the process is thus rendered useless > (they were the important functions, of course), but at least I > get an idea of where the memory is going. > > On the other hand, commenting out some other expressions (such as > those that remember data -- in other words, the things that I > would expect to take up memory and not release it again) doesn't > make a blind bit of difference. That's a pretty good sign that you have circular references that are keeping objects alive. Check out Cyclops from ftp://ftp.python.org/pub/python/contrib/System/. Also, be aware that even if your python objects are getting collected, that doesn't mean your c runtime is giving the memory back to the OS. Although 250M would indicate a pretty horrid c runtime. > So what's going on? My guesses so far have been along the lines > of refcounts not going down -- how else do I explain why memory > that was allocated was seemingly not deallocated? I've tried > del'ing everything in sight, storing ids instead of objects, > inserting the odd sys.exc_traceback=None to clear those pesky > traceback reference holders ... none of it has helped so far. > > Are there other hidden things that might hold references to my > objects? And if so, what can I do about them? After using an > object once, I don't want (don't need) to keep it in memory any > more, so for those objects I'll be revisiting at a later date, I > just remember their id and delete them. In your code, dict1 is holding a reference to every object you've visited, and thus keeping them all alive. OTOH, judging by "for item in obj.subs:", it looks like the whole graph is alive all the time anyway. Essentially, you've got a huge pointer- based data structure. You need to hoist most of the smarts up to a Graph object, and use some kind of persistent key to identify objects (which are really on disk, or recreated on the fly...). So that snippet might be: for itemname in obj.subs: obj = graph.getobject(itemname) > If it's any help, the process does something like this: > > def recurse(obj, list, dict1, dict2): > # Prevent circular recursion... > if dict1.has_key(obj.__id__): > return > else: > dict1[obj.__id__] = None > > a = do_thing(obj, dict2) > > # Recurse into obj's children, or do something else > for item in obj.subs: > if item.spam: > recurse(item, list, dict1, dict2) > else: > b = do_thing(item, dict2) > > c = do_thing(obj, dict2) > > # Remember some things -- commenting > # out produces no memory saving. > list.append(a,b,c) > > The function do_thing implements a loop; in total (over the whole > process) the loop's body is executed tens of thousands of times > -- it causes the biggest memory saving when commented out (and of > course it's the most important bit), but does no obvious > "remembering" of things. > > Does anybody have any ideas? Or can you maybe point me to some > documentation that deals with this -- the FAQ looked promising > but ultimately didn't help. > > Cheers, > Steve > > -- > -- Steve Tregidgo -- > Developer for Business Collaborator > www.enviros.com/bc > > > Sent via Deja.com http://www.deja.com/ > Before you buy. > > -- > http://www.python.org/mailman/listinfo/python-list - Gordon From fredrik at pythonware.com Fri Nov 19 05:56:08 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 19 Nov 1999 11:56:08 +0100 Subject: Batch window References: <383525CB.6E2EE3AF@obop.com.pl> Message-ID: <016c01bf327c$b2ad5260$f29b12c2@secret.pythonware.com> Przemyslaw G. Gawronski wrote: > Is it posible to automaticaly minimize the python window, when starting > a GUI application on Windows ? you can get rid of it entirely, by using the "pythonw" interpreter: pythonw myapp.py (note that stdout and strerr are directed to the bit bucket) From LCortes at Flash.Net Sat Nov 27 13:52:14 1999 From: LCortes at Flash.Net (Luis Cortes) Date: Sat, 27 Nov 1999 18:52:14 GMT Subject: Prolog Extension Message-ID: <19991127.19045200@negrita.brunner.org> Is there a version of Python with Prolog Extension?? Where can I find it if there is? Thanks, Luis. P.S. Could you please reply to the sender too. -------------- next part -------------- An HTML attachment was scrubbed... URL: From hnowak at cuci.nl Fri Nov 19 17:20:42 1999 From: hnowak at cuci.nl (Hans Nowak) Date: Fri, 19 Nov 1999 23:20:42 +0100 Subject: Python in DOS In-Reply-To: Message-ID: <199911192222.XAA26465@dionysus.fw.cuci.nl> On 19 Nov 99, at 10:59, Curtis, Craig M. wrote: > I tried setting PYTHONCASEOK to 0 and did the configure and make and still > have the same problem. Any more suggestions? Yeah, try setting it to 1. :o) 0 doesn't have much effect AFAIK. This variable does not affect compilation though, it only affects the interpreter when it runs. If that doesn't help, do as I said... uncomment the code. I think uncommenting a coupla fprintf statements in getpath.c will do. You'll know 'em when you see 'em... they're these infamous error/warning messages of course. HTH, --Hans Nowak (zephyrfalcon at hvision.nl) Homepage: http://fly.to/zephyrfalcon You call me a masterless man. You are wrong. I am my own master. From pinard at iro.umontreal.ca Mon Nov 1 19:56:49 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 01 Nov 1999 19:56:49 -0500 Subject: Default indentation of 4 columns In-Reply-To: "Mark Hammond"'s message of "Mon, 25 Oct 1999 16:17:22 +1000" References: <004001bf1eb0$99d713f0$0501a8c0@bobcat> Message-ID: "Mark Hammond" writes: > However, look at "string.split.__doc__" - this does use a style > similar to what Tim described and it is in .py code - and indeed does > end up showing the arg information twice in the calltip window. > So-basically-I-have-no-idea-what-Tim-meant-ly, Hmph! I see: Python 1.5.2 (#1, Jul 23 1999, 06:38:16) [GCC egcs-2.91.66 19990314/Linux (egcs- on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> print string.split.__doc__ split(str [,sep [,maxsplit]]) -> list of strings splitfields(str [,sep [,maxsplit]]) -> list of strings Return a list of the words in the string s, using sep as the delimiter string. If maxsplit is nonzero, splits into at most maxsplit words If sep is not specified, any whitespace string is a separator. Maxsplit defaults to 0. (split and splitfields are synonymous) You see that `str' is used in the prototype, while `s' is used in the description. Such errors might be caught more easily by the eye if the capitals convention was followed. Compare (I'm using simili-GNU style): split(STR [,SEP [,MAXSPLIT]]) -> list of strings splitfields(STR [,SEP [,MAXSPLIT]]) -> list of strings Return a list of the words in the string STR, using SEP as the delimiter string. If MAXSPLIT is nonzero, splits into at most MAXSPLIT words. If SEP is not specified, any whitespace string is a separator. MAXSPLIT defaults to 0. (`split' and `splitfields' are synonymous.) P.S. - If I were doing it, I would also write STRING and SEPARATOR in full. Using smallish abbreviations come from prehistory :-) :-). -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From ivnowa at hvision.nl Mon Nov 22 16:23:07 1999 From: ivnowa at hvision.nl (Hans Nowak) Date: Mon, 22 Nov 1999 22:23:07 +0100 Subject: Python in DOS / PYTHONHOME In-Reply-To: Message-ID: <199911222122.WAA22314@axil.hvision.nl> On 22 Nov 99, Curtis, Craig M. wrote: > Commenting out those dreaded printfs certainly does work :-) > > I guess I do not understand what PYTHONHOME should be set to. I tried > setting it to the python-1.5.2 root and also to the lib under it, but > neither of these work. I don't understand PYTHONHOME either. ;-) That is, I never tried to use it. Running 'python -?' yields: [...] PYTHONHOME : alternate directory (or ;). The default module search path uses /python1.5. Maybe this makes more sense in a Unix environment? I can imagine Unix directories called usr/lib/python1.5 or something, but in DOS, this is quite uncommon. Does anyone use this under DOS? --Hans Nowak (zephyrfalcon at hvision.nl) Homepage: http://fly.to/zephyrfalcon You call me a masterless man. You are wrong. I am my own master. From claudius at catlover.com Fri Nov 5 23:15:59 1999 From: claudius at catlover.com (claudius at catlover.com) Date: Sat, 06 Nov 1999 04:15:59 GMT Subject: Numbers in SQL statements References: <38235836.D2F9A909@src.uchicago.edu> Message-ID: <3YNU3.17551$Ec1.184623@news1.frmt1.sfba.home.com> Nick Collier says: >Hi, > >I've been creating SQL statements from dictionaries holding the field >name and the new value to insert or update. As might be expected this >new value is often a number. When turning this number into a string in >order to create the sql statement the number will have a "L" appended if >it is a long. Consequently, the resulting SQL might look like the >following: > >update myTable >set id_num = 23L >where food = 'spam' > >I've been testing if the value is a number whose string representation >ends with "L" and then stripping the "L", but am pretty sure there must >be a better way. If so, any suggestions as to what is? Try (if you're using a module that supports the full Python DB API 1.0): cursor.execute('update myTable set id_num = ? where food = ?', (id_num, food)) This mechanism is much more forgiving than stringifying directly into the query. I've been using this format with great success (including storing binary pickled datastructures and marshalled Python bytecode in the database. Whee!) From jima at aspectdv.com Tue Nov 16 15:28:24 1999 From: jima at aspectdv.com (Jim Althoff) Date: Tue, 16 Nov 1999 12:28:24 -0800 Subject: Beginning programming with Python In-Reply-To: <38317787.19AFDAF5@compaq.com> References: <382B3A53.5816B2@callware.com> <382B3D79.74CD3E0F@email.sps.mot.com> <80p9ds$ppo$1@newshost.accu.uu.nl> Message-ID: <4.2.0.58.19991116121641.00b4bd60@mail.aspectdv.com> yes. yes. yes. (If only we didn't have to type "self" into every method arg list. sigh.) Jim At 04:25 AM 11/17/99 +1300, Greg Ewing wrote: >Janos Blazi wrote: > > > > the indenting this time? There is actually nothing else you can forget in > > Python. > >Well, not quite - you can forget the "self" in method >declarations fairly easily... > >Greg > >-- >http://www.python.org/mailman/listinfo/python-list From abrahams at mediaone.net Sun Nov 7 17:52:48 1999 From: abrahams at mediaone.net (Dave Abrahams) Date: Sun, 07 Nov 1999 17:52:48 -0500 Subject: Python and generating images for web References: <3824F785.40DF4393@yahoo.com> Message-ID: In article <3824F785.40DF4393 at yahoo.com> , Alexander Stepanov wrote: > (I am in a process of comparison Perl and Python to solve this problem. > I plan to use the application > under WindowsNT4.0 environment + Perl? or Python interp-r). Hi Alexander! Unfortunately, I can't help you with your gif/png/chart/plot problems, though I'm sure someone will step forward with a clue, since so many useful libraries have been written in Python. I assume you've tried the search engine at www.python.org already. Also I have nothing to say about Perl, having never used it. I just wanted to express my appreciation of coding in Python for its parallels with generic programming in C++, something I have a hunch you may take a liking to also. While you don't get overloading ,or the performance advantages, the similarities in code structure keep jumping out at me. In particular the lack of strong type checking makes _everything_ generic. The ability to pass type objects as function parameters is analogous to type template parameters. I have to say that once I got over my initial revulsion at the lack of compile-time type checking, I've quite enjoyed my experience with Python. I hope you have as much fun as I have. Best Regards, Dave Abrahams From volumeregeling at hotmail.com Mon Nov 29 06:22:18 1999 From: volumeregeling at hotmail.com (volumeregeling) Date: Mon, 29 Nov 1999 11:22:18 GMT Subject: help with opening html files Message-ID: <384261c4.8540090@122.0.0.250> Hi, Can anyone tell me how to open a html file from within python in windows. thanks From timmuddletin at news.vex.net Thu Nov 25 00:39:39 1999 From: timmuddletin at news.vex.net (tim muddletin) Date: 25 Nov 1999 05:39:39 GMT Subject: How to perform syntax check in Python References: <382A2384.CC37FBA8@hp.com> <00bf01bf2c1d$2a927be0$f29b12c2@secret.pythonware.com> <3838CE1A.C7BE0530@horvath.com> <38398D45.DFA52EFD@horvath.com> <383AD4F1.740DFD7E@computer.org> Message-ID: <81ii2r$2pq9$1@hub.org> On Tue, 23 Nov 1999 09:54:57 -0800, Charles Y. Choi wrote: >Look for trace.py by Andrew Dalke. I tracked this down to ftp://starship.python.net/pub/crew/dalke So i could enter it into my Vaults of Parnassus database ( http://localhost/~x/parnassus/apyllo.py?i=63889258 ) My problem is that i don't really understand what this script does. There is no general description provided. I suppose it's one of those things that is self-evident to those who know what it is. <-: What is this "coverage" stuff? Can someone provide me with a description for the database? I'm lost on this one; my ignorance is showing. (ps. also it is announced in usenet --- also without a general description -- here: http://x33.deja.com/=dnc/getdoc.xp?AN=49968748 ) From Gareth.McCaughan at pobox.com Fri Nov 26 17:36:36 1999 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: 26 Nov 1999 22:36:36 +0000 Subject: Python complaints References: <867lj85g4c.fsf@g.local> <383CC835.B585EBDD@Lugoj.Com> <383D9C63.3A7E5806@Lugoj.Com> <86ogci2tfm.fsf@g.local> Message-ID: <86aeo0283v.fsf@g.local> Markus Stenberg wrote: [I said:] >> Garbage collectors have got a *lot* better since the days when >> GC meant half-second pauses waiting for the machine to sweep >> through all its memory. Let alone 20 seconds. > > Where can I admire such a beast? At least none of the Java > implementations(*) I have tried(**) have one. say, for 128MB of trash, it's > consistent N second sweep (0.5-10, depending on hardware). In a modern Lisp implementation. Modern Smalltalks are probably just as good. (Unfortunately, "modern" might have to imply "commercial" here; I'm not sure of the quality of the GC in the various free implementations of those languages.) -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From fredrik at pythonware.com Thu Nov 4 02:54:40 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 4 Nov 1999 08:54:40 +0100 Subject: Python and Literate Programming References: Message-ID: <006501bf2699$da9cbca0$f29b12c2@secret.pythonware.com> Philip H. Jensen wrote: > Incidentally, I'm also a booster for Modula-3, and of course Python > has well-known and intentional similarities to M3. But one of my other > enthusiasms is Literate Programming, and I'm wondering about the > possibilities for it in Python. you should be able to find something called interscript here: http://www.triode.net.au/~skaller (that link doesn't work when I'm writing this; if it has moved, you might be able to locate it via: http://www.ozemail.com.au/~skaller/ From NebtShpilfoygel at news.vex.net Sun Nov 14 00:32:05 1999 From: NebtShpilfoygel at news.vex.net (Nebt Shpilfoygel) Date: 14 Nov 1999 05:32:05 GMT Subject: NT admin scripts with python References: <000201bf2e34$26d93750$020a10ac@p350.gnaa.net> Message-ID: <80lhgl$22gn$1@hub.org> On Sat, 13 Nov 1999 16:06:50 -0800, geoff nordli wrote: >Does anyone know if there is a reservoir of python scripts on the net. Kind >of like Perl's CPAN It's not like CPAN but you might try http://www.vex.net/~x/parnassus/ ... From mwh21 at cam.ac.uk Tue Nov 16 12:04:43 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 16 Nov 1999 17:04:43 +0000 Subject: __str__ vs. __repr__ References: <000001bf275c$02370d20$1d2d153f@tim> <01fd01bf2dce$d2c03cf0$f29b12c2@secret.pythonware.com> <942499879snz@vision25.demon.co.uk> Message-ID: wtanksle at hawking.armored.net (William Tanksley) writes: > On 15 Nov 1999 20:48:39 GMT, Tres Seaver wrote: > >Michael Hudson wrote: > >>philh at vision25.demon.co.uk (Phil Hunt) writes: > > >>It's one of those things I might get round to writing one of these > >>days. I don't really know how hard it would be. Not especially, I > >>suspect. > > >Besides, you need to defer it until _after_ this year's Pythonic award, > >for which you are already in pole position for inventing bytecodehacks :). > > You might note that Tim is rather proud of being the only living recipient > of the Pythonic award (for some definition of 'life'). I understand he > might take action to keep that distinction if someone else were to win the > award. > > If you get what I mean. > I don't think the bytecodehacks, while sufficiently dark and useless to be a tim-ism, qualify me in any way for a Pythonic Wizard Hat when compared the sheer contribution in terms of wit, code, accurate advice, experience, emacs modes and general amazingly useful stuff that Tim Peters has given to the Python community. <0.0 wink>. Try http://www.python.org/tim_one/ if you don't see what I mean. not-a-bot-yet-ly y'rs - Michael From guido at cnri.reston.va.us Tue Nov 2 20:51:13 1999 From: guido at cnri.reston.va.us (Guido van Rossum) Date: 02 Nov 1999 20:51:13 -0500 Subject: Can't start IDLE References: <381F4EB1.AFD9BA32@src.uchicago.edu> Message-ID: <5lg0yotka6.fsf@eric.cnri.reston.va.us> Nick Collier writes: > On winNT sp3 I get the following message when I do a "python idle.py" > from the command line: > > C:\Program Files\Python\Tools\idle>python idle.py > Traceback (innermost last): > File "idle.py", line 3, in ? > PyShell.main() > File "PyShell.py", line 612, in main > fixwordbreaks(root) > File "EditorWindow.py", line 606, in fixwordbreaks > tk.call('tcl_wordBreakAfter', 'a b', 0) # make sure word.tcl is > loaded > TclError: invalid command name "tcl_wordBreakAfter" > > I looked around deja.com and found one other person with the same > problem, but no response so I'm asking here. Could it be that you have an older (or newer) Tcl version installed? Python (for now, until I upgrade the _tkinter module) requires Tcl/Tk 8.0.5 -- which is the version that comes with the Python 1.5.2 for Windows installer. Try to erase all traces of other Tcl installs and reinstall Python and see if that works. --Guido van Rossum (home page: http://www.python.org/~guido/) From g_will at cyberus.ca Mon Nov 29 12:08:40 1999 From: g_will at cyberus.ca (Gordon Williams) Date: Mon, 29 Nov 1999 17:08:40 GMT Subject: Pythonwin Reset References: <01bf38df$8127e0c0$3a42c3d1@Cyberus.cyberus.ca> <_X004.7432$VA6.38559@news-server.bigpond.net.au> <01bf39bd$a28831a0$4155c3d1@Cyberus.cyberus.ca> <81rmh5$9e$1@hub.org> Message-ID: <01bf3a8c$3f855b80$2241c3d1@Cyberus.cyberus.ca> Tim, Thanks for the note. It now works in that it eliminates all the names, but it doesnt quite fix my problem. When I make a GUI with wxPython (using Pythonwin IDE) and I get an exception, the next time I try and run the program after fixing the mistake, I get another exception saying One wxApps process only! Something was left behind. The only way I have found to clear the problem was to close Pythonwin and then restart it and reload the file. Regards, Gordon Williams tim muddletin wrote in article <81rmh5$9e$1 at hub.org>... > On Sun, 28 Nov 1999 16:29:35 GMT, Gordon Williams wrote: > >NameError: __main__ > > > >what has gone wrong? > > A non-obvious gotcha. You have to "import __main__" first, to get access > to the namespace in that way. > > > From moonseeker at my-deja.com Thu Nov 25 08:57:23 1999 From: moonseeker at my-deja.com (moonseeker at my-deja.com) Date: Thu, 25 Nov 1999 13:57:23 GMT Subject: natural speech parser? Message-ID: <81jf82$kil$1@nnrp1.deja.com> Hi, I'm looking for a command parser to parse sentences like: enable KEY1 and write 'Hello World' to var2 I havn't done such a thing like parsers or compilers (which works with command trees) since yet and would welcome any suggestion. Mike Sent via Deja.com http://www.deja.com/ Before you buy. From T.Middleton at news.vex.net Fri Nov 19 04:43:25 1999 From: T.Middleton at news.vex.net (T. Middleton) Date: 19 Nov 1999 09:43:25 GMT Subject: Proposal: Python Info Collective (another ramble) References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> <80ubrg$tuj$1@hub.org> <3dso23jvmf.fsf@amarok.cnri.reston.va.us> Message-ID: <81363t$1u17$1@hub.org> On 18 Nov 1999 17:14:00 -0500, Andrew M. Kuchling wrote: >it to a host without a weekly bandwidth limitation. Someone mentioned >putting it onto starship.python.net; is anything happening with that? I will be confirming by this weekend (hopefully) whether Vaults of Parnassus stays on vex.net (with bandwidth expanded) or not. Surely by the end of the month at the most all these things will be sorted out. (For the curious. Been doing about 30 megs traffic a day since it was 'outed' a mere 4 or 5 days ago... have recieved 11 hundred hits on the main page.) ... From mal at lemburg.com Fri Nov 5 08:31:47 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 05 Nov 1999 14:31:47 +0100 Subject: Module for generic platform information: platform.py References: <199911042207.XAA16602@axil.hvision.nl> Message-ID: <3822DC43.4B022439@lemburg.com> Hans Nowak wrote: > > On 4 Nov 99, M.-A. Lemburg wrote: > > > There is a new release of the platform.py module available at: > > > > http://starship.skyport.net/~lemburg/platform.py > > > > Still needed: > > ? support for WinCE > > ? support for MS-DOS (PythonDX ?) > > Hmm... Doesn't that work already? I tried it several days ago, so > with an older version of platform.py, obviously. Here's what it says > when fed to Python-DX: > > c:/djgpp/bin/uname.exe: invalid option -- p > Try `c:/djgpp/bin/uname.exe --help' for more information. > MS-DOS-7-pc > > (OK, the error message doesn't belong there, but that's just because > of the uname call. Most DOS users won't have an uname at all on their > system. In spite of this, it does find the right DOS version. By the > way, note that the os.popen, used to call uname, works. ;-) Not bad :-) I wonder where the 'pc' in the string comes from... BTW, I've added an if to prevent the call to 'uname -p' on DOS platforms, so the above error should no longer show up. > When run with Python for Windows (on the same PC) it says: > > Windows-95-4.00.1111 > > I don't know what it does on DOS 6 and lower, though. =/ Does Python run on those ? -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 56 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From aa8vb at yahoo.com Wed Nov 3 07:17:27 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Wed, 3 Nov 1999 07:17:27 -0500 Subject: Exceptions from callbacks In-Reply-To: <381FAE6D.73F426FE@lords.com> References: <381CA8E5.5D69E64@lords.com> <7virj4$b7b$1@towncrier.cc.monash.edu.au> <381FAE6D.73F426FE@lords.com> Message-ID: <19991103071727.A87523@vislab.epa.gov> Eric Dorland: |Jonathan Giddy wrote: |> Eric Dorland writes: |> |> >I'm writing a Python wrapper for a library. The library stores some |> >callbacks for some events, and with some glue code, get these to call |> >python functions. That's the easy part. Now since its the library these |> >callback and not Python per se, how do you pass an exception back to the |> >interpreter, because you can't return NULL from the callback. Do you |> >just set the exception, and Python will pick up on it? ... |You're not understanding exactly. It is synchronous (ie one thread), but |since the library is calling the callback, and not the python |interpreter, I can't return NULL to the interpreter. Basically, is there |a way from inside the callback to say "Wake up python, an exception!", |without having to return NULL to the interpreter, which is impossible |from the callback. I've done this, and I got the impression that Jonathan understood your question. What he described works and it's what I'm using. To extend your description, you don't say "Wake up, Python!" from the callback. You say it from the C function(s) from which you entered the C library that invoked the callback. Return NULL, and the exception is restarted with the Python stack frames saved in the callback in-tow. To make this concrete, for a C library API that might potentially invoke a callback (which in-turn would relay to Python) would look like this: (Python) -> HandlePendingMessages -> MYLIB -> Callback -> (Python) And your wrapper code might look like this: ------------------------------------------------------------------------------ PyObject *_wrap_MYLIBHandlePendingMessages( PyObject *self, PyObject *args ) { PyErr_Clear(); <<< call C function here >>> /* If a Python callback threw an exception, restart its propagation */ /* in the controlling Python. */ if ( PyErr_Occurred() ) return NULL; ... } ------------------------------------------------------------------------------ static void _wrap_MYLIBCallback( void ) /* C callback used to relay to Python callable objects. */ { ... /* Pass the buck onto Python */ pyresult = PyEval_CallObject( pyfunc, pyargs ); /* Call Python */ Py_DECREF( pyargs ); /* Trash arg list */ if ( pyresult ) Py_DECREF( pyresult ); /* Trash any result*/ /* If the callback threw an exception, it will be propagated across */ /* the C layer ( we check PyErr_Occurred() on the other side). */ } ------------------------------------------------------------------------------ If the Python callback tossed an exception, then it's still lying around when _wrap_MYLIBCallback() returns. We then return through the C library, which eventually returns to _wrap_MYLIBHandlePendingMessages, who recognizes that a Python exception is pending and restarts its propagation in the controlling Python stack frames. Note that if you have a C library layer that isn't Python-exception-aware, then it could go on to perform useless or invalid work after a Python callback throws an exception. In this case you'll need to "make" it aware. That is, have it call PyErr_Occurred(), or turn Python exceptions into C library errors inside of your callback wrappers. Hope this clarifies things a bit. Randall From JamesL at Lugoj.Com Thu Nov 25 14:48:09 1999 From: JamesL at Lugoj.Com (James Logajan) Date: Thu, 25 Nov 1999 11:48:09 -0800 Subject: Python complaints References: Message-ID: <383D9279.98543836@Lugoj.Com> Oleg Broytmann wrote: > > On Wed, 24 Nov 1999, James Logajan wrote: > > def ifexp(cond, trueVal, falseVal): > > if cond: > > return trueVal > > else: > > return falseVal > > > > print "You scored %s point%s" % (score, ifexp(score == 1, "", "s")) > > The problem with this solution is that python will calculate both > expressions (trueVal, falseVal) even if "cond" is false - what is VERY > undesireable in most situations. What if I just cannot calculate falseVal > if "cond" is false? > Then how about: if score == 1: suffix = "" else: suffix = "s" print "You scored %s point%s" % (score, suffix) I better put a in here; never know when the terminally lazy might become terminally ballistic! Besides the pluralization algorithm isn't portable to other languages (such as German...(do I need to add another wink?)) From wtanksle at hawking.armored.net Mon Nov 15 17:43:38 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 15 Nov 1999 22:43:38 GMT Subject: __str__ vs. __repr__ References: <000001bf275c$02370d20$1d2d153f@tim> <01fd01bf2dce$d2c03cf0$f29b12c2@secret.pythonware.com> <942499879snz@vision25.demon.co.uk> Message-ID: On 15 Nov 1999 20:48:39 GMT, Tres Seaver wrote: >Michael Hudson wrote: >>philh at vision25.demon.co.uk (Phil Hunt) writes: >>It's one of those things I might get round to writing one of these >>days. I don't really know how hard it would be. Not especially, I >>suspect. >Besides, you need to defer it until _after_ this year's Pythonic award, >for which you are already in pole position for inventing bytecodehacks :). You might note that Tim is rather proud of being the only living recipient of the Pythonic award (for some definition of 'life'). I understand he might take action to keep that distinction if someone else were to win the award. If you get what I mean. >Tres. watching-my-back-and-underachieving-ly y'rs, -- -William "Billy" Tanksley <1.0 wink> From jeremy at cnri.reston.va.us Mon Nov 1 17:04:03 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Mon, 1 Nov 1999 17:04:03 -0500 (EST) Subject: Feature request for interactive interpreter In-Reply-To: <51C9F3C392D0D111A15600A0C99E64A9AF5606@localhost> References: <51C9F3C392D0D111A15600A0C99E64A9AF5606@localhost> Message-ID: <14366.3667.934145.165288@goon.cnri.reston.va.us> Python already lets you run user-supplied code every time you fire up an interactive interpreter (PYTHONSTARTUP environment variable). If you add your definition for help that way, there would be no need to change Python. Jeremy From donn at u.washington.edu Wed Nov 10 13:27:14 1999 From: donn at u.washington.edu (Donn Cave) Date: 10 Nov 1999 18:27:14 GMT Subject: Exceptions: ^z References: <38299522.5D06E8D5@sw.ods.com> Message-ID: <80cde2$oou$1@nntp6.u.washington.edu> Quoth Sai Ramanath : | Is there a way to catch Ctrl-Z which in UNIX lets the user suspend the Python | shell into background? | | I know we can catch Ctrl-C and Ctrl-D using KeyboardInterrupt and EOFError | respectively. You'd use signal.signal(signal.SIGTSTP, signal_handler_function) I wouldn't want to actually do that, myself. Partly because UNIX signal handling and Python don't get along too well, partly because it doesn't pay to tinker with the delicate machinery of Berkeley job control. If all you really want is to turn off this feature, do that with the terminal driver: import termios import TERMIOS attr = termios.getattr(0) attr[6][TERMIOS.VSUSP] = '\000' # '\032' sets it back to ^Z termios.setattr(0, TERMIOS.TCSANOW, attr) Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From a.eyre at optichrome.com Mon Nov 29 09:15:45 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Mon, 29 Nov 1999 14:15:45 -0000 Subject: XML tool status? In-Reply-To: Message-ID: <000d01bf3a74$3a4aa110$3acbd9c2@peridot.optichrome.com> > 1) I can't find a Windows version of the software; and Odd. It should be platform independent. > 2) the Python XML SIG status page has a "most recent update" date from > December 1998 --- is that fossilware, or has there really not > been anything new posted since then? The website is not updated as often as the source. You'll have to grab it via CVS. See: http://www.python.org/sigs/xml-sig/anon-cvs.html -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From gmcm at hypernet.com Mon Nov 1 15:40:01 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Mon, 1 Nov 1999 15:40:01 -0500 Subject: __str__ vs. __repr__ In-Reply-To: <19991101121709.A134039715@vislab.epa.gov> Message-ID: <1270634443-26149069@hypernet.com> Randall Hopper wrote: > 1) Is there a convention for what __str__ and __repr__ should > return for > classes? > 2) Or, whatever they return, should they return the same value? > 3) If so, why have both in the language? If possible, __repr__ should return something that when eval'd yields an identical object. If that's not possible, it should be the programmer's view of the object. __str__ is free to return a highly munged user-friendly string. str(obj) will use obj.__repr__ if obj.__str__ doesn't exist. Consider this: class HTMLTable: blah blah blah t = HTMLTable(...) repr(t) # -> "MyModule.HTMLTable([...])" str(t) # -> "....." (see IPWP for this idea carried to extreme lengths). > Searching the archives yields an example with odd behavior > that > suggests they should generally return the same value: > > class c: > def __str__(self): return 'foo' > def __repr__(self): return 'bar' > > >>> str(c()) > 'foo' > > >>> str([c(), c(), c()]) > '[bar, bar, bar]' Sick enough, but not convoluted enough, to be a Tim-ism... - Gordon From T.Muddletyn at news.vex.net Tue Nov 16 01:58:14 1999 From: T.Muddletyn at news.vex.net (T. Muddletyn) Date: 16 Nov 1999 06:58:14 GMT Subject: Proposal: Python Info Collective References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> <80pe77$osc$1@hub.org> Message-ID: <80qva6$1fgh$1@hub.org> On 15 Nov 1999 17:41:30 GMT, Mitchell Morris wrote: >My personal take is that you never actually look at CPAN in a browser. The Yes, you make a good point there. My rant was based on a narrow and biggotted browser view. The command line tools for searching and retrieving are a potentially very handy thing. Martijn Faassen in a previous message made the great suggestion of possibly integrating Parnassus somehow with the "distutils" system which is being worked on. It would be very interesting. As things are now, with python resources being so diversely packaged and hosted, it would require a fair bit of effort and time by all owners of resources to re-package themselves for compliance for a full blown system like this to take off (though one has to start somewhere!) On the other hand, a simple command-line querying util, at every least, would be really cool (and save me a bit of bandwidth too! heh) I'll definitely think about this! ... From da at ski.org Fri Nov 5 13:40:36 1999 From: da at ski.org (David Ascher) Date: Fri, 5 Nov 1999 10:40:36 -0800 (Pacific Standard Time) Subject: IPC8: SouthWest Airlines Internet specials Message-ID: For those of you who are paying for the IPC8 conference out of your personal entertainment budget: I just bought tickets to go to the IPC8 Conference for $194 roundtrip on Southwest from Oakland, CA. I fly into Baltimore-Washington, which saves a *lot* of money, even factoring in ground transportation. I mention it because the internet special has to be bought before November 8th. --david ascher From matz at netlab.co.jp Thu Nov 4 23:30:43 1999 From: matz at netlab.co.jp (Yukihiro Matsumoto) Date: 05 Nov 1999 13:30:43 +0900 Subject: Some more Ruby observations (Re: Comparison between Python and "Ruby") References: <3819BCDA.AC4FD4CA@strs.co.uk> <87k8o2x67f.fsf@ev.netlab.co.jp> <7vjtrc$hmm$1@newshost.accu.uu.nl> <3821A860.5D32AFCC@compaq.com> Message-ID: <87904dv9u4.fsf@ev.netlab.co.jp> neelk at brick.cswv.com (Neel Krishnaswami) writes: |Are there any syntax-tree munging phases to do stuff like common |subexpression elimination and loop hoisting? I guess that could yield |enough speedups to make a VM not yet necessary. No. It's pretty hard to optimize a dynamic language like Ruby, in which even integer addition can be re-defined. The optimizer can't tell whether a subexpression has side effect or not. Optimization ideas are welcome, though. :-) matz. From news at dorb.com Mon Nov 15 14:19:01 1999 From: news at dorb.com (Darrell) Date: Mon, 15 Nov 1999 14:19:01 -0500 Subject: Memory not being released? References: <80pdvo$99r$1@nnrp1.deja.com> Message-ID: <%_YX3.8353$wG3.451084@typhoon.nyroc.rr.com> Here's an idiom I like in this case. Store your objects in a dict based on id(obj), just as you've done. Now if objects must reference each other use the id(obj) and look up the obj. And delete them from the dict when needed. Yes it's slow but only use it in these big ugly cyclic data structures. But notice how fast memory gets used up. This eats 84meg. >>> dict={} >>> for x in xrange(1000000): ... dict[x]=(x,x+1) ... >>> You might take a look at shelve. It gives you a persistent dictionary. I've been playing with a flat file manager that can reclaim freed space. -- --Darrell Steve Tregidgo wrote in message news:80pdvo$99r$1 at nnrp1.deja.com... > Hi there, > > I'm having problems with a large process, and I'd really appreciate > some help in tracking down the cause of its bloatedness. > From aa8vb at yahoo.com Tue Nov 2 07:34:22 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Tue, 2 Nov 1999 07:34:22 -0500 Subject: __str__ vs. __repr__ In-Reply-To: <000701bf24ef$e2d29b20$0f2d153f@tim> References: <1270634443-26149069@hypernet.com> <000701bf24ef$e2d29b20$0f2d153f@tim> Message-ID: <19991102073422.B134170008@vislab.epa.gov> Tim Peters: |[Randall Hopper gives an example] |> class c: |> def __str__(self): return 'foo' |> def __repr__(self): return 'bar' |> |> >>> str(c()) |> 'foo' |> |> >>> str([c(), c(), c()]) |> '[bar, bar, bar]' | |[which Gordon McMillan explains, adding] |> Sick enough, but not convoluted enough, to be a Tim-ism... | |The real illness is that lists (and dicts, and tuples) don't pass |str-vs-repr'ness *down*. That is, even though the example explicitly |asks for str of a list, the list object asks for the repr of its |elements. That's convoluted: if (as happens to be true) str is meant to |give a friendly string, why do the builtin container types ask their |containees to produce unfriendly strings regardless? Thanks. That's the source of my confusion. I wanted to follow the language convention. But Python's internals currently don't follow it, so the point is somewhat moot. For consistency, would it make sense to change this for Python 1.5.3 (that is, have sequence and dict types pass 'str-vs-repr'ness down)? Thanks, Randall -- Randall Hopper aa8vb at yahoo.com From mhammond at skippinet.com.au Mon Nov 8 17:45:54 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 08 Nov 1999 22:45:54 GMT Subject: .dll and .exe file version informaton References: <806tck$5o9$1@nnrp1.deja.com> Message-ID: Thw win32 extensions currently dont expose that - but someone is working currently on a win32ver module... So no for now, but soon... Mark. emuller at painewebber.com wrote in message <806tck$5o9$1 at nnrp1.deja.com>... >Can anyone give me an idea how to quikly get the version info on .dll >and .exe files under windows? > > >Sent via Deja.com http://www.deja.com/ >Before you buy. From tbryan at python.net Wed Nov 24 06:19:30 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Wed, 24 Nov 1999 06:19:30 -0500 Subject: Python complaints References: Message-ID: <383BC9C2.901A2D6@python.net> Mikael Olofsson wrote: > > On 24-Nov-99 Thomas Hamelryck wrote: > > Block delimitation by indenting. > > I am one of those who appreciates this. My reason is the following: I generally don't mind this aspect of Python, but I've recently found that it can cause problems when transmitting code. For example, I saw some code that I wanted to copy in DejaNews c.l.py archives, but the lines wrap in narrow columns in DejaNews. I had to reindent the code. Grrr. I have also had problems when e-mailing code when I e-mail the code as text in the message instead of attaching a document. Is there a better way to transmit code so that possible indentation munging won't force the reader to reindent? vaguely-remembering-something-about-option-BEGIN-and-END-ly yours ---Tom From kuncej.CENTRAL2.MDCEMAIL at mail.conservation.state.mo.us Fri Nov 19 11:29:40 1999 From: kuncej.CENTRAL2.MDCEMAIL at mail.conservation.state.mo.us (Jeffrey Kunce) Date: Fri, 19 Nov 1999 10:29:40 -0600 Subject: UserDict, UserList... UserFile? Message-ID: >why isn't there a UserFile class, while there is a UserList and a UserDict? >... >Otherwise, I'll write it myself; it shouldn't be too hard! If you write your own, StringIO.py in the standard library might be a good template to work from. --Jeff From nospam at bitbucket.com Sat Nov 27 02:12:29 1999 From: nospam at bitbucket.com (Phil Mayes) Date: Fri, 26 Nov 1999 23:12:29 -0800 Subject: threading and timeouts References: <943504970.076.346131773@cs.usyd.edu.au> Message-ID: Piers Lauder wrote in message <943504970.076.346131773 at cs.usyd.edu.au>... >Are timeouts possible inside threads? > >Eg: escaping from an attempt to use smtplib.SMTP().sendmail() inside a >child thread if the remote host is being extremely slow. > >It doesn't seem possible to use the traditional signal(SIG_ALRM,...) >approach because signals only work inside the main thread. > >The only option I can think of is to re-write the smtplib module to use >`select', but does anyone know of a simpler solution? I struggled with this for some time, failed to get plain old timeouts working, and ended up with a timeout_socket.py that uses select, based on code from Lloyd Zusman . I then take advantage of smtplib.py and poplib.py by inheriting: class timeout_POP3(poplib.POP3): def __init__(self, host, port = poplib.POP3_PORT): self.host = host self.port = port self.sock = timeout_socket.timeout_socket() self.sock.connect(self.host, self.port) self.file = self.sock.makefile('rb') # same as poplib.POP3 self._debugging = 0 self.welcome = self._getresp() class timeout_SMTP(smtplib.SMTP): def connect(self, host='localhost', port = 0): """Connect to a host on a given port. Override the std SMTP connect in order to use a timeout_socket. """ if not port: i = string.find(host, ':') if i >= 0: host, port = host[:i], host[i+1:] try: port = string.atoi(port) except string.atoi_error: raise socket.error, "nonnumeric port" if not port: port = smtplib.SMTP_PORT self.sock = timeout_socket.timeout_socket() if self.debuglevel > 0: print 'connect:', (host, port) self.sock.connect(host, port) (code,msg)=self.getreply() if self.debuglevel >0 : print "connect:", msg return (code,msg) This allows me to use poplib.py & smtplib.py unchanged. The timeout_socket class follows. I run on Win9x and have a vague feeling that this won't run on Unix which is why I didn't publish it before. If you find out why, yell! ------------ code start ---------------------- """ timeout socket class for connections that can potentially cause the server to hang """ import socket import errno import select import string #import appstate # see comment below _TIMEOUT = 20.0 class Timeout(Exception): pass class Closing(Exception): pass class timeout_socket: def __init__(self, timeout=_TIMEOUT, s=None): self.timeout = timeout self.inbuf = '' if s == None: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.s = s self.s.setblocking(0) # destructor notes: socket.socket will close when destroyed def connect(self, host, port): timeout = self.timeout s = self.s try: # Non-blocking mode s.setblocking(0) s.connect(host,port) s.setblocking(timeout != 0) return 1 except socket.error,why: # The exception arguments can be (string) or (int,string) if len(why.args) == 1: code = 0 else: code,why = why if timeout: s.setblocking(1) if code in (errno.EINPROGRESS, errno.EALREADY, errno.EWOULDBLOCK): # Ok, then wait... r,w,e = select.select([],[s],[],timeout) if w: try: s.connect(host, port) return 1 except socket.error,why: # This can throw string or (int,string) if len(why.args) == 1: code = 0 else: code,why = why if code == errno.EISCONN: return 1 except: code = 0 why = 'Unknown error trying to connect' # format the error message if code: code = 'error %d = ' % code else: code = '' msg = 'Connect to %s timed out after %d sec (%s%s)' % (host, int(self.timeout), code, why) raise Timeout, msg def send(self, data, timeout=0): next = 0 t = timeout or self.timeout total = len(data) while 1: if appstate.state > appstate.running: raise Closing, 'closing' r,w,e = select.select([],[self.s], [], t) if w: buf = data[next:next+8192] sent = self.s.send(buf) next = next + sent if next == total: return else: raise Timeout, 'timeout while sending "%.20s...": %d sec' % (data, int(t)) def recv(self, amt, timeout=0): t = timeout or self.timeout r,w,e = select.select([self.s], [], [], t) if r: recvd = self.s.recv(amt) return recvd if not hasattr(self,'s'): print 'timeout_socket has no socket s ?!',self.s #TMP - Sam's problem 9/21 raise Timeout, "timeout while receiving from %s: %d sec" % (`self.s.getpeername()`, int(timeout)) def recvpending(self, timeout=0): """ returns 1/0 """ return [] != select.select([self.s], [], [], timeout or self.timeout)[0] def read(self, amt): """ This only returns when amt has been read or socket times out """ # new version works with readline (except this doesn't convert CRLF => LF) while 1: if appstate.state > appstate.running: raise Closing, 'closing' if len(self.inbuf) >= amt: break self.inbuf = self.inbuf + self.recv(4096) data = self.inbuf[:amt] self.inbuf = self.inbuf[amt:] return data # new readline buffers data # this -isn't- called for the makefile clone def readline(self): while 1: # useful but non-generic code: # if appstate.state > appstate.running: # raise Closing, 'closing' crlf = string.find(self.inbuf, '\r\n') if crlf >= 0: break self.inbuf = self.inbuf + self.recv(4096) data = self.inbuf[:crlf] + '\n' self.inbuf = self.inbuf[crlf+2:] return data def close(self): self.s.close() def makefile(self, flags): self.s.setblocking(1) # s is a socket._socketobject save = self.s._sock # stash the real thing self.s._sock = self # replace it by us # this call creates a _fileobject that has been passed self as the socket x = self.s.makefile(flags) self.s._sock = save # restore the real socket return x ------------ code end ------------------------ -- Phil Mayes pmayes AT olivebr DOT com Olive Branch Software - home of Arranger http://www.olivebr.com/ From jeremy at cnri.reston.va.us Tue Nov 2 14:40:52 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Tue, 2 Nov 1999 14:40:52 -0500 (EST) Subject: Assorted Questions regarding the future of Python... In-Reply-To: References: <6D8A17398E28D3119F860090274DD7DB49833A@pces.cadlab.it> <006201bf2517$50edf1f0$f29b12c2@secret.pythonware.com> Message-ID: <14367.15940.373465.105829@goon.cnri.reston.va.us> >>>>> "FP" == Fran?ois Pinard writes: FP> I'm curious. Does Python use standard optimisation techniques FP> on that byte code (CSE, strength reduction, and all that)? I FP> would be tempted to guess that the stack machine receives code FP> that pretty closely resemble the source code. Would the stack Good guess! FP> machine be able to express optimisations? For example, could we FP> copy or exchange arbitrary stack elements? Take a look at the Optimizing Python session at the last Python conference. http://www.foretec.com/python/workshops/1998-11/proceedings.html In particular, see Skip's paper. http://www.foretec.com/python/workshops/1998-11/proceedings/papers/montanaro/montanaro.html Jeremy From robin at jessikat.demon.co.uk Sun Nov 28 18:58:54 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Sun, 28 Nov 1999 23:58:54 +0000 Subject: http://www.python.org/ blank ? Message-ID: for some reason I see http://www.python.org/ as a blank page. Any ideas? -- Robin Becker From garabik at melkor.dnp.fmph.uniba.sk.spam Fri Nov 5 09:07:52 1999 From: garabik at melkor.dnp.fmph.uniba.sk.spam (Radovan Garabik) Date: 5 Nov 1999 14:07:52 GMT Subject: finding out console user (Win95) Message-ID: <941814380.235290@cdwork.cvt.stuba.sk> I am porting my script from unix to windows, and I need to find console user under win95 (under WinNT I can use os.environ['USERNAME'], which is not exactly console user, but good enough for me). Something like cuserid() or getlogin() as implemented in Cygwin would be ideal.... Is there a simple way to find it? TIA -- ----------------------------------------------------------- | Radovan Garabik http://melkor.dnp.fmph.uniba.sk/~garabik/ | | __..--^^^--..__ garabik @ fmph.uniba.sk | ----------------------------------------------------------- Antivirus alert: file .signature infected by signature virus. Hi! I'm a signature virus! Copy me into your signature file to help me spread! From fredrik at pythonware.com Tue Nov 30 08:59:23 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 30 Nov 1999 14:59:23 +0100 Subject: Htmlizing text References: <943909426snz@vision25.demon.co.uk> <19991129170705.A314@better.net> <19991130141224.A2813@stopcontact.palga.uucp> <002301bf3b39$5b5bc9e0$f29b12c2@secret.pythonware.com> Message-ID: <005b01bf3b3b$1c14d5e0$f29b12c2@secret.pythonware.com> I wrote: > Gerrit Holl wrote: > > By the way, why doesn't the cgi module does this? > > if you use ISO Latin 1 for your pages (which happens to > be default in HTTP/1.1, HTML 3.0, and real life), you > don't really have to quote all possible entities just be- > cause you can... and yes, your code assumes that the original string always uses ISO Latin 1. the cgi version works fine with plain ASCII, and *any* 8-bit ISO encoding. From versation at home.com Wed Nov 3 10:52:32 1999 From: versation at home.com (Pat Ward) Date: Wed, 03 Nov 1999 15:52:32 GMT Subject: working Tcl/Tk8.2.1 & python - broken Tkinter Message-ID: <4TYT3.7612$OS2.690403@news.rdc1.il.home.com> I have a working Tcl/Tk8.2.1 & python1.5.2 on RH linux/alpha. Tkinter passes: import _tkinter import Tkinter fails: Tkinter._test() dumping core I compiled Tcl/Tk with the Compaq beta compiler which gave me a better build than egcs I've tried compiling Python with both the Compaq and the egcs. Either gives me a working _tkinter and a core dumping "test". I believe that the Modules/Setup is correctly modified and re-made. I'm baffled. Any ideas? -- Pat Ward Versation Corp. - phone 847.506.9095 digital audio and digital media services 425 N. Douglas Avenue Arlington Heights IL 60004-6122 | http://versation.net/ From hildeb at www.stahl.bau.tu-bs.de Sat Nov 27 12:35:42 1999 From: hildeb at www.stahl.bau.tu-bs.de (Ralf Hildebrandt) Date: 27 Nov 1999 17:35:42 GMT Subject: fcntl/ioctl and O_NONBLOCK References: <81ml5t$eer$0@216.39.151.169> <81p32a$m14$1@216.39.151.169> Message-ID: On 27 Nov 1999 17:06:18 GMT, Donn Cave wrote: >Right - if there's anything to read, you will read only that and >not block. (So of course you must always check how much you actually >have read!) Select tells you precisely that your I/O won't block, >either because there's data to read or end of file. Fine. My problem here is the following: I start a program (plot) and feed it with random input data until it crashes. Output is irrelevant to me, I need only know if it crashes or exit()'s. On the shell: % plot < t1 > /dev/null Segmentation fault. In my Python program, though: The program ran for a while and never returned. It didn't crash, it didn't exit, nothing. It just sat there status "sleep" (displayed top). It didn't consume cpu-time, either. I figured I should empty fromchild (since the command above generates 8MB of output) from time to time. Then I came across the select() problem. This is also fixed now, but now the popen3 Object generates about 1 MB of output (which I read using select() and read()), and then it STILL doesn't return. No crash, no exit. And once more, in top it says "sleep" once more. Any ideas what's going on there? >I guess - except of course, sockets are bi-directional, and pipes are >one direction only. One direction is sufficient for me. From tim_one at email.msn.com Tue Nov 30 01:59:52 1999 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 30 Nov 1999 01:59:52 -0500 Subject: '==' vs. 'is' behavior In-Reply-To: Message-ID: <000501bf3b00$802af180$c92d153f@tim> [Fran?ois Pinard] > By the way, is there common wisdom (or rather, maybe, > usage-standards-to-be) about using `is' instead of `=='? In general, don't -- you'll often end up regretting this cleverness. Note that a is b is the same as id(a) == id(b) so the former is *appropriate* only when the latter is *intended*. A good example of appropriate use is in copy.deepcopy, where Python's by-value == is useless for determining whether a structure contains a cycle. A terrible example is "if i is 42": whether that appears to work is an accident that may change from release to release or even run to run. That said, a few objects are guaranteed to exist uniquely, and so it's OK (but dubious anyway) to use "is" with them. "x is None", "x is types.StringType" (and friends), sometimes "x.__class__ is MyClass", and "s is t" where it's *known* that s and t are both intern()ed strings. BTW, the truth of "x is y" implies the truth of "x == y", because the first thing the (current) implementation of comparison does is check for pointer equality. However, "x == y" does not imply "x is y". Clearest and safest: don't use "is" when "==" would suffice. Most pragmatic: don't use "is" unless you know you can get away with it forever. Most common: use "is" randomly, then complain about suspected Python bugs at 3 in the morning <0.9 wink>. x-is-y-is-y-is-x-is-not-x-is-not-y-is-not-y-is-not-x-ly y'rs - tim From stidolph at origin.ea.com Tue Nov 16 14:58:45 1999 From: stidolph at origin.ea.com (Stidolph, David) Date: Tue, 16 Nov 1999 13:58:45 -0600 Subject: list.without()? Message-ID: <11A17AA2B9EAD111BCEA00A0C9B41793034AAEE7@molach.origin.ea.com> so ... def without(source, element): while element in source: source.remove(element) Is that what you are looking for? It would help if I had read the earlier posts! :) -----Original Message----- From: Christian Tismer [mailto:tismer at appliedbiometrics.com] Sent: Tuesday, November 16, 1999 11:15 AM To: Magnus L. Hetland Cc: python-list at python.org Subject: Re: list.without()? "Magnus L. Hetland" wrote: > > "Mike Fletcher" writes: > > > Well... > > > > def without( source, element): > > temp = source[:] > > while temp: > > try: > > temp.remove( element ) > > except: > > break > > return temp > > Whoa! > > Why on *earth* would you use a while/try/break-combination? IMO a much > more natural solution would be: > > def without(source, element): > result = source[:] > if element in result: > result.remove(element) > return result But that would be wrong. "Without" means "there is no such object in it", while list.remove removes the first occourance of an object. Mike's implementation appears to be very cheap, since through the try..except clause, he can combine removal with test for existance. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home -- http://www.python.org/mailman/listinfo/python-list From OlaFried at news.vex.net Sat Nov 13 12:05:35 1999 From: OlaFried at news.vex.net (Ola Fried) Date: 13 Nov 1999 17:05:35 GMT Subject: DBF interface References: <382C38AF.69FFACF4@obop.com.pl> Message-ID: <80k5ov$2di6$1@hub.org> On Fri, 12 Nov 1999 16:56:32 +0100, Przemys?aw G. Gawro?ski wrote: >Is there a DBF file interface module ? I actually have two of them listed in my little non-dbf database... http://www.vex.net/~x/parnassus/apyllo.py?find=dbf The one already mentioned by Michael and S., plus another by Lars Garshol called dbfreader at http://www.stud.ifi.uio.no/~lmariusg/download/python/ Though if you are on MS platform have ODBC and any MS's (or borland's) database engine you could access your DBF completely that way probably, using the odbc module, or the even better mxODBC. ... From billtut at microsoft.com Wed Nov 24 04:52:29 1999 From: billtut at microsoft.com (Bill Tutt) Date: Wed, 24 Nov 1999 01:52:29 -0800 Subject: Python and COM: a bug? Message-ID: <4D0A23B3F74DD111ACCD00805F31D8100DB915A7@RED-MSG-50> Well if you can reproduce it, others will try to fix it! Or at least try to find a workaround, if it can't be fixed. Just sitting around saying this or that sometimes happens doesn't help many people out. Saying your C++ code is ok just because it works with VB/VBScript doesn't necessarily make it ok code. > -----Original Message----- > From: Adrian Eyre [mailto:a.eyre at optichrome.com] > > > We did get some oddities running PythonCOM through Rational's > Purify: I > don't have the results any more, but I seem to remember there > was internal > memory corruption somewhere. Not being a COM kind of person, > I found an > easier solution by removing PythonCOM from the project > entirely, and going > via an extension module instead. > Do you recall what kind of scenario caused the problems or did any old PythonCOM usage cause the problem? Bill From mhammond at skippinet.com.au Tue Nov 2 21:31:44 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 3 Nov 1999 13:31:44 +1100 Subject: Reading .lnk files In-Reply-To: <004801bf258f$5c19d0d0$0501a8c0@bobcat> Message-ID: <006301bf25a3$92a7f140$0501a8c0@bobcat> OK - thanks everyone - it seems certain that the code does indeed work, and that the problem was something specific to Ivan - quite possibly his use of the MKS shell. Ive had positive responses from NT, 98 and 95 now. Thanks, Mark. [I wrote] > Ivan has mailed me that this does not work for him (dies with a big > crash!). If anyone else has a spare moment, could you please try this > code and see if it works? Whether it does or not, please also include > info on the OS you tried it on. Please mail me personally with this > info, and I will summarize back to the list. > > Thanks, > > Mark. > > > -----Original Message----- > > From: python-list-admin at python.org > > [mailto:python-list-admin at python.org]On Behalf Of Mark Hammond > > Sent: Wednesday, 3 November 1999 9:44 > > To: 'Ivan Van Laningham'; 'Python Mailing List' > > Subject: RE: Reading .lnk files > > > > > > Sure is. For more details, see the COM help file on PyIShellLink. > > > > Mark. > > > > # DumpShortcut.py > > # A demo of how to dump a shortcut using Python. > > > > # This code dumps the shortcut specificed as sys.argv[1] > > > > from win32com.shell import shell > > import pythoncom > > > > def DumpIt(fileName): > > # Get the shell interface. > > sh = pythoncom.CoCreateInstance(shell.CLSID_ShellLink, None, \ > > pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink) > > > > # Get an IPersist interface > > persist = sh.QueryInterface(pythoncom.IID_IPersistFile) > > > > persist.Load(fileName) > > > > # Get the data > > print "Path name:", sh.GetPath(shell.SLGP_SHORTPATH)[0] > > print "Args:", sh.GetArguments() > > print "Description:", sh.GetDescription() > > print "Working directory:", sh.GetWorkingDirectory() > > > > if __name__=='__main__': > > import sys > > DumpIt(sys.argv[1]) > > > > # demo of usage: > > C:\>DumpShortcut.py IDLE.lnk > > Path name: L:\src\PYTHON~1.2\PCbuild\pythonw.exe > > Args: l:\src\python-cvs\tools\idle\idle.pyw > > Description: > > Working directory: L:\src\python-cvs\tools\idle > > > > > > -- > > http://www.python.org/mailman/listinfo/python-list > > > > > -- > http://www.python.org/mailman/listinfo/python-list > From bjorn at roguewave.com Tue Nov 2 15:59:16 1999 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Tue, 2 Nov 1999 13:59:16 -0700 Subject: capturing stderr && stdout Message-ID: <51C9F3C392D0D111A15600A0C99E64A9AF560C@localhost> What you want is in module popen2, probably popen2.popen3 (they're described in the module reference). -- bjorn > -----Original Message----- > From: Agent Drek [mailto:drek at monsterbymistake.com] > Sent: Tuesday, November 02, 1999 12:19 PM > To: python-list at python.org > Subject: capturing stderr && stdout > > > Hullo, > > I have searched the web and all the python documents/examples > I could find > before posting here. My apologies if I have missed the > obvious :) (I bought > two books as well that I am going through) > > Alot of what I need to do with python depends on launching > and controlling > a subprogram called hscript. It's a 'closed' application that > is not a full > bodied language like python. I am hoping to launch one > instance of hscript > write to it and keep its stdout && stderr. > > Most of our work gets done with csh scripts like the following: > > #!/bin/csh -f > > #csh stuff goes here > > hscript -q $HIPDIR/$HIPFILE << ENDCAT >>&! $LOG > # now I write hscript commands > opcf /obj > #etc > ENDCAT > exit > > > here's a stripped down version of what I have thus far. > > > #!/usr/local/bin/python > > import os, sys > HSCRIPT = "hscript" > > p = os.popen("%s" % HSCRIPT, "w") > p.write("opcd /obj\n") > p.write("opadd geo\n") > p.write("opls\n") > p.write("quit\n") > > > This is great so far but I just need stderr from hscript > (just in case it > crashes:) and stdout (to keep a neat log file) > > This will need to work on *nix. > > I'm trying to move to python as our main scripting language > so that we can > reuse code and integrate a gui (tkinter) easily into our apps. > > If you're interested in what hscript is you can visit http://www.sidefx.com/ and check out houdini. thanks for any tips, =derek Monster By Mistake Inc > 'digital plumber' mailto:drek at monsterbymistake.com http://www.interlog.com/~drek "This mail was powered by Linux & Vim" -- http://www.python.org/mailman/listinfo/python-list From phd at phd.russ.ru Wed Nov 10 08:19:58 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Wed, 10 Nov 1999 13:19:58 +0000 (GMT) Subject: SWIG and function name question In-Reply-To: <7vqojf$bgf$1@marcie.fissiontech.com> Message-ID: On 4 Nov 1999, Scott Barron wrote: > class Foo: > self.f = foo.__foo # Create an alias for foo.__foo > If I comment out self.f = foo.__foo all works fine. What am I doing wrong > here? Inside a class, all nmaes that starts with double underscore (__) mangles into Klassname__name. > self.f = foo.__foo # Create an alias for foo.__foo This is equivalent to > self.f = foo.Foo__foo And python cannot find any Foo__foo... Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From fdrake at acm.org Mon Nov 29 17:27:36 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Mon, 29 Nov 1999 17:27:36 -0500 (EST) Subject: Modules/getpath.c chases links? In-Reply-To: <199911280746.XAA29926@lotus.CS.Berkeley.EDU> References: <199911280746.XAA29926@lotus.CS.Berkeley.EDU> Message-ID: <14402.64984.900304.580726@weyr.cnri.reston.va.us> Edward Jason Riedy writes: > Is there a reason why Modules/getpath.c chases links to get the > `correct' path? I'd like to see that removed, but the comments > make me think someone had a specific reason for including it. Jason, Without that, automatic detection of the installation directories becomes massively fragile. Consider a fairly reasonable installation: $prefix == $exec_prefix == /opt/python/1.5.2 symlinks: /usr/local/bin/python --> python152 /usr/local/bin/python152 --> /opt/python/1.5.2/bin/python Without the symlink chasing, the standard library won't be found (I don't think it even needs to be that complex). > I use symlink trees to separate out different versions of packages > distributed by different people (here, stock python 1.5.2 and the > LLNL-distributed NumPy). The symlink chasing breaks this badly > by looking into the symlinked directory rather than using the tree > of symlinks. I'm not sure I follow. This sounds incredibly difficult to maintain. What does it buy you? > Simply removing the code protected by HAVE_READLINK makes my life > much nicer. I'd really like to see it officially removed. (If you > want a full-featured system for finding the installation, check the > kpathsea library in the Web2C distribution of TeX.) kpathsea is overkill for most things; anything that doesn't have the number of critical configuration items that a TeX installation has doesn't need such a heavy approach. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From fdrake at acm.org Fri Nov 5 11:12:50 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Fri, 5 Nov 1999 11:12:50 -0500 (EST) Subject: Apply a function to each list member? In-Reply-To: <19991105215504.A497@Ridcully.home> References: <19991105215504.A497@Ridcully.home> Message-ID: <14371.514.406346.901988@weyr.cnri.reston.va.us> Malcolm Tredinnick writes: > one-to-one, not one-to-many). So some mapping that sends, say, the number 2 > to the numbers 3 and 4 is not a function (but a mapping that sends both the > numbers 3 and 4 to the number 2 is a function, since for each input there For people who are confused, this is also called a "relation." All functions are relations, but not all relations are functions (for exactly the reasons Malcolm gives). -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From news at dorb.com Wed Nov 24 10:47:10 1999 From: news at dorb.com (Darrell) Date: Wed, 24 Nov 1999 10:47:10 -0500 Subject: CRC-module References: <38396766.B189D15A@bibsyst.no> <383C1089.1D0F7C18@bibsyst.no> Message-ID: >From Fredrik's post: sha (160-bit digest) So more bits are better and 160 bits is best. UNTESTED: shaHash=sha.sha(open(yourFile).read()).digest() The output is a number. But if you look at any 8bits of the 160 possible bits. Some may be printable characters. -- --Darrell "Thomas Weholt" wrote in message news:383C1089.1D0F7C18 at bibsyst.no... > Hi, > > Ok, so I`ve looked into zlib.crc32 and zlib.adler32. They seem easy > enough to use, but I thought crc-codes had characters and numbers in > them, not just a plain integer like the methods above return. ( As you > can see, I`m a complete ass on this subject, but don`t have time to do > the proper research myself, and was hoping for a "quick fix" ... ) > > A friend of mine mentioned that I should try SHA-1 instead, for more > accuracy. Can anybody give me an example on how to compute crc-codes, > using zlib or preferrably some more accurate method, for single files ?? > > If this is all it takes : > > crc = module_name.crc_method(file) > > and comparison is done like : > > if (crc1 == crc2): print "Equal." > else : print "Different." > > then all I need is the name of the most effective/accurate module to > use. > > If, for some strange reason, I should use one module instead of another, > that info would be interesting too. > > I`ll stop bother you now and let you get back to work. ;-> > > Thomas Weholt > > -- > http://www.python.org/mailman/listinfo/python-list From tekhir at yahoo.com Sun Nov 14 18:47:46 1999 From: tekhir at yahoo.com (Jeremy Misavage) Date: Sun, 14 Nov 1999 18:47:46 -0500 Subject: Setting up Pythong for IIS/PWS Message-ID: <382F4A22.514281A8@yahoo.com> First I want to thank everyone who answered my previous question. All of you helped me out. Now I have anotehr uestion. I don't think I setup IIS on NT and PWS on Win95 correctly. Supposly you just: "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\ScriptMap and enter the following line (making any specific changes that your system may need) .py :REG_SZ: c:\\python.exe -u %s %s " But I keep getting a 405 error "Method not allowed". I'm assuming this is because I didn't add the above correctly. Anyone want to walk me through or poit me to a site that already has a setup tutorial? (I'm kinda out of my element in Widows) From htrd90 at zepler.org Sun Nov 7 09:13:45 1999 From: htrd90 at zepler.org (Toby Dickenson) Date: Sun, 07 Nov 1999 14:13:45 +0000 Subject: __str__ vs. __repr__ References: <199911041325.IAA14001@eric.cnri.reston.va.us> <000001bf275c$02370d20$1d2d153f@tim> Message-ID: "Tim Peters" wrote: >Let me back off to what repr and str "should do": > >repr(obj) should return a string such that > eval(repr(obj)) == obj I don't understand the motivation for this requirement. Why would anyone want to pass such a string to eval? If you anticipate the need for reconstructing the object from a textual representation, then surely pickle is a better option? Alternatively, most classes could implement __repr__ as :-) def __repr__(self): return "pickle.loads(%s)" % repr(pickle.dumps(self)) >repr() currently cheats in another way: for purely aesthetic reasons, >repr(float) and repr(complex) don't generate enough digits to allow exact >reconstruction of their arguments (assuming high-quality float<->string in >the platform libc). This is a case where an argument appropriate to str() >was applied to repr(), not because it makes *sense* for repr, but because so >much output goes thru an *implicit* repr() now and you didn't want to see >all those "ugly" long float strings <0.50000000000000079 wink>. OK, so repr as it stands today is clearly not suitable for formatting for people, and is less than ideal for formatting for the machine. However there is a third audience for who it is ideal, the programmer, who need a representation for use in development tools such as debuggers, or the interactive mode. Tim's Rat class is a good example of how __repr__ should not be implemented, because it exposes the internal representation of the object, not the external value. However, using a small number of digits for repr(float) does make sense because it still provides sufficient precision for most programmers. Toby Dickenson From m.faassen at vet.uu.nl Fri Nov 19 05:44:08 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 19 Nov 1999 10:44:08 GMT Subject: Proposal: Python Info Collective References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> <80oqn9$ocq$2@newshost.accu.uu.nl> <80p9su$ppo$2@newshost.accu.uu.nl> <80piru$13rl$1@hub.org> <80re5d$55a$1@newshost.accu.uu.nl> <810jto$lo0$1@newshost.accu.uu.nl> <811pdu$dvo$1@newshost.accu.uu.nl> <8138ek$22mj$1@hub.org> Message-ID: <8139lo$jc0$1@newshost.accu.uu.nl> T. wrote: > On 18 Nov 1999 21:00:46 GMT, Martijn Faassen wrote: >>with the same speech patterns _from vex.net_, I meant! deja nor I are that > Argh! They're on to me. I see i'll have to randomise news servers > for posting more, and deja too. (-; Oh yaw, and type with a dutch > accent! Happy trails. > ... Don't underestimate the Python Secret Underground! :) Now I *still* don't know why. Is it just that you're so dynamic? :) Wonders-if-he-himself-types-with-a-Dutch-accent-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From skaller at maxtal.com.au Thu Nov 25 18:34:29 1999 From: skaller at maxtal.com.au (skaller) Date: Fri, 26 Nov 1999 10:34:29 +1100 Subject: Python complaints References: <81g8po$reo$1@mach.vub.ac.be> <81h2hh$85c$1@nntp9.atl.mindspring.net> Message-ID: <383DC785.5C81CA06@maxtal.com.au> Aahz Maruch wrote: > > In article <81g8po$reo$1 at mach.vub.ac.be>, > Thomas Hamelryck wrote: > > > >Block delimitation by indenting. This makes python look like a porsche > >with a caravan attached :-). As far as I know, most python users even > >seem to like this for some reason. > > I agree with you and I'm also one of the people who likes it. Here's > why: it makes Python code *readable*. I agree. I'll go further. I like to write code, literate programming style FOR PUBLICATION. Just try typesetting C for publication (and I mean ALL the required code, not just snippets). Compare with Python. you don't even need to understand python to read an algorithm written using it: for i in [1,2,3]: print i, i * i is plain obvious 'psuedo code' that has the nice feature that it can actually be executed. -- John Skaller, mailto:skaller at maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia homepage: http://www.maxtal.com.au/~skaller voice: 61-2-9660-0850 From tbryan at python.net Fri Nov 12 18:31:06 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Fri, 12 Nov 1999 18:31:06 -0500 Subject: making the Python case to my dept. References: <9911051740130D.02530@william.jinsa.org> <3823FC43.CF7FBD71@python.net> <99110609085702.02970@quadra.teleo.net> <382467FA.577E70A0@callware.com> <3824EF76.113E3699@python.net> Message-ID: <382CA33A.89B50E87@python.net> "Thomas A. Bryan" wrote: > > Ivan Van Laningham wrote: > > > > Since this is a FAQ, I'd vote for preserving Thomas' answer somewhere > > > on the python.org Web site, so people could point to the URL when the > > > question comes up again. It's now in the FAQ under section 2. ---Tom From mlh at vier.idi.ntnu.no Mon Nov 8 09:55:08 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 08 Nov 1999 15:55:08 +0100 Subject: What are Aspects? (Re: How can I make my assertions smarter?) References: <7vvq63$ehm$1@nntp4.atl.mindspring.net> <3826C32A.FB47EF6@compaq.com> Message-ID: Greg Ewing writes: > Smacks of the legendary > come-from statement, somehow... Sounds cool... Only a myth? > > Greg -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From ivanlan at callware.com Tue Nov 2 15:14:22 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Tue, 02 Nov 1999 13:14:22 -0700 Subject: Barf References: <381F37FA.3899AAEF@callware.com> Message-ID: <381F461E.3E136341@callware.com> Hi All-- Ivan Van Laningham wrote: > [snip] > > It works fine, but if I move the mouse pointer out of the info box > (select Help->About) and back to the main window, I get a segmentation > violation. > If I add a Frame to the root window, it works perfectly. Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From steve at acer.spvi.com Wed Nov 3 06:24:43 1999 From: steve at acer.spvi.com (Steve Spicklemire) Date: Wed, 3 Nov 1999 06:24:43 -0500 (EST) Subject: Python director XTra.... cute 'robot' toy for mac *and* windows.... In-Reply-To: <199911022220.RAA21086@acer.spvi.com> (message from Steve Spicklemire on Tue, 2 Nov 1999 17:20:28 -0500 (EST)) References: <199910291511.KAA26339@acer.spvi.com> <199911022220.RAA21086@acer.spvi.com> Message-ID: <199911031124.GAA24189@acer.spvi.com> Windows version now available.... There is now a Windows version of the Python Xtra for Macromedia director. There are also a couple of dumb bug fixes. To use the Xtra you'll need to have Python installed on the system where the movie (or projector) is running. (Doesn't everyone have python installed?) find it at: http://opensource.spvi.com Source code is, of course, included in this release. Any help would be most welcome. ;-) If you have any comments or problems, please email me directly since it's totally impossible for me to keep up with this list and get anything else done. thanks! -steve From fuming at venus.radsci.uci.edu Fri Nov 5 10:34:25 1999 From: fuming at venus.radsci.uci.edu (Fuming Wang) Date: Fri, 5 Nov 1999 07:34:25 -0800 Subject: Problems with Tkinter while the thread module is configured In-Reply-To: References: <19991105215504.A497@Ridcully.home> <14370.53219.667492.946075@gargle.gargle.HOWL> <27NwjKAK1uI4EwdJ@jessikat.demon.co.uk> Message-ID: Hi, Is there anyone having this problem too? When "thread" module is configured, Tkinter programs would exit right after start. Environment: Python1.5.2 LinuxThread-0.71 Libc5.4.46 Linux2.0.33 Fuming Wang From bellman at lysator.liu.se Wed Nov 17 07:48:01 1999 From: bellman at lysator.liu.se (Thomas Bellman) Date: 17 Nov 1999 12:48:01 GMT Subject: cgi.py inefficiency (with fix) Message-ID: <80u861$ngs$1@newsy.ifm.liu.se> I was profiling an embedded web server we have written in Python, and found that it spent a lot of time in FieldStorage.has_key() and FieldStorage.__getitem__() from cgi.py. So I looked at the code for the FieldStorage class, and found that it basically emulates a normal dictionary, but is implemented using a linear list of fields. Thus, has_key() and __getitem__() must do linear searches to find things. Is there any reason why this is done, instead of having a dictionary of lists? I did a quick stab at replacing the list with a dictionary, and in our application, we got a threefold increase in speed per request... Of course, in our application we have forms sometimes containing well over a thousand entries. It is probably not very common for people to have such large forms, but it is a pity that the cgi module does not scale well. Anyway, here is a diff of the changes I made. I haven't tested it very extensively (in our application we have subclassed the FieldStorage class, and use a modified __init__() method, which makes it difficult to fully test the real FieldStorage class), but from what I have tested, it seems to work. I started with revision 1.45 of cgi.py, which I checked out from the CVS archives this Monday. =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/cgi.py,v retrieving revision 1.45 diff -u -5 -r1.45 cgi.py --- cgi.py 1999/06/11 18:26:09 1.45 +++ cgi.py 1999/11/17 12:30:23 @@ -724,11 +724,11 @@ """Like FieldStorage, for use when no file uploads are possible.""" # Dummy attributes filename = None - list = None + dict = None type = None file = None type_options = {} disposition = None disposition_options = {} @@ -890,11 +890,12 @@ pass if maxlen and clen > maxlen: raise ValueError, 'Maximum content length exceeded' self.length = clen - self.list = self.file = None + self.file = None + self.dict = None self.done = 0 self.lines = [] if ctype == 'application/x-www-form-urlencoded': self.read_urlencoded() elif ctype[:10] == 'multipart/': @@ -912,74 +913,69 @@ raise AttributeError, name if self.file: self.file.seek(0) value = self.file.read() self.file.seek(0) - elif self.list is not None: - value = self.list + elif self.dict is not None: + value = self.dict.values() else: value = None return value def __getitem__(self, key): """Dictionary style indexing.""" - if self.list is None: + if self.dict is None: raise TypeError, "not indexable" - found = [] - for item in self.list: - if item.name == key: found.append(item) - if not found: - raise KeyError, key + found = self.dict[key] if len(found) == 1: return found[0] else: return found def keys(self): """Dictionary style keys() method.""" - if self.list is None: + if self.dict is None: raise TypeError, "not indexable" - keys = [] - for item in self.list: - if item.name not in keys: keys.append(item.name) - return keys + return self.dict.keys() def has_key(self, key): """Dictionary style has_key() method.""" - if self.list is None: + if self.dict is None: raise TypeError, "not indexable" - for item in self.list: - if item.name == key: return 1 - return 0 + return self.dict.has_key(key) def __len__(self): """Dictionary style len(x) support.""" - return len(self.keys()) + return len(self.dict) def read_urlencoded(self): """Internal: read data in query string format.""" qs = self.fp.read(self.length) - self.list = list = [] + self.dict = dict = {} for key, value in parse_qsl(qs, self.keep_blank_values, self.strict_parsing): - list.append(MiniFieldStorage(key, value)) + l = dict.get(key, []) + l.append(MiniFieldStorage(key, value)) + dict[key] = l self.skip_lines() FieldStorageClass = None def read_multi(self, environ, keep_blank_values, strict_parsing): """Internal: read a part that is itself multipart.""" - self.list = [] + self.dict = {} klass = self.FieldStorageClass or self.__class__ part = klass(self.fp, {}, self.innerboundary, environ, keep_blank_values, strict_parsing) # Throw first part away while not part.done: headers = rfc822.Message(self.fp) part = klass(self.fp, headers, self.innerboundary, environ, keep_blank_values, strict_parsing) - self.list.append(part) + l = self.dict.get(part.name, []) + l.append(part) + self.dict[part.name] = l self.skip_lines() def read_single(self): """Internal: read an atomic part.""" if self.length >= 0: =================================================================== -- Thomas Bellman, Lysator Computer Club, Link?ping University, Sweden "Beware of bugs in the above code; I have ! bellman @ lysator.liu.se only proved it correct, not tried it." ! Make Love -- Nicht Wahr! From gerrit.holl at pobox.com Fri Nov 19 08:01:08 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Fri, 19 Nov 1999 14:01:08 +0100 Subject: Beginning programming with Python In-Reply-To: References: <382B3A53.5816B2@callware.com> <382B3D79.74CD3E0F@email.sps.mot.com> <80p9ds$ppo$1@newshost.accu.uu.nl> <38312D55.A36EB56D@iqsoft.hu> <19991116173142.A31379@optiplex.palga.uucp> Message-ID: <19991119140108.C4306@optiplex.palga.uucp> Janos Blazi wrote: > > the less time it costs to program it, the more time it costs to run it, > > the more time it costs to program it, the less time it costs to run it. > > Is this some law of nature I missed at university? Well, no. I'm 14 :-) > But obviously, as far as raw speed is concerned Python cannot compete with > C. Nobody can attempt to deny that. Yes > So if speed is an issue for you, use C. But if *development* speed is an issue, use Python. > Or even assembly language. > If you do not like Python, use C anyway. Why not? Actually I do not care. I like Python. Some people don't like Python *because* of it's easy syntax, but I find that hard to believe. regards, Gerrit. -- "We all know Linux is great...it does infinite loops in 5 seconds." (Linus Torvalds about the superiority of Linux on the Amterdam Linux Symposium) From gmcm at hypernet.com Tue Nov 16 16:00:23 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 16 Nov 1999 16:00:23 -0500 Subject: Python in business programming [was Re: Beginning programming with Python] In-Reply-To: <383195C1.826B3342@iqsoft.hu> Message-ID: <1269336472-10033930@hypernet.com> Nemeth Miklos writes: [snip] > The only thing I wanted, is to point out a potential shortcoming (if at all) of > Python -- I am not sure if the lack of compile-time type safety is really a > badly needed feature. It is, but only if you're used to relying on it. That is, some people miss it dearly. Coming from a background of languages that did static type checking, I did at first. Adapting has meant big changes to my development style (the code, compile, test cycle is now rarely more than half an hour). Test suites are more important (but also easier). For large systems, decomposing the problem cleanly is very important - to preserve your sanity you need the smallest, cleanest interfaces possible between subsystems. But, if at first you foul it up, you can still rewrite most of it before lunch. > I am neither a physicist nor a mathematician, I am a simple business software > engineer. I like Python but I'd like to be convinced that Python is not only > for scientific programming, but also for business programming. I can assure you that there are lots of business programmers who use and love Python. Probably around half of c.l.py contributers are involved in business, not math / science. Businesses tend to be pretty conservative, however, and exercise rigid control over the tools their programmers use. So acceptance at the mangerial level is slow. In my business as a consultant, most of my clients want C, C++ or Java. That doesn't mean that I don't write it (and rewrite it until it's right) in Python first. And sometimes they accept delivery in Python (when they hear what the price tag would be to get it in C, for example). - Gordon From tbryan at python.net Fri Nov 12 18:16:50 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Fri, 12 Nov 1999 18:16:50 -0500 Subject: Where are Python's IDEs documented? Message-ID: <382C9FE1.944D3494@python.net> I wanted to point users to some documentation about IDEs for Python: PythonWin, IDLE, Emacs, etc. I was hoping to find one page on the Python website that at least listed all of the options, maybe with screenshots. I searched around http://www.python.org for a while, but I never found such a page. Is there one? I think that such a page would be valuable, especially for first-time programmers. ---Tom From torkristensen at my-deja.com Tue Nov 16 05:22:37 1999 From: torkristensen at my-deja.com (torkristensen at my-deja.com) Date: Tue, 16 Nov 1999 10:22:37 GMT Subject: Python accessing Webcam? Message-ID: <80rb9c$m87$1@nnrp1.deja.com> Hi all, I was wondering if anyone could point me in a direction that would let me grab a frame from a webcam. Is there a way to access DEVICE.framebuffer? thanks in advance t Sent via Deja.com http://www.deja.com/ Before you buy. From gvwilson at nevex.com Sun Nov 28 13:47:51 1999 From: gvwilson at nevex.com (Greg Wilson) Date: Sun, 28 Nov 1999 13:47:51 -0500 Subject: discrete event simulation? Message-ID: Has anyone written a discrete event simulation framework in Python? If so, I'd be grateful for pointers. Thanks, Greg From prodos8 at yahoo.com Tue Nov 30 18:38:28 1999 From: prodos8 at yahoo.com (help) Date: Tue, 30 Nov 1999 18:38:28 -0500 Subject: For sale: "Learning Python" + "Python Pocket Ref." Message-ID: <301119991838284235%prodos8@yahoo.com> $18.00 including UPS ground shipping anywhere in the US: I have for sale a new, almost unused copy of the ORA book Learning Python and the supplement Python Pocket Reference. Both are good, well-done books that have gotten great reviews. Learning Python is $23.96 new from amazon.com, plus shipping; the pocket reference is $5.56. You save, by buying my copy for $18, $11 plus shipping. email me at brian at innobyte.com if you are interesed. If you are in the Boston area and can pick it up, they are yours for $15.00. thanks. From dnagata at creo.com Fri Nov 12 23:00:39 1999 From: dnagata at creo.com (Dale Nagata) Date: Fri, 12 Nov 1999 20:00:39 -0800 Subject: print "foo", without a space References: <382AD3BB.69899CBD@helsinki.xx> Message-ID: <382CE267.5A94@creo.com> Mikael Johansson wrote: > Is there another way of getting print to not make a newline than > using: > print "foo", ? > This because the comma always produces a space [snip] have you tried sys.stdout.write( "foo" ) -- Dale Nagata | tel : +1 604.451.2700 ext. 2254 (UTC-0800) Software Developer | fax : +1 604.437.9891 Creo Products Inc. | pgr : +1 604.691.8279 Burnaby BC Canada | http://www.creo.com/ From pinard at iro.umontreal.ca Tue Nov 2 13:22:10 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 02 Nov 1999 13:22:10 -0500 Subject: Assorted Questions regarding the future of Python... In-Reply-To: Skip Montanaro's message of "Tue, 2 Nov 1999 13:19:02 -0600 (CST)" References: <6D8A17398E28D3119F860090274DD7DB49833A@pces.cadlab.it> <006201bf2517$50edf1f0$f29b12c2@secret.pythonware.com> <14367.14630.983098.834929@dolphin.mojam.com> Message-ID: Skip Montanaro ?crit: > For pointers to [optimisation related] stuff [...] Thanks a great deal, Skip, for all these pointers, I'll preciously save them. Who knows, maybe that one of these days, I'll find some more time and try to go play into your sandbox, if there is some corner for me at that time ;-). -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From ivanlan at callware.com Sat Nov 27 15:02:20 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Sat, 27 Nov 1999 13:02:20 -0700 Subject: yet 'nother newbie question References: <3840300F.66DC46DD@wjk.mv.com> Message-ID: <384038CC.BBB47AE4@callware.com> Hi All-- "William J. King" wrote: > > Hi: > > When passing an argument to a function etc. -- how does one determine > that it is > an integer that is being passed and not a string for example... Is there > something > available to determine it's type. The only way I can figure is to use > 'try' and > 'except' for a partial solution: > > try: > x = x + "" # suceeds then its a string -- if so > x = string.atoi(x) > except: > x = x + 0 #This sort of partially ensures that int is passed..... > > or if you have the reverse situation?... > > Hmmm -- It seems python knows the difference internally, how can I > determine > types and work with variables without having to resort to exception > checking... > Hope this makes sense... Thanks..... > type(x) That is, if type(x) == type(""): print "I'm a string" elif type(x) == type(0): print "I'm an integer" else: print "I'm something else" type() returns a repr (a printable string) object that might look like this: There is a module (types) that you can import which has shortcuts in it so that you can call if type("")==StringType: blah blah but I generally don't bother, since it saves almost nothing on typing. -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours ---------------------------------------------- From gerrit.holl at pobox.com Wed Nov 10 08:11:43 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Wed, 10 Nov 1999 14:11:43 +0100 Subject: MSWIN:getch() UNIX:? In-Reply-To: <80a3rk$dg4$1@nslave2.tin.it> References: <80a3rk$dg4$1@nslave2.tin.it> Message-ID: <19991110141143.A32387@optiplex.palga.uucp> Francesco wrote: > There's a module with a getch() function that can run on all platforms? Write a function what checks on witch OS it is and import the getch() from the curses module if you're on unix but from another module on dos. For unix, read the curses howto. regards, Gerrit. -- linuxgames.nl.linux.org All about games on Linux in Dutch (under construction). www.nl.linux.org The Dutch resource for Dutch Linux documentation. www.nl.linux.org/discoverb Learn foreign words and definitions. www.nl.linux.org/~gerrit/asperger I'm an Asperger, go here for more info. www.nl.linux.org/~gerrit About me and pictures of me. From sramanath at my-deja.com Tue Nov 9 16:05:05 1999 From: sramanath at my-deja.com (sramanath at my-deja.com) Date: Tue, 09 Nov 1999 21:05:05 GMT Subject: Detect file existance before open? References: <380c92a7.412580789@192.77.87.74> Message-ID: <80a29u$gn9$1@nnrp1.deja.com> import commands commands.getstatus('') In article <380c92a7.412580789 at 192.77.87.74>, jlj at cfdrc.com (Lyle Johnson) wrote: > os.path.exists(filename) > > On Sat, 16 Oct 1999 21:06:07 -0600, "Bill Rodgers" > wrote: > > >I would like to check for the existance of a file before I attempt an open > >and maybe throw an exception. I don't see a way to do this. I would like > >to tell the user that the file he specified doesn't exist. Is there a way > >to do this or do I need to catch the exception and deal with it that way? > >Thanks, > >-- > >Bill Rodgers > >Enterprise Management Consultant > >Specialty: BMC/Patrol > >brodg1 at ix.netcom.com > > > > > > Sent via Deja.com http://www.deja.com/ Before you buy. From martian1 at dds.nl Sun Nov 28 15:24:17 1999 From: martian1 at dds.nl (Martian) Date: Sun, 28 Nov 1999 21:24:17 +0100 Subject: "Import error"--MySQLmodule broke betw. Python 1.5.1 and 1.5.2 Message-ID: <38418F71.A39C213E@dds.nl> Hello, I am programming a CGI app which uses the MySQLmodule 1.4 python interface to the MySQL database (version 3.22.27). I've downloaded and installed Python 1.5.2 for my FreeBSD 3.3 box. In August, I programmed something similar, also using the MySQLmodule, but then I used Python 1.5.1 The problem is as follows: When I start Python (interactively) and type: >>> import MySQLmodule I get: ImportError: dynamic module does not define init function (_initMySQL) I've never seen this problem before; in Py1.5.1 MySQLmodule could be used just fine, both interactively and in a script. The MySQLmodule hasn't changed--indeed, hasn't since Oct. 1998 The module itself is written in C, and I compiled it without errors or warnings. (Hard though that may seem with a C program! ;-) I suppose the easy solution would be to simply remove Python 1.5.2 and install Python 1.5.1, but I would much rather stay with 1.5.2 to stay up-to-date. (Besides, aren't there bugfixes in this release? Better to have them, too) Could you tell me if I could perhaps define some kind of "dummy" C function within the MySQLmodule C code which would satisfy Python--an "__initMySQL__" function which simply does nothing. I am inexperienced in programming C (I know the basics, though) and have never integrated C and Python. If I define an empty __initMySQL__ function in MySQLmodule.c, will that break the module? Does the hypothetical initMySQL function somehow need to register MySQLmodule's objects, or in any other way do something more than just *exist* ? Thank you for any help you can offer, Martijn Herber P.S Since I am not (yet) subscribed to the list itself, please also respond to my email adress directly: martian1 at dds.nl From gerrit.holl at pobox.com Wed Nov 10 08:13:15 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Wed, 10 Nov 1999 14:13:15 +0100 Subject: __str__ vs. __repr__ In-Reply-To: <000301bf2b46$4d7e6f60$d82d153f@tim> References: <14376.31199.948463.211294@goon.cnri.reston.va.us> <000301bf2b46$4d7e6f60$d82d153f@tim> Message-ID: <19991110141315.B32387@optiplex.palga.uucp> Tim Peters wrote: > No, in that case it would have been named __representation__. __repr__ is > actually an acronym, meaning Regular-Expression Parsable Rendition. > Similarly __str__ is short for Simpler Than Repr. I never learned what > __init__ stands for -- it never interested Tim . :-) > guess-what-wink-stands-for-and-win-a-fabulous-prize!-ly y'rs - tim Windows-Is-Not-Kewl? regards, Gerrit. -- linuxgames.nl.linux.org All about games on Linux in Dutch (under construction). www.nl.linux.org The Dutch resource for Dutch Linux documentation. www.nl.linux.org/discoverb Learn foreign words and definitions. www.nl.linux.org/~gerrit/asperger I'm an Asperger, go here for more info. www.nl.linux.org/~gerrit About me and pictures of me. From aahz at netcom.com Thu Nov 18 16:21:13 1999 From: aahz at netcom.com (Aahz Maruch) Date: 18 Nov 1999 21:21:13 GMT Subject: Beginning programming with Python References: <19991116173142.A31379@optiplex.palga.uucp> Message-ID: <811qk9$3b4$1@nntp9.atl.mindspring.net> In article , Janos Blazi wrote: >> the less time it costs to program it, the more time it costs to run it, >> the more time it costs to program it, the less time it costs to run it. > >Is this some law of nature I missed at university? >But obviously, as far as raw speed is concerned Python cannot compete with >C. Nobody can attempt to deny that. So if speed is an issue for you, use C. >Or even assembly language. >If you do not like Python, use C anyway. Why not? Actually I do not care. The point is that, generally speaking, programming in Python takes less time than programming in C, but C programs are faster. So you trade development time for code speed. OTOH, programming in C is enough more difficult that if your speed requirements are based on finding a good algorithm, your Python program might well be faster (because you can try more algorithms per unit time in Python). -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From greg.ewing at compaq.com Wed Nov 3 03:58:37 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Wed, 03 Nov 1999 21:58:37 +1300 Subject: Printing of individually returned values when running interactively References: <9t966zk6gvk.fsf@mraz.iskon.hr> Message-ID: <381FF93D.861C0DBB@compaq.com> Hrvoje Niksic wrote: > > I've just noticed (the hard way) a very unusual feature of Python's > interactive interpreter mode. If you evaluate several values on > several lines, all the values are printed! > > Why would anyone want a thing like that? I doubt anyone ever explicitly wanted it. I suspect it's a side effect of the implementation. I just did the following experiment: >>> c = compile(""" if 1: 1 2 3 """, "", "single") >>> c >>> from dis import dis >>> dis(c) 0 SET_LINENO 0 3 SET_LINENO 2 6 LOAD_CONST 0 (1) 9 JUMP_IF_FALSE 25 (to 37) 12 POP_TOP 13 SET_LINENO 3 16 LOAD_CONST 0 (1) 19 PRINT_EXPR 20 SET_LINENO 4 23 LOAD_CONST 1 (2) 26 PRINT_EXPR 27 SET_LINENO 5 30 LOAD_CONST 2 (3) 33 PRINT_EXPR 34 JUMP_FORWARD 1 (to 38) >> 37 POP_TOP >> 38 LOAD_CONST 3 (None) 41 RETURN_VALUE In other words, in interactive mode, the compiler emits a PRINT_EXPR bytecode after every expression -- including, apparently, ones nested within another statement. > Doesn't it produce loads of debug-like output when pasting > more complex things? The fact that nobody seems to have noticed this before (or at least not complained about it) suggests that people don't usually paste complex things in interactive mode. Greg From meera_bavadekar at hp.com Wed Nov 10 21:01:40 1999 From: meera_bavadekar at hp.com (Meera) Date: Wed, 10 Nov 1999 18:01:40 -0800 Subject: How to perform syntax check in Python Message-ID: <382A2384.CC37FBA8@hp.com> Hello everybody, I am looking for a utility to perform syntax validation in python. Consider following code - try: a = 3 print a #Do some more processing except: print b The fact that variable b is not defined is known only when we get exception. We will get 'NameError exception' _not_ the actual exception we are expecting. When we have multi-developer and multi-platform environment - such feature is crucial. This is one area which I would like python to improve over conventional language. Thanks, Meera From mal at lemburg.com Mon Nov 1 09:27:57 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Mon, 01 Nov 1999 15:27:57 +0100 Subject: os.popen() and (IDLE, PythonWin) ? References: <1270664157-24361801@hypernet.com> Message-ID: <381DA36D.B04DF056@lemburg.com> Gordon McMillan wrote: > > Marc-Andre wrote: > > "M.-A. Lemburg" wrote: > > > > > > [os.popen('ver') fails under IDLE and PythonWin, yet works > > > under "normal" > > > Python] > > > > Ok, I found the FAQ entry on this: > > > > 7.13. Why doesn't os.popen() work in PythonWin on NT? > [snip] > > Under PythonWin this is no problem (although I wish os.popen > > would automatically choose the different approach for me in the > > above setup). Yet under IDLE I have a problem: win32 doesn't have > > to be installed... is there some other workaround ? > > tempfile and redirection :-(. Ok, but how can I prevent the shell windows from popping up ? I read something about os.spawnv() in the docs, but the mode argument remains a complete mystery and I always get IOErrors about files not being found... Any help appreciated :-), -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 60 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From asc at bsiag.com Tue Nov 2 10:49:58 1999 From: asc at bsiag.com (Alex Schroeder) Date: 02 Nov 1999 16:49:58 +0100 Subject: Download Python Imaging Library Handbook Message-ID: Where can I download the Python Imaging Library Handbook so that I can work with the library without being connected to the net? I was unable to find a tarball on www.pythonware.com and www.python.org... Alex. -- http://www.geocities.com/kensanata/ http://www.bsiag.com/ From vespe at cs.tut.fi Tue Nov 30 00:41:19 1999 From: vespe at cs.tut.fi (Vespe Savikko) Date: 30 Nov 1999 07:41:19 +0200 Subject: Htmlizing text References: <943909426snz@vision25.demon.co.uk> Message-ID: Also sprach philh at vision25.demon.co.uk (Phil Hunt): Is there a function in the standard Python library to HTML-ize text, i.e. to replace 'a > b & c < d' with 'a > b & c < d'? (I realize this can be done with regular expressions, but is there an easy way?) >>> import cgi >>> cgi.escape( 'a > b & c < d' ) 'a > b & c < d' ++Vespe -- ------------------------------------------------------------------ Vespe Savikko vespe at cs.tut.fi - to doom de doomsday - From cgr at formulae.co.uk Fri Nov 5 20:02:44 1999 From: cgr at formulae.co.uk (Colm Rafferty) Date: Sat, 06 Nov 1999 01:02:44 GMT Subject: smtplib.py how to ? Message-ID: <38237da0.3456244@news.force9.net> Dear all, I cannot insert text into the headers To: From: CC: etc, of the email The script below ( the sample in the smtplib.py module) only sends all the text in the body of the email. How do I insert text in the headers? ---------------------------------------- import smtplib s=smtplib.SMTP("localhost") tolist=["cgr at formulae.co.uk","c.rafferty at virgin.net","cgr at pangea.co.uk"] msg = ''' From: test at my.org Subject: testin'... This is a first test ''' s.sendmail("me at mydomain.co.uk",tolist,msg) s.quit() ---------------------------------------- Thanks for any help Colm Rafferty From ejohnson at netcom.com Mon Nov 15 22:51:27 1999 From: ejohnson at netcom.com (Eric Johnson) Date: 16 Nov 1999 03:51:27 GMT Subject: Bug? - win32pipe.popen2 is moody under W98 Message-ID: <80qkbv$2m5$1@nntp5.atl.mindspring.net> I'm working on a multi-threaded make engine under Python. In so doing, I'm desperately trying to get a popen like facility running under Win98 in Python. I've got Mark Hammond's win32 extensions (build 127 to be exact), and I'm still striking out. The following sample code spins off a couple of threads. Each thread makes a popen2 call and displays the results. Ideally, each popen2 call should be capable of being executed in tandem with the rest. import threading import thread import win32pipe def doit(): print "here\n"; a=win32pipe.popen2("dir") s=a[1].readline() while(s): print s s=a[1].readline() print "Done\n" for n in range(4): a1=threading.Thread(target=doit) a1.start() This and its variant that uses os.popen directly works just fine under NT 4.0. But under W98, it gets all hung up on itself quite quickly. Repeated investigation and experimentation shows that the hang point appears to be on simulataneous calls to .readline() while another thread is invoking popen. Can anyone say either way whether this can be expected to work under W98? -Eric Johnson From mgm at unpkhswm04.bscc.bls.com Fri Nov 19 09:07:49 1999 From: mgm at unpkhswm04.bscc.bls.com (Mitchell Morris) Date: 19 Nov 1999 14:07:49 GMT Subject: Proposal: Python Info Collective References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> <80pe77$osc$1@hub.org> <80vp2m$275$1@nntp9.atl.mindspring.net> Message-ID: In article , Alexander Williams wrote: >On 18 Nov 1999 20:31:58 GMT, Mitchell Morris > wrote: > >>Reading is not so bad ... searching blows. As an example, I'm looking at the >>page for the "re" module and want to see the argument list for "unpack" but >>can't seem to remember if it's in "string" or "struct" or >>Guido-only-knows-where. Lynx provides squat for this operation, so I wind up > >Magic word: index. > >See the last page of the doc list in HTML, an index of functions and >terms hyperlinked to the discussion thereof. Voila. > >Has the dimmunation of print media really caused us to forget such >simple methods? "For the sake of argument I'll ignore all your fighting words" -- Larry Wall Your editing of my paragraph removed the portion where I stated that I had to traverse the document hierarchy. That is, while viewing the "re" page, I must go "back" to the previous node, in either a browser of the GNU info viewer, and then forward to another page which contains the information I desire. Is this not the procedure you're suggesting? Please note that traversing the hierarchy does not imply that there are no indices nor does it imply that the indices are unused. I just find it tedious to have to visit the index page and manually search (or initiate an automated search) to find the other page of interest. I was observing that the other "P*" language supplies a tool that removes the need to visit the index page in between, and I thought that was a good thing. Or are you saying that your copies of the index pages have all the references flattened therein so that you can use Lynx's "search in document" feature to jump directly from the "re.compile" secion to the "struct.unpack" section? index-pages-are-for-automated-tools-ly y'rs, +Mitchell -- Mitchell Morris Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden implementation of half of Common Lisp. -- Phil Greenspun From mlh at vier.idi.ntnu.no Mon Nov 1 10:55:02 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 01 Nov 1999 16:55:02 +0100 Subject: How can I make my assertions smarter? References: <381D7087.BF8510E5@webone.com.au> Message-ID: Stuart Hungerford writes: > Hi all, > > I'm using some simple functions to implement crude precondition, > postcondition and invariant checking in Python classes. > > (Tim: please be gentle ;-) > > Is there some neat way to wrap these tests up so I can print any > code expression that fails, e.g: > > Precondition failed foo.py line 42: spoon.shape == 'bent' > > which would appear at line 42 of foo.py as > > pre(spoon.shape == 'bent') How about using (assuming that you won't use assert): pre("spoon.shape == 'bent'") And then using eval() in your code? Like... def pre(condition): if not eval(condition): raise "Precondition Failure", condition Pretty simple, IMO... -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From a.eyre at optichrome.com Fri Nov 26 04:30:51 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Fri, 26 Nov 1999 09:30:51 -0000 Subject: XML to in-memory tree? In-Reply-To: Message-ID: <000001bf37f0$edcc4850$3acbd9c2@peridot.optichrome.com> > Hi. Has anyone built a layer on top of XMLLIB that will load an XML > document into an in-memory (similar to the one built by explicit calls to > HTMLgen)? Have a look through the XML-sig's code. There's a SAX DOM builder if that's what you mean. See: http://www.python.org/topics/xml/ or http://www.python.org/sigs/xml-sig/ -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From davidh at progmatics.com.au Thu Nov 25 18:59:20 1999 From: davidh at progmatics.com.au (David Hobley) Date: Fri, 26 Nov 1999 10:59:20 +1100 Subject: oddity with ftplib Message-ID: <383DCD58.44915F58@progmatics.com.au> Has anyone had any problems using the storbinary command of ftplib? I had been using it for a while for transferring image files to an ISP. I recently changed ISP and the new ISP appears to only get truncated images when it is above a certain size. I am looking into the problem, but thought i would check if anyone had seen this before? -- Cheers, david davidh at progmatics.com.au Progmatics Pty Ltd - Architects of IT and Internet Solutions Level 8, 191 Clarence Street Phone +61 2 9262 4933 Sydney NSW Australia Fax +61 2 9262 4045 http://www.progmatics.com.au/ From phd at phd.russ.ru Thu Nov 25 07:01:47 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Thu, 25 Nov 1999 12:01:47 +0000 (GMT) Subject: Python complaints In-Reply-To: <383CC835.B585EBDD@Lugoj.Com> Message-ID: On Wed, 24 Nov 1999, James Logajan wrote: > def ifexp(cond, trueVal, falseVal): > if cond: > return trueVal > else: > return falseVal > > print "You scored %s point%s" % (score, ifexp(score == 1, "", "s")) The problem with this solution is that python will calculate both expressions (trueVal, falseVal) even if "cond" is false - what is VERY undesireable in most situations. What if I just cannot calculate falseVal if "cond" is false? Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From spaceram00 at earthlink.net Tue Nov 9 03:35:50 1999 From: spaceram00 at earthlink.net (Spaceram) Date: Tue, 9 Nov 1999 00:35:50 -0800 Subject: Grail Brower question Message-ID: <808m9h$nnn$1@holly.prod.itd.earthlink.net> For anyone who knows what the grail browser is I have a question. How do I use the brower? I download it and when i doubleclick it it opens a open with box which means that windows doesn't know what to do with the file. Please email all answers to spaceram00 at earthlink.net From peter at hotmail.com Fri Nov 5 16:17:47 1999 From: peter at hotmail.com (peter at hotmail.com) Date: Friday, 05 Nov 1999 15:17:47 -0600 Subject: No banner,free,homepage storage with high speed 15608 Message-ID: <05119915.1747@hotmail.com> No banner,free,homepage storage with high speed. home.ublaze.com http://home.ublaze.com From nascheme at enme.ucalgary.ca Mon Nov 8 14:57:24 1999 From: nascheme at enme.ucalgary.ca (Neil Schemenauer) Date: Mon, 08 Nov 1999 19:57:24 GMT Subject: Fastest GUI toolkit? References: <01bf29f1$cbfd5e60$5a41c3d1@Cyberus.cyberus.ca> Message-ID: Gordon Williams wrote: > >I have an application where I need to draw many lines fast and repeatedly >(an oscilloscope). The number of lines ranges from about 1000 to 16000. >Currently I have the application using Tkinter but I am finding it too >slow. I assume you are using the canvas to draw. I think it is much faster to use Canvas.coords to move the lines then to redraw them. If this approch works for your application it may be worth a try. Neil From fredrik at pythonware.com Mon Nov 22 09:37:33 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 22 Nov 1999 15:37:33 +0100 Subject: RDF/RSS References: <943225647snz@vision25.demon.co.uk> Message-ID: <00e301bf34f7$1db60da0$f29b12c2@secret.pythonware.com> Phil Hunt wrote: > RDF channels you mean RSS channels, right? http://my.netscape.com/publish/help/quickstart.html (or are you talking about something completely different? -- the reason I'm asking is that some moron just flamed me because a Python solution I posted to this newsgroup didn't work in C++...). > Oh, and what does RDF stand for anyway? resource description framework: http://www.w3.org/RDF/ (iirc, the last version of RSS is no longer RDF- compatible, but that's another story). From quinn at riyal.ugcs.caltech.edu Sat Nov 27 21:22:57 1999 From: quinn at riyal.ugcs.caltech.edu (Quinn Dunkan) Date: 28 Nov 1999 02:22:57 GMT Subject: Binary vs non-binary References: <19991127103504.A1536@stopcontact.palga.uucp> Message-ID: On Sat, 27 Nov 1999 10:35:04 +0100, Gerrit Holl wrote: >Hello, > >can someone explain me the difference in opening a file in binary mode >and opening it not in binary mode? And when is some file defined to be >binary, when it contains an ASCII 0? If so, I understand you need to say >it's binary in C, but if Python doesn't store it strings with an ASCII 0 >on the end, why is there any difference? This is an artifact of C having grown up on unix, where lines end with \n, and then being used on other systems, where lines end with \r\n (also, many network protocols use \r\n for some reason). Anyway, if you open a file in C on, say, DOS, there is going to be an inconsistency because C wants to think of lines being terminated by single characters. So stdio does some behind the scenes munging to turn all \r\ns into \ns and vice-versa. But if you did that on binary data, you'd corrupt it because \n is just another bit pattern there. So you need to know whether you're opening a binary file or not. And since python is written in C.. Basically: under unix and other systems that use \n, you don't have to worry about binary mode---setting it does nothing. But if you want your programs to be portable to DOS (and probably MacOS too, which uses \r), you should use binary mode when opening binaries. It has nothing to do with ASCII 0 (NUL), although it's a good thing to notice: many C programs choke on input with NULs in it. *whew* remember-that-when-breaking-into-the-pentagon-ly y'rs From htrd90 at zepler.org Fri Nov 5 14:54:34 1999 From: htrd90 at zepler.org (Toby Dickenson) Date: Fri, 05 Nov 1999 19:54:34 +0000 Subject: A Comparison of Python and Ruby Extension Interfaces (Re: Comparison between Python and "Ruby") References: <3819BCDA.AC4FD4CA@strs.co.uk> <87k8o2x67f.fsf@ev.netlab.co.jp> <7vjtrc$hmm$1@newshost.accu.uu.nl> <38204614.2EAC6051@compaq.com> <021119992327527678%pereira@research.att.com> <38215CE7.70C3D560@compaq.com> Message-ID: Greg Ewing wrote: >Fernando Pereira wrote: >> >> Same comment. There is no portable way of unwinding the C stack. What >> does that mean for Ruby's portability? > >It uses setjmp/longjmp. Presumably these work correctly on >any system where they are implemented. Porting Ruby to a >system where they're not implemented could be difficult. > Presumably this makes it difficult for Ruby extensions to use C++? Toby Dickenson From morse at harborcom.net Tue Nov 9 08:01:50 1999 From: morse at harborcom.net (Kevin Dahlhausen) Date: Tue, 09 Nov 1999 13:01:50 GMT Subject: Windows Sound Card References: <01bf2a01$27e7cda0$8355c3d1@Cyberus.cyberus.ca> Message-ID: <38281a8e.88096035@news.oh.verio.com> I'd suggest finding a C/C++ library on the net or a toolkit header file from the vendor. Then take a look at SWIG. SWIG will generate a python module from the C/C++ header files, sometimes without any extra work. O yeah, then make the module available somewhere so Python can have a voice on lots of PC's! (What kind of sound does a Python make anyway?) >I am looking for information on a module to get data from the input from a >sound card on a Windows box. Is this possible using Python?? I have had a >search through all the docs and FAQs but havent found anything for Windows. > >Any pointers would be a help. > >Thanks, > >Gordon Williams From charliehubbard76 at yahoo.com Mon Nov 15 15:57:41 1999 From: charliehubbard76 at yahoo.com (charliehubbard76 at yahoo.com) Date: Mon, 15 Nov 1999 20:57:41 GMT Subject: Python, COM and Excel Message-ID: <80ps42$kkk$1@nnrp1.deja.com> Hello, I'm trying to write a python script to take an excel workbook and turn it into html pages. I'm trying to automate this process, but I can't seem to get the bounds of the selection through com. I can get the contents of a selection with app = Dispatch(Excel.Application) app.Selection() But this just gives me the data contained with the cells. I want to be able to check fonts, bold, and format information of each cell to get it as close to the excel formatting as possible. In order to do this I need to either get the bounds of the selection, or retrieve all the cells references' being used. Preferrably a bounding selection of all the cells being used. For example, "A3:AN32" or "1,3,36,32". Any ideas? thanks charlie Sent via Deja.com http://www.deja.com/ Before you buy. From aahz at netcom.com Wed Nov 24 11:05:44 1999 From: aahz at netcom.com (Aahz Maruch) Date: 24 Nov 1999 16:05:44 GMT Subject: Python complaints References: <8666ysfta9.fsf@ix.netcom.com> Message-ID: <81h2co$96s$1@nntp9.atl.mindspring.net> In article <8666ysfta9.fsf at ix.netcom.com>, Brad Knotwell wrote: > >In general, the only thing I've found annoying about Python are the scoping >rules: That's actually one of the things I like best about Python. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) Plus ca change, plus c'est la meme chose. From fdrake at acm.org Wed Nov 10 16:18:08 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Wed, 10 Nov 1999 16:18:08 -0500 (EST) Subject: random function In-Reply-To: <3829D78B.7FC142F4@scripps.edu> References: <3829D78B.7FC142F4@scripps.edu> Message-ID: <14377.57616.255562.594683@weyr.cnri.reston.va.us> Olivier Roche writes: > By looking at the index of the python documentation index i haven't > seen any random function description. Could somebody tell me if a > random function to generate random number (between 0 and 1) exists I see the following entries in the latest version; take a look at the docs for both the random and whrandom modules: random() (in whrandom) random (standard module) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From fdrake at acm.org Fri Nov 5 15:13:19 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Fri, 5 Nov 1999 15:13:19 -0500 (EST) Subject: (no subject) Message-ID: <14371.14943.544121.316575@weyr.cnri.reston.va.us> IPC8 Call For Demos and Posters Important Dates * Nov. 30 : Deadline for demos and posters. * Dec. 15 : Notification of acceptance for demos and posters. Demonstrations and Posters We invite researchers and developers to present their work in demonstrations or posters. Works in progress and results which don't warrant a full paper may be presented this way, as well as demonstrations of interesting applications. Demos and posters will be selected based on the broad applicability of new technologies and novelty of new approaches. Tables and power will be provided. Computers will not be provided; if you intend to do a demonstration, bring your own with all the software you need. There may be a slow Internet connection (at most a shared ISDN line); please let us know if Internet access is important to your demonstration. What is a poster? When presenting a poster, you typically bring one or more posters that can be tacked up to a wall. The posters should provide a concise summary of your work, and diagrams or other graphics are strongly encouraged. You then stand next to your poster and discuss your work with other conference attendees (who will undoubtedly ask why you're standing there). If you're feeling confident, you can provide handouts that explain your research or project in more detail, or tell where to find more information. Bring plenty of copies. So, what's a demo? A demo is a poster, but you use your computer to actually show people what you did. You can have a slide presentation or let people play with your applications. If you want to give a demonstration, be sure to bring your computer! What to Submit and How to Submit It To request space for a demonstration or poster, send an email to Fred Drake (fdrake at acm.org) describing your demonstration or poster. If you have special space or power requirements, please be sure to include the appropriate information. If you require Internet connectivity, be sure to tell us about that as well! For more information Questions regarding demo and poster submissions should be addressed to Fred Drake (fdrake at acm.org). From philh at vision25.demon.co.uk Mon Nov 22 15:01:09 1999 From: philh at vision25.demon.co.uk (Phil Hunt) Date: Mon, 22 Nov 99 20:01:09 GMT Subject: RDF/RSS References: <943225647snz@vision25.demon.co.uk> <00e301bf34f7$1db60da0$f29b12c2@secret.pythonware.com> Message-ID: <943300869snz@vision25.demon.co.uk> In article <00e301bf34f7$1db60da0$f29b12c2 at secret.pythonware.com> fredrik at pythonware.com "Fredrik Lundh" writes: > Phil Hunt wrote: > > RDF channels > > you mean RSS channels, right? > > http://my.netscape.com/publish/help/quickstart.html That's it. > (or are you talking about something completely > different? -- the reason I'm asking is that some > moron just flamed me because a Python solution > I posted to this newsgroup didn't work in C++...). > > > Oh, and what does RDF stand for anyway? > > resource description framework: > > http://www.w3.org/RDF/ > > (iirc, the last version of RSS is no longer RDF- > compatible, but that's another story). What is the latest version number? I've heard of 0.9 and 0.91, but my.netscape.com only seems to describe 0.9. -- Phil Hunt - - - phil at comuno.com Want to see the FAQs for your favourite newsgroups? Read them on the web with Comuno's FAQ server at http://www.comuno.com/faq/ From rmeegan at murl.com Mon Nov 8 11:29:01 1999 From: rmeegan at murl.com (Robert Meegan) Date: Mon, 8 Nov 1999 10:29:01 -0600 (EST) Subject: pythonistas or pythoneers? In-Reply-To: <07111999.2@sanctum.jae> Message-ID: On Sun, 7 Nov 1999, Juergen A. Erhard wrote: > > I'm confused: are we pythoneers or pythonistas? > > I tend to go for pythoneers... sounds more pythonic. > > Or are these two levels of experience? If so, what's higher? > > Confused, > I always thought we were Pythogorians. Your most righteous servant, --- Robert Robert Meegan Murl.com - Because it's not just your data, it's your life. From I.Clarke at strs.co.uk Thu Nov 4 06:25:24 1999 From: I.Clarke at strs.co.uk (Ian Clarke) Date: Thu, 04 Nov 1999 11:25:24 +0000 Subject: A morality tale of Perl versus Python References: <199911041120.LAA22431@tardis.tardis.ed.ac.uk> Message-ID: <38216D24.89E39380@strs.co.uk> >From rec.humor.funny: > ___________________________________________________________________________ > EXTERIOR: DAGOBAH -- DAY > With Yoda strapped to his back, Luke climbs up one of the > many thick vines that grow in the swamp until he reaches the > Dagobah statistics lab. Panting heavily, he continues his > exercises -- grepping, installing new packages, logging in as > root, and writing replacements for two-year-old shell scripts > in Python. > > YODA: Code! Yes. A programmer's strength flows from code maintainability. > But beware of Perl. Terse syntax... more than one way to do it... > default variables. The dark side of code maintainability are they. > Easily they flow, quick to join you when code you write. If once > you start down the dark path, forever will it dominate your destiny, > consume you it will. > > LUKE: Is Perl better than Python? > > YODA: No... no... no. Quicker, easier, more seductive. > > LUKE: But how will I know why Python is better than Perl? > > YODA: You will know. When your code you try to read six months from > now. > ___________________________________________________________________________ > > -- > Selected by Jim Griffith. MAIL your joke to funny at netfunny.com. > Attribute the joke's source if at all possible. A Daemon will auto-reply. > If you don't need an auto-reply, submit to rhf at netfunny.com instead. > For the full submission guidelines, see http://www.netfunny.com/rhf/ > > This joke's link: http://www.netfunny.com/rhf/jokes/99/Nov/perl.html -- Ian Clarke Email: I.Clarke at strs.co.uk Homepage: http://www.gnu.demon.co.uk/ Also see: http://freenet.on.openprojects.net/ "All we see and all we seem is but a dream within a dream" From jeremy at cnri.reston.va.us Fri Nov 5 15:02:49 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Fri, 5 Nov 1999 15:02:49 -0500 (EST) Subject: IPC8: SouthWest Airlines Internet specials In-Reply-To: References: Message-ID: <14371.14313.700685.807764@goon.cnri.reston.va.us> Everyone planning to fly to the conference should consider flying through BWI. I have flown from BWI to San Jose and San Francisco a few times this year, each time for about $200. Flights through BWI are often cheaper than flights from Dulles or National. Jeremy From meh9 at cornell.edu Tue Nov 2 10:18:59 1999 From: meh9 at cornell.edu (Matthew Hirsch) Date: Tue, 02 Nov 1999 10:18:59 -0500 Subject: Printing strings Message-ID: <381F00E1.721BB47F@cornell.edu> Hi All, I'm trying to do something like the following: a=4.0 b=2.0 print '2(%3.1f)' % a,b where I really mean print '%3.1f %3.1f' % a,b but it's printing 2(4.0) 2.0 Is there a way of doing this so I don't have to write out %3.1f, multiple times? Thanks, Matt From clarence at beach.silcom.com Sat Nov 6 20:27:59 1999 From: clarence at beach.silcom.com (Clarence Gardner) Date: Sun, 07 Nov 1999 01:27:59 GMT Subject: A Modest Proposal -- References: <99110613580407.02970@quadra.teleo.net> Message-ID: Patrick Phalen wrote: : In XHTML, this has discrepancy been ameliorated by adding the closing : delimiter "/>" to "
", to yield "
". This indicates to the : XML processor that the tag is EMPTY. Therefore, under the new proposal, : "" would, of necessity, become "". In fact, since
, while empty, does admit of attributes, XHTML must allow tokens to follow the slash, and this allows the very important fractional winkery to be spelt also. I'm sure we can get the TimBot to change to using divisors rather than multipliers. -- Clarence Gardner Software Engineer NetLojix Communications NASDAQ:NETX clarence at netlojix.com From python-list at teleo.net Tue Nov 9 21:14:36 1999 From: python-list at teleo.net (Patrick Phalen) Date: Tue, 9 Nov 1999 18:14:36 -0800 Subject: Java vs. Python - Serialization Bakeoff Message-ID: <99110918085909.01567@quadra.teleo.net> http://starship.python.net/crew/gandalf/DNET/serial/jp-serial.html contains an report on tests comparing Java's and Python's data marshalling, using various criteria. Numerous interesting charts and graphs are presented. Since this was published in 1996 (Python 1.4), I wonder if anyone expert in this subject has any comment on whether the intervening years would have changed the conclusions substantively -- namely that Python is, on average, faster, simpler, and more flexible. From robin at jessikat.demon.co.uk Tue Nov 9 05:31:11 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Tue, 9 Nov 1999 10:31:11 +0000 Subject: python: something completely different References: <3820C0B8.62B2@iowegian.com> <38249ED2.BB7EA1DE@znet.com> <8028jv$7cf$1@hub.org> <38259F18.437@iowegian.com> <38278B5F.1AFF953C@python.net> <3827514F.3A8F@iowegian.com> Message-ID: In article <3827514F.3A8F at iowegian.com>, Grant Griffin writes .... >One could take a cue from Octave here. Octave provides Matlab-style >plot commands which are simply wrappers to Gnuplot. (However, Octave's >reliance on Gnuplot creates a significant installation barrier in the >Windows world.) > >Speaking as someone who is very new to Python, I am impressed by the >variety of plotting schemes available for it, as well as somewhat >bewildered by them. From a new user's point of view, one would like to >be handed "standards" (while still having choices). Python's use of Tk >is a good example of this balance relative to GUI. I believe that the >inclusion of some sort of high-quality, portable, easy-to-install, >standardized plotting system would go a long way to helping Python >invade Matlab's turf. Perhaps one of the plotting systems currently >available meet all these needs, if only it were given the blessing by >being distributed with NumPy. > >> .... There are a lot of these available it's true, but few of them will print well from win32. Fewer still will do decent 3d charts of any kind. If I could just get to the ease of use of the graph tools embedded inside M$ tools I would be happy. -- Robin Becker From jon_mclin at attglobal.net Tue Nov 30 07:18:02 1999 From: jon_mclin at attglobal.net (Jon McLin) Date: Tue, 30 Nov 1999 12:18:02 +0000 Subject: Installation Problem (1.5.2) References: <3843B816.F4A31F07@attglobal.net> Message-ID: <3843C07A.21A33E57@attglobal.net> Ahhh. Much better now. Thanks. Incidentally, I did in fact type "exec_prefix", which was accepted (i.e., the binary was placed in /usr/bin). I'm not going to go find out why just now... But simply setting --prefix to /usr solved my problem. Must be the lack of caffeine this morning. Thanks again, Jon Michael Hudson wrote: ... > 1) you mean --exec-prefix. > > 2) you may have binaries in /usr/bin, but you also have libraries in > /usr/lib, not /usr/local/lib. pass --prefix=/usr to configure. > > Regards, > Michael From mlh at vier.idi.ntnu.no Sat Nov 13 11:10:42 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 13 Nov 1999 17:10:42 +0100 Subject: A Modest Proposal -- References: <99110613580407.02970@quadra.teleo.net> <8072o6$m4i$1@newshost.accu.uu.nl> <80jqqo$n3m$1@newshost.accu.uu.nl> Message-ID: m.faassen at vet.uu.nl (Martijn Faassen) writes: > Magnus L. Hetland wrote: > > m.faassen at vet.uu.nl (Martijn Faassen) writes: > > >> > >> As you can see, XWTSNTSDL is fully consistent with your current proposals. > >> It is therefore expected the major internet browsers will soon be able to > >> support these new standards. > > > It is not consistent with XML... It would have to be .... > > Ah, but XWTSNTSDL takes care of that, of course. :) > > It defines a XPPMS (eXtensible PreProcessor Macro System), which allows > single tags. The XPPMS system transforms the source into valid XML. > After that the other subsystems of XWTSNTSDL take over. But - if you have XPPMS, why do you need XWTSNTSDL? You could just transform This is some text into This is some text and Bob's your uncle... Then you can use standard XML tools... :) Or - does XWTSNTSDL include tools for deciding where the wink-section starts, semantically? > I-can-come-up-with-more-acronyms-than-you-can-with-objections-ly yours, > > Martijn > -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From c.hintze at gmx.net Wed Nov 17 03:13:36 1999 From: c.hintze at gmx.net (Clemens Hintze) Date: Wed, 17 Nov 1999 08:13:36 GMT Subject: Type/Class Unification in Ruby References: <3819BCDA.AC4FD4CA@strs.co.uk> <87k8o2x67f.fsf@ev.netlab.co.jp> <7vjtrc$hmm$1@newshost.accu.uu.nl> <38204614.2EAC6051@compaq.com> <5ld7trtak5.fsf@eric.cnri.reston.va.us> <3826D63C.2731BB1F@compaq.com> <38328948.9E35556F@compaq.com> Message-ID: Hi, Greg, you have done a great analyze! I wish you would have done it sooner ;-) It would have spare me some time to fiddle that out on my own. This part of Ruby is, unfortunately, not too well documented. :-( But in addition to your analyze, may I add some remarks? >>>>> "Greg" == Greg Ewing writes: [...] Greg> 2) A class can only inherit from at most one other class. This is, in fact, true. But it is worth mentioning, that Ruby features single inheritance *by*purpose*. Not because of the implementation details! If it would implement multi-inheritance, the class structure could e.g. use an array of pointer to all such C structs, not only one pointer, as implemented now! Greg> The only methods which actually create C structures are the Greg> built-in instantiation methods of the built-in classes, so Greg> even if you define your own instantiation method in your Greg> subclass, it eventually has to call a built-in one somewhere Greg> up its inheritance chain, which knows what kind of C Greg> structure is needed. That is not totally true (or, perhaps, I misunderstood you). You have to differ two kind of class-building. you seem to describe, how Ruby's built-in classes are implemented. But there is also a second way, that should be used by own extensions. *Only* Ruby built-in (means built into the interpreter) classes, should use the way you have described. The second (preferred) way is, to build instances of class DATA wrapping the C struct you have allocated for your extension. That DATA instance is marked as beeing not a DATA instance, but an instance of your extension class! So that means, that *you* would allocate your instance! Deriving a Ruby class coded in C from another one also coded in C, seems to be the only right tricky part of that language, IMHO. :-) Greg> This scheme will fail if you somehow manage to extract a Greg> built-in method out of one class and stuff it into Greg> another. However there doesn't seem to be any obvious way to Greg> do this (nothing like myClass.__dict__["foo"] in Python). So Greg> it seems to be safe. Good derivation! I have also missed it for some time. But as Ruby features closures, I had learned to use them instead of extraced methods. Anyway Ruby has no functions, only methods. You could extract a method object (means a method implementation). But you would not be able to use it out-of-context of the class it was taken from! As matz (the author of Ruby) has told me, methods are too strong connected to the class they belongs to (performance reasons). Greg> Now, what happens if you assign to a new instance variable Greg> in a method of your subclass of a built-in class? At first Greg> sight it seems that this can't possibly work, because the C Greg> structs of built-in types don't have any place to store Greg> arbitrary instance variables. ;-))))))) Greg> When I tried it, however, to my surprise, it worked! It Greg> turns out that there is a global table whose purpose is to Greg> hold the values of these instance variables (in Python terms Greg> it is a dictionary of dictionaries, indexed by Greg> [object][variable_name]). Python might be able to use a That was a great idea from matz, IMHO! :-) Greg> similar solution, although it might cause ref counting Greg> problems. Once again, thanks for Ruby's true garbage collection! :-) Greg> As a final note, some built-in classes, such as Fixnum, Greg> don't have any instantiation method, so although you can Greg> subclass them, there's no point because you can never create Greg> an instance of your subclass. In addition to your analyze: in the past, at least the classes of Numeric and childs had instanstiation methods. But some user of Ruby have convinced matz, that it would make no sense to derive another numeric type from them. So the methods were delete. The big exception, AFAIK, was class Fixnum. It never had any instanciation method, as it doesn't wrap any struct. The pointer-to-struct is 'misused' as contents of Fixnum. If I remember right, Smalltalk has also chosen that way for implementing SmallInteger. Greg> Others, however, such as Array (Ruby's version of ListType) Greg> do have an instantiation method, and subclasses work just Greg> the way you'd expect. It is worth mentioning too, that it is often not necessary to derive something from e.g. Array. Often it is better to use the module mechanism to add methods to class Array or some of its instances during runtime. You can do that also in your extension. So if Ruby's Array would not have 'push' and 'pop' methods, I would not derive a class Stack from Array, but I would implement a module Stack (implementing 'push' and 'pop') and simply add them to class Array, whenever I need them ... :-))) Greg> Hoping this has been enlightening, Greg We would need more of such ... :-) Clemens. From python-list at teleo.net Sat Nov 6 14:24:22 1999 From: python-list at teleo.net (Patrick Phalen) Date: Sat, 6 Nov 1999 11:24:22 -0800 Subject: making the Python case to my dept. In-Reply-To: <3824723A.5DE35FE5@callware.com> References: <9911051740130D.02530@william.jinsa.org> <801p3q$q01$1@nntp2.atl.mindspring.net> <3824723A.5DE35FE5@callware.com> Message-ID: <99110611340304.02970@quadra.teleo.net> [Ivan Van Laningham, on Sat, 06 Nov 1999]: :: Aahz Maruch wrote: :: > I believe that there are more jobs for good Python programmers than :: > people with the skills to fill them. My company is certainly having :: > difficulties (jobs in Mountain View! ask me!), and having HP Cupertino :: > advertising for 10-12 Python positions only increases the difficulty. :: I really hope that Aahz is correct. As most of you know, I'm stuck out :: here in Utah, which is widely known to be significantly behind *any* :: curve you want to name. :: :: If there's a curve coming to Utah, I sure hope it will be one with jobs :: for Pythonistas, because there certainly aren't *any* here now. Look at it this way: the HP jobs all appear to center around developing the E-speak technology. Python has been chosen as the official scripting language for E-speak. Novell has publicly endorsed E-speak. If Novell decides to builds Netware hooks into E-speak, they'll probably hire rafts of Pythonistas in Utah. :) From iam at not.you Wed Nov 17 09:23:51 1999 From: iam at not.you (Ken Power) Date: Wed, 17 Nov 1999 14:23:51 GMT Subject: Alphabetized dictionary listings Message-ID: <3832b6ce.80769668@news1.mysolution.com> Why does this occur? More to the point, how can I have the print-out be in alphabetical order? >>> myList = ['Abel', 'Dexter', 'Francis', 'Matthew', 'Samantha', 'Tyrone'] >>> myDict = {} >>> for name in myList: myDict[name] = 0 >>> for key in myDict.keys(): print key Tyrone Samantha Francis Abel Matthew Dexter Again, how can I have the printout be in Alphabetical order? I also noticed that if I fed values to myDict[key] from another list, that was constructed so it's values would match the keys in myDict, that the values would be assigned to the wrong keys: >>> myList2 = ['lebA', 'rexteD', 'sicnarF', 'wehttaM', 'ahtnamaS', 'enoryT'] >>> var = 0 >>> for key in myDict.keys(): myDict[key] = myList2[var] var = var + 1 >>> for key in myDict.keys(): print key, myDict[key] Matthew ahtnamaS Francis sicnarF Abel wehttaM Samantha rexteD Dexter enoryT Tyrone lebA As you can see the assignements are in correct. Well, if this is understandable, could someone offer some insight? Thank you. Ken -------------------------------- Ken Power uncle_wiggly at bigfoot dot com get that? -------------------------------- From mlh at vier.idi.ntnu.no Tue Nov 16 05:06:15 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 16 Nov 1999 11:06:15 +0100 Subject: list.without()? References: <01b001bf3019$48c5a010$f29b12c2@secret.pythonware.com> Message-ID: "Fredrik Lundh" writes: > Magnus L. Hetland wrote: > > Why on *earth* would you use a while/try/break-combination? > > maybe because the meaning of "without a > specified element" is unclear. mike's version > guarantees that: > > list.without(element) > assert element not in list > > never fails, while your version behaves just > like "remove" -- if there are several instances > of an element value, only the first one is > removed: > > count = list.count(element) > list.without(element) > assert count == 0 or list.count(element) == count-1 Oh - sorry about that. :) My intended meaning was that implemented in my own routine, which made me blind to the benefits of Mike's version. ;) > > in either case, adding "without" (like remove, but > returns a new list) strikes me as being even more > contrived than earlier proposals like "sorted" (like > sort, but returns a new list), etc. Okay... I don't think that is contrived either, but I guess we just disagree ;) > > > -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From phd at phd.russ.ru Tue Nov 16 12:17:42 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Tue, 16 Nov 1999 17:17:42 +0000 (GMT) Subject: function override??? In-Reply-To: <80s0sd$1g4k$1@rtpnews.raleigh.ibm.com> Message-ID: On Tue, 16 Nov 1999, Arinte wrote: > I am defining a python callback for my embedded app, but I want the script > writer to override my function. So, basically what I want is a function > prototype. Ex. here is what I am thinking. > > ;---fprot.py > def overrideme(self, str, someint) > > ;--fimp.py > import fprot #I know this ain't right. > # I don't know how to import from other python > scripts yet. Enlighten me? I ithink it is correct. Why do you think it is not? > def overrideme(self, str, someint) > do_some_junk() Define your procedure: ;---fprot.py def overrideme(self, str, someint): pass ;--fimp.py import fprot And assign your override function: fprot.overrideme = my_override After this, call fprot.overrideme from any place (C or Python). Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From mwh21 at cam.ac.uk Sat Nov 6 05:46:12 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 06 Nov 1999 10:46:12 +0000 Subject: exec / execfile namespace problem References: <004aa0e3.c3e96526@usw-ex0101-002.remarq.com> Message-ID: Karan Vasudeva writes: > Hi, > > I'm trying to do this: > execfile('cool.py') > > and this: > > import fileinput > chunk = '' > for line in fileinput.input('cool.py'): > chunk = chunk + line > exec(chunk) How does that differ from exec open('cool.py').read() ? What you have will be really quite inefficient, because repeatedly executing chunk = chunk + line is a quadratic algorithm ... but back to the point. > > where 'cool.py' is this: (in part) > import httplib > import time > import whrandom > h = httplib.HTTP('') > h.putrequest('GET', '/favicon.ico') Have you tried executing `python cool.py'? The obvious (to me) problem with the above is that you're not telling httplib about server! I think you want h = httplib.HTTP("server.domain.tld") HTH, Michael From maxco at telenia.it Thu Nov 25 13:35:37 1999 From: maxco at telenia.it (maxco) Date: Thu, 25 Nov 1999 19:35:37 +0100 Subject: Programmatori italiani Python per Mac Message-ID: <81jvhu$fvk$1@serv1.iunet.it> Sorry for OT. Se c'? qualche programmatore di Python su Mac scriva a: tec at daker.com per una consulenza. From paul at prescod.net Sun Nov 7 11:20:36 1999 From: paul at prescod.net (Paul Prescod) Date: Sun, 07 Nov 1999 10:20:36 -0600 Subject: Python and Smalltalk and Java envy References: <1270663667-24391282@hypernet.com> <381ED7A6.D7D7FB13@compaq.com> <877lk1wiij.fsf@ev.netlab.co.jp> <19991102154543.A4469@optiplex.palga.uucp> <381F9EB4.63FA033F@python.net> <7vqkqq$oa7$1@nnrp1.deja.com> <382484F1.F8B8D712@home.com> Message-ID: <3825A6D4.CDFD9E6B@prescod.net> Wostenberg wrote: > > Intersting observation. Perhaps it comes down to those of us who are > comfortable with niche languages (Python, Smalltalk, Lisp) and those who > suffer Java-envy . Do Python people, Ada advocates, or little Lispers wring > there hands about the fact "we are not the most used language?" Why should > Smalltalkers? Programmers of minority languages do often wring their hands for the simple reason that they are often forced to program in majority languages. -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco "Some of Disney's older properties, such as Peter Pan, Winnie the Pooh, and Alice in Wonderland, came out of books. But the authors' names are rarely if ever mentioned, and you can't buy the original books at the Disney store. If you could, they would all seem old and queer, like very bad knockoffs of the purer, more authentic Disney versions." - http://www.cryptonomicon.com/beginning.html From stidolph at origin.ea.com Tue Nov 16 15:01:24 1999 From: stidolph at origin.ea.com (Stidolph, David) Date: Tue, 16 Nov 1999 14:01:24 -0600 Subject: PythonWin Debugger Message-ID: <11A17AA2B9EAD111BCEA00A0C9B41793034AAEE8@molach.origin.ea.com> I have a Win32 app that does its own UI (no MFC available or even standard windows drawing stuff. Is there any way to integrate the PythonWin debugger so it will fire up on an exception or allow me to fire it up? We are using the Python DLL. Advice?? -----Original Message----- From: Mark Hammond [mailto:mhammond at skippinet.com.au] Sent: Monday, November 01, 1999 4:58 AM To: 'Adrian Eyre'; 'Python Mailing List' Subject: RE: PythonWin Debugger > > Hmmm. The debugger should run from all embedded apps, > except Tkinter > > ones (and therefore except IDLE). > > Does that include straight win32 (non-MFC) apps? Yes - it should work there. Eg, if you run "pythonwin\pywin\debugger\fail.py" as a normal script from Python.exe, the debugger should fire up correctly. > > This particular problem would appear to be a bug. I have another > > debugger bug I need to track down, and hopefully I can also solve > > this. > > Is it connected with this one, or is it completely different? Different - occasionally the debugger seems to "hang" (although it hasnt really - it just doesnt respond - as if a modal dialog is up, although the modal dialog is hidden). I can't repro this at the moment, even tho I have seen it before :-( > > OTOH, the best stragegy for this is probably remote > debugging - use a > > seperate process to perform the debugging. This would also solve a > > few of the hairy "blocking" problems I need to deal with. However, > > this doesnt appear trivial either :-( > > I should imagine not. I suppose there is some sort of API > under Windows > to allow this sort of thing (like the Visual C++ debugger does) but I > wouldn't have any idea where to start. That API is too low-level for Python to use effectively. We really dont need the ability to replace an instruction with a break-point. Mark. -- http://www.python.org/mailman/listinfo/python-list From fredrik at pythonware.com Tue Nov 30 08:46:49 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 30 Nov 1999 14:46:49 +0100 Subject: Htmlizing text References: <943909426snz@vision25.demon.co.uk> <19991129170705.A314@better.net> <19991130141224.A2813@stopcontact.palga.uucp> Message-ID: <002301bf3b39$5b5bc9e0$f29b12c2@secret.pythonware.com> Gerrit Holl wrote: > This is better: > > def escapeall(s): > import htmlentitydefs > for k, v in htmlentitydefs.items(): > s = string.replace(s, v, '&' + k) > return s I assume this is untested code? > By the way, why doesn't the cgi module does this? if you use ISO Latin 1 for your pages (which happens to be default in HTTP/1.1, HTML 3.0, and real life), you don't really have to quote all possible entities just be- cause you can... also see: http://www.lysator.liu.se/?ttabitars/ (*) "mangling 8-bit data down to 7 bits is broken, and has no excuses." -- linus torvalds *) ie 5.0 users should use this link instead: http://www.lysator.liu.se/%e5ttabitars/ From mhammond at skippinet.com.au Tue Nov 30 08:31:51 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 30 Nov 1999 13:31:51 GMT Subject: WinNT and python as text filter... References: <3842f32d.30322451@news.concentric.net> Message-ID: How are you executing the code? Are you just typing: c:\>myscript.py > out If so, there is a bug in the NT command prompt - you need to specify the full path to Python.exe on the command line, and it will work... Mark. Tim Ottinger wrote in message <3842f32d.30322451 at news.concentric.net>... >I'm working in WinNT with VIM (good tool) and wanted to write some >handy filters in python to help me with routine editing chores. > >I run my python command at the command line and get the output I want >printed nicely on my screen. However, if I pipe it to a file the file >comes out empty, if I pipe it to more I get nothing at all. > >Does python know it's in a pipe and act differently? Does 'print' not >work right in NT? What's up? > >My python is: > > PythonWin 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on >win32 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > Portions Copyright 1994-1999 Mark Hammond >Tim From python-list at teleo.net Mon Nov 29 14:03:34 1999 From: python-list at teleo.net (Patrick Phalen) Date: Mon, 29 Nov 1999 11:03:34 -0800 Subject: Zope 2: External objects? In-Reply-To: <3842C700.A2685499@gmd.de> References: <3842C700.A2685499@gmd.de> Message-ID: <99112911104600.03274@quadra.teleo.net> [Peter K., on Mon, 29 Nov 1999] :: Hi, a short question: How do I link external objects, :: defined in a Python module, into Zope 2? Once again, this is not the appropriate list for Zope questions. Go to http://www.zope.org and subscribe to the Zope list and/or the Zope-Dev list. However, before posting basic questions like the above to the Zope lists, *please* read the docs at www.zope.org and at zdp.zope.org, where you will find the answer you seek. From bjorn at roguewave.com Mon Nov 1 14:03:35 1999 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Mon, 1 Nov 1999 12:03:35 -0700 Subject: Feature request for interactive interpreter Message-ID: <51C9F3C392D0D111A15600A0C99E64A9AF5606@localhost> I'm getting tired of typing, so my request for the next version of the interactive interpreter is a "help" function, probably defined as: def help(x): print x.__doc__ (with the appropriate 'no help available' message if the object doesn't have a doc string...) pretty-pleas'ly y'rs --bjorn From thomas at bibsyst.no Wed Nov 24 11:21:29 1999 From: thomas at bibsyst.no (Thomas Weholt) Date: Wed, 24 Nov 1999 17:21:29 +0100 Subject: CRC-module References: <38396766.B189D15A@bibsyst.no> Message-ID: <383C1089.1D0F7C18@bibsyst.no> Hi, Ok, so I`ve looked into zlib.crc32 and zlib.adler32. They seem easy enough to use, but I thought crc-codes had characters and numbers in them, not just a plain integer like the methods above return. ( As you can see, I`m a complete ass on this subject, but don`t have time to do the proper research myself, and was hoping for a "quick fix" ... ) A friend of mine mentioned that I should try SHA-1 instead, for more accuracy. Can anybody give me an example on how to compute crc-codes, using zlib or preferrably some more accurate method, for single files ?? If this is all it takes : crc = module_name.crc_method(file) and comparison is done like : if (crc1 == crc2): print "Equal." else : print "Different." then all I need is the name of the most effective/accurate module to use. If, for some strange reason, I should use one module instead of another, that info would be interesting too. I`ll stop bother you now and let you get back to work. ;-> Thomas Weholt From mwh21 at cam.ac.uk Tue Nov 9 16:42:59 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 09 Nov 1999 21:42:59 +0000 Subject: what is a function object? References: <809p0a$8nf$1@nnrp1.deja.com> Message-ID: zakons at my-deja.com writes: > Hi, > I use function objects for sorting lists and they are great but I want > to know more about what a function object is in the python environment. Well, in one way, a function isn't really much different from an integer or an instance of a class or any other Python object; they're builtin objects so you can't derive from them, etc. > * How is a function object different from other python objects? What > does it include extra? What is missing? Well, they're of type types.FunctionType. This means that when you try and call one the interpreter notices that it is a function and does the right thing. > * How may function objects be accessed by name in various namespaces? Exactly as any other data type. With one caveat: if a function is residing in the __dict__ of a class object and you access it via . notation, it is automagically wrapped up into a method object. > * Other than for sorting, what are typical uses of function objects? Hmm, passing as arguments to map, callbacks into various libraries, ... oh and calling them. y'see when the interpreter sees foo(x) it doesn't know a priori that the name "foo" is bound to a function. So it looks the name "foo" up, and assuming it finds something, attempts to call it with argument x. "Attempting to call it" goes something like: if type(foo) is types.MethodType: apply(foo.im_func,(foo.im_self,x)) elif type(foo) is types.FunctionType: apply(foo,(x,)) elif hasattr(foo,'__call__'): apply(foo.__call__,(x,)) builtins complicate the above, but I hope you get the idea. > * What does it mean to say that function objects are first-class > objects in the python environment? That you can pass the as arguments, return them from functions and store them in variables as with any other data type. > Thanks, > Stuart Zakon > Objects by Design > www.objectsbydesign.com I hope that helped. Michael From 71351.356 at compuserve.com Wed Nov 17 20:21:18 1999 From: 71351.356 at compuserve.com (T. C. Mits) Date: Wed, 17 Nov 1999 20:21:18 -0500 Subject: Need help dealing with spaces in NT paths. References: <80pr76$jq5$1@nnrp1.deja.com> <11f733ec.96958819@usw-ex0101-007.remarq.com> <80sj4q$l7t$1@nnrp1.deja.com> <80tgi8$hbn$1@ssauraaa-i-1.production.compuserve.com> Message-ID: <80vkj6$e20$1@ssauraaa-i-1.production.compuserve.com> The commands: os.system(r'dir "Program Files"') os.system('dir "Program Files"') work on win98. Thanks. However, certain others do not. Such as: >>> os.system('"dir" "Program Files"') Bad command or file name Though now that I look at it, it seems trivial, some other newbies may also get tripped up. Maybe some experts can add the reasons for these kinds of issues in the Python FAQs (where ever those are). wrote in message news:uzowdfktm.fsf at cs.uu.nl... > >>>>> "T. C. Mits" <71351.356 at compuserve.com> (TCM) writes: > > TCM> A simple example of the difficulty is: > >>>> os.system(r'"dir Program Files"') > TCM> Bad command or file name > TCM> 0 > >>>> > > > TCM> This is run at the root of C: for simplicity. > > > TCM> I also get: > > TCM> os.popen(r'"dir Program Files"', "r") > TCM> Bad command or file name > TCM> > > TCM> What does that mean? > > It means there is no program with the name: dir program files > You should use: > > os.system(r'dir "Program Files"') > os.popen(r'dir "Program Files"', "r") > -- > Piet van Oostrum > URL: http://www.cs.uu.nl/~piet [PGP] > Private email: Piet.van.Oostrum at gironet.nl From skaller at maxtal.com.au Thu Nov 18 18:32:21 1999 From: skaller at maxtal.com.au (skaller) Date: Fri, 19 Nov 1999 10:32:21 +1100 Subject: Beginning programming with Python References: <382B3A53.5816B2@callware.com> <382B3D79.74CD3E0F@email.sps.mot.com> <80p9ds$ppo$1@newshost.accu.uu.nl> <38312D55.A36EB56D@iqsoft.hu> <3831A4EB.76FF32AF@boi.hp.com> Message-ID: <38348C85.8CC9C61@maxtal.com.au> Bill Anderson wrote: > > Nemeth Miklos wrote: > > > > Janos Blazi wrote: > > > > > I have tried to use Perl in my teaching. It has a very powerful but alas! > > > not very simple syntax! To start with, my pupils used to forget the dollar > > > signs and Perl does not like that. So this year I shall use Python. We shall > > > see. Time will tell, if Python is really better. Maybe my pupils will forget > > > the indenting this time? There is actually nothing else you can forget in > > > Python. > > > > I am quite new in Python programming, and I was a bit :-( by understanding that > > Python does not have any (even optional) mechanism to enforce the usage of > > predeclared variables and functions. The complete lack of compile-time > > type-safety of Pythom may be a problem in large projects, which may be the most > > serious technical (ie non-marketing) obstacle to Python's becoming a widespread > > language like Java. > > Let us see an example: > > # Module t.py > > def f(): > > print "started" > > x = 128 > > x.foo() > > > > Let us import it in the Python interpreter: > > >>> import t > > >>> > > You can see thet the interpreter compiled t.py to t.pyc (or t.pyo) but found no > > error. > > All typos (typing errors of variable and function names) will be detected ONLY > > at runtime! Python is perfect language to write programs fast, but with the > > cost of hordes of testers. > > Disagree. I write many things in python, fast, and without hordes of > testers. > > > However this may not be a big problem, because any > > piece of software should be thoroughly tested, to make sure that there are no > > semantic errors in the application. In the case of Python the applications > > should also be tested for "syntactic" errors. > > As should _any_ language. > > > In Python (just like in Smalltalk or in Perl, or in Tcl) there are a lot of > > things a programmer may forget. [] -- John Skaller, mailto:skaller at maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia homepage: http://www.maxtal.com.au/~skaller voice: 61-2-9660-0850 From quinn at amatho.ugcs.caltech.edu Tue Nov 30 20:29:41 1999 From: quinn at amatho.ugcs.caltech.edu (Quinn Dunkan) Date: 1 Dec 1999 01:29:41 GMT Subject: What's the canonical vi setting for Python indentation References: <38445B6A.A1283D2E@cs.mu.oz.au> <19991201111751.A1277@Ridcully.home> Message-ID: On Wed, 1 Dec 1999 11:17:51 +1100, Malcolm Tredinnick wrote: >On Tue, Nov 30, 1999 at 11:46:10PM +0000, Sean Blakey wrote: >> I don't know about canonical, but I have the following in my .vimrc >> set expandtab "Turn's tabs into spaces >> set hardtabs=4 "Make tabs 4 spaces wide >> set tabstop=4 >> set shiftwidth=4 "For use with << and >> > >I tend to avoid 'set expandtab' to save typing. If I want to back out from one >indentation level to the previous one, it takes a single BackSpace to do so. >If I am using the 'expandtab' setting, it takes four keystrokes (these things >matter to me). Of course, I am also using the 'autoindent' setting (but, then >again, doesn't everybody in vim?). Note that in vim5, you can set softtabstop=4 to take out expanded tabs with a single backspace. Here's my config: se et ts=8 sw=4 softtabstop=4 smarttab I like keeping tabs at 8 chars since many other things expect that. For indentation I use: se ai im : : This mapping also works well for editing natural language, which is a good example of how intuitive python's indentation rules are :) >42.7 percent of all statistics are made up on the spot 82.8 percent of those are completely inaccurate. From reic0024 at ub.d.umn.edu Tue Nov 16 10:29:03 1999 From: reic0024 at ub.d.umn.edu (Aaron J Reichow) Date: Tue, 16 Nov 1999 09:29:03 -0600 Subject: Anyway to use file masks with os.listdir()? Message-ID: Is there any way to pass a filemask to os.listdir()? For example, to list only files with the extension .jpg. Any help would be appreciated! :) Aaron From culliton at clark.net Wed Nov 24 01:18:39 1999 From: culliton at clark.net (Tom Culliton) Date: Wed, 24 Nov 1999 06:18:39 GMT Subject: Returning a variable reference References: Message-ID: <3rL_3.41286$oa2.253950@iad-read.news.verio.net> In article , Ross Hutton wrote: >Ahh, I think I've just seen the light. Rather than trying to pass an >lvalue up the chain I should be passing the rrr code down to lower >access functions (get(rrr) and set(rrr,value)) and have them do the >dirty work. Or, since you can pass a tuple anywhere you can pass an index, just compose and pass (mem, idx) or (reg, idx) around as your destination. It does take a while to get over the C mentality and realize that multi-element return values or parameters are both easy and natural in python. >Many thanks again to Tom and Ben for their suggestions. You got me talking >to myself and that's probably not such a bad thing. > >It's quite interesting learning Python which is in many ways a lovely >language (problem is that I keep thinking in C). I was amazed when I >did some function pointer work without even looking in a manual. I >just assigned a function to a variable and called the variable as a >function. I just wrote code the way I thought it should work (and was >quite surprised when it did). More C mindset to unlearn, try to stop thinking of them as pointers. EVERYTHING in python is passed (and returned) uniformly by reference, some are immutable like numbers, strings, tuples, functions, others are mutable like lists, dictionaries, class objects, most extension types, ... Maybe you've heard Lisp people talk about functions being "first class objects"? This is also true in Python, any "basic" operation you can do with other types you can do with a function, "assign" it to a variable, pass it as a parameter, return it, ... Each type also has their own special operations like indexing sequence and mapping objects, dumping the keys of a mapping, bitwise operations on integers, calling functions, ... It's easy to get fooled by how familiar "assignment" looks, when it's really a very different mechanism. Python doesn't have variables as you know them in C. A C variable name refers directly to a piece of storage of a particular size and shape, but in Python it's an indirect binding to an object of any type. In C when you say: x = x + 1 It fetches data from the location refered to by "x" adds 1 to that value, and stores it back in the same location. Where in Python, it looks up "x" in a dictionary, eventually calls the add function with references to that object and another object containing the integer value 1, creates a new object containing the result, modifies the dictionary to point to it, and if the reference count on the object that x used to refer to has gone to zero garbage collects it. In C the things you need to internalize to really get it are pointer math and the central position of expressions. When you've done this things like: char *p, *q; int i; for (i = 0; i[p] = *(q + i); ++i) ; are not suprising, just in bad taste. To really get Python you need to internalize the mutable/immutable distinction, and the central place of dictionaries and references. Oh well, thats probably way more preaching than you wanted. ;-) Tom From tbryan at python.net Wed Nov 24 06:11:01 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Wed, 24 Nov 1999 06:11:01 -0500 Subject: Upgrade to version 1.5.2 - won't configure? References: <383990AC.A7D2BD27@python.net> <383A82DE.29ED626F@python.net> Message-ID: <383BC7C5.9FCFD75D@python.net> Don Oliver wrote: > The Python web site doesn't say that all these extra programs are required, > nor does the readme in the download. No. It assumes that you have a UNIX machine where you can compile C programs. That is, it assumes that you have a functioning C compiler, a linker, appropriate libraries, etc. Most people developing on a UNIX machine don't start using the C compiler by trying to build Python. If you had decided to build any other program from sources first, then you would have encountered this problem then. What I'm saying is that your problem wasn't Python-specific: it's really more of a Linux/UNIX configuration problem. Perhaps the README should at least mention that you must have a functioning C development environment to build Python from the sources. > > Wow! I never have any idea what's going on with Windows.... > > I said that I knew what I was doing, I never claimed to know all about the > DLL's, etc. > By that, I meant that I had no problem installing and using any programs. > Big difference! Just like the rest of us. ;-) There's nothing wrong with using Python under Windows. I do it often. Switching to Linux/UNIX, learning Python, and learning to compile C programs is a lot to do simultaneously. > >Don't we all... seriously, one thing I have learnt over my year or two > >with Linux is to let rpm do it's stuff and not move stuff around > >underneath it. It's possible to do it yourself using tarballs and mv > >and cp, but it becomes harder to keep track of what's where. > > I guess I'll stick with rpms for now. Good idea. :) Note that you can still install Python modules such as PMW and HTMLgen after you install the basic Python RPMs. Any Python module/package that has no C extension simply requires you to put the .py files somewhere where Python can find them. Many of the most commonly used C extensions for Python are available as RPMs, so you don't have to build them from the sources either. but-I-build-all-python-packages-from-sources-on-the-Starship-anyway-ly yours ---Tom From c.hintze at gmx.net Sat Nov 27 04:50:55 1999 From: c.hintze at gmx.net (Clemens Hintze) Date: Sat, 27 Nov 1999 09:50:55 GMT Subject: Python complaints References: <867lj85g4c.fsf@g.local> <86so1v4jlj.fsf@g.local> <86ln7m2t31.fsf@g.local> Message-ID: You wrote: Your> Gareth McCaughan writes: Your> > Markus Stenberg wrote: [...] Your> > One quickly gets used to Lisp syntax. Like using Your> > indentation to denote block structure. :-) After a while, Your> > you just stop noticing all those parentheses. Your> Your> This leads to a thought: would it be possible using lisp's Your> silly amount of flexibility to get the reader to Your> auto-paranthesize (word? doubt it): Your> Your> defun our-member (obj lst) Your> if null lst Your> nil Your> if eql (car lst) obj Your> lst Your> our-member obj (car lst) There are several tries to get rid of parentheses. One try is named LOGO. Your example would be coded in LOGO like that: to our-member :obj :lst ifElse nullp lst nil ifElse (first lst) == obj lst our-member obj (first lst) end Okay, I have to admit that indentation is not an issue here ;-) Your> indentation-as-structure-*will*-rule-the-world-ly y'rs Your> Michael Dreams-are-allowed-ly y'rs Clemens From m.faassen at vet.uu.nl Thu Nov 4 07:15:13 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 4 Nov 1999 12:15:13 GMT Subject: Comparison between Python and "Ruby" References: <1270552684-31022246@hypernet.com> <87n1svugfh.fsf@ev.netlab.co.jp> Message-ID: <7vrtch$nro$1@newshost.accu.uu.nl> Yukihiro Matsumoto wrote: [snip] > But TMTOWTDI (in other words: the more, the merrier) is the slogan to > emphasize maximum variability in ALL AREAS, so that I felt weird to > see Pythoneers talking TMTOWTDI or even TMTOWTHMTOWTDI in positive > attitude. Reducing variablility in ANY AREA contradict against > TMTOWTDI, I think. But there are more ways to have more ways to do it, which is I think what TMTOWTHMTOWTDI stands for. :) Python does it by reducing syntactic variability, while still having a large semantic variability; and because it's so easy to use, it arguably has a larger semantic variability than C. Of course this is nonsense because Python is written in C, but it's just *easier* to use different programming styles in Python (procedural, object oriented, functional, etc). More inviting. In this sense Python may even invite *more* semantic ways to do it than Perl (for instance people sometimes complain about the OO implementation of Perl). So there are more ways to have multiple solutions than just Perl's way. As I'm sure you'll agree with. :) There-are-more-ways-to-understand-TMTOWTDI-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From jean-marc.jezequel at irisa.fr Mon Nov 8 20:43:08 1999 From: jean-marc.jezequel at irisa.fr (Jean-Marc Jezequel) Date: Mon, 8 Nov 1999 17:43:08 -0800 Subject: Call for Papers - TOOLS Europe 2000 Message-ID: <807u34$dgc$1@news.rain.org> TOOLS Europe 2000 "Enterprise Architecture - Patterns - Components" Mont St Michel & St Malo, France June 5-8, 2000 http://www.tools.com/europe CALL FOR CONTRIBUTIONS (deadline 31st January 2000) TOOLS is the major international conference series devoted to applications of object-oriented technology. TOOLS Europe 2000 will be held in Le Mont St Michel, at the borderline of Normandy and Brittany in the north-west of France, and will continue the commitment to excellence of earlier TOOLS conferences in Europe, Australia, Asia and the USA. The proceedings will be published world-wide by the IEEE Computer Society. PAPERS TOOLS Europe 2000 is now soliciting papers on all aspects of object-oriented technology. All submitted papers will be refereed and assessed for technical quality and usefulness to practitioners and applied researchers. TOOLS Europe particularly welcomes papers that present general findings based upon industrial experience. Such papers will be judged by the quality of their contribution to industrial best-practice (rather than to the body of research knowledge). TUTORIALS and WORKSHOPS Tutorials and workshops form an important part of TOOLS conferences. TOOLS Europe 2000 is keen to receive proposals for tutorials, workshops and panels on topics. MORE DETAILS Please visit the conference website for more details. http://www.tools.com/europe From wjk at wjk.mv.com Sat Nov 27 14:25:04 1999 From: wjk at wjk.mv.com (William J. King) Date: Sat, 27 Nov 1999 14:25:04 -0500 Subject: yet 'nother newbie question Message-ID: <3840300F.66DC46DD@wjk.mv.com> Hi: When passing an argument to a function etc. -- how does one determine that it is an integer that is being passed and not a string for example... Is there something available to determine it's type. The only way I can figure is to use 'try' and 'except' for a partial solution: try: x = x + "" # suceeds then its a string -- if so x = string.atoi(x) except: x = x + 0 #This sort of partially ensures that int is passed..... or if you have the reverse situation?... Hmmm -- It seems python knows the difference internally, how can I determine types and work with variables without having to resort to exception checking... Hope this makes sense... Thanks..... From bciceron at rsn.hp.com Mon Nov 8 18:13:19 1999 From: bciceron at rsn.hp.com (Benoit Ciceron) Date: Mon, 8 Nov 1999 17:13:19 -0600 (CST) Subject: [Python] header (fwd) Message-ID: can we get an automatic subject header : "[Python]" to ALL messages submitted to the list , including replies and newsgroup threads ? thank you, ben_ From mal at lemburg.com Fri Nov 12 04:57:33 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 12 Nov 1999 10:57:33 +0100 Subject: time/strptime/mktime/localtime References: Message-ID: <382BE48D.89CD174B@lemburg.com> Oleg Broytmann wrote: > > Hello! > > The following program prints "1999-09-21 21:44:33" on Linux and > "1999-09-21 22:44:33" on Solaris (1 hour offset). > > Is it a problem with my config? libs? python? Timezone is Europe/Moscow, > set (I think) correctly on both systems. > > #! /usr/local/bin/python -O > > import time > > t = time.strptime("1999-09-21 21:44:33", "%Y-%m-%d %T") > m = time.mktime(t) > print time.strftime("%Y-%m-%d %T", time.localtime(m)) Could be that one of those sets the DST flag to 0 while the other sets it to 1... please provide the output of time.strptime() for both machines. -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 49 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From tbryan at python.net Wed Nov 10 21:03:55 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Wed, 10 Nov 1999 21:03:55 -0500 Subject: ASCII delimited files References: <942231502.1914033961@news.interbusiness.it> Message-ID: <382A240B.B247AD6B@python.net> Roger Irwin wrote: > > Is there any function or module available for parsing ASCII delimited files, > before I go and re-invent the wheel writing my own. I'm not sure exactly what you're looking for. I've appended something that I was playing with one day. It was just a way to create an object easily that could parse and validate ascii, delimited files. It might be terribly slow: I never timed it. Basically, you create a DelimFldParser object with a list of DelimParserField subclasses and a delimiter. Each DelimParserField subclass knows how to handle a specific "column" of the ASCII file. The DelimFldParser is then handed a file object (anything with a readline() method, really), and it returns a list of lists. The inner list is a list of values returned by the DelimFldParser objects for a specific line. Oh, I also assume that each line of the file has the same number of "columns." I implemented three sample DelimParserField objects. One converts ascii values to floats. Another checks that the field value is in a specified list of values. The last is designed to perform a verification of field values based on a regular expression. I wrote this thing to read and verify files before importing them into a database. I never really had much chance to use it, though. I would love to see someone optimize this thing because it makes the task of building a parser for a new format of an ASCII file very simple. It would be great, for example, for dealing with delimited data exported from a database or for parsing a delimited file for for import into a database. ---Tom #!/usr/bin/python import string import re class DelimFldParser: def __init__(self, fields, delimiter=None): """fields is an ordered list of DelimParserField instances""" self.delimiter = delimiter self.fields = fields self.numCols = len(fields) self.cols = [] for el in fields: self.cols.append(el.name) def parseLine(self, line): list = string.split(line, self.delimiter) assert len(list) == self.numCols, \ "The following line doesn't have enough fields.\n%s" % line for idx in range(self.numCols): list[idx] = self.fields[idx].convert(list[idx]) self.fields[idx].verify(list[idx]) return list def parseFile(self, fileObj): data = [] line = fileObj.readline() while line: data.append(self.parseLine(line)) line = fileObj.readline() return data def __str__(self): s = '' return s class DelimParserField: def __init__(self, name): self.name = name def convert(self,value): return value def verify(self,value): pass class EnumField(DelimParserField): def __init__(self,name,validValues): DelimParserField.__init__(self,name) self.validValues = validValues[:] def verify(self,value): assert value in self.validValues, \ "%s not in %s on the following line" % (value,self.validValues) class NumericRngField(DelimParserField): def __init__(self,name,start,stop): DelimParserField.__init__(self,name) self.min = start self.max = stop def convert(self,value): return float(value) def verify(self,value): assert value >= self.min and value <= self.max, \ "%s is not between %s an d %s" % (value,self.min,self.max) class RegexpField(DelimParserField): def __init__(self,name,regexp,flags=None): DelimParserField.__init__(self,name) if flags: self.re = re.compile(regexp,flags) else: self.re = re.compile(regexp) def verify(self,value): assert self.re.search(value), \ "%s does not match the pattern '%s'" % (value, self.re.pattern) if __name__ == '__main__': fh = open('delimParser.test','w') fh.write("""a 10 9/10/1999 b 3.5 10/11/1974 c 5.7 09/10/1974 """) fh.close() fh = open('delimParser.test','r') myParser = DelimFldParser((EnumField('Enum',('a','b','c')), NumericRngField('Range',0,10), RegexpField('RegExp','\d{1,2}/\d{2}/\d{4}'))) print myParser output = myParser.parseFile(fh) fh.close() print output From olipt at mayo.edu Tue Nov 9 17:14:58 1999 From: olipt at mayo.edu (Travis Oliphant) Date: Tue, 9 Nov 1999 16:14:58 -0600 Subject: PyArg_ParseTupleAndKeywords problem In-Reply-To: <38287096.689640FD@ioc.ee> References: <38287096.689640FD@ioc.ee> Message-ID: > > So, I write the following C code: > > static PyObject *test_foo(PyObject *capi_self, PyObject *capi_args, > PyObject *capi_keywds) { > PyObject *a_capi = NULL; > PyObject *b_capi = NULL; > static char *capi_kwlist[] = {"b",NULL}; When using PyArg_ParseTupleAndKeywords I've always had to specify a keyword string for ALL of the arguments: static char *capi_kwlist[] = {"a","b"}; > So, clearly PyArg_ParseTupleAndKeywords command emulates only a subset > of Python possibilities. Travis From claudius at catlover.com Wed Nov 24 16:16:54 1999 From: claudius at catlover.com (claudius at catlover.com) Date: Wed, 24 Nov 1999 21:16:54 GMT Subject: preprocessor for Python? Message-ID: All, I'm interested in a CPP-style macro preprocessor for Python development... Are there any such beasts? Primarily, I'm looking for some macro facilities so I can include debug statements that are removed when I need to test performance. (And yes I know of the assert statement...) From pnagel at tbs.co.za Thu Nov 18 05:24:42 1999 From: pnagel at tbs.co.za (Pieter Nagel) Date: Thu, 18 Nov 1999 12:24:42 +0200 Subject: Beginning programming with Python In-Reply-To: References: <382B3A53.5816B2@callware.com> <382B3D79.74CD3E0F@email.sps.mot.com> <80p9ds$ppo$1@newshost.accu.uu.nl> <38312D55.A36EB56D@iqsoft.hu> <19991116173142.A31379@optiplex.palga.uucp> Message-ID: On Tue, 16 Nov 1999, Janos Blazi wrote: > From: Janos Blazi > > the less time it costs to program it, the more time it costs to run it, > > the more time it costs to program it, the less time it costs to run it. > > Is this some law of nature I missed at university? > But obviously, as far as raw speed is concerned Python cannot compete with > C. Nobody can attempt to deny that. So if speed is an issue for you, use C. But then of course 90% of the time is spent in only 10% of the code. So I'd write 90% of the code in Python and just the speed-critical bit in C. -- ,_ /_) /| / / i e t e r / |/ a g e l Tangible Business Software http://www.tbs.co.za +27 12 46 8563 From tbryan at python.net Mon Nov 15 07:08:42 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Mon, 15 Nov 1999 07:08:42 -0500 Subject: Proposal: Python Info Collective References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> Message-ID: <382FF7CA.319CCC1@python.net> Jules Allen wrote: > The best part of your story for me is confirmation that open source > projects don't do well without strong leadership. No ESR or an > ESR-like figure to crack the whip, no Trove. In my experience, strong leadership is only necessary to maintain direction in an Open Source project. To get work done, you don't need a leader cracking the whip; you need one or more programmers who really want to solve some problem. As long as they are motivated, the project will progress. If they are solving a problem that plagues or interests other programmers, then others will volunteer to contribute. (This is where leadership comes in... keeping all interested contributors moving in the same direction.) It progresses this way until all of the current maintainers get bored and move on...but since the source is open, others can pick it up and use it to start new development. if-guido-got-hit-by-a-bus,-python-wouldn't-die-ly yours ---Tom From mlh at vier.idi.ntnu.no Tue Nov 16 04:20:15 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 16 Nov 1999 10:20:15 +0100 Subject: list.without()? References: Message-ID: "Mike Fletcher" writes: > Well... > > def without( source, element): > temp = source[:] > while temp: > try: > temp.remove( element ) > except: > break > return temp Whoa! Why on *earth* would you use a while/try/break-combination? IMO a much more natural solution would be: def without(source, element): result = source[:] if element in result: result.remove(element) return result My point was that I wanted a method in the standard libraries, or, preferrably as a list method. I guess the closest I got wat the filter suggestion. -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From aa8vb at yahoo.com Wed Nov 17 09:02:14 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Wed, 17 Nov 1999 09:02:14 -0500 Subject: wxPython and DISLIN work nicely together In-Reply-To: <80s0b4$g5n@mail.psy.uva.nl> References: <80s0b4$g5n@mail.psy.uva.nl> Message-ID: <19991117090214.B807152@vislab.epa.gov> Ionel Simionescu: |DISLIN (http://www.linmpi.mpg.de/dislin/) is a powerful visualization |package available on quite a lot of platforms, aimed at scientists. |DISLIN is "ported" to Python as well. | |I want to report that wxPython and DISLIN work very well together. If only wxPython would build on IRIX... -- Randall Hopper aa8vb at yahoo.com From m.faassen at vet.uu.nl Thu Nov 25 04:00:31 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 25 Nov 1999 09:00:31 GMT Subject: Python complaints References: <81g8po$reo$1@mach.vub.ac.be> <81h2hh$85c$1@nntp9.atl.mindspring.net> Message-ID: <81itrf$eqc$1@newshost.accu.uu.nl> Aahz Maruch wrote: > In article <81g8po$reo$1 at mach.vub.ac.be>, > Thomas Hamelryck wrote: >> >>Block delimitation by indenting. This makes python look like a porsche >>with a caravan attached :-). As far as I know, most python users even >>seem to like this for some reason. > I agree with you and I'm also one of the people who likes it. Here's > why: it makes Python code *readable*. In fact, I wish that Guido would > disallow > if foo : bar() > and force it to always be > if foo : > bar() Agreed. The Zope sources are full of the former and that idiom doesn't help me read them particularly. Perhaps 1.6 could introduce this requirement, and some scripts to convert existing code. The only use I can see for the former is to write nice obfuscated one liners. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From pinard at iro.umontreal.ca Mon Nov 1 20:01:01 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 01 Nov 1999 20:01:01 -0500 Subject: Default indentation of 4 columns In-Reply-To: Michael Hudson's message of "24 Oct 1999 18:42:36 +0100" References: Message-ID: Michael Hudson writes: > It hadn't occurred to me before, but one `solution' would be to chuck > another space between `if' and `(', like so: > def r(): > if (long_condition > and other_condition): > return ineteresting_stuff > Not especially natural, but it might just work... Yes. Not bad! :-) Thanks for the suggestion. P.S. - Thanks to Emile van Sebille for sharing his idea: > How about : > for file_name, line_number, function_name, python_text in frames: > if (function_name[0] not in ('_', '<') > and function_name not in transparent_functions > ): > name = os.path.basename(file_name) > if name not in transparent_files: > return name, line_number > At least here, the '):' is clear. It was the next best suggestion (not raising fights with Python Emacs mode). I did try it a few times, and I'm not sure I'll easily tame myself to it. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From aahz at netcom.com Fri Nov 5 18:45:07 1999 From: aahz at netcom.com (Aahz Maruch) Date: 5 Nov 1999 23:45:07 GMT Subject: What are Aspects? (Re: How can I make my assertions smarter?) References: Message-ID: <7vvq63$ehm$1@nntp4.atl.mindspring.net> In article , William Tanksley wrote: > >In short, aspects are like objects, only where an object implements a >self-contained concept, an aspect implements a widespread concept. For >example, reference counting could be written as an aspect, but never as an >object. Sounds like templates to me, or Python's "mix-in" classes. Am I missing something? -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From hildeb at www.stahl.bau.tu-bs.de Fri Nov 26 11:22:41 1999 From: hildeb at www.stahl.bau.tu-bs.de (Ralf Hildebrandt) Date: 26 Nov 1999 16:22:41 GMT Subject: fcntl/ioctl and O_NONBLOCK References: Message-ID: On 26 Nov 1999 14:19:11 GMT, Ralf Hildebrandt wrote: >What I want to do: I want to use select() to see if there's data to be >read from stdin or stdout and read it ALL (thus I need stdin/stdout to >be non blocking!) Hmm, is this here correct ? fcntl.fcntl(stdout.fileno(), FCNTL.F_SETFD, FCNTL.O_NDELAY) From robin.boerdijk at nl.origin-it.com Wed Nov 10 11:14:09 1999 From: robin.boerdijk at nl.origin-it.com (Robin Boerdijk) Date: Wed, 10 Nov 1999 17:14:09 +0100 Subject: .dll and .exe file version informaton References: <000101bf2b3c$a7d43e40$d32d153f@tim> Message-ID: <0E16861EE7BCD111BE9400805FE6841F0C7A489C@c1s5x001.cor.srvfarm.origin-it.com> Tim Peters wrote in message news:000101bf2b3c$a7d43e40$d32d153f at tim... > [emuller at painewebber.com] > > Can anyone give me an idea how to quikly get the version info on .dll > > and .exe files under windows? > > In Explorer, right-click on the file, select Properties from the context > menu, and click the Version tab. Strange... My Explorer only gives me a General tab. Quickview in the context menu, however, shows a lot of technical info about the selected .dll or .exe. Robin From nick at src.uchicago.edu Wed Nov 3 15:38:42 1999 From: nick at src.uchicago.edu (Nick Collier) Date: Wed, 03 Nov 1999 14:38:42 -0600 Subject: Can't start IDLE References: <381F4EB1.AFD9BA32@src.uchicago.edu> <5lg0yotka6.fsf@eric.cnri.reston.va.us> Message-ID: <38209D52.C4370040@src.uchicago.edu> It looks like this is the problem. Unfortunately, some other software I've got installed relies on other versions of tcl, so I'll have to run emacs as my python editor for now. Saw IDLE at the talk you gave at the Univ. of Chicago last week and wanted to give it a try. I enjoyed the talk and thanks for coming. Nick Guido van Rossum wrote: > > Nick Collier writes: > > > On winNT sp3 I get the following message when I do a "python idle.py" > > from the command line: > > > > C:\Program Files\Python\Tools\idle>python idle.py > > Traceback (innermost last): > > File "idle.py", line 3, in ? > > PyShell.main() > > File "PyShell.py", line 612, in main > > fixwordbreaks(root) > > File "EditorWindow.py", line 606, in fixwordbreaks > > tk.call('tcl_wordBreakAfter', 'a b', 0) # make sure word.tcl is > > loaded > > TclError: invalid command name "tcl_wordBreakAfter" > > > > I looked around deja.com and found one other person with the same > > problem, but no response so I'm asking here. > > Could it be that you have an older (or newer) Tcl version installed? > Python (for now, until I upgrade the _tkinter module) requires Tcl/Tk > 8.0.5 -- which is the version that comes with the Python 1.5.2 for > Windows installer. > > Try to erase all traces of other Tcl installs and reinstall Python and > see if that works. > > --Guido van Rossum (home page: http://www.python.org/~guido/) -- Nick Collier nick at src.uchicago.edu Social Science Research Computing University of Chicago Chicago, IL 60637 From duncan at rcp.co.uk Wed Nov 10 07:01:17 1999 From: duncan at rcp.co.uk (Duncan Booth) Date: 10 Nov 1999 12:01:17 GMT Subject: Newbee WinNT ODBC Question References: <809ckk$vbf$1@nnrp1.deja.com> Message-ID: <8E7A7ABCDduncanrcpcouk@news.rmplc.co.uk> wayne_strauss at mail.medscape.com wrote in <809ckk$vbf$1 at nnrp1.deja.com>: >I've installed Python and Win32all.exe. When I run the following (only >the first three lines shown): > >import dbi, odbc # ODBC modules >import time # standard time module > >dbc = odbc.odbc('db/id/pw') > >I get: > >>>> Traceback (innermost last): > File "d:\Program >Files\Python\Pythonwin\pywin\framework\scriptutils.py", line 237, in >RunScript > exec codeObject in __main__.__dict__ > File "D:\dev\Python\ODBC\odbc.py", line 1, in ? > import dbi, odbc # ODBC modules > File "odbc.py", line 4, in ? > dbc = odbc.odbc('db/id/pw') >TypeError: call of non-function (type module) > >If the import worked then why does the actual function call fail? It looks rather as though you called your file odbc.py so when you do import odbc it tries to reimport your script instead of importing the odbc module. Rename your source file and it should work a bit better. From philh at welshnet.co.uk Mon Nov 29 17:53:07 1999 From: philh at welshnet.co.uk (Phil Harris) Date: Mon, 29 Nov 1999 22:53:07 -0000 Subject: Exposing COM via XML-RPC or Something Else References: <613145F79272D211914B0020AFF6401914DD7C@gandalf.digicool.com> <00f001bf3b6c$5debe270$4500a8c0@thomasnotebook> Message-ID: <944002498.101563@zx81.mersinet.co.uk> Thomas Heller wrote in message news:00f001bf3b6c$5debe270$4500a8c0 at thomasnotebook... > > You might want to take a look at MS' SOAP (Simple Object Access > > Protocol) spec - it's not fully baked yet, but it basically takes > > xml-rpc several steps further, allowing you to communicate with > > SOAP-enabled objects (COM or otherwise) using XML over HTTP. We in > > Zope-land are keeping a close eye on this, as publishing objects > > via HTTP is the core idea of Zope already. > > Zope and SOAP sounds very similar. > Is this by accident? yes > > Thomas Heller > > > From janne at nnets.fi Thu Nov 11 07:04:01 1999 From: janne at nnets.fi (Janne Sinkkonen) Date: 11 Nov 1999 14:04:01 +0200 Subject: How do I compile NumPy on Linux? References: <382A8094.3354DE70@mdmlab.mi.infm.it> <19991111064736.A528@better.net> Message-ID: William Park writes: > On Thu, Nov 11, 1999 at 09:38:45AM +0100, Sandro Ferrari wrote: > > I downloaded the LLNLDistribution.tgz file and followed the installation > > instruction: > > cd Numerical > > ./makethis.py > > but I get the message: > > make: Makefile.pre.in: No such file or directory > > make: *** No rule to make target `Makefile.pre.in'. Stop. > > make: *** No targets. Stop. > > In the documentation isn't mentioned anything about it. > > Any help? > > thanks > > Sandro > > This was long time ago. But, from my memory, I did > python makethis.py > python installthis.py > So, check the *.py files whether this should be. It's identical to what he tried. I guess that he either has an incomplete Numeric package (unlikely) or that /usr/lib/python1.5/config/Makefile.pre.in or an equivalent is missing. I don't know whether the config directory is provided by the python RPM or by the python-devel RPM, but the config directory _was_ missing from a Python 1.5.2. RPM which I installed some months ago (all this assumes he uses RedHat). A suitable combination of RPMs or installing from sources fixes this problem. -- Janne From pmoran at nas.nasa.gov Tue Nov 2 17:35:34 1999 From: pmoran at nas.nasa.gov (Patrick J. Moran) Date: 2 Nov 1999 22:35:34 GMT Subject: NT DLL modules and C++ Message-ID: <7vnovm$6do$1@sun500.nas.nasa.gov> Hello, I am using Python as a wrapper around several C++ libraries that our group has developed. My approach is to make dynamically linked modules and then import them. The libraries contain classes with static data members that need to be initialized when the module is loaded. On SGI's, if I build Python with "LDSHARED=CC -n32 -shared -all", then Python knows to call the C++ initialization routine when my module is loaded. How do I get Python to call the initialization under NT? Thanks. Pat # -------------------------------------------------------------------- # Patrick J. Moran http://www.nas.nasa.gov/~pmoran # Veridian/MRJ Technology Solutions NASA Ames Research Center From mstenber at cc.Helsinki.FI Fri Nov 26 10:46:24 1999 From: mstenber at cc.Helsinki.FI (Markus Stenberg) Date: 26 Nov 1999 17:46:24 +0200 Subject: Python complaints References: <867lj85g4c.fsf@g.local> <383CC835.B585EBDD@Lugoj.Com> <383D9C63.3A7E5806@Lugoj.Com> <86ogci2tfm.fsf@g.local> Message-ID: Gareth McCaughan writes: > James Logajan wrote: > > Oh yeah? Well yer mudder wears army boots! Seriously though, the price I am > > talking about has absolutely nothing to do with simplicity. It has to do > > with the fact that languages such as Java that have "true" GC are > > non-deterministic in their execution times because GC can cause execution > > pauses in the VM at unpredictable times. This makes Java unacceptable for a > > large number of real-world applications that I have been involved in lately. > > ("I'm sorry, but your 911 call can not go through for another 20 seconds > > while our Java VM garbage collects 1GB of memory on the switch.") I have > > recommended Python over Java in at least one environment because of Python's > > deterministic approach to memory management. Had Python not had that, I > > suppose we would have gone with some other scripting language or even > > designed our own (gak!). > Garbage collectors have got a *lot* better since the days when > GC meant half-second pauses waiting for the machine to sweep > through all its memory. Let alone 20 seconds. Where can I admire such a beast? At least none of the Java implementations(*) I have tried(**) have one. say, for 128MB of trash, it's consistent N second sweep (0.5-10, depending on hardware). > -- > Gareth McCaughan Gareth.McCaughan at pobox.com > sig under construction (*) HPUX JVM, Linux Sun/IBM JVM, Windows Sun JVM (**) I could have tried harder. Yes. But I'm hoping for clues here <0.5wink> -- The IBM Principle: Machines should work. People should think. The Truth About the IBM Principle: Machines don't often work, people don't often think. From krutz at cg.tuwien.ac.at Wed Nov 24 13:57:02 1999 From: krutz at cg.tuwien.ac.at (Markus Krutz) Date: Wed, 24 Nov 1999 18:57:02 GMT Subject: newbie question Message-ID: <943469319.838266356@news.teleweb.at> How the f*** do I create a string containing a *single* "\" ? regards Markus From mcfletch at vrtelecom.com Mon Nov 29 08:35:30 1999 From: mcfletch at vrtelecom.com (Mike Fletcher) Date: Mon, 29 Nov 1999 08:35:30 -0500 Subject: [wxPython] Mandelbrot - further improvements In-Reply-To: Message-ID: Urgh, forgot the attachment... here it is... -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: mandelbrot.py URL: From Josef.Betancourt at GTECH.COM Wed Nov 3 11:23:24 1999 From: Josef.Betancourt at GTECH.COM (Betancourt, Josef) Date: Wed, 3 Nov 1999 11:23:24 -0500 Subject: capturing stderr && stdout Message-ID: <7780536C9FD5D211801B0008C75D433933D00D@rimail03> Agent: I'm using: if on98 : program = os.popen(cmdl, 'r') elif onNT : program = os.popen('( ' + cmdl + ' ) 2>&1', 'r') else: # this assumes Solaris... program = os.popen('{ ' + cmdl + '; } 2>&1', 'r') It works,but stdout and stderr are both captured. -- Josef > -----Original Message----- > From: Agent Drek [mailto:drek at MonsterByMistake.Com] > Sent: Tuesday, November 02, 1999 2:19 PM > To: python-list at python.org > Subject: capturing stderr && stdout > > > Hullo, > > I have searched the web and all the python documents/examples > I could find > before posting here. My apologies if I have missed the > obvious :) (I bought > two books as well that I am going through) > > Alot of what I need to do with python depends on launching > and controlling > a subprogram called hscript. It's a 'closed' application that > is not a full > bodied language like python. I am hoping to launch one > instance of hscript > write to it and keep its stdout && stderr. > > Most of our work gets done with csh scripts like the following: > > #!/bin/csh -f > > #csh stuff goes here > > hscript -q $HIPDIR/$HIPFILE << ENDCAT >>&! $LOG > # now I write hscript commands > opcf /obj > #etc > ENDCAT > exit > > > here's a stripped down version of what I have thus far. > > > #!/usr/local/bin/python > > import os, sys > HSCRIPT = "hscript" > > p = os.popen("%s" % HSCRIPT, "w") > p.write("opcd /obj\n") > p.write("opadd geo\n") > p.write("opls\n") > p.write("quit\n") > > > This is great so far but I just need stderr from hscript > (just in case it > crashes:) and stdout (to keep a neat log file) > > This will need to work on *nix. > > I'm trying to move to python as our main scripting language > so that we can > reuse code and integrate a gui (tkinter) easily into our apps. > > If you're interested in what hscript is you can visit http://www.sidefx.com/ and check out houdini. thanks for any tips, =derek Monster By Mistake Inc > 'digital plumber' mailto:drek at monsterbymistake.com http://www.interlog.com/~drek "This mail was powered by Linux & Vim" -- http://www.python.org/mailman/listinfo/python-list From darcy at vex.net Thu Nov 11 09:40:43 1999 From: darcy at vex.net (D'Arcy J.M. Cain) Date: 11 Nov 1999 14:40:43 GMT Subject: ASCII delimited files References: <942231502.1914033961@news.interbusiness.it> Message-ID: <80ekhb$1qrh$1@hub.org> Roger Irwin wrote: > Is there any function or module available for parsing ASCII delimited files, > before I go and re-invent the wheel writing my own. > BTW, I know it is simple to do, but I was thinking along the lines that a > 'standard' could easily be substituted for a C version for large files. I use delimited.py which works pretty good. Here's an example usage. import delimited for l in delimited.split_delimited(open('datafile.csv').read()): print "Field 1: %s\nField 2: %s\n\n" % (l[0], l[1]) I couldn't find this on the Python or Starship sites but you can get it from http://www.deja.com/getdoc.xp?AN=448769706. One small problem with it is that it doesn't handle commas within quoted strings properly. I am going to look at this today for another project and I will post it here when I have something. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From tlane at parlant.com Mon Nov 8 12:17:10 1999 From: tlane at parlant.com (Thomas Lane) Date: Mon, 08 Nov 1999 10:17:10 -0700 Subject: Image buttons with Tkinter Message-ID: <38270596.A391995C@parlant.com> I'm trying to create a button that displays an image instead of text, but I don't seem to be having any luck. The button just comes up gray. Here is a code snippet of what I'm trying to do: # Put remove.gif on a button (actionbar is a frame for various controls) deletebutton = Button(actionbar,image=PhotoImage(file="remove.gif")) deletebutton.place(x=0) What am I doing wrong here? Also, is there a place on the net where I can find lots of sample Python/Tkinter code? I've read Fredrik Lundh's intro, but I haven't been able to find any other code or reference material for Tkinter. -- Thomas Lane Provo, UT tlane at parlant.com From mhammond at skippinet.com.au Thu Nov 11 00:39:16 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 11 Nov 1999 05:39:16 GMT Subject: ASCII delimited files References: <942231502.1914033961@news.interbusiness.it> <382A240B.B247AD6B@python.net> <382A2801.FDE3CA09@python.net> <382A4330.833C4EBD@easystreet.com> Message-ID: <8EsW3.962$Xo.4938@news-server.bigpond.net.au> Al Christians wrote in message <382A4330.833C4EBD at easystreet.com>... >There's a trick with files of delimited fields. If a string field >contains a delimiter (e.g. a comma in a csv file), then the field >gets enclosed in quotes. The handling of quotes is probably trickier, >IDK what the rules are if a field starts with or contains a single or >double quote mark. I think I remember that some spreadsheets used tp >routinely enclose all strings in quotes in CSV files, but I'm not sure. Yes - a good CSV parser would make a very useful addition to the library! Mark. From Jorrit.Tyberghein at uz.kuleuven.ac.be Wed Nov 24 04:57:08 1999 From: Jorrit.Tyberghein at uz.kuleuven.ac.be (Jorrit Tyberghein) Date: Wed, 24 Nov 1999 10:57:08 +0100 Subject: Problem installing Python 1.5.2 on Solaris Message-ID: <943437439.63660@marvin> Hi, I'm trying to compile Python 1.5.2 on Solaris. uname -a gives the following info: SunOS poirot 5.6 Generic_105181-15 sun4u sparc SUNW,Ultra-2 I do a configure which seems to work ok and then I type 'make'. This works for a while but then I get the following errors: gmake[1]: Entering directory `/users/poirot/c3t2d0s0/jorrit/varia/engine/Python-1.5.2/Modules' gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c ./regexmodule.c gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c ./regexpr.c gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c ./pcremodule.c gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c ./pypcre.c gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c ./posixmodule.c In file included from ./posixmodule.c:3031: /usr/include/sys/statvfs.h:38: parse error before `fsblkcnt_t' /usr/include/sys/statvfs.h:38: warning: no semicolon at end of struct or union /usr/include/sys/statvfs.h:39: warning: data definition has no type or storage class /usr/include/sys/statvfs.h:40: parse error before `f_bavail' /usr/include/sys/statvfs.h:40: warning: data definition has no type or storage class /usr/include/sys/statvfs.h:41: parse error before `f_files' /usr/include/sys/statvfs.h:41: warning: data definition has no type or storage class /usr/include/sys/statvfs.h:42: parse error before `f_ffree' /usr/include/sys/statvfs.h:42: warning: data definition has no type or storage class /usr/include/sys/statvfs.h:43: parse error before `f_favail' /usr/include/sys/statvfs.h:43: warning: data definition has no type or storage class /usr/include/sys/statvfs.h:51: parse error before `}' /usr/include/sys/statvfs.h:51: warning: data definition has no type or storage class ./posixmodule.c: In function `posix_fstatvfs': ./posixmodule.c:3044: storage size of `st' isn't known ./posixmodule.c: In function `posix_statvfs': ./posixmodule.c:3096: storage size of `st' isn't known gmake[1]: *** [posixmodule.o] Error 1 Hope you can help me. Greetings, -- --------------------------------------------------------------------------- Jorrit Tyberghein (Jorrit.Tyberghein at uz.kuleuven.ac.be) Project Manager of Crystal Space, a free and portable 3D 6DOF portal engine. More info at: http://crystal.linuxgames.com --------------------------------------------------------------------------- From fredrik at pythonware.com Thu Nov 25 03:58:13 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 25 Nov 1999 09:58:13 +0100 Subject: Python complaints References: <867lj85g4c.fsf@g.local> <383CC835.B585EBDD@Lugoj.Com> Message-ID: <00bd01bf3723$36d699c0$f29b12c2@secret.pythonware.com> James Logajan wrote: > Sorry, but I think the price paid for "true" GC is too high for the small > number of programs that benefit from this. Perhaps one should learn to clean > up after oneself when cycles are expected. Hmm. I've recently dissected two large (and very complicated) Python projects, and one of the major cost contributors when going from "working code" to "production quality code" was the time needed to hunt down a number of totally unexpected re- source leaks. GC would have helped in most of those cases. (and in contrast what people claim on this list, more syntactic sugar or static typing would have saved al- most nothing...) I plan to write a longer piece on this at a later time. From hamish_lawson at yahoo.co.uk Tue Nov 16 05:44:51 1999 From: hamish_lawson at yahoo.co.uk (hamish_lawson at yahoo.co.uk) Date: Tue, 16 Nov 1999 10:44:51 GMT Subject: Python module to format text into columns? References: <80oq13$ql3$1@nnrp1.deja.com> Message-ID: <80rcj3$n23$1@nnrp1.deja.com> mlh at vier.idi.ntnu.no (Magnus L. Hetland) wrote: > Without really knowing whether there is such a module, I offer a > simple implementation of some of the functionality, which can easily > be extended: Holding to the principle of not reinventing the wheel, I decided to search the Python archives and (if necessary) ask in this newsgroup before attempting to write my own module. Now that it appears that no such module already exists, your contribution, Magnus, has given me a start in writing my own. Thank you. The module could provide a format picture mechanism for specifying column widths and alignments: formatter.setpicture(" <<<<<<<<<<<<<<<< <<<< >>>>>>") but I'm inclined to provide (at least initially) just the direct methods: formatter.setcolumn(column=1, margin=4, width=16, align=left) formatter.setcolumn(column=2, margin=2, width=4, align=left) formatter.setcolumn(column=3, margin=2, width=6, align=right) Does anyone have any thoughts on this? Hamish Lawson Sent via Deja.com http://www.deja.com/ Before you buy. From phd at phd.russ.ru Wed Nov 24 10:47:03 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Wed, 24 Nov 1999 15:47:03 +0000 (GMT) Subject: CRC-module In-Reply-To: <383C1089.1D0F7C18@bibsyst.no> Message-ID: On Wed, 24 Nov 1999, Thomas Weholt wrote: > crc = module_name.crc_method(file) > > and comparison is done like : > > if (crc1 == crc2): print "Equal." > else : print "Different." > > then all I need is the name of the most effective/accurate module to > use. Use md5. It is one of the best in this area. Attached module has a method that you can use to md5 a file. Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. -------------- next part -------------- #! /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") From cgw at fnal.gov Fri Nov 5 07:38:59 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Fri, 5 Nov 1999 13:38:59 +0100 (MET) Subject: [OFFTOPIC] Maps and functions (was Re: Apply a function to each list member?) In-Reply-To: <19991105215504.A497@Ridcully.home> References: <19991105215504.A497@Ridcully.home> Message-ID: <14370.53219.667492.946075@gargle.gargle.HOWL> Malcolm Tredinnick writes: > > Correct. In fact, since we're being precise, let me point out that > (mathematically speaking), all functions are maps (or mappings), but not > all mappings are functions. The point is that a function should have only a > single "output" for any given input (i.e. it should be many-to-one or > one-to-one, not one-to-many). So some mapping that sends, say, the number 2 > to the numbers 3 and 4 is not a function (but a mapping that sends both the > numbers 3 and 4 to the number 2 is a function, since for each input there > is only a single output). Hmm... what kind of "map" are you thinking of that could send 2 to "both 3 and 4"? I think such a thing is not a mapping, at least not according to any definition of "map" that I've ever seen. If you look, for instance, in any basic topology text, you will see that "map" and "function" mean exactly the same thing, when used as nouns. "Map" also has a sense as a transitive verb, which means "to apply a function to", which is where the Python/functional programming usage comes from. From wahern at jinsa.org Fri Nov 5 17:26:52 1999 From: wahern at jinsa.org (William Ahern) Date: Fri, 5 Nov 1999 17:26:52 -0500 Subject: making the Python case to my dept. Message-ID: <9911051740130D.02530@william.jinsa.org> Hello, I have never used Python, but I'm currently attempting to persuade a department at my university (Geroge Washington) to use Python as an intro language. I have read that it was good for this. From what I hear, the current options on the table are Delphi and Java. I don't know much about Delphi, but I doubt Java is any good for intro classes. Could anybody suggest some substantive info to make the case (or not make it). Also, the department will need an IDE (Win95/Mac), so if anybody knows where to find one.... I know Python is being used on a broad range of applications. Complaints from students these days, a professor told me, is that the current language, Pascal, is outdated and doesn't have much applicability in the real world. I tend to agree, though I'm an International Affairs major, not CS. I've seen all of the energy and spirit behind the Python community, and I can't fathom why any cash strapped organization would drop a few grand for something that is freely available on the internet. Anyhow, how much support coukd somebody need for an IDE (and a prgramming language). Not to mention the fact that a free and OSS language implementation and IDE would preclude students from secretly passing around the only CD in class w/ the applications on it. I figure using Python would be a start to getting people to think outside of the Microsoft culture (for better or worse). In any event, please at least CC: responses to wahern at jinsa.org. I'm not subscribed to this list. Thanx a bunch, Bill Ahern MIS, JINSA From jhefferon at my-deja.com Fri Nov 5 16:19:06 1999 From: jhefferon at my-deja.com (jhefferon at my-deja.com) Date: Fri, 05 Nov 1999 21:19:06 GMT Subject: Python and Literate Programming References: Message-ID: <7vvhk7$9h4$1@nnrp1.deja.com> "Tim Evans" wrote: > For just this functionality, you could try using the `noweb' tool. It > manages to not break pythons indentation much at all. For example, > the input: > > <>= > for p in parrots: > <> > > <>= > if p.perched and not p.nailed: > print "It's f****** stuffed it!" > > Will actually be correctly turned into: > > for p in parrots: > if p.perched and not p.nailed: > print "It's f****** stuffed it!" > > I'm not sure if other tools will do this correctly. Noweb has the > disadvantages that it's written in icon, and that its LaTeX output is > not great, but it isn't all bad. Noweb works great; that's what I use. But looking on deja.com on the comp.lang.programming.literate group for Python also nets a nice program called py2tex by Jeroen van Maanen . Very nice output. Jim Hefferon Sent via Deja.com http://www.deja.com/ Before you buy. From aa8vb at yahoo.com Mon Nov 1 10:21:03 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Mon, 1 Nov 1999 10:21:03 -0500 Subject: Tkinter canvas blow-up: bbox(ALL) == None Message-ID: <19991101102103.A134035786@vislab.epa.gov> Apparently if the bounds of the items in a Tk canvas widget exceed MAXINT, bbox(ALL) returns None. The attached Python script demonstrates this. Intuitively it seems like this is a bug since the contents of the canvas are maintained in floating point; integer bounds shouldn't be involved, should they? Is this a Tk bug or a Tkinter bug? Thanks, Randall -- Randall Hopper aa8vb at yahoo.com -------------- next part -------------- #!/usr/bin/env python # # canvas_test.py - Demonstrates a bug in Tkinter's Canvas widget # where bbox = None when the bbox exceeds signed MAXINT # (2^31 on most machines). from Tkinter import * # # Create widgets # root = Tk() canvas = Canvas( root, width = 300, height = 300 ) canvas.pack() canvas.create_rectangle( (-100,-100,100,100), outline = "#008000", fill="#800000", width = 3 ) canvas.create_line( (-100,-100,100,100), fill="blue", width=3 ) canvas.create_line( (-100,100,100,-100), fill="blue", width=3 ) canvas.config( scrollregion = canvas.bbox( ALL ) ) # # Zoom the canvas until it's bounds get toasted because they exceed MAXINT # def TimerCB( canvas=canvas ): old = canvas.bbox( ALL ) canvas.scale( ALL, 0.0, 0.0, 2.0, 2.0 ) new = canvas.bbox( ALL ) print "Old = %s, New = %s" % ( old, new ) if new == None: raise SystemError, "canvas's bbox is toast (exceeds signed MAXINT)" canvas.after( 300, TimerCB ) print "CANVAS ZOOM BLOW-UP TEST:\n" canvas.after( 1500, TimerCB ) root.mainloop() From a.eyre at optichrome.com Wed Nov 24 04:40:43 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Wed, 24 Nov 1999 09:40:43 -0000 Subject: Minimal Python installation? In-Reply-To: Message-ID: <002b01bf365f$fa007430$3acbd9c2@peridot.optichrome.com> > We intend to bundle Python with a product, but would like to avoid > wasting more space than necessary. Is this a problem, license wise? > I mean, is one supposed to pass the _whole_ Python distribution only? You can, but (assuming Win32) you only need the python15.dll, and the contents of the Lib directory. -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From smigowsky at dspace.de Fri Nov 12 02:56:08 1999 From: smigowsky at dspace.de (Stefan Migowsky) Date: Fri, 12 Nov 1999 08:56:08 +0100 Subject: Win32api.... can it create a Windows shortcut (.lnk) file? Message-ID: <326536345498D311B3BC00105A39802A0744C8@newsintern.dspace.de> Hi, since this program is so clean and simple there is no error checking. The IPersists interface just throws an unspecified OLE exception, if i.e. the path of the lnk is non existent. So just include some error checking like : ... import os import types if type(Path) != types.StringType or\ type(Target) != types.StringType or\ type(Arguments) != types.StringType or\ .... raise TypeError, "String arguments required" LinkDir = os.path.dirname(Path) TargetDir = os.path.dirname(Target) if not os.path.isfile(Target) or\ raise TypeError, "Target file does not exist" # Not very correct but convienient if not os.path.isdir(LinkDir) raise TypeError, "Link directory does not exist" # Not very correct but convienient .... etc. Stefan Dipl.-Physiker Stefan Migowsky dSPACE GmbH Technologiepark 25 33100 Paderborn (Germany) mailto:smigowsky at dspace.de http://www.dspace.de -----Original Message----- From: me [mailto:none at fake.net] Sent: Friday, November 12, 1999 6:18 AM To: smigowsky at dspace.de Subject: Re: Win32api.... can it create a Windows shortcut (.lnk) file? That's a nice clean example.... but I'm having one small problem, even taking it exactly as you put it: ########################################## Traceback (innermost last): File "C:\Program Files\Python\Win32\Pythonwin\pywin\framework\scriptutils.py", line 237, in RunScript exec codeObject in __main__.__dict__ File "C:\PROGRA~1\PYTHON\MYPROJ~1\WINTOOLS\wintools.py", line 144, in ? CreateShortCut(Path,Target,Arguments,StartIn,Icon,Description) File "C:\PROGRA~1\PYTHON\MYPROJ~1\WINTOOLS\wintools.py", line 132, in CreateShortCut persist.Save(Path, 1) com_error: (-2147467259, 'Unspecified error', None, None) ########################################## Unfortunately, "Unspecified error" doesn't help me too much... q:]. I'll be looking into that tonite, but if you have a quick fix, I'd appreciate it. I've been using the win32api module a lot, and it's great, but not pythoncom a lot yet... q:] Kevin. Stefan Migowsky wrote in message news:137053459BA7D211B3930090272A62CA8EDD80 at newsintern.dspace.de... > Hi > > > Mark Hammond did a great job on wrapping the win32api. So > creating a shortcut is just so easy : > ################ CreateShortCut.py #################### > > from win32com.shell import shell > import win32api > import pythoncom > import os > import sys > > def CreateShortCut(Path, Target,Arguments = "", StartIn = "", Icon = ("",0), > Description = ""): > # Get the shell interface. > sh = pythoncom.CoCreateInstance(shell.CLSID_ShellLink, None, \ > pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink) > > # Get an IPersist interface > persist = sh.QueryInterface(pythoncom.IID_IPersistFile) > > # Set the data > sh.SetPath(Target) > sh.SetDescription(Description) > sh.SetArguments(Arguments) > sh.SetWorkingDirectory(StartIn) > sh.SetIconLocation(Icon[0],Icon[1]) > > # Save the link itself. > persist.Save(Path, 1) > > if __name__ == "__main__": > TempDir = os.environ["TEMP"] > WinRoot = os.environ["windir"] > > Path = WinRoot + "\\Profiles\\All Users\\Desktop\\New > Link.lnk" > Target = Pythonroot + "pythonw.exe " > Arguments = TempDir + "\\test.py" > StartIn = TempDir > Icon = (Pythonroot + "\\py.ico", 0) > Description = "New Link" > > CreateShortCut(Path,Target,Arguments,StartIn,Icon,Description) > > > Stefan > > > > Dipl.-Physiker Stefan Migowsky > dSPACE GmbH > Technologiepark 25 33100 Paderborn (Germany) > mailto:smigowsky at dspace.de http://www.dspace.de > > > > -----Original Message----- > From: me [mailto:none at fake.net] > Sent: Thursday, November 11, 1999 7:54 AM > To: python-list at python.org > Subject: Win32api.... can it create a Windows shortcut (.lnk) file? > > > I'm just trying to find an easy to create shortcuts on Windows platforms > through Python... it doesn't seem to be a simple matter though. > I've gone > through all the Win32 docs, and found nothing, and have started writing > (with limited success) a C function to do it. > > Is there an easy way? q:] > > Thanks, > Kevin Cazabon > > > > > -- > http://www.python.org/mailman/listinfo/python-list > > From mhammond at skippinet.com.au Tue Nov 16 00:50:00 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 16 Nov 1999 05:50:00 GMT Subject: Bug? - win32pipe.popen2 is moody under W98 References: <80qkbv$2m5$1@nntp5.atl.mindspring.net> Message-ID: Eric Johnson wrote in message <80qkbv$2m5$1 at nntp5.atl.mindspring.net>... >Can anyone say either way whether this can be expected to work under >W98? Unfortunately it is not. This is mentioned in the Python FAQ (including a link to the MS KB article that documents the bug) On the brighter side, Bill Tutt finally decided to work around this bug in Windows 98. It will be there in the next version of win32all. In the mean-time, I could probably send you the necessary updates... However, it will be pretty resource hungy - the solution (as documented by MS) is to execute a "shim" exe - so each popen on Win95/98 will now have _3_ new processes - this shim, command.com and the actual .exe you are trying to run. Win95/98 probably wont handle the strain too well, thereby giving you a practical limit of just a few popen's running... Mark. From gerrit.holl at pobox.com Tue Nov 30 08:12:24 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Tue, 30 Nov 1999 14:12:24 +0100 Subject: Htmlizing text In-Reply-To: <19991129170705.A314@better.net>; from parkw@better.net on Mon, Nov 29, 1999 at 05:07:05PM -0500 References: <943909426snz@vision25.demon.co.uk> <19991129170705.A314@better.net> Message-ID: <19991130141224.A2813@stopcontact.palga.uucp> William Park wrote: > On Mon, Nov 29, 1999 at 09:03:46PM +0000, Phil Hunt wrote: > > > > Is there a function in the standard Python library to HTML-ize text, > > i.e. to replace 'a > b & c < d' with 'a > b & c < d'? > > > > (I realize this can be done with regular expressions, but is there > > an easy way?) > > > > -- > > Phil Hunt - - - phil at comuno.com > > The following function replaces [<&>] unconditionally. > def escapeall(s): > s = string.replace(s, '&', '&') # do this first > s = string.replace(s, '<', '<') > s = string.replace(s, '>', '>') > return s > I used this in my 'HTMLtag' module which generates HTML tags. This is better: def escapeall(s): import htmlentitydefs for k, v in htmlentitydefs.items(): s = string.replace(s, v, '&' + k) return s By the way, why doesn't the cgi module does this? regards, Gerrit. -- "The move was on to 'Free the Lizard'" -- Jim Hamerly and Tom Paquin (Open Sources, 1999 O'Reilly and Associates) 2:08pm up 35 min, 4 users, load average: 0.00, 0.00, 0.08 From mhammond at skippinet.com.au Sun Nov 7 00:20:48 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 07 Nov 1999 05:20:48 GMT Subject: win32com and IIS? References: <802s6a$mj5$1@web1.cup.hp.com> Message-ID: I have never seen this before. However, these details really arent enough to help me diagnose the problem. It is possible to break this down further? Mail me if you want help doing this. A good start would be to turn on the debugging flags at the top of win32com\client\dynamic.py... Mark. Arad Rostampour wrote in message <802s6a$mj5$1 at web1.cup.hp.com>... >Hi, > >I've been using win32com to access IE and get webpages using: > >import win32com.client >ie = win32com.client.Dispatch("InternetExplorer.Application") >ie.Navigate("http://www.hp.com") >... > >This works fine from the command line. But, when I try to do this from a >CGI script under IIS, I get the following error: > >File "f:\python\win32com\client\dynamic.py", line 319, in __getattr__ raise >pythoncom.com_error, details pywintypes.com_error: (-2147467259, >'Unspecified error', (0, None, None, None, 0, -2147467259), None) Exception >exceptions.AttributeError: in ignored > >Any ideas on how to work around this? From stidolph at origin.ea.com Tue Nov 23 15:23:10 1999 From: stidolph at origin.ea.com (Stidolph, David) Date: Tue, 23 Nov 1999 14:23:10 -0600 Subject: Launching Python debugger from embedded Python Message-ID: <11A17AA2B9EAD111BCEA00A0C9B41793034AAF19@molach.origin.ea.com> I'm getting my company to register for PyWin so we can get the debug versions of PyWin, but in the meantime I made a release version of our app to test it out. I have the following code that is called from a Menu operation in our own ui: def OnMenuDebug(self,x,y,flags): print 'OnMenuDebug' import pywin.debugger try: a = 1 / 0 except: pywin.debugger.post_mortem() In the Output Debug Window of MSDev, I can see that the win32ui.pyd is loading, and it loads other DLL's, but it crashes. I'm going to do another release build with all the debug info turned on, but wanted to get this question out to see if anyone has ideas to get the debugger working. OnMenuDebug Loaded 'C:\Program Files\Python\Pythonwin\win32ui.pyd', no matching symbolic information found. Loaded 'C:\WINNT\system32\PyWinTypes15.dll', no matching symbolic information found. Loaded 'C:\WINNT\system32\ole32.dll', no matching symbolic information found. Loaded 'C:\WINNT\system32\oleaut32.dll', no matching symbolic information found. Loaded 'C:\WINNT\system32\mfc42.dll', no matching symbolic information found. Loaded 'C:\WINNT\system32\winspool.drv', no matching symbolic information found. Loaded 'C:\WINNT\system32\shell32.dll', no matching symbolic information found. Loaded 'C:\WINNT\system32\shlwapi.dll', no matching symbolic information found. First-chance exception in uo2client.exe (PYTHON15.DLL): 0xC0000005: Access Violation. The program 'C:\UO2\build-win32\uo2client\Release\uo2client.exe' has exited with code 0 (0x0). From A.Weis at t-online.de Sat Nov 27 18:05:58 1999 From: A.Weis at t-online.de (Arnold Weis) Date: Sat, 27 Nov 1999 23:05:58 GMT Subject: Sending files to a WWW-Server References: <81nje2$su9$1@rznews.rrze.uni-erlangen.de> Message-ID: <38406354.3417747@news.main-echo.net> "Jan Stiller" wrote: >Hi all > >I'm searching for examples how to send files to a web server. I've found >out, that I have to use multipart messages, but don't know exactly how to >construct them. Maybe http://starship.python.net/crew/jbauer/cgiupload/ is what you are searching for? Regards Arnold From ionel at psy.uva.nl Tue Nov 16 09:55:11 1999 From: ionel at psy.uva.nl (Ionel Simionescu) Date: Tue, 16 Nov 1999 15:55:11 +0100 Subject: docs References: <000a01bf2ffc$3e70b0e0$042d153f@tim> Message-ID: <80rr5j$fku@mail.psy.uva.nl> Tim Peters wrote in message news:000a01bf2ffc$3e70b0e0$042d153f at tim... | Ask MS for the source code . Short of that, there's no reason to | suppose it's a problem with the docs, and every reason to suspect the | obvious. Indeed, there was no problem with the docs. Our guess was that the IE would register properly the MIME type (for the cached copies), only if the comment between and is moved elsewhere. ionel From ivanlan at callware.com Tue Nov 30 22:00:49 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Tue, 30 Nov 1999 20:00:49 -0700 Subject: Python complaints References: <81bmmi$279$1@nnrp1.deja.com> <3841EE77.6B5D6AC9@wjk.mv.com> <38435C43.B238EC15@mindspring.com> <384484A2.AF4BE448@mindspring.com> Message-ID: <38448F61.6153AC89@callware.com> Hi All--- "Jesse D. Sightler" wrote: [horrible stuff bobbitted] > > >>> incr(x) > > >>> x > > 2 > > Ack, and I though Perl was the only language that made you do stuff like > that. :) Could you please explain this little piece of code? > > It sure looks like byte-code dependant, self-modifying crazyness to me. > :) > NO, no, don't ask him to explain it! It'll just encourage him! -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours ---------------------------------------------- From news at dorb.com Tue Nov 30 16:42:06 1999 From: news at dorb.com (Darrell) Date: Tue, 30 Nov 1999 16:42:06 -0500 Subject: Does this code create a circular reference ? References: <8216ih$2ki@mail.psy.uva.nl> Message-ID: Let the child keep a key to look up the parent. dic={} class child: def __init__(self, parent): self.parent = parent def do_something(self): pass class headache: def __init__(self): global dic dic[`self`]=self def method(self): a_child = child(`self`) a_child.do_something() -- --Darrell "Ionel Simionescu" wrote in message > I need advice on whether the situation described below introduces circular > references. > From wlfraed at ix.netcom.com Wed Nov 24 11:26:01 1999 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Wed, 24 Nov 1999 08:26:01 -0800 Subject: Python complaints References: <8666ysfta9.fsf@ix.netcom.com> <012e01bf365d$912fa360$f29b12c2@secret.pythonware.com> Message-ID: <5g08OLe6ncyc5Uu5627KDJVZ2N0R@4ax.com> On Wed, 24 Nov 1999 10:23:27 +0100, "Fredrik Lundh" declaimed the following in comp.lang.python: > Brad Knotwell wrote: > > Similarly, the only thing I've found missing from Python is C's > > ternary operator, it would be nice to be able to do something like > > the following: > > > > def max(x,y): return ((x>y) ? x : y) > > now that was one lousy example ;-) > Also potentially unsafe if either x or y is some expression when invoked. At least, I seem to recall some suggestion to always put macro arguments in parens... def max(x,y): return(((x)>(y)) ? (x) : (y)) -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From gmcm at hypernet.com Sun Nov 14 22:24:12 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Sun, 14 Nov 1999 22:24:12 -0500 Subject: Variable scope question.. singletons? In-Reply-To: <382f70a7@news.nwlink.com> Message-ID: <1269486246-1025196@hypernet.com> Adam Vandenberg asks: > I have a bunch of modules that will be used by a bunch of top-level scripts > (cgis). > Each top-level script is going to: "import prefs" which I want to check > cookies > and fill out a Prefs class. > So far OK. > > Now, is there any way to make this class "more global" so that any of the > modules I import can access it? > I guess this is sort of like declaring the variable "extern". > > Any thoughts? Sometimes. Rarely on Sundays. > Does this make sense? Not an iota of a scintilla . The very first import will install the module in sys.modules. Subsequent imports will simply return references to the thing in sys.modules. So, in the absense of bizarre import hooks, it already is "extern". returning-to-Sunday-night-oblivion-ly y'rs - Gordon From sekter at mail.matav.hu Mon Nov 15 09:51:35 1999 From: sekter at mail.matav.hu (Arpad Kiss) Date: Mon, 15 Nov 1999 15:51:35 +0100 Subject: PIL 1.0 on win32? References: <009b01bf2f5e$fef3b900$029f38c3@geometria.hu> <01ee01bf2f61$96097a80$f29b12c2@secret.pythonware.com> <004701bf2f6a$bd67f990$029f38c3@geometria.hu> Message-ID: <005501bf2f78$ea3d9a70$029f38c3@geometria.hu> Hi, I've got some new font files and with them it works. And when I commented out the text drawing part of my code I left some text related line in it, that causes the mirrored image(i think). Thanks a lot, Arpad Kiss ----- Original Message ----- From: Arpad Kiss To: Fredrik Lundh Cc: Sent: Monday, November 15, 1999 2:10 PM Subject: Re: PIL 1.0 on win32? > > Fredrik Lundh wrote: > > Arpad Kiss wrote: > > > I have a PIL based Zope product I have been developing on a Linux box. I > > > just wanted to test it on a Windows NT(sp5), but it doesn't work.:-( > > > At first it didn't recognize my fonts, because the readline method on > win32 > > > returns 10+13 at the end of the lines and in ImageFont.py only \n is > > > checked. > > > > PIL opens the font files in binary mode, so this > > shouldn't be a problem. you probably messed > > something up when you transferred the font > > files to the PC... > > I have created a .tar.gz then extracted it with WinZip. > > > > > > After I solved it I got an error message(memory error in line 151 of > > > ImageDraw.py) when I wanted to draw some text. > > > When I commented out the text drawing code in my program, then I got > back a > > > picture, but it is mirrored! > > > > this sounds really weird -- but at least the > > memory error might be due to bogus font data... > > Ok. I will try to replace my fonts. > > > > > what win32 build do you use? can you post some > > code? > > Python1.5.2 and pil-win32-991101.zip > I will write a minimal example. > > > > > > Of course on linux box my program works fine. > > > I just want know who else use PIL 1.0 on win32 and what experiences they > > > have. Should this text drawing function work? Is it my fault? > > > > fwiw, PIL is being developed on win32... > > Maybe a minimal example(without Zope) can help me, if cannot then I'll post > it. > Thanks, > Arpad > > > > -- > http://www.python.org/mailman/listinfo/python-list > From fredrik at pythonware.com Tue Nov 2 05:22:23 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 2 Nov 1999 11:22:23 +0100 Subject: Comparison between Python and "Ruby" References: <1270663667-24391282@hypernet.com><381ED7A6.D7D7FB13@compaq.com> <877lk1wiij.fsf@ev.netlab.co.jp> Message-ID: <003901bf251c$290775d0$f29b12c2@secret.pythonware.com> Yukihiro Matsumoto wrote: > I guess he loves reducing variablity, if possible, which is totally > against TMTOWTDI. I don't judge whether it is good or bad. you're confusing syntax with semantics. there are MANY ways to solve any given problem in Python, but when you've decided that you want to use a certain pattern (be it a loop, an iterator, an object factory, or any other pydiom) in your solution, there's usually ONE way to write the code. think about it. From hildeb at www.stahl.bau.tu-bs.de Sun Nov 28 10:47:16 1999 From: hildeb at www.stahl.bau.tu-bs.de (Ralf Hildebrandt) Date: 28 Nov 1999 15:47:16 GMT Subject: fcntl/ioctl and O_NONBLOCK References: <81ml5t$eer$0@216.39.151.169> <81p32a$m14$1@216.39.151.169> <81qj26$be6$0@216.39.151.169> Message-ID: On 28 Nov 1999 06:45:26 GMT, Donn Cave wrote: >Yes - only a guess, but it bites everyone at least once when trying >to talk to another process via pipes. After each write(), where your >Python program is writing to the ``stdin'' of the plot process, add >a flush(), i.e. stdin.flush(). Yup, forgot that one. As usual. >data to be written immediately anyway. You can also control this >by the buffer size parameter to the function that creates the file >object, or just avoid a file object altogether and write directly >to the pipe file descriptor. Yes? I always wondered what the "default" buffer size was. From Bjoern.Giesler at stud.uni-karlsruhe.de Tue Nov 23 13:11:40 1999 From: Bjoern.Giesler at stud.uni-karlsruhe.de (Bjoern.Giesler at stud.uni-karlsruhe.de) Date: Tue, 23 Nov 1999 19:11:40 +0100 (CET) Subject: Embedding: Getting the module from a PyObject * Message-ID: Hi, can anyone tell me how to get the module object that a certain instance's class is defined in, from that instance? In my code, I call PyImport_ImportModule(name). The module's Python code defines a plugin object obj and calls CPlugin.register(obj), which maps to the C function CPluginPyRegister(). In CPluginPyRegister, I want to add the module's PyObject * to an internal structure so I can unload the module at some later time. Phew, I hope this isn't too unclear. If anyone could help me, I'd be extremely thankful. --Bjoern From mikael at isy.liu.se Fri Nov 5 07:32:57 1999 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 05 Nov 1999 14:32:57 +0200 (MET) Subject: [OFFTOPIC] Maps and functions (was Re: Apply a function to e In-Reply-To: <14370.53219.667492.946075@gargle.gargle.HOWL> Message-ID: On 05-Nov-99 Charles G Waldman wrote: > Hmm... what kind of "map" are you thinking of that could send 2 to > "both 3 and 4"? I think such a thing is not a mapping, at least not > according to any definition of "map" that I've ever seen. If you > look, for instance, in any basic topology text, you will see that > "map" and "function" mean exactly the same thing, when used as nouns. > "Map" also has a sense as a transitive verb, which means "to apply a > function to", which is where the Python/functional programming usage > comes from. There is nothing that says that a map cannot output a set. But then again, that is an object (in a set of sets), even if the set consists of many smaller objects. As an example, the inverse mapping of the squaring function (a->a^2) is a mapping from the set of reals to a set of sets of reals, sets containing at most two real elements (b->{+/-sqrt(b)},{0}, or the empty set), depending on if b is positive, zero, or negative. You are probably right when you state that a function is a mapping is a function, but people tend to give them different interpretations. As an example (to make things even more confused), I have a reference (Davenport: Probability and Random Processes) that uses the words in the following way: A function determines a mapping from one set to another. This suggests that a function is just an expression, and the mapping is its action on the elements of a set. Are-we-being-too-scientific-ly y'rs /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: 05-Nov-99 Time: 13:55:12 This message was sent by XF-Mail. ----------------------------------------------------------------------- From fredrik at pythonware.com Wed Nov 24 06:50:45 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 24 Nov 1999 12:50:45 +0100 Subject: Absolute newbie question References: Message-ID: <002501bf3672$26107e50$f29b12c2@secret.pythonware.com> Philip Tellis wrote: > Where are the man pages for python? I am new to python, and would like to > look through the man pages before I start. Someone please help. $ man python NAME python - an interpreted, interactive, object-oriented pro- gramming language SYNOPSIS python [ -d ] [ -i ] [ -O ] [ -S ] [ -t ] [ -u ] [ -v ] [ -x ] [ -X ] [ -c command | script | - ] [ arguments ] DESCRIPTION Python is an interpreted, interactive, object-oriented programming language that combines remarkable power with very clear syntax. For an introduction to programming in Python you are referred to the Python Tutorial. The Python Library Reference documents built-in and standard types, constants, functions and modules. Finally, the Python Reference Manual describes the syntax and semantics of the core language in (perhaps too) much detail. Python's basic power can be extended with your own modules written in C or C++. On most systems such modules may be dynamically loaded. Python is also adaptable as an exten- sion language for existing applications. See the internal documentation for hints. COMMAND LINE OPTIONS -d Turn on parser debugging output (for wizards only, depending on compilation options). -i When a script is passed as first argument or the -c option is used, enter interactive mode after exe- cuting the script or the command. It does not read the $PYTHONSTARTUP file. This can be useful to inspect global variables or a stack trace when a script raises an exception. -O Turn on basic optimizations. This changes the filename extension for compiled (bytecode) files from .pyc to pyo. -S Disable the import of the module site and the site- dependent manipulations of sys.path that it entails. -t Issue a warning when a source file mixes tabs and spaces for indentation in a way that makes it depend on the worth of a tab expressed in spaces. Issue an error when the option is given twice. -u Force stdin, stdout and stderr to be totally unbuffered. -v Print a message each time a module is initialized, showing the place (filename or built-in module) -x Skip the first line of the source. This is intended for a DOS specific hack only. Warning: the line numbers in error messages will be off by one! -X Make the standard exceptions strings instead of classes. Use for backward compatibility with old code only. -c command Specify the command to execute (see next section). This terminates the option list (following options are passed as arguments to the command). INTERPRETER INTERFACE The interpreter interface resembles that of the UNIX shell: when called with standard input connected to a tty device, it prompts for commands and executes them until an EOF is read; when called with a file name argument or with a file as standard input, it reads and executes a script from that file; when called with -c command, it executes the Python statement(s) given as command. Here command may contain multiple statements separated by newlines. Leading whitespace is significant in Python statements! In non-interactive mode, the entire input is parsed befored it is executed. If available, the script name and additional arguments thereafter are passed to the script in the Python variable sys.argv , which is a list of strings (you must first import sys to be able to access it). If no script name is given, sys.argv is empty; if -c is used, sys.argv[0] con- tains the string '-c'. Note that options interpreted by the Python interpreter itself are not placed in sys.argv. In interactive mode, the primary prompt is `>>>'; the sec- ond prompt (which appears when a command is not complete) is `...'. The prompts can be changed by assignment to sys.ps1 or sys.ps2. The interpreter quits when it reads an EOF at a prompt. When an unhandled exception occurs, a stack trace is printed and control returns to the primary prompt; in non-interactive mode, the interpreter exits after printing the stack trace. The interrupt signal raises the KeyboardInterrupt exception; other UNIX signals are not caught (except that SIGPIPE is sometimes ignored, in favor of the IOError exception). Error messages are written to stderr. FILES AND DIRECTORIES These are subject to difference depending on local instal- lation conventions: /usr/local/bin/python Recommended location of the interpreter. /usr/local/lib/python Recommended location of the directory containing the standard modules. ENVIRONMENT VARIABLES PYTHONHOME Change the location of the standard Python libraries. By default, the libraries are searched in /lib/python and /lib/python, where and are installation-dependent directo- ries, both defaulting to /usr/local. When $PYTHON- HOME is set to a single directory, its value replaces both and . To spec- ify different values for these, set $PYTHONHOME to :. PYTHONPATH Augments the default search path for module files. The format is the same as the shell's $PATH: one or more directory pathnames separated by colons. Non- existant directories are silently ignored. The default search path is installation dependent, but generally begins with /lib/python (see PYTHONHOME below). The default search path is always appended to $PYTHONPATH. If a script argu- ment is given, the directory containing the script is inserted in the path in front of $PYTHONPATH. The search path can be manipulated from within a Python program as the variable sys.path . PYTHONSTARTUP If this is the name of a readable file, the Python commands in that file are executed before the first prompt is displayed in interactive mode. The file is executed in the same name space where interac- tive commands are executed so that objects defined or imported in it can be used without qualification in the interactive session. You can also change the prompts sys.ps1 and sys.ps2 in this file. PYTHONDEBUG If this is set to a non-empty string it is equiva- lent to specifying the -d option. PYTHONINSPECT If this is set to a non-empty string it is equiva- lent to specifying the -i option. PYTHONUNBUFFERED If this is set to a non-empty string it is equiva- lent to specifying the -u option. PYTHONVERBOSE If this is set to a non-empty string it is equiva- lent to specifying the -v option. SEE ALSO Python Tutorial Python Library Reference Python Reference Manual AUTHOR Guido van Rossum CNRI 1895 Preston White Drive Reston, VA 20191 USA E-mail: guido at cnri.reston.va.us, guido at python.org And a cast of thousands. INTERNET RESOURCES Web site: http://www.python.org FTP site: ftp://ftp.python.org Newsgroup: comp.lang.python COPYRIGHT Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, The Netherlands. All Rights Reserved Permission to use, copy, modify, and distribute this soft- ware and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the names of Stichting Mathema- tisch Centrum or CWI or Corporation for National Research Initiatives or CNRI not be used in advertising or public- ity pertaining to distribution of the software without specific, written prior permission. While CWI is the initial source for this software, a modi- fied version is made available by the Corporation for National Research Initiatives (CNRI) at the Internet address ftp://ftp.python.org. STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WAR- RANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. (END) From alan.gauld at gssec.bt.co.uk Mon Nov 29 08:36:32 1999 From: alan.gauld at gssec.bt.co.uk (Alan Gauld) Date: Mon, 29 Nov 1999 13:36:32 +0000 Subject: NEWBIE References: <81m7m3$82$1@news.qub.ac.uk> Message-ID: <38428160.56B1D46D@gssec.bt.co.uk> Stuarty at excite.co.uk wrote: > I have just recently started using Python, after the first day I was further > on than I am after a semester of C programming(were at arrays...). > tutorial by Giudo van Rossum was very useful, but I attempted printing out the > reference library..there are now less considerably less trees in the world. So are you asking a question? ....or just boasting? ;-) Alan g. -- ================================================= This post represents the views of the author and does not necessarily accurately represent the views of BT. From thomas at xs4all.nl Wed Nov 3 17:18:27 1999 From: thomas at xs4all.nl (Thomas Wouters) Date: Wed, 3 Nov 1999 23:18:27 +0100 Subject: BSDI 4.0, threads and signals. Message-ID: <19991103231827.H29354@xs4all.nl> I've been busy the last two days trying to track down a weird bug in BSDI 4.0.1 compiled python with threads. The problem is that the test_signal test hangs. Compiling without thread support makes it work fine. So i whipped out the old gdb ;) I've tracked it down to the pause() library call. Apparently, compiling with threads support yields very different libc code for the pause() call. And the thread version does react to a delivered signal, the signal handler gets called, but after that, the pause()-code does not return. It does do something, but gcc -g for some reason doesn't link against a libc with debug symbols, so i can't exactly see what :P However, now i'm sort-of stuck. I could but BSDI support, but i doubt it would bring much reaction without a test program that shows the bug -- and i dont know how to make one :) I know the basics of threading and even posix threads, but not the details. Might i be missing something in the way of configuring the behaviour of pause() in a threaded enviroment ? And what need I do to compile a teensy-tiny bit of program with threading ? I tried the thread #defines from python's config.h et al, but that didn't work. Anyone with any C-clue thread-wise able to give me some pointers ? It would be greatly appreciated. Not that this bug needs fixing for me to use python... So i'm not really in a hurry or anything ;) regard's'ly-y'rs, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From didier.willame at ieee.org Mon Nov 8 00:47:41 1999 From: didier.willame at ieee.org (Didier WILLAME) Date: Mon, 08 Nov 1999 00:47:41 -0500 Subject: TEST Message-ID: <382663FD.1C9A5B6E@ieee.org> Sorry, This is a test. From sbarron at twilight. Fri Nov 5 23:24:41 1999 From: sbarron at twilight. (Scott Barron) Date: Sat, 06 Nov 1999 04:24:41 GMT Subject: Writing to files from C Message-ID: Hey all, Disregard my post on this subject. I had fflush() in the wrong function. How silly I feel. Scott From mwh21 at cam.ac.uk Mon Nov 22 08:18:19 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: Mon, 22 Nov 1999 13:18:19 +0000 (GMT) Subject: bytecodehacks-0.60 Message-ID: Just a quick note to say that the (public domain) bytecodehacks have, after a lengthy fallow period, reached version 0.60. The approach of the version numbers to 1.0 should not be taken to mean anything. Not much has changed; some things are neater/safer, I've corrected a few typos in the docs and incorporated a couple of changes suggested by Evan Simpson. Oh yes, there's a prototype Python assembler. Most useful, I'm sure! The package is now distributed using the distutils. Is this the first package to do so? Comments are, as ever, appreciated. Regards, Michael

bytecodehacks 0.60 A minor update to the package that lets you do unlikely things in Python by manipulating strings of bytecode. - (1999/11/22) From skip at mojam.com Thu Nov 18 16:50:07 1999 From: skip at mojam.com (Skip Montanaro) Date: Thu, 18 Nov 1999 15:50:07 -0600 (CST) Subject: urllib.getsize() In-Reply-To: <19991118213925.A10221@optiplex.palga.uucp> References: <19991118213925.A10221@optiplex.palga.uucp> Message-ID: <14388.29839.294164.707388@dolphin.mojam.com> Gerrit> I've written a function to get the size of a HTTP/FTP url, is it Gerrit> good enough to be put in urllib.py? My only worry is that HEAD doesn't always work (for whatever reason having to do more with servers than clients). Would it be better to wrap things in a try/except block? Anyone have a URL that fails with HEAD? Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/ 847-971-7098 | Python: Programming the way Guido indented... From boncelet at udel.edu Fri Nov 26 03:36:40 1999 From: boncelet at udel.edu (Charles Boncelet) Date: Fri, 26 Nov 1999 08:36:40 +0000 Subject: DDD and Numerical Python References: Message-ID: <383E4698.E07B9FE@udel.edu> Greg Wilson wrote: > > Hi. Has anyone integrated DDD's data visualization with the Numerical > Python extensions? > Thanks, > Greg I've used DDD a little (once or twice) and I was going to say that this worked already (I recall seeing a plot of some NumPy data), but just now I tried to do it and DDD crashed. Perhaps a more appropriate request is "has anyone integrated data visualization into IDLE"? Charlie Boncelet -- Charles Boncelet University of Delaware Newark DE 19716 USA http://www.eecis.udel.edu/~boncelet/ From news at dorb.com Tue Nov 30 17:15:15 1999 From: news at dorb.com (Darrell) Date: Tue, 30 Nov 1999 17:15:15 -0500 Subject: Does this code create a circular reference ? References: <8216ih$2ki@mail.psy.uva.nl> Message-ID: <1_X04.11614$wG3.744186@typhoon.nyroc.rr.com> After a closer look, No it doesn't create a circular reference. If the "headache" class had kept a reference to a_child it would have. def eater(): l1=[] l2=[] l1.append(l2) l2.append(l1) for y in range(50000): eater() Now that's a circular reference. -- --Darrell "Ionel Simionescu" wrote in message > I need advice on whether the situation described below introduces circular > references. > From da at ski.org Tue Nov 2 14:01:39 1999 From: da at ski.org (David Ascher) Date: 2 Nov 1999 13:01:39 -0600 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Nov 2) Message-ID: Today is election day in the United States. Here are the winners from a much simpler yet equally non-scientific selection process: The Python Consortium is started! Hewlett-Packard and LLNL provides the marquee status and the big bucks, Digital Creations the wildly successful application, Interet quietly chips in, along with Foretec Seminars, the first organization that had a check in hand! http://www.python.org/consortium/ Michel Pelletier (of Digital Creations) and Dan York (of LinuxCare) announce that they are writing a Zope book for O'Reilly and Associates: http://www.zope.org/Members/michel/ZopeBook/index_html/index_html Jan Walter announces some scripts for Blender, a computer graphics rendering tool, with very nice pictures to boot: http://www.q-bus.de/Blender/ David S. Harrison puts forth code which formats number for human consumption: http://www.deja.com/getdoc.xp&=542270123 Scot Hacker explains how good scripting BeOS is http://www.byte.com/column/BYT19991026S0001 Tim Peters sort of sorts out some of the sort issues sorted out between 1.5.1 and 1.5.2: http://www.deja.com/getdoc.xp&=AN=541957314 The same Tim accounts for a surprising 'feature' involving testing the object identity of immutable objects which puzzled Pearu Peterson and yours truly: http://www.python.org/pipermail/matrix-sig/1999-November/003106.html ========================================================================= Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the center of Pythonia http://www.python.org 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 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/ 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 http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From ejr at CS.Berkeley.EDU Sun Nov 28 02:46:20 1999 From: ejr at CS.Berkeley.EDU (Edward Jason Riedy) Date: Sat, 27 Nov 1999 23:46:20 -0800 Subject: Modules/getpath.c chases links? Message-ID: <199911280746.XAA29926@lotus.CS.Berkeley.EDU> Is there a reason why Modules/getpath.c chases links to get the `correct' path? I'd like to see that removed, but the comments make me think someone had a specific reason for including it. I use symlink trees to separate out different versions of packages distributed by different people (here, stock python 1.5.2 and the LLNL-distributed NumPy). The symlink chasing breaks this badly by looking into the symlinked directory rather than using the tree of symlinks. Simply removing the code protected by HAVE_READLINK makes my life much nicer. I'd really like to see it officially removed. (If you want a full-featured system for finding the installation, check the kpathsea library in the Web2C distribution of TeX.) Jason (not subscribed, please cc) From Gaetan_Corneau at baan.com Thu Nov 11 09:17:04 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Thu, 11 Nov 1999 09:17:04 -0500 Subject: Win32api.... can it create a Windows shortcut (.lnk) file? Message-ID: <816010E2456BD111A48700805FBBE2EEFDF79E@ex-quebec-u1.baan.com> Kevin, There is a VB example: Option Explicit 'NOTE: In Visual Basic 5.0, change Stkit432.dll in the following 'statement to Vb5stkit.dll. Private Declare Function fCreateShellLink Lib "STKIT432.DLL" (ByVal _ lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal _ lpstrLinkPath As String, ByVal lpstrLinkArgs As String) As Long Sub Command1_Click() Dim lReturn As Long 'Add to Desktop lReturn = fCreateShellLink("..\..\Desktop", _ "Shortcut to Calculator", "c:\Winnt\system32\calc.exe", "") 'Add to Program Menu Group lReturn = fCreateShellLink("", "Shortcut to Calculator", _ "c:\Winnt\system32\calc.exe", "") 'Add to Startup Group 'Note that on Windows NT, the shortcut will not actually appear 'in the Startup group until your next reboot. lReturn = fCreateShellLink("\Startup", "Shortcut to Calculator", _ "c:\Winnt\system32\calc.exe", "") End Sub If you have NT 4, you should have Vb5stkit.dll already (I do, and I don't have VB). I think a better way with Python would be using the IShellLink COM interface, but I have never used it. Hope this helps, ______________________________________________________ Gaetan Corneau Software Developer (Quality Assurance Team) BaaN Supply Chain Solutions E-mail: Gaetan_Corneau at baan.com Compuserve: Gaetan_Corneau at compuserve.com ICQ Number: 7395494 Tel: (418) 266-8252 ______________________________________________________ "Profanity is the one language all programmers know best" > -----Original Message----- > From: me [mailto:none at fake.net] > Sent: Thursday, November 11, 1999 1:54 AM > To: python-list at python.org > Subject: Win32api.... can it create a Windows shortcut (.lnk) file? > > > I'm just trying to find an easy to create shortcuts on > Windows platforms > through Python... it doesn't seem to be a simple matter > though. I've gone > through all the Win32 docs, and found nothing, and have > started writing > (with limited success) a C function to do it. > > Is there an easy way? q:] > > Thanks, > Kevin Cazabon > kcazabon at home.com > > > > -- > http://www.python.org/mailman/listinfo/python-list > From gmcm at hypernet.com Mon Nov 8 22:15:01 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Mon, 8 Nov 1999 22:15:01 -0500 Subject: Can't use len() on returned PyList object? In-Reply-To: <3.0.6.32.19991108211217.007cb210@mail.in-gen.net> Message-ID: <1270005198-16611844@hypernet.com> sessile writes: > Why can't I use 'len()' to find the length of a list > returned from my new extension module? The error is > shown as: > > TypeError: call of non-function (type int) > > The list was created by 'PyList_New()' and populated > using 'PyList_SetItem()'. I get the same error message > regardless of the data type held in the list. I can > access each element of the list just fine, but I don't > always know how many there are. Is there a reasonable > way for me to find the length of these lists in Python > other than returning the length from the extension as a > separate object? Most likely you've clobbered the name "len" by binding it to an integer (as the error msg so tersely implies). Probably nothing wrong with your extension. - Gordon From robin at jessikat.demon.co.uk Tue Nov 2 11:39:22 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Tue, 2 Nov 1999 16:39:22 +0000 Subject: Comparison between Python and "Ruby" References: <1270663667-24391282@hypernet.com> <381ED7A6.D7D7FB13@compaq.com> <877lk1wiij.fsf@ev.netlab.co.jp> <19991102154543.A4469@optiplex.palga.uucp> Message-ID: In article <19991102154543.A4469 at optiplex.palga.uucp>, Gerrit Holl writes >Yukihiro Matsumoto wrote: >> >> I guess he loves reducing variablity, if possible, which is totally >> against TMTOWTDI. I don't judge whether it is good or bad. >> > >Are there people who see TMTOWTDI [1] as an advantage? > >[1] >There's more than one way to do it. > >regards, >Gerrit. well I guess if the mathematica guys are right, having every known programming language simultaneously available allows you to just learn mathematica -symbolically confused-ly yrs- Robin Becker From jtc at dimensional.com Fri Nov 26 13:41:17 1999 From: jtc at dimensional.com (Jim Cochrane) Date: Fri, 26 Nov 1999 11:41:17 -0700 Subject: Problems Finding and installing Tkinter Message-ID: <383ED44D.3E31C959@dimensional.com> I've been trying, with no success, to install the Tkinter package for developing GUIs in Python. First I tried downloading the latest version I could find on the net, as well as the latest version of Python, to make sure everything was in synch. I then ran into problems with libraries needed for Tkinter. After downloading and installing several, including tkinter, I still had problems and gave up. (All of these were .rpm files. The last error I remember getting was for an unresovled symbol: __bzero.) Next I tried uninstalling everything I had installed, and then installing the version of Tkinter in my SuSE distribution (and reinstalling Python). (I'm using SuSE 6.1.) I made sure all the needed packages were installed, such as tk and tcl. Again, no luck. When I try to execute a simple example: #!/usr/bin/env python from Tkinter import * widget = Label (None, text = 'Hello GUI word!') widget.pack() widget.mainloop() I get the following error message: Traceback (innermost last): File "gui1.py", line 3, in ? from Tkinter import * File "/usr/lib/python1.5/lib-tk/Tkinter.py", line 5, in ? import _tkinter # If this fails your Python is not configured for Tk ImportError: /usr/X11R6/lib/libtk8.0.so: undefined symbol: panic So it's not finding a symbol named "panic". I have no idea what library this should be in. Any help, clues, or pointers would be appreciated. Also, I think another way to do this might be to download and install the latest version of everything needed for Tkinter - as I tried to do before - but obtaining everything from the same place as one consistent package. Does anyone know if this is possible and, if so, where I should look for this? Thanks! Jim Cochrane jtc at dimensional.com From arad at fc.hp.com Sun Nov 7 03:34:13 1999 From: arad at fc.hp.com (Arad Rostampour) Date: Sun, 7 Nov 1999 01:34:13 -0700 Subject: win32com and IIS? References: <802s6a$mj5$1@web1.cup.hp.com> Message-ID: <803e2a$dul$1@web1.cup.hp.com> Thanks for the quick reply...Here is a simpler example with debugging flags on: import win32com.client ieweb = win32com.client.Dispatch("InternetExplorer.Application") ieweb.Navigate("http://www.hp.com") print ieweb.Document.Body.innerText Attribute Document not in cache Getting property Id 0xcb from OLE object Traceback (innermost last): File "d:\inetpub\scripts\news\news.py", line 252, in ? PrintHeader(form) File "d:\inetpub\scripts\news\news.py", line 234, in PrintHeader HandleMail(form) File "d:\inetpub\scripts\news\news.py", line 210, in HandleMail print ieweb.Document.Body.innertext File "f:\python\win32com\client\dynamic.py", line 319, in __getattr__ raise pythoncom.com_error, details pywintypes.com_error: (-2147023169, 'The remote procedure call failed and did not execute.', None, None) Again, it works from the python interactive interpreter but does not work in a cgi script under IIS. It doesn't like getting ieweb.Busy either...Also, are there any issues with running the COM interface not specifically as myself or a specific user, but rather IUSR_machinename? Is there any special set-up besides the Script Map key that ties a .py file to python? Thanks, Arad -- Arad Rostampour- arad at fc.hp.com NT Platform and I/O Team Software and System Development Lab Hewlett-Packard Mark Hammond wrote in message ... >I have never seen this before. However, these details really arent enough >to help me diagnose the problem. It is possible to break this down further? > >Mail me if you want help doing this. A good start would be to turn on the >debugging flags at the top of win32com\client\dynamic.py... > >Mark. > >Arad Rostampour wrote in message <802s6a$mj5$1 at web1.cup.hp.com>... >>Hi, >> >>I've been using win32com to access IE and get webpages using: >> >>import win32com.client >>ie = win32com.client.Dispatch("InternetExplorer.Application") >>ie.Navigate("http://www.hp.com") >>... >> >>This works fine from the command line. But, when I try to do this from a >>CGI script under IIS, I get the following error: >> >>File "f:\python\win32com\client\dynamic.py", line 319, in __getattr__ raise >>pythoncom.com_error, details pywintypes.com_error: (-2147467259, >>'Unspecified error', (0, None, None, None, 0, -2147467259), None) Exception >>exceptions.AttributeError: in ignored >> >>Any ideas on how to work around this? > > > From tino at wildenhain.de Mon Nov 1 15:50:22 1999 From: tino at wildenhain.de (Tino Wildenhain) Date: Mon, 01 Nov 1999 21:50:22 +0100 Subject: __str__ vs. __repr__ References: <19991101121709.A134039715@vislab.epa.gov> Message-ID: <381DFD0E.26964066@wildenhain.de> Hallo Randell, Randall Hopper wrote: > > 1) Is there a convention for what __str__ and __repr__ should return for > classes? > 2) Or, whatever they return, should they return the same value? > 3) If so, why have both in the language? > > Searching the archives yields an example with odd behavior that > suggests they should generally return the same value: If you test, its oviously (I thin its mentioned somewhere in the docs too) : __str__ represents an human-readable version of the object as string for use with "print" or formatet string ("%s") __repr__ should produce a form that can be cut & pasted to construct the named object. print "Hello" Hello "Hello" 'Hello' see the difference? best regards Tino Wildenhain From donn at oz.net Thu Nov 25 15:55:37 1999 From: donn at oz.net (Donn Cave) Date: 25 Nov 1999 20:55:37 GMT Subject: threading and timeouts References: <943504970.076.346131773@cs.usyd.edu.au> Message-ID: <81k7o9$n4m$0@216.39.151.169> Quoth Piers Lauder : | Are timeouts possible inside threads? | | Eg: escaping from an attempt to use smtplib.SMTP().sendmail() inside a | child thread if the remote host is being extremely slow. | | It doesn't seem possible to use the traditional signal(SIG_ALRM,...) | approach because signals only work inside the main thread. | | The only option I can think of is to re-write the smtplib module to use | `select', but does anyone know of a simpler solution? Note that the select option gets even more complicated if it's going to time out the connect as well as the actual SMTP I/O. To my vague recollection this requires a non-blocking socket, don't think I have ever done it myself but have seen it discussed here. Maybe you could use two threads, the first just to start the second which does all the work. Meanwhile the first can "join" the thread with a timeout, and if it hits the timeout it can do something (like close the socket) that will insure the death of the work thread. That last part sounds very OS-dependent to me. Hope I'm not too confused over the threading API, haven't had any opportunity to use it yet since the threads in my programs come out of the OS itself. But I guess I have to solve this same SMTP timeout problem myself, now that you mention it. Donn Cave, donn at oz.net From jeremy at cnri.reston.va.us Thu Nov 11 11:51:46 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Thu, 11 Nov 1999 11:51:46 -0500 (EST) Subject: method overriding trick Message-ID: <14378.62498.649973.150075@bitdiddle.cnri.reston.va.us> Overriding methods of a base class is a little clunky in Python. You need to explicitly name the base class that implements the method, and you call its as an unbound method, passing self as the first argument. Example: Base.aMethod(self, arg) I was reading about MzScheme the other day (a Scheme variant with object and interface support), and noticed that the MzScheme approach translates well to Python. MzScheme class defintions allow a rename declarations that create a name in the class being defined that is bound to a name in a superclass. In Python, rename is just called assignment. class Base: def aMethod(self, arg): return arg * 2 class Derived1(Base): super_aMethod = Base.aMethod def aMethod(self, arg): return self.super_aMethod(arg) + 1 I haven't seen this strategy for overriding mentioned before, although I did not search the list archives. When I described it to Guido, he said, "Does that work?" Has anyone used this trick before? It doesn't solve the must-name-the-base-class problem, but it helps manage it better. If you keep the override assignments at the top of the class statement, then you only have one place to look in each class when the inheritance hierarchy changes. Jeremy From andres at corrada.com Sun Nov 21 01:33:23 1999 From: andres at corrada.com (Andres Corrada) Date: Sun, 21 Nov 1999 01:33:23 -0500 Subject: Order of keyword arguments Message-ID: <38379233.ADE65CDB@corrada.com> Hi, Can one access the order in which keyword arguments were passed to a function? I want to call a function with the keyword syntax: f( foo='theFooString', bar='theBarString' ) and use the fact that foo was listed first so I can do something like: def f( **kw ): Process keyword arguments remembering the order in which the were used to call the function. Print first keyword Print second keyword . . . ------------------------------------------------------ Andres Corrada-Emmanuel Email: andres at corrada.com Owner http://www.corrada.com/mamey Mamey Phone: (413) 587-9595 ------------------------------------------------------ From psoares at consiste.pt Wed Nov 10 12:01:15 1999 From: psoares at consiste.pt (Paulo Soares) Date: Wed, 10 Nov 1999 17:01:15 -0000 Subject: Syntax colouring in WinEdit? Message-ID: <51998F46F8B7D011BF7C0060B03502AD2F353E@orion.consiste.pt> I ended up doing my own colour file. Put the following text in a file named winedit\system\syntax\py.clr and then associate the extension py with it and the character '#' as a comment. It doesn't work with strings of the type '''. ***Start of py.clr*** [COLORS] ;Colors for Keywords (=1, Quoted Strings, Comments ;Default test and backgrond defined in syntax coloring dialog ;Additional colors defined here [KEYWORDS] and=1 assert=1 break=1 class=1 continue=1 def=1 del=1 elif=1 else=1 except=1 exec=1 finally=1 for=1 from=1 global=1 if=1 import=1 in=1 is=1 lambda=1 not=1 or=1 pass=1 print=1 raise=1 return=1 try=1 while=1 Best Regards, Paulo Soares > -----Original Message----- > From: Paulo Soares > Sent: Wednesday, November 10, 1999 11:56 > To: python-list at python.org > Subject: Syntax colouring in WinEdit? > > Does anyone has something to do python syntax colouring in WinEdit? > > Best Regards, > Paulo Soares > > -- > http://www.python.org/mailman/listinfo/python-list From donn at oz.net Sat Nov 6 15:14:11 1999 From: donn at oz.net (Donn Cave) Date: 6 Nov 1999 20:14:11 GMT Subject: __str__ vs. __repr__ References: <3823E65E.D9E49CC6@python.net> <000001bf275c$02370d20$1d2d153f@tim> <7vvni7$19q0$1@nntp6.u.washington.edu> Message-ID: <80226j$nvq$0@216.39.151.169> Quoth "Thomas A. Bryan" : ... | The problem is that this thread is the first time many of us have | ever thought about the problem. I've never noticed those two lines | in the library reference, and I haven't seen the str/repr distinction | clearly made anywhere else. Furthermore, since the interactive i | nterpreter *does* use repr(), many of us make __repr__ return the | human readable form so that we can easily test our classes. | | So, what I'm hearing is: | 1. __str__ *should* be a human readable string | 2. __repr__ *should* be a representation that can be eval'd back to the | original object | 3. This convention is not widely known, but | 3b. the interactive interpreter discourages the convention by using | repr to show the result of an expression One of the problems here is that there are not two types of string representations, but at least three. 1. Human readable representation of object. Interpreter should display this in interactive use, for example. 2. Machine readable representation of object, for eval. 3. Machine readable object qua string - intentionally, not the object's faithful representation, but what it would be if it had been a string. What the author of rfc822.Message.__str__ appears to have had in mind, for example. I don't see how any two of these three can be made compatible enough to comfortably use the same implementation. When usage parted with documented intentions, it probably wasn't just a lot of people failing to read the documentation. There's a fundamental need for a machine __str__ that's different from a machine __repr__, and the machine __str__ is worse for general display purpose if it's intentionally inaccurate. Now I'm arguing that one reason many of us have never considered this issue is that the current implementation is the best resolution of these conflicts. It's not completely OK, there is dissatisfaction because people wish for the eval-able repr, but if we change course in favor of the documented behavior, it's going to pinch somewhere else. We already have a glimpse of this in the special cases that would apparently be necessary. A string's str is of course itself - string qua string - and its repr adds quotes, and that works out fine the way we do things now. Change the context in which these are used - like make str(container) use str() for contents - and you realize that the repr was really a lot more friendly for some objects, like strings. I'm saying this is not just a quirk of strings, it's because a string is computable data and that's what we do use str() for. Wouldn't it be great if that eval-able string could be shifted to another function? Then if you exercised that function, you could be more or less sure to really get something the author intended to eval with a sensible result. Or you get an AttributeError. Not a string that may or may not eval, when you get around to trying it. Donn Cave, donn at u.washington.edu From gmcm at hypernet.com Fri Nov 5 12:57:07 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Fri, 5 Nov 1999 12:57:07 -0500 Subject: Problems Building Python under Cygwin In-Reply-To: <7vtath$n1j$1@nnrp1.deja.com> Message-ID: <1270297874-731799@hypernet.com> salvadorej at my-deja.com wrote: > I'm having some problems building Python under Cygwin on Windows > NT 4. > 2) the second problem I haven't solved. What I really wanted > Python for was to build Zope from scratch. When I went to build > Zope, it informed me that I needed not the "vanilla" version of > Python, but Python compiled with thread support. OK. I go back, > make clean, and try configure --with-threads. And partway through > the make, I get this: > > cd Modules ; make OPT="-g -O2" VERSION="1.5" \ > prefix="/usr/local" exec_prefix="/usr/local" all > gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c > ./threadmodule.c ./threadmodule.c:38: #error "Error! The rest > of Python is not compiled with thread support." > ./threadmodule.c:39: #error "Rerun configure, adding a > --with-thread > option." > ./threadmodule.c:40: #error "Then run `make clean' followed by > `make'." make[1]: *** [threadmodule.o] Error 1 make: *** > [Modules] Error 2 Without looking into it too deeply, you've got 2 potential problems here. First is that (as of earlier this year, at least) you could do multithreaded with mingw32 but not with cygwin32. If that's been fixed, then possibly configure is not detecting things right. You could try editing the generated config.h and just #define WITH_THREAD. - Gordon From gmcm at hypernet.com Wed Nov 24 08:05:24 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 24 Nov 1999 08:05:24 -0500 Subject: Python complaints In-Reply-To: <867lj85g4c.fsf@g.local> Message-ID: <1268673769-3409210@hypernet.com> Gareth McCaughan says (among other things): > Mark Carroll wrote: > > > Basically, I'd be really interested to learn: what _don't_ > > people like about Python? > > - if/then/else works on *statements* (strictly, suites of > statements) rather than on *expressions*, so I can't > say > print "You scored %s point%s" % (score, if score==1 then "" > else "s") > or anything like that. (Or, as some people prefer to put it, > Python has no ? : operator.) >>> def p(score): ... print "You scored %d point%s" % (score, score==1 and ' ' or 's') ... >>> p(1) You scored 1 point >>> p(3) You scored 3 points >>> - Gordon From tjs at longford.cs.monash.edu.au Wed Nov 24 22:10:28 1999 From: tjs at longford.cs.monash.edu.au (Toby J Sargeant) Date: Thu, 25 Nov 1999 14:10:28 +1100 Subject: Python complaints In-Reply-To: <383D1AA2.35E8F0EC@compaq.com>; from Greg Ewing on Fri, Nov 26, 1999 at 12:16:50AM +1300 References: <000601bf36be$f1bf5e80$292d153f@tim> <383D1AA2.35E8F0EC@compaq.com> Message-ID: <19991125141028.G17130@longford.cs.monash.edu.au> On Fri, Nov 26, 1999 at 12:16:50AM +1300, Greg Ewing wrote: > Tim Peters wrote: > > > > mutex.acquire() > > do stuff > > mutex.release() > > > > is a syntax error in Python. > > What's *really* needed here is a way to abstract these kinds > of constructs. In Scheme I would arrange things so that I > could write > > (with-mutex-acquired mutex > some > stuff) > > or in Smalltalk > > mutex do: [ > some > stuff > ] Just throwing this up in the air, and seeing what comes back... class Acquire: def __init__(self,lock): self.lock=lock lock.acquire() def __del__(self): self.lock.release() def function(mutex): _a=Acquire(mutex) # do stuff. It relies on Acquire.__del__() being called as soon as _a goes out of scope, but that doesn't seem likely to change for the moment. (Of course doing this in JPython is a recipe for disaster... or at least extreme inefficiency) It also has the advantage that you can exit the function in many ways (including by exception), and the lock will be released regardless. It also makes the whole function a critical section which is not always what's wanted. thoughts? Toby. From arcege at shore.net Thu Nov 4 16:06:14 1999 From: arcege at shore.net (Michael P. Reilly) Date: Thu, 04 Nov 1999 21:06:14 GMT Subject: Curses: Character in bottom right corner References: <19991031170404.A18549@optiplex.palga.uucp> Message-ID: Gerrit Holl wrote: : Hello, : can someone explain me why the following doesn't work: : --- *** --- : #!/usr/bin/python : import curses : def main(stdscr): : maxy, maxx = stdscr.getmaxyx() : stdscr.addstr(maxy-1, maxx-1, "s", curses.A_NORMAL) : stdscr.refresh() : if __name__ == '__main__': : import curses, traceback : try: : stdscr=curses.initscr() : curses.noecho() : curses.cbreak() : stdscr.keypad(1) : main(stdscr) # Enter the main loop : stdscr.keypad(0) : curses.echo() : curses.nocbreak() : curses.endwin() # Terminate curses : except: : stdscr.keypad(0) : curses.echo() ; curses.nocbreak() : curses.endwin() : traceback.print_exc() # Print the exception : --- *** --- : I'm getting this error: : 17:05:23:192/693:gerrit at gerrit:~/oefen/python/ncurses$ python test.py : Traceback (innermost last): : File "test.py", line 18, in ? : main(stdscr) # Enter the main loop : File "test.py", line 7, in main : stdscr.addstr(maxy-1, maxx-1, "s", curses.A_NORMAL) : error: [mv]waddstr() returned ERR : It seems that he thinks it falls of the screen, but if I make either x or : y smaller (not both!) it does work, so if I change line 7 to something like : follows, it works. : stdscr.addstr(maxy-2, maxx-1, "s", curses.A_NORMAL) : stdscr.addstr(maxy-1, maxx-2, "s", curses.A_NORMAL) : What am I doing wrong? You aren't really doing anything wrong. It's just that curses doesn't let you write to the last character on the screen for historical (and in some cases, practical) purposes. On many terminals, writing to the last character (right-most, bottom-most) causes the terminal itself to scroll, corrupting what curses has written and what it thinks is being displayed. So even on terminals that allow positioning a character there, curses will not allow it. Try setting stdscr.scrollok(0) before doing anything else. Wishing-he-knew-where-his-curses-book-was-ly yours, -Arcege From fdrake at acm.org Fri Nov 5 17:19:42 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Fri, 5 Nov 1999 17:19:42 -0500 (EST) Subject: IPC8: SouthWest Airlines Internet specials In-Reply-To: <14371.18695.714122.631868@goon.cnri.reston.va.us> References: <14371.14313.700685.807764@goon.cnri.reston.va.us> <14371.16525.555599.961527@dolphin.mojam.com> <14371.18695.714122.631868@goon.cnri.reston.va.us> Message-ID: <14371.22526.178578.870222@weyr.cnri.reston.va.us> Jeremy Hylton writes: > $50-$60. She also mentioned a company called "1-800-BLUE-VAN" that > might offer a shuttle bus to the hotel; she was vague on details, but > it sounds like we have at least a phone number. I think I used them to catch a ride to BWI from Reston for IPC7; the price was $50 from Reston, so it should be cheaper to the conference hotel from BWI. The van was blue, at any rate. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From michael.stroeder at inka.de Fri Nov 12 07:43:55 1999 From: michael.stroeder at inka.de (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Fri, 12 Nov 1999 13:43:55 +0100 Subject: time/strptime/mktime/localtime References: Message-ID: <382C0B8B.DE2DC3A9@inka.de> Oleg Broytmann wrote: > > print time.strptime("1999-09-21 21:44:33", "%Y-%m-%d %T") > > Linux: (1999, 9, 21, 21, 44, 33, 6, 1, 0) > Solaris: (1999, 9, 21, 21, 44, 33, 6, 1, 0) A couple of weeks ago I found some oddities with strptime on my glibc-based Linux system. Someone told me that strptime in glibc is broken. Ciao, Michael. From nascheme at enme.ucalgary.ca Tue Nov 30 00:13:40 1999 From: nascheme at enme.ucalgary.ca (Neil Schemenauer) Date: Tue, 30 Nov 1999 05:13:40 GMT Subject: '==' vs. 'is' behavior References: <382C2C6A.64A8F2C2@theriver.com> <14380.12036.197083.409565@weyr.cnri.reston.va.us> <8E7F86267duncanrcpcouk@news.rmplc.co.uk> Message-ID: Fran?ois Pinard wrote: > >By the way, is there common wisdom (or rather, maybe, usage-standards-to-be) >about using `is' instead of `=='? `is' will always return 0 if == returns 0 (ie. it is a finer distinction). `is' is slightly faster in some cases. The only places I use `is' is when testing if instances of objects are the same and when testing for None. To me, `is' means that something is the same object. Using `is' interchangably with == is asking for trouble. It works most of the time (just enough to screw you) due to implementation details (interning of strings, caching of small integers, etc.). >>> a = 'a' >>> b = 'a' >>> a is b 1 >>> b = raw_input() b >>> b 'b' >>> a is b 0 Your lucky you don't do Lisp. In scheme (r5rs) there is: eqv? eq? equal? and in Common Lisp: eq eql equal equalp = char= Python is absolute simplicity is comparison. Neil -- python -c "f=lambda n:n and f(n/128)+chr(n%128) or '';print f(0x13b2\ e9d8829e3d1976e5dd87ae5e481e6ec3cf1e8cbb72c0eb8f0eccf879795d8f0bel)" From tbryan at python.net Mon Nov 8 22:02:07 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Mon, 08 Nov 1999 22:02:07 -0500 Subject: build failure for SunOS 5.5 References: <38269571.14471A7D@lag.ensieg.inpg.fr> Message-ID: <38278EAF.1C6055E2@python.net> Matija Exel wrote: > > hello, > > is there a way to build Python for SunOS 5.5? Here are my attempts > on a SPARCstation20 platform: Yes. I built it at least once with no problems. The box had a lot of other GNU tools available to it, but you definitely shouldn't be getting errors for symbols such as chown on SunOS 5.5. I think that I built it with gcc, but I thought that Sun's cc was supposed to work. Those sound like pretty severe messages in the configure.log. Did ./configure run to completion without error? Can you tell which portion of the configure script generates the error messages? You could always try a make clobber and start over. ---Tom From gmcm at hypernet.com Tue Nov 16 15:12:56 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 16 Nov 1999 15:12:56 -0500 Subject: README: Python-URL! - the weekly guide to Python resources (Nov 16) Message-ID: <1269339321-9862524@hypernet.com> Python-URL! - the (approximately) weekly digest of news and snippets from the Python community. For the CORBA-inclined, there was some great news out of AT&T Labs, Cambridge: In http://www.deja.com/getdoc.xp?AN=546873219 Duncan Grisby announced omniORB, a free C++ ORB conforming to the OMG's (draft) Python mappings. http://www.uk.research.att.com/omniORB/omniORBpy/ Robin Dunn announces release 2.1.11 of wxPython, a wrapper for the full-featured and snappy cross-platform GUI wxWindows. http://www.deja.com/getdoc.xp?AN=549145965 http://alldunn.com/wxPython/ In a series of mysterious and understated messages (like http://www.deja.com/getdoc.xp?AN=548355817), an awesome new compendium of Python resource links is divulged: http://www.vex.net/~x/parnassus/. The highly dynamic author and maintainer can be referred to as "Tim Middleton", for those who are old-fashioned about that sort of thing. Jeffrey Kunce shares his configuration for doing a shared NT network installation of python: http://www.deja.com/getdoc.xp?AN=547109447 http://starship.python.net/crew/jjkunce/ There were a couple messages on Python in the big time: Paul Everitt in http://www.deja.com/getdoc.xp?AN=546857881 points us to an article about the merger of eGroups and Onelist: http://www.thestandard.com/articles/display/0,1449,7543,00.ht ml While Fredrik in http://www.deja.com/getdoc.xp?AN=546861601 points to an article on Searchbutton.com http://cnbc.com/commentary/commentary_full_story_stocks.a sp?StoryID=6926 Speaking of big-time, Skip Montanaro talks about the configuration of one high volume Python-powered website: his own Musi-Cal site: http://www.deja.com/getdoc.xp?AN=546536571 Finally, from the "what-the?" dept., the eff-bot comments on Latin-1 and other strange characters in Python: http://www.deja.com/getdoc.xp?AN=546828364 ============================================= Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the center of Pythonia http://www.python.org 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 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=AL L&format=threaded&showsort=date&maxhits=100&groups=co mp.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/ 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 http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From fdrake at acm.org Thu Nov 4 17:03:42 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 4 Nov 1999 17:03:42 -0500 (EST) Subject: C-Python tutorial? In-Reply-To: References: <19991101203120.A29797@optiplex.palga.uucp> Message-ID: <14370.702.155351.996170@weyr.cnri.reston.va.us> Michael P. Reilly writes: > The first two are on the Python website and the last is at: > http://starship.python.net/~arcege/extwriting/pyext.html > > When I get some more time here at my new job, I'll flesh this doc out, > get it formatted and sent off to Fred. I look forward to getting this when you get to it! You can even send it as plain text if you don't want to do the LaTeX markup yourself. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From ivanlan at callware.com Thu Nov 11 16:51:15 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Thu, 11 Nov 1999 14:51:15 -0700 Subject: Beginning programming with Python References: Message-ID: <382B3A53.5816B2@callware.com> Hi All-- Aaron Ginn wrote: > > Hello all, > > I'm starting a non-profit organization dedicated to promoting computer > literacy in low-income youth (ages 12-18). An admirable goal indeed. I will be interested in hearing how well this works. Are you affiliating yourself with any municipal, civic or religious organizations? > The curriculum will > include an introduction to programming using either Python or Perl. > > First, I know Perl very well, but I know nothing about Python. I've > heard from many sources that Python is the best language to teach > someone with no programming experience because it emphasizes > fundamentals and the correct (i.e. best) way to program. Could anyone > comment on how the two languages compare in this aspect? Also, I will > need to learn Python as well if I choose to go that route. I am very > literate with Perl and Tcl/TK. How quickly can I expect to pick up > Python? > *Extremely* quickly. In fact, if you'd started yesterday you wouldn't need to ask this question. > Secondly, if I choose to use Python for this, I would like to supply > each student with a reference book on Python. I've narrowed it down > to a choice between the two O'Reilly books, "Programming Python" and > "Learning Python". PP apears to have a lot more meat to it, but LP > appears to be more suited to the beginner. Assuming the audience > includes kids that have never programmed before, should I go with LP, > or will I miss out on anything by not getting the more detailed book? > Of the two books mentioned, yes, _Learning Python_ would be the better choice. However, if you can wait, _Teach Yourself Python in 24 Hours_ is aimed *specifically* at people who have never programmed before. It covers: 1) Introduction to programming (*rock-bottom* fundamentals--what's a variable? What's a for loop?) 2) Introduction to Object-oriented programming 3) Introduction to Tkinter The three parts have 8 chapters each. TYPython will be out early next year. When is your course starting? Where is Chandler?-) PP is very thorough, but needs a new edition. LP is aimed at people who do have some idea of how to program, and is a gentle way to further your programming skills. Both books are funny and interesting, too. TYPython is for total newbies; I can't speak to either funny or interesting (modesty overwhelms me), but I try to get their attention. None of these three books is a *reference*, however. If you really want a reference, then you're better off with Dave Beazley's _Python: Essential Reference_. But you need to know Python before you can make use of it. Hope this helps, -ly y'rs, Ivan -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours ---------------------------------------------- From wtanksle at hawking.armored.net Tue Nov 9 16:50:01 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 9 Nov 1999 21:50:01 GMT Subject: What are Aspects? (Re: How can I make my assertions smarter?) References: <7vvq63$ehm$1@nntp4.atl.mindspring.net> <3826C32A.FB47EF6@compaq.com> Message-ID: On Tue, 09 Nov 1999 01:33:46 +1300, Greg Ewing wrote: >Aahz Maruch wrote: >> Sounds like templates to me, or Python's "mix-in" classes. Am I missing >> something? >It seems like you can apply these things after the fact to >already-written classes. To do the same with templates or >mixins you would have to modify the existing code. That's the secondary idea -- you can drop an 'aspect' class into an app and just have it work. This is good for Debugging, Logging, Testing, or Optimization aspects -- the code should work both with and without them, and it should be possible to add them without disturbing the originals. The _primary_ idea, though, is that aspects can contain functionality which classes simply can't. In order to implement reference counting with classes, for example, you have to modify tons of source code by hand, all in seperate classes. If you use aspects, though, you can start with code which has _no_ memory management, and write a single aspect which describes reference counting, and have most of your memory management problems solved. (A second aspect might help with cycles, and yet another aspect to handle some memory management staticly, since in some cases it's easy.) >It's an interesting idea, but something about code which >can reach out and affect the behaviour of widely scattered >parts of the program, in ways the authors of those parts >didn't anticipate, makes me uneasy. Smacks of the legendary >come-from statement, somehow... You mean like overriding a method in a subclass? (Exactly.) Or since gotos are harmful, we shouldn't use any loops, because they're implemented using gotos. I agree with your hesitation -- AOP isn't proven yet, and right now AspectJ looks like a limited semantic-based preprocessor more than a language (still a nice thing to have!). However, none of the arguments you cite stand on their own; you need to back them up, or some smartmouth will come up with parallel arguments to known-useful technologies. ;-) I'm pretty impressed with aspects, especially since they're so easy to understand. But I see a good case for holding off on depending on them. >Greg -- -William "Billy" Tanksley From cthuang at interlog.com Tue Nov 9 09:25:35 1999 From: cthuang at interlog.com (Chin Huang) Date: 9 Nov 1999 09:25:35 -0500 Subject: win32com and IIS? References: <802s6a$mj5$1@web1.cup.hp.com> <803e2a$dul$1@web1.cup.hp.com> Message-ID: <809asv$7nq@shell1.interlog.com> In article <803e2a$dul$1 at web1.cup.hp.com>, Arad Rostampour wrote: >Again, it works from the python interactive interpreter but does not work in >a cgi script under IIS. It doesn't like getting ieweb.Busy either...Also, >are there any issues with running the COM interface not specifically as >myself or a specific user, but rather IUSR_machinename? Yes, there are issues with permissions when accessing COM objects from ISAPI extensions. Look at http://support.microsoft.com/support/kb/articles/Q156/2/23.asp From haskin at ptway.com Tue Nov 9 16:01:05 1999 From: haskin at ptway.com (Brian Haskin) Date: Tue, 09 Nov 1999 16:01:05 -0500 Subject: Stackless python progress? References: <38274626.5D8C1EC2@ptway.com> <38281b64.88310413@news.oh.verio.com> Message-ID: <38288B91.636DCE65@ptway.com> Take a look at http://www.pns.cc/stackless/stackless.htm This has an explanation of what it is and also some of the advantages. Brian Haskin Kevin Dahlhausen wrote: > > I must confess I don't know this, but what is the advantage of stackless Python? > Are you referring to the byte-code interpreter? > [snip] From mwh21 at cam.ac.uk Wed Nov 3 14:21:33 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 03 Nov 1999 19:21:33 +0000 Subject: SWIG and function name question References: <7vmc7e$8h$1@marcie.fissiontech.com> Message-ID: kain at twilight. (Scott Barron) writes: > Hey folks, > > I downloaded and started to learn SWIG today and I ran into a little problem. > In the C code there is a structure like this: > > struct __foo { ... }; > > When I import my SWIG created module using 'import mymodule' I have access > to the struct's set/get operation via mymodule.__foo_set_member() but if I > import my module using 'from mymodule import *' I have access to all of my > modules functions accept the two get/set functions that begin with __ > (I'm using dir() to check this). This isn't too much of a problem for me > but I'm just wondering what's going on. Can anyone clear this up for me? It's nothing to do with SWIG; try this for size: put this in a file called foo.py on your PYTHONPATH: def nowyouseeme(): return "hi!" def _nowyoudont(): return "oi!" then: >>> from foo import * >>> nowyouseeme() 'hi!' >>> _nowyoudont() Traceback (innermost last): File "", line 1, in ? NameError: _nowyoudont >>> import foo >>> foo.nowyouseeme() 'hi!' >>> foo._nowyoudont() 'oi!' Y'see, identifiers starting with `_' are considered (to some extent) module private and are *not* imported when you use the "import *" style. There's a simple answer: don't use the "import *" style. Ever. That's a bit harsh, but the only exceptions I make are for modules that are written with that in mine, eg. Tkinter. Also it can be handy in interactive mode, but I still tend to avoid it there. readline rules! HTH, Michael O, look: http://www.python.org/doc/current/ref/import.html has all the gory details... From mcfletch at vrtelecom.com Tue Nov 30 05:56:10 1999 From: mcfletch at vrtelecom.com (Mike Fletcher) Date: Tue, 30 Nov 1999 05:56:10 -0500 Subject: Python bugs In-Reply-To: <001301bf3b15$b391c4d0$3acbd9c2@peridot.optichrome.com> Message-ID: I have build structures that are very much like that discussed. For some classes of application they are quite useful. Adding an object to the ObjectStore merely marks it as "to be stored" when the ObjectStore is committed and adds it to the identity cache (though a write-through flag can override that, causing immediate committing of that item). When the ObjectStore is committed or destroyed it writes the current values of all active (cached) objects to disk. When an attempt is made to access a variable, it is either read from the identity cache or loaded directly. Although not as elegant as some caching schemes, it's not a truly abysmal solution :) . Unfortunately, that code is not mine to release, so I can't demonstrate the value :-/ . Enjoy, Mike -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Adrian Eyre Sent: November 30, 1999 4:32 AM To: Skip Montanaro Cc: python-list at python.org Subject: RE: Python bugs > >>> s = shelve.open("foo") > >>> l = [] > >>> s["bar"] = l > >>> s["bar"] > [] > >>> l.append("baz") > >>> s["bar"] > [] > > I think you're asking for magic that really can't happen (at least not > easily). ... From phd at phd.russ.ru Fri Nov 12 06:01:20 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Fri, 12 Nov 1999 11:01:20 +0000 (GMT) Subject: time/strptime/mktime/localtime In-Reply-To: <382BE48D.89CD174B@lemburg.com> Message-ID: Hi! Thanks for replying. On Fri, 12 Nov 1999, M.-A. Lemburg wrote: > > The following program prints "1999-09-21 21:44:33" on Linux and > > "1999-09-21 22:44:33" on Solaris (1 hour offset). > > > > Is it a problem with my config? libs? python? Timezone is Europe/Moscow, > > set (I think) correctly on both systems. > > > > #! /usr/local/bin/python -O > > > > import time > > > > t = time.strptime("1999-09-21 21:44:33", "%Y-%m-%d %T") > > m = time.mktime(t) > > print time.strftime("%Y-%m-%d %T", time.localtime(m)) > > Could be that one of those sets the DST flag to 0 while > the other sets it to 1... please provide the output of > time.strptime() for both machines. print time.strptime("1999-09-21 21:44:33", "%Y-%m-%d %T") Linux: (1999, 9, 21, 21, 44, 33, 6, 1, 0) Solaris: (1999, 9, 21, 21, 44, 33, 6, 1, 0) No difference. Anyway, I think you are near to be right, as I found there are some dates that converted back and forth correctly, without 1 hour offset. t = time.strptime("1999-10-31 14:50:16", "%Y-%m-%d %T") m = time.mktime(t) print time.strftime("%Y-%m-%d %T", time.localtime(m)) prints "1999-10-31 14:50:16", what is Ok... Seems the error is relative to DST. May be I have incorrect timezone definition on Solaris... Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From tismer at appliedbiometrics.com Thu Nov 11 16:05:02 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Thu, 11 Nov 1999 22:05:02 +0100 Subject: ASCII delimited files References: <942231502.1914033961@news.interbusiness.it> <80ekhb$1qrh$1@hub.org> <80et0b$2df8$1@hub.org> Message-ID: <382B2F7E.78642C70@appliedbiometrics.com> "D'Arcy J.M. Cain" wrote: > > D'Arcy J.M. Cain wrote: > > I couldn't find this on the Python or Starship sites but you can get it > > from http://www.deja.com/getdoc.xp?AN=448769706. One small problem with > > it is that it doesn't handle commas within quoted strings properly. I > > am going to look at this today for another project and I will post it > > here when I have something. > > And here it is. Note that Christian Tismer wrote the original (at least > he posted it) but didn't leave his name in the script itself. I didn't > want to add it in since he may have had his reasons but I wanted to > acknowledge that he wrote it. Thanks for mentioning. FWIW, my name is of course in it (and is still), maybe not too obvious :-) Whem I'm posting code without any authors mentioned, then I'm always the author. I used to forget to name myself, but never other's work. > #! /usr/bin/env python > # delimited.py > # Modified from the original by D'Arcy J.M. Cain > # > # CT990226 V0.1 This says Christian Tismer wrote this crap on February 26, 1999. Ahem, well I have to change these to be Y2K compliant! :-) ciao - CT -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From mikael at isy.liu.se Wed Nov 24 05:32:21 1999 From: mikael at isy.liu.se (Mikael Olofsson) Date: Wed, 24 Nov 1999 11:32:21 +0100 (MET) Subject: Python complaints In-Reply-To: <81g8po$reo$1@mach.vub.ac.be> Message-ID: On 24-Nov-99 Thomas Hamelryck wrote: > Block delimitation by indenting. This makes python look like a porsche with > a caravan attached :-). As far as I know, most python users even seem to > like this for some reason. I am one of those who appreciates this. My reason is the following: I prefer to write readable, understandable code. To me, that means (among other things) indenting blocks. Hence, I already indent blocks in every programming language, if the language allows me to. So, block delimiters like begin...end or {} are simply redundant to me. AFAIK, I have not yet stumbled over a programming language that doesn't allow me to indent, and I would certainly avoid such a language. Block delimiting by indenting is actually a strong reason for me to use python. Someone once said: "Real programmers don't comment their code. If it was hard to write, it should be hard to read." I-guess-I'm-not-a-real-programmer-ly y'rs /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: 24-Nov-99 Time: 11:15:28 This message was sent by XF-Mail. ----------------------------------------------------------------------- From ivanlan at callware.com Fri Nov 5 12:24:14 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Fri, 05 Nov 1999 10:24:14 -0700 Subject: Dave Beazley's Book Message-ID: <382312BE.3913670B@callware.com> Hi All-- I just received my copies of Dave Beazley's _Python Essential Reference_. Knowing Dave, I knew it would be good. It's better than that, and New Riders has produced an extremely nice package. Even my wife admired it (the physical book, not the Pythonic content), and she usually reserves her admiration for books from Yale, Harvard or (some) Knopf. I wish I'd had this book when I _started_ on TYPython. -ly y'rs, Ivan;-) ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From phd at phd.russ.ru Fri Nov 12 10:28:48 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Fri, 12 Nov 1999 15:28:48 +0000 (GMT) Subject: '==' vs. 'is' behavior In-Reply-To: <382C2C6A.64A8F2C2@theriver.com> Message-ID: On Fri, 12 Nov 1999, Andy Fox wrote: > >>> a is b #are they the same object? yes. Why? > 1 > > Further experimentation shows that this seems to work for integers > through 99, but that starting with 100 the results of the 'is' test > return 0, as I would expect. I believe intergers 0 through 99 are preallocated by Python interpreter to speed up common things like "x = y + 12". Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From nascheme at enme.ucalgary.ca Tue Nov 30 03:14:36 1999 From: nascheme at enme.ucalgary.ca (Neil Schemenauer) Date: Tue, 30 Nov 1999 08:14:36 GMT Subject: performance of tuple-less Python? References: <1268226961-30285235@hypernet.com> <943917954snz@vision25.demon.co.uk> Message-ID: Phil Hunt wrote: >In article <1268226961-30285235 at hypernet.com> > gmcm at hypernet.com "Gordon McMillan" writes: >> They're only redundant if the concept of mutability is >> meaningless. A reference-based language without a concept >> of mutability would be, um, an adventure. > >Why? Some values should be immutable. Consider if integers in Python were mutable. You store a reference to 1 and somewhere else the value of 1 is changed to 2. Is that not a problem? Also, you can not (efficiently) implement hash tables. Maybe you mean that mutability is not required. That would be an interesting language. How to you accomplish anything? Sometimes you want mutability and sometimes you don't. That is why both tuples and lists exist. BTW, my example about changing the value of None is not really the same thing. I re-bound the global variable None to a new value. That is not the same as modifying the value of None. Neil From akuchlin at mems-exchange.org Sat Nov 13 14:25:04 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 13 Nov 1999 14:25:04 -0500 Subject: Production Web Deployment? References: <3826C69F.B4E26B89@digicool.com> <14379.18122.156471.644349@ghost.bbn.com> <382D68D3.46CEFD61@digicool.com> Message-ID: <3d4seqp52n.fsf@amarok.cnri.reston.va.us> Paul Everitt writes: > FastCGI gives us a three-year-old Apache module, plus commercial and > supported versions for Netscape and IIS (and Apache). Additionally, > FastCGI has support for TCP sockets in addition to domain sockets, which > helps deal with file permission errors when configuring it. Indeed. For this reason I'm not planning to go farther with mod_pcgi; it works as a proof-of-concept, but the FastCGI approach lets me^H^H us benefit from the work of others and not have do all the work. >The major reason we ditched FastCGI and came up with PCGI in the first >place (lack of threading in the library meant a person could telnet into >your application and lock the app) is no longer pertinent with the new >Zope2 architecture. This has us hoping to get FastCGI back in as a So, does this mean that if I use the FCGIPublisher, I can have multiple threads in Zope at the same time, without having to run ZServer? Good news, if so... -- A.M. Kuchling http://starship.python.net/crew/amk/ All the evils of publishing can be traced to one source -- copyright. -- Stefan Stykolt, quoted by Kildare Dobbs in _The Living Name_ (1964) From dorland at lords.com Tue Nov 2 22:39:27 1999 From: dorland at lords.com (Eric Dorland) Date: Wed, 03 Nov 1999 03:39:27 GMT Subject: Exceptions from callbacks References: <381CA8E5.5D69E64@lords.com> <7virj4$b7b$1@towncrier.cc.monash.edu.au> Message-ID: <381FAE6D.73F426FE@lords.com> Jonathan Giddy wrote: > > Eric Dorland writes: > > >I'm writing a Python wrapper for a library. The library stores some > >callbacks for some events, and with some glue code, get these to call > >python functions. That's the easy part. Now since its the library these > >callback and not Python per se, how do you pass an exception back to the > >interpreter, because you can't return NULL from the callback. Do you > >just set the exception, and Python will pick up on it? > > Assuming these are synchronous callbacks from within the one thread (Python > code calls C interface calls library calls C callback calls Python callback), > you can call PyErr_Clear() before calling the library routine, then return > if PyErr_Occurred() is true afterwards, return NULL from the C interface. > See the Python/C API manual, section 1.3 "Exceptions". > > If they happen to be asynchronous callbacks from threads started by the > library, the simplest solution is to ignore them, maybe calling > PyErr_PrintEx(0) to warn the user. You're not understanding exactly. It is synchronous (ie one thread), but since the library is calling the callback, and not the python interpreter, I can't return NULL to the interpreter. Basically, is there a way from inside the callback to say "Wake up python, an exception!", without having to return NULL to the interpreter, which is impossible from the callback. -- Eric Dorland dorland at lords.com From m.faassen at vet.uu.nl Mon Nov 8 12:54:14 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 8 Nov 1999 17:54:14 GMT Subject: A Modest Proposal -- References: <99110613580407.02970@quadra.teleo.net> Message-ID: <8072o6$m4i$1@newshost.accu.uu.nl> Patrick Phalen wrote: [snip] > Please consider writing email to the HTML Working Group in support of > this proposal. Okay, done. A copy here: ** Dear HTML Working Group, XML Working Group, It is imperative and essential that you include the tag in your proposals. If not, the Timbot will not be able to produce XHTML compliant output, and the whole Internet will grind to a halt as a consequence. To adopt the tag some minor changes to XML need to be made. The tag affects any _previous_ (not containing) markup. I am proposing a system called XWTSNTSDL (XML Wink Tag Schedule Namespace Transformation Semantic Disruption Language) to deal with this. XWTSNTSDL depends on the two other proposals I sent to you previously: XGNBAML and XACL (XML Grand Name But Actually MeaningLess and XML Acronym Complexification Language). As you can see, XWTSNTSDL is fully consistent with your current proposals. It is therefore expected the major internet browsers will soon be able to support these new standards. Regards, Martijn Faassen, PSU (Python Secret Underground) -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From gmcm at hypernet.com Wed Nov 3 12:11:01 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 3 Nov 1999 12:11:01 -0500 Subject: C++ embeding API? In-Reply-To: <816010E2456BD111A48700805FBBE2EEFDF74D@ex-quebec-u1.baan.com> Message-ID: <1270473441-35788679@hypernet.com> Gaetan Corneau wrote: > > Is anyone working on a high-level C++ embedding API? > I would be interested in that, and could help any ongoing effort > in that direction. I have no experience writing C++ apps with > embedded Python (I'm just beginning to read the doc), but I am an > experienced C++ programmer. There are at least 2 C++ libraries for Python. cxx (from the LLNL download) is a very sophisticated one, my SCXX is a vastly simpler, less complete and lighterweight one (on my starship pages). There may be more - check out the C++ SIG. In both of the above, the emphasis is on making commonly used PyObjects look like C++ objects. As for "embedding" - there is no embedding API. Embedding varies between: Py_Initialize(); PyRun_SimpleString('...'); Py_Finalize(); to highly complex interactions where you're importing modules, creating instances, calling methods etc. cxx covers a great deal more of that, but SCXX doesn't use templates and most of it ends up inline. SCXX-is-probably-also-buggier-ly y'rs - Gordon From robin at alldunn.com Wed Nov 3 01:25:41 1999 From: robin at alldunn.com (Robin Dunn) Date: Tue, 2 Nov 1999 22:25:41 -0800 Subject: Need Berkley DB!! References: <381D5E84.98931682@bibsyst.no> Message-ID: > After I spent most of my weekend trying to get Berkley DB to work with > Python on my Linux ( Suse 6.1) machine, I`ve now given up completly. > I`ve tried to install DB.1.85. and DB.2.7.7, neither worked, either > crashing under installation ( which of course, is not Python > related ) or when I tried to test the installation with the examples in > the documentation ( the wrapper for the 2.7.5-module listed at > www.python.org, under modules, databases ). Have you tried my DB module at http://starship.python.net/crew/robind/ ? Assuming you can get DB 2.7.x built and installed, this module should do what you need. -- Robin Dunn Software Craftsman robin at AllDunn.com http://AllDunn.com/robin/ http://AllDunn.com/wxPython/ Check it out! From nemeth at iqsoft.hu Tue Nov 16 12:34:57 1999 From: nemeth at iqsoft.hu (Nemeth Miklos) Date: Tue, 16 Nov 1999 18:34:57 +0100 Subject: Beginning programming with Python References: <382B3A53.5816B2@callware.com> <382B3D79.74CD3E0F@email.sps.mot.com> <80p9ds$ppo$1@newshost.accu.uu.nl> <38312D55.A36EB56D@iqsoft.hu> Message-ID: <383195C1.826B3342@iqsoft.hu> Janos Blazi wrote: > Dear Nicholas, > > what you say ist speculative. Your theses are not scientific predictions > about nature. It would be very, very difficult to design an experiment that > proves your theses wrong. Therefore from a scientific point of view, they > are neither right nor wrong. Though they contain predictions about nature, > these predictions should be much more carefully and precisely put to be > really scientific. > > You are not saying that big project cannot be done with Python. You are > saying that Python is less well suited for big projects than C. But it is > not easy to atribbute a quantitative meaning to "less well". How do you want > to scale that? You could take the number of man months necessary or you > could try to quantify the quality of you product. Unless you provide us with > these details I can neither confirm nor contradict. I can only check if > there are inner contradictions in what you say. There are none, but that is > not enough. Physics as seen by Aristotle was a wonderful piece of > speculative thinking, without inner contradictions, bu today we know that we > should not overestimate its practical meaning and we better take the > Newtonian point of view. > Excuse me if my problem was not comprehendable. I am really not very strong in presenting points. The only thing I wanted, is to point out a potential shortcoming (if at all) of Python -- I am not sure if the lack of compile-time type safety is really a badly needed feature. I am neither a physicist nor a mathematician, I am a simple business software engineer. I like Python but I'd like to be convinced that Python is not only for scientific programming, but also for business programming. I'd like to know the general opinion of the "official" Python community on this (I think) important topic. I learned from this list ( Fredrik Lundh) not long ago that there is a http://www.chordate.com/kwParsing/index.html so this topic must be hot for the Python community. > > Your second question concerns teaching. > > (1) > I have not tried Python as a language for teaching yet so I have not had any > experience. I should like to use Python first and give a judgement after > using it. > > (2) > I agree with you: If Python were good for nothing else, it would not be good > for teaching either. But in ther first part of your message you only say > that Python is not well suited for large projects (though, as i have tried > to show you, it is not clear, what that statement means). Now you say that > it cannot be used at all. But I have had the experience that Python is nice > for small projects, say below 3000 lines of code. So i am aifraid your > argumentation is vulnerable at this point. > As far as I understood, you are absolutely sure that Python is a perfect language, I have to trust in it without any hesitation? Miklos Nemeth IQSOFT From news at dorb.com Mon Nov 8 07:25:50 1999 From: news at dorb.com (Darrell) Date: Mon, 8 Nov 1999 07:25:50 -0500 Subject: Just a note References: <381D5E84.98931682@bibsyst.no> <381D78C3.9BBECCB0@bibsyst.no> <7vut5l$pgn$1@nnrp1.deja.com> <3826A8E2.D2C557D7@bibsyst.no> Message-ID: I believe Aaron was just throwing out ideas since you requirements are vague. In most cases C++ solution will be faster than pure Python. Sounds like you want a disk based dictionary. I'd be curious how much C++ will buy you in this case. Disk I/O will eat into your gains. If you try this in Python avoid readline(), but there is a fast replacement floating around. My current paradigm is to code it in Python then push the slow stuff into C++. The Python phase can really clarify the problem. I'd like to hear how you solve this. -- --Darrell Thomas Weholt wrote in message news:3826A8E2.D2C557D7 at bibsyst.no... > > Also, please have a look at bplustree.py which > > provides many of the advantages of berkeley db but in a pure python > > implementation. > > And once again the re-occurring question when talking about pure python > implementations of things like these : > > 1. speed ?? > 2. size ?? > > Like I mentioned I`ll be storing huge amounts of data. HUGE !!! Not huge > entries/pickled objects, but many small. It`s my impression that pure > python approaches to problems like this ( I`m thinking of pickle vs. > cPickle) is slow when compared to similar solutions programmed in C/C++. > > Thomas > > > -- > http://www.python.org/mailman/listinfo/python-list From hildeb at www.stahl.bau.tu-bs.de Sat Nov 27 11:34:13 1999 From: hildeb at www.stahl.bau.tu-bs.de (Ralf Hildebrandt) Date: 27 Nov 1999 16:34:13 GMT Subject: fcntl/ioctl and O_NONBLOCK References: <81ml5t$eer$0@216.39.151.169> Message-ID: On 26 Nov 1999 18:57:01 GMT, Donn Cave wrote: >I don't know about the ioctl, but you may not need it after all if >you're already going to use select. Select will tell you if the >I/O would block, if so then don't read. Ah! So a read only block if there's nothing at all to read? >(And you can't read from both ends, "stdin" (i.e., Popen3.tochild) >is opened for write and attempts to read from it will probably be >frustrating.) :) Yup. I read the sockets HOWTO by now, and select() on a file/pipe is more or less the same on unix. From bparsia at email.unc.edu Wed Nov 3 23:26:56 1999 From: bparsia at email.unc.edu (Bijan Parsia) Date: Wed, 3 Nov 1999 23:26:56 -0500 Subject: Comparison between Python and "Ruby" References: <1270663667-24391282@hypernet.com> <381ED7A6.D7D7FB13@compaq.com> <877lk1wiij.fsf@ev.netlab.co.jp> <19991102154543.A4469@optiplex.palga.uucp> <381F9EB4.63FA033F@python.net> <382066F2.D12ECDA2@prescod.net> Message-ID: <1e0pmag.pgoc9kfj8sd1N%bparsia@email.unc.edu> Paul Prescod wrote: > Neel Krishnaswami wrote: > > > > Python (and Ruby, for that matter) remind me more of Smalltalk than > > anything else -- ie, they have extensive libraries, a community with a > > love of elegance but not of purity[*], and a greater focus on practical > > applications than on academic research. > > Isn't the Smalltalk community pretty enamored of purity? I mean "if" is > an object that takes messages, right? > > Paul Prescod Close. Boolean's are objects which take the messages ifTrue:, ifFalse:, ifTrue:ifFalse:, ifFalse:ifTrue:, whileTrue:, etc. All control structures are messages (typically taking blocks--aka anonymous functions arguments): 4 timesRepeat: [self beep]. "This is a message to an Integer." #(1 2 3) do: [:item | Transcript cr; show: item printString]. "do: is sent to the array (the sharp parens is the literal). The block has one parameter, internally know as 'item'). The semi-colon means to send the next message to the same object, i.e., Transcript. Thus Transcript gets two messages, cr and show:." Etc. The only non-message type thing I can think of off-hand is the assignment operator. Well, and the cascade. Cheers, Bijan Parsia. From Gareth.McCaughan at pobox.com Wed Nov 24 17:23:14 1999 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: 24 Nov 1999 22:23:14 +0000 Subject: Python complaints References: <1268673769-3409210@hypernet.com> Message-ID: <86puwz4jhp.fsf@g.local> Gordon McMillan wrote: [I said:] >> - if/then/else works on *statements* (strictly, suites of >> statements) rather than on *expressions*, so I can't >> say >> print "You scored %s point%s" % (score, if score==1 then "" >> else "s") >> or anything like that. (Or, as some people prefer to put it, >> Python has no ? : operator.) > >>>> def p(score): > ... print "You scored %d point%s" % (score, score==1 and ' ' > or 's') > ... >>>> p(1) > You scored 1 point >>>> p(3) > You scored 3 points >>>> Yes. Unfortunately, as we all know, this doesn't work when it's (say) 1 and 0 you're choosing between instead of "s" and ""... -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From aaron.ginn at motorola.com Thu Nov 11 16:12:02 1999 From: aaron.ginn at motorola.com (Aaron Ginn) Date: 11 Nov 1999 14:12:02 -0700 Subject: Beginning programming with Python Message-ID: Hello all, I'm starting a non-profit organization dedicated to promoting computer literacy in low-income youth (ages 12-18). The curriculum will include an introduction to programming using either Python or Perl. First, I know Perl very well, but I know nothing about Python. I've heard from many sources that Python is the best language to teach someone with no programming experience because it emphasizes fundamentals and the correct (i.e. best) way to program. Could anyone comment on how the two languages compare in this aspect? Also, I will need to learn Python as well if I choose to go that route. I am very literate with Perl and Tcl/TK. How quickly can I expect to pick up Python? Secondly, if I choose to use Python for this, I would like to supply each student with a reference book on Python. I've narrowed it down to a choice between the two O'Reilly books, "Programming Python" and "Learning Python". PP apears to have a lot more meat to it, but LP appears to be more suited to the beginner. Assuming the audience includes kids that have never programmed before, should I go with LP, or will I miss out on anything by not getting the more detailed book? Thanks for your time. Aaron Ginn -- Aaron J. Ginn Motorola SPS Phone: (480) 814-4463 SemiCustom Solutions Fax: (480) 814-4058 1300 N. Alma School Rd. mailto:aaron.ginn at motorola.com Chandler, AZ 85226 From skip at mojam.com Mon Nov 29 16:29:04 1999 From: skip at mojam.com (Skip Montanaro) Date: Mon, 29 Nov 1999 15:29:04 -0600 (CST) Subject: Python bugs In-Reply-To: <51C9F3C392D0D111A15600A0C99E64A9AF569C@localhost> References: <51C9F3C392D0D111A15600A0C99E64A9AF569C@localhost> Message-ID: <14402.61472.118271.508744@dolphin.mojam.com> Bjorn> Which is a good thing, but shouldn't preclude it from being used Bjorn> as a dictionary in the update statement (although the fix Bjorn> probably have to be to Dict.update rahter than os.environ). You are correct. It would have to make some assumptions about how to get a dict from an instance object. Should it access the instance's "__dict__" attribute or (in this case) the "data" attribute or try to an "as_dict" method? Since no such well-defined interface currently exists, you're probably better off in the short term simply executing d.update(os.environ.data) Bjorn> Cool (do you know if you can do db.items() also? -- found that Bjorn> one five minutes ago...) I don't see it, and I doubt it's going to get added any time soon. One motivation for using on-disk mappings such as provided by bsddb and (g)dbm is that they can be really huge (hundreds of thousands or millions of keys are not out of the question). Asking for values() or items() in these situations is much more likely to get you into memory trouble than for simple dicts which tend to be smaller. Still, you can have this functionality easily enough: class MyShelf(shelve.Shelf): def values(self): v = [] for k in self.keys(): v.append(self[k]) return v def items(self): i = [] for k in self.keys(): i.append((k, self[k])) return i If your shelve object is really big, figure on getting a cup of coffee while these methods execute, however... Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/ 847-971-7098 | Python: Programming the way Guido indented... From a.eyre at optichrome.com Mon Nov 29 08:50:22 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Mon, 29 Nov 1999 13:50:22 -0000 Subject: PyArg_ParseTuple() and oprtional remaining argument lists In-Reply-To: <38422744.174116386@news.ricochet.net> Message-ID: <000c01bf3a70$ae184ec0$3acbd9c2@peridot.optichrome.com> > I also have trouble using PyArg_ParseTuple(...) with a single item, > e.g. > if (PyArg_Parse(args,"i",&index) && (index >= 0)) { > is ok, but > if (PyArg_ParseTuple(args,"i",&index) && (index >= 0)) { Aha. That's the clue. Make sure that your PyMethodDef struct is like this: static struct PyMethodDef methods[] = { { "method1", method1, 1 }, { "method2", method2, 1 }, { NULL, NULL, 0 } }; Not like this: static struct PyMethodDef methods[] = { { "method1", method1 }, { "method2", method2 }, { NULL, NULL } }; -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From timmuddletin at news.vex.net Mon Nov 29 10:56:51 1999 From: timmuddletin at news.vex.net (tim muddletin) Date: 29 Nov 1999 15:56:51 GMT Subject: XML tool status? References: Message-ID: <81u7o3$15sp$1@hub.org> gvwilson at nevex.com (Greg Wilson) wrote: >1) I can't find a Windows version of the software; and Christian Tismer announced a Win32 installer for the XML-Sig stuff a while back. I don't know why it hasn't been added to the XML-Sig web page. Anyhow, that post is at: http://x44.deja.com/=dnc/getdoc.xp?AN=535449110 The links it gives are-- Executable binary installer: ftp://pns.cc/pub/xml/PythonXML.EXE http://www.pns.cc/anonftp/pub/xml/PythonXML.EXE ( I had been meaning to look this up for a while myself --- so thanks for the excuse to finally do it. (-: ) ... From robin at jessikat.demon.co.uk Thu Nov 4 17:20:19 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Thu, 4 Nov 1999 22:20:19 +0000 Subject: Assorted Questions regarding the future of Python... References: <3822f253.11537059@news.demon.co.uk> <002d01bf270e$238223a0$0501a8c0@bobcat> Message-ID: In article <002d01bf270e$238223a0$0501a8c0 at bobcat>, Mark Hammond writes >[Andy writes:] >> I haven't done any benchmarking myself, but when I installed VB6 I >> didn't exactly leap off my seat at the speed increase. > >And more to the point, VB was (and is), usually, "fast enough". Who >does huge matrix manipulation etc in VB anyway? Lots of the focus the >industry has on speed is a red herring IMO. > >Just like Python itself - really quite "slow" compared to these >natively compiled languages - but in the entire time I have used it, I >have had to use the profiler exactly twice. In every other case, it >has been more than "fast enough" (and the development speed far >outweighs the difference anyway). > >Whats-a-milli-second-between-friends-ly, > >Mark. > > > I did huge matrix multiplications etc. When it came to VBA 64kbytes was the old limit in terms of easy passing to dlls. Has it gone up? -- Robin Becker From emuller at painewebber.com Sat Nov 13 14:06:21 1999 From: emuller at painewebber.com (emuller at painewebber.com) Date: Sat, 13 Nov 1999 19:06:21 GMT Subject: .dll and .exe file version informaton References: <816010E2456BD111A48700805FBBE2EEFDF793@ex-quebec-u1.baan.com> <80ha4a$pmg$1@nnrp1.deja.com> Message-ID: <80kcrb$tml$1@nnrp1.deja.com> I am not a C programmer, but I did come up with a very stupid hack (see below). This hack requires that the executable filever.exe be either in the current path or the current directory. filever.exe is part of the NT Resource Kit. def FileVer(path,file): import win32pipe import string verdata = {} curDir = win32api.GetFullPathName('.') progPath = "FILEVER.EXE" + " /V \"" + win32api.GetFullPathName (path) + "\\" + file + "\"" myPipe = win32pipe.popen(progPath ,'r') verRaw = myPipe.read() # split the raw data into lines.... lines = string.split(verRaw,"\012\011") #There was only basic data, parse that verdata['attributes'] = lines[0][0:5] verdata['Short OS'] = lines[0][6:10] verdata['Short FileType'] = lines[0][11:14] verdata['Short Language'] = lines[0][15:18] verdata['Short Version'] = string.strip(string.strip(lines[0] [19:34])) verdata['Short Mode'] = lines[0][35:38] verdata['Size'] = string.strip(lines[0][39:49]) verdata['Date'] = lines[0][50:60] verdata['Filename'] = string.strip(lines[0][61:]) if len(lines) <> 1: del lines[0] for line in lines: list = string.split(line,"\011") if len(list) == 1: continue else: verdata[list[0]] = string.strip(list[len (list)-1]) return verdata If any one uses this, let me know, if anyone fixes a bug please let me know as well. In article , "Darrell" wrote: > Given the win32 calls it wouldn't be too hard to wrap them up in an > extension module. > > -- > --Darrell > wrote in message > news:80ha4a$pmg$1 at nnrp1.deja.com... > > It looks like they are not available yet.... > > In article <816010E2456BD111A48700805FBBE2EEFDF793 at ex-quebec- > > u1.baan.com>, > > Gaetan Corneau wrote: > > > > go-ahead-just-*try*-to-write-a-program-to-do-that-ly y'rs - > > tim > > > > > > If you really want to do it in a program, take a look at the following > > > functions in the help: > > > GetFileVersionInfo > > > VerQueryValue > > > QueryField > > > > > Sent via Deja.com http://www.deja.com/ Before you buy. From gerrit.holl at pobox.com Sat Nov 27 04:35:04 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Sat, 27 Nov 1999 10:35:04 +0100 Subject: Binary vs non-binary Message-ID: <19991127103504.A1536@stopcontact.palga.uucp> Hello, can someone explain me the difference in opening a file in binary mode and opening it not in binary mode? And when is some file defined to be binary, when it contains an ASCII 0? If so, I understand you need to say it's binary in C, but if Python doesn't store it strings with an ASCII 0 on the end, why is there any difference? regards, Gerrit. -- "The world is beating a path to our door" -- Bruce Perens, (Open Sources, 1999 O'Reilly and Associates) 10:33am up 17 min, 9 users, load average: 1.81, 1.47, 0.79 From cfelling at iae.nl Mon Nov 1 15:33:02 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 1 Nov 1999 21:33:02 +0100 Subject: Contribution: nice floating point number formatting References: <381a4316$0$209@nntp1.ba.best.com> <19991030063317.A16991@better.net> <7vhrfm$glv$1@vvs.superst.iae.nl> <19991101124124.A903@Ridcully.home> Message-ID: <7vktdu$u2$1@vvs.superst.iae.nl> Malcolm Tredinnick wrote: > On Sun, Oct 31, 1999 at 05:41:26PM +0100, Carel Fellinger wrote: >> And for the spaces in the decimal part, are you shure that is conventional? >> I can't remember having seen this *ever* in my life. At least not in my life >> as a programmer. > There is a convention in some situations/places where the comma (or, in > Europe, the dot) is dropped entirely and a thin space is used (if you are > typesetting -- something smaller than a normal inter-word space). now that you mention the size of the space I'm inclined to think that you are right. (I really have a rusty retension that needs to be poked now and again:) It's also quit common these days to use such thin spaces to make phone numbers memorizable. > appear quite frequently. IMVHO, the spaces every three digits look nicer > than throwing a bunch of punctuation marks at the number. :-) I agree, but only if the spaces are trully thin, not that huge blob of white space called a space in teletype (terminal) fonts. -- groetjes, carel From gmcm at hypernet.com Tue Nov 2 16:40:07 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 2 Nov 1999 16:40:07 -0500 Subject: Installer v0.3d - problem with Builder In-Reply-To: <381F0803.6D76E236@netscape.com> Message-ID: <1270543697-31562797@hypernet.com> Michel Orengo writes: > I've tried to use the new beta of installer (simple) but I've got > an Attribute Error at line 109 in 'archmodule.modules' With > installer v0.2 (simple), it works fine. Any idea of what went > wrong? Thanks for your help Looks like you're talking about my stuff, but that's not enough for me to guess at what went wrong. If you cut & paste the traceback, and attach the .log file, I can probably figure it out, (directly to me, of course). - Gordon From toby at puckish.demon.co.uk Mon Nov 8 13:31:56 1999 From: toby at puckish.demon.co.uk (Toby Kelsey) Date: Mon, 8 Nov 1999 18:31:56 +0000 Subject: GC patch Message-ID: <+YHjVAAccxJ4EwGk@puckish.demon.co.uk> Here is a patch implementing garbage collection for python v1.5.2, it compiles under linux using egcs-1.1.2. It doesn't use the Boehm CG, or full mark-and-sweep. See the file gcmodule.c for details. Currently it only checks cycles containing lists, tuples and dicts. It has not been tested strenuously, and I would be interested in any benchmarks people can generate. So no-one feels left out, I have left plenty of scope for optimisation and improvements :-). Firstly a short script which shows what it does: === cut === class foo: def __init__(s, w): s.greeting = w def __del__(s): print s.greeting # list loop a = foo('bye list') b=[a] del a b.append(b) print 'list id', id(b) del b # tuple-list loop x = foo('bye tuple') b = [] c = (b, x) b.append(c) print 'tuple, list ids', id(c), id(b) del x; del b; del c # dict loop y = foo('bye dict') t = {} t[1] = y del y t[2] = t print 'dict id', id(t) del t import gc print 'pending', gc.pending() print 'collect', gc.collect() print 'pending', gc.pending() === cut === Enable DEBUG in gcmodule.c to see what is happening. Comments, insults, free beer etc. welcome, Toby The patch follows... begin 644 gc-patch.bz2 M0EIH.3%!62936:ZFK/4`&(G?@&@P>_______W\Z____^8""<`>\/ER\[O7>\ MU[/H5!5"JH.Z^VH^^^NMOGWCO:[WO!3USO7V*[=K.;N]7Q]> M5QK.F?;[L?7NO?;3U[OOGE;9\-)\Y7UO;ZD;OO<>O/L[ON[[?`E-("`3(3%- MJ:>A`FGD-%/$GM4!Y30T`'J:&0--!`$)IHFI/3)E,IY1M(]0`#0`````)!)$ M13U#U-/4!M0TT:,@`T``-`:```(4BD4>H]-!J>H]0#3:HTP/41@:#1J&F$8" M#$PB2*80TF(3*>$T)HPF$FFU#3";00:#(!D`DU(28D>B9(U'II,ILF)E,&II MD&F:@`TR`#0:#@, at 5$+W8%'LBJ01$T?_GNQP)V%45$435A&,A!23%!04K$!0 ME,110)0$3!"00[,#()IBJ*W?MVS+`WU9H=[UK4<-&EW5!!30Q2WU89!=`:_O MFS<)42!_J7+APWFU-DL7C&/$&C((>DLB2))H*")**&D*:&)"E(*@AJ)9D):" M@@ABB(""AD("&"(DE92`02*D0 at SZA\YVS0R/S8_-?5KX;ZWC2Q at WIG(F499) M85#&M0N0),L9!,EF2!&E,SA:0A;!X,URQ].+9K`V-H2I6%"@0P9&B*0D"@-, M:&;88C%IC&FTM9`NY&Y0MHS!K%F4P&HHI$O08#%2Y&@1$*H*CD-1L(4HHBB% M)5%(H*#&BC"T%E5$VMHHD-5VQ1HB:8S;3`X+9YFT<%`3''F!2].&!NR"F)*0 MF`JH)I/04UKZC/8^'H_Y^Z_CL/N_GMI;_L MPW71.S(F at C[(;H#I+C_7'E<99-]$1B=,OI+^ZG5Y_2O, M\3ZSP-HW]9!8R3->UHM3-ZBC#8TM^LBB:.* M.479YFVVRAR###MK at J#3##AY%-CDBED3Q7^+,T,0]+)9^GV4:)JR:(%G,K>< M:N1)S!6*R,9$Z]CO]>\<9?=?7REZ[]SR5*E]=3@[I,G_5!DRZ.KY8Y<"5D;W M>VY[23B99>3T\)`I#)`XC`41&""$*C0P?3\+]7L/[[]IGW]0^$?K[$P^*3A7 M].\/V?+3`JAJ,=;4>)]7LYM1B1.E#.6?4613*GSJ?-KD<)W=IV[N><,'=TC0 MH=!$^WXV=Q/C:=P_WBA!6O"'<4(([$#>[JMI8N4(VO(9 MFDQ]FP2Y1Q"#>PNZ0AJ.?T.<3!J,K1;'YICN%\-F4#3;+4;1R>V^IW&^MK%[ M+8"_$]!PYPZ`YT)>UZ@<>K0-M`T]T>J];S6,QA5H68\\*"FK6E^V!.MM^ M0]ZY at 5Y3O;EF8,[WEKGI:L?$*J%W>[KF&IS3(%75R9V?X?);IDYFN'A01Q%? MF/I0:/I4::P9 at DRWAG,VO3U>0L4![=AMRZWF`B[F]9*DSNPW[/--1Q2MG'`N<0&3RP1=IW2M(&F?)@,=,%9WZRN& MUZU+:A?:SRH^&[7G3B,"O*E^K.I%Q(F,RGK(79V\H;HX%2&4+]*:XTAN!0X[ M-JSR.>E8B/`LE=)]2V[GS^/<^NCL&E>!6Z$M\'\5$_%9`I-^)B-.3)&'W8>5 M>?2O6V,/9TW<*-%QMH\K[-H:SV[!]CW:SS.XT!CB&U:!%:-QB8<%,`+W,>\/ M:K3Z`5_SJ.HGS.M1UOMUN[858`RJAX6791SI,-7JN-JFQF,\T^.7CW\I7$]VK."0>',V&41/ M8<*2GH[$X.#?B19B.E1*J"G$CQ;S$_`I>PL!/"=8,I'OPZ:B(OP;1\GCK93N M'\$(0(9WB\.4<#(W=76G+Y<-0;^QE-%])AJGD_F#SIQUP-!MBPDJ[+2RR,.%XG)EZOU MU%P6R-NXK at U<(F3GPL-H&M*WC4QLW<=(C)/4 at 55&3889VNTF1%,)33#]"PIYGP>?KKN2/&S[`V" MO@"!^E/I9(0B$4U ML-V.&6\M"C2%0I)7O7>WYWZ.!U]H>J(6%=YFE`)C]-A$9#6C]["LH\<5NJ?!'0 M*=-`FF913C4]RR([C?[0X!ZH(OH-1NAP4Z`9B"R!X>HJE1K8YXD3VN]7$X;5 MZCAI3%%B/`BMKM!!-4V.4C>.ZA7T"\4'0:VOUEA"N67Q]%`U=FOJ':8-:+SL M5JZA>Y6`O(,,V4QS60KCZ-*UW\;]?BU-=L(DBA\ZJ"F at C<`X2PW,-_#]8 M5RA8#XSG)\VRT2(&.^S"ZXTX)7-:W.'HI?$WIFL"\O]0<7MJIV0]]C'*FZ?7 M2,-/%4NFX*P<2VIQ%:2(!"O95]E9-"E#NRC*LL[UM.MO'^_]W;$_6WQ/1Z>T M/*>;[O>#C)F$]3ZI@*M"U3K`$.L^!)&S1#V'B/:+_367F?V/X#P>;SGZTBD3 MH*S(=%0^8((G6N$8^KVB3%+-RB1$U9`=8)'K3A"["XREH',=E^#HMZ@)!K&Z M[P#IJQD3:8%FS$-[]%F'?5F,SOS6]65W/MA=.%O)INO;U_@`>,`P#,\[))I[ M.L=H8>D03UKUWHD5)$%,!898E&24.8&&600[M1$555Y!N!!#+D?P/SGS?$8D MGO"P$UWINH^8."YEZB%3%QBJ`_DJHKU%_Z&8,)+`_W&'%YJ+^?%O&U_UD.M009H M"4/#:!DPE_2S=8%B)LK8HJ.84F7FWW+H55HFK.Z`6G9R"Z/G#`N,?C&R9`$Q MV%X]^.85[R%N5;4G9W?U0+:OI8^&:H'R),2H0`[3EPP?8$2?01.,]C/]>U#\0H+/YPX4?'[10YQHL?\8?/M M^G0O^2=L/!J'^P0TF6H!L_FLH;VD4.";>4G^$#R'A"(&QEIP8V#0_ at VI?'>X M<60D1.I-JDYX1YC,I+=,TWXE=P53T=5 at VL,"B2%0*(%'9=8/;^ MA*1<&)Z@][A\9(&P<]KX5JB:H(BJ)9*[POB*]ACP/+Z$P7 at 4AS)W#H@/>0Z4 MST#X&O0S&+*8$H3)=_%?B"#8O7Y?A^SUO3WT$.XYWX>'W>/CB@]E4B,U+KBA M'T,2YL*#B'B.WX3OZDS3(*]\.LLCJ:P^,X?4J*CY_(/)3!F?J`L%U2\"Y^LP M!88?:5$@IR^X0N"](BG=T9ZB[,KSS:'9@@?`SI(OB#K#89Y M>WF?6&_8CCD7G`<)&.-T_9,@^$[1I7@'`..;D(DY\S,-&N85,/$E7ID"IAXJ6MV!2`8_ M)Q^EUG)I?"KAQ@:3W=WU;E4-PY^*C.1#;A4ULB<8<0R(H`3$C?P7:O1YTGKY"TE$34]BME$011F=S3D M1-4RP)"$+J>5!JCO";@8]K2+KB'MO)D[2D_/^%,(9$R9!]CQJ,P:%"UU30C! MO(E`K*\X(78899S^6B2,JB4V%&%"2!$F#$YG$K:X at 8>R`8M@*)8#76TPCD2I M*D*>5Z0-+2IB*@`4*U0X"34*()4(,&6J#'60I>VGPT:=":9160 at 3T4&;N2T0 MYB!)DNK>;H)@![3`(%'J,!)H+)F%&R-. at 0>?8N]!O%I-4?E,K!89;7;BX*F8 MXHXG_14C%A()`BN_&K"@5`/Q`B0Z#'<:.H;6K;77E"D0MNFRUM*:M/H6]ZN$ MV&SBFL42;.0-EW`Y8M1BAP8"&%E;PV[S;*K`389(*9`7>0Z3>P'W[@P#6)AC M!D%H0%[S>SC:,R:R83IL0;=I(H&:&*P63%6;9`?3+ED)-4_)X85Z&RF,)EQ+ M<3/C!8P&RIF059-L4\`B3#24A`F`,B-*`#C1,A<%C<:72-X(572"T at 65J^2J MP8ZI@#Q<0,$^=%39D`40F:..H*S-6]Z6Z/U>HM=)V>%*N6)6$)91R<`P*(OT$4DD`@P^X7.`[(&+]`!! MP'J83CC"E&#*(H.S#OE$Q`3*U`&$V=0#4'$,.8WDF/8'M$-VA,PN9DZ-P at 2_ M at +@IZ*N<)[ZEG"VI?2I,%"T1DUYEM9C@'`7PQ497(!9]:63`[+'(AZW/9GX7 M at KP)/#U)F8%F`R=O at I9'#,].C>YY6'P*(A2MH]_+8/?UQP>RP/GT/Q,QDC5E M.1J[SQSG`A&:)Y=R=:@'[2+?Q7/JG:I)=K&!YR&9N2 at J@AO`YLA.Y[U:<^_) MI.Y$!!B"R+MCMZ-;(-KS$#;0;#O:%A`),"1/0!P?`OV,;%ZW&[+"[P,EKFD,C1)Q+$ M,!O>Q>%X4AIF94=`0-V1D.%6;@.@)-N.FXY;L2YL,1'X2>=GQ*R*",BA"[U! M@%+22D#Z`^@$X%YM<4N&8:D at DP9,9G4(OAS MVE!"6QX<-DK8NQ2M`S8=,RJM$+O`#<&L`S&,&3QX)/`P[XC!AAS=TK>B<_.$ MD!6EW&4!H at 07"(\!@/61`1UU#?P.*-:A39>#..(#0T<:7BIPI!T'6.Z%F!1Y MB4J;&[[&:S5FB7_`1R:8<1H/4 at RIH!C`8,!5%$$CG74PVVH M at 0W>`S7,9`Z:>C5D=B`@[T3S"U.U;ES@(R@*J<`/`"LQ,*@Q]]EM;IHQZTVV M\4!-941Q$94;AL$U9%A18PF?4G9W)[OS]LJP5'O)17R<+R8\U2GQ"&9PA#Q3 MB!\P)(&^/S7,V26+F?B#-#<0`A)%9!CQL>`^2)`-89J/.P,]?MR]*`6)RKQ+ MB=2>6*.'NXT!G$9B:E,'7R;B*5(1U@&]HK`;G`.*!6S`SPD.$$V^5?$^0]T- M;\U!XTBV"+(CY2#*JJ>H5T;(4QA'E&YZ`%[UKE$ M3NU!MP3FTZ*,T,B`=KB;$L)S;JV[^EW%*ZA"6Q>\=)O%M#/Z^0QF8=]#8Z4^ MQ"`T1%8R$CB#71`A"`D5L8)NW68#PQ-NN-SIQ*:9)!L0URHX<3 at 0;SNSH$F3 M-YA`.O+\KF3"X4E.K_8O7-VK8X9R<[S`>\8U,&28$(3E,BQO,=2( MR!R8!5LU=Z,J8O8M(&1T#-8)K@?)%?OVF')BIGMO9US0-E)837:SOW&EFZK9 M5RSO"9)`P\KW:"0PW)',)D9D8%E at 6/R269J-OF1)*X(Y:;O"LFM[Z,NQO M&&SNA#F:E9AE+2>;L#Z8D]8GE9"B34&%"*(2>8E$-#5YIN-#,PLN`L4.*D2, MX#04\IRW-,L at Q;CDV$IOKIXACH/)C4"!&1I&$`W@&XN9KD\&PJ6,S`LP,9`I MJ]^5KJ2^H?*$-U`>4QH7D/#?V\!WS005(0 at 0UI:C,-$0MK-(T6%O0]*!5N`+ M6F<3$`K5/8P,:.]K!/.=TE6$TQ6](M*@ MD1#B'O at 94`%$P)%PRY(3CP at QP,'(J%32#:%HKIR1."7"[94<>'"NE)U.TR=H M]Y'S=U/(G_JP-Y\#9ODEGAO$Q$>L#74Y at X/`I)VTIT#7,SQ=<>*K)(,B<28:)# M06F[&ZGN19L1RN8=>&3;"Q8'VJ9T6=1S]#:T0/]@] MA>02N,+R3=,,CRD(2(0*R89Q)24'H$MY3$)V0."6`UA>.NKGJ4`NA$,&`O4! MDM\ Hello, Sorry if my question is not strictly a Python question. I would like to explore distributed programming, and I think Python would be the right tool for that. I don't want to produce industrial-strenght code right now, but learn the basics. I'm not really interested in the "middleware" aspects, so I didn't subscribe to the "Python Distributed Objects" SIG right away. I just want to answer questions like how do I partition a monolithic program to run on multiple computers? I went to the bookstore, and found some title (not with Python), but I wasn't sure which one to buy. Those are expensive, and I thought that someone here could point me in the right direction. I'm looking for practical, hands-on stuff, if possible. Thanks in advance, ______________________________________________________ Gaetan Corneau Software Developer (Quality Assurance Team) BaaN Supply Chain Solutions http://www.baan.com E-mail: Gaetan_Corneau at baan.com Tel: (418) 266-8252 ______________________________________________________ "Profanity is the one language all programmers know best" From king at calibre-dd.com Wed Nov 24 12:15:35 1999 From: king at calibre-dd.com (Stephen J King) Date: Wed, 24 Nov 1999 12:15:35 -0500 Subject: Numeric module under IRIX 6.5 Message-ID: <383C1D37.41863D9B@calibre-dd.com> I've downloaded LLNL Numeric module and compiled it for IRIX 6.5 (using -n32 flag), but when importing the module to Python, it dumps core |=( Has anyone encountered/solved this problem? Thanks -- Stephen J King Technology Manager Calibre Digital Pictures -- king at calibre-dd.com http://www.calibredigital.com From gmcm at hypernet.com Thu Nov 4 19:41:05 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 4 Nov 1999 19:41:05 -0500 Subject: NT DLL modules and C++ In-Reply-To: <7vqf95$5rg$1@sun500.nas.nasa.gov> Message-ID: <1270360037-42609785@hypernet.com> Patrick J. Moran writes: > I should clarify a bit. I have an initFOO() call for my FOO > module, and it gets called just fine. I can manually call > "placement new" constructors on the static data members of my > classes to initialize them, but it's awkward and a hack. It's > also not a complete solution because there may be other static > objects that belong to libraries whose implementation I'm not > familiar with, e.g., iostreams. There's got to be a better way. > > My understanding is that there is an entry point, > _DllMainCRTStartup, that the linker generates that calls the > necessary C++ constructors, and then calls DllMain. It's a routine in the C runtime, not in your DLL. > So, the good > news is that I could call _DllMinCRTStartup and the appropriate > construction code would be called, assuming I figure out the > arguments required by _DllMainCRTStartup. I don't think you can call it. > The bad news is that > _DllMainCRTStartup calls DllMain, the entry point provided by the > user (or the Python library, I presume). DllMain can be provided by the dll author. If he/she doesn't provide one, a dummy one will be created. > DllMain in turn calls > my initFOO (again, I presume) so I would be in an infinite loop. > Of course I could think of hacks to prevent the infinite looping. > Still, there's got to be a better way. Nope. DllMain (the default one) does nothing. If you write one, it's generally to do things like set up TLS (which you probably _don't_ want to do with Python). > The solution that I'm looking for is to get Python to call the > constructor code when it does the dynamic linking. I think this > means calling _DllMainCRTStartup rather than DllMain. I've tried > looking through the doc in the PC directory, but it's still > unclear to me. That's what I was looking for help with. It's not Python's responsibility, it's the runtime library. I haven't tried it in a couple years, but I was never successful in getting static initializers to work with DLLs. In fact, I had a lot of problems with them in normal MSVC apps, so I got out of the habit of using them. I just "new" them on startup. - Gordon From T.Middletin at news.vex.net Mon Nov 15 13:19:42 1999 From: T.Middletin at news.vex.net (T. Middletin) Date: 15 Nov 1999 18:19:42 GMT Subject: Proposal: Python Info Collective References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> <80oqn9$ocq$2@newshost.accu.uu.nl> <80p9su$ppo$2@newshost.accu.uu.nl> Message-ID: <80piru$13rl$1@hub.org> On 15 Nov 1999 15:46:38 GMT, Martijn Faassen wrote: >mature enough, Parnassus can have a flag somewhere 'distutils compatible' >or something like that for each module/program in its database. Yeesh! Got about a hundred times more hits on my web site today than i've ever gotten. And now i'm posting ten times more usenet messages in one day than i usually do in a week or a month or more! Grumble grumble. (-; Er... i mean, nice idea. (-: I'm game for it. Anything to make distributing python stuff easier, i'm interested in definitely. Will have to keep this in mind and see if it goes anywhere... ... From dkaznadzey at my-deja.com Mon Nov 8 14:44:16 1999 From: dkaznadzey at my-deja.com (dkaznadzey at my-deja.com) Date: Mon, 08 Nov 1999 19:44:16 GMT Subject: Popup menus in Tkinter References: <199911081726.SAA25412@axil.hvision.nl> Message-ID: <80796f$f9h$1@nnrp1.deja.com> Thanks A LOT ! It worked perfectly! What would be a good source of information on tk commands available through Tkinter? Denis Sent via Deja.com http://www.deja.com/ Before you buy. From bernhard at alpha1.csd.uwm.edu Sat Nov 27 14:57:27 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 27 Nov 1999 19:57:27 GMT Subject: XPython (X11) References: <383E5350.1E07536A@xrce.xerox.com> <81ms2n$126$1@essle.valdyas.org> Message-ID: On 26 Nov 1999 20:54:47 GMT, Boudewijn Rempt wrote: >Bernhard Reiter wrote: >> On Fri, 26 Nov 1999 10:30:56 +0100, Emmanuel Pietriga wrote: >> If I want to program a GUI I look in to wxPython. >> Or pyGtk or pyFOX or pyFLTK, but XPython... :) >Hey! Don't forget PyQt and PyKDE (and PyQt seems to be >working under Windows, too, nowadays)... Do you have to but the Troll Kit first? >:) And I didn't mention pyGNOME, why should I mention to PyKDE? To create an application tied to KDE or GNOME is a mistake in my eyes anyway. people-will-love-it-any-way-ly, yours Bernhard -- Research Assistant, Geog Dept UM-Milwaukee, USA. (www.uwm.edu/~bernhard) Free Software Projects and Consulting (intevation.net) Association for a Free Informational Infrastructure (ffii.org) From mwh21 at cam.ac.uk Tue Nov 16 06:16:12 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 16 Nov 1999 11:16:12 +0000 Subject: exec/eval changed? References: <942690155.686795566@news.glph1.on.wave.home.com> <3830AC4B.1C8C1107@kw.igs.net> Message-ID: JB writes: > Michael Hudson wrote: > > > > JB writes: > > > > > Did the exec/eval statements change somehow in the 1.5 versions? I > > > have a script that did an eval( "some code", dict1, locals()) but > > > now it doesn't work. I've looked through the doc's but they are > > > little thin as to these statements. Any help is appreciated. > > > > Well, eval("some code") is a syntax error. What are you trying to to > > do? We can't read minds here. > > > > Regards, > > Michael > > My apologies. I was thinking that the scoping for the 2nd and 3rd > parameters to the eval call had changed somehow and thus the code was > irrelevant to the example. > > What I am trying to do is simple eval a string with python formatting > operations within and return the result. The code string is dynamic. > Basically: > > eval( "'The value of t is %(t)s' % t", self.private_dict, locals()) > > where t is in self.private_dict. The questions comes because this code > worked in python v1.5 but does not work in v 1.5.2 and I was curious if > there had been any changes to the scoping or to the eval/exec calls > themselves. How does it fail? If I try something like that I get: Traceback (innermost last): File "", line 1, in ? test(2).go() File "", line 6, in go return eval( "'The value of t is %(t)s' % t", self.private_dict, locals()) File "", line 0, in ? TypeError: format requires a mapping If I change it to return eval( "'The value of t is %s' % t", self.private_dict, locals()) then it works. You aren't trying to do return 'The value of t is %(t)s'%self.private_dict are you? The use of eval seems a bit overkill here! > Sorry for the confusion. That's OK; but for future reference you might want to include how your problem code fails as well! HTH, Michael From cgw at fnal.gov Thu Nov 11 10:11:30 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Thu, 11 Nov 1999 16:11:30 +0100 (MET) Subject: print "foo", without a space In-Reply-To: References: <382AD3BB.69899CBD@helsinki.xx> Message-ID: <14378.56482.32270.846010@gargle.gargle.HOWL> Michael Hudson writes: > Mikael Johansson writes: > > > Hello All! > > > > Is there another way of getting print to not make a newline than > > using: > > print "foo", ? > > I think there's some way invloling sys.stdout.softspace, but I'm no > sure what. However... Another option is to forego the "print" and use "sys.stdout.write()" instead. Conversion of the argument to a string is your responsibility, and no extra spaces/newlines/etc are added to the output. From tbryan at python.net Thu Nov 11 21:35:33 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Thu, 11 Nov 1999 21:35:33 -0500 Subject: Beginning programming with Python References: Message-ID: <382B7CF5.68048F5F@python.net> Aaron Ginn wrote: > > Hello all, > > I'm starting a non-profit organization dedicated to promoting computer > literacy in low-income youth (ages 12-18). The curriculum will > include an introduction to programming using either Python or Perl. I'd definitely vote for Python. I've programmed in both quite a bit, and I can't imagine using Perl over Python for this purpose. Some things that spring to mind: 1. Python's interactive interpreter will let them get their feet wet immediately and will continue to help them test code as they progress. 2. Multiple IDEs exist for programming in Python. 3. Python's core syntax is much simpler than Perl's. Learning some of Python's libraries will eventually be useful, but students can do a lot of learning before even dipping into the library. 4. Python's design nudges programmers toward what I would consider a better style and overall architecture. I believe that coding in Python improved my programming in all other languages that I use. I think that some of its design (indentation-based blocks, any file is a module, convenient object-oriented support) make would really help students get off to a good start. 5. Objects and references are simpler to explain and use in Python than in Perl. See also the "Making the Python case to my dept." thread from a few days ago. The thread there was geared toward using Python at a University, but many of the same arguments apply in your case, too. ---Tom From Gareth.McCaughan at pobox.com Wed Nov 24 05:38:27 1999 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: 24 Nov 1999 10:38:27 +0000 Subject: Python complaints References: Message-ID: <867lj85g4c.fsf@g.local> Mark Carroll wrote: > Basically, I'd be really interested to learn: what _don't_ people like > about Python? - if/then/else works on *statements* (strictly, suites of statements) rather than on *expressions*, so I can't say print "You scored %s point%s" % (score, if score==1 then "" else "s") or anything like that. (Or, as some people prefer to put it, Python has no ? : operator.) In fact, the distinction between statements and expressions is in my view a wart. (Lots of people would, of course, disagree.) - Memory management is by refcounting instead of GC. This has its good points (it means that one can define more precisely when e.g. finalisation happens), but it does mean that if you build structures with cycles in the reference graph then they won't get GCed when you want them to. This is a real nuisance, for instance, when you're exploring ideas or debugging: suppose you have a piece of code that builds a big data structure out of class instances; then every time you make a small change and run it again (you have to run it again, because existing instances belong to the old versions of the classes) you can be leaking a lot of memory. - Method definitions have to be lexically contained in class definitions. So suppose you write something that parses a language and then does various things with the parse tree; if you adopt an OO approach to the parse tree (with things like "class IfStatement(ParseNode):") then you can't separate out very different operations like foo.print(), foo.compile() and foo.evaluate(). (That is, you can't group all the print methods together, and group all the compile methods together somewhere else, etc.) You can, of course, split your code up by having the WhileLoop and UntilLoop classes in different files, but this seems less sensible to me. :-) (This particular gripe applies to most OO languages.) - The Python interpreter is rather slow. (I'm talking about CPython here. I believe JPython is usually somewhat slower.) - Some more iteration constructs would be nice. - do ... while - parallel iteration across more than one list - a less yucky way of saying "for i in range(1,20,3)" -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From malcolmt at smart.net.au Tue Nov 30 19:17:51 1999 From: malcolmt at smart.net.au (Malcolm Tredinnick) Date: Wed, 1 Dec 1999 11:17:51 +1100 Subject: What's the canonical vi setting for Python indentation In-Reply-To: ; from Sean Blakey on Tue, Nov 30, 1999 at 11:46:10PM +0000 References: <38445B6A.A1283D2E@cs.mu.oz.au> Message-ID: <19991201111751.A1277@Ridcully.home> On Tue, Nov 30, 1999 at 11:46:10PM +0000, Sean Blakey wrote: > I don't know about canonical, but I have the following in my .vimrc > set expandtab "Turn's tabs into spaces > set hardtabs=4 "Make tabs 4 spaces wide > set tabstop=4 > set shiftwidth=4 "For use with << and >> I tend to avoid 'set expandtab' to save typing. If I want to back out from one indentation level to the previous one, it takes a single BackSpace to do so. If I am using the 'expandtab' setting, it takes four keystrokes (these things matter to me). Of course, I am also using the 'autoindent' setting (but, then again, doesn't everybody in vim?). To avoid making this a complete "me too" post, I'll point out that the "retab" command is useful at some points, too. After I've edited a program to more or less completeness, if I'm going to email it or print it, I will do :se et :1,$ret You can go back the other way by doing :se noet :1,$ret! <--- Changing sequences of spaces back to tabs This way I get the best of both worlds -- efficient typing speeds, but something that doesn't rely on the receiver's (printer or email adressee) tab settings to look the same as my on-screen copy. Cheers, Malcolm Tredinnick -- 42.7 percent of all statistics are made up on the spot From jblazi at netsurf.de Tue Nov 16 16:17:01 1999 From: jblazi at netsurf.de (Janos Blazi) Date: Tue, 16 Nov 1999 22:17:01 +0100 Subject: Beginning programming with Python References: <382B3A53.5816B2@callware.com> <382B3D79.74CD3E0F@email.sps.mot.com> <80p9ds$ppo$1@newshost.accu.uu.nl> <38312D55.A36EB56D@iqsoft.hu> <3831A4EB.76FF32AF@boi.hp.com> Message-ID: There is one thing though in Python I do like at all! The language is not as versatile as PERL when loops are concerned. I very much like the construction REDO ... UNLESS or something like this. It is a pity Python does not have this sort of things. Janos B. Bill Anderson schrieb in im Newsbeitrag: 3831A4EB.76FF32AF at boi.hp.com... > Nemeth Miklos wrote: > > > > Janos Blazi wrote: > > > > > I have tried to use Perl in my teaching. It has a very powerful but alas! > > > not very simple syntax! To start with, my pupils used to forget the dollar > > > signs and Perl does not like that. So this year I shall use Python. We shall > > > see. Time will tell, if Python is really better. Maybe my pupils will forget > > > the indenting this time? There is actually nothing else you can forget in > > > Python. > > > > I am quite new in Python programming, and I was a bit :-( by understanding that > > Python does not have any (even optional) mechanism to enforce the usage of > > predeclared variables and functions. The complete lack of compile-time > > type-safety of Pythom may be a problem in large projects, which may be the most > > serious technical (ie non-marketing) obstacle to Python's becoming a widespread > > language like Java. > > Let us see an example: > > # Module t.py > > def f(): > > print "started" > > x = 128 > > x.foo() > > > > Let us import it in the Python interpreter: > > >>> import t > > >>> > > You can see thet the interpreter compiled t.py to t.pyc (or t.pyo) but found no > > error. > > All typos (typing errors of variable and function names) will be detected ONLY > > at runtime! Python is perfect language to write programs fast, but with the > > cost of hordes of testers. > > Disagree. I write many things in python, fast, and without hordes of > testers. > > > However this may not be a big problem, because any > > piece of software should be thoroughly tested, to make sure that there are no > > semantic errors in the application. In the case of Python the applications > > should also be tested for "syntactic" errors. > > As should _any_ language. > > > In Python (just like in Smalltalk or in Perl, or in Tcl) there are a lot of > > things a programmer may forget. > > Just like in C, java, C++ ... > > > I am on my way of becomming a Python programmer, but this should not prevent me > > from seeing the pitfalls of the language. > > A tutor must emphasize these gotchas of any programming language. > > Perl has a facility called 'use strict': it is also very poor compared to C++ > > and Java strict static (ie compile time) system. > > The only really large project implemented in Python I found is Zope. Zope is a > > fantastic piece of software, and may be regarded as an evidence of my being > > totally wrong ;-). > > yup :-) > > > > I feel that it is the right language for teaching. > > > > Anyway, Python is a great language for teaching, but why to learn a language, > > which is good only for teachning?! This is the real question you (or the Python > > community) should answer! > > Not possible. The question is predicated upon an assumption. You > incorrectly assume that Python is _only_ good for teaching. There are > quite a number or large companies that would disagree with you. > > Bill > > > -- > Bill Anderson Linux/Unix Administrator, Security Analyst > ESBU (ARC) banderson at boi.hp.com > My opinions are just that; _my_ opinions. From billtut at microsoft.com Wed Nov 24 09:37:24 1999 From: billtut at microsoft.com (Bill Tutt) Date: Wed, 24 Nov 1999 06:37:24 -0800 Subject: Python and COM: a bug? Message-ID: <4D0A23B3F74DD111ACCD00805F31D8100DB915AA@RED-MSG-50> > From: Gaetan Corneau [mailto:Gaetan_Corneau at baan.com] > Here is my original post: > > > Hello, > > I have encountered a weird problem a few times in the past months. I'm > testing COM server (written here) with Python, and it seems > that there is > something wrong in the code that optimizes the calls to COM objects. > Sometimes (a very rare occurence) the wrong function gets > called when I > access a property. Suppose I have object O with properties a > (an int), b (a > date), c (a string), then > > print O.b > > would give me > "Hello, world" > > The error always seem to be off by one (in the same > direction), but I'm not > absolutely sure about that. > How is this "O" written? Is it an ATL C++ COM object that uses IDispatchImpl? (i.e. a dual interface) Is it a C++ COM object that implements IDispatch on its own? (not a dual interface) Is it a C++ COM object that uses OLEAUT's builtin IDispatch, but just doesn't use ATL? (i.e. a dual interface) My hunch would either be a bug in Python dispid code, or your COM object has a bug in some custom IDispatch code. I also don't think we try to optimize any calls. COM doesn't give one enough information to even bother optimizing anything other than caching Name -> DispID mappings. > And sometimes, I get something like that: > > >>> Object > > > >>> P = Object.Parent # Parent is an attribute that is the object that > created the current object > >>> P > > >>> P = Object.get_Parent() > >>> P > > > >>> > What really helps in cases like this is to have the IDL for your dispatch/dual interface so that we can examine whats happening much easier. :) The otherthing to note is that the > occurs because you aren't wrapping the typelibrary with Python helper classes. Using win32com.client.EnsureModule("") allows you to support a couple of features that are impossible to deterimine without the typelib. I forget exactly what those are off the top of my head. > I have workarounds, but what really annoys me is that I'm > still fighting a > couple of guys here to get Python accepted: they always ask > "why don't you > just use VBScript?", and it's true that I don't have those > problems with > VBScript (because VBScript doesn't try to optimize calls). > The answer believe it or not is, "Python is the most powerful scripting language on the planet for Win32 programming." its multi threaded, COM happy, ActiveX Scripting Engine happy, and really easy to talk to. VBScript on the other hand... Don't get me started... :) > I'll try to find what the problem is by tracing the Python > code, but since > I'm not familiar with it, I don't expect to find the cause. > At this point, > all I want to know is if I'm the only one with that kind of strange > behavior... > I've seen behavior like the above "Parent" issue before. I haven't ever seen the first behavior you mentioned... Bill From skip at mojam.com Fri Nov 5 15:39:41 1999 From: skip at mojam.com (Skip Montanaro) Date: Fri, 5 Nov 1999 14:39:41 -0600 (CST) Subject: IPC8: SouthWest Airlines Internet specials In-Reply-To: <14371.14313.700685.807764@goon.cnri.reston.va.us> References: <14371.14313.700685.807764@goon.cnri.reston.va.us> Message-ID: <14371.16525.555599.961527@dolphin.mojam.com> Jeremy> Everyone planning to fly to the conference should consider Jeremy> flying through BWI. I have flown from BWI to San Jose and San Jeremy> Francisco a few times this year, each time for about $200. Jeremy> Flights through BWI are often cheaper than flights from Dulles Jeremy> or National. If you're on a budget and might like to get away without renting a car, don't forget to figure in the cost of ground transport into the total equation. For IPC1 I flew into BWI and found the metro didn't go there. Not real convenient. At least with National you've got a Metro station nearby. All that said, I don't know how convenient the conference location is to public transport. Jeremy, Guido, and other locals (yikes! Guido's a local now?) can probably give a summary of that sort of thing. me-who-rarely-drives-a-car-to-work-ly y'rs Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/ 847-971-7098 | Python: Programming the way Guido indented... From gmcm at hypernet.com Fri Nov 19 09:06:19 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Fri, 19 Nov 1999 09:06:19 -0500 Subject: Python in business programming [was Re: Beginning programming with Python] In-Reply-To: <19991119135811.B4306@optiplex.palga.uucp> References: <1269336472-10033930@hypernet.com> Message-ID: <1269102119-24129916@hypernet.com> Gerrit Holl wrote: [snip] > I agree. But some functions are too small to be used: > in os.path: > def os.path.isabs(s): > return p[:1] == '/' > > I think that's a redicolous (how does one spell that?) > function... "Ridiculous" on *nix, "Wrong" on Windows. - Gordon From phd at phd.russ.ru Sat Nov 6 08:39:21 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Sat, 6 Nov 1999 13:39:21 +0000 (GMT) Subject: Get parameter by name In-Reply-To: Message-ID: On 6 Nov 1999, Michael Hudson wrote: > locals() should do the trick: > > def f(x): > return locals()["x"] Thanks! Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From Gaetan_Corneau at baan.com Fri Nov 12 11:53:58 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Fri, 12 Nov 1999 11:53:58 -0500 Subject: .dll and .exe file version informaton Message-ID: <816010E2456BD111A48700805FBBE2EEFDF7AE@ex-quebec-u1.baan.com> > Given the win32 calls it wouldn't be too hard to wrap them up in an > extension module. Yes. The only problem is that the file information is divided in two parts: the first one is fixed, and is independant of locale, the second is user-defined. The second part is harder to read. If anyone is interested (is that really useful?), I could code the fixed part and publish the C++ code. That would require only a few minutes of my time. ______________________________________________________ Gaetan Corneau Software Developer (Quality Assurance Team) BaaN Supply Chain Solutions E-mail: Gaetan_Corneau at baan.com Compuserve: Gaetan_Corneau at compuserve.com ICQ Number: 7395494 Tel: (418) 266-8252 ______________________________________________________ "Profanity is the one language all programmers know best" From victor_ng at my-deja.com Mon Nov 15 00:32:59 1999 From: victor_ng at my-deja.com (victor_ng at my-deja.com) Date: Mon, 15 Nov 1999 05:32:59 GMT Subject: Debian/Apache problems Message-ID: <80o5ub$csn$1@nnrp1.deja.com> PYTHONPATH /usr/lib/cgi-bin/python/stdlibs I added the top 3 lines to my access.conf file in Debian, but I can't seem to get module imports to work for my CGIs. What's going on? I don't really know Apache that well - so any help would be useful. Vic Sent via Deja.com http://www.deja.com/ Before you buy. From parkw at better.net Thu Nov 18 18:58:12 1999 From: parkw at better.net (William Park) Date: Thu, 18 Nov 1999 18:58:12 -0500 Subject: Python in DOS In-Reply-To: References: Message-ID: <19991118185812.A949@better.net> On Thu, Nov 18, 1999 at 06:24:25PM -0500, Curtis, Craig M. wrote: > Does anyone know the "approved" way to get rid of the following message: > > Could not find platform dependent libraries > Consider setting $PYTHONHOME to [:] > 'import site' failed; use -v for traceback > Python 1.5.2 (#6, Nov 18 1999, 17:19:05) [GCC 2.8.1] on ms-dos7 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > > > I've tried everything I can think of to set PYTHONHOME and PYTHONPATH and > python ALWAYS starts up this way. If I remember (this was long long time ago), I had to remove case sensitivity for library files by setting some dummy environment variable. From jcd2 at lehigh.edu Mon Nov 8 18:58:41 1999 From: jcd2 at lehigh.edu (Josh Daghlian) Date: Mon, 08 Nov 1999 18:58:41 -0500 Subject: [OFFTOPIC] Maps and functions (was Re: Apply a function to each list member?) References: <19991105215504.A497@Ridcully.home> <14370.53219.667492.946075@gargle.gargle.HOWL> <27NwjKAK1uI4EwdJ@jessikat.demon.co.uk> Message-ID: Here is an example of something that maps a single input to multiple outputs: y(x) = arcsin(x) For x = 0, y(0) == ..., -2*pi, -pi, 0, pi, 2*pi, 3*pi, ... Note that this is *not* a function (in the math sense), but it is a perfectly good mapping that lots of nerdy folks use all the time. Now lets move to alt.math or something. :) Cheers. --josh In article , Michael Hudson wrote: : Robin Becker writes: : : > In article <14370.53219.667492.946075 at gargle.gargle.HOWL>, Charles G : > Waldman writes : > I define f as a thing which takes integer arguments and outputs sets of : > integers : > : > presumably I can have such an f that : > : > f(2)={3,4} : > : > to my simple engineer's eyes f could belong to the functions mapping Z-- : > >2^Z : > : > I assume we're not talking that way if the f above isn't a function. : : f is a function, as you say from Z to 2^Z. A difference between that : and a function from Z to Z, is that this f throws away a lot of the : algebraic structure of Z (i.e. being a uniquely generated commutative : ring), and so is in many ways less interesting than a function that : preserves this structure. : : Regards, : Michael From news at dorb.com Sat Nov 13 19:53:29 1999 From: news at dorb.com (Darrell) Date: Sat, 13 Nov 1999 19:53:29 -0500 Subject: method overriding trick References: <14378.62498.649973.150075@bitdiddle.cnri.reston.va.us> <382DFF59.51F186A6@x.x> Message-ID: Eric Jacobs wrote in message news:382DFF59.51F186A6 at x.x... > You wouldn't be able to reassign the _Parent variable to define another > class elsewhere in the same module, though, because the functions defined > this way will always look up the _Parent from the module namespace at > execution time. A variant that removes that restriction is: > > > _Parent = basedlg.BaseDlg > > class AddressDlg(_Parent): > > def __init__(self, param, _Parent=_Parent): > > The default args are evaluated at function definition time, which means > that the variable has the value you expect. Now you have true cut'n'paste > coding! This doesn't seem to be a problem. >>> class A: ... a=1 ... >>> class C: ... pass ... >>> p=A >>> class B(p): ... def __init__(self, p=p): ... print 'p:', p ... print self.__class__.__bases__ ... >>> B().a p: __main__.A (,) 1 >>> p=C >>> B().a p: __main__.A (,) 1 >>> If you want to change base classes on the fly check this out. >>> class X: ... pass ... >>> X.__bases__ () >>> X.__bases__=(B,) >>> X() p: __main__.A (,) <__main__.X instance at 7fb1f0> >>> -- --Darrell From Brian at digicool.com Tue Nov 30 09:33:45 1999 From: Brian at digicool.com (Brian Lloyd) Date: Tue, 30 Nov 1999 09:33:45 -0500 Subject: Exposing COM via XML-RPC or Something Else Message-ID: <613145F79272D211914B0020AFF6401914DD7C@gandalf.digicool.com> > I'm playing around with a way to expose Windows COM object via > XML-RPC (or something else). > > Let me explain: > > My first thought was to write an XML-RPC API to expose the MAPI COM > object and it's methods. > ... > So my current question, can anyone think of an existing technology or > library that will allow me to expose these COM objects in a way that > could be used by other platforms/languages. Corba (FNORB), ILU, PYRO? > > Or am I really just going a little crazy? You might want to take a look at MS' SOAP (Simple Object Access Protocol) spec - it's not fully baked yet, but it basically takes xml-rpc several steps further, allowing you to communicate with SOAP-enabled objects (COM or otherwise) using XML over HTTP. We in Zope-land are keeping a close eye on this, as publishing objects via HTTP is the core idea of Zope already. Once the SOAP spec is fleshed out enough to implement in Python, it will probably be laugably easy not only to implement SOAP objects in Python but also to wrap most any existing COM objects as SOAP-aware objects. If you're interested, the current spec is at: http://msdn.microsoft.com/workshop/xml/general/soaptemplate.asp Brian Lloyd brian at digicool.com Software Engineer 540.371.6909 Digital Creations http://www.digicool.com From ionel at psy.uva.nl Mon Nov 1 16:09:49 1999 From: ionel at psy.uva.nl (Ionel Simionescu) Date: Mon, 1 Nov 1999 22:09:49 +0100 Subject: How to control app from Python? References: <38160DD8.5C695E09@theriver.com> <3817BD5F.7E05BDC9@home.com> <38185A03.9AB0FAD6@theriver.com> <7vke68$6r6$1@nnrp1.deja.com> Message-ID: <7vkvia$st7@mail.psy.uva.nl> | > The app to be controlled is visual... | > I discovered Mark Hammond's win32 stuff... Easy would it be if the application is a DDE server or a COM server. Check its docs. If it is none of that, you can still approach it the hard way, that is by getting a handle to one of its windows (through system functions) and then sending messages to it, or even data (via a pipe). The attachment is an example written in C for controlling Gnuplot. The example is simple and clear enoough to give you a starting point. The problem with it is that not all system functions used there are also found in the win32 extensions, yet. Succes, ionel begin 666 pgnuplot.c M+RH*("H@<&=N=7!L;W0N8R M+2!P:7!E('-T9&EN('1O('=G;G5P;&]T"B J M( H@*B!697)S:6]N(# N,R M+2 S,"!*=6X@,3DY.0H@*B *("H at 5&AI7)I9VAT("A#*2 Q M.3DY($AA;G,M0F5R;FAA7)I9VAT("A#*2 Q.3DY($-R86EG(%(N(%-C M:&%R9'0N"B J"B J(%1H92!C;V1E(&ES(')E;&5A2!I2!#2!#7,@&5C*"D@=&\@&4*"0D@('=H M:6-H(&ES(&QE2!T:&%N('1H92!O;&0@"@D)("!T96-H;FEQ=64N"@D)*R!3 M:6UP;&EF:65D(&UE2!O M9B!W9VYU<&QO="X at 5&AE(&]N;'D*"7=A>2!T;R!A=F]I9"!T:&ES('!R;V)L M96T@=V%S('1O(&-H86YG92!P9VYU<&QO="!S;R!T:&%T(&ET('=O=6QD('-T M87)T(&$@"@EN97<@:6YS=&%N8V4@;V8@=V=N=7!L;W0 at 979E2!C86QL:6YG"@EI="!D:7)E8W1L M>2!FF4@=&AIPH)+RH@'0@=VEN M9&]W("HO"@EH=VYD5&5X=" ]($9I;F17:6YD;W=%>"AH=VYD+"!.54Q,+"!4 M15A40TQ!4U,L($Y53$P@*3L*"@DO*B!I9B!T:&4@=&5X="!W:6YD;W<@=V%S M(&9O=6YD+"!S=&]P(&QO;VMI;F<@*B\*"7)E='5R;B H(&AW;F1497AT("$] M($Y53$P@*3L*?0H*+RH@2!S=')I;F<@:68@;F\@PH)=VAI;&4@*" H*G!C*2 F)B H M*G!C("$]("<@)RD@)B8@*"IP8R A/2 G7'0G*2 I>PH)"6EF("@@*G!C(#T] M("PH)"0ED;R!["@D)"0EP8RLK.PH)"0E]('=H:6QE("@@*'!C6S%= M*2 F)B H*G!C("$]("2AF M:6QE;F\H&ET*$58251?1D%) M3%5212D["@E]"@H)+RH at 0U)3.B!I;FET:6%L:7IE('1H92!35$%25%5024Y& M3R!A;F0 at 8V%L;"!#2!N86UE(" @(" @*B\*"0D) M)G-I4W1A&5C M=71E.B!<(B5S7")<;B(L( H)"0D)"0E'971,87-T17)R;W(H*2P@<'-';G5P M;&]T0V]M;6%N9$QI;F4I.PH)"65X:70H15A)5%]&04E,55)%*3L*"7T*"@DO M*B!#4E,Z(&=I=F4 at 9VYU<&QO="!E;F]U9V@@=&EM92!T;R!S=&%R=" H,2!S M96,N*2 J+PH):68@*"!786ET1F]R26YP=71)9&QE*'!I4')O8TEN9F\N:%!R M;V-EPH)"69P'0@*2!["@DO*B!3=&EL;"!N;R!G;G5P;&]T('=I;F1O M=S\@4')O8FQE;2$@*B\*"0EF<')I;G1F*'-T9&5R2 J+PH)+RH at 0U)3.B!!9&0 at 82!T97-T M('1O('-E92!I9B!G;G5P;&]T(&ES('-T:6QL(')U;FYI;F<_("HO"@E0;W-T M4W1R:6YG*&AW;F1497AT+" B7&YE>&ET7&XB*3L*"@ER971U <8ZCT3.18814$1v5.202282@newscontent-01.sprint.ca> <3821E345.FC6C372F@chello.nl> Message-ID: <3826AE96.F36@mailserver.hursley.ibm.com> Robin Becker wrote: > > In article <3821E345.FC6C372F at chello.nl>, Jan Nijtmans > writes > >Robin Becker wrote: > > > >> I thought stubs were for extensions. The tkinter case is slightly the > >> wrong way round as it starts tcl up. > > > >Stubs can very well be used for applications as well. For example, > >I already used it to Stubify the Tcl plugin, so I don't need to > >recompile it when Tcl8.3 comes out ;-). The only problem is that > >Tcl doesn't yet contain a portable way to use dlopen()/LoadLibrary() > >or whatever this function might be called. > > > ok so what is the minimal way to do this? Does tkinter call Tk_Main (doubtful) ? I would suggest that you do something like. hTcl = dlopen (whatever version of Tcl) createInterp = dlsym (hTcl, "Tcl_CreateInterp"); interp = createInterp (); Tcl_InitStubs (interp, "version", ...); If Tk was a dynamically loadable package then you could do something like Tcl_PkgRequire (interp, "Tk", "version", ...); Otherwise you have to do hTk = dlopen (whatever version of Tk) tkInit = dlsym (hTk, "Tk_Init") tkSafeInit = dlsym (hTk, "Tk_SafeInit") tkInit (interp); Tcl_StaticPackage (tkInit, tkSafeInit, "Tk", "version") At this point you now have a working Tcl and Tk. How you actually choose the version of Tcl and Tk to use is up to you. -- Paul Duffin DT/6000 Development Email: pduffin at hursley.ibm.com IBM UK Laboratories Ltd., Hursley Park nr. Winchester Internal: 7-246880 International: +44 1962-816880 From parkw at better.net Wed Nov 10 06:31:34 1999 From: parkw at better.net (William Park) Date: Wed, 10 Nov 1999 06:31:34 -0500 Subject: Text Manipulation in Python In-Reply-To: References: Message-ID: <19991110063134.A3633@better.net> On Wed, Nov 10, 1999 at 08:46:42AM +0000, Edward Hasted wrote: > I am completely new to Python. > > We want to use it to alter specific lines in template files, typically > something like changing:- > > Variable = 1234 > > to > > Variable = Company Name > > The text manipulation strings within Python seem to work sequentially > rather than on a line basis. > > 1. Is this correct? Well, you have read line by line. Try something like f = open(..., "r") for s in f.readlines(): s = ...do string substitution using 're' or 'string' module... print s But, if you're running Unix, you can also use 'sed'. > 2. What is the best way to do text searching and manipulation within > Python. > > Many thanks, > > Edward > > > -- > http://www.python.org/mailman/listinfo/python-list From emuller at painewebber.com Tue Nov 9 10:23:51 1999 From: emuller at painewebber.com (emuller at painewebber.com) Date: Tue, 09 Nov 1999 15:23:51 GMT Subject: Running a program as another user on Win32 Message-ID: <809ea4$ln$1@nnrp1.deja.com> I am writing a bunch of scripts that will need to run as Administrator (Domain Administrator) on Windows NT 4.0 workstation clients that belong to an NT domain. I've tried using LogonUser, but I always get the following: pywintypes.api_error: (1314, 'LogonUser', ' A required privilege is not held by the client.'). I've also tried using LogonUser with the local Administrator account on my NT machine with no luck. The scripts will be run locally on the system and perform various tasks. The scripts will be used by service technicians and admins. If I can't figure out how to do this in Python I'll have to use WinBatch, which supposedly can do this (Run programs as another user)... Any ideas how I can do this? Help! I don't want to use winbatch. Sent via Deja.com http://www.deja.com/ Before you buy. From fbi at boxer.no Tue Nov 9 08:47:49 1999 From: fbi at boxer.no (Frank Biringer) Date: Tue, 09 Nov 1999 14:47:49 +0100 Subject: Writing dates to a ODBC-database Message-ID: <38282605.3CD233E9@boxer.no> Does anybody know how to write a date to a ODBC-database? I use the standard dbi- and odbc-modules for the Python-win32 distribution. I guess I have to create a dbi.dbiDate object. But since there's neither source or documentation for the dbi-module I don't know what kind of parameter this method expects (it expects exactly one parameter). Any ideas?? -- Regards, _________ -|- rank Biringer. ______________________________________________________ Systemanalytiker Boxer Technologies AS tel: (+47) 55 19 20 34 mailto:fbi at boxer.no fax: (+47) 38 01 90 01 http://www.boxer.no/ ______________________________________________________ From a_stepanov at yahoo.com Sat Nov 6 22:52:37 1999 From: a_stepanov at yahoo.com (Alexander Stepanov) Date: Sat, 06 Nov 1999 22:52:37 -0500 Subject: Python and generating images for web Message-ID: <3824F785.40DF4393@yahoo.com> Hello, I am a newcomer to web programming and python. I need to create a small web application to make some charts based on user's data input. Is it possible to generate gif or png images on a fly using Python? I will appreciate if you point me out accessible chart/plot modules and libraries as well as documentation and working sites. Any additional information is strongly welcome. (I am in a process of comparison Perl and Python to solve this problem. I plan to use the application under WindowsNT4.0 environment + Perl? or Python interp-r). Sincerely, Alexander email: a_stepanov at yahoo.com From arad at fc.hp.com Sat Nov 6 22:29:07 1999 From: arad at fc.hp.com (Arad Rostampour) Date: Sat, 6 Nov 1999 20:29:07 -0700 Subject: win32com and IIS? Message-ID: <802s6a$mj5$1@web1.cup.hp.com> Hi, I've been using win32com to access IE and get webpages using: import win32com.client ie = win32com.client.Dispatch("InternetExplorer.Application") ie.Navigate("http://www.hp.com") ... This works fine from the command line. But, when I try to do this from a CGI script under IIS, I get the following error: File "f:\python\win32com\client\dynamic.py", line 319, in __getattr__ raise pythoncom.com_error, details pywintypes.com_error: (-2147467259, 'Unspecified error', (0, None, None, None, 0, -2147467259), None) Exception exceptions.AttributeError: in ignored Any ideas on how to work around this? Thanks, Arad -- Arad Rostampour- arad at fc.hp.com NT Platform and I/O Team Software and System Development Lab Hewlett-Packard From jam at quark.emich.edu Wed Nov 24 17:31:28 1999 From: jam at quark.emich.edu (Jeff) Date: Wed, 24 Nov 1999 17:31:28 -0500 Subject: newbie question In-Reply-To: <943469319.838266356@news.teleweb.at> References: <943469319.838266356@news.teleweb.at> Message-ID: <19991124173128.A26194@quark.emich.edu> On Wed, Nov 24, 1999 at 06:57:02PM +0000, Markus Krutz wrote: > How the f*** do I create a string containing a *single* "\" ? > > regards > Markus > [~] [5:30pm] [jam at toast-pts/3] % 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 >>> a = "\\" >>> print a \ piece-of-pie-ly y'rs, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From tbryan at python.net Thu Nov 11 21:12:09 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Thu, 11 Nov 1999 21:12:09 -0500 Subject: ASCII delimited files References: <942231502.1914033961@news.interbusiness.it> <382A240B.B247AD6B@python.net> <382A2801.FDE3CA09@python.net> <382A4330.833C4EBD@easystreet.com> Message-ID: <382B7779.9601F556@python.net> Al Christians wrote: > > There's a trick with files of delimited fields. If a string field > contains a delimiter (e.g. a comma in a csv file), then the field > gets enclosed in quotes. Ah. That's probably what the poster wanted! I just posted what I had lying around on my machine. In my case, I had to deal with basically those three field types, numeric values in a range, values from a list, and values that matched a regex (like a date). They never contained the delimeter (usually a tab or the pipe '|' character). I guess I should have said that it helped me, but YMMV. :) The big problem for me was that the values came from hardware that sometimes garbled dates or did other nasty things. The format of the file (number and ordering of the columns) wasn't set in stone either, so I needed the capability to detect whether a new data file given to me possibly deviated from the one the parser expected. Thus, the ability to build a parser quickly that would validate the data was what I wanted. I still like my idea since, in my opinion, one of the worst things is loading corrupt data into a database. The parser code should deal with delimiter characters nested in the values. I don't need it, and I lack sufficient leisure time to do it just for fun right now. If somebody else has the need/time, feel free to take the code and make something really usable out of it. ---Tom > What I usually wind up doing to circumvent these problems with delimited > files is loading them back into a spreadsheet, typically the same one > that wrote them (I suppose that a database program would > offer the same option), and then I write them out as tab-delimited. > Tabs within fields are just about never in a lifetime in my work, so > far. From tim_one at email.msn.com Tue Nov 30 01:59:45 1999 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 30 Nov 1999 01:59:45 -0500 Subject: performance of tuple-less Python? In-Reply-To: Message-ID: <000301bf3b00$7c775f60$c92d153f@tim> [Greg Wilson] > Has anyone ever built a version of Python that didn't include tuples, > and looked at the performance of code that consistently used lists > instead? I'm curious as to whether the use of tuples (which I believe > are conceptually redundant) They do differ semantically, due to immutability (see other msgs). > actually has a significant positive impact on the interpreter's > performance on non-trivial codes (i.e. once caching, instruction > ordering, and all other effects have come into play). tuple[i] and list[i] access have (up to accidents of architecture) identical cost; tuple[i] may be faster in pathological cases because of cache effects (a tuple's object header is contiguous with the tuple's content vector; a list's object header is not generally contiguous with the list's content vector). A predictably bigger effect is that allocating a list object requires two malloc() calls (one for the object header, another for the content vector). Allocating a tuple object typically requires no malloc calls (because tuples are expected to be short, Python maintains internal free lists of tuples of various small sizes, and recycles them directly from there). Similarly, destroying a list requires two free() calls, while destroying a tuple typically just links it onto the appropriate internal free list. So creation and destruction of tuples goes faster, and tuples are more memory-efficient. Indeed, I've had larger programs that wouldn't run at all on a 32Mb machine (constant disk thrashing) before I changed lists to tuples! That doesn't mean all possible implementations would have these characteristics; they're the truth for the implementation that exists, though. if-tuples-didn't-exist-someone-would-invent-them-ly y'rs - tim From paul at digicool.com Mon Nov 8 07:48:31 1999 From: paul at digicool.com (Paul Everitt) Date: Mon, 08 Nov 1999 07:48:31 -0500 Subject: Production Web Deployment? References: Message-ID: <3826C69F.B4E26B89@digicool.com> Dirk Leas wrote: > I've read numerous threads regarding how to deploy Python on the web and > there appears to be no real consensus on what actually performs/scales well > (about 3M hits/month). Is anybody taking lots of hits with httpdapy, > PyApache, ASP+Python, fastcgi, or Zope? I've got a customer who's > development staff is struggling with the complexity of Java Servlets and > they're already using a large 3rd party, vertical Python application (and > several folks already use Python). Peliminary testing showed plain CGI was > just too slow... Zope.org seems to be doing up to 2M hits/month quite easily, and it's a pretty complicated site (many of the pages are generated by catalog queries to the index). Over the last couple of weeks we had some inexplicable slow spots, which turned out to be caused by accidentally setting the object cache way too low (200 instead of 4000). Note that Zope.org doesn't use a relational database for any content. As far as I can tell, performance on Zope.org is quite snappy right now. It's running on a sub-$1k machine (a vanilla PIII-550 with 256 Mb RAM and an IDE drive). I'd expect it to do four or five times more hits before it appears sluggish. As mentioned in another reply, keeping database connections open is quite important. Zope does a good job at this and some of the database adapters are pretty well optimized (Oracle and Sybase particularly). Hopefully over the next month we'll migrate Zope.org away from PCGI (a Zope system for getting requests from the web server to the long-running process) to FastCGI. This will eliminate execution of small C "wrapper" executable. Finally, Digital Creations has a commercial-with-source-plus-consulting solution called ZEO: http://www.digicool.com/Solutions/ZEOFactSheet.pdf This lets you spread your object system across multiple machines/locations. --Paul From parkw at better.net Sun Nov 14 07:18:33 1999 From: parkw at better.net (William Park) Date: Sun, 14 Nov 1999 07:18:33 -0500 Subject: Python and sending emails with it In-Reply-To: <382E2DB2.A00B9109@nv2.cc.va.us> References: <382E2DB2.A00B9109@nv2.cc.va.us> Message-ID: <19991114071833.B2775@better.net> On Sat, Nov 13, 1999 at 10:34:10PM -0500, Jeremy Misavage wrote: > I'm kinda new to python and I'm trying to write a small program that will take > in form data, save it in a db, and then send an email to a person. > > The program processes a users request for a "equipment request." It gets > loggged in a db (already done) and sends an email to the person in change of the > equipment. I need help on the email part. Does some out there have some code > that will taken data and send it to a person. It shouldn't need a username and > password, but if it does I'll live with that. In Python, try 'smtplib' module. I think it goes something like e = smtplib.SMTP('machine.com') e.sendmail('tekhir', 'supervisor', "...") e.quit() Or, if you use Linux machine (like me), pipe the message to mail -s "subject" supervisor Yours truly, William Park From skip at mojam.com Mon Nov 29 15:59:01 1999 From: skip at mojam.com (Skip Montanaro) Date: Mon, 29 Nov 1999 14:59:01 -0600 (CST) Subject: Python bugs In-Reply-To: <51C9F3C392D0D111A15600A0C99E64A9AF5690@localhost> References: <51C9F3C392D0D111A15600A0C99E64A9AF5690@localhost> Message-ID: <14402.59669.289009.979094@dolphin.mojam.com> Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import os >>> {}.update(os.environ) Traceback (innermost last): File "", line 1, in ? TypeError: dictionary, instance >>> import shelve >>> s = shelve.open('foo') >>> s.get('bar', 'baz') Traceback (innermost last): File "", line 1, in ? AttributeError: get >>> I believe os.environ is a class to allow constructs like os.environ["FOO"] = "PYTHON" to work like os.putenv("FOO", "PYTHON") with regard to setting or changing the values of environment variables. The lack of a get attribute in shelve objects seems to have been rectified since the 1.5.2 release: >>> db = shelve.BsdDbShelf (bsddb.btopen("/var/tmp/foo2", "c")) >>> db["1"] = 1 >>> db.keys() ['1'] >>> db.get("1", 0) 1 >>> db.get("2", 0) 0 Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/ 847-971-7098 | Python: Programming the way Guido indented... From fredrik at pythonware.com Wed Nov 10 07:03:58 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 10 Nov 1999 13:03:58 +0100 Subject: Python company worth $100M References: <38295BC2.13E2E31F@digicool.com> Message-ID: <033201bf2b73$ad1e49e0$f29b12c2@secret.pythonware.com> Paul Everitt wrote: > Nice guys _don't_ finish last, it seems. Congrats to Scott and Sam, and > yippee for us, because this is good news! here's another interesting story: http://cnbc.com/commentary/commentary_full_story_stocks.asp?StoryID=6926 "Searchbutton.com Inc. is a rare breed of Silicon Valley start-up. The CEO of the nine-month-old firm says his company will actually be making money before it goes public, which could happen as early as next year." "I'd certainly buy the stock when they go public," says Darcy Fowkes, an analyst with the Aberdeen Group /.../ They have exactly the things Wall Street looks for." and if you look at the technical credits page, what do you find? http://www.searchbutton.com/misc/technicalCredits asynclib again, of course ;-) From rm at murl.com Tue Nov 9 09:54:25 1999 From: rm at murl.com (Robert Meegan) Date: Tue, 09 Nov 1999 14:54:25 GMT Subject: [Python] header (fwd) In-Reply-To: References: Message-ID: <19991109.14542500@robert.polytopic.com> >>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<< On 11/8/99, 5:13:19 PM, Benoit Ciceron wrote regarding [Python] header (fwd): > can we get an automatic subject header : "[Python]" to ALL messages > submitted to the list , including replies and newsgroup threads ? > thank you, > ben_ If what you want is a way to filter mailing list messages, may I suggest that you look for "python-list" in both the "To:" and "CC:" fields. If you would like to sort your mail, "[Python]" is not adequate, as you will need to add the capability to move all of Guido's and Tim Peters' mail to the top while moving anything with "Perl" in the subject or body to the bottom. --- Robert > -- > http://www.python.org/mailman/listinfo/python-list From fredrik at pythonware.com Wed Nov 10 05:51:00 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 10 Nov 1999 11:51:00 +0100 Subject: [Python-Dev] I18N Toolkit References: <19991109135839.25864.rocketmail@web607.mail.yahoo.com><199911091646.LAA21467@eric.cnri.reston.va.us><14376.22527.323888.677816@amarok.cnri.reston.va.us><199911091726.MAA21754@eric.cnri.reston.va.us><14376.23671.250752.637144@amarok.cnri.reston.va.us><14376.25768.368164.88151@anthem.cnri.reston.va.us> <14376.30652.201552.116828@amarok.cnri.reston.va.us> <027101bf2b68$6a286a90$f29b12c2@secret.pythonware.com> Message-ID: <028501bf2b69$7a527d10$f29b12c2@secret.pythonware.com> I wrote: > a slightly hairer design issue is what combinations > of pattern and string the new 're' will handle. and posted it to the wrong list. sorry for the confusion. From cfelling at iae.nl Tue Nov 9 14:47:52 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 9 Nov 1999 20:47:52 +0100 Subject: making the Python case to my dept. References: <9911051740130D.02530@william.jinsa.org> <7GOU3.272$Ae3.194028@news-dal.corridex.com> <801p16$10s$1@vvs.superst.iae.nl> Message-ID: <809tp8$1ek$1@vvs.superst.iae.nl> Evan Simpson wrote: > http://www.alice.org thanks, looks good, but elas not on linux, and no room on my windows disk, so I've to wait a few weeks -- groetjes, carel From boud at rempt.xs4all.nl Tue Nov 30 01:59:15 1999 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 30 Nov 1999 06:59:15 GMT Subject: XPython (X11) References: <383E5350.1E07536A@xrce.xerox.com> <81ms2n$126$1@essle.valdyas.org> Message-ID: <81vsk3$g8$3@essle.valdyas.org> Rob Hodges wrote: > bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) writes: > I'm struggling a bit to understand why you say that in this context. > I can't speak for pyKDE (although I imagine the situation is the > same), but developing with pyGnome doesn't imply a 'tying' to Gnome; > only that the Gnome libs must be available in addition to the GTK libs > -- just as you must have wxwin in addition to GTK to run wxpython > apps. One advantage of PyGnome over straight PyGtk is that it offers > the Gnome Canvas widget, which can be useful whether the user is > running Gnome or not. Likewise, one of the strong points of PyKDE is the KHTMLView widget, which can be put to good use in a lot of applications. And I like things like global key accelerators. Anyway, any app where you can't easily substitute one gui for another has some design flaws. -- Boudewijn Rempt | http://denden.conlang.org From jcosby at wolfenet.com Tue Nov 23 20:32:45 1999 From: jcosby at wolfenet.com (Jon Cosby) Date: Tue, 23 Nov 1999 17:32:45 -0800 Subject: Problems configuring Personal Web Server Message-ID: <81ff61$c4e$1@sparky.wolfe.net> I need help configuring MS Personal Web Server to run Python CGI scripts. I've followed the steps given on Aaron Watters' web page (http://starship.python.net/crew/aaron_watters/pws.html), but my server isn't recognizing my scripts as executables; I'm being prompted to download them instead. It worked for me in Windows 95, I'm in Windows 98 now. I can't see any other difference. I've checked my registry editor over and over, and everything looks right. Any guesses as to what I'm overlooking? -- Jon Cosby E-mail: jcosby at wolfenet.com Website: http://www.wolfenet.com/~jcosby/ From m.faassen at vet.uu.nl Mon Nov 15 10:38:36 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 15 Nov 1999 15:38:36 GMT Subject: Beginning programming with Python References: <382B3A53.5816B2@callware.com> <382B3D79.74CD3E0F@email.sps.mot.com> Message-ID: <80p9ds$ppo$1@newshost.accu.uu.nl> "Aaron Ginn (rp2885)" wrote: > An honest opinion, please; is Python better suited for beginners than Perl, as > I've heard? You're asking in the Python newsgroup, so here's my honest opinion: Yes. I was an experienced programmer (C, C++, Pascal, and some glancing familiarity with a host of other languages) when I learned Python. Before I looked at Python, I struggled a few weeks trying to teach myself Perl. Then I downloaded the Python tutorial, read it in about an hour, and I never looked back. I could program in Python from then on. Python was much much easier for me to learn. I could reason about the right syntax for things, while with Perl I was constantly checking the documentation. This was of course the example of an experienced programmer, but I think it'll be true for beginners too. The multiplicity of syntax of Perl to do the same thing, and the odd syntax to do certain things will confuse beginners, and will also teach the wrong idea to beginners; programming is not about syntax gimmicks. With perl you could be tempted to learn lots of snippets and tricks to solve a problem and how to assemble these to a working program. Lots of copy&paste programming, and lots of 'how do I do this in Perl' questions. With Python you can focus more on the underlying structure, the semantics, of the program. Then again, this is a biased opinion. There are arguments why Perl would suit the human mind better *because* it is so syntactically variable and complicated. I don't believe in these arguments myself. Python has a clean and powerful syntax. Perl has just a powerful syntax. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From edward at corpex.com Wed Nov 10 03:46:42 1999 From: edward at corpex.com (Edward Hasted) Date: Wed, 10 Nov 1999 08:46:42 GMT Subject: Text Manipulation in Python Message-ID: I am completely new to Python. We want to use it to alter specific lines in template files, typically something like changing:- Variable = 1234 to Variable = Company Name The text manipulation strings within Python seem to work sequentially rather than on a line basis. 1. Is this correct? 2. What is the best way to do text searching and manipulation within Python. Many thanks, Edward From grant.griffin at iowegian.com Sun Nov 7 10:47:36 1999 From: grant.griffin at iowegian.com (Grant Griffin) Date: Sun, 07 Nov 1999 15:47:36 +0000 Subject: python: something completely different References: <3820C0B8.62B2@iowegian.com> <38249ED2.BB7EA1DE@znet.com> <8028jv$7cf$1@hub.org> Message-ID: <38259F18.437@iowegian.com> Patty Thomas wrote: > > On Sat, 06 Nov 1999 13:34:10 -0800, Robert Cain wrote: > >Back to the subject at hand (Python in the DSP universe) has anyone > >investigated the possibility of conversion, compilation or whatever of > >MatLab to Python? I'm naive WRT to both at this point because 1) MatLab > > I know nothing about MatLab, but a quick search here > http://www.vex.net/~x/parnassus/apyllo.py?so=d&find=matlab reveals that it > would seem Travis Oliphant has some MatLab like tools (or functions at least) > which could be useful until someone 'converts, compiles, or whatever', > matlab to python here... http://oliphant.netpedia.net/ As you suggest, Travis is creating a Matlab-like "Signal Processing Toolbox" for Python. I don't know if a Matlab-to-Python translator is currently available, but if not, I don't think it would be all that hard to write one (in Python, of course). =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From greg.ewing at compaq.com Fri Nov 19 03:57:53 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Fri, 19 Nov 1999 21:57:53 +1300 Subject: Type/Class Unification in Ruby References: <3819BCDA.AC4FD4CA@strs.co.uk> <87k8o2x67f.fsf@ev.netlab.co.jp> <7vjtrc$hmm$1@newshost.accu.uu.nl> <38204614.2EAC6051@compaq.com> <5ld7trtak5.fsf@eric.cnri.reston.va.us> <3826D63C.2731BB1F@compaq.com> <38328948.9E35556F@compaq.com> Message-ID: <38351111.6B3E08C5@compaq.com> Clemens Hintze wrote: > > But it is worth mentioning, that Ruby features > single inheritance *by*purpose*. Not because of the implementation > details! I wasn't making a value judgement, only pointing out that Ruby's solution is as simple as it is because of this restriction. > If it would implement multi-inheritance, the class structure could > e.g. use an array of pointer to all such C structs, not only one > pointer, as implemented now! Sure, Python could do something like that too. But it would get very hairy and complicated and probably slow everything down a lot, casting doubt on whether it's worth the effort. A middle ground might be to allow inheriting from any number of user-defined classes, but at most one built-in type. > The second (preferred) way is, to build instances of class DATA > wrapping the C struct you have allocated for your extension. Yes, I know, but what I was saying still applies in that case. All the methods of the extension class expect the DATA object to be pointing to their own particular kind of struct, and because of the inheritance structure, this is always true -- so they don't need to bother checking. > Deriving a Ruby class coded in C from another one also coded in C, > seems to be the only right tricky part of that language, IMHO. :-) I think it will work as long as the derived class makes sure that its C structure is an exension of the superclass's C structure. > Greg> [global instance var dict] might cause ref counting > Greg> problems. > > Once again, thanks for Ruby's true garbage collection! :-) Garbage collection alone doesn't actually solve the problem; the references from the global dict need to be treated as weak references somehow under either scheme. I haven't looked, but presumably Ruby must be ignoring the global dict refs when marking, and cleaning them up whenever a builtin or extension object is deallocated. Python could be made to do the equivalent. > The big exception, > AFAIK, was class Fixnum. It never had any instanciation method, as it > doesn't wrap any struct. Yes, that's the one class you really can't instantiate a subclass of, since its class is totally implicit. But it's not clear whether it's any use having something like a UserFlonum, either, even though technically it could be done. Unless you override every method, any arithmetic on it would return an ordinary Flonum. And if you are going to override every method, it might as well be a totally new class! > Often it is better to use the module > mechanism to add methods to class Array or some of its instances > during runtime. You mean you can add methods to an *existing* class that way? Not sure if I like that idea... Greg From endgamer71 at hotmail.com Tue Nov 9 08:52:46 1999 From: endgamer71 at hotmail.com (Endgamer) Date: Tue, 09 Nov 1999 13:52:46 GMT Subject: Another bloody newbie question: Executable Python files? Message-ID: <382821f1.96924220@212.225.36.99> Is it possible (I know it's not required) to compile a Python program to be stand-alone? Or is it required that Python be installed on every machine the program runs on? I'm working with Windows machines, and I'm writing this little script I need to have run on each machine (of about 20) at startup - I'd prefer not to have to install Python on each machine! Thanks in advance... Endgamer Spider Warrior (Endgamer71 at spamtrap.hotmail.com) ##################################### Not a quote, just an on-the-spot observation: You know you're a geek when your PC costs exactly 15 times as much as your stereo. And gives better sound quality. Endgamer ##################################### From a.eyre at optichrome.com Wed Nov 24 12:25:23 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Wed, 24 Nov 1999 17:25:23 -0000 Subject: SMTP? In-Reply-To: <19991124171120.1623.qmail@hotmail.com> Message-ID: <003301bf36a0$e3bf3710$3acbd9c2@peridot.optichrome.com> > send: 'mail FROM: size=10\015\012' > reply: '250 , Sender accepted\015\012' > reply: retcode (250); Msg: , Sender accepted > send: 'rcpt TO:\015\012' > reply: '250 , Recipient ok\015\012' > reply: retcode (250); Msg: , Recipient ok > send: 'data \015\012' > reply: '354 Enter mail, end with .\015\012' > reply: retcode (354); Msg: Enter mail, end with . > data: (354, 'Enter mail, end with .') In here you might need to put in standard RFC822 headers. From: xxx at yyy To: aaa at bbb Subject: Not a lot [Blank line here to indicate end of headers] Message here > send: 'Small msg\015\012' > send: '\015\012.\015\012' > reply: '250 Ok, message saved\015\012' > reply: retcode (250); Msg: Ok, message saved > data: (250, 'Ok, message saved') > send: 'quit \015\012' > reply: '221 See ya in cyberspace\015\012' > reply: retcode (221); Msg: See ya in cyberspace Check the RFC, but I think the only important bit is the blank line to indicate end of headers. -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From viruswall at bam.com Thu Nov 25 16:24:54 1999 From: viruswall at bam.com (viruswall at bam.com) Date: Thu, 25 Nov 1999 16:24:54 -0500 (Eastern Standard Time) Subject: InterScan NT Alert Message-ID: <199911252130.QAA13064@python.org> Sender, Bell Atlantic Mobile has detected virus(es) in your e-mail attachment. Please take the appropiate action to protect your workstation with virus protection software or install the latest virus signature file. Date: Thu, 25 Nov 1999 16:24:54 -0500 (Eastern Standard Time) Method: Mail From: To: File: Happy99.exe Action: clean failed - deleted Virus: TROJ_SKA From mikael at isy.liu.se Fri Nov 5 04:31:03 1999 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 05 Nov 1999 11:31:03 +0200 (MET) Subject: __str__ vs. __repr__ In-Reply-To: <19991105102233.I29354@xs4all.nl> Message-ID: On 05-Nov-99 Thomas Wouters wrote: > We're too busy bitching about the idiocy of people who expect to change > a country's (usually) ancient currency, habits and not to mention every > keyboard, font and accountancy software in the world in a matter of years. > Or perhaps we just dont _care_ about the euro symbol. Your Euro symbol, by > the way, Tim, ended up as '?' in my font -- but possibly because isprint() > returned 0 and my mail-reader therefor refused to print it ;) Actually, many European currecies are not more than approximately 100 years old, and so are many of the countries as well. That's not so ancient to me. But it's true; many of us don't care. /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: 05-Nov-99 Time: 11:26:19 This message was sent by XF-Mail. ----------------------------------------------------------------------- From cfelling at iae.nl Mon Nov 8 17:06:12 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 8 Nov 1999 23:06:12 +0100 Subject: a simple helper class for parsing command line options References: Message-ID: <807hgk$289$1@vvs.superst.iae.nl> In article you wrote: > I threw this together to make parsing command line options and arguments > a little easier than just using getopt directly. Feedback welcome. Sorry for reacting so late, but it took some time to cough up a responce. (or actually to build my own option state machine) Besides being publically accused of Perlish behaviour made me hesitate to react:), but now that no one else has... A bunch of nice ideas: inspired me to adjust it, rewrite it and eventually write my own:), But what would you expect with something so close to the look of ones program and moreover from a Dutch man. > class OptionFactory: this triggered me to see option parsing as a state machine > self.__options = [('help','h','help','','print this help message')] I personally have some problems reading all those quotes, so I would prefer something more friendly like: self.__options = [('-h, --help : print this help message')] > self.__dict = {} a seperate dict for the state, I keep that:) (though I would call it __state, less likely to be confused with __dict__) > def __getitem__(self, item): > return self.__dict[item] and these, ofcourse > def add_options(self, options): > """ > label = identifier for the option, used to retrieve option value my problem here is, why should I specify an extra identifier, I could as well use the short and or long flags themselves and enhance __getitem__ to deal with that. > value = descriptive string of the value the option requires it took a while before I stopt forgetting that you refer here to the optional argument to the option flags and not to the actual value specified on the command line. Well that just shows how silly I am. > def add_argdesc(self, argdesc): > """ add a description of the expected arguments """ Great. I would add a similar one to allow for the replacement of the default [OPTIONS...] string as well as it is hard to construct a meaningfull option list automagically. > def usage(self): a lot of code, necessary to join the flags part of the description. In my previously proposed variant, this flags part could be used almost without any massaging. And what about multiline descriptions? > def parse(self, argv): > """ pass in sys.argv, not sys.arv[1:] """ or define a default value like: def parse(self, argv=argv[1:]): > self.name = argv[0] definitatively > try: > optlist, args = getopt(argv[1:], self.__shortstring, self.__longlist) > for opt in optlist: > self.__process_opt(opt) > self.args = args > except error, x: > msg = 'Error parsing options: %s' % x > sys.stderr.write('%s\n' % msg) > sys.stderr.write('\n%s\n' % self.usage()) > sys.exit(1) nice to catch getopt.error here, though I myself would prefer a short responce to stderr refering to the use of the --help option. Just hate to have to scroll back just to see what I was doing:) For those interested: I redid the above, treating option parsing more like transitions in a state machine. Using that module one can say things like: options = OptionState(test=0, verbosity=0) add = options.add_option add('-t, --test : just testing', test=1) add('--version : show the version and exit', options._version) add('--help : show this help message', options._help) add('-v : increment the verbosity', options._inc, 'verbosity') add('-V : increase verbosity with 5', options._inc, 'verbosity', 5) add('-D : set verbosity to 11', options._int, 'verbosity', 11) add('-x : ', x=1) # secret option, not displayed in help message! ... if options.verbosity > 8: pass if options['test']: pass if options.x or options.has_option('x'): pass One can also keep a list of values of repeated option flags, or easily enhance this state machine with your own special purpose transitions. -- groetjes, carel -- groetjes, carel From mal at lemburg.com Mon Nov 1 04:56:26 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Mon, 01 Nov 1999 10:56:26 +0100 Subject: os.popen() and (IDLE, PythonWin) ? References: <3819DD05.FF6656C3@lemburg.com> Message-ID: <381D63CA.9073803D@lemburg.com> "M.-A. Lemburg" wrote: > > [os.popen('ver') fails under IDLE and PythonWin, yet works under "normal" > Python] Ok, I found the FAQ entry on this: 7.13. Why doesn't os.popen() work in PythonWin on NT? The reason that os.popen() doesn't work from within PythonWin is due to a bug in Microsoft's C Runtime Library (CRT). The CRT assumes you have a Win32 console attached to the process. You should use the win32pipe module's popen() instead which doesn't depend on having an attached Win32 console. Example: import win32pipe f = win32pipe.popen('dir /c c:\\') print f.readlines() f.close() Under PythonWin this is no problem (although I wish os.popen would automatically choose the different approach for me in the above setup). Yet under IDLE I have a problem: win32 doesn't have to be installed... is there some other workaround ? -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 60 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From mwh21 at cam.ac.uk Tue Nov 30 10:31:41 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 30 Nov 1999 15:31:41 +0000 Subject: Python complaints References: <81bmmi$279$1@nnrp1.deja.com> <3841EE77.6B5D6AC9@wjk.mv.com> <38435C43.B238EC15@mindspring.com> Message-ID: wware-nospam at world.std.com (Will Ware) writes: > Will Ware wrote: > > I find myself grumbling about having to type "x = x + 1". The really > > clean thing to do, given that integers are objects, would be to define > > increment and decrement methods, so you'd type something like "i.incr()". > > Jesse D. Sightler (jsight at mindspring.com) wrote: > > Wouldn't this be impossible, since Integers are also immutable? So, eg, > > i.incr() could only return an incremented version of i, but not actually > > increment i? > > Right, this is what Gordon was pointing out. A "++" method could not > magically reach out of its object, find the "i" variable, and bind it > to the incremented value. Hate to be awkward, but when it comes to things like this, there's very little like this that can't be done in Python! >>> def incr(var): try: raise 1/0 except ZeroDivisionError: import sys,dis f = sys.exc_traceback.tb_frame.f_back loadins = f.f_code.co_code[f.f_lasti - 3:f.f_lasti] loadop = ord(loadins[0]) name = dis.opname[loadop] loadarg = ord(loadins[1]) + 256*ord(loadins[2]) vname = f.f_code.co_names[loadarg] f.f_locals[vname] = f.f_locals[vname] + 1 >>> x=1 >>> incr(x) >>> x 2 well, it works in the IDLE shell window... I'll stop now ;-). > Something like this could be accomplished by tinkering with Python's > parser, but that wouldn't be a great idea. As above, not necessary. > A lot of work for something that would never find wide acceptance. That much is true! Cheers, Michael From usenet-mm-yyyy at julesallen.com Wed Nov 10 19:51:43 1999 From: usenet-mm-yyyy at julesallen.com (Jules Allen) Date: Thu, 11 Nov 1999 00:51:43 GMT Subject: IPC8: Call the 800 number! References: <3826f6ac.0@news.bestsoftware.com> Message-ID: In article , Robin Dunn wrote: | We called the 800 number and they still didn't know about it. They did | however have an $84 room that I snached up faster than they could say "Would | you like that one?" Now I just hope it's in the right hotel and not next to | the dumpster or something... Actually that $84 room *is* a dumpster... -- Want to mail me? Put the current numeric month and year in the obvious place. From Gareth.McCaughan at pobox.com Thu Nov 25 15:52:26 1999 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: 25 Nov 1999 20:52:26 +0000 Subject: Python complaints References: <1268673769-3409210@hypernet.com> <86puwz4jhp.fsf@g.local> <14397.6317.426060.330244@gargle.gargle.HOWL> Message-ID: <86iu2q2t11.fsf@g.local> Charles Waldman wrote: > You can often (ab)use dictionaries to get a ?:-like effect, as in this > construction: > > def p(score): > print "You scored %d point%s" % (score, {1:''}.get(score,'s')) That's disgusting. But very neat. :-) -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From nbecker at fred.net Mon Nov 1 13:20:01 1999 From: nbecker at fred.net (nbecker at fred.net) Date: 01 Nov 1999 13:20:01 -0500 Subject: Need Berkley DB!! References: <381D5E84.98931682@bibsyst.no> <14365.51195.136678.559903@dolphin.mojam.com> Message-ID: You shouldn't need to compile db - your linux already comes with it. >From /usr/include/db.h: #define DB_VERSION_STRING "Sleepycat Software: DB 2.4.14: (6/2/98)" From MHammond at skippinet.com.au Fri Nov 5 17:29:27 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Fri, 05 Nov 1999 22:29:27 GMT Subject: Accessing Word object model from Python COM server References: <3822a7d2.251040356@news.mch.sni.de> Message-ID: Nikolai Kirsebom wrote in message <3822a7d2.251040356 at news.mch.sni.de>... > >When the GetNew method in the Python COM server is executed, an error >indicates that the name 'Documents' is invalid. The self.ApplObj is >of type PyIDispatch (I think), however may it must be an 'instance' in >order to be able to access the object model. If I instead of This is correct. What you need to do is doc = win32com.client.Dispatch(doc) This will wrap it in the Python class that manages all the magic. Mark. From fredrik at pythonware.com Sat Nov 20 06:03:37 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 20 Nov 1999 12:03:37 +0100 Subject: Displaying an array as an image References: Message-ID: <006101bf3346$e6264be0$f29b12c2@secret.pythonware.com> David Fenyes wrote: > Is there an easy way to display a 2D array as an image using just > Tkinter? I'm aware of a TK Image canvas widget, but can't find docs > on how to use it or what an 'image' is supposed to consist of. I'm > just evaluating numerical python as a platform and this is a pretty > important functionality that is not really addressed in any of the > readily available docs. see the attached message. and remember that python.org's search facility is your friend. > PIL and friends seem to be more oriented to reading/writing image > formats, and are not really what I'm looking for. since you obviously don't know what PIL can do for you, how can you be so sure? check out: http://www.pythonware.com/library/pil/handbook/imagetk.htm and the demo scripts in the source distribution. Newsgroups: comp.lang.python From: "Fredrik Lundh" Subject: Re: Tkinter PhotoImage Question Date: Fri, 12 Nov 1999 16:06:38 +0100 Ivan Van Laningham wrote: > Ok, I've managed to create an image, using xx=PhotoImage(file), and I > can retrieve pixel values from that image using xx.get(x,y). > > Now I want to use the put() method to write a pixel. > > How do I do that? I would have expected that put() would take a string > of pixel values for the data argument, but that doesn't seem to be the > case. ... from the eff-bot archives: # # create a greyscale ramp using pure Tkinter # # fredrik lundh, january 1998 # # fredrik at pythonware.com # http://www.pythonware.com # from Tkinter import * # must initialize interpreter before you can create an image root = Tk() data = range(256) # 0..255 im = PhotoImage(width=len(data), height=1) # tkinter wants a list of pixel lists, where each item is # a tk colour specification (e.g. "#120432"). map the # data to a list of strings, and convert the list to the # appropriate tuple structure im.put( (tuple(map(lambda v: "#%02x%02x%02x" % (v, v, v), data)),) ) # resize the image to the appropriate height im = im.zoom(1, 32) # and display it w = Label(root, image=im, bd=0) w.pack() mainloop() # after playing with this a little, you'll love # the Python Imaging Library. From skip at mojam.com Wed Nov 24 14:10:25 1999 From: skip at mojam.com (Skip Montanaro) Date: Wed, 24 Nov 1999 13:10:25 -0600 (CST) Subject: whitespace.py module In-Reply-To: References: Message-ID: <14396.14369.586465.200108@dolphin.mojam.com> Rajesh> I'm new to the python language, and the newsgroup. So, if this Rajesh> newsgroup is not appropriate for this type of posting, please Rajesh> pardon my ignorance and notify me. Perfectly appropriate. Rajesh> I have written up a module called `whitespace.py' available at Rajesh> Rajesh> and a sample program `whitespace' which uses this module, also available at Rajesh> the same URL. Have you checked out tabnanny in Tools/scripts/tabnanny.py of the Python distribution? A merging of interests might be useful. I suspect the two scripts detect similar problems. Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/ 847-971-7098 | Python: Programming the way Guido indented... From mcfletch at vrtelecom.com Wed Nov 17 00:06:45 1999 From: mcfletch at vrtelecom.com (Mike Fletcher) Date: Wed, 17 Nov 1999 00:06:45 -0500 Subject: list.without()? In-Reply-To: <19991116221403.D7366@krikkit.vollmert.home> Message-ID: Nope, not a big difference. Requires a few extra steps if the original list is [], testing for list "truth" is pretty fast. Cheers, Mike -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Robert Vollmert Sent: November 16, 1999 4:14 PM To: python-list at python.org Subject: Re: list.without()? ... Would it make a big difference if while temp: were replaced by while 1: ? ... From shouldbe at message.com Tue Nov 16 14:24:18 1999 From: shouldbe at message.com (Arinte) Date: Tue, 16 Nov 1999 14:24:18 -0500 Subject: Final classes like in java??? Message-ID: <80sao7$1848$1@rtpnews.raleigh.ibm.com> Is there a way you can define your python class to be final or not able to be inherited from? From fredrik at pythonware.com Tue Nov 30 03:45:04 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 30 Nov 1999 09:45:04 +0100 Subject: Embedded size? References: <3842cf05.407909516@news.earthlink.net> Message-ID: <022501bf3b14$9445a480$f29b12c2@secret.pythonware.com> freshhorses at earthlink.net wrote: > Were I to embed Python as my in-application scripting language, how > much space would it need in both code and memory? I don't see > anything obvious on the org site discussing those sorts of > requirements :) well, if you do things the right way, you'll probably save both code and memory by adding the interpreter to your app (not to mention development time!). but if you're interested in downsizing python, take a look at the material at: http://www.abo.fi/~iporres/python/ From smigowsky at dspace.de Fri Nov 19 06:58:16 1999 From: smigowsky at dspace.de (Stefan Migowsky) Date: Fri, 19 Nov 1999 12:58:16 +0100 Subject: Running Exel Message-ID: <326536345498D311B3BC00105A39802A0744E8@PDC-DSPACE> See file : ...\Python\win32com\test\testMSOffice.py There are examples how to use the office suite. Stefan >-----Original Message----- >From: Przemyslaw G. Gawronski [mailto:gawron at obop.com.pl] >Sent: Friday, November 19, 1999 12:16 PM >To: python-list at python.org >Subject: Running Exel > > >How can I run MS Exel via OLE using Python (with windows ext.) ? > >Thankx > >Przemek > >-- >Przemyslaw G. Gawronski UIN:8358522 >mailto:gawronskip at usa.net >mailto:gawron at obop.com.pl > > > >-- >http://www.python.org/mailman/listinfo/python-list > From fredrik at pythonware.com Mon Nov 22 10:21:04 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 22 Nov 1999 16:21:04 +0100 Subject: CRC-module References: <38396766.B189D15A@bibsyst.no> Message-ID: <006c01bf34fd$31ce5800$f29b12c2@secret.pythonware.com> Thomas Weholt wrote: > Is there a crc-module or an easy way to compute crc-values from files? I > want to store these values in a database to check ftp-sites, cd-roms > etc. to see if there are updated version or new files etc. ? here's a few: zlib.crc32 (32-bit checksum) zlib.adler32 (32-bit checksum) md5 (128-bit digest) sha (160-bit digest) see the library reference (or the eff-bot guide) for more info. From fdrake at acm.org Tue Nov 23 10:52:43 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Tue, 23 Nov 1999 10:52:43 -0500 (EST) Subject: Python books In-Reply-To: <383A9EF4.5D1E8986@callware.com> References: <199911230613.HAA21179@dionysus.fw.cuci.nl> <383A9EF4.5D1E8986@callware.com> Message-ID: <14394.47179.621762.615067@weyr.cnri.reston.va.us> Ivan Van Laningham writes: > If "Python Annotated Archives" is /F's book, it's already out as an > eMatter book. Visit www.python.org for details on how to get it. > Search Deja News for important information on using this style of > book--there was a thread on here about it. It's not -- this is something from McGraw-Hill. I don't think it's out yet. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From tseaver at starbase.neosoft.com Mon Nov 15 15:48:39 1999 From: tseaver at starbase.neosoft.com (Tres Seaver) Date: 15 Nov 1999 20:48:39 GMT Subject: __str__ vs. __repr__ References: <000001bf275c$02370d20$1d2d153f@tim> <01fd01bf2dce$d2c03cf0$f29b12c2@secret.pythonware.com> <942499879snz@vision25.demon.co.uk> Message-ID: In article , Michael Hudson wrote: >philh at vision25.demon.co.uk (Phil Hunt) writes: > >> In article <01fd01bf2dce$d2c03cf0$f29b12c2 at secret.pythonware.com> >> fredrik at pythonware.com "Fredrik Lundh" writes: >> > 2) what's the reason byte code cannot be used to recover >> > the original source code >> >> Perhaps because two different (but obviously functionally >> identical and very similar) source codes could produce the same >> byte code. > >I doubt it actually. Python's bytecode is really pretty high >level. Leastaways, I can't think of any examples. > >It's one of those things I might get round to writing one of these >days. I don't really know how hard it would be. Not especially, I >suspect. Besides, you need to defer it until _after_ this year's Pythonic award, for which you are already in pole position for inventing bytecodehacks :). Tres. -- --------------------------------------------------------------- Tres Seaver tseaver at palladion.com 713-523-6582 Palladion Software http://www.palladion.com From a.eyre at optichrome.com Wed Nov 24 04:52:36 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Wed, 24 Nov 1999 09:52:36 -0000 Subject: Multi-Dimensional Arrays. Message-ID: <002c01bf3661$a2e27160$3acbd9c2@peridot.optichrome.com> > Allow me to refine the question. If I make a list of lists to be my > multi-dimensional array, how do I pass that into C? > PyArg_ParseTuble(args, "?", &x)? That should work. > What would go in place of the "?"? A big 'O'. > Or would it be done a different way. Then to pass it back to Python, > I would return what? Could I use Py_BuildVal("?", x) ? You can. The PyArg_Parse and Py_BuildValue are really for converting to/from C types. Since there is no obvious conversion for a Python list, you must use the Python list API (function beginnig with PyList.) Something like: PyObject* myfunc(PyObject* self, PyObject* args) { PyObject* mylist; int length, c; if (!PyArg_ParseTuple(args, "O", &mylist)) return NULL; length = PyList_Size(mylist); for (c = 0; c < length; c++) { PyObject* item = PyList_GetItem(mylist, c); /* Do something with item */ } /* Let's return the empty list */ return PyList_New(0); } -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From mhammond at skippinet.com.au Mon Nov 29 23:56:31 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 30 Nov 1999 04:56:31 GMT Subject: Pythonwin Reset References: <01bf38df$8127e0c0$3a42c3d1@Cyberus.cyberus.ca> <_X004.7432$VA6.38559@news-server.bigpond.net.au> <01bf39bd$a28831a0$4155c3d1@Cyberus.cyberus.ca> <81rmh5$9e$1@hub.org> <01bf3a8c$3f855b80$2241c3d1@Cyberus.cyberus.ca> Message-ID: <3OI04.9647$VA6.47885@news-server.bigpond.net.au> Gordon Williams wrote in message <01bf3a8c$3f855b80$2241c3d1 at Cyberus.cyberus.ca>... >Tim, > >Thanks for the note. > >It now works in that it eliminates all the names, but it doesnt quite fix >my problem. When I make a GUI with wxPython (using Pythonwin IDE) and I >get an exception, the next time I try and run the program after fixing the >mistake, I get another exception saying One wxApps process only! Something >was left behind. The only way I have found to clear the problem was to >close Pythonwin and then restart it and reload the file. This is a known issue with Pythonwin and wxPython. I believe the issue is mainly in wxPython and is on the (no doubt) long list of things to be done... Mark. From fdrake at acm.org Wed Nov 17 09:49:05 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Wed, 17 Nov 1999 09:49:05 -0500 (EST) Subject: docs In-Reply-To: <000501bf30d9$a6e93100$a42d153f@tim> References: <14385.28690.800102.134431@weyr.cnri.reston.va.us> <000501bf30d9$a6e93100$a42d153f@tim> Message-ID: <14386.49249.39479.67579@weyr.cnri.reston.va.us> Tim Peters writes: > No, I doubt the service pack has anything to do with it. What's "obvious" > in the MS world is that it's a random bug that maybe 1 person in 1000 can > reproduce. That's par for the MS course! Or did many people report the > same problem with NT SP4? I saw one report here, and a partial possible Only the one report, but that's enough for me to implement a simple work-around. As a Unix-weenie, I consider it evil to reformat & reinstall an entire system! Heck, I don't even restart XEmacs for months if the power company cooperates. ;-) > The usual MS fix is to scandisk, defrag, clear all the caches, and reinstall > stuff from scratch. And I haven't had more than 8 browser bugs that weren't > eventually cured by reformatting my hard drives . I fixed an NT installation by repartitioning and reformatting once, but I skipped the reinstallation step and used the space under my O/S of choice. Works better now. ;-) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From cfelling at iae.nl Tue Nov 9 14:45:47 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 9 Nov 1999 20:45:47 +0100 Subject: Python for children..... References: <9911051740130D.02530@william.jinsa.org> <7GOU3.272$Ae3.194028@news-dal.corridex.com> <801p16$10s$1@vvs.superst.iae.nl> <199911080328.WAA24200@acer.spvi.com> <199911080333.WAA24231@acer.spvi.com> Message-ID: <809tlb$1eg$1@vvs.superst.iae.nl> Steve Spicklemire wrote: > Forgot to mention: > PyBots: http://opensource.spvi.com looks interesting, but elas, it doesn't run on linux and i've hardly any room on my left-over windows partition. so I've to wait for an other port or Sinterklaas. -- groetjes, carel From kuncej at mail.conservation.state.mo.us Wed Nov 10 18:50:18 1999 From: kuncej at mail.conservation.state.mo.us (Jeffrey Kunce) Date: Wed, 10 Nov 1999 17:50:18 -0600 Subject: Shared NT network installation of python Message-ID: I've worked out a procedure to run python (including tkinter) on NT from a shared network installation. It is working for me with only some minor glitches. I'm making it available with the ***CAUTION*** that it is an experimental work in progress. If it trashes your registry, don't blame me! See: pynetinst at: http://starship.python.net/crew/jjkunce/ Comments and suggestions are welcome. --Jeff From herzog at online.de Thu Nov 4 10:13:12 1999 From: herzog at online.de (Bernhard Herzog) Date: 04 Nov 1999 16:13:12 +0100 Subject: __str__ vs. __repr__ References: <000401bf25b9$88ea57e0$2e2d153f@tim> <199911040157.UAA11908@eric.cnri.reston.va.us> <00c001bf26c9$14f75a20$4500a8c0@thomasnotebook> Message-ID: "Thomas Heller" writes: > > How about a hook function a la __import__? I.e. have a function > > __format__ [1] in __builtin__ that is bound to repr by default. Whenever > > Python prints the result of an expression in interactive mode, it calls > > __format__ with the result as parameter and expects it to return a > > string ready for printing. > > But you have a custom python interpreter, don't you? No, I haven't. > Or how do you > manage to use your __format__ as the printer for interactive mode? My phrasing might have been a bit misleading. I meant it as a suggestion how to deal with the different user preferences when it comes to format the result in interactive mode for printing. The python interpreter would have to be changed if my suggestion were adopted. -- Bernhard Herzog | Sketch, a drawing program for Unix herzog at online.de | http://www.online.de/home/sketch/ From aahz at netcom.com Mon Nov 1 08:38:14 1999 From: aahz at netcom.com (Aahz Maruch) Date: 1 Nov 1999 13:38:14 GMT Subject: Comparison between Python and "Ruby" References: <3819BCDA.AC4FD4CA@strs.co.uk> <87k8o2x67f.fsf@ev.netlab.co.jp> <7vjtrc$hmm$1@newshost.accu.uu.nl> Message-ID: <7vk546$g08$1@nntp1.atl.mindspring.net> In article <7vjtrc$hmm$1 at newshost.accu.uu.nl>, Martijn Faassen wrote: > >What-does-TMTOWTDI-stand-for?-ly yours, It's the Perl motto: "There's More Than One Way To Do It" -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From cove at shell10.ba.best.com Sat Nov 27 19:17:26 1999 From: cove at shell10.ba.best.com (Cove Schneider) Date: 28 Nov 1999 00:17:26 GMT Subject: fcntl/ioctl and O_NONBLOCK References: <81ml5t$eer$0@216.39.151.169> <81p32a$m14$1@216.39.151.169> Message-ID: <38407496$0$222@nntp1.ba.best.com> Ralf Hildebrandt wrote: [snip] > This is also fixed now, but now the popen3 Object generates about 1 MB > of output (which I read using select() and read()), and then it STILL > doesn't return. No crash, no exit. And once more, in top it says > "sleep" once more. > Any ideas what's going on there? Humm.. Sounds like your not checking for an EOF.. Cove (at nbn dot com) -- Cove Schneider From fdrake at acm.org Fri Nov 12 13:56:21 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Fri, 12 Nov 1999 13:56:21 -0500 (EST) Subject: docs In-Reply-To: <80hkju$okf@mail.psy.uva.nl> References: <80epm7$vbo$1@nnrp1.deja.com> <14378.61648.633649.431232@weyr.cnri.reston.va.us> <80hkju$okf@mail.psy.uva.nl> Message-ID: <14380.25301.616025.322479@weyr.cnri.reston.va.us> Ionel Simionescu writes: > I have seen it before and I have just checked it again. > > Just open a doc, > say C:\Python\Doc\tut\tut.html, > with Internet Explorer 5.00.2314.1003, > on Windows NT 4.0 SP4, > and refresh it (F5). I don't see this when using NT4 SP3; can anyone check this for other service packs? I'm really not sure how to approach this problem. Suggestions from people more NT-aware than myself? -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From aahz at netcom.com Tue Nov 16 11:55:55 1999 From: aahz at netcom.com (Aahz Maruch) Date: 16 Nov 1999 16:55:55 GMT Subject: Python module to format text into columns? References: <80oq13$ql3$1@nnrp1.deja.com> <80rcj3$n23$1@nnrp1.deja.com> Message-ID: <80s2ar$nnn$1@nntp9.atl.mindspring.net> In article <80rcj3$n23$1 at nnrp1.deja.com>, wrote: > >but I'm inclined to provide (at least initially) just the direct >methods: > > formatter.setcolumn(column=1, margin=4, width=16, align=left) > formatter.setcolumn(column=2, margin=2, width=4, align=left) > formatter.setcolumn(column=3, margin=2, width=6, align=right) Instead of explicitly naming the columns, I'd suggest passing in a list of dicts (dicts so that you can set global defaults). That means that for three columns all taking in the global defaults, you'd pass in formatter.setcolumns ( [ {}, {}, {} ] ) -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From bjorn at roguewave.com Mon Nov 1 13:59:14 1999 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Mon, 1 Nov 1999 11:59:14 -0700 Subject: dynamically generating function assignent Message-ID: <51C9F3C392D0D111A15600A0C99E64A9AF5605@localhost> You can do: fn = eval('func_' + 'a') # look it up in the environment fn() -- bjorn > -----Original Message----- > From: anantk at my-deja.com [mailto:anantk at my-deja.com] > Sent: Monday, November 01, 1999 11:19 AM > To: python-list at python.org > Subject: dynamically generating function assignent > > > Hi, > > Here is my problem. I have defined say 12 pairs of functions > > func_a() > parse_func_a() > > func_b() > parse_func_b() > . > . > func_l() > parse_func_l() > > A file contains a series of strings which are the names of these > functions eg: > > a > c > f > b > > Now for each of these strings I need to call the two functions > func_(), and parse_func_(), where is the name of > the function > that string refers to. > > I know you can do something like > call = func_a, and call effectively gets assigned to func_a. My > question is how can I generate the RHS of this assignment dynamically? > So that all I have to do is > > = > call1 = func_ > call2 = parse_func_ > call1() > call2() > > Any help would be appriciated. > > Thanks > > -- Anant > anantk at yahoo.com > > > Sent via Deja.com http://www.deja.com/ > Before you buy. > > -- > http://www.python.org/mailman/listinfo/python-list > From reic0024 at ub.d.umn.edu Mon Nov 8 12:00:39 1999 From: reic0024 at ub.d.umn.edu (Aaron J Reichow) Date: Mon, 8 Nov 1999 11:00:39 -0600 Subject: Fastest GUI toolkit? In-Reply-To: <01bf29f1$cbfd5e60$5a41c3d1@Cyberus.cyberus.ca> References: <01bf29f1$cbfd5e60$5a41c3d1@Cyberus.cyberus.ca> Message-ID: > I would like to draw 1000 lines in 1/10 of a second on a P166 machine. (Am > I way off the mark??) I was hoping that someone would have tried different > packages and could give me pointers in the right direction. Perhaps wxWindows/wxPython? I've not done much work with it, but I would suppose that it is a bit faster than tkinter, as the GUI routines are written in C++ and not Tcl/Tk. Am I right? Aaron From greg.ewing at compaq.com Wed Nov 24 05:46:32 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Wed, 24 Nov 1999 23:46:32 +1300 Subject: automatic "lotjes trekken" References: <81cqnv$2ip$1@vvs.superst.iae.nl> <81e3s2$j14$2@newshost.accu.uu.nl> <81e41d$j14$3@newshost.accu.uu.nl> Message-ID: <383BC208.4795B8CB@compaq.com> Martijn Faassen wrote: > > So, > each time a person is drawn by someone, the program removes that program > from everybody else's lists (if that person was in there in the first > place). That doesn't guarantee that everyone gets drawn, though. You might get down to drawing for the last person and find that there's nobody left on their list, even though there are people remaining on other lists that have never been drawn. I can't think of any method that wouldn't have to backtrack under some circumstances. But is that really a problem in practice? How big a data set are we talking about? Unless you have a REALLY BIG family with lots and lots of conflicts, I'd expect a solution to be found fairly quickly in most cases, even if theoretically it could take a long time for some pathological cases. Greg From rvollmert at gmx.net Tue Nov 16 16:14:03 1999 From: rvollmert at gmx.net (Robert Vollmert) Date: Tue, 16 Nov 1999 22:14:03 +0100 Subject: list.without()? In-Reply-To: <3831BE57.366ED454@appliedbiometrics.com>; from tismer@appliedbiometrics.com on Tue, Nov 16, 1999 at 09:28:07PM +0100 References: <3831BE57.366ED454@appliedbiometrics.com> Message-ID: <19991116221403.D7366@krikkit.vollmert.home> On Tue, Nov 16, 1999 at 09:28:07PM +0100, Christian Tismer wrote: > Oh well, I overlooked that you have the try inside the while. > That's bad. I thought I had read this: > > def without( source, element): > temp = source[:] > try: > while temp: > temp.remove( element ) > except: > return temp > return temp > > Did you try this (I didn't, have no time). Would it make a big difference if while temp: were replaced by while 1: ? -- Robert Vollmert rvollmert at gmx.net From hildeb at www.stahl.bau.tu-bs.de Mon Nov 29 09:42:32 1999 From: hildeb at www.stahl.bau.tu-bs.de (Ralf Hildebrandt) Date: 29 Nov 1999 14:42:32 GMT Subject: fcntl/ioctl and O_NONBLOCK References: <81ml5t$eer$0@216.39.151.169> <81p32a$m14$1@216.39.151.169> <81qj26$be6$0@216.39.151.169> Message-ID: On 28 Nov 1999 06:45:26 GMT, Donn Cave wrote: >Yes - only a guess, but it bites everyone at least once when trying >to talk to another process via pipes. After each write(), where your >Python program is writing to the ``stdin'' of the plot process, add >a flush(), i.e. stdin.flush(). > >Python file objects use C buffered I/O, and when output is a pipe >device it's block buffered. This means your data doesn't go directly >to the pipe, but into a buffer, and the pipe doesn't see it until a >certain amount has accumulated. The flush() forces all the buffered >data to be written immediately anyway. You can also control this >by the buffer size parameter to the function that creates the file >object, or just avoid a file object altogether and write directly >to the pipe file descriptor. Meanwhile I found out: 1) I use select() to see if there's s.th. to read/write 2) I use os.read(fd, buffersize) to read and make the fd non-blocking using fcntl.fcntl(stdout.fileno(), FCNTL.F_SETFD, FCNTL.O_NDELAY) fcntl.fcntl(stderr.fileno(), FCNTL.F_SETFD, FCNTL.O_NDELAY) The problem was that the normal commands std(out|err).read() are blocking, because they don't encounter an EOF. They just keep reading. From bjorn at roguewave.com Mon Nov 29 11:47:22 1999 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Mon, 29 Nov 1999 09:47:22 -0700 Subject: Unbuffered stdout Message-ID: <51C9F3C392D0D111A15600A0C99E64A9AF568E@localhost> > leon wrote: > > I'm developping an IRC like software which must work on the > Web. I can't use > > Java, and I'm using Python to program the CGI. But, I have > a big problem : I > > don't know how to make the stdout unbuffered. > > I tried to make some > > sys.stdout.write("test") > > sys.stdout.flush() > > but it don't work. > > looks fine to me. maybe something else > is wrong? > > anyway, you could try running the inter- > preter with the -u option: > > $ python -? > Unknown option: -? > usage: python [option] ... [-c cmd | file | -] [arg] ... > Options and arguments (and corresponding environment variables): > ... > -u : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x) > ... > > Note that some webservers automatically buffer cgi output until the cgi closes stdout. To the best of my knowledge there are no pretty workarounds for this... You should check your webserver's docs to see if this is the case though. --bjorn From greg.ewing at compaq.com Wed Nov 24 04:08:20 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Wed, 24 Nov 1999 22:08:20 +1300 Subject: rlcompleter References: <383A87F6.5D2F@cs.bham.ac.uk> Message-ID: <383BAB04.63DFCA4A@compaq.com> Stuart Reynolds wrote: > > readline.parse_and_bind("\C-tab: complete") > > should bind complete to Control+tab. However, this still seems to leave > it bound to just tab. Since ascii tab is already a control character, I doubt whether it can tell the difference between Tab and Control-Tab. Greg From tim_one at email.msn.com Wed Nov 24 15:18:23 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 24 Nov 1999 15:18:23 -0500 Subject: Call for Programs: the "phonecode" benchmark In-Reply-To: <80tro1$e7e$4@news.rz.uni-karlsruhe.de> Message-ID: <000201bf36b9$0f0b1f20$292d153f@tim> [Lutz Prechelt] > - Out of the following set of scripting languages: > Perl, Python, Rexx, Tcl > do you prefer one over the others? Yes. > - Do you think one is inherently better than the others? Yes -- but which one depends on what you're doing <0.5 wink>. Suppose the task is this: next Tuesday, you will be assigned a problem to solve via program, drawn at random from the set of all problems that have ever been solved, or might plausibly be solved, via program. You must choose the programming language you're going to use next Monday, before knowing which problem you must solve. You must solve the problem by next Wednesday, else your failure will be announced on Usenet and you'll suffer 10% more flames than usual. There are only two sane choices: Python -- or suicide . > ... > I have prepared an interesting small programming problem > [at http://wwwipd.ira.uka.de/~prechelt/phonecode/] This was fun! I enjoyed it. Excellent writeup of the problem. > ... > I would now like to extend this investigation to scripting languages: > > o Are differences between implementations using the same language > smaller or even larger than for "standard" programming languages? My guess is larger: "high level" data structures and algorithms are so much easier to experiment with in high-level languages that a greater diversity of approaches is natural. > o Do systematic differences between different scripting languages > exist? Yes. For example, not all scripting languages use "#" as a comment character . > o How do the scripting languages compare to standard programming > languages such as C or Java? Shorter code, easier to read, easier to write, easier to test, easier to debug, less likely correct on first run (due to lack of static declarations), more likely correct on last run (due to extensive error-checking in the languages' runtime support -- Perl has to be run with -w to get this, though), slower to run an equivalent algorithm, but more likely to come up with a better algorithm. > ... > The effort required is typically somewhere between 1 and 8 hours. Goodness -- that's between a month and a year's work for Fredrik . cheerleadingly y'rs - tim From mstenber at cc.Helsinki.FI Thu Nov 25 05:17:58 1999 From: mstenber at cc.Helsinki.FI (Markus Stenberg) Date: 25 Nov 1999 12:17:58 +0200 Subject: Python complaints References: <867lj85g4c.fsf@g.local> <86so1v4jlj.fsf@g.local> Message-ID: Gareth McCaughan writes: .. snip.. > Dylan is sort of nice. I can't think of any purpose for which > I'd prefer Dylan to Common Lisp, though; the strengths of the > two languages are in similar places, and I think CL wins. I have always found lisp-ish syntax of "masses of ()s" disconcerting in large amounts - admittedly, I've written more than few lines of [ce]lisp/scheme/.., but never enjoyed browsing the results very much. I consider Dylan to be "readable" clisp. Admittedly, if the notation of clisp doesn't hinder you, it's _very_ powerful tool - I just can't wrap my head around larger clisp constructs.. >From trivial example - do you consider (+ 2 (* 3 4)) more readable than 2 + 3 * 4 most languages (including Dylan) allow me to do? > -- > Gareth McCaughan Gareth.McCaughan at pobox.com > sig under construction -Markus -- "If you want to travel around the world and be invited to speak at a lot of different places, just write a Unix operating system." -- Linus Torvalds From robin at jessikat.demon.co.uk Tue Nov 2 11:37:06 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Tue, 2 Nov 1999 16:37:06 +0000 Subject: Assorted Questions regarding the future of Python... References: <6D8A17398E28D3119F860090274DD7DB49833A@pces.cadlab.it> Message-ID: In article , Rob Hodges writes >Alessandro Bottoni writes: > >> 3) Visual Basic has two advantages on Python: it can compile programs (OK: I >> know that we can generate "frozen" Python programs with "Freeze") > >Unless something has changed dramatically since I last used windoze, >VB is not compiled (in the sense of native machine code) any more than >a frozen python program; rather, VB "executables" have a small header >of native code that launches the vbrunxxx.dll (interpreter) to run the >bytecode that makes up the rest of the file. Which is more or less >the equivalent of writing "#! /usr/bin/env python" at the top of your >python script in UN*X, providing a corresponding .pyc has been >generated. Or double-clicking a .pyc file in windoze, for that >matter. So either way, your users have to either have the python >interpreter or the appropriate vb dll somewhere on their system. > >Someone please correct me if I'm wrong. (Though there's no way I'll >ever touch VB <*shudder*>; just that I wouldn't like to be spreading >disinformation.) > >-Rob > there's a pretty easy way to tell; just implement a null loop and time it. Loops in VBA, VB script et al. are pretty slow. -- Robin Becker From fdrake at acm.org Tue Nov 16 09:54:10 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Tue, 16 Nov 1999 09:54:10 -0500 (EST) Subject: docs In-Reply-To: <000a01bf2ffc$3e70b0e0$042d153f@tim> References: <14380.25301.616025.322479@weyr.cnri.reston.va.us> <000a01bf2ffc$3e70b0e0$042d153f@tim> Message-ID: <14385.28690.800102.134431@weyr.cnri.reston.va.us> Tim Peters writes: > Ask MS for the source code . Short of that, there's no reason to > suppose it's a problem with the docs, and every reason to suspect the > obvious. The catch is that no matter how obvious it is, I don't want to lock people out of the docs by requiring they update to a newer service pack; patching an OS is never trivial (no matter how easy the installation of the patches), and prone to break things (esp. for NT service packs!). I'm inclined to change the generation of the comment in the HTML simply to avoid having this problem. It's annoying, but easily handled. (And people who read the CVS checkin messages may have noticed that I've already handled it that way. ;) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From Gaetan_Corneau at baan.com Wed Nov 3 10:27:00 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Wed, 3 Nov 1999 10:27:00 -0500 Subject: C++ embeding API? Message-ID: <816010E2456BD111A48700805FBBE2EEFDF74D@ex-quebec-u1.baan.com> Hello, Is anyone working on a high-level C++ embedding API? I would be interested in that, and could help any ongoing effort in that direction. I have no experience writing C++ apps with embedded Python (I'm just beginning to read the doc), but I am an experienced C++ programmer. Thanks, ______________________________________________________ Gaetan Corneau Software Developer (Quality Assurance Team) BaaN Supply Chain Solutions E-mail: Gaetan_Corneau at baan.com Compuserve: Gaetan_Corneau at compuserve.com ICQ Number: 7395494 Tel: (418) 266-8252 ______________________________________________________ "Profanity is the one language all programmers know best" From huiray at gate.sinica.edu.tw Mon Nov 29 13:33:59 1999 From: huiray at gate.sinica.edu.tw (SINICA) Date: Tue, 30 Nov 1999 02:33:59 +0800 Subject: Access violation while trying to replace stdout with a local disk file References: <1268224356-30441862@hypernet.com> Message-ID: <000a01bf3a98$4f13c940$36f96d8c@sylvia> > They both need to be linked to the same c-runtime library, (ie, > "Multithreaded DLL" in Settings | Compile | Code Generation). > > - Gordon > > i've changed the c-runtime to "Multithreaded " for myprog.exe and "Multithreaded DLL" for python15.dll but it still refuse to work, shall i change to "Multithreaded DLL" instead of "Multithreaded" for myprog.exe ? anyway, thank for your quick response. yap From da at ski.org Fri Nov 26 13:28:34 1999 From: da at ski.org (David Ascher) Date: Fri, 26 Nov 1999 10:28:34 -0800 (Pacific Standard Time) Subject: Installing NumPy in a non-standard place... In-Reply-To: Message-ID: On 26 Nov 1999, Magnus L. Hetland wrote: > Installing Python is a dream - but NumPy seems to be a bit stubborn... > How can I tell it where I want to install it? I have copied > Makefile.pre.in from my python installation, but still it wants to > install it in a standard location (that I don't have access to, > because I don't have root access on the machine)... Should I just copy > all the files manually? Am I missing something? (Couldn't see anything > in the installation instructions...) Take installthis.py and add early: import sys sys.exec_prefix = '/wher/ever' The long-term strategy has to be to get distutils-sig to replace the tools we built for NumPy. --david From akoch at rbg.informatik.tu-darmstadt.de Tue Nov 16 08:11:02 1999 From: akoch at rbg.informatik.tu-darmstadt.de (Andreas Koch) Date: Tue, 16 Nov 1999 14:11:02 +0100 Subject: Integrate Phyton in a (Delphi) App .... Message-ID: <383157E6.48E8@rbg.informatik.tu-darmstadt.de> Hi , i plan writing a huge app , in Delphi (Win95). It will have lots of classes for the various game objects , and i currently think about writing this class tree in Phython , to allow users changing it and adding new stuff. (for short , i call the delphi app winapp ) So : 1-How much work is it to integrate Phyton into a win app ? The app will hold the complete framework for user interface , movement , graphics , the phyton classes need to call and be called by my procedures 2-How fast is Phyton ? Speed is essential , i will have at least 100 objects per frame that need to be called and (usually) call my winapps "drawtile" function. 3-Is it possible to restrict certain program parts from using certain code parts ? For example , don't allow while-loops in a user definable module ? 4-Is it possible for my winapp to execute some of the phyton scripts in single step mode ? thanks , Andreas From bwarsaw at cnri.reston.va.us Sat Nov 6 00:15:06 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Sat, 6 Nov 1999 00:15:06 -0500 (EST) Subject: Announcing Mailman 1.1 Message-ID: <14371.47450.186806.711568@anthem.cnri.reston.va.us> I have just uploaded Mailman version 1.1 to www.list.org, and this will hopefully soon be mirrored to ftp.gnu.org. This release is precipitated by the removal of all GIFs from the distribution. There have also been some performance improvements, although lots more can still be done. ;) See the NEWS file excerpt below for details of changes. Sadly, the internationalization effort has not yet been integrated (mostly due to time constraints of the core maintainers). Mailman, the GNU mailing list manager, is software to help manage email discussion lists, much like Majordomo and Smartmail. Unlike most similar products, Mailman gives each mailing list a web page, and allows users to subscribe, unsubscribe, etc. over the web. Even the list manager can administer his or her list entirely from the web. Mailman also integrates most things people want to do with mailing lists, including archiving, mail-to-news gateways, and so on. Mailman is writtein primarily in Python, with a little bit of C for security. See http://www.list.org or http://www.gnu.org/software/mailman/mailman.html for details and downloading. -Barry -------------------- snip snip -------------------- - All GIFs removed. See http://www.gnu.org/philosophy/gif.html for the reason why. - Improvements to the Pipermail archiver which make things faster. Primary change is that the .txt files are not gzip'd on every posted message. Instead, use the new cron script `nightly_gzip' to gzip the .txt file in batches (this means that the .txt file will lag behind the on-line archives a little). - From the C drivers programs, Python is invoked with the -S option. This tells Python to avoid importing the site module, which can improve start up time of the Python process considerably. Note that the command line script invocation has not been changed. - New configuration variables PUBLIC_EXTERNAL_ARCHIVER and PRIVATE_EXTERNAL_ARCHIVER which can contain a shell command string for os.popen(). This can be used to invoke an external archiver instead of the bundled Pipermail archiver. See Defaults.py for details. - new script `bin/find_member' which can be used to search for a member by regular expression. - More child processes are reaped, which should eliminate most occurances of zombie processes. - A few small miscellaneous bug fixes (including PR#99, PR#107) and improvements to the file locking algorithms. -------------------- snip snip --------------------

Mailman 1.1 - the GNU mailing list manager, implemented primarily in Python. (05-Nov-1999) From T.Middletin at news.vex.net Fri Nov 19 05:23:16 1999 From: T.Middletin at news.vex.net (T. Middletin) Date: 19 Nov 1999 10:23:16 GMT Subject: Proposal: Python Info Collective References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> <80oqn9$ocq$2@newshost.accu.uu.nl> <80p9su$ppo$2@newshost.accu.uu.nl> <80piru$13rl$1@hub.org> <80re5d$55a$1@newshost.accu.uu.nl> <810jto$lo0$1@newshost.accu.uu.nl> <811pdu$dvo$1@newshost.accu.uu.nl> Message-ID: <8138ek$22mj$1@hub.org> On 18 Nov 1999 21:00:46 GMT, Martijn Faassen wrote: >with the same speech patterns _from vex.net_, I meant! deja nor I are that Argh! They're on to me. I see i'll have to randomise news servers for posting more, and deja too. (-; Oh yaw, and type with a dutch accent! Happy trails. ... From robin at alldunn.com Mon Nov 15 15:55:58 1999 From: robin at alldunn.com (Robin Dunn) Date: Mon, 15 Nov 1999 12:55:58 -0800 Subject: Proposal: Python Info Collective References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> <14384.16479.836502.161209@anthem.cnri.reston.va.us> <80pifh$12n1$1@hub.org> Message-ID: <8s_X3.676$pw2.12189912@news.randori.com> > > I must say i'm a little worried about bandwidth issues after the > discussions here. But on the other hand... we'll never know what the > system can or can't take until we try right? Heh. > > Or perhaps it would be prudent for me to look into possibilities > further.... i'm in a bit of a quandry. I've gotten more response than > I expected (which has been nice... but a little frightening too!). > Could it be moved to the Starship or perhaps to a machine at CNRI to be part of python.org? -- Robin Dunn Software Craftsman robin at AllDunn.com http://AllDunn.com/robin/ http://AllDunn.com/wxPython/ Check it out! From claudius at catlover.com Sat Nov 6 12:08:23 1999 From: claudius at catlover.com (claudius at catlover.com) Date: Sat, 06 Nov 1999 17:08:23 GMT Subject: type object of an instance without instantiation? Message-ID: I have the following code (well, in summary): class BigClass: def __init__(self): ...does some horrifyingly nasty operation... def some_generic_fn(object): if hasattr(object, '__class__') and object.__class__ == BigClass: ...do some BigClass-specific thing... Is there a way to create a type object for the instance of a BigClass object without actually creating an instance of one? From mwh21 at cam.ac.uk Thu Nov 11 10:02:24 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 11 Nov 1999 15:02:24 +0000 Subject: print "foo", without a space References: <382AD3BB.69899CBD@helsinki.xx> Message-ID: Mikael Johansson writes: > Hello All! > > Is there another way of getting print to not make a newline than > using: > print "foo", ? I think there's some way invloling sys.stdout.softspace, but I'm no sure what. However... > This because the comma always produces a space which necessary > isn't that nice, for example: > > for i in range (1,30): > print i, > if i%10==1 and i<>11: print "st", > elif i%10==2 and i<>12: print "nd", > elif i%10==3 and i<>13: print "rd", > else: print "th", > print "fish" > > Now you would like the "endings" to come right after the number. > There is naturally always some way to get around this, in this > case for example: > > end=["st","nd","rd","th"] > for i in range(1,30): > print `i`+end[max(min(abs(i)%10,4)-1- > 4*(not(int('0'+`abs(i)`[-2:-1])-1)),-1)],'fish' > > OK, this got a bit out of hand, ! > the above looks terrible, does > anyone see how it could be simplified? At least it's more general > than the above as it can handle the whole range of integers, > including negative ones :-) However it shows that it would be > less obfuscating to have a print statement that could continue > printing on the same line without a space. Do you know about the string % operator? Try: def ordinate(n): if n%10 == 1 and n <> 11: return "st" if n%10 == 2 and n <> 12: return "nd" else: return "th" print "This is the %d%s fish"%(i,ordinate(i)) It's generally the way to go for formatting output. > If there isn't an easy way for this, I suggest the following: > print "foo". > So that a dot at the end of the line would mean "no space either". With all due respect: no chance. > Appreciating any comments. Hoping this helps, Michael From fredrik at pythonware.com Wed Nov 24 06:37:22 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 24 Nov 1999 12:37:22 +0100 Subject: Python complaints References: <383BC9C2.901A2D6@python.net> Message-ID: <018401bf3670$46b24af0$f29b12c2@secret.pythonware.com> Thomas A. Bryan wrote: > I generally don't mind this aspect of Python, but I've recently found that > it can cause problems when transmitting code. For example, I saw some > code that I wanted to copy in DejaNews c.l.py archives, but the lines > wrap in narrow columns in DejaNews. I had to reindent the code. Grrr. but you didn't have to do that, really -- dejanews has a small "view original Usenet format" link at the bottom of each message. (or you can use the "mail to a friend" link to mail your- self an exact copy of the original message...) From phil at ricochet.net Tue Nov 30 02:38:49 1999 From: phil at ricochet.net (phil) Date: Tue, 30 Nov 1999 07:38:49 GMT Subject: PyArg_ParseTuple() and oprtional remaining argument lists References: <000c01bf3a70$ae184ec0$3acbd9c2@peridot.optichrome.com> Message-ID: <38437a53.7776331@news.ricochet.net> On Mon, 29 Nov 1999 13:50:22 -0000, "Adrian Eyre" wrote: Thanks, that fixed both the problems. phil. >Aha. That's the clue. Make sure that your PyMethodDef struct is like >this: > >static struct PyMethodDef methods[] = { > { "method1", method1, 1 }, > { "method2", method2, 1 }, > { NULL, NULL, 0 } >}; > >Not like this: > >static struct PyMethodDef methods[] = { > { "method1", method1 }, > { "method2", method2 }, > { NULL, NULL } >}; > >-------------------------------------------- >Adrian Eyre >Optichrome Computer Solutions Ltd >Maybury Road, Woking, Surrey, GU21 5HX, UK >Tel: +44 1483 740 233 Fax: +44 1483 760 644 >http://www.optichrome.com >-------------------------------------------- > > > The world is divided into two sorts of people: those that think the world is divided into two sorts of people and those that don't. From gmcm at hypernet.com Sat Nov 6 20:58:57 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Sat, 6 Nov 1999 20:58:57 -0500 Subject: exec / execfile namespace problem In-Reply-To: <000b8d9b.b9d3bdca@usw-ex0101-003.remarq.com> Message-ID: <1270182562-5943662@hypernet.com> Karan Vasudeva has problems with exec: > .... my > problem is, when i call my script from another script (by doing > an exec, thats what i need to do, you see), the interpreter stops > at httplib.py as it can't find that socket called self.sock . > This appears to be a namespace issue. I just want to know how to > do this right. exec is pretty much only used when you don't know what you'll be running at the time you wrote it. If you know what you're running at the time you write it, there's no reason to use exec. You probably just want: import cool and maybe: cool.main(args) Many python scripts have the form: ----------------- def main(): # whatever def otherthing(): # stuff used by main, or usable by others if __name__ == '__main__': main() # if invoked as a script, run main() --------------------------------- Then they can run as the top level script, or they can be imported, and any functions, classes etc. used by the importer. - Gordon From framiere at netcom-service.com Mon Nov 15 06:12:59 1999 From: framiere at netcom-service.com (Florent Ramière) Date: Mon, 15 Nov 1999 12:12:59 +0100 Subject: Python ISAPI Message-ID: <80oq15$ln8$1@oceanite.cybercable.fr> Hello, i am looking for an python ISAPI, but could not find any. Could you tell me where i can get such a goodie ? Does anybody ever worked on this ? Thanks. From steven_shaw at adc.com Thu Nov 4 01:57:22 1999 From: steven_shaw at adc.com (steven_shaw at adc.com) Date: Thu, 04 Nov 1999 06:57:22 GMT Subject: SWIG and function name question References: <7vmc7e$8h$1@marcie.fissiontech.com> Message-ID: <7vraoh$6tm$1@nnrp1.deja.com> You won't get them with your 'from module import *' because they begin with underscore. Names beginning with underscore are "private" by convention in Python. The 'from module import *' implements this "convention". It is the only for of access restriction in Python. Probably someone else can explain it better. -SS In article <7vmc7e$8h$1 at marcie.fissiontech.com>, kain at dynup.net wrote: > Hey folks, > > I downloaded and started to learn SWIG today and I ran into a little problem. > In the C code there is a structure like this: > > struct __foo { ... }; > > When I import my SWIG created module using 'import mymodule' I have access > to the struct's set/get operation via mymodule.__foo_set_member() but if I > import my module using 'from mymodule import *' I have access to all of my > modules functions accept the two get/set functions that begin with __ > (I'm using dir() to check this). This isn't too much of a problem for me > but I'm just wondering what's going on. Can anyone clear this up for me? > > Thanks, > Scott > > Sent via Deja.com http://www.deja.com/ Before you buy. From mwh21 at cam.ac.uk Wed Nov 10 02:56:07 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 10 Nov 1999 07:56:07 +0000 Subject: IDLE and rlcompleter [Was: Re: making the Python case to my dept.] References: <000201bf2b3c$a977dc20$d32d153f@tim> Message-ID: "Tim Peters" writes: > [Michael Hudson] > > ... > > While we're on the subject of idle, is there any easy (preferably one > > or two keystrokes) that way to import/reload the module being edited > > into the Python shell and bring said shell to the front for instant > > interactive play? That'd be ?bercool. > > Already implemented, in the current CVS IDLE. It's that bloody time machine again! I'd have sworn I looked before I posted. Regards, Michael From gmcm at hypernet.com Fri Nov 5 21:47:56 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Fri, 5 Nov 1999 21:47:56 -0500 Subject: __str__ vs. __repr__ In-Reply-To: <7vvni7$19q0$1@nntp6.u.washington.edu> Message-ID: <1270266026-923418@hypernet.com> Donn Cave writes: > Quoth "Tim Peters" : > > | Let me back off to what repr and str "should do": > | > | repr(obj) should return a string such that > | eval(repr(obj)) == obj > For real? I'm very used to seeing repr's that don't eval at all > - > > '' > "', mode 'w' at 80005660>" > '' import StringIO x = ['a', 1, 'b', {'x':(4,5L),'z':None}] f = StringIO.StringIO() f.write(repr(x)) y = eval(f.getvalue()) if y == x: print "You betcha" I've even been known to implement __repr__ in classes and C extension types so this property holds true, and I've been bitten by the fact that UserList just forwards repr to self.data. - Gordon From godzilla at netmeg.net Thu Nov 4 23:38:37 1999 From: godzilla at netmeg.net (Les Schaffer) Date: Fri, 05 Nov 1999 04:38:37 GMT Subject: ~ 1 = -2 ??? References: Message-ID: william tanksley added this marble to my collection: > The marble about 32-bit twos' complement signed integers. They're > not four-bit, BTW. its not even midnite and i am already brain-dead, yeeesh. i was doing ops on 4 bit numbers, so i fooled myself. i should have said: 0000 0001 --> 1111 1110 and to keep only the 4 lower bits... 1111 1110 & 0000 1111 --> 0000 1110 which equals 14, not 13 (sheesh... nobody is ever gonna listen to me again) so for my code, i will do def not4bit(x): return ~x & 15 >>> not4bit(1) 14 ahh, that feels better.... goodnite world. les schaffer From darcy at vex.net Thu Nov 11 15:44:43 1999 From: darcy at vex.net (D'Arcy J.M. Cain) Date: 11 Nov 1999 20:44:43 GMT Subject: ASCII delimited files References: <942231502.1914033961@news.interbusiness.it> <80ekhb$1qrh$1@hub.org> <80et0b$2df8$1@hub.org> <80evr8$2lc7$1@hub.org> <80f11i$2nof$1@hub.org> Message-ID: <80f9rr$9m0$1@hub.org> D'Arcy J.M. Cain wrote: > OK, this one does the right thing. *sigh* Except that I accidently posted an earlier test version. > SEP='|' Should be SEP = '\0' -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From da at ski.org Thu Nov 11 12:22:30 1999 From: da at ski.org (David Ascher) Date: Thu, 11 Nov 1999 09:22:30 -0800 (Pacific Standard Time) Subject: method overriding trick In-Reply-To: <14378.62498.649973.150075@bitdiddle.cnri.reston.va.us> Message-ID: On Thu, 11 Nov 1999, Jeremy Hylton wrote: > Overriding methods of a base class is a little clunky in Python. You > need to explicitly name the base class that implements the method, and > you call its as an unbound method, passing self as the first argument. > Example: Base.aMethod(self, arg) > > I was reading about MzScheme the other day (a Scheme variant with > object and interface support), and noticed that the MzScheme approach > translates well to Python. MzScheme class defintions allow a rename > declarations that create a name in the class being defined that is > bound to a name in a superclass. In Python, rename is just called > assignment. > > class Base: > def aMethod(self, arg): > return arg * 2 > > class Derived1(Base): > super_aMethod = Base.aMethod > > def aMethod(self, arg): > return self.super_aMethod(arg) + 1 > > I haven't seen this strategy for overriding mentioned before, although > I did not search the list archives. When I described it to Guido, he > said, "Does that work?" Has anyone used this trick before? > > It doesn't solve the must-name-the-base-class problem, but it helps > manage it better. If you keep the override assignments at the top of > the class statement, then you only have one place to look in each > class when the inheritance hierarchy changes. Cute! You can also make it a mixin, along the lines of: import new class Mixin: def __getattr__(self, k): if k[:len('super_')] == 'super_': for b in self.__class__.__bases__: m = getattr(b, k[len('super_'):], None) if m: return new.instancemethod(m, self, self.__class__) else: raise AttributeError, k else: raise AttributeError, k class Base(Mixin): def f(self): print 'Base.f' class Sub(Base): def f(self): print 'Sub.f' self.super_f() s = Sub() s.f() Not especially fast, of course, but doesn't require as much human memory load. --david From mal at lemburg.com Fri Nov 12 14:02:08 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 12 Nov 1999 20:02:08 +0100 Subject: __str__ vs. __repr__ References: <000001bf275c$02370d20$1d2d153f@tim> <7vvni7$19q0$1@nntp6.u.washington.edu> <382BEC79.EC65913D@maxtal.com.au> Message-ID: <382C6430.8DC07E3E@lemburg.com> skaller wrote: > ...viperi's version of repr... > You may be wondering how this works. The answer is that Viperi does not > use bytecode, it executes the 'Abstract Syntax Tree' directly. > Consequently, the original code can be recovered. (without comments, > or the original formatting, of course). Could you point me to some resources ? Using ASTs for execution is an interesting subject and I would like to know how you deal with Python dynamic nature in this context (are the ASTs self modifying ?). BTW, all your software links are broken... Thanks, -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 49 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From skip at mojam.com Mon Nov 29 15:39:45 1999 From: skip at mojam.com (Skip Montanaro) Date: Mon, 29 Nov 1999 14:39:45 -0600 (CST) Subject: Python bugs In-Reply-To: <001101bf3a8f$5fe300f0$3acbd9c2@peridot.optichrome.com> References: <51C9F3C392D0D111A15600A0C99E64A9AF5690@localhost> <001101bf3a8f$5fe300f0$3acbd9c2@peridot.optichrome.com> Message-ID: <14402.58513.737532.298175@dolphin.mojam.com> >>> s = shelve.open("foo") >>> l = [] >>> s["bar"] = l >>> s["bar"] [] >>> l.append("baz") >>> s["bar"] [] I think you're asking for magic that really can't happen (at least not easily). Shelve transparently does the mapping to strings that most/all dbm-like packages require, so when you execute s["bar"] = l you'd don't get the usual object-to-name binding you expect. Instead, l is marshalled into Pickle's string form and that string is stuffed into the underlying dbm file keyed by the string "bar". Similarly, when getting the value of s["bar"], the read+unpickle operation is performed. When you append "baz" to l, it has nothing to do with s["bar"]. While this isn't as transparent as you'd like, the lack of transparency has one big advantage: speed. Because you're forced to explicitly read and write elements of a shelve object, e.g.: s = shelve.open("foo") l = s["bar"] ... do lots of stuff with l ... s["bar"] = l instead of s = shelve.open("foo") ... do lots of stuff with s["bar"] ... the result is that all operations involving l are done in memory instead of by constanting marshalling and unmarshalling a possibly very big item out of a file. All that aside, I believe the good folks at Digital Creations worked some magic using ExtensionClasses a few years ago to make this work in certain contexts. Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/ 847-971-7098 | Python: Programming the way Guido indented... From mwh21 at cam.ac.uk Mon Nov 29 12:38:25 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 29 Nov 1999 17:38:25 +0000 Subject: performance of tuple-less Python? References: Message-ID: "Greg Wilson" writes: > Has anyone ever built a version of Python that didn't include tuples, and > looked at the performance of code that consistently used lists instead? I doubt it. > I'm curious as to whether the use of tuples (which I believe are > conceptually redundant) actually has a significant positive impact > on the interpreter's performance on non-trivial codes (i.e. once > caching, instruction ordering, and all other effects have come into > play). Tuples are immutable. This is important in some respects; they're hashable for instance, and can be guaranteed not to contain cycles. I don't think they're there for reasons of performance. M. From kern at temp1.caltech.edu Wed Nov 10 14:50:45 1999 From: kern at temp1.caltech.edu (kern at temp1.caltech.edu) Date: 10 Nov 1999 19:50:45 GMT Subject: Using GNU C complier as the "default" windows complier References: <4D0A23B3F74DD111ACCD00805F31D8100DB9151B@RED-MSG-50> Message-ID: <80cial$gfn@gap.cco.caltech.edu> In article <4D0A23B3F74DD111ACCD00805F31D8100DB9151B at RED-MSG-50>, Bill Tutt writes: > cygwin isn't thread safe at this moment in time. > If anything, Python should be compiled using mingw32 instead of cygwin. > Esp, in order to get the Win32 extensions to be useful. > > However.... I have no idea if the Win32 extensions actually can be compiled > successfully using mingw32 as a substantial portion of them are C++, and > even if they could be compiled, there would be binary incompatability > problems due to using C++. (C++ mangling is different for all C++ > compilers...) C extensions work fine when compiled with mingw32 as long as you patch the headers slightly. I have compiled M.A. Lemburg's C++ mxCrypto extensions with mingw32, and they seem to work fine. LLNL's CXX doesn't run the last time I tried, but this may be a problem with the options I used and not a fundamental incompatibility. I have not had the opportunity to try GCC 2.95.2 yet. > So given those two things, and neither Mark, I, or anybody > else atm seems to care enough to bother trying to see if it'll work. The > binary compatability problem is the biggest problem though. If a MSVC > compiled Python install can't make use of a mingw32 Win32 extension DLL (or > vice versa) then even bothering with trying becomes counter productive. MSVC Python can use mingw32 extensions if the extensions are compiled properly. See http://starship.python.net/crew/kernr/mingw32/Notes.html for instructions. Paul Sokolovsky has patched the Python interpreter to compile with mingw32. The build process still needs work, but the base is there. http://www.is.lg.ua/~paul/devel > (unless your willing to invest time in submitting changes to the source code > to remove the C++ mangling issues) i.e. Turn all exported C++ objects into > COM objects or something so you can just use COM vtbls to communicate. > Needless to say, thats a lot of work that I'd rather not do. (I expect Mark > won't be to gung ho to do that work either... :) ) > > Bill [piggybacking below] > > -----Original Message----- > > From: Werner Fouche [mailto:wfouche at mindspring.com] > > Sent: Wednesday, November 10, 1999 3:59 AM > > To: python-list at python.org > > Subject: Re: Using GNU C complier as the "default" windows complier > > > > > > > > "Mike Callahan" wrote in message > > news:ma4W3.7794$Ur4.223420 at news.rdc1.tn.home.com... > > > This a question from a newbie but I was thinking...why > > doesn't the default > > > Python code for windows use the GNU C complier for windows > > instead of the > > MS > > > complier. Would it be possible to distribute the GNU > > package along with > > the > > > Python package and thus make it easier to compile, extend, and embed > > Python, > > > use freeze, etc? I know it would take some work, but it > > seems it would > > make > > > windows Python a lot more like unix Python. Just a thought. Bad idea. Cygwin is huge, and anyone who needs it can get it herself. Cygwin alone is not the best compiler to use since it goes through a POSIX emulation layer that slows things down. mingw32 would be better since it uses MSVCRT.dll as its C runtime library (when properly configured). However, as Bill mentioned, C++ issues still would have to be worked out. Here's how things stand as I can see: 1) mingw32 extensions run on MSVC Python. 2) The Python interpreter can be compiled with mingw32. 3) C++ support is still iffy. 4) freeze will probably work with mingw32, but I've never heard of anyone trying. 5) Embedding? Who knows? 6) Use Cygwin for tools and not the compiler. > > I had the same idea on the weekend. So I installed Cygwin > > (http://www.cygnus.com/cygwin) on my NT system and after running > > "./configure" got Python to compile and run. However, I could > > not get Python > > threads to work. Cygwin proper is not threadsafe. mingw32 can be. Robert Kern kern at caltech.edu From godzilla at netmeg.net Thu Nov 4 23:01:22 1999 From: godzilla at netmeg.net (Les Schaffer) Date: Fri, 05 Nov 1999 04:01:22 GMT Subject: ~ 1 = -2 ??? Message-ID: i am doing some bit operations, and dont understand the following: >>> ~ 1 -2 huh???? i would have thought that bitwise invert of 1 would be 0001 --> 1110 = 13 (base 10) what marble am i missing? les schaffer From andres at corrada.com Sun Nov 21 12:36:39 1999 From: andres at corrada.com (Andres Corrada) Date: Sun, 21 Nov 1999 12:36:39 -0500 Subject: Order of keyword arguments References: <1268914352-35423797@hypernet.com> Message-ID: <38382DA7.A03A2023@corrada.com> Gordon McMillan wrote: > > Ah, but that would be "alphabetical order", not "entry order", > and not much use to anybody if it were. > I disagree. I think you are confusing entry order with type of ordering. entry order could be alphabetical but it could also be by time of entry, for example. My point still stands: an ordered dictionary would be a useful data structure to have. > Python data structures that would suit your apparent desires: > [ (optionname, optionvalue), ... ] Mike Fletcher suggested this also and it is the way I'm getting to eat my cake and have it too :-) ------------------------------------------------------ Andres Corrada-Emmanuel Email: andres at corrada.com Owner http://www.corrada.com/mamey Mamey Phone: (413) 587-9595 ------------------------------------------------------ From tekhir at yahoo.com Tue Nov 16 21:56:33 1999 From: tekhir at yahoo.com (Jeremy Misavage) Date: Tue, 16 Nov 1999 21:56:33 -0500 Subject: How I got Python to Work with IIS 4.0 on NT Message-ID: <38321961.540FFEFD@yahoo.com> The instructions I found on python.org didn't work for me totally. IIS knew I had .py as a script type, but it wouldn't execute them correctly. However, I did get it to work and this is how: 1. In the Management Console select your web site 2. Pull up Properties (I had to right click) 3. Go to the Home directory tab 4. Click configure 5. Select the App Mappings tab This is where you say that .py files are handled by "c:\Program Files\Python\python.exe" (by default) "c:\Program Files\Python\python.exe" -u %s %s I've also been told to put "" around the %s sometime. Like so: "%s" "%s" MS Personal Web Server however doesn't have a Management Console so registry hacking is the only way to get it to work. From x at domain.com Sat Nov 27 18:57:32 1999 From: x at domain.com (Cove Schneider) Date: 27 Nov 1999 23:57:32 GMT Subject: SMTP - again ;) References: <19991126080017.26482.qmail@hotmail.com> Message-ID: <38406fec$0$222@nntp1.ba.best.com> Ulf Engstr?m wrote: > I've gotten my prog to work now, only have some problems with our > server/firewall, but that's hardly an issue. > Anyway, something else came up, when I enter a name in the header: > "To: Ulf Engstr?m" the mail gets to the dest as: > To: Ulf.Engstr?m at mb04.swip.net if I use mb04.swip.net as outgoing server, > eventhough the address is completely different...and the add before @ is not > correct either, since it's the Real Name.. > Is there a way to get rid of that? In the To-field of the mail I just want > the name, not @anywhere... Er.. Well, your most likely confusing your MTA because there's no address in the To field. Though I suppose you could always do something like: To: Foo Bar <> and just use a blank address.. that shouldn't really pose any problems.. Cove (at nbn dot com) From thamelry at vub.ac.be Thu Nov 25 04:29:18 1999 From: thamelry at vub.ac.be (Thomas Hamelryck) Date: 25 Nov 1999 09:29:18 GMT Subject: Python complaints References: <000601bf36be$f1bf5e80$292d153f@tim> Message-ID: <81ivhe$12l$1@mach.vub.ac.be> Tim Peters (tim_one at email.msn.com) wrote: : There is one (& only one) area where Python's indentation gets in my way a : bit: conceptual blocks that can't be written as blocks. These typically Right. Another example occurs in OpenGL, eg. glBegin(GL_POLYGON) glVertex2f(-0.5, -0.5) glVertex2f(-0.5, 0.5) glVertex2f(0.5, 0.5) glVertex2f(0.5, -0.5) glEnd() This makes the code more readable, but it's not allowed in Python. I've got used to the indentation rule in Python, and I'm not annoyed by it that much anymore, but I still think it is a major mistake. Cheers, ------------------------------------------------ Thomas Hamelryck//Free University Brussels (VUB) Intitute for Molecular Biology// ULTR Department Paardestraat 65//1640 Sint-Gensius-Rode//Belgium ------------------------------------------------ From marten at btk.utu.fi Fri Nov 26 06:18:51 1999 From: marten at btk.utu.fi (marten at btk.utu.fi) Date: 26 Nov 1999 13:18:51 +0200 Subject: Tkinter: closing app with active messagebox Message-ID: Hi Im writing a small script that asks the user for some input and checks it from a mysql server. If the user doesn't respond the app should close after a timeout period. Normally this works fine, but if there is an active messagebox (tkMessageBox.showinfo), the app won't close until the OK button in the messagebox is clicked. My question is: How do I force an active messagebox to close? Can this be done with the standard dialog boxes in tkMessageBox or do I have to write my own dialog boxes? Any help appreciated Yours Marten Hedman Marten.Hedman at btk.utu.fi Turku Centre for Biotechnology Abo Academy University & Turku University Turku, Finland From fredrik at pythonware.com Tue Nov 16 11:33:46 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 16 Nov 1999 17:33:46 +0100 Subject: Anyway to use file masks with os.listdir()? References: Message-ID: <008a01bf3050$5f819cf0$f29b12c2@secret.pythonware.com> Aaron J Reichow wrote: > Is there any way to pass a filemask to os.listdir()? For example, to list > only files with the extension .jpg. Any help would be appreciated! :) it's spelled "glob": http://www.python.org/doc/current/lib/module-glob.html From andy at robanal.demon.co.uk Sun Nov 7 11:41:18 1999 From: andy at robanal.demon.co.uk (Andy Robinson) Date: Sun, 07 Nov 1999 16:41:18 GMT Subject: __str__ vs. __repr__ References: <000001bf275c$02370d20$1d2d153f@tim> Message-ID: <38257118.2127148@news.demon.co.uk> "Tim Peters" wrote: >> Should I really assume stdout is capable of displaying Latin-1? > >No. But I don't grasp why you think you need to know *anything* about this. >Until Unicode takes over the world, there's nothing you can do other than >tell users the truth: "most of" printable 7-bit ASCII displays the same way >across the world, but outside of that *all* bets are off. It will vary by >all of OS, display device, displaying program, and user configuration >choices. > Well said. I'm going to pass this message around to my team at work as it encapsulates so many of the issues involved in internationalisation (and if you think inputting Fran?ois is bad, try figuring out a way to clean up Japanese names using vi on an English Solaris box). I have found there are only three really sane points of reference when dealing with encodings - anywhere between the gaps just causes confusion all around: Level 1: Code that is assumed to work as above (tab, newline and 32-127) Level 2: Code that keeps all 256 values intact without understanding the contents, like Python strings. Level 3: A fully general multi-byte encoding toolkit, where the programmer is in explicit control of which encoding a string is in, and has capable libraries which can convert from one to the other, and can reason in advance about whether a particular data set can survive a particular round-trip conversion, and knows the exact capabilities of the fonts ultimately used for display or printing. AFAIK (3) does not exist yet - we got most of the way at work with Unilib and a load of ad hoc Python code, and Java goes most of the way. I think the key concept is a special kind of string which is tagged to know which encoding it is in. Regards, Andy From tre17 at student.canterbury.ac.nz Sun Nov 14 20:28:41 1999 From: tre17 at student.canterbury.ac.nz (Tim Evans) Date: 15 Nov 1999 14:28:41 +1300 Subject: Other ways to disable Wm in Tkinter? References: <80nabr$q62$1@nnrp1.deja.com> Message-ID: brian at liaone.ne.mediaone.net writes: > Hello, > I have a question on how to dynamically activate/deactivate the window > manager. I'm using a button activated listbox to enter items into an > application. The listbox is on a separate managerless Toplevel to give > it a placard appearance. When the listbox pops up, it has a local grab. > Unfortanately, one can still drag around the main window underneath > and thus inadvertantly hide the listbox. I have managed to get around > this problem by using withdraw/overrideredirect/deiconify on the > main window when the listbox appears and again when the listbox > disappears (to restart the window manager). This is not a good fix > since it results in irritating flashes as the main window is > clobbered and redrawn. > > Thus, my question - can one disable the window manager (or at least > disable window movement) short of withdraw/overrideredirect/deiconify? > It goes without saying that using grab_set_global is a bit too brutal. > Thanks, > Brian > I've included some code that does a better job of it. The new window does actually use a global grab, just the same as a menu window. The behaviour matches how the same kind of window behaves in other more complex widget sets. ============================== #!/usr/bin/env python from Tkinter import * import string class ScrolledMenu(Toplevel): def __init__(self, command=None): self.command = command Toplevel.__init__(self) self.withdraw() self.overrideredirect(1) self.listbox = Listbox(self) scroll = Scrollbar(self, orient='v', command=self.listbox.yview) self.listbox.configure(yscrollcommand=scroll.set) self.listbox.pack(fill='both', expand=1, side='left') scroll.pack(fill='y', side='right') self.bind('', self._press) self.bind('', self._close) self.bind('', self._close) self.listbox.bind('', self._select) self.up = 0 def popup(self, onto): x = onto.winfo_rootx() y = onto.winfo_rooty() + onto.winfo_height() self.geometry('+%d+%d' % (x,y)) self.deiconify() self.up = 1 self.grab_set_global() def _close(self, event=None): self.grab_release() self.withdraw() self.up = 0 def _select(self, event): self.update() # let the listbox change its selection self._close() index = self.listbox.curselection() value = self.listbox.get(index)[0] if self.command is not None: self.command(value) def _press(self, event): x,y = self.winfo_pointerxy() window = self.winfo_containing(x,y) if window is None or window.winfo_toplevel() != self: self._close() class _Test(Tk): def __init__(self): Tk.__init__(self) self.sm = ScrolledMenu(self.result) apply(self.sm.listbox.insert, (0,)+tuple(string.lowercase)) self.b= Button(self, text='Test', command=self.popup) self.b.pack() def result(self, value): print 'selected:', value def popup(self): self.sm.popup(self.b) if __name__ == '__main__': mw = _Test() mw.mainloop() ============================== -- Tim Evans From curtis_c at lxe.com Mon Nov 22 09:52:31 1999 From: curtis_c at lxe.com (Curtis, Craig M.) Date: Mon, 22 Nov 1999 09:52:31 -0500 Subject: Python in DOS Message-ID: Commenting out those dreaded printfs certainly does work :-) I guess I do not understand what PYTHONHOME should be set to. I tried setting it to the python-1.5.2 root and also to the lib under it, but neither of these work. Thanks, Craig > ---------- > From: Hans Nowak[SMTP:hnowak at cuci.nl] > Sent: Friday, November 19, 1999 5:20 PM > To: Curtis, Craig M. > Cc: python-list at python.org > Subject: RE: Python in DOS > > > On 19 Nov 99, at 10:59, Curtis, Craig M. wrote: > > > I tried setting PYTHONCASEOK to 0 and did the configure and make and > still > > have the same problem. Any more suggestions? > > Yeah, try setting it to 1. :o) 0 doesn't have much effect AFAIK. This > variable does not affect compilation though, it only affects the > interpreter when it runs. > > If that doesn't help, do as I said... uncomment the code. I think > uncommenting a coupla fprintf statements in getpath.c will do. You'll > know 'em when you see 'em... they're these infamous error/warning > messages of course. > > HTH, > > --Hans Nowak (zephyrfalcon at hvision.nl) > Homepage: http://fly.to/zephyrfalcon > You call me a masterless man. You are wrong. I am my own master. > From jblazi at netsurf.de Mon Nov 15 16:03:39 1999 From: jblazi at netsurf.de (Janos Blazi) Date: Mon, 15 Nov 1999 22:03:39 +0100 Subject: Beginning programming with Python References: <382B3A53.5816B2@callware.com> <382B3D79.74CD3E0F@email.sps.mot.com> <80p9ds$ppo$1@newshost.accu.uu.nl> Message-ID: I have tried to use Perl in my teaching. It has a very powerful but alas! not very simple syntax! To start with, my pupils used to forget the dollar signs and Perl does not like that. So this year I shall use Python. We shall see. Time will tell, if Python is really better. Maybe my pupils will forget the indenting this time? There is actually nothing else you can forget in Python. I feel that it is the right language for teaching. Janos Blazi Germany Martijn Faassen schrieb in im Newsbeitrag: 80p9ds$ppo$1 at newshost.accu.uu.nl... > "Aaron Ginn (rp2885)" wrote: > > An honest opinion, please; is Python better suited for beginners than Perl, as > > I've heard? > > You're asking in the Python newsgroup, so here's my honest opinion: > > Yes. > > I was an experienced programmer (C, C++, Pascal, and some glancing > familiarity with a host of other languages) when I learned Python. > Before I looked at Python, I struggled a few weeks trying to teach > myself Perl. Then I downloaded the Python tutorial, read it in about an > hour, and I never looked back. I could program in Python from then on. Python > was much much easier for me to learn. I could reason about the right > syntax for things, while with Perl I was constantly checking the documentation. > > This was of course the example of an experienced programmer, but I think > it'll be true for beginners too. The multiplicity of syntax of Perl to > do the same thing, and the odd syntax to do certain things will confuse > beginners, and will also teach the wrong idea to beginners; programming > is not about syntax gimmicks. With perl you could be tempted to learn > lots of snippets and tricks to solve a problem and how to assemble > these to a working program. Lots of copy&paste programming, and lots of > 'how do I do this in Perl' questions. With Python you can focus more on > the underlying structure, the semantics, of the program. > > Then again, this is a biased opinion. There are arguments why Perl would > suit the human mind better *because* it is so syntactically variable and > complicated. I don't believe in these arguments myself. > > Python has a clean and powerful syntax. Perl has just a powerful syntax. > > Regards, > > Martijn > -- > History of the 20th Century: WW1, WW2, WW3? > No, WWW -- Could we be going in the right direction? From thamelry at vub.ac.be Wed Nov 24 03:48:56 1999 From: thamelry at vub.ac.be (Thomas Hamelryck) Date: 24 Nov 1999 08:48:56 GMT Subject: Python complaints References: Message-ID: <81g8po$reo$1@mach.vub.ac.be> Mark Carroll (markc at chiark.greenend.org.uk) wrote: [snip] : Basically, I'd be really interested to learn: what _don't_ people like : about Python? [snip] Well, here are some of the things I don't like very much: Block delimitation by indenting. This makes python look like a porsche with a caravan attached :-). As far as I know, most python users even seem to like this for some reason. I very much miss the unary arithmatic operations that C has (e.g. a+=1). Lack of true garbage collection (which leads to problems with circular references). Lack of private attributes (although you can simulate private attributes by picking a name with two underscores; python then does some name magling with it). But of course, it's still a very nice language :-) Cheers, ------------------------------------------------ Thomas Hamelryck//Free University Brussels (VUB) Intitute for Molecular Biology// ULTR Department Paardestraat 65//1640 Sint-Gensius-Rode//Belgium ------------------------------------------------ From tim_one at email.msn.com Fri Nov 5 02:14:25 1999 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 5 Nov 1999 02:14:25 -0500 Subject: ~ 1 = -2 ??? In-Reply-To: Message-ID: <000301bf275d$6468e120$1d2d153f@tim> [Les Schaffer] > ... > so for my code, i will do > > def not4bit(x): > return ~x & 15 > > >>> not4bit(1) > 14 Les, if x is always in range(16), simply subtract it from 15. That is, def not4bit(x): assert 0 <= x < 16 return 15 - x It's twice as fast . or-15-times-as-slow-it's-hard-to-tell-ly y'rs - tim From tim_one at email.msn.com Thu Nov 25 05:38:58 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 25 Nov 1999 05:38:58 -0500 Subject: automatic "lotjes trekken" Message-ID: <000001bf3731$486ea840$be2d153f@tim> [Carel Fellinger] > ... > in the damp and cold days of late November and early December we > think and ponder on a nice and teasing Sinterklaas gift for one- > other. To prevent doublures, we draw lotjes (lots) with the name > of the one to tease. Ofcourse you are not allowed to draw one-self. > And often some one would rather not have specific others; e.g. my > eldest girls, being twins, rather not have each other, as the mere > fact that one refuses to cooperate with the other is a sure sign > that she drew her twin sister. And part of the fun is that the > drawing is secret and kept secret; though everybody tries to figure > it out anyway. > > Being fed up with drawing and redrawing and redrawing and... > I decided to use python. Piece of cake using random.choice, sends > mail to all and the lot. Then I added these restrictions, still > trivial. But elas running the little devil with to many restrictions > took awile:) I decided to check before hand whether a drawing was > possible at all by counting all possibilities. There must be something > more clever than backtracking to get to this number, something with > permutations and so, but my mind is to blurred to see it. The mail<->news gateway is screwed up, so my apologies if you already got a sufficient answer (although, as will become clear, I doubt it ). In combinatorics, this is the general problem of permutations with forbidden positions: you can view the lots as mapping the set of people into itself, one-to-one and onto. That is, it's a permutation. Since a person is not allowed to map to themself here, an upper bound is the number of "derangements" (great word!) of N people. A derangement is simply a permutation where no element maps to itself. Asymptotically, there are N!/e derangements of N things (N! is N factorial = N * (N-1) * ... * 1, and e is 2.71828...). This is an excellent approximation even for small N; e.g., for N=5, 5!/e = 120/e ~= 44.15, while the exact number of derangements of 5 things is 44. That the number e pops out of a very uniform special case should suggest that the general theory isn't likely to be dirt simple. And, in a great surprise, it turns out that it actually isn't dirt simple . Something you could ponder the whole winter! To get you started, here's a simple (& std) way to think about it: picture an NxN chessboard. A permutation corresponds naturally to placing N rooks on the chessboard in such a way that no rook can capture another. For example, label the rows of the chessboard with the names of the people, and the columns likewise, and say that a rook in rank i and file j (row i and column j) means that person i has drawn person j. No two rooks can be in the same row (a person can't get gifts for two people) or in the same column (a person can't get gifts from two people). A permutation with forbidden positions is then placing N non-capturing rooks on a *damaged* chessboard, where large irregular lumps of hardened smelly cheese are firmly stuck to forbidden squares, thus preventing a rook from standing on them. For example, the derangement requirement is modeled by placing cheese all along the main diagonal. Now you *can* systematically count the number of ways to do this without backtracking, but accounting for the 2-dimensional geometry of the forbidden positions is essential. This makes it tricky. Here's how: Stare at your damaged chessboard. Pick any square without a lump of cheese on it (if there aren't any, you're done: it's impossible). You have two choices: you can either put a rook there, or not. This splits all possible solutions into two mutually exclusive kinds, so the total number of solutions is the sum of the number of solutions for each case: 1. You do put a rook there. Then physically remove that square's rank and file from the chessboard, and count the number of ways to put N-1 non-capturing rooks on the resulting N-1 x N-1 chessboard. 2. You do not put a rook there. Then firmly press a large irregular lump of hardened smelly cheese on to the square, and count the number of ways to place N non-capturing rooks on this cheesier N x N chessboard. 3. Add those two results. This reduces the problem to two subproblems of the same kind, but each subproblem either has a smaller board to worry about or a board with more cheese. So proceed recursively, and every path eventually leads to a 1x1 board and/or a board completely filled with cheese. Those are trivial. Here's the depressing part: the end cases are *too* trivial. The tails of the recursion contribute only 0 or 1 each to the total count. So there are a *lot* of function calls to get those to add up to something that can grow as large as N!/e (if you've got no restriction other than derangement). This is where "accounting for the 2-dimensional geometry" comes into play: at each step, you want to pick the free square with care, striving to produce subproblems where the cheese-free squares can be split into two smaller chessboards with no rows or columns in common. The number of solutions for a chessboard of that special form is the *product* of the number of solutions for the two smaller chessboards (they have no rows or columns in common, so what you do to one of them can have no effect on the other), and that lets you get to the final answer enormously quicker. The next twist in the tale is too involved to explain here: it turns out that it's possible to deduce the result from the numbers of ways to place 0, 1, 2, ... and N non-capturing rooks on the "cheese-inverted" chessboard obtained by putting cheese on all the empty squares and removing the cheese from the cheesy squares. In most applications, there are many more empty squares than cheesy squares, so inverting their roles can slash the amount of computation. If you enjoy this sort of thing, the theory is elegant and makes for a delightfully delicate series of programming challenges (start with a Cheese class ). I did it in Fortran once, many years ago -- and that I don't have to anymore is the true meaning of Thanksgiving . sinterturkeyly y'rs - tim From sessile at in-gen.net Tue Nov 9 13:16:39 1999 From: sessile at in-gen.net (sessile at in-gen.net) Date: Tue, 09 Nov 1999 13:16:39 -0500 Subject: Can't use len() on returned PyList object? In-Reply-To: <19991109143023.A1001@Ridcully.home> References: <3.0.6.32.19991108211217.007cb210@mail.in-gen.net> <3.0.6.32.19991108211217.007cb210@mail.in-gen.net> Message-ID: <3.0.6.32.19991109131639.007d89f0@mail.in-gen.net> My thanks to those who responded. You were correct. I had assigned 'len' as a variable elsewhere in the program. I quite foolishly did this by too closely emulating the C source that my Python program is going to replace. Doh! Thanks again. At 02:30 PM 11/9/1999 +1100, you wrote: >On Mon, Nov 08, 1999 at 09:12:17PM -0500, sessile at in-gen.net wrote: >> Why can't I use 'len()' to find the length of a list >> returned from my new extension module? The error is >> shown as: >> >> TypeError: call of non-function (type int) > >You have probably used 'len' as an integer variable at some point >previously in the program. This would have overwritten the builtin >declaration of len as a function. From tbryan at python.net Mon Nov 8 21:47:59 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Mon, 08 Nov 1999 21:47:59 -0500 Subject: python: something completely different References: <3820C0B8.62B2@iowegian.com> <38249ED2.BB7EA1DE@znet.com> <8028jv$7cf$1@hub.org> <38259F18.437@iowegian.com> Message-ID: <38278B5F.1AFF953C@python.net> Grant Griffin wrote: > I don't know if a Matlab-to-Python translator is currently available, > but if not, I don't think it would be all that hard to write one (in > Python, of course). I'm sure how useful such a thing would be. Most people I know who seriously use Matlab use at least one of its toolboxes. They also tend to output plots/graphs when they're done with their work, and Matlab actually makes some very nice plots. I haven't looked at the state of Python plotting/graphing in about a year, but when I last looked, I judged that the effort to produce nice plots with Python would be considerable. That said, from what I remember of Matlab syntax, it probably would be a fairly straight-forward project to implement a translator for the basic vector/array/structure/scripting syntax (assuming that we're translating to a Python with Numeric Python compiled). It might be a fun project, but it probably wouldn't move too many people away from Matlab until they could get colored, labeled, scaled plots from Python. Most people would also have to be willing to code the few crucial routines that they've been using from a Matlab toolbox. Of course, if the translator existed, maybe more people would try to move to Python. That could spur a lot of growth in toolboxes for Numeric Python! :) ---Tom From ivanlan at callware.com Mon Nov 29 19:04:56 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Mon, 29 Nov 1999 17:04:56 -0700 Subject: [Tutor] TKinter References: <003301bf3ab5$13138080$0c5bdfc8@the-user> <38431229.7B60A603@worldnet.att.net> Message-ID: <384314A8.6929482C@callware.com> Hi All-- Ralph Alberti wrote: > > Have you seen this: > > http://starship.python.net/crew/fredrik/tkintro/Introduction.htm > > --Ralph > > Alexandre Passos wrote: > > > > Has someone got a link to some __downloadable__ tutorial of TKinter? > > And also this: http://www.pythonware.com/library.htm Which has a link to the PDF version of the introduction. There're lots of parts missing, 'cause /F is so busy, but it's still about the best place to start. ... Take care, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours ---------------------------------------------- From wware-nospam at world.std.com Tue Nov 30 09:12:49 1999 From: wware-nospam at world.std.com (Will Ware) Date: Tue, 30 Nov 1999 14:12:49 GMT Subject: Python complaints References: <81bmmi$279$1@nnrp1.deja.com> <3841EE77.6B5D6AC9@wjk.mv.com> <38435C43.B238EC15@mindspring.com> Message-ID: Will Ware wrote: > I find myself grumbling about having to type "x = x + 1". The really > clean thing to do, given that integers are objects, would be to define > increment and decrement methods, so you'd type something like "i.incr()". Jesse D. Sightler (jsight at mindspring.com) wrote: > Wouldn't this be impossible, since Integers are also immutable? So, eg, > i.incr() could only return an incremented version of i, but not actually > increment i? Right, this is what Gordon was pointing out. A "++" method could not magically reach out of its object, find the "i" variable, and bind it to the incremented value. Something like this could be accomplished by tinkering with Python's parser, but that wouldn't be a great idea. A lot of work for something that would never find wide acceptance. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From exeq at my-deja.com Wed Nov 3 17:06:39 1999 From: exeq at my-deja.com (exeq at my-deja.com) Date: Wed, 03 Nov 1999 22:06:39 GMT Subject: Tkinter and Solaris 7 Sparc [Q] Message-ID: <7vqblc$ham$1@nnrp1.deja.com> Hi! I am trying to compile Python 1.5.2 with tkinter on Solaris 7 (Sparc). I have installed TCL/TK 8.0.5, GCC 2.8.1 / Sun Workshop 5 (I tryied with both compilers). I just get an error saying that libX11.so.6.1 is needed. Is there a way to build tkinter without X11? Or I just need to download and install X11? Thanks in advance. /B Sent via Deja.com http://www.deja.com/ Before you buy. From mcalla at home.com Tue Nov 9 20:49:06 1999 From: mcalla at home.com (Mike Callahan) Date: Wed, 10 Nov 1999 01:49:06 GMT Subject: Using GNU C complier as the "default" windows complier Message-ID: This a question from a newbie but I was thinking...why doesn't the default Python code for windows use the GNU C complier for windows instead of the MS complier. Would it be possible to distribute the GNU package along with the Python package and thus make it easier to compile, extend, and embed Python, use freeze, etc? I know it would take some work, but it seems it would make windows Python a lot more like unix Python. Just a thought... From thantos at chancel.org Tue Nov 16 18:05:13 1999 From: thantos at chancel.org (Alexander Williams) Date: Tue, 16 Nov 1999 23:05:13 GMT Subject: Beginning programming with Python References: <382B3A53.5816B2@callware.com> <382B3D79.74CD3E0F@email.sps.mot.com> <80p9ds$ppo$1@newshost.accu.uu.nl> <38312D55.A36EB56D@iqsoft.hu> <383195C1.826B3342@iqsoft.hu> Message-ID: On Tue, 16 Nov 1999 18:34:57 +0100, Nemeth Miklos wrote: >engineer. I like Python but I'd like to be convinced that Python is not only >for scientific programming, but also for business programming. I'd like to know >the general opinion of the "official" Python community on this (I think) The proof is in the pudding, as it were; there are several /very/ large programming projects in the business community (including my own) which are Python Powered; I've certainly found maintainance /easier/ in Python than in strongly-typed languages; a type-error will typically be found in testing (which is far easier to do bit by bit as you go with the interpreter than the usual compile-run-edit cycle) rather than when the program is deployed. -- Alexander Williams (thantos at gw.total-web.net) "In the end ... Oblivion Always Wins." From m.faassen at vet.uu.nl Sun Nov 14 06:14:45 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 14 Nov 1999 11:14:45 GMT Subject: Python for children..... References: <9911051740130D.02530@william.jinsa.org> <7GOU3.272$Ae3.194028@news-dal.corridex.com> <801p16$10s$1@vvs.superst.iae.nl> <199911080328.WAA24200@acer.spvi.com> <199911080333.WAA24231@acer.spvi.com> <809tlb$1eg$1@vvs.superst.iae.nl> Message-ID: <80m5j5$mvm$2@newshost.accu.uu.nl> Carel Fellinger wrote: > Steve Spicklemire wrote: >> Forgot to mention: >> PyBots: http://opensource.spvi.com > looks interesting, but elas, it doesn't run on linux > and i've hardly any room on my left-over windows partition. > so I've to wait for an other port or Sinterklaas. Ah, yeah, Sinterklaas, Sinterklaas. I explained all about him last year when the Goedheilig Man was around. Interested people should check DejaNews. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From cgw at fnal.gov Tue Nov 16 07:14:32 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Tue, 16 Nov 1999 13:14:32 +0100 (MET) Subject: Alright, I give up...chalk this one up to experience... In-Reply-To: <383145c0.4445469@212.225.36.99> References: <383145c0.4445469@212.225.36.99> Message-ID: <14385.19112.173132.954102@gargle.gargle.HOWL> Endgamer writes: > I can't see why, when I run this as a script from Windows 95, it > doesn't return the current date setting on my machine. > > # Date setting program (chunk 1) > import os > > olddate=os.popen("date",'r') > olddate=readdate > print olddate > What is "readdate"? I'd expect this snippet of code to give a NameError since readdate isn't defined anywhere. I'm not quite sure what your intention is here, with the line "olddate=readdate"; what's the point of calling the popen function and assigning the returned value to olddate if on the very next line you're going to throw this value away (by reassigning to olddate), before doing anything with it? I think the info that you need to know is this: os.popen returns a file-like object from which you can read the output of the executed command. You use it like this: import os pipe = os.popen("date",'r') olddate = pipe.read() exit_status = pipe.close() print olddate From nemeth at iqsoft.hu Thu Nov 4 14:08:32 1999 From: nemeth at iqsoft.hu (Németh Miklós) Date: Thu, 04 Nov 1999 20:08:32 +0100 Subject: Extending Python dynamically References: <3F8BA119B48AD11197470008C7A493CB98B636@HQOBGEX1> Message-ID: <3821D9B0.56C01339@iqsoft.hu> ScherBi at BAM.com wrote: > > I have downloaded DCOracle extension. I have RH6.0, and (at > > least until now) I have not installed the source distribution of Python. I > have > > installed only the binary RPMs. I unpacked DCOracle in a directory and > > managed to build the so files (Buffer.so and oci_.so). > > How to install then this DCOracle package? I have been trying > > to figure out but no success. > > Create a directory somewhere in your pythonpath (import sys; print > sys.path), call it DCOracle. > In this directory put the two .so files, and all the .py files that came in > the DCOracle package. > > Then you may import DCOracle. > > Let me know if you need more help. > > Bill Scherer Thank you for your help. The method you suggested works perfectly! However, I do not understand completely how the Python interpreter finds out that it has to load an so file. Normally -- I believed -- when Python sees an "import xxx" statement it looks for a xxx.py, xxx.pyc or xxx.pyo file in the $PYTHONPATH directories or an xxx subdirectory having an __init__.py file, but not an xxx.so file. This means that if I add the current directory to the $PYTHONPATH (such as export PYTHONPATH='.' Python will find any arbitrary so file in the $PWD? Anyway, I am very happy that I do not have to recompile Python every time I add a new extension library (ie. an so file) :-). Thanks again, NM From guido at cnri.reston.va.us Thu Nov 4 22:36:44 1999 From: guido at cnri.reston.va.us (Guido van Rossum) Date: 04 Nov 1999 22:36:44 -0500 Subject: __str__ vs. __repr__ References: <000401bf25b9$88ea57e0$2e2d153f@tim> <199911040157.UAA11908@eric.cnri.reston.va.us> Message-ID: <5logd98v8z.fsf@eric.cnri.reston.va.us> Bernhard Herzog writes: > How about a hook function a la __import__? I.e. have a function > __format__ [1] in __builtin__ that is bound to repr by default. Whenever > Python prints the result of an expression in interactive mode, it calls > __format__ with the result as parameter and expects it to return a > string ready for printing. Brilliant! The default function could do all the current built-in magic -- print nothing if it's None, assign it to builtin _, and so on. I wonder if it would have to have a __magic__ name? It could be called display and it could be documented and usable in non-interactive programs as well. Or am I getting carried away? (Possibly the habit if assigning to _ and suppressing None would make the default display() function a bit clumsy to use.) --Guido van Rossum (home page: http://www.python.org/~guido/) From tim_one at email.msn.com Wed Nov 10 00:30:13 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 10 Nov 1999 00:30:13 -0500 Subject: IDLE and rlcompleter [Was: Re: making the Python case to my dept.] In-Reply-To: Message-ID: <000201bf2b3c$a977dc20$d32d153f@tim> [Michael Hudson] > ... > While we're on the subject of idle, is there any easy (preferably one > or two keystrokes) that way to import/reload the module being edited > into the Python shell and bring said shell to the front for instant > interactive play? That'd be ?bercool. Already implemented, in the current CVS IDLE. ubergooberly y'rs - tim From ajung at sz-sb.de Thu Nov 11 10:38:38 1999 From: ajung at sz-sb.de (Andreas Jung) Date: Thu, 11 Nov 1999 16:38:38 +0100 Subject: .html -> .ps ? In-Reply-To: <19991111080506.A1007@better.net>; from parkw@better.net on Thu, Nov 11, 1999 at 08:05:06AM -0500 References: <19991111080506.A1007@better.net> Message-ID: <19991111163838.A943@sz-sb.de> On Thu, Nov 11, 1999 at 08:05:06AM -0500, William Park wrote: > Hi, > > I need to convert HTML file to Postscript, so that I can send fax it. > > 1. Does anyone have experience with 'html2ps', 'html2tex', and > 'html2latex' programs? Or, is there any other program that will do > the conversion in Python or otherwise? > > 2. Is there a command-line options to tell Netscape to print to a file? > This would be ideal, since one can already do this manually with > mouse. Take a look at w3m (http://ei5nazha.yz.yamagata-u.ac.jp/~aito/w3m/eng/ ). w3m is a textmode browser like lynx however w3m is able to render tables. With the -dump option of w3m you can dump the ascii outpout to stdout - so you're able to convert html to ascii and then to postscript. There is also a html2ps converter (in Perl written) available however the latest version is outdated and has never readched a stable state. Cheers, Andreas From olivier at scripps.edu Thu Nov 11 10:57:34 1999 From: olivier at scripps.edu (Olivier Roche) Date: Thu, 11 Nov 1999 07:57:34 -0800 Subject: How do I compile NumPy on Linux? References: <382A8094.3354DE70@mdmlab.mi.infm.it> <19991111064736.A528@better.net> Message-ID: <382AE76D.A448CC4B@scripps.edu> William Park wrote: > On Thu, Nov 11, 1999 at 09:38:45AM +0100, Sandro Ferrari wrote: > > I downloaded the LLNLDistribution.tgz file and followed the installation > > instruction: > > cd Numerical > > ./makethis.py > > but I get the message: > > make: Makefile.pre.in: No such file or directory > > make: *** No rule to make target `Makefile.pre.in'. Stop. > > make: *** No targets. Stop. > > In the documentation isn't mentioned anything about it. > > Any help? > > thanks > > Sandro > You must just install the "python-devel" rpm to get the Makefile.pre.in. You should have with rpm -qa | grep python python-1.5.1-10 pythonlib-1.23-1 python-devel-1.5.1-10 Olivier -- ___________________________________________________________ Olivier Roche, PhD Department of Molecular Biology, TPC6 The Scripps Research Institute Tel (858) 784 9782 10550 North Torrey Pines Road Fax (858) 784 8688 La Jolla, California 92037 E-mail: olivier at scripps.edu http://www.multimania.org/09/oroche/ ____________________________________________________________ From S.I.Reynolds at cs.bham.ac.uk Wed Nov 17 07:02:54 1999 From: S.I.Reynolds at cs.bham.ac.uk (Stuart Reynolds) Date: Wed, 17 Nov 1999 12:02:54 +0000 Subject: Wild idea - a type finder Message-ID: <3832996E.1517@cs.bham.ac.uk> Does anyone know of any tools which let you do things like: We have some exisiting function: def f(a, b): return a(int) Or in another example you might get: >>> findtype( add ) (number)(number)-->(number) >>> findtype( map ) (()())(seq)(seq)-->(seq) ( ()() ) denotes a function which takes two arguments of unknown type. I've only ever seen this kind of thing in pure functional programming languages (gopher to be specific). The reason I ask is that I think, in general, its really useful to be able to tell what minimum interface the arguments you give to a method needs to support (you can stick it in your documenation for one thing). It would also be pretty useful to uncover the kind of nasty bugs which crop up in untyped langauges whereby the functions or methods you've written have stronger requirements on the interfaces of their arguments than you realised (espcially in the case where your code calls lots of other functions who's types you're not too sure about). Stuart From zippy at cs.brandeis.edu Wed Nov 24 01:40:21 1999 From: zippy at cs.brandeis.edu (Patrick Tufts) Date: Tue, 23 Nov 1999 22:40:21 -0800 Subject: Python complaints References: <38397696@news.xtml.co.uk> <221119992150405215%zippy@cs.brandeis.edu> Message-ID: <231119992240219368%zippy@cs.brandeis.edu> In article <221119992150405215%zippy at cs.brandeis.edu>, Patrick Tufts wrote: > Here's an example: > > (defun foo (x) (mod x 4)) ; return x mod 4, always an integer > > (defun bar (x) (^ 2 x)) ; return 2^x, always an integer > > (defun baz (a b) (+ (foo a) (bar b))) ; foo(a) + bar(b) A reader has pointed out that this is a bogus example, because foo and bar are not guaranteed to return ints (among other things). I could give an example like (defun foo (x) 4) (defun bar (x) 3) (defun baz (a b) (+ (foo a) (bar b))) but that's so simple that it's not very interesting, and my mind is too fuzzy now to come up with an interesting example. If anyone else is up to the challenge of correctly saying what I should have, please do. --Pat From fredrik at pythonware.com Thu Nov 11 03:17:15 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 11 Nov 1999 09:17:15 +0100 Subject: How to perform syntax check in Python References: <382A2384.CC37FBA8@hp.com> Message-ID: <00bf01bf2c1d$2a927be0$f29b12c2@secret.pythonware.com> Meera wrote: > I am looking for a utility to perform syntax validation in python. > Consider following code - > > try: > a = 3 > print a > #Do some more processing > except: > print b > > The fact that variable b is not defined is known only when we get > exception. > We will get 'NameError exception' _not_ the actual exception we are > expecting. > > When we have multi-developer and multi-platform environment - such > feature is crucial. This is one area which I would like python to improve > over conventional language. having been there and done that, I'd say a good testing harness is a better way to address that -- helps you find both code glitches and real bugs (!). but if you really prefer linting, check out chordate's pylint utility, available from: http://www.chordate.com/kwParsing/index.html From dway at mat.net Wed Nov 3 19:43:06 1999 From: dway at mat.net (Doug Way) Date: Thu, 04 Nov 1999 00:43:06 GMT Subject: Python and Smalltalk (Was: Re: Comparison between Python and "Ruby") References: <1270663667-24391282@hypernet.com> <381ED7A6.D7D7FB13@compaq.com> <877lk1wiij.fsf@ev.netlab.co.jp> <19991102154543.A4469@optiplex.palga.uucp> <381F9EB4.63FA033F@python.net> Message-ID: <7vqkqq$oa7$1@nnrp1.deja.com> In article , neelk at alum.mit.edu wrote: > > Python (and Ruby, for that matter) remind me more of Smalltalk than > anything else -- ie, they have extensive libraries, a community with a > love of elegance but not of purity[*], and a greater focus on practical > applications than on academic research. > > The differences are that there's less of a closed-world attitude in > Python than in the ST world, though -- Python can be used for sysadmin > work where ST (even Squeak) wouldn't be a natural fit. But on the flip > side Smalltalk has always had a stronger focus on UI and dev > environments. This is changing, though -- the ST culture is beginning > to value the ability to deal with the world outside the system image, > and Guido's latest enthusiasm is "computer programming for everybody" > (which is a very ST-ish sort of idea). > > Neel Smalltalk is sort of on the "other side" of Python from Perl in a lot of ways. Smalltalk's syntax is considerably pared down from even Python's not-too-complex syntax. In other words, if you hate Perl, you might really like Smalltalk. :-) (Randal Schwartz might disagree with me here, 'cause I know he's on the Squeak list...) I agree with Neel about the differences that exist. Python does interact with the outside world better, but Smalltalk's dev tools really are great, and are easy to tweak to suit your own needs, since everything's written in Smalltalk and the source is right there. >From a historical point of view, Smalltalk is a little like Lisp, in that it's a little outside of the mainstream, but it has enough new ideas in it that will give it a very long lifespan. Smalltalk will still be relevant 20 years from now, just as Lisp-based languages are still reasonably relevant today, after 40 years. I suppose "having a lot of new ideas" and "being a little outside of the mainstream" go hand in hand. (Smalltalk isn't *that* obscure, though... there are more Smalltalk programming jobs available than, say, Python or Lisp jobs.) Contrast this with a mainstream language like Java, which will have a huge spike in popularity for a few years, but since it's mostly just a cleaned-up version of another language (C++), it won't be cutting-edge for very long. Which isn't to say that it will dissappear, just that it will be easier to replace with something better as the new "King of the Mainstream Programming Languages" in a few years. In any case, Smalltalk is definitely worth exploring if you're looking at programming languages similar to Python. See http://squeak.org, http://www.goodstart.com/dialects.html, etc. - Doug Way EAI/Transom Technologies, Ann Arbor, MI http://www.transom.com dway at mat.net, @eai.com Sent via Deja.com http://www.deja.com/ Before you buy. From sekter at mail.matav.hu Mon Nov 15 06:46:03 1999 From: sekter at mail.matav.hu (Arpad Kiss) Date: Mon, 15 Nov 1999 12:46:03 +0100 Subject: PIL 1.0 on win32? Message-ID: <009b01bf2f5e$fef3b900$029f38c3@geometria.hu> Hi, I have a PIL based Zope product I have been developing on a Linux box. I just wanted to test it on a Windows NT(sp5), but it doesn't work.:-( At first it didn't recognize my fonts, because the readline method on win32 returns 10+13 at the end of the lines and in ImageFont.py only \n is checked. After I solved it I got an error message(memory error in line 151 of ImageDraw.py) when I wanted to draw some text. When I commented out the text drawing code in my program, then I got back a picture, but it is mirrored! Of course on linux box my program works fine. I just want know who else use PIL 1.0 on win32 and what experiences they have. Should this text drawing function work? Is it my fault? Best regards, Arpad Kiss From skaller at maxtal.com.au Thu Nov 25 17:48:20 1999 From: skaller at maxtal.com.au (skaller) Date: Fri, 26 Nov 1999 09:48:20 +1100 Subject: Python on top of Oberon instead of C? References: <8192fu$91h$1@nnrp1.deja.com> Message-ID: <383DBCB4.91CB8B5F@maxtal.com.au> William Tanksley wrote: > > On Sun, 21 Nov 1999 15:18:24 GMT, srenner at lycosmail.com wrote: > >Anyone think this is an interesting idea? > > Not as such -- the work of translating Python's existing code to Oberon > doesn't seem to be repaid by the benefits of Oberon. > > OTOH, I _would_ like to see a Python compiler which output Juice format > rather than bytecodes. That would be very nice indeed. My understanding > is that Viper is very close to this already. Not yet. In a previous article, Hal wrote: >Having already responded on the Native Oberon list, I must add that I'm more >familiar with Oberon than Python. But I'm back-and-forth between these two >languages. I'm guessing that the OPython interpreter that produces the byte >code (*.pyc) would be the hardest part. I don't think this is actually correct. My experience building Viper is that the 'hardest' part is implementing the libraries. Not that it is 'hard' per se, just quite laborious, and requiring continual fiddles to the overall architecture, while juggling compromises between CPython implementation details, and the needs of real CPython programs. I consider the following modules basic: _builtins_, string, exception, types, marshal, pickle, sys, os, posix, re, array, traceback, time (and a few more ..) Interestingly, string, exception, and types work as written in pure python, without modification (but 'string' is way too slow). In addition, Viper will support a full scale, _builtin_ GUI, rational numbers, and probably matrices. I'd guess and Oberon version of Python would face the same issues: I don't think that the 'python language' is much use without the standard libraries people need to do actual work. -- John Skaller, mailto:skaller at maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia homepage: http://www.maxtal.com.au/~skaller voice: 61-2-9660-0850 From pinard at iro.umontreal.ca Mon Nov 29 17:28:16 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 29 Nov 1999 17:28:16 -0500 Subject: Proposal: Python Info Collective In-Reply-To: m.faassen@vet.uu.nl's message of "18 Nov 1999 10:20:40 GMT" References: <3d1z9sq2uc.fsf@amarok.cnri.reston.va.us> <80oqn9$ocq$2@newshost.accu.uu.nl> <80p9su$ppo$2@newshost.accu.uu.nl> <80piru$13rl$1@hub.org> <80re5d$55a$1@newshost.accu.uu.nl> <810jto$lo0$1@newshost.accu.uu.nl> Message-ID: m.faassen at vet.uu.nl (Martijn Faassen) writes: > No, no, a more extensive deja search indicated to me that this person > has posted under other names to the group previously. Sh*t, I'm unveiled! God knows I did try my very best at using different writing styles, consistently, for each of the various names I use when I wrote to the list, so far. And especially, when I write as Tim Peters. I may confess it now, this invention of mine has been fairly difficult to sustain, all along :-) P.S. - Odo, to one Bajoran: "Your noses are giving me some trouble." -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From fredrik at pythonware.com Mon Nov 15 07:04:24 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 15 Nov 1999 13:04:24 +0100 Subject: PIL 1.0 on win32? References: <009b01bf2f5e$fef3b900$029f38c3@geometria.hu> Message-ID: <01ee01bf2f61$96097a80$f29b12c2@secret.pythonware.com> Arpad Kiss wrote: > I have a PIL based Zope product I have been developing on a Linux box. I > just wanted to test it on a Windows NT(sp5), but it doesn't work.:-( > At first it didn't recognize my fonts, because the readline method on win32 > returns 10+13 at the end of the lines and in ImageFont.py only \n is > checked. PIL opens the font files in binary mode, so this shouldn't be a problem. you probably messed something up when you transferred the font files to the PC... > After I solved it I got an error message(memory error in line 151 of > ImageDraw.py) when I wanted to draw some text. > When I commented out the text drawing code in my program, then I got back a > picture, but it is mirrored! this sounds really weird -- but at least the memory error might be due to bogus font data... what win32 build do you use? can you post some code? > Of course on linux box my program works fine. > I just want know who else use PIL 1.0 on win32 and what experiences they > have. Should this text drawing function work? Is it my fault? fwiw, PIL is being developed on win32... From wjk at wjk.mv.com Sat Nov 27 12:54:27 1999 From: wjk at wjk.mv.com (William J. King) Date: Sat, 27 Nov 1999 12:54:27 -0500 Subject: SMTP References: <19991126095821.87186.qmail@hotmail.com> Message-ID: <38401AD2.31396C84@wjk.mv.com> Was just looking at an interesting program called Rebol which does some interesting things with mail/ftp etc. http://www.rebol.com - handles various protocols etc. A scripting communications/messaging language.. hope I got that correct.. Sassenfrath of Amiga fame is source. This might be yet another simple solution for SMTP area. From mark.hamstra at bentley.com Sat Nov 6 14:12:50 1999 From: mark.hamstra at bentley.com (Mark Hamstra) Date: 06 Nov 1999 14:12:50 -0500 Subject: JPython and NetBeans and Java envy (Was Re: Python and Smalltalk and Java envy) References: <1270663667-24391282@hypernet.com> <7vqkqq$oa7$1@nnrp1.deja.com> <382484F1.F8B8D712@home.com> <99110612201506.02970@quadra.teleo.net> Message-ID: Patrick Phalen writes: > [Wostenberg, on Sat, 06 Nov 1999]: > > :: Intersting observation. Perhaps it comes down to those of us who are > :: comfortable with niche languages (Python, Smalltalk, Lisp) and those who > :: suffer Java-envy . Do Python people, Ada advocates, or little Lispers wring > :: there hands about the fact "we are not the most used language?" Why should > :: Smalltalkers? > > > Speaking of Java envy, Barry Warsaw pointed out the other day on the > JPython list that www.netbeans.com is running a survey to pick the best > scripting language to be integrated with NetBeans. (You'll find the form > in their left navbar.) > > I won't reveal the *overwhelming* winner, thus far. Find out for > yourself. ;) Just curious, why not Bean Scripting Framework, since it allows for JPython and any other scripting language that has been hooked into the BSF? -- Mark Hamstra Bentley Systems, Inc. From x at x.x Wed Nov 24 17:45:47 1999 From: x at x.x (Eric Jacobs) Date: Wed, 24 Nov 1999 17:45:47 -0500 Subject: Python complaints References: <867lj85g4c.fsf@g.local> <00bf01bf3685$0c345610$f29b12c2@secret.pythonware.com> Message-ID: <383C6A9B.4049CB12@x.x> Fredrik Lundh wrote: > > note that python already has a special syntax > for this purpose: > > >>> a = range(20) > >>> print a[1:20:3] > Traceback (innermost last): > File "", line 1, in ? > TypeError: sequence index must be integer > > (note that you got a type error, not a syntax > error. numpy arrays fully support this syntax). > > in other words, you don't have to be guido to > realize that something like: > > for i in [1:20:3]: > ... > > could be the right way to do it in Python. in > fact, it's already on the list for 2.0: I don't know if I like that syntax. Taking a slice of what? If I had to replace range, I'd go with: for i in Int[1:20:3]: ... Here Int is an object that represents a list of all integers. We take a slice of it... and get exactly what we expect. Either way, the semantics of lists with an infinite number of elements or negative indices would have to be cleared up somewhat. That would be a good thing. From poinot at onera.fr Thu Nov 25 03:28:38 1999 From: poinot at onera.fr (Marc POINOT) Date: Thu, 25 Nov 1999 09:28:38 +0100 Subject: Numeric module under IRIX 6.5 References: <383C1D37.41863D9B@calibre-dd.com> Message-ID: <383CF336.1B6ED368@onera.fr> Stephen J King wrote: > > I've downloaded LLNL Numeric module and compiled it for IRIX 6.5 (using > -n32 flag), but when importing the module to Python, it dumps core |=( > > Has anyone encountered/solved this problem? > > Thanks > > -- Stephen J King Technology Manager Calibre Digital Pictures > -- king at calibre-dd.com http://www.calibredigital.com > > -- > http://www.python.org/mailman/listinfo/python-list We are using the LLNL module(s) on IRIX 6.5, either with ABI mode -n32 or -64. We met some problems with the Fortran calls we had in our application, some of the Numeric object files were hidding the native fortran library. We removed the f2c_lite.o object file from the library we were using. This now works... perfectly. Marcvs [alias Hop! Zizelp...] From herzog at online.de Tue Nov 9 11:01:30 1999 From: herzog at online.de (Bernhard Herzog) Date: 09 Nov 1999 17:01:30 +0100 Subject: Graphics. References: <3826E949.BBA1BAFD@imf.au.dk> <091119991052098844%kantel@mpiwg-berlin.mpg.de> <80973f$poq@newton.cc.rl.ac.uk> Message-ID: "Richard Brodie" writes: > ...and as everyone knows, if you haven't done Python in German, you > haven't done Python :) > > Ich bin ein Holzf?ller und f?hl mich stark, > Ich schlaf des Nachts und hack am Tag. Shouldn't that have been Ich bin ein Pyonier und f?hl mich stark, Ich hack des Nachts und schlaf am Tag. ? -- Bernhard Herzog | Sketch, a drawing program for Unix herzog at online.de | http://www.online.de/home/sketch/ From xfb52.no_spam at dial.pipex.com Sat Nov 6 06:08:05 1999 From: xfb52.no_spam at dial.pipex.com (Alex Zbyslaw) Date: Sat, 06 Nov 1999 11:08:05 +0000 Subject: Control-C on Unix misbehaviour? References: <000101bf193a$1a2fc8c0$842d153f@tim> <19991018154752.A16714@testserv.mathi.uni-heidelberg.de> Message-ID: <38240C15.1D841E4@dial.pipex.com> Quinn Dunkan wrote: > > On Mon, 18 Oct 1999 15:47:52 +0200, flight at mathi.uni-heidelberg.de > Here's a data point for Irix6: > If you hit ^C at the >>> prompt with readline loaded (python 1.5), python > stops responding. Further ^Cs do nothing, in fact the only way I've found > to get out is to kill from another shell or hit ^z kill %. I had exactly the same problem on FreeBSD 3.2 but ONLY when I had thread support enabled. I have eventually tracked the problem down to a bad interaction (read library/kernel bug) between threads/sigjmp and interrupted reads. I have created two "fixes" which can be applied either to a) python or b) python and readline which fix the problems differently. The fixes are pretty trivial and so far they work for me. You can check them out at http://www.xfb52.dial.pipex.com/patches/python.shtml I don't know how they may affect people who have had ^C dumping them into a shell. No one else has mentioned whether they had thread support enabled or not. >From extensive poking around I am quite sure that this misbehaviour is not a bug in either Python or readline. Good luck, --Alex From mcfletch at vrtelecom.com Tue Nov 16 15:26:04 1999 From: mcfletch at vrtelecom.com (Mike Fletcher) Date: Tue, 16 Nov 1999 15:26:04 -0500 Subject: list.without()? In-Reply-To: <38319104.F54AECEF@appliedbiometrics.com> Message-ID: Hmm, actually, it's only cheap for certain subsets of the problem (which I took to be the common case). In particular, it shines for small numbers of instances in lists of fairly arbitrary size. It falls down completely when you are removing large numbers of instances (such as all of them). I just tested five algos, testing 1 instance in middle of list, and a list composed of only elements to be removed, findings, module, and raw test results below... Conclusions: First is the posted algo (while,try,except,break) -- gives very good performance for the few-in-many case but very poor performance for the many in many cases for large values of many Second is a for loop with == test and append -- gives decent (but not spectacular) results whenever memory effects are not a big factor, not really a contender. Third is the lambda solution (which does surprisingly well) -- gives acceptable but not great performance all over, seems strange that function-call-overhead is so minor a factor. Fourth is a backwards-index-counting scheme with del -- gives marginally better performance than third on few-in-many case, marginally worse than third in many-in-many case. Fifth is Preston's remove function -- gives best results for few-in-many case, again, very poor results in many-in-many case Summary: Looks like the fourth algo is likely the "winner" in this set (assuming few-in-many is the most common case, but that many-in-many is a potential case). Third might be preferred due to the simplicity of the implementation and similar speed. For maximum few-in-many speed, the fifth is the most appropriate. Module is below, along with results run on a PIII 500 under NT. Enjoy, Mike 8<_____ without.py ____________________ def without( source, element): temp = source[:] while temp: try: temp.remove( element ) except: break return temp def without2( source, element ): temp = [] for el in source: if el != element: temp.append( el ) return temp def without3( source, element ): return filter(lambda x, element=element: x!=element, source) def without4( source, element ): temp = source[:] for index in xrange( len(temp)-1, -1, -1 ): if temp[index] == element: del temp[index] return temp def remove(list, element): while element in list: list.remove(element) return list def test( function): import time print "Testing function:", function print " single element at middle:" for dl in (10, 100, 1000, 10000, 100000, 1000000): t = time.time() res = function( range( dl), dl/2) delta = time.time()-t print " %s: %s"%(dl,delta) if delta > 10: print "###Note: Tests skipped due to time overrun" break print print " all elements being removed:" for dl in (10, 100, 1000, 10000, 100000, 1000000): t = time.time() res = function( [1]*dl, 1) delta = time.time()-t print " %s: %s"%(dl,delta) if delta > 10: print "###Note: Tests skipped due to time overrun" break print if __name__ == "__main__": #test( without ) #test( without2 ) test( without3 ) test( without4 ) test( remove ) 8<_____ run results ___________________ p:\>without Testing function: single element at middle: 10: 0.0 100: 0.0 1000: 0.0 10000: 0.00999999046326 100000: 0.0699999332428 1000000: 1.11199998856 all elements being removed: 10: 0.120000004768 100: 0.0 1000: 0.0100001096725 10000: 0.770999908447 100000: 78.7929999828 ###Note: Tests skipped due to time overrun Testing function: single element at middle: 10: 0.0 100: 0.0 1000: 0.0100001096725 10000: 0.039999961853 100000: 0.460999965668 1000000: 19.6879999638 ###Note: Tests skipped due to time overrun all elements being removed: 10: 0.120000004768 100: 0.0 1000: 0.0 10000: 0.0100001096725 100000: 0.110999941826 1000000: 1.16100001335 Testing function: single element at middle: 10: 0.0 100: 0.0 1000: 0.0 10000: 0.0299999713898 100000: 0.341000080109 1000000: 3.39499998093 all elements being removed: 10: 0.129999995232 100: 0.0 1000: 0.0 10000: 0.0299999713898 100000: 0.320000052452 1000000: 3.17499995232 Testing function: single element at middle: 10: 0.0 100: 0.0 1000: 0.0 10000: 0.0199999809265 100000: 0.19000005722 1000000: 1.9129999876 all elements being removed: 10: 0.120000004768 100: 0.0 1000: 0.0 10000: 0.039999961853 100000: 0.401000022888 1000000: 4.00499999523 Testing function: single element at middle: 10: 0.0 100: 0.0 1000: 0.0 10000: 0.00999999046326 100000: 0.0509999990463 1000000: 0.580000042915 all elements being removed: 10: 0.130999922752 100: 0.0 1000: 0.00999999046326 10000: 0.771000027657 100000: 79.1130000353 ###Note: Tests skipped due to time overrun From ScherBi at BAM.com Mon Nov 29 09:34:54 1999 From: ScherBi at BAM.com (ScherBi at BAM.com) Date: Mon, 29 Nov 1999 09:34:54 -0500 Subject: Unbuffered stdout Message-ID: <3F8BA119B48AD11197470008C7A493CB98B693@HQOBGEX1> try using #!/usr/bin/env python -u at the top of your scripts (assuming unix, or at least apache here) see python --help for more info. Bill > -----Original Message----- > From: leon [mailto:leonar_n at epita.fr] > Sent: Monday, November 29, 1999 9:17 AM > To: python-list at python.org > Subject: Unbuffered stdout > > > Hi there ! > > I'm developping an IRC like software which must work on the > Web. I can't use > Java, > and I'm using Python to program the CGI. > But, I have a big problem : I don't know how to make the > stdout unbuffered. > I tried to make some > sys.stdout.write("test") > sys.stdout.flush() > but it don't work. > > So any idea ?? > > > Leon. > > > > -- > http://www.python.org/mailman/listinfo/python-list > From nemeth at iqsoft.hu Wed Nov 17 05:46:08 1999 From: nemeth at iqsoft.hu (Nemeth Miklos) Date: Wed, 17 Nov 1999 11:46:08 +0100 Subject: Beginning programming with Python [my last comment] References: <382B3A53.5816B2@callware.com> <382B3D79.74CD3E0F@email.sps.mot.com> <80p9ds$ppo$1@newshost.accu.uu.nl> <38312D55.A36EB56D@iqsoft.hu> <383195C1.826B3342@iqsoft.hu> Message-ID: <38328770.EDFD9352@iqsoft.hu> Thank you for all remarks, opinions about the topic. All replies helped me a lot on my way to the Python World. Yesterday night I had a determining experience. I was evaluating Fnorb (a Python CORBA ORB implementation) and it worked perfectly, without a hitch with my quite complex CORBA server written in C++ based on ORBacus. And even more, writing CORBA applications in Python is extremelly simple and easy to read, much easier than in Java or C++. This is a testimonial that CORBA programming with Python is a joy. The CORBA support of Python is of a top priority in my case, because the telecom corporation I work for decided CORBA as the standard enterprise platform (aka bus). I evaluated Perl, Tcl, and PHP but neither of them has acceptable CORBA support (ie. extension modules). Miklos Nemeth From aahz at netcom.com Mon Nov 1 08:33:30 1999 From: aahz at netcom.com (Aahz Maruch) Date: 1 Nov 1999 13:33:30 GMT Subject: Newbie Question References: <7vidsi$qm8$1@nnrp1.deja.com> Message-ID: <7vk4ra$3hp$1@nntp6.atl.mindspring.net> In article <7vidsi$qm8$1 at nnrp1.deja.com>, wrote: > >I am completely new to the language. Congratulations! >I heard that Yahoo uses it? Is this true? Is it a good language for >developing Web Pages? Is it a "best of breed"? Yes. Yes. Yes. Maybe. Python is certainly my favorite language (currently), but I've used enough languages over the years that I'm not going to make wildly exaggerated claims for Python. What I will claim is that all but poorly-written Python code is much more readable than any other language I've tried. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From x at x.x Wed Nov 3 19:33:48 1999 From: x at x.x (Eric Jacobs) Date: Wed, 03 Nov 1999 19:33:48 -0500 Subject: Namespace question... References: <7vqgib$l8v$1@nnrp1.deja.com> Message-ID: <3820D46C.517EA278@x.x> oofoe at my-deja.com wrote: > > Hi! > > How can you access the global namespace in python 1.5.1? I'd like to get > a version string which is declared in the main script file. However, > each module also has a version string which overrides the original one. > I tried to access it as __main__.Version, similarly to $main::Version in > Perl, which is what I'm more familiar with. Of course, it didn't work. > > I have something like this: > > module file foo.py: > ------------------------------ > Version = '$Id$' > > def bar(): > print "Version is: ", __main__.Version > > main program: > ------------------------------ > Version = '$Id$' > > import foo > > foo.bar() > > ------------------------------- > > I'd certainly appreciate any pointers. The namespace stuff seems to get > a little hazy around issues like this. Import it first! Use import __main__. I think some of this confusion arises because there is no global namespace in the sense of a area that exists above all modules (a good design design, IMO). The word global simply refers to variables at the level of the module, as opposed to within a function. From gmcm at hypernet.com Mon Nov 1 07:32:58 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Mon, 1 Nov 1999 07:32:58 -0500 Subject: Comparison between Python and "Ruby" In-Reply-To: <7vjtrc$hmm$1@newshost.accu.uu.nl> Message-ID: <1270663667-24391282@hypernet.com> Martijn Faassen asks: > What-does-TMTOWTDI-stand-for?-ly yours, That's the Perler's war cry. Snort. As if there was only one way to have more than one way to do it. (As used by Matz, of course, it does not qualify as an oxymoron.) - Gordon From schliep at Octopussy.MI.Uni-Koeln.DE Fri Nov 5 23:06:22 1999 From: schliep at Octopussy.MI.Uni-Koeln.DE (Alexander Schliep) Date: 06 Nov 1999 05:06:22 +0100 Subject: Drawing (directed) graphs References: Message-ID: R.M.Everson at ex.ac.uk (R.M.Everson) writes: > Hello, > > Does anyone know of Python code for drawing graphs of the > graph-theoretic type? Ideally, I'd like to be able to interactively > add nodes and edges etc and add data to structures associated with the > nodes and edges. Checkout http://www.zpr.uni-koeln.de/~gato. Gato comes with gred the graph editor. It does not do automatic layout though. Yours, Alexander -- Alexander Schliep schliep at zpr.uni-koeln.de ZPR/ZAIK Tel: +49-221-470-6040 (w) University of Cologne FAX: +49-221-470-5160 Weyertal 80 http://www.zpr.uni-koeln.de/~schliep 50931 Cologne, Germany From michelorengo at netscape.com Tue Nov 2 10:49:33 1999 From: michelorengo at netscape.com (Michel Orengo) Date: Tue, 02 Nov 1999 15:49:33 GMT Subject: Installer v0.3d - problem with Builder Message-ID: <381F0803.6D76E236@netscape.com> I've tried to use the new beta of installer (simple) but I've got an Attribute Error at line 109 in 'archmodule.modules' With installer v0.2 (simple), it works fine. Any idea of what went wrong? Thanks for your help Michel Orengo From tim_one at email.msn.com Mon Nov 8 12:03:31 1999 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 8 Nov 1999 12:03:31 -0500 Subject: __str__ vs. __repr__ In-Reply-To: Message-ID: <000101bf2a0b$2f87d0a0$e1a2143f@tim> >> repr(obj) should return a string such that >> eval(repr(obj)) == obj [Toby Dickenson] > I don't understand the motivation for this requirement. Why would > anyone want to pass such a string to eval? If you anticipate the need > for reconstructing the object from a textual representation, then > surely pickle is a better option? This was well covered by others (not everything of common interest can be pickled; and pickle strings, while portable, are wholly unreadable by people). > ... > OK, so repr as it stands today is clearly not suitable for formatting > for people, It's much better suited for that than is pickle. That is, people can and do cut & paste reprs with confidence, and even edit them by hand. So, indeed, the requirement at the top of the msg doesn't capture *everything* a good repr should do. > and is less than ideal for formatting for the machine. Based on the repr(float) example? That one is easy to repair. So long as interactive mode uses repr() for raw expressions, though, and containers don't "pass str() down", most people won't want to see the "extra" digits most of the time. > However there is a third audience for who it is ideal, the programmer, > who need a representation for use in development tools such as > debuggers, or the interactive mode. People (no, not even programmers ) aren't that monolithic; e.g., in development tools it's likely you're going to want to see the repr() of your own objects and the str() of mine. I'm not trying to address that -- there's only so much we can squeeze out of two functions. It would be a real help if those two (repr & str) had clearly understood purposes, though -- they would cover more of the space if they weren't treated like fuzzy synonyms in practice. > Tim's Rat class is a good example of how __repr__ should not be > implemented, because it exposes the internal representation of the > object, not the external value. Beg to differ: it's an excellent example of how __repr__ should be implemented. The information in a *typical* Rat can require terabytes of string space to represent if expressed as, e.g., a decimal expansion. It's a case where "the internal representation" is no accident: a pair of longs is one of a very few tractable ways to capture the object's true value. Approximations are fine for __str__, though (and, although I didn't show it, Rat.__str__ supports a dozen options for making nice-looking and compact approximation strings -- alas, it's hard to talk Python into *invoking* Rat.__str__!). > However, using a small number of digits for repr(float) does make > sense because it still provides sufficient precision for most > programmers. See above: I told you you'd want to see the str() of everyone's objects except your own <0.5 wink>. This isn't a joke to people who use floats seriously -- just as you take your objects seriously. most-americans-don't-give-a-rip-about-o-umlaut-either-ly y'rs - tim From amitp at Xenon.Stanford.EDU Wed Nov 24 16:12:13 1999 From: amitp at Xenon.Stanford.EDU (Amit Patel) Date: 24 Nov 1999 21:12:13 GMT Subject: Help with SMTP References: <81hase$bdj$1@news.fsu.edu> Message-ID: <81hkbd$1m8$1@nntp.Stanford.EDU> Glenn Kidd wrote: | Hello, | | I wrote a few weeks ago and I received a lot of responses. I have a new | problem. I am trying to write a form mailer and I have gotten the script to | accept the form data and mail the info. The message is received and | everyhting looks in order but the website reports a "500 Internal Server | Error". When I look at the server log I get the following description of | the error: Is your CGI script printing anything out? It needs to print out some headers and a web page body (in HTML format, most likely). - Amit From timmuddletin at news.vex.net Fri Nov 26 22:55:48 1999 From: timmuddletin at news.vex.net (tim muddletin) Date: 27 Nov 1999 03:55:48 GMT Subject: Sending files to a WWW-Server References: <81nje2$su9$1@rznews.rrze.uni-erlangen.de> Message-ID: <81nko4$18hg$1@hub.org> On Sat, 27 Nov 1999 04:32:33 +0100, Jan Stiller wrote: >I'm searching for examples how to send files to a web server. I've found Two ever popular examples listed here: http://www.vex.net/~x/parnassus/apyllo.py?so=d&find=cgi+upload From hniksic at iskon.hr Tue Nov 2 10:41:03 1999 From: hniksic at iskon.hr (Hrvoje Niksic) Date: 02 Nov 1999 16:41:03 +0100 Subject: Printing of individually returned values when running interactively Message-ID: <9t966zk6gvk.fsf@mraz.iskon.hr> I've just noticed (the hard way) a very unusual feature of Python's interactive interpreter mode. If you evaluate several values on several lines, all the values are printed! For instance: >>> if 1: ... 1 ... 2 ... 3 ... 1 2 3 My remark will probably look strange to seasoned Pythoneers, but I'm really surprised by discovering this. Why would anyone want a thing like that? Doesn't it produce loads of debug-like output when pasting more complex things? I guess I'm more used to Lisp interactive interpreters whose REPL is sexp-oriented, and prints the value of the last read sexp. (If you're curious, the case that hit me hard was when I tested mxODBC's connection with a remote database at work. I wrote something like: for i in range(10000): cur.execute('insert into test ...', i) Needless to mention, the execute() method returns a number!) From muniff at yahoo.com Thu Nov 25 03:15:23 1999 From: muniff at yahoo.com (Ahmad Munif) Date: Thu, 25 Nov 1999 08:15:23 GMT Subject: how to split the contain of retr (using poplib module) Message-ID: <383ceefd.3147421@news.dnet.net.id> i'm using poplib module to connect to pop3 server. i can retrieve mail with retr mothode. but i don't know, how to split the contain of mail, so, i can get the value of mail, such as: To,From,body message. how to split it ? From tim_one at email.msn.com Sat Nov 6 04:02:47 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 6 Nov 1999 04:02:47 -0500 Subject: __str__ vs. __repr__ In-Reply-To: <7vvni7$19q0$1@nntp6.u.washington.edu> Message-ID: <000201bf2835$b2c9a380$9c2d153f@tim> [Tim] >> repr(obj) should return a string such that >> eval(repr(obj)) == obj [Donn Cave] > For real? This, along with the later claim about what str() "should do", are paraphrased from the Language Reference Manual (3.3.1 Basic customization). It's "why" e.g. the equation above holds for repr(string) but not for str(string). The builtin types took this stuff as seriously as they could, modulo some unfortunate lapses (like repr(float)) covered elsewhere in this thread. > I'm very used to seeing repr's that don't eval at all - > > '' > "', mode 'w' at 80005660>" > '' Are you for real <0.9 wink>? Be reasonable. > ... > Well, really I guess I would prefer that authors _not_ try to capture > *everything* important, if that means a large data dump. repr is used > in lots of places, like the interactive interpreter, where the output > only has to be roughly indicative, The latter is str()'s purpose (see 3.3.1 again), and the thread was arguing (among other things) that the interpreter use it (instead of repr()) interactively. > and I have never seen and can't find any example of its use with > eval or in any context where it has to be definitive. I've seen it used often as a poor-man's pickle, and as a way to email Python objects as plain text. repr() is very useful for that. Unfortunately, most class authors seem to ignore the distinction (my classes don't!), and that limits its usefulness. The lapses in the core also hurt. One email response I didn't see posted here describes a typical example of the latter: I've only been writing Python for a year or so, but bumped into this 'cheat' and had to write floats out to a file using binary format, a portability nightmare. The floats were in an array, and you can't pickle arrays. >>> repr(12345678901234567.0) '1.23456789012e+016' # Just 12 digits! is currently what you get. >>> x = 12345678901234567.0 >>> x == eval(repr(x)) # Nope. 0 It sure would be nice to be able to count on eval(repr(obj)) == obj. On the other hand, while repr(1L) has to return '1L', there's no reason str(1L) shouldn't be '1'. OTOH, >>> x == eval("%24.16e" % x) 1 >>> on any IEEE-754 conforming platform, as was covered in detail earlier. That's what repr(float) should do. > If there are folks who want to provide this functionality at the expense > of making a string that's unusable for repr's normal applications, > they should put it in a different function. The language took its stand on this issue in 1991 , and you're arguing against *that*. I'm arguing for the language to finish what it started. > ... > Bah. If we get str() because it's pleasant to read, aren't we worried > that repr() will be harsh and stressful? Will one repr() too many send > one of us into a homicidal rage one of these days? I said before that repr() is rarely appropriate -- but essential when it is. > Let us think about taming the cruel repr()! If I may speculate on what > you're trying to say, str() is pleasant because it shows the data in > form that has been digested for human consumption. In contrast to > repr(), which is intended for the machine. Ah -- you *have* read section 3.3.1 . > ... > So look at the way it's really used. Inconsistently, confusingly, and inappropriately, in both classes and (but substantially less so) in the core types. We can't deduce anything useful about what should happen now based on what is a mess in practice. My aim is to get the mess cleaned up. and-thanks-for-your-support-ly y'rs - tim From fredrik at pythonware.com Mon Nov 29 06:01:05 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 29 Nov 1999 12:01:05 +0100 Subject: Problems Finding and installing Tkinter References: <383ED44D.3E31C959@dimensional.com> Message-ID: <01bd01bf3a59$093a9dc0$f29b12c2@secret.pythonware.com> Jim Cochrane wrote: > import _tkinter # If this fails your Python is not configured for Tk > > ImportError: /usr/X11R6/lib/libtk8.0.so: undefined symbol: panic > > So it's not finding a symbol named "panic". I have no idea what library > this should be in. libtcl8.0.so, most likely: $ nm libtk8.0.so | grep panic U panic $ nm libtcl8.0.so | grep panic 0000afac T panic 0005af58 D panicProc From spamfranke at bigfoot.de Tue Nov 2 13:19:14 1999 From: spamfranke at bigfoot.de (Stefan Franke) Date: Tue, 02 Nov 1999 18:19:14 GMT Subject: Drawing (directed) graphs References: Message-ID: <381f2a3b.27625609@news.btx.dtag.de> There's a package for the wxWindows GUI toolkit called OGL (object graphics library). A demo is included in wxPython. Very simple - you can only place & resize vertices with the mouse and the edges follow -, but could be a start. Stefan On Tue, 2 Nov 1999 14:25:34 GMT, R.M.Everson at ex.ac.uk (R.M.Everson) wrote: > >Hello, > >Does anyone know of Python code for drawing graphs of the >graph-theoretic type? Ideally, I'd like to be able to interactively >add nodes and edges etc and add data to structures associated with the >nodes and edges. > >Many thanks >Richard Everson. From andres at corrada.com Sun Nov 21 11:50:11 1999 From: andres at corrada.com (Andres Corrada) Date: Sun, 21 Nov 1999 11:50:11 -0500 Subject: Order of keyword arguments References: <38379233.ADE65CDB@corrada.com> <19991121034245.A21255@quark.emich.edu> <38380F92.D9817451@corrada.com> <19991121114827.A21697@quark.emich.edu> Message-ID: <383822C3.DD0CE177@corrada.com> Jeff wrote: > ....................................................... but I don't see the > advantage to 'knowing' the order that the keywords were used by the calling > function. > I think there would be an advantage to having such a data structure as an ordered dictionary. My "American Heritage Dictionary of the English Language" is such a data structure. ------------------------------------------------------ Andres Corrada-Emmanuel Email: andres at corrada.com Owner http://www.corrada.com/mamey Mamey Phone: (413) 587-9595 ------------------------------------------------------ From arcege at shore.net Thu Nov 4 16:47:53 1999 From: arcege at shore.net (Michael P. Reilly) Date: Thu, 04 Nov 1999 21:47:53 GMT Subject: C-Python tutorial? References: <19991101203120.A29797@optiplex.palga.uucp> Message-ID: Gerrit Holl wrote: : Hello, : I have learned python as my first langauge some time ago. Is there a C : tutorial for python programmers, that covers C programming, espaccialy for : extending it with python? : I think not. Can anyone write one? I would be very grateful! There is not C _tutorial_, but a documents exist on how to write C extensions for Python, embed Python in C and to write your own C types for Python. The first two are on the Python website and the last is at: http://starship.python.net/~arcege/extwriting/pyext.html When I get some more time here at my new job, I'll flesh this doc out, get it formatted and sent off to Fred. -Arcege From jon_mclin at attglobal.net Tue Nov 30 06:42:14 1999 From: jon_mclin at attglobal.net (Jon McLin) Date: Tue, 30 Nov 1999 11:42:14 +0000 Subject: Installation Problem (1.5.2) Message-ID: <3843B816.F4A31F07@attglobal.net> On my Mandrake 6.0 box, I just upgraded from 1.5.1 to 1.5.2 with a fresh compile. Since the 1.5.1 installation placed the binaries in /usr/bin, I used the configure option "--exec_prefix=/usr" My procedure: rm configure.cache make clean ./configure --exec_prefix=/usr make OPT=-O0 # optimization off due to compiler problem (else fails test_long, test_types) make test make install Unfortunately, when I subsequently start the interpreter in /usr/bin, I get: Built-in exception class not found: EnvironmentError. Library mismatch? Warning! Falling back to string-based exceptions Python 1.5.2 (#7, Nov 30 1999, 04:22:04) [GCC pgcc-2.91.66 19990314 (egcs-1.1.2 on linux2 The interpreter in the build directory starts successfully (with ./python): Python 1.5.2 (#7, Nov 30 1999, 04:22:04) [GCC pgcc-2.91.66 19990314 (egcs-1.1.2 on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam If I build and install with the default (to /usr/local/), /usr/local/bin/python starts successfully. No python variables are present in my environment. What am I missing? Thanks, Jon From boud at rempt.xs4all.nl Fri Nov 19 05:53:45 1999 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: Fri, 19 Nov 1999 11:53:45 +0100 (CET) Subject: Beginning programming with Python In-Reply-To: <012401bf3277$72897010$f29b12c2@secret.pythonware.com> Message-ID: On Fri, 19 Nov 1999, Fredrik Lundh wrote: > Boudewijn Rempt wrote: > > You needn't guess about that, I guess ;-). I didn't know there > > was a design team for Python, I though it was Guido's invention. > > it is -- the CWI researchers (including GvR) worked > on Python's predecessor ABC. > > > But I still wonder about the double == - if I can't assign in > > an if, why insist on ==? > > probably because binding and comparision > are two different things; consider: > > a = b = c > > vs. > > a = b == c > Ah, that makes it a lot clearer - I just didn't know about a = b == c. After having earned the monthly envelope with software development for a few years, I'm only know realizing how much I don't know, never having been educated for it. But I've started to read up on it! Boudewijn Rempt | http://denden.conlang.org From mwh21 at cam.ac.uk Wed Nov 24 12:23:38 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 24 Nov 1999 17:23:38 +0000 Subject: Python complaints References: <8666ysfta9.fsf@ix.netcom.com> <012e01bf365d$912fa360$f29b12c2@secret.pythonware.com> <5g08OLe6ncyc5Uu5627KDJVZ2N0R@4ax.com> Message-ID: Dennis Lee Bieber writes: > On Wed, 24 Nov 1999 10:23:27 +0100, "Fredrik Lundh" > declaimed the following in comp.lang.python: > > > Brad Knotwell wrote: > > > Similarly, the only thing I've found missing from Python is C's > > > ternary operator, it would be nice to be able to do something like > > > the following: > > > > > > def max(x,y): return ((x>y) ? x : y) > > > > now that was one lousy example ;-) > > > Also potentially unsafe if either x or y is some expression when > invoked. At least, I seem to recall some suggestion to always put macro > arguments in parens... > > def max(x,y): return(((x)>(y)) ? (x) : (y)) Eh? This is Python, not some yucky character-based macro equipped UNIX implementation language . One thing that x = (var and (ifexp,) or (elseexp,))[0] has over def choose(var,ifvar,elsevar): if var: return ifvar else: return elsevar x = choose(var,ifexp,elseexp) besides brevity is that the former will only evaluate one of ifexp or elseexp, but that isn't going to matter for max (obviously...). It can be handy in things like: x = (hasattr(x,"foo") and (x.foo,) or (None,))[0] though in this case x = getattr(x,"foo",None) is clearly better... Regards, Michael From foxes at theriver.com Tue Nov 2 14:10:47 1999 From: foxes at theriver.com (Andy Fox) Date: Tue, 02 Nov 1999 12:10:47 -0700 Subject: How to control app from Python? References: <38160DD8.5C695E09@theriver.com> <3817BD5F.7E05BDC9@home.com> <38185A03.9AB0FAD6@theriver.com> <7vke68$6r6$1@nnrp1.deja.com> <7vkvia$st7@mail.psy.uva.nl> Message-ID: <381F3737.3D20B5E9@theriver.com> ionel, Thanks for the code example. This looks like _exactly_ what I'm trying to do with Python. The app I want to control is neither a DDE nor COM server. Thanks again, -- Andy Fox From tottinge at concentric.net Tue Nov 30 13:59:41 1999 From: tottinge at concentric.net (Tim Ottinger) Date: 30 Nov 1999 10:59:41 PST Subject: WinNT and python as text filter... References: <3842f32d.30322451@news.concentric.net> Message-ID: <38442033.107384791@news.concentric.net> On Tue, 30 Nov 1999 13:31:51 GMT, "Mark Hammond" wrote: >How are you executing the code? Are you just typing: > >c:\>myscript.py > out > >If so, there is a bug in the NT command prompt - you need to specify the >full path to Python.exe on the command line, and it will work... > This works: c:\> myscript.py and produces the output I want. This, however: c:\> myscript.py > somefile.txt produces an empty text file. I have somewhat better luck with: c:\> python myscript.py > somefile.txt I want this to work from within vim, so it's pretty important that I have pipeable output. Of course, better yet would be getting the python stuff compiled into my vim.... tim From preston at jump.net Wed Nov 17 22:22:08 1999 From: preston at jump.net (Preston Landers) Date: 17 Nov 1999 21:22:08 -0600 Subject: How to capture stdout in an exec'ed string? References: <80v7j4$g0n$1@nnrp1.deja.com> Message-ID: <87bt8sqyan.fsf@gandalf.localnet> Thanks a lot Mark! It only took a few microseconds after I posted to realize what I needed to do. For some reason the concept of saving and restoring the stdout handler didn't occur to me. I was thinking about namespace issues which are not really related. ---Preston "Mark Hammond" writes: > Something like this should work: > > try: > oldout = sys.stdout > sys.stdout = My_STDOUT() > try: > cruft = my_ancient_class() > cruft.do_your_thang() > finally: > sys.stdout = oldout > except SystemExit, msg: > process(msg) > > > Mark. From nhv at cape.com Thu Nov 25 15:36:45 1999 From: nhv at cape.com (Norman Vine) Date: Thu, 25 Nov 1999 15:36:45 -0500 Subject: Journaling Code Message-ID: <81k6m9$gkm$1@newsie2.cent.net> I am involved with a new Open Source 3D Modeller project and we are investigating various undo-redo mechanism's. A member of the group suggested implementing a scripting layer between the modeller and the GUI, and journalling all user invoked scripts in order to be able to rebuild the model from a saved state by simply replaying the journaled code. I am wondering if anyone has used Python for anything similar, and if so if they would be willing to share their knowledge. Cheers Norman Vine archives http://www.topica.com/lists/3dmodeller URL ; http://www.woodsoup.org/~sbaker/modellers From mhammond at skippinet.com.au Sat Nov 27 22:03:22 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 28 Nov 1999 03:03:22 GMT Subject: Pythonwin Reset References: <01bf38df$8127e0c0$3a42c3d1@Cyberus.cyberus.ca> Message-ID: <_X004.7432$VA6.38559@news-server.bigpond.net.au> Nope. The closes Pythonwin could really do is to perform a __main__.__dict__.clear(), and that is pretty easy to type. There is no way Pythonwin could perform a more intrusive reset, as Pythonwin is written in Python! Mark. Gordon Williams wrote in message <01bf38df$8127e0c0$3a42c3d1 at Cyberus.cyberus.ca>... >Hello All, > >Is there a way to reset Pythonwin IDE between runs. I want to eliminate >any rogue objects or modules that are still in memory from the previous run >of the program. > >Thanks > >Gordon Williams From greg.ewing at compaq.com Thu Nov 25 05:57:13 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Thu, 25 Nov 1999 23:57:13 +1300 Subject: Python complaints References: <867lj85g4c.fsf@g.local> Message-ID: <383D1609.322062A5@compaq.com> Gareth McCaughan wrote: > > if you adopt an OO approach to the > parse tree (with things like "class IfStatement(ParseNode):") > then you can't separate out very different operations like > foo.print(), foo.compile() and foo.evaluate(). (That is, > you can't group all the print methods together, and group > all the compile methods together somewhere else, etc.) There is a way to do this. Instead of defining just one class for each parse node, you define classes PrintIfStatement, CompileIfStatement, EvaluateIfStatement, etc. which contain the appropriate methods. Then you define the main IfStatement class so that it inherits all of these. The individual classes can then be grouped however you want, e.g. you could put all the Compile* classes in a Compile module, etc. Greg From thantos at chancel.org Wed Nov 24 08:58:26 1999 From: thantos at chancel.org (Alexander Williams) Date: Wed, 24 Nov 1999 13:58:26 GMT Subject: Python complaints References: <383979F7.25D6@cs.bham.ac.uk> <81fsab$2b$1@news.udel.edu> Message-ID: On 24 Nov 1999 05:15:55 GMT, Terry Reedy wrote: >You are currently welcome to save 3 keystrokes (rather than 4) >by naming the method parameter 's' instead of 'self'. The latter In a fit of lazy genius, I struck upon using 'me' instead; its a more active referent /and/ faster to type than 'self.' :) -- Alexander Williams (thantos at gw.total-web.net) "In the end ... Oblivion Always Wins." From cfelling at iae.nl Sat Nov 6 12:37:42 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 6 Nov 1999 18:37:42 +0100 Subject: making the Python case to my dept. References: <9911051740130D.02530@william.jinsa.org> <7GOU3.272$Ae3.194028@news-dal.corridex.com> Message-ID: <801p16$10s$1@vvs.superst.iae.nl> Evan Simpson wrote: > Now I'm preparing to introduce my children to programming through Python. > I'm starting with their fascination with Alice, the 3-D animation workshop > which even my 6 year old enjoys playing with (though he doesn't script it... > yet). where can I find more on this Alice thing? my kids would love to play with 3-D animations! (I take it that scripting it is with Python) thanks for the pointer -- groetjes, carel From bernhard at alpha1.csd.uwm.edu Fri Nov 26 13:01:23 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 26 Nov 1999 18:01:23 GMT Subject: NEWBIE References: <81m7m3$82$1@news.qub.ac.uk> Message-ID: On 26 Nov 1999 15:06:43 GMT, Stuarty at excite.co.uk wrote: >I have just recently started using Python, after the first day I was further >on than I am after a semester of C programming(were at arrays...). Welcome to the pythondome. :) >tutorial by Giudo van Rossum was very useful, but I attempted printing out the >reference library..there are now less considerably less trees in the world. There are trees wasted and trees put to work. Bernhard -- Research Assistant, Geog Dept UM-Milwaukee, USA. (www.uwm.edu/~bernhard) Free Software Projects and Consulting (intevation.net) Association for a Free Informational Infrastructure (ffii.org) From philh at vision25.demon.co.uk Mon Nov 29 18:25:54 1999 From: philh at vision25.demon.co.uk (Phil Hunt) Date: Mon, 29 Nov 99 23:25:54 GMT Subject: performance of tuple-less Python? References: <1268226961-30285235@hypernet.com> Message-ID: <943917954snz@vision25.demon.co.uk> In article <1268226961-30285235 at hypernet.com> gmcm at hypernet.com "Gordon McMillan" writes: > They're only redundant if the concept of mutability is > meaningless. A reference-based language without a concept > of mutability would be, um, an adventure. Why? -- Phil Hunt - - - phil at comuno.com "Software is like sex, it's better when it's free" -- Linus Torvalds From alex at somewhere.round.here Tue Nov 2 13:41:15 1999 From: alex at somewhere.round.here (Alex) Date: 02 Nov 1999 13:41:15 -0500 Subject: Printing strings References: <381F00E1.721BB47F@cornell.edu> Message-ID: > I'm trying to do something like the following: > > a=4.0 > b=2.0 > print '2(%3.1f)' % a,b > > where I really mean > > print '%3.1f %3.1f' % a,b You could use print string.join(2*['%3.1f'])%(a,b) I suppsoe. Alex. From bbosware at vic.bigpond.net.au Mon Nov 29 23:37:34 1999 From: bbosware at vic.bigpond.net.au (John Leach) Date: Tue, 30 Nov 1999 04:37:34 GMT Subject: Looking for sshlib.py Message-ID: Is there an ssh lib for Python. Or anything similar. I'm looking for something more secure than telnet. Any ideas? Write my own? John Leach http://www.bosware.com.au From gerrit.holl at pobox.com Fri Nov 19 07:34:04 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Fri, 19 Nov 1999 13:34:04 +0100 Subject: urllib.getsize() In-Reply-To: <14388.29839.294164.707388@dolphin.mojam.com> References: <19991118213925.A10221@optiplex.palga.uucp> <14388.29839.294164.707388@dolphin.mojam.com> Message-ID: <19991119133404.A3308@optiplex.palga.uucp> Skip Montanaro wrote: > > Gerrit> I've written a function to get the size of a HTTP/FTP url, is it > Gerrit> good enough to be put in urllib.py? > > My only worry is that HEAD doesn't always work (for whatever reason having > to do more with servers than clients). Would it be better to wrap things in > a try/except block? Oh. Yes, I think getsize() should return -1 or None or an error if HEAD doesn't work. Just doing a GET then isn't good, of course ;-) Another problem: does every HTTP server give the Content-Length header? > Anyone have a URL that fails with HEAD? I don't have one. regards, Gerrit. -- "We all know Linux is great...it does infinite loops in 5 seconds." (Linus Torvalds about the superiority of Linux on the Amterdam Linux Symposium) From bjorn at roguewave.com Fri Nov 5 12:57:14 1999 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Fri, 5 Nov 1999 10:57:14 -0700 Subject: Comparison between Python and "Ruby" Message-ID: <51C9F3C392D0D111A15600A0C99E64A9AF5629@localhost> > Neel Krishnaswami wrote: > > > > Python (and Ruby, for that matter) remind me more of Smalltalk than > > anything else -- ie, they have extensive libraries, a > community with a > > love of elegance but not of purity[*], and a greater focus > on practical > > applications than on academic research. > > Isn't the Smalltalk community pretty enamored of purity? I > mean "if" is > an object that takes messages, right? > > Paul Prescod Almost. A comparison creates a boolean object that takes ifTrue: and ifFalse: (and whileTrue: etc.) messages. Quite elegant... -bjorn From mhammond at skippinet.com.au Mon Nov 1 05:57:58 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 1 Nov 1999 21:57:58 +1100 Subject: PythonWin Debugger In-Reply-To: <001f01bf244c$43f705c0$3acbd9c2@peridot.optichrome.com> Message-ID: <002401bf2457$f6500fe0$0501a8c0@bobcat> > > Hmmm. The debugger should run from all embedded apps, > except Tkinter > > ones (and therefore except IDLE). > > Does that include straight win32 (non-MFC) apps? Yes - it should work there. Eg, if you run "pythonwin\pywin\debugger\fail.py" as a normal script from Python.exe, the debugger should fire up correctly. > > This particular problem would appear to be a bug. I have another > > debugger bug I need to track down, and hopefully I can also solve > > this. > > Is it connected with this one, or is it completely different? Different - occasionally the debugger seems to "hang" (although it hasnt really - it just doesnt respond - as if a modal dialog is up, although the modal dialog is hidden). I can't repro this at the moment, even tho I have seen it before :-( > > OTOH, the best stragegy for this is probably remote > debugging - use a > > seperate process to perform the debugging. This would also solve a > > few of the hairy "blocking" problems I need to deal with. However, > > this doesnt appear trivial either :-( > > I should imagine not. I suppose there is some sort of API > under Windows > to allow this sort of thing (like the Visual C++ debugger does) but I > wouldn't have any idea where to start. That API is too low-level for Python to use effectively. We really dont need the ability to replace an instruction with a break-point. Mark. From nick at src.uchicago.edu Tue Nov 2 15:50:57 1999 From: nick at src.uchicago.edu (Nick Collier) Date: Tue, 02 Nov 1999 14:50:57 -0600 Subject: Can't start IDLE Message-ID: <381F4EB1.AFD9BA32@src.uchicago.edu> On winNT sp3 I get the following message when I do a "python idle.py" from the command line: C:\Program Files\Python\Tools\idle>python idle.py Traceback (innermost last): File "idle.py", line 3, in ? PyShell.main() File "PyShell.py", line 612, in main fixwordbreaks(root) File "EditorWindow.py", line 606, in fixwordbreaks tk.call('tcl_wordBreakAfter', 'a b', 0) # make sure word.tcl is loaded TclError: invalid command name "tcl_wordBreakAfter" I looked around deja.com and found one other person with the same problem, but no response so I'm asking here. thanks, Nick -- Nick Collier nick at src.uchicago.edu Social Science Research Computing University of Chicago Chicago, IL 60637 From jeremy at cnri.reston.va.us Tue Nov 16 15:37:09 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Tue, 16 Nov 1999 15:37:09 -0500 (EST) Subject: Final classes like in java??? In-Reply-To: <14385.48747.331513.47679@weyr.cnri.reston.va.us> References: <80sao7$1848$1@rtpnews.raleigh.ibm.com> <14385.45862.55010.146256@weyr.cnri.reston.va.us> <14385.48236.202756.297241@goon.cnri.reston.va.us> <14385.48747.331513.47679@weyr.cnri.reston.va.us> Message-ID: <14385.49269.629053.250222@goon.cnri.reston.va.us> >>>>> "FLD" == Fred L Drake, writes: FLD> I wrote: >> Not guaranteed, but this should be good enough: FLD> Jeremy Hylton writes: >> This doesn't really work. FLD> That's exactly why I said it wasn't guaranteed. ;-) Would you be interested in buying my general purposes NP algorithm solver? It provides polynomial time solutions to all problems in NP. I don't guarantee the results, but it should be good enough . Jeremy From skip at mojam.com Thu Nov 11 17:30:20 1999 From: skip at mojam.com (Skip Montanaro) Date: Thu, 11 Nov 1999 16:30:20 -0600 (CST) Subject: Beginning programming with Python In-Reply-To: References: Message-ID: <14379.17276.267502.673474@dolphin.mojam.com> Aaron> How quickly can I expect to pick up Python? You should be comfortable with the syntactic elements of Python in a few minutes (modulo the indentation-based block structure that tends to initially derail people with a Perl/C/Pascal background) and presuming you are familiar with object-oriented programming, comfortable with the language as a whole within a few hours. Unlike Perl, where much of the power is in the language itself (e.g., its regex machinery), much of Python's functionality lies in modules that you import when you need them (see http://www.python.org/doc/lib/modindex.html, for example). Getting comfortable with a large fraction of that will take awhile. There are probably a half-dozen modules that you'll need to master fairly quickly and pass on to your students, however: sys, string and os come to mind as well as several of the builtin functions (available also via the module __builtin__ and referred to in the library manual that way), and perhaps re and time. Aaron> Secondly, if I choose to use Python for this, I would like to Aaron> supply each student with a reference book on Python. >From what I've seen on the list, Learning Python sounds like a more appropriate book for first-time programmers, though I've personally not seen it. Also, I would think that others, like me, who learned Python well before any books were available and already knew other languages might be ill-equipped to make unbiased recommendations in this area. I have PP, and while it is an excellently written book, I'd grown so used to using the online docs, scanning the newsgroup archives and browsing source code that I didn't find it added much to my existing sources of information, so I've rarely used it. You might want to scan through the reviews of both books at Amazon.com to see what others have to say. Finally, you might want to check out Guido van Rossum's Computer Programming for Everybody (CP4E) project at http://www.python.org/doc/essays/cp4e.html Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/ 847-971-7098 | Python: Programming the way Guido indented... From emuller at painewebber.com Thu Nov 11 19:33:32 1999 From: emuller at painewebber.com (emuller at painewebber.com) Date: Fri, 12 Nov 1999 00:33:32 GMT Subject: Win32: CreateProcess wsetup program problem References: <80fkki$kmg$1@nnrp1.deja.com> Message-ID: <80fn8s$mls$1@nnrp1.deja.com> I've also discoverd that winbatch's RunWait Function does not exhibit this behavior. In article <80fkki$kmg$1 at nnrp1.deja.com>, emuller at painewebber.com wrote: > I wrote a wrapper to CreateProcess that runs a program with args and > waits until it ends. It works great for most programs (ie..calc, > notepad, net, etc, etc, etc), but when I use it to run a setup.exe > program (NAV 5.0 to be exact), the setup program starts and an exit > value of 0 is returned to me, but the setup program just started. I > figure that the setup program is doing something, then spawning another > process to do the install (a _SETUP.EXE..something or other) and > detaching itself from that process, letting it just run on.... > > Is there anyone out there who knows how I can pause until that other > program (or whatever happens) is done? > > I am using the following code in a module called win32helper.py > (BTW: If anyone would like to use this code, go ahead. I hope to write > a bunch of helper functions and put them here, then post them someday) > > import win32api > import win32security > import win32process > import pywintypes > import win32con > import win32event > > def RunWait(cmd, args=""): > pHandle, tHandle, pId, tId = win32process.CreateProcess (cmd," " > + args,None,None,0,0,None,None,win32process.STARTUPINFO()) > win32event.WaitForSingleObject(pHandle,win32event.INFINITE) > exitCode = win32process.GetExitCodeProcess(pHandle) > win32api.CloseHandle(pHandle) > win32api.CloseHandle(tHandle) > return exitCode > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From skaller at maxtal.com.au Tue Nov 30 08:52:05 1999 From: skaller at maxtal.com.au (skaller) Date: Wed, 01 Dec 1999 00:52:05 +1100 Subject: Python complaints References: <81bmmi$279$1@nnrp1.deja.com> <3841EE77.6B5D6AC9@wjk.mv.com> Message-ID: <3843D685.C8C13355@maxtal.com.au> Will Ware wrote: > > William J. King (wjk at wjk.mv.com) wrote: > : 4. conversion of integer to a string ( which may exist but havn't found > : yet) > > Try this: > str(123) > or: > hex(123) > > : 2. would like something like 'increment'/'decrement' operators > : either in form: > : "x++" or "incr x" vice "x = x + 1 " but its ok > > I find myself grumbling about having to type "x = x + 1". The really > clean thing to do, given that integers are objects, would be to define > increment and decrement methods, so you'd type something like "i.incr()". Integers are NOT objects in Python, they're values. Same for strings and tuples. We can pretend they're objects, and say they're 'immutable', but the truth is that they're just plain values. My new Viper interpreter may support 'mutable' integers and strings as follows: you write: x := 1 x++ x+=1 This notation actually creates a reference (pointer) to the value, so x is a 'reference to an integer', and x++ actually means: x := x + 1 To see the difference consider: a = 1 x := a x++ print a,x and you will get 1,2. The integer value a is bound to is still immutable and cannot be changed. x++, on the other hand, does not increment what x refers to, rather it replaces what x refers to by the old value plus 1. References in 'rvalue' contexts convert automatically to the designated value, but when used on the LHS the distinction between a reference to a value, and a value is preserved. [References can be used with any type, but they're not quite as useful with tuples (since there is a mutable list already) or with class instance objects (since they're already mutable). Comments on this idea appreciated. -- John Skaller, mailto:skaller at maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia homepage: http://www.maxtal.com.au/~skaller voice: 61-2-9660-0850 From AKiss at GEOMETRIA.hu Tue Nov 16 07:57:10 1999 From: AKiss at GEOMETRIA.hu (Kiss, Arpad) Date: Tue, 16 Nov 1999 13:57:10 +0100 Subject: Alright, I give up...chalk this one up to experience... Message-ID: <01BF303A.7AFA1770@exchange1.geometria.hu> Hi, Maybe date is waiting for your new date setting, but why don't you use time instead of it: import time print time.ctime(time.time()) print time.localtime(time.time()) Arpad Kiss Endgamer wrote in message news:<383145c0.4445469 at 212.225.36.99>... > Alright, I finally give up. I've been bashing at this bloody idea all > week...maybe I'm incredibly stupid (probably), but I can't see why, > when I run this as a script from Windows 95, it doesn't return the > current date setting on my machine. Could somebody put me out of my > misery? I promise I'll stop bothering you . > > ------------------------------------------------------- > > # Date setting program (chunk 1) > import os > > olddate=os.popen("date",'r') > > olddate=readdate > > print olddate > > ------------------------------------------------------- > > > Endgamer > Spider Warrior From I.Clarke at strs.co.uk Tue Nov 30 09:55:20 1999 From: I.Clarke at strs.co.uk (Ian Clarke) Date: Tue, 30 Nov 1999 14:55:20 +0000 Subject: Python Make Message-ID: <3843E558.8AC91A97@strs.co.uk> Hi, just a quick idea I had that I wanted to share with the newsgroup. Has anyone considered using Python as a replacement for the "make" utility? A module could be provided which did several small things like testing modification times of a list of source files against a destination file to see whether an update was required. I am prompted to suggest this after spending yet another half-day trying to debug a Makefile. What do people think? Ian. -- Ian Clarke Email: I.Clarke at strs.co.uk Homepage: http://www.gnu.demon.co.uk/ Also see: http://freenet.on.openprojects.net/ "All we see and all we seem is but a dream within a dream" From wheinemanNOwhSPAM at uconect.net.invalid Sat Nov 13 01:16:15 1999 From: wheinemanNOwhSPAM at uconect.net.invalid (wheineman) Date: Fri, 12 Nov 1999 22:16:15 -0800 Subject: Win32 API Communication Functions Module Message-ID: <09920fb9.076b8f52@usw-ex0102-013.remarq.com> I have Swigged the Win32 API Communication Functions and data structures into a module. I've tested it on Windows 9x and NT4.0 with Pythonwin 127. An example console terminal application is provided. The module can be found at http://www.uconect.net/~wheineman/python/win32comm.zip. I hope this is useful to everyone looking for advanced serial port capabilities on Win32 platforms. * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free! From phd at phd.russ.ru Sat Nov 6 06:34:44 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Sat, 6 Nov 1999 11:34:44 +0000 (GMT) Subject: smtplib.py how to ? In-Reply-To: <38237da0.3456244@news.force9.net> Message-ID: On Sat, 6 Nov 1999, Colm Rafferty wrote: > import smtplib > s=smtplib.SMTP("localhost") > tolist=["cgr at formulae.co.uk","c.rafferty at virgin.net","cgr at pangea.co.uk"] > msg = ''' > From: test at my.org > Subject: testin'... > > This is a first test ''' > > s.sendmail("me at mydomain.co.uk",tolist,msg) > s.quit() You've inserted empty line, so sendmail recognized it as "end of headers". Do this way: vvvvv - no empty line here msg = '''From: test at my.org Subject: testin'... This is a first test ''' or this: vvvv msg = '''\ From: test at my.org Subject: testin'... This is a first test ''' Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From mlh at vier.idi.ntnu.no Fri Nov 5 09:29:11 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 05 Nov 1999 15:29:11 +0100 Subject: Drawing (directed) graphs References: <000a01bf2792$b83ff150$3acbd9c2@peridot.optichrome.com> <14370.59564.979979.285996@gargle.gargle.HOWL> Message-ID: Charles G Waldman writes: > Magnus L. Hetland writes: [...] > > Even on Minix you could easily generate jpegs, or postscript files or > > whatever with Piddle. If you can't run an X server or something, that > > only means that you can't see it... Or maybe you have a printer? > > Or for maximum portatbility, you could use the "aa" ascii-art library > to display the images on an ASCII terminal.... it's a C library, but > it would be trivial to SWIG up a set of Python bindings, if this > hasn't been done yet. Excellennt suggestion :) A nice backend for PIDDLE... Any takers? -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From wlfraed at ix.netcom.com Fri Nov 26 20:54:11 1999 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Fri, 26 Nov 1999 17:54:11 -0800 Subject: Python complaints References: <86so1v4jlj.fsf@g.local> <81ksj6$lif$1@nntp9.atl.mindspring.net> Message-ID: On 26 Nov 1999 02:51:18 GMT, aahz at netcom.com (Aahz Maruch) declaimed the following in comp.lang.python: > In article , > Markus Stenberg wrote: > > > >From trivial example - do you consider (+ 2 (* 3 4)) more readable than 2 + > >3 * 4 most languages (including Dylan) allow me to do? > > I think that should be written as "3 4 * 2 +". ;-) Taking it in the order the old HP manuals (and my old compiler class) taught... 2 3 4 * + -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From ionel at psy.uva.nl Thu Nov 18 08:41:37 1999 From: ionel at psy.uva.nl (Ionel Simionescu) Date: Thu, 18 Nov 1999 14:41:37 +0100 Subject: Comparing Python to (free) Math languages/environments References: <19991118014716.13748.00000334@ng-bj1.aol.com> Message-ID: <810vjh$7et@mail.psy.uva.nl> Dparsavand wrote in message news:19991118014716.13748.00000334 at ng-bj1.aol.com... | I've browsed some interesting links from www.python.org and I have played just | a little with Python and Scilab. I have used Matlab a fair amount in school | and find Octave to be a reasonable replacement. I'm curious if anyone has used | any free Math scripting language or Math environment (Rlab, Scilab, Octave, | others?) as well as Python and might care to compare them. | | I tried to compare Octave to Python in terms of speed by producing some random | vectors and taking FFT's and Python seemed to by about twice as fast. However, | I'm not too keen on the syntax of Python for some things compared to Octave | (e.g. A*B vs. matrixmultiply(A,B)). I read that one frustration with Matlab | (and I imagine Octave as well) is the limit to two-dimensional arrays, which | has bugged me in the past. | | I also read the CP4E proposal, and I can definitely relate to the part about | how nice it would be to be able to modify the code in my GPS unit (mine drives | me crazy). Python sounds great for these type of things, but does it really | make the best Math language? | Hi, Python is a very nice language, to the extent it may be addicting. However, the suitability of a certain language for a certain task, is also determined by the availability of specialized libraries. The support for (possibly multi-dimensional, heterogeneous) array manipulation, some numerically intensive jobs and scientific visualization is very good in the Python library. (See, the relevant SIGs (Special Interest Groups) for pointers.) However, this support is pretty generic. If you have very specialized problems in fields such as DSP, ODE's, Kalman filtering, time series, advanced statistics, then you better use one of the field experts: MATLAB/Mathematica/O-Matrix/Scilab/Octave/Gauss/Mathcad/etc. "Better" does not mean that you'll be very happy coding, but you will get *safer* results *faster*. You shall also find a lot more support in those communities to your job specific problems. If your problem can not benefit much from existing solutions, then Welcome!, Python will provide you the means to solve your problem. As you mentioned performance issues, allow me to notice that, indeed, you can code in Python such as to beat MATLAB, but you will still lag behind C/C++/Fortran. If speed is essential you should be prepared to consider your Python code a prototype and translate it to a lower-level, optimized implementation. Very often, the < design&test with Python -implement with C/C++ > approach it's still the fastest way to come with a solution. ionel PS MATLAB currently (5.#) supports multi-dimensional, heterogeneous arrays, data structures and even some form of OOP (actually, just function overloading). From idt at ornl.gov Mon Nov 1 13:48:07 1999 From: idt at ornl.gov (Russell W. Schmidt) Date: Mon, 01 Nov 1999 18:48:07 GMT Subject: Contribution: nice floating point number formatting References: <381a4316$0$209@nntp1.ba.best.com> <19991030063317.A16991@better.net> <7vhrfm$glv$1@vvs.superst.iae.nl> <19991101124124.A903@Ridcully.home> Message-ID: <7vkn97$8ts$1@sws1.ctd.ornl.gov> First off - thanks to the original contributor for a nice addition to my toolbox. In article <19991101124124.A903 at Ridcully.home>, "Malcolm Tredinnick" wrote: >On Sun, Oct 31, 1999 at 05:41:26PM +0100, Carel Fellinger wrote: >> And for the spaces in the decimal part, are you shure that is conventional? >> I can't remember having seen this *ever* in my life. At least not in my life >> as a programmer. > >There is a convention in some situations/places where the comma (or, in >Europe, the dot) is dropped entirely and a thin space is used (if you are >typesetting -- something smaller than a normal inter-word space). > >You will notice I have couched that last paragraph somewhat cautiously: my >recollection is that this situation (using spaces) is meant to be standard, >these days but since everybody is used to using commas, etc, they still >appear quite frequently. IMVHO, the spaces every three digits look nicer >than throwing a bunch of punctuation marks at the number. :-) > >(and if that doesn't start some sort of religious war, I don't know what >will.) :-) > The spaces every three digits, on both sides of the decimal point, are indeed part of an international standard, called the International System of Units (the Metric System to most Americans). You can fnd a US reference to it on the NIST (National Institute of Standards and Technology) web site. It is specifically called out in NIST Special Publication 811 (1995 Edition) "Guide for the Use of the International System of Units (SI)". See section 10.5.3, Grouping Digits. The authors note that chapter 10 is adapted in part from ISO 31-0 and ISO 31-11. I will not type in the whole section (pull it from NIST if you care), but the short summary in their "Check List for Reviewing Manuscripts" says: "The digits of numerical values having more than four digits on either side of the decimal marker are separated into groups of three using a thin, fixed space counting from both the left and right of the decimal marker. For example, 15 739.012 53 is highly preferred to 15739.01253. Commas are not to be used to separate digits into groups of three." -- Russ Schmidt (idt at ornl.gov) Lockheed Martin Energy Systems, Inc. Oak Ridge, Tennessee 37831-2009 From gerrit.holl at pobox.com Wed Nov 10 11:12:56 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Wed, 10 Nov 1999 17:12:56 +0100 Subject: Intelligent strptime? Message-ID: <19991110171256.A5196@optiplex.palga.uucp> Hello, Does there exist an intelligent strptime? "26/11/99", for example, can _only_ mean the 26th November of this year, and the chance that "14:11:12" means 14 november 1912 is very small. Is there a module/function that guesses the format? There isn't doubt very often, only for 12/11/99, US is 11 december, Europe is 12 November (isn't it?). regards, Gerrit. From greg.ewing at compaq.com Fri Nov 19 04:15:45 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Fri, 19 Nov 1999 22:15:45 +1300 Subject: Type/Class Unification in Ruby References: <3819BCDA.AC4FD4CA@strs.co.uk> <87k8o2x67f.fsf@ev.netlab.co.jp> <7vjtrc$hmm$1@newshost.accu.uu.nl> <38204614.2EAC6051@compaq.com> <5ld7trtak5.fsf@eric.cnri.reston.va.us> <3826D63C.2731BB1F@compaq.com> <38328948.9E35556F@compaq.com> Message-ID: <38351541.FD1EBDEF@compaq.com> Clemens Hintze wrote: > > But it is worth mentioning, that Ruby features > single inheritance *by*purpose*. Not because of the implementation > details! I wasn't making a value judgement, only pointing out that Ruby's solution is as simple as it is because of this restriction. > If it would implement multi-inheritance, the class structure could > e.g. use an array of pointer to all such C structs, not only one > pointer, as implemented now! Sure, Python could do something like that too. But it would get very hairy and complicated and probably slow everything down a lot, casting doubt on whether it's worth the effort. A middle ground might be to allow inheriting from any number of user-defined classes, but at most one built-in type. > The second (preferred) way is, to build instances of class DATA > wrapping the C struct you have allocated for your extension. Yes, I know, but what I was saying still applies in that case. All the methods of the extension class expect the DATA object to be pointing to their own particular kind of struct, and because of the inheritance structure, this is always true -- so they don't need to bother checking. > Deriving a Ruby class coded in C from another one also coded in C, > seems to be the only right tricky part of that language, IMHO. :-) I think it will work as long as the derived class makes sure that its C structure is an exension of the superclass's C structure. > Greg> [global instance var dict] might cause ref counting > Greg> problems. > > Once again, thanks for Ruby's true garbage collection! :-) Garbage collection alone doesn't actually solve the problem; the references from the global dict need to be treated as weak references somehow under either scheme. I haven't looked, but presumably Ruby must be ignoring the global dict refs when marking, and cleaning them up whenever a builtin or extension object is deallocated. Python could be made to do the equivalent. > The big exception, > AFAIK, was class Fixnum. It never had any instanciation method, as it > doesn't wrap any struct. Yes, that's the one class you really can't instantiate a subclass of, since its class is totally implicit. But it's not clear whether it's any use having something like a UserFlonum, either, even though technically it could be done. Unless you override every method, any arithmetic on it would return an ordinary Flonum. And if you are going to override every method, it might as well be a totally new class! > Often it is better to use the module > mechanism to add methods to class Array or some of its instances > during runtime. You mean you can add methods to an *existing* class that way? Not sure if I like that idea... Greg From kuntsi at cc.helsinki.fi.spam.no Tue Nov 16 05:10:07 1999 From: kuntsi at cc.helsinki.fi.spam.no (Antti Kuntsi) Date: 16 Nov 1999 10:10:07 GMT Subject: Memory not being released? References: <1269432569-4253767@hypernet.com> Message-ID: Gordon McMillan sepusti: > Steve Tregidgo writes: > > I have a process (goes up to 250+ MB, cue lots of virtual memory > > usage and hence slowdown), which busies the server so much that > > it just can't bring itself to do other things -- in other words > > it's severely impractical. > That's a pretty good sign that you have circular references that > are keeping objects alive. Check out Cyclops from > ftp://ftp.python.org/pub/python/contrib/System/. I had similar problem just a while ago, and Cyclops helped a lot. But it didn't solve the whole problem, as it was not python's fault, but a Linux library glibc was functioning improperly. If you are running RedHat 6.0 and/or have glibc version 2.1.1, you should upgrade asap. Upgrading to 2.1.2 the bloating dissappeared and everything has worked nicely ever since. Antti Kuntsi -- ______________________________________________________________ |O| ---------------------------------------------------------- | | |Twisted mind? No, just bent in several strategic places.| `\| |___________________________________mickut at iki.fi/mickut/| From edwardm_painewebber at my-deja.com Fri Nov 12 10:01:32 1999 From: edwardm_painewebber at my-deja.com (edwardm_painewebber at my-deja.com) Date: Fri, 12 Nov 1999 15:01:32 GMT Subject: .dll and .exe file version informaton References: <816010E2456BD111A48700805FBBE2EEFDF793@ex-quebec-u1.baan.com> Message-ID: <80ha4a$pmg$1@nnrp1.deja.com> It looks like they are not available yet.... In article <816010E2456BD111A48700805FBBE2EEFDF793 at ex-quebec- u1.baan.com>, Gaetan Corneau wrote: > > go-ahead-just-*try*-to-write-a-program-to-do-that-ly y'rs - tim > > If you really want to do it in a program, take a look at the following > functions in the help: > GetFileVersionInfo > VerQueryValue > QueryField > > You wil find all this stuff crappy, but it works. > ______________________________________________________ > Gaetan Corneau > Software Developer (Quality Assurance Team) > BaaN Supply Chain Solutions > E-mail: Gaetan_Corneau at baan.com > Compuserve: Gaetan_Corneau at compuserve.com > ICQ Number: 7395494 > Tel: (418) 266-8252 > ______________________________________________________ > "Profanity is the one language all programmers know best" > > Sent via Deja.com http://www.deja.com/ Before you buy. From pinard at iro.umontreal.ca Tue Nov 2 09:27:46 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 02 Nov 1999 09:27:46 -0500 Subject: Printing strings In-Reply-To: Matthew Hirsch's message of "Tue, 02 Nov 1999 10:18:59 -0500" References: <381F00E1.721BB47F@cornell.edu> Message-ID: Matthew Hirsch writes: > a=4.0 > b=2.0 > print '2(%3.1f)' % a,b > where I really mean > print '%3.1f %3.1f' % a,b > but it's printing > 2(4.0) 2.0 > Is there a way of doing this so I don't have to write out %3.1f, > multiple times? Maybe you could play around this idea? >>> a, b = 4.0, 2.0 >>> print '%4.1f' * 2 % (a, b) 4.0 2.0 I changed `%3.1f' into `%4.1f' because `4.02.0' would not look nice.) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From phd at phd.russ.ru Tue Nov 16 11:45:38 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Tue, 16 Nov 1999 16:45:38 +0000 (GMT) Subject: Anyway to use file masks with os.listdir()? In-Reply-To: Message-ID: On Tue, 16 Nov 1999, Aaron J Reichow wrote: > Is there any way to pass a filemask to os.listdir()? For example, to list > only files with the extension .jpg. Any help would be appreciated! :) Module fnmatch.py is your friend. Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From matz at netlab.co.jp Sun Nov 7 21:26:30 1999 From: matz at netlab.co.jp (Yukihiro Matsumoto) Date: 08 Nov 1999 11:26:30 +0900 Subject: A Comparison of Python and Ruby Extension Interfaces (Re: Comparison between Python and "Ruby") References: <3819BCDA.AC4FD4CA@strs.co.uk> <87k8o2x67f.fsf@ev.netlab.co.jp> <7vjtrc$hmm$1@newshost.accu.uu.nl> <38204614.2EAC6051@compaq.com> <021119992327527678%pereira@research.att.com> <38215CE7.70C3D560@compaq.com> Message-ID: <87vh7du3ah.fsf@ev.netlab.co.jp> Toby Dickenson writes: |>It uses setjmp/longjmp. Presumably these work correctly on |>any system where they are implemented. Porting Ruby to a |>system where they're not implemented could be difficult. |> | |Presumably this makes it difficult for Ruby extensions to use C++? I don't think so. Some extensions for Ruby are written in C++ (e.g. MySQL interface) without problems. matz. From philh at vision25.demon.co.uk Mon Nov 15 20:57:23 1999 From: philh at vision25.demon.co.uk (Phil Hunt) Date: Tue, 16 Nov 99 01:57:23 GMT Subject: __str__ vs. __repr__ References: <000001bf275c$02370d20$1d2d153f@tim> <7vvni7$19q0$1@nntp6.u.washington.edu> <382BEC79.EC65913D@maxtal.com.au> <382C6430.8DC07E3E@lemburg.com> <01fd01bf2dce$d2c03cf0$f29b12c2@secret.pythonware.com> <942499879snz@vision25.demon.co.uk> Message-ID: <942717443snz@vision25.demon.co.uk> In article mwh21 at cam.ac.uk "Michael Hudson" writes: > philh at vision25.demon.co.uk (Phil Hunt) writes: > > > In article <01fd01bf2dce$d2c03cf0$f29b12c2 at secret.pythonware.com> > > fredrik at pythonware.com "Fredrik Lundh" writes: > > > 2) what's the reason byte code cannot be used to recover > > > the original source code > > > > Perhaps because two different (but obviously functionally > > identical and very similar) source codes could produce the same > > byte code. > > I doubt it actually. Python's bytecode is really pretty high > level. Leastaways, I can't think of any examples. How about: x = a + b + c x = (a + b) + c x=a+b+c I'd guess these all produce the same bytecode. I'd also not be surprised if you could consistently change the name of a local variable within a function without changing bytecodes, i.e. Python internally doesn't know the names of local variables. > It's one of those things I might get round to writing one of these > days. I don't really know how hard it would be. Not especially, I > suspect. You might want to have a look at how Java bytecode decompilers work. -- Phil Hunt - - - - - - - - - philh at vision25.demon.co.uk Moore's Law: processor speed doubles every 18 months Gates' Law: software speed halves every 18 months From a.eyre at optichrome.com Thu Nov 25 09:05:02 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Thu, 25 Nov 1999 14:05:02 -0000 Subject: decompress a bunch of .gz files In-Reply-To: <81jc8i$ilp$1@nnrp1.deja.com> Message-ID: <000501bf374e$116bafb0$3acbd9c2@peridot.optichrome.com> > I'm searching for a way to decompress all .gz > files in a directory automatically. Unix: #!/bin/sh for file in *.gz; do gunzip $file; done Dos: @echo off for %%file in (*.gz) do gunzip %%file -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From edwardam at home.com Tue Nov 30 00:10:09 1999 From: edwardam at home.com (Edward Muller) Date: Tue, 30 Nov 1999 05:10:09 GMT Subject: SMTP References: <19991126095821.87186.qmail@hotmail.com> <38401AD2.31396C84@wjk.mv.com> Message-ID: <38435C2D.435B3986@home.com> "William J. King" wrote: > Was just looking at an interesting program called Rebol which does some > interesting things with mail/ftp etc. http://www.rebol.com - handles > various protocols etc. A scripting communications/messaging language.. > hope I got that correct.. Sassenfrath of Amiga fame is source. > > This might be yet another simple solution for SMTP area. Have ever tried to understand a long Rebol Script? I've tried. I thought it was really great at first, but then got a BIG headache. Python is much easier to read From Gaetan_Corneau at baan.com Tue Nov 16 17:12:54 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Tue, 16 Nov 1999 17:12:54 -0500 Subject: Time object (COM) Message-ID: <816010E2456BD111A48700805FBBE2EEFDF7D7@ex-quebec-u1.baan.com> Hi, Sorry to ask this again, I can't find the e-mails I received when I first asked :( I have a COM object with a property that looks like this when I print it: